· 7 years ago · Oct 10, 2018, 03:06 PM
1FUNCTION UpdateRatioSizeBucket
2 LPARAMETERS pnPKey, pnSizeBucket, pnQty_Change, pnCoeff && 1014475 12/27/05 YIK
3
4 *- 1014475 12/27/05 YIK
5 *- We may need to increase qty if we add qty for one UPC along with deleting/decreasing qty
6 *- for another. Added pnCoeff to handle that.
7 SELECT VzzoUnits_Ratio_Confirm
8 LOCATE FOR pkey = pnPKey
9 IF FOUND()
10 DO CASE
11 CASE tcEiPCtd.Sizebucket = 1
12 REPLACE ;
13 Size01_Qty WITH Size01_Qty - pnCoeff*pnQty_Change, ;
14 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
15 IN VzzoUnits_Ratio_Confirm
16
17 CASE tcEiPCtd.Sizebucket = 2
18 REPLACE ;
19 Size02_Qty WITH Size02_Qty - pnCoeff*pnQty_Change, ;
20 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
21 IN VzzoUnits_Ratio_Confirm
22
23 CASE tcEiPCtd.Sizebucket = 3
24 REPLACE ;
25 Size03_Qty WITH Size03_Qty - pnCoeff*pnQty_Change, ;
26 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
27 IN VzzoUnits_Ratio_Confirm
28
29 CASE tcEiPCtd.Sizebucket = 4
30 REPLACE ;
31 Size04_Qty WITH Size04_Qty - pnCoeff*pnQty_Change, ;
32 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
33 IN VzzoUnits_Ratio_Confirm
34
35 CASE tcEiPCtd.Sizebucket = 5
36 REPLACE ;
37 Size05_Qty WITH Size05_Qty - pnCoeff*pnQty_Change, ;
38 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
39 IN VzzoUnits_Ratio_Confirm
40
41 CASE tcEiPCtd.Sizebucket = 6
42 REPLACE ;
43 Size06_Qty WITH Size06_Qty - pnCoeff*pnQty_Change, ;
44 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
45 IN VzzoUnits_Ratio_Confirm
46
47 CASE tcEiPCtd.Sizebucket = 7
48 REPLACE ;
49 Size07_Qty WITH Size07_Qty - pnCoeff*pnQty_Change, ;
50 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
51 IN VzzoUnits_Ratio_Confirm
52
53 CASE tcEiPCtd.Sizebucket = 8
54 REPLACE ;
55 Size08_Qty WITH Size08_Qty - pnCoeff*pnQty_Change, ;
56 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
57 IN VzzoUnits_Ratio_Confirm
58
59 CASE tcEiPCtd.Sizebucket = 9
60 REPLACE ;
61 Size09_Qty WITH Size09_Qty - pnCoeff*pnQty_Change, ;
62 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
63 IN VzzoUnits_Ratio_Confirm
64
65 CASE tcEiPCtd.Sizebucket = 10
66 REPLACE ;
67 Size10_Qty WITH Size10_Qty - pnCoeff*pnQty_Change, ;
68 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
69 IN VzzoUnits_Ratio_Confirm
70
71 CASE tcEiPCtd.Sizebucket = 11
72 REPLACE ;
73 Size11_Qty WITH Size11_Qty - pnCoeff*pnQty_Change, ;
74 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
75 IN VzzoUnits_Ratio_Confirm
76
77 CASE tcEiPCtd.Sizebucket = 12
78 REPLACE ;
79 Size12_Qty WITH Size12_Qty - pnCoeff*pnQty_Change, ;
80 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
81 IN VzzoUnits_Ratio_Confirm
82
83 CASE tcEiPCtd.Sizebucket = 13
84 REPLACE ;
85 Size13_Qty WITH Size13_Qty - pnCoeff*pnQty_Change, ;
86 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
87 IN VzzoUnits_Ratio_Confirm
88
89 CASE tcEiPCtd.Sizebucket = 14
90 REPLACE ;
91 Size14_Qty WITH Size14_Qty - pnCoeff*pnQty_Change, ;
92 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
93 IN VzzoUnits_Ratio_Confirm
94
95 CASE tcEiPCtd.Sizebucket = 15
96 REPLACE ;
97 Size15_Qty WITH Size15_Qty - pnCoeff*pnQty_Change, ;
98 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
99 IN VzzoUnits_Ratio_Confirm
100
101 CASE tcEiPCtd.Sizebucket = 16
102 REPLACE ;
103 Size16_Qty WITH Size16_Qty - pnCoeff*pnQty_Change, ;
104 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
105 IN VzzoUnits_Ratio_Confirm
106
107 CASE tcEiPCtd.Sizebucket = 17
108 REPLACE ;
109 Size17_Qty WITH Size17_Qty - pnCoeff*pnQty_Change, ;
110 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
111 IN VzzoUnits_Ratio_Confirm
112
113 CASE tcEiPCtd.Sizebucket = 18
114 REPLACE ;
115 Size18_Qty WITH Size18_Qty - pnCoeff*pnQty_Change, ;
116 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
117 IN VzzoUnits_Ratio_Confirm
118
119 CASE tcEiPCtd.Sizebucket = 19
120 REPLACE ;
121 Size19_Qty WITH Size19_Qty - pnCoeff*pnQty_Change, ;
122 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
123 IN VzzoUnits_Ratio_Confirm
124
125 CASE tcEiPCtd.Sizebucket = 20
126 REPLACE ;
127 Size20_Qty WITH Size20_Qty - pnCoeff*pnQty_Change, ;
128 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
129 IN VzzoUnits_Ratio_Confirm
130
131 CASE tcEiPCtd.Sizebucket = 21
132 REPLACE ;
133 Size21_Qty WITH Size21_Qty - pnCoeff*pnQty_Change, ;
134 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
135 IN VzzoUnits_Ratio_Confirm
136
137 CASE tcEiPCtd.Sizebucket = 22
138 REPLACE ;
139 Size22_Qty WITH Size22_Qty - pnCoeff*pnQty_Change, ;
140 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
141 IN VzzoUnits_Ratio_Confirm
142
143 CASE tcEiPCtd.Sizebucket = 23
144 REPLACE ;
145 Size23_Qty WITH Size23_Qty - pnCoeff*pnQty_Change, ;
146 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
147 IN VzzoUnits_Ratio_Confirm
148
149 CASE tcEiPCtd.Sizebucket = 24
150 REPLACE ;
151 Size24_Qty WITH Size24_Qty - pnCoeff*pnQty_Change, ;
152 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
153 IN VzzoUnits_Ratio_Confirm
154 ENDCASE
155 ENDIF
156 ENDFUNC
157
158 * ===============================================
159
160 FUNCTION RecordError
161 LPARAMETERS pcErrorMessage
162
163 * Record error in tceipctd.errs_msg_d, errs_flg_d / tceipcth.errs_msg_d / errs_flg_d:
164 *- 1014475 12/28/05 YIK
165 *- Append new error message to the existing.
166 SELECT tcEiPCtd
167 REPLACE ;
168 Errs_Msg_D WITH Errs_Msg_D + pcErrorMessage + CHR(10) + CHR(13), ;
169 Errs_Flg_D WITH "Y" ;
170 IN tcEiPCtd
171
172 SELECT tcEiPCth
173 REPLACE ;
174 Errs_msg_H WITH Errs_msg_H + pcErrorMessage + CHR(10) + CHR(13), ;
175 Errs_flg_h WITH "Y" ;
176 IN tcEiPCth
177
178 THIS.lUpdate860Records = .T.
179
180 ENDFUNC
181
182 * ===============================================
183
184 PROCEDURE CancelSO
185 LPARAMETERS pcCncl_Rsn, pcCncl_Type
186 LOCAL llRetVal
187 * Cancels an entire Sales Order.
188
189 * Create blank record in ratio cursor for each line item in SO detail:
190 * NOTE: Vzzounits_Ratio_860I has been freshly created for POC_Purp = "01"
191 SELECT Vzzoordrd_860I
192
193 SCAN
194 SELECT VzzoUnits_Ratio_Confirm
195 APPEND BLANK
196 *- 1014475 12/21/05 YIK
197 *- Replaced "Last_Mod WITH DATETIME()"
198 REPLACE ;
199 pkey WITH Vzzoordrd_860I.pkey, ;
200 fkey WITH Vzzoordrd_860I.fkey, ;
201 Last_mod WITH Vzzoordrd_860I.Last_mod ;
202 IN VzzoUnits_Ratio_Confirm
203 ENDSCAN
204
205 WITH THIS
206 llRetVal = .oBPOCancel.ProcessCancelByOrder(Vzzoordrh_860I.pkey)
207
208 IF llRetVal
209 .lUpdateSalesOrder = false
210 .lUpdate860Records = false
211 .lDelete860Records = true
212 .lOneDetailLineBad = false
213 .lUpdateCancelViews = true
214 ELSE
215 .RecordError("Could not perform cancellation.")
216 .lUpdate860Records = true
217 .lUpdateCancelViews = false
218 ENDIF
219 ENDWITH
220
221 ENDPROC
222
223 * ===============================================
224
225 FUNCTION GetQtyFromSizeBucket
226 LPARAMETERS pnSizeBucket
227 LOCAL lnRetVal
228
229 lnRetVal = 0
230
231 DO CASE
232 CASE pnSizeBucket = 1
233 lnRetVal = Vzzoordrd_860I.Size01_Qty
234
235 CASE pnSizeBucket = 2
236 lnRetVal = Vzzoordrd_860I.Size02_Qty
237
238 CASE pnSizeBucket = 3
239 lnRetVal = Vzzoordrd_860I.Size03_Qty
240
241 CASE pnSizeBucket = 4
242 lnRetVal = Vzzoordrd_860I.Size04_Qty
243
244 CASE pnSizeBucket = 5
245 lnRetVal = Vzzoordrd_860I.Size05_Qty
246
247 CASE pnSizeBucket = 6
248 lnRetVal = Vzzoordrd_860I.Size06_Qty
249
250 CASE pnSizeBucket = 7
251 lnRetVal = Vzzoordrd_860I.Size07_Qty
252
253 CASE pnSizeBucket = 8
254 lnRetVal = Vzzoordrd_860I.Size08_Qty
255
256 CASE pnSizeBucket = 9
257 lnRetVal = Vzzoordrd_860I.Size09_Qty
258
259 CASE pnSizeBucket = 10
260 lnRetVal = Vzzoordrd_860I.Size10_Qty
261
262 CASE pnSizeBucket = 11
263 lnRetVal = Vzzoordrd_860I.Size11_Qty
264
265 CASE pnSizeBucket = 12
266 lnRetVal = Vzzoordrd_860I.Size12_Qty
267
268 CASE pnSizeBucket = 13
269 lnRetVal = Vzzoordrd_860I.Size13_Qty
270
271 CASE pnSizeBucket = 14
272 lnRetVal = Vzzoordrd_860I.Size14_Qty
273
274 CASE pnSizeBucket = 15
275 lnRetVal = Vzzoordrd_860I.Size15_Qty
276
277 CASE pnSizeBucket = 16
278 lnRetVal = Vzzoordrd_860I.Size16_Qty
279
280 CASE pnSizeBucket = 17
281 lnRetVal = Vzzoordrd_860I.Size17_Qty
282
283 CASE pnSizeBucket = 18
284 lnRetVal = Vzzoordrd_860I.Size18_Qty
285
286 CASE pnSizeBucket = 19
287 lnRetVal = Vzzoordrd_860I.Size19_Qty
288
289 CASE pnSizeBucket = 20
290 lnRetVal = Vzzoordrd_860I.Size20_Qty
291
292 CASE pnSizeBucket = 21
293 lnRetVal = Vzzoordrd_860I.Size21_Qty
294
295 CASE pnSizeBucket = 22
296 lnRetVal = Vzzoordrd_860I.Size22_Qty
297
298 CASE pnSizeBucket = 23
299 lnRetVal = Vzzoordrd_860I.Size23_Qty
300
301 CASE pnSizeBucket = 24
302 lnRetVal = Vzzoordrd_860I.Size24_Qty
303
304 ENDCASE
305
306 RETURN lnRetVal
307 ENDFUNC
308 * ===============================================
309
310 FUNCTION ValidateDecrease
311 LPARAMETERS pnSizeBucket, pnQty_Change, pcQualifier
312 LOCAL llRetVal
313
314 * CB - All of the less than comparisons in this room were less than or equal to's.
315 * Removed the equal to because of a deadline (today) for ALPHA. Since DI's come through
316 * this same code, this would never work. We may want to add a property to the class -
317 * lWasDelete - and decide whether to do <= or < based on this. Currently a variable
318 * is set in ValidateDetail() that says that the line was a delete.
319
320 IF Vzzoordrd_860I.Total_Qty < pnQty_Change
321 RETURN .F.
322 ENDIF
323
324 llRetVal = .T.
325 DO CASE
326 CASE pnSizeBucket = 1
327 IF Vzzoordrd_860I.Size01_Qty < pnQty_Change
328 llRetVal = .F.
329 ENDIF
330 CASE pnSizeBucket = 2
331 IF Vzzoordrd_860I.Size02_Qty < pnQty_Change
332 llRetVal = .F.
333 ENDIF
334 CASE pnSizeBucket = 3
335 IF Vzzoordrd_860I.Size03_Qty < pnQty_Change
336 llRetVal = .F.
337 ENDIF
338 CASE pnSizeBucket = 4
339 IF Vzzoordrd_860I.Size04_Qty < pnQty_Change
340 llRetVal = .F.
341 ENDIF
342 CASE pnSizeBucket = 5
343 IF Vzzoordrd_860I.Size05_Qty < pnQty_Change
344 llRetVal = .F.
345 ENDIF
346 CASE pnSizeBucket = 6
347 IF Vzzoordrd_860I.Size06_Qty < pnQty_Change
348 llRetVal = .F.
349 ENDIF
350 CASE pnSizeBucket = 7
351 IF Vzzoordrd_860I.Size07_Qty < pnQty_Change
352 llRetVal = .F.
353 ENDIF
354 CASE pnSizeBucket = 8
355 IF Vzzoordrd_860I.Size08_Qty < pnQty_Change
356 llRetVal = .F.
357 ENDIF
358 CASE pnSizeBucket = 9
359 IF Vzzoordrd_860I.Size09_Qty < pnQty_Change
360 llRetVal = .F.
361 ENDIF
362 CASE pnSizeBucket = 10
363 IF Vzzoordrd_860I.Size10_Qty < pnQty_Change
364 llRetVal = .F.
365 ENDIF
366 CASE pnSizeBucket = 11
367 IF Vzzoordrd_860I.Size11_Qty < pnQty_Change
368 llRetVal = .F.
369 ENDIF
370 CASE pnSizeBucket = 12
371 IF Vzzoordrd_860I.Size12_Qty < pnQty_Change
372 llRetVal = .F.
373 ENDIF
374 CASE pnSizeBucket = 13
375 IF Vzzoordrd_860I.Size13_Qty < pnQty_Change
376 llRetVal = .F.
377 ENDIF
378 CASE pnSizeBucket = 14
379 IF Vzzoordrd_860I.Size14_Qty < pnQty_Change
380 llRetVal = .F.
381 ENDIF
382 CASE pnSizeBucket = 15
383 IF Vzzoordrd_860I.Size15_Qty < pnQty_Change
384 llRetVal = .F.
385 ENDIF
386 CASE pnSizeBucket = 16
387 IF Vzzoordrd_860I.Size16_Qty < pnQty_Change
388 llRetVal = .F.
389 ENDIF
390 CASE pnSizeBucket = 17
391 IF Vzzoordrd_860I.Size17_Qty < pnQty_Change
392 llRetVal = .F.
393 ENDIF
394 CASE pnSizeBucket = 18
395 IF Vzzoordrd_860I.Size18_Qty < pnQty_Change
396 llRetVal = .F.
397 ENDIF
398 CASE pnSizeBucket = 19
399 IF Vzzoordrd_860I.Size19_Qty < pnQty_Change
400 llRetVal = .F.
401 ENDIF
402 CASE pnSizeBucket = 20
403 IF Vzzoordrd_860I.Size20_Qty < pnQty_Change
404 llRetVal = .F.
405 ENDIF
406 CASE pnSizeBucket = 21
407 IF Vzzoordrd_860I.Size21_Qty < pnQty_Change
408 llRetVal = .F.
409 ENDIF
410 CASE pnSizeBucket = 22
411 IF Vzzoordrd_860I.Size22_Qty < pnQty_Change
412 llRetVal = .F.
413 ENDIF
414 CASE pnSizeBucket = 23
415 IF Vzzoordrd_860I.Size23_Qty < pnQty_Change
416 llRetVal = .F.
417 ENDIF
418 CASE pnSizeBucket = 24
419 IF Vzzoordrd_860I.Size24_Qty < pnQty_Change
420 llRetVal = .F.
421 ENDIF
422 ENDCASE
423
424 RETURN llRetVal
425 ENDFUNC
426
427 * ===============================================
428
429 FUNCTION UpdateSizeBucket
430 LPARAMETERS pnSizeBucket, pnQty_Change, pcQualifier
431
432 IF pcQualifier = "QD"
433 pnQty_Change = pnQty_Change * -1
434 ENDIF
435
436 DO CASE
437 CASE pnSizeBucket = 1
438 REPLACE ;
439 Size01_Qty WITH Size01_Qty + pnQty_Change ;
440 IN Vzzoordrd_860I
441 CASE pnSizeBucket = 2
442 REPLACE ;
443 Size02_Qty WITH Size02_Qty + pnQty_Change ;
444 IN Vzzoordrd_860I
445 CASE pnSizeBucket = 3
446 REPLACE ;
447 Size03_Qty WITH Size03_Qty + pnQty_Change ;
448 IN Vzzoordrd_860I
449 CASE pnSizeBucket = 4
450 REPLACE ;
451 Size04_Qty WITH Size04_Qty + pnQty_Change ;
452 IN Vzzoordrd_860I
453 CASE pnSizeBucket = 5
454 REPLACE ;
455 Size05_Qty WITH Size05_Qty + pnQty_Change ;
456 IN Vzzoordrd_860I
457 CASE pnSizeBucket = 6
458 REPLACE ;
459 Size06_Qty WITH Size06_Qty + pnQty_Change ;
460 IN Vzzoordrd_860I
461 CASE pnSizeBucket = 7
462 REPLACE ;
463 Size07_Qty WITH Size07_Qty + pnQty_Change ;
464 IN Vzzoordrd_860I
465 CASE pnSizeBucket = 8
466 REPLACE ;
467 Size08_Qty WITH Size08_Qty + pnQty_Change ;
468 IN Vzzoordrd_860I
469 CASE pnSizeBucket = 9
470 REPLACE ;
471 Size09_Qty WITH Size09_Qty + pnQty_Change ;
472 IN Vzzoordrd_860I
473 CASE pnSizeBucket = 10
474 REPLACE ;
475 Size10_Qty WITH Size10_Qty + pnQty_Change ;
476 IN Vzzoordrd_860I
477 CASE pnSizeBucket = 11
478 REPLACE ;
479 Size11_Qty WITH Size11_Qty + pnQty_Change ;
480 IN Vzzoordrd_860I
481 CASE pnSizeBucket = 12
482 REPLACE ;
483 Size12_Qty WITH Size12_Qty + pnQty_Change ;
484 IN Vzzoordrd_860I
485 CASE pnSizeBucket = 13
486 REPLACE ;
487 Size13_Qty WITH Size13_Qty + pnQty_Change ;
488 IN Vzzoordrd_860I
489 CASE pnSizeBucket = 14
490 REPLACE ;
491 Size14_Qty WITH Size14_Qty + pnQty_Change ;
492 IN Vzzoordrd_860I
493 CASE pnSizeBucket = 15
494 REPLACE ;
495 Size15_Qty WITH Size15_Qty + pnQty_Change ;
496 IN Vzzoordrd_860I
497 CASE pnSizeBucket = 16
498 REPLACE ;
499 Size16_Qty WITH Size16_Qty + pnQty_Change ;
500 IN Vzzoordrd_860I
501 CASE pnSizeBucket = 17
502 REPLACE ;
503 Size17_Qty WITH Size17_Qty + pnQty_Change ;
504 IN Vzzoordrd_860I
505 CASE pnSizeBucket = 18
506 REPLACE ;
507 Size18_Qty WITH Size18_Qty + pnQty_Change ;
508 IN Vzzoordrd_860I
509 CASE pnSizeBucket = 19
510 REPLACE ;
511 Size19_Qty WITH Size19_Qty + pnQty_Change ;
512 IN Vzzoordrd_860I
513 CASE pnSizeBucket = 20
514 REPLACE ;
515 Size20_Qty WITH Size20_Qty + pnQty_Change ;
516 IN Vzzoordrd_860I
517 CASE pnSizeBucket = 21
518 REPLACE ;
519 Size21_Qty WITH Size21_Qty + pnQty_Change ;
520 IN Vzzoordrd_860I
521 CASE pnSizeBucket = 22
522 REPLACE ;
523 Size22_Qty WITH Size22_Qty + pnQty_Change ;
524 IN Vzzoordrd_860I
525 CASE pnSizeBucket = 23
526 REPLACE ;
527 Size23_Qty WITH Size23_Qty + pnQty_Change ;
528 IN Vzzoordrd_860I
529 CASE pnSizeBucket = 24
530 REPLACE ;
531 Size24_Qty WITH Size24_Qty + pnQty_Change ;
532 IN Vzzoordrd_860I
533 ENDCASE
534 *- 1014475 12/21/05 YIK
535 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
536 *- and Vzzoordrd_860I
537
538 REPLACE ;
539 Total_Qty WITH Total_Qty + pnQty_Change, ;
540 User_id WITH goEnv.cUser ;
541 IN Vzzoordrd_860I
542
543 REPLACE ;
544 Ord_Qty WITH Ord_Qty + pnQty_Change, ;
545 User_id WITH goEnv.cUser ;
546 IN Vzzoordrh_860I
547 ENDFUNC
548
549 *=================================================
550
551 *!* Use this logic if we change the approach to all records in result set, and one table update, rather than
552 *!* requery/tableupdate one record at a time. NOTE: would have to add the index to the sales order header to
553 *!* make this work...
554 *!* FUNCTION FindCorrespondingSalesOrder
555 *!* LPARAMETERS pcDivision, pnPO_Num, pcStore, pcCustomer, plFindDetail
556
557 *!* LOCAL llRetVal, lnSelect
558
559 *!* llRetVal = .T.
560 *!* lnSelect = SELECT()
561
562 *!* SELECT Vzzoordrh_860I
563 *!* SEEK pcDivision + STR(pnPO_Num) + pcStore + pcCustomer
564 *!* IF FOUND()
565 *!* IF plFindDetail
566 *!* SELECT Vzzoordrd_860I
567 *!* SEEK Vzzoordrh_860I.PKey
568 *!* IF NOT FOUND()
569 *!* llRetVal = .F.
570 *!* ENDIF
571 *!* ENDIF
572 *!* ELSE
573 *!* llRetVal = .F.
574 *!* ENDIF
575 *!*
576 *!* SELECT (lnSelect)
577 *!* RETURN llRetVal
578 *!* ENDFUNC
579
580 *=================================================
581
582 FUNCTION IndexSalesOrder
583 LOCAL lnSelect
584
585 lnSelect = SELECT()
586
587 SELECT Vzzoordrh_860I
588 INDEX ON division + STR(PO_Num) + STORE + customer TAG sku
589 SET ORDER TO TAG sku
590
591 SELECT Vzzoordrd_860I
592 INDEX ON fkey TAG fkey
593 SET ORDER TO TAG fkey
594
595 SELECT (lnSelect)
596 ENDFUNC
597
598 *=================================================
599
600 FUNCTION CreateSOViews
601 * LPARAMETERS pcSQLFilterString
602 LOCAL llRetVal, lnSelect, lcSQLString
603
604 llRetVal = true
605 lnSelect = SELECT()
606
607 *!* pcSQLFilterString = IIF(EMPTY(pcSQLFilterString), "", " AND " + pcSQLFilterString)
608
609 *!* * Header table:
610 *!* lcSQLString = ;
611 *!* "SELECT * " + ;
612 *!* " FROM zzeipcth " + ;
613 *!* " WHERE (1=1) " + ;
614 *!* pcSQLFilterString
615
616 *!* llRetVal = v_SQLExec(lcSQLString, "tceipcth")
617
618 *!* * Detail table:
619 *!* lcSQLString = ;
620 *!* "SELECT * " + ;
621 *!* " FROM zzeipctd " + ;
622 *!* " WHERE FKey IN " + ;
623 *!* " (SELECT PKey " + ;
624 *!* " FROM zzeipcth " + ;
625 *!* " WHERE (1=1) " + ;
626 *!* pcSQLFilterString + ;
627 *!* ")"
628
629 *!* llRetVal = llRetVal AND v_SQLExec(lcSQLString, "tceipctd")
630
631 IF llRetVal
632 SELECT tcEiPCtd
633 INDEX ON fkey TAG fkey
634 SET ORDER TO TAG fkey
635 ENDIF
636
637 * Create views for Sales Order Header and Detail:
638 *- 1014975 12/21/05 YIK
639 *-- Add ..AND ord_status = 'O' otherwise if we have the same order
640 *- as Open and Pick - REQUERY fails with "Buffer..contains uncommited changes"
641 lcSQLString = ;
642 "SELECT * FROM zzoordrh " + ;
643 " WHERE Customer = ?pcCustomer " + ;
644 " AND PO_Num = ?pnPO_Num " + ;
645 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
646 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
647 " AND Ord_Status = 'O' "
648 *- 01/16/06 YIK
649 *- We may want to modify the view to allow picks also,
650 *- but check that the view creates only 1 header, i.e.
651 *- the entire order either open or picked, no partial pick allowed.
652 *- Cancels, of course are excluded.
653 *- Currently it is out of scope.
654 *- " AND (Ord_Status = 'O' OR Ord_Status = 'P')"
655
656 llRetVal = llRetVal AND THIS.CreateSQLView("Vzzoordrh_860I", lcSQLString)
657
658 lcSQLString = ;
659 "SELECT * FROM zzoordrd " + ;
660 " WHERE FKey IN " + ;
661 "(SELECT PKey FROM zzoordrh " + ;
662 " WHERE Customer = ?pcCustomer " + ;
663 " AND PO_Num = ?pnPO_Num " + ;
664 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
665 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
666 " AND Ord_Status = 'O') "
667 *- 01/16/06 YIK
668 *- see the comment above re: picked orders.
669 *- " AND (Ord_Status = 'O' OR Ord_Status = 'P') )"
670
671 llRetVal = llRetVal AND THIS.CreateSQLView("Vzzoordrd_860I", lcSQLString)
672
673 *--- TR 1016589 NH : SO Notes are in sysnotes table
674 lcSQLString = ;
675 "SELECT * FROM sysnotes " + ;
676 " WHERE table_name = 'ZZOORDRH' AND ord_num IN " + ;
677 "(SELECT ord_num FROM zzoordrh " + ;
678 " WHERE Customer = ?pcCustomer " + ;
679 " AND PO_Num = ?pnPO_Num " + ;
680 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
681 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
682 " AND Ord_Status = 'O') "
683
684 llRetVal = llRetVal AND THIS.CreateSQLView("Vnotes_zzoordrh_860I", lcSQLString)
685
686 lcSQLString = ;
687 "SELECT * FROM sysnotes " + ;
688 " WHERE table_name = 'ZZOORDRD' AND ord_num IN " + ;
689 "(SELECT ord_num FROM zzoordrH " + ;
690 " WHERE Customer = ?pcCustomer " + ;
691 " AND PO_Num = ?pnPO_Num " + ;
692 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
693 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
694 " AND Ord_Status = 'O') "
695
696 llRetVal = llRetVal AND THIS.CreateSQLView("Vnotes_zzoordrd_860I", lcSQLString)
697
698 *=== TR 1016589 NH
699
700 *--- TR 1016589 NH : Add opentable for order notes
701 llRetVal = llRetVal AND ;
702 THIS.OPENTABLE("Vzzoordrh_860I",,.F.) AND ;
703 THIS.OPENTABLE("Vzzoordrd_860I",,.F.) AND ;
704 THIS.OPENTABLE("Vnotes_zzoordrh_860I",,.F.) AND ;
705 THIS.OPENTABLE("Vnotes_zzoordrd_860I",,.F.)
706
707 .SetBufferMode("Vzzoordrh_860I", DB_BUFOPTRECORD)
708 SELECT Vzzoordrh_860I
709 INDEX ON pkey TAG pkey
710 *--- TR 1016589 NH
711 INDEX ON customer + division + po_num + store TAG OrdKey
712 *=== TR 1016589 NH
713 INDEX ON ord_num TAG ord_num
714 .SetBufferMode("Vzzoordrh_860I", DB_BUFOPTTABLE)
715
716 .SetBufferMode("Vzzoordrd_860I", DB_BUFOPTRECORD)
717 SELECT Vzzoordrd_860I
718 INDEX ON pkey TAG pkey
719 INDEX ON fkey TAG fkey
720 INDEX ON division + style + color_code + lbl_code + dimension TAG OUR_SKU
721 *---- TR 1019356 NH: typo - should be order detail instead of order header table buffering.
722 *.SetBufferMode("Vzzoordrh_860I", DB_BUFOPTTABLE)
723 .SetBufferMode("Vzzoordrd_860I", DB_BUFOPTTABLE)
724 *==== TR 1019356 NH
725 .SetBufferMode("Vnotes_zzoordrh_860I", DB_BUFOPTRECORD)
726 SELECT Vnotes_zzoordrh_860I
727 INDEX ON pkey TAG pkey
728 INDEX ON fkey TAG fkey
729 INDEX ON ord_num TAG ord_num
730 INDEX ON ALLTRIM(STR(ord_num)) + note_type TAG Ord_NTtyp
731 .SetBufferMode("Vnotes_zzoordrh_860I", DB_BUFOPTTABLE)
732
733 .SetBufferMode("Vnotes_zzoordrd_860I", DB_BUFOPTRECORD)
734 SELECT Vnotes_zzoordrd_860I
735 INDEX ON pkey TAG pkey
736 INDEX ON fkey TAG fkey
737 INDEX ON ALLTRIM(STR(FKEY)) + note_type TAG FkeyNT
738 .SetBufferMode("Vnotes_zzoordrd_860I", DB_BUFOPTTABLE)
739
740 *=== TR 1016589 NH
741
742 llRetVal = llRetVal AND THIS.oBPOCancel.DeclareViewsAndCursors()
743 SELECT (lnSelect)
744 RETURN llRetVal
745 ENDFUNC
746 *- 1014475 12/02/05 YIK
747 *--- TR 1016904 NH
748 PROCEDURE TableUpdateTransaction
749 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
750 *--- TR 1050827 24-NOV-2010 HNISAR && Added plSkipSLNUpdate
751 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
752 LPARAMETERS pceipcTH, pceipcTD, pceipcTC, pcVnotes_IPCH_iPCproc, pcVnotes_IPCD_iPCproc, ;
753 pceipcTS,plSkipSLNUpdate, pceipcTWHSE
754 LOCAL llRetVal, lcSQLDelete, lcTempTable&& TR 1016560 NH
755 llRetVal= .T.
756 lcSQLDelete = "" && TR 1016560 NH
757 WITH THIS
758 lcMessage= "Sending transaction records to server"
759 .InitThermo(1)
760 .UpdateThermoCaption(lcMessage + "...")
761 *--- TR 1016904 NH : increase dimension size from 3 to 5
762 * --- TR 1047609 7/7/10 CM --- Changed arrray from 5 to 6
763 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli Changed array from 6 to 8 ===
764 LOCAL laTables[8], llBeganTransaction
765 LOCAL llBeganTransaction, loEiPCth
766 LOCAL lceipcTH_temp, lceipcTD_temp ,lceipcTC_temp, lcSQL_eipcTH
767 LOCAL loEiPCth,loEiPCtd,loeipctc
768
769 laTables[1] = "VzzeiPCth_iPCproc"
770 laTables[2] = "VzzeiPCtc_iPCproc"
771 laTables[3] = "VzzeiPCtd_iPCproc"
772 *--- TR 1016904 NH
773 laTables[4] = pcVnotes_IPCH_iPCproc
774 laTables[5] = pcVnotes_IPCD_iPCproc
775 *=== TR 1016904 NH
776
777 * --- TR 1047609 7/7/10 CM
778 laTables[6] = "VzzeiPCts_iPCproc"
779 * === TR 1047609 7/7/10 CM
780
781 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
782 laTables[7] = "VzzeiPCtWhse_iPCproc"
783 laTables[8] = "VzzeiPCta_iPCproc"
784 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
785
786 SELECT(pceipcTH)
787 SCAN
788 SCATTER NAME loEiPCth MEMO
789 IF SEEK(loEiPCth.pkey,'Vzzeipcth_ipcproc','PKEY')
790 SELECT('Vzzeipcth_ipcproc')
791 GATHER NAME loEiPCth MEMO
792 *--- TR 1016904 NH -- need to add records for "DI" qualifier (ALL store)
793 ELSE
794 SELECT('Vzzeipcth_ipcproc')
795 APPEND BLANK
796 GATHER NAME loEiPCth MEMO
797 *=== TR 1016904 NH
798 ENDIF
799 ENDSCAN
800
801
802 SELECT(pceipcTD)
803 SCAN
804 SCATTER NAME loEiPCtd MEMO
805 IF SEEK(loEiPCtd.pkey,'Vzzeipctd_ipcproc','PKEY')
806 SELECT('Vzzeipctd_ipcproc')
807 GATHER NAME loEiPCtd MEMO
808 *--- TR 1016904 NH -- need to add records for "DI" qualifier (ALL store)
809 ELSE
810 SELECT('Vzzeipctd_ipcproc')
811 APPEND BLANK
812 GATHER NAME loEiPCtd MEMO
813 *=== TR 1016904 NH
814 ENDIF
815 ENDSCAN
816
817
818 *--- TR 1016560 NH
819 *--- delete record from history detail table for matching transaction detail pkey .
820 *--- TR 1041492 JUL-20-2009 BR
821 *CREATE CURSOR tmpPkey (pkey i)
822 *--- TR 1032802 NH 04/23/08
823 SELECT ("Vzzeipctd_ipcproc")
824*!* SCAN
825*!* IF NOT SEEK(pkey,pceipcTD,"pkey")
826*!* INSERT INTO tmpPkey (PKEY) VALUES (Vzzeipctd_ipcproc.pkey)
827*!* DELETE in Vzzeipctd_ipcproc
828*!* ENDIF
829*!* ENDSCAN
830 .LogEntry("Inserting pkey from views to temporary cursor for final table update.")
831 SELECT PKEY FROM Vzzeipctd_ipcproc WHERE pkey NOT IN(SELECT pkey FROM (pceipcTD)) INTO CURSOR tmpPkey READWRITE
832 .LogEntry("Inserting pkey from views to temporary cursor for final table update...Complete")
833
834 .LogEntry("Deleting records from views for matching pkeys.")
835 DELETE FROM Vzzeipctd_ipcproc WHERE pkey in(Select pkey FROM tmpPkey)
836 .LogEntry("Deleting records from views for matching pkeys...Complete")
837 *=== TR 1041492 JUL-20-2009 BR
838
839*!* SELECT(pceipcTD)
840*!* LOCAL lcOldSetDeleted
841*!* lcOldSetDeleted = SET("Deleted")
842*!* SET DELETED off
843*!* SCAN FOR DELETED()
844*!* IF SEEK(pkey,"Vzzeipctd_ipcproc","Pkey")
845*!* INSERT INTO tmpPkey (PKEY) VALUES (Vzzeipctd_ipcproc.pkey)
846*!* DELETE in Vzzeipctd_ipcproc
847*!* ENDIF
848*!* ENDSCAN
849*!* SET DELETED &lcOldSetDeleted
850 *=== TR 1032802 NH 04/23/08
851 lcTempTable = ""
852 llRetVal = llRetVal and .GetDeleteSQLForMatchingTransHistoryPkey(@lcSQLDelete,@lcTempTable, "tmpPkey")
853 *=== TR 1016560 NH
854
855 SELECT(pceipcTC)
856 SCAN
857 SCATTER NAME loeipctc MEMO
858 IF SEEK(loeipctc.pkey,'Vzzeipctc_ipcproc','PKEY')
859 SELECT('Vzzeipctc_ipcproc')
860 GATHER NAME loeipctc MEMO
861 ENDIF
862 ENDSCAN
863
864 * --- TR 1047609 7/7/10 CM
865 *--- TR 1050827 24-NOV-2010 HNISAR
866 * The This method is called Totally Thrice out of which twice from Prevaliation method
867 * When Prevalidation method is called second time from PopulateActualStoreForALLStore
868 * , the Vzzeipcts_ipcproc view is MAY be already populated ( specially when the process fetches data from Flat file
869 * and not one which is avalilable in transaction maintanance ) In that case we need to prevent scattering to this view
870 * otherwise it throws error of "Cursor update Conflict" to achive this added the parameter plSkipSLNUpdate to this method.
871
872*!* IF NOT EMPTY(pceipcTS)
873 IF NOT EMPTY(pceipcTS) AND NOT plSkipSLNUpdate
874 *=== TR 1050827 24-NOV-2010 HNISAR
875
876 SELECT(pceipcTS)
877 SCAN
878 SCATTER NAME loEiPCts MEMO
879 IF SEEK(loEiPCts.pkey,'Vzzeipcts_ipcproc','PKEY')
880 SELECT('Vzzeipcts_ipcproc')
881 GATHER NAME loEiPCts MEMO
882 ENDIF
883 ENDSCAN
884 ENDIF
885 * === TR 1047609 7/7/10 CM
886
887 IF llRetVal
888 llBeganTransaction = THIS.BeginTransaction()
889 *--- TR 1016560 NH
890 *--- First delete the matching pkey from history.
891 IF NOT EMPTY(lcSQLDelete)
892 llRetVal = llRetVal and v_SQLExec(lcSQLDelete)
893 ENDIF
894 *llRetVal = IIF(!THIS.TABLEUPDATE(@laTables), .F., .T.)
895 llRetVal = llRetVal and THIS.TABLEUPDATE(@laTables)
896 *=== TR 1016560 NH
897 IF llRetVal
898 IF llBeganTransaction
899 THIS.EndTransaction()
900 ENDIF
901 ELSE
902 IF llBeganTransaction
903 THIS.RollbackTransaction()
904 ENDIF
905 ENDIF
906 ENDIF
907 *--- TR 1016560 NH
908 *--- temp table has been created and will be droped here
909 IF NOT EMPTY(lcSQLDelete)
910 llRetVal = llRetVal and v_Sqlexec( "drop table " + lcTempTable)
911 ENDIF
912 *=== TR 1016560 NH
913 .oLog.LogEntry(lcMessage + ": " + IIF(llRetVal, 'Succeeded','FAILED'))
914 ENDWITH
915 RETURN llRetVal
916 ENDPROC
917
918 PROCEDURE CloseIPCViews
919 LOCAL llRetVal
920 llRetVal = .T.
921 IF llRetVal
922 * --- TR 1047609 7/7/10 CM --- Changed array from 3 to 4
923 &&--- TechRec 1073591 31-Oct-2013 TShenbagavalli changed from 4 to 6 ===
924 LOCAL laTables[6]
925 laTables[1] = "VzzeiPCth_iPcproc"
926 laTables[2] = "VzzeiPCtd_iPCproc"
927 laTables[3] = "VzzeiPCtc_iPCproc"
928
929 * --- TR 1047609 7/7/10 CM
930 laTables[4] = "VzzeiPCts_iPCproc"
931 * === TR 1047609 7/7/10 CM
932
933 *--- TechRec 1073591 31-Oct-2013 TShenbagavalli ---
934 laTables[5] = "VzzeiPCtWhse_iPCproc"
935 laTables[6] = "VzzeiPCta_iPCproc"
936 *=== TechRec 1073591 31-Oct-2013 TShenbagavalli ===
937
938 THIS.oLog.LogEntry("Close all transaction views.")
939 llRetVal = THIS.TableClose(@laTables, true) && close and delete all temp views
940 IF NOT llRetVal
941 THIS.oLog.LogWarning("Failed to close all transaction views.")
942 ENDIF
943 ENDIF
944 ENDPROC
945 *= 1014475
946
947 *- 1015584 02/14/06 YIK
948 FUNCTION RecordHeaderError
949 LPARAMETERS pcErrorMessage
950
951 SELECT tcEiPCth
952 REPLACE ;
953 Errs_msg_H WITH Errs_msg_H + pcErrorMessage + CHR(10) + CHR(13), ;
954 Errs_flg_h WITH "Y" ;
955 IN tcEiPCth
956
957 THIS.lUpdate860Records = .T.
958
959 ENDFUNC
960
961 *--- TR 1016904 NH
962 ********************************************************************************
963
964 PROCEDURE PopulateActualStoreForALLStore
965 *--- TR 1050827 18-NOV-2010 HNISAR && Added newparameter pceipcTS
966 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
967 LPARAMETERS pceIPCth, pceIPCtd, pceIPCcr, pceIPCth_nt, pceIPCtd_nt, pceipcTS, pceipcTWHSE
968
969
970 LOCAL llRetVal, lnOldSelect, lceIPCth_d, lceIPCtd_d, lcActualStoreToAdd, lceipcth_dbf_add, LceipctD_dbf_add
971 DIMENSION arrSeverTempTbl[5]
972
973 llRetVal = .t.
974 lnOldSelect = SELECT()
975 lceIPCth_d = "tceIPCth_ALL"
976 lceIPCtd_d = "tceIPCtd_ALL"
977 lceIPCth_svr = ""
978 lceIPCtd_svr = ""
979
980 this.LogMajorStage("Adding actual SDQ orders for ALL stores for 'DI' qualifier ")
981 this.LogEntry("Starting procedure " + PROGRAM())
982
983 *--- TR 1036066 NH
984 llRetVal = llRetVal and this.PopulateStoreFromOrderForSingleOrder(pceIPCth)
985 *=== TR 1036066 NH
986
987 *--- create cursor with ALL store ipc header
988 *--- TR 1036066 NH
989 *select * from tceipcth a where a.edi_store = this.cStore_ALL AND a.CUSTOMER > '' into cursor (lceIPCth_d)
990 select * from tceipcth a where a.ForAllStore = 'Y' AND a.CUSTOMER > '' into cursor (lceIPCth_d)
991 *=== TR 1036066 NH
992 this.LogEntry("Number of header record found with ALL store is " + TRANSFORM(RECCOUNT(lceIPCth_d)))
993
994 IF NOT RECCOUNT(lceIPCth_d) > 0
995 SELECT(lnOldSelect)
996 RETURN
997 ENDIF
998
999 *--- create cursor with ALL store ipc detail
1000 *--- TR 1036066 NH
1001*!* SELECT * FROM tceIPCtd d where exists ( ;
1002*!* select * from tceipcth h where h.pkey = d.fkey and h.edi_store = this.cStore_ALL and h.customer > '') ;
1003*!* into cursor (lceIPCtd_d)
1004 SELECT * FROM tceIPCtd d where exists ( select h.pkey from (lceIPCth_d) h where h.pkey = d.fkey ) ;
1005 into cursor (lceIPCtd_d)
1006
1007 IF NOT RECCOUNT(lceIPCtd_d) > 0
1008 *--- nothing to process no need to go any further just return true from here.
1009 SELECT(lnOldSelect)
1010 RETURN
1011 ENDIF
1012
1013 arrSeverTempTbl[1] = '#tceipctD_dbf_add' + SYS(2015)
1014 lceipctD_dbf_add = arrSeverTempTbl[1]
1015 arrSeverTempTbl[2] = "#tceipcth_dbf_add" + SYS(2015)
1016 lceipcth_dbf_add = arrSeverTempTbl[2]
1017 arrSeverTempTbl[3] = "#ActualStoreToAdd" + SYS(2015)
1018 lcActualStoreToAdd = arrSeverTempTbl[3]
1019 arrSeverTempTbl[4] = "#Ipcth_dbf_exists" + SYS(2015)
1020 lceipcth_dbf_exists = arrSeverTempTbl[4]
1021 arrSeverTempTbl[5] = "#ipctD_dbf_addForHeaderExists" + SYS(2015)
1022 lceipctD_dbf_addForHeaderExists = arrSeverTempTbl[5]
1023
1024 this.LogEntry("Number of detail record found with ALL store is " + TRANSFORM(RECCOUNT(lceIPCtd_d)))
1025
1026 *--- set to server
1027 WITH this
1028 .cSQLTempTable = ""
1029 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCth_d)
1030 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCth_d)
1031 lceIPCth_svr = .cSQLTempTable
1032
1033 .cSQLTempTable = ""
1034 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCtd_d)
1035 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCtd_d)
1036 lceIPCtd_svr = .cSQLTempTable
1037
1038 *--- create list of customer, po_num, and stores with actual store for ALL store orders
1039 *--- all the orders (stores) available for the each PO number + Customer
1040 *--- exclude any order (store) that already have been counted.
1041 *--- add IPCH for DI detail that does not included in ipch for any po_num, customer combination
1042
1043 ******************************************** new header **********************************
1044 *--- get all stores that needs to be counted to created new IPC header.
1045 *--- TR 1028857 NH : no need to check if the detail exists or not at this point, only check that trans detail exists
1046 *--- for each header
1047*!* "exists (select * from " + lceIPCtd_svr + " td " + ;
1048*!* "where d.division = td.division and d.style = td.style and " + ;
1049*!* " d.color_code = td.color_code and d.lbl_code = td.lbl_code " + ;
1050*!* "and d.dimension = td.dimension) " + ;
1051*!* " and exists (select * from " + lceIPCth_svr + " t WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
1052 *--- TR 1036066 NH
1053*!* lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
1054*!* lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
1055*!* "WHERE H.ORD_STATUS = 'O' " + ;
1056*!* " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
1057*!* " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
1058*!* " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
1059*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
1060*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
1061*!* " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
1062 *--- Added - n.ForAllStore <> 'Y'
1063 *--- removed - n.edi_store <> '" + this.cStore_ALL + "'
1064 *--- TR 1039809 APR-17-2009 BR - ADDED and n.doc_num = t.doc_num
1065 *--- TechRec 1051992 14-Feb-2011 TShenbagavalli added " and h.ord_qty > case when h.conf_type = 'B' then 0 end " in condition ---
1066
1067 *- TR 1062971 YIK/FH - removed TR 1051992 and replace it with simply AND d.TOTAL_QTY > 0.
1068*!* lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
1069*!* lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
1070*!* "WHERE H.ORD_STATUS = 'O' " + ;
1071*!* " and 1 = case when h.CONF_TYPE = 'B' and h.ORD_QTY > 0 then 1 else 2 end " + ; && tr 1051992
1072*!* " and 1 = case when h.CONF_TYPE = 'B' and d.TOTAL_QTY > 0 then 1 else 2 end " + ; && tr 1051992
1073*!* " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
1074*!* " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
1075*!* " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
1076*!* " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
1077*!* " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
1078*!* " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
1079
1080 lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
1081 lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
1082 "WHERE H.ORD_STATUS = 'O' " + ;
1083 " AND d.TOTAL_QTY > 0 " + ; && 1062971
1084 " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
1085 " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
1086 " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
1087 " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
1088 " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
1089 " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
1090
1091 *=== TR 1036066 NH
1092 *=== TR 1028857 NH
1093 llRetVal = llRetVal and v_sqlExec(lcSQL)
1094 this.LogEntry("Create list of customer, po_num, and stores with actual " + ;
1095 "store for ALL store " + IIF(llRetVal,"successful.","failed."))
1096
1097 *--- Create entire IPC header with order info from existing IPC header for ALL store
1098 *--- for only the one (order) that does not exists in IPC header.
1099 *--- TR 1036066 NH : Added - ForAllStore = 'Y'
1100 *--- removed - a.edi_store = '" + this.cStore_ALL + "'"
1101*!* lcSQL = "Select b.ord_num as ord_num_add , b.store as store_add , a.* into " + lceipcth_dbf_add + ;
1102*!* " from " + lceIPCth_svr + " a JOIN " + lcActualStoreToAdd + " b on a.customer = b.customer " + ;
1103*!* " and a.po_num = b.po_num where a.edi_store = '" + this.cStore_ALL + "'"
1104 lcSQL = "Select b.ord_num as ord_num_add , b.store as store_add , a.* into " + lceipcth_dbf_add + ;
1105 " from " + lceIPCth_svr + " a JOIN " + lcActualStoreToAdd + " b on a.customer = b.customer " + ;
1106 " and a.po_num = b.po_num where a.ForAllStore = 'Y'"
1107 *=== TR 1036066 NH
1108 llRetVal = llRetVal and v_sqlExec(lcSQL)
1109
1110 this.LogEntry("Creating entire IPC header with order info for only the ones " + ;
1111 "that needs to be added " + IIF(llRetVal,"successful.","failed."))
1112
1113 *-- update ord_num and store
1114 lcSQL = "Update " + lceipcth_dbf_add + " set ord_num = ord_num_add, store = store_add"
1115 llRetVal = llRetVal and v_sqlExec(lcSQL)
1116
1117 *-- got rid of extra column ord_num_add, store_add, pkey
1118 lcSQL = "Alter table " + lceipcth_dbf_add + " drop column ord_num_add, store_add"
1119 llRetVal = llRetVal and v_sqlExec(lcSQL)
1120
1121
1122 *--- TR 1032802 NH 04/23/08
1123 *--- Get rid of the detail lines that does not exists in SO order
1124 *--- then get rid of the order (store) has no detail line.
1125
1126 LOCAL lceipctD_add_tmp
1127 lceipctD_add_tmp = "#EipctD_add_tmp" + SYS(2015)
1128 llRetVal = llRetVal and this.RemoveTransHdrAndDtlForOrderLineNotExists(lceipcth_dbf_add,lceIPCtd_svr,lceipctD_add_tmp)
1129 *=== TR 1032802 NH 04/23/08
1130
1131 *--alter table #tceipcth_dbf_add drop column pkey_add
1132 lcSQL = "Alter table " + lceipcth_dbf_add + " add pkeyI int not null identity(1,1)"
1133 llRetVal = llRetVal and v_sqlExec(lcSQL)
1134
1135 *-- create #tceipctD_dbf_add table
1136 *-- NOTE: As header and detail are inner join, fkey_add will have correct pkey
1137 *-- from header even though doc_num remains same.
1138 *--- making details for all new headers
1139 *--- TR 1032802 NH 04/23/08
1140*!* lcSQL = "select h.pkeyI as fkey_add, d.* into " + lceipctD_dbf_add + " from " + lceIPCtd_svr + " d " + ;
1141*!* "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num"
1142*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
1143
1144 lcSQL = "select h.pkeyI as fkey_add, d.* into " + lceipctD_dbf_add + " from " + lceipctD_add_tmp + " d " + ;
1145 "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num and h.po_num = d.po_num " + ;
1146 " and h.customer = d.customer and h.store = d.store "
1147 llRetVal = llRetVal and v_sqlExec(lcSQL)
1148
1149 lcSql = "Alter table " + lceipctD_dbf_add + " drop column store, po_num "
1150 llRetVal = llRetVal and v_sqlExec(lcSQL)
1151 *=== TR 1032802 NH 04/23/08
1152
1153 *-- update fkey value
1154 lcSQL = "update " + lceipctD_dbf_add + " set fkey = fkey_add"
1155 llRetVal = llRetVal and v_sqlExec(lcSQL)
1156
1157 *-- got rid of extra column fkey_add
1158 lcSQL = "alter table " + lceipctD_dbf_add + " drop column fkey_add"
1159 llRetVal = llRetVal and v_sqlExec(lcSQL)
1160
1161 lcSQL = "select count(*) as Reccount from " + lceipcth_dbf_add
1162 llRetVal = llRetVal and v_sqlExec(lcSQL,"IPCH_COUNT")
1163
1164 lnPkey_ipch = 0
1165 IF llRetVal AND USED("IPCH_COUNT")
1166 this.LogEntry("Number of new IPC header will be added for ALL stores are " + TRANSFORM(IPCH_COUNT.Reccount))
1167 ENDIF
1168 *--- update pkey of ipcth
1169 IF llRetVal AND USED("IPCH_COUNT") AND IPCH_COUNT.Reccount > 0
1170 lnPkey_ipch = v_NextPkey("ZZEIPCTH",IPCH_COUNT.Reccount) - IPCH_COUNT.Reccount
1171 *--- set pkey for ipcth
1172 lcSQL = "Update " + lceipctH_dbf_add + " set pkey = pkeyI + " + TRANSFORM(lnPkey_ipch)
1173 llRetVal = llRetVal and v_sqlExec(lcSQL)
1174
1175 *--- update fkey of ipctd
1176 lcSQL = "Update d set fkey = h.pkey from " + lceipctD_dbf_add + " d inner join " + lceipctH_dbf_add +;
1177 " h on h.pkeyI = d.fkey"
1178 llRetVal = llRetVal and v_sqlExec(lcSQL)
1179
1180 *--- populate edi_store for new orders
1181 lcSQL = "Update d set edi_store = r.edi_store from " + lceipctH_dbf_add + " d inner join " + ;
1182 " zzxstorr r on d.customer = r.customer and d.store = r.store "
1183 llRetVal = llRetVal and v_sqlExec(lcSQL)
1184 ENDIF
1185
1186 *--- no use of pkeyI field in ipcth - remove it here.
1187 lcSQL = "alter table " + lceipctH_dbf_add + " drop column pkeyI"
1188 llRetVal = llRetVal and v_sqlExec(lcSQL)
1189
1190
1191 ************************** Header exists for other details with qualifier <> "DI" *************************************
1192 *--- find the transaction header records that are already available for other qualifiers
1193 *--- transaction detail records
1194 *---- and add these transaction record into lceipcth_dbf_add table and update the fkey of lceipctD_dbf_add
1195 *--- TR 1035409 NH
1196*!* lcSQL = " select n.* into " + lceipcth_dbf_exists +" from zzeipcth n inner join " + lceIPCth_svr + ;
1197*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
1198*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
1199*!* " AND not exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
1200*!* " and td.qualifier IN ('DI','PC')) "
1201
1202*!* llRetVal = llRetVal and v_SQLExec(lcSQL)
1203*!*
1204
1205*!* *--- now create details (DI) for these headers joining on doc_num
1206*!* lcSQL = "select h.pkey as fkey_add, d.* into " + lceipctD_dbf_addForHeaderExists + " from " + lceIPCtd_svr + " d " + ;
1207*!* "inner join " + lceipcth_dbf_exists + " h on h.doc_num = d.doc_num"
1208*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
1209
1210*!* *-- update fkey value
1211*!* lcSQL = "update " + lceipctD_dbf_addForHeaderExists + " set fkey = fkey_add"
1212*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
1213
1214*!* *-- got rid of extra column fkey_add
1215*!* lcSQL = "alter table " + lceipctD_dbf_addForHeaderExists + " drop column fkey_add"
1216*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
1217 llRetVal = llRetVal and this.AddDetailForExistingHeader(lceIPCth_svr, lceIPCtd_svr, lceipcth_dbf_exists, lceipctD_dbf_addForHeaderExists)
1218 *=== 1035409 nh
1219 lcSQL = "insert into " + lceipctD_dbf_add + " select * from " + lceipctD_dbf_addForHeaderExists
1220 llRetVal = llRetVal and v_sqlExec(lcSQL)
1221
1222 *--- moving existing header into Add header table for validation
1223 lcSQL = "insert into " + lceipcth_dbf_add + " select * from " + lceipcth_dbf_exists
1224 llRetVal = llRetVal and v_sqlExec(lcSQL)
1225
1226 ************************************************************************************
1227
1228 lcSQL = "Select count(*) as Reccount from " + lceipctd_dbf_add
1229 llRetVal = llRetVal and v_sqlExec(lcSQL,"IPCD_COUNT")
1230
1231 lnPkey_ipcd = 0
1232 IF llRetVal AND IPCD_COUNT.Reccount > 0
1233 lnPkey_ipcd = v_NextPkey("ZZEIPCTD",IPCD_COUNT.Reccount) - IPCD_COUNT.Reccount
1234 ENDIF
1235
1236 lcSQL = "Alter table " + lceipctD_dbf_add + " add pkeyI int not null identity(1,1)"
1237 llRetVal = llRetVal and v_sqlExec(lcSQL)
1238
1239 *--- update pkey of ipctd
1240 lcSQL = "Update " + lceipctD_dbf_add + " set pkey = pkeyI + " + TRANSFORM(lnPkey_ipcD)
1241 llRetVal = llRetVal and v_sqlExec(lcSQL)
1242
1243 lcSQL = "alter table " + lceipctD_dbf_add + " drop column pkeyI"
1244 llRetVal = llRetVal and v_sqlExec(lcSQL)
1245
1246 *--- TR 1036066 NH : stamp 'P' in forallstore field for the already exploded store orders.
1247 lcSql = "update h set forallstore = 'P' from " + lceipcth_dbf_add + " h where edi_store > '' and store > '' and forallstore = 'Y'"
1248 llRetVal = llRetVal and v_sqlExec(lcSQL)
1249 *=== TR 1036066 NH
1250
1251 *--- lceipcth_dbf_add and lceipctD_dbf_add has new order header and detail for "DI" qualifier
1252 lcSQL = "select * from " + lceipcth_dbf_add
1253 llRetVal = llRetVal and v_sqlexec(lcSQL,"tceipcth_dbf_add_readOnly")
1254
1255 lcSQL = "select * from " + lceipctd_dbf_add
1256 llRetVal = llRetVal and v_sqlexec(lcSQL,"tceipctd_dbf_add_readOnly")
1257
1258 *--- make cursor writable "tceipcth_dbf_add", "tceipctd_dbf_add" - FIX ME
1259 .MakeCursorWritable("tceipcth_dbf_add_readOnly","tceipcth_dbf_add")
1260 .MakeCursorWritable("tceipctd_dbf_add_readOnly","tceipctd_dbf_add")
1261
1262 *--- TR 1036066 NH : any detail line with qualifier not 'DI' or 'PC' should be kept with the transaction header for error
1263 *--- lceIPCtd_svr table has records that are suppose to be exploded for all store
1264 *--- and any qualifier other than 'DI' and 'PC' can not be exploded for all store and should be error out in transaction
1265 lcSql = "select * from " + lceIPCtd_svr + " d where qualifier not in ('DI','PC') "
1266 llRetVal = llRetVal and v_sqlexec(lcSql,"tceipctD_dbf_Bad")
1267
1268 SELECT tceipctD_dbf_Bad
1269 INDEX on pkey TAG pkey
1270 INDEX on fkey TAG fkey
1271
1272 IF llRetVal AND USED("tceipcth_dbf_add") AND USED("tceipctd_dbf_add") &&--- TR 1032802 NH 04/23/08
1273 SELECT tceipcth_dbf_add
1274 INDEX ON impl_ok TAG ImplOK FOR impl_ok = '' && TR 1041492 JUL-20-2009 BR
1275 INDEX ON customer + PO_num TAG CustPo
1276 INDEX ON pkey TAG pkey
1277 SELECT tceipctd_dbf_add
1278 INDEX ON pkey TAG pkey
1279 INDEX ON fkey TAG fkey
1280 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1281 ENDIF &&--- TR 1032802 NH 04/23/08
1282 *--- validate only the new records
1283 *--- TR 1050827 18-NOV-2010 HNISAR && Passed 2paramerter pceipcTS , .T.
1284 llRetVal = llRetVal and .PreValidation("tceipcth_dbf_add", "tceipctd_dbf_add", pceIPCcr,pceipcTS,.T.)
1285
1286 *--- append to additional records for "DI" SDQ to respective cursors
1287 llRetVal = llRetVal and .ScatterGatherOnExistsCopyErrorMsg("tceipcth_dbf_add",pceIPCth)
1288 llRetVal = llRetVal and .ScatterGather("tceipctd_dbf_add",pceIPCtd)
1289 llRetVal = llRetVal and .UpdateActualStoreNotesWithALLStoreNotes(pceIPCth,pceIPCtd,"Vnotes_IPCH_iPCproc","Vnotes_iPCD_iPCproc")
1290
1291 *--- TechRec 1073591 18-Oct-2013 TShenbagavalli ---
1292 llRetVal = llRetVal and .UpdateActualStoreDatawhseWithALLStoreDatawhse(pceIPCth,pceIPCtd,pceIPCtwhse)
1293 *=== TechRec 1073591 18-Oct-2013 TShenbagavalli ===
1294
1295 llRetVal = llRetVal and .DeleteALLStoreOrder(pceIPCth, pceIPCtd,"VzzeiPCth_iPCproc", "VzzeiPCtd_iPCproc", "tceipcth_dbf_add", "tceipctD_dbf_Bad") && -- tr 1036066 nh
1296 llRetVal = llRetVal and .DropSeverTempTable(@arrSeverTempTbl)
1297 ENDWITH
1298
1299 SELECT(lnOldSelect)
1300 RETURN llRetVal
1301 ENDPROC
1302
1303 *****************************************************************************************
1304 *--- TR 1036066 NH
1305 PROCEDURE PopulateStoreFromOrderForSingleOrder
1306 LPARAMETERS pceIPCth
1307
1308 LOCAL llRetVal, lnOldSelect, lceIPCth_d
1309 llRetVal = .t.
1310 lnOldSelect = SELECT()
1311 lceIPCth = "tcEIPCth" + SYS(2015)
1312
1313 select customer, po_num, pkey from tceipcth a where a.ForAllStore = 'Y' AND a.CUSTOMER > '' into cursor (lceIPCth)
1314 IF RECCOUNT(lceIPCth) = 0
1315 SELECT(lnOldSelect)
1316 RETURN llRetVal
1317 ENDIF
1318 LOCAL lceIPCth_svr, lcSinglePO
1319 lcSinglePO = "tcSinglePO" + SYS(2015)
1320 WITH this
1321 .cSQLTempTable = ""
1322 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCth)
1323 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCth)
1324 lceIPCth_svr = .cSQLTempTable
1325
1326 *--- find the PO that has only one order in Sales order and then get the store and edi_store from order and store ref
1327 lcSql = " select th.pkey, oh.customer, oh.po_num, oh.store, r.edi_store " + ;
1328 " from zzoordrh oh " + ;
1329 " inner join " + lceIPCth_svr + " th on th.customer = oh.customer and th.po_num = oh.po_num " + ;
1330 " inner join zzxstorr r on oh.customer = r.customer and oh.store = r.store " + ;
1331 " where oh.ord_status = 'O' and oh.pkey in " + ;
1332 " ( select max(pkey) as pkey from zzoordrh h (nolock) " + ;
1333 " where h.ord_status = 'O' and h.customer = oh.customer and h.po_num = oh.po_num " + ;
1334 " group by customer, po_num having count(*) = 1) " + ;
1335 " order by th.pkey "
1336
1337 llRetVal = llRetVal and v_sqlexec(lcSql, lcSinglePO)
1338 IF USED(lcSinglePO) AND RECCOUNT(lcSinglePO) > 0
1339 *--- update pceIPCth store and edi_store and set ForAllStore as processed = 'P'
1340 UPDATE th SET store = oh.store, edi_store = oh.edi_store, ForAllStore = 'P' ;
1341 from (lcSinglePO) oh inner join (pceIPCth) th on th.pkey = oh.pkey
1342
1343 USE IN (lcSinglePO)
1344 ENDIF
1345
1346 ENDWITH
1347
1348 SELECT(lnOldSelect)
1349 RETURN llRetVal
1350 ENDPROC
1351
1352 *=== TR 1036066 NH
1353 ********************************************************************************
1354 *--- TR 1035409 NH
1355 PROCEDURE AddDetailForExistingHeader
1356 LPARAMETERS pceIPCth_svr, pceIPCtd_svr, pceipcth_dbf_exists, pceipctD_dbf_addForHeaderExists
1357
1358 LOCAL llRetVal, lnOldSelect, lcSql
1359 lnOldSelect = SELECT()
1360 llRetVal = .t.
1361 lcSql = ""
1362 LOCAL lcOrderDtl
1363 lceIPCth_svr = pceIPCth_svr
1364 lceIPCtd_svr = pceIPCtd_svr
1365 lcOrderDtl = "#OrderDtl" + SYS(2015)
1366 lcSql = " select od.* into " + lcOrderDtl + " from zzoordrd od (nolock) " + ;
1367 " inner join zzoordrh oh (nolock) on oh.pkey = od.fkey " + ;
1368 " inner join " + lceIPCth_svr + " th on th.po_num = oh.po_num and th.customer = oh.customer " + ;
1369 " AND oh.ord_status = 'O' "
1370 llRetVal = llRetVal and v_sqlExec(lcSQL)
1371 LOCAL lcZzoordrdv
1372 lcZzoordrdv = ""
1373 llRetVal = llRetVal and this.GetVerticalOpenOrder(lcOrderDtl,@lcZzoordrdv)
1374 *--- TR 1036066 NH - remove - n.edi_store <> '" + this.cStore_ALL + "'
1375
1376*!* lcSQL = " select n.* into " + pceipcth_dbf_exists + " from zzeipcth n inner join " + lceIPCth_svr + ;
1377*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
1378*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
1379*!* " AND exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
1380*!* " and td.qualifier IN ('DI','PC')) " + ;
1381*!* " AND exists (select oh.pkey from zzoordrh oh (nolock) " + ;
1382*!* " inner join " + lcZzoordrdv + " od (nolock) on od.fkey = oh.pkey " + ;
1383*!* " inner join " + lceIPCtd_svr + " td on td.style = od.style and td.color_code = od.color_code " + ;
1384*!* " and td.lbl_code = od.lbl_code and td.dimension = od.dimension and td.sizebucket = od.sizebucket " + ;
1385*!* " where oh.po_num = n.po_num " + ;
1386*!* " and oh.customer = n.customer and oh.store = n.store and oh.ord_status = 'O' " + ;
1387*!* " and td.fkey = t.pkey )"
1388 *--- TR 1039809 APR-17-2009 BR - ADDED and n.doc_num = t.doc_num
1389 *--- TR 1062197 15-Oct-2012 Goutam. Added consol_code
1390 *- TR 1093179 FH - add ord_type
1391 lcSQL = " select t.ord_type, SPACE(5) as consol_code, n.* into " + pceipcth_dbf_exists + " from zzeipcth n inner join " + lceIPCth_svr + ;
1392 " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
1393 " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
1394 " AND exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
1395 " and td.qualifier IN ('DI','PC')) " + ;
1396 " AND exists (select oh.pkey from zzoordrh oh (nolock) " + ;
1397 " inner join " + lcZzoordrdv + " od (nolock) on od.fkey = oh.pkey " + ;
1398 " inner join " + lceIPCtd_svr + " td on td.style = od.style and td.color_code = od.color_code " + ;
1399 " and td.lbl_code = od.lbl_code and td.dimension = od.dimension and td.sizebucket = od.sizebucket " + ;
1400 " where oh.po_num = n.po_num " + ;
1401 " and oh.customer = n.customer and oh.store = n.store and oh.ord_status = 'O' " + ;
1402 " and td.fkey = t.pkey )"
1403 *=== TR 1036066 NH
1404 *=== TR 1035409 NH
1405 llRetVal = llRetVal and v_SQLExec(lcSQL)
1406
1407 *--- now create details (DI) for these headers joining on doc_num
1408 *--- TR 1048315 JUL-21-2010 BR - ADDED h.ord_num as ord_num
1409 lcSQL = "select h.pkey as fkey_add, h.ord_num as ord_num, d.* into " + pceipctD_dbf_addForHeaderExists + " from " + lceIPCtd_svr + " d " + ;
1410 "inner join " + pceipcth_dbf_exists + " h on h.doc_num = d.doc_num and h.customer = d.customer" + ; &&--- TR 1036066 NH
1411 " where d.qualifier in ('DI','PC') " &&--- TR 1036066 NH
1412 llRetVal = llRetVal and v_sqlExec(lcSQL)
1413
1414 *-- TR 1048315 JUL-21-2010 BR
1415 lcDelExistDTL = "#DelExistDTL" + SYS(2015)
1416 lcSQL = " select d.style, d.color_code, d.dimension, d.lbl_code, d.sizebucket, d.ord_num, dv.style as st_style into " + lcDelExistDTL + ;
1417 " from " + pceipctD_dbf_addForHeaderExists + " d " + ;
1418 " left outer join " + lcZzoordrdv + " dv on dv.division = d.division and dv.style = d.style and dv.color_code = d.color_code " + ;
1419 " and dv.lbl_code = d.lbl_code and dv.dimension = d.dimension and dv.sizebucket = d.sizebucket and dv.ord_num = d.ord_num " + ;
1420 " where dv.style is null "
1421
1422 llRetVal = llRetVal and v_sqlExec(lcSQL)
1423
1424 lcSQL = " delete d from " + pceipctD_dbf_addForHeaderExists + " d Join " + lcDelExistDTL + " e on d.style = e.style " + ;
1425 " and d.color_code = e.color_code and d.lbl_code = e.lbl_code " + ;
1426 " and d.dimension = e.dimension and d.sizebucket = e.sizebucket and d.ord_num = e.ord_num "
1427 llRetVal = llRetVal and v_sqlExec(lcSQL)
1428
1429 *-- got rid of extra column ord_num
1430 lcSQL = "alter table " + pceipctD_dbf_addForHeaderExists + " drop column ord_num"
1431 llRetVal = llRetVal and v_sqlExec(lcSQL)
1432 *== TR 1048315 JUL-21-2010 BR
1433
1434 *-- update fkey value
1435 lcSQL = "update " + pceipctD_dbf_addForHeaderExists + " set fkey = fkey_add"
1436 llRetVal = llRetVal and v_sqlExec(lcSQL)
1437
1438 *-- got rid of extra column fkey_add
1439 lcSQL = "alter table " + pceipctD_dbf_addForHeaderExists + " drop column fkey_add"
1440 llRetVal = llRetVal and v_sqlExec(lcSQL)
1441
1442 SELECT(lnOldSelect)
1443 RETURN llRetVal
1444 ENDPROC
1445
1446 *=== TR 1035409 NH
1447 ********************************************************************************
1448 *--- TR 1032802 NH 04/25/08
1449
1450 PROCEDURE RemoveTransHdrAndDtlForOrderLineNotExists
1451 LPARAMETERS pceipcth_dbf_add,pceIPCtd_svr,pceipctD_add_tmp
1452
1453 LOCAL lceipcth_dbf_add,lceIPCtd_svr,lceipctD_add_tmp
1454
1455 lceipcth_dbf_add = pceipcth_dbf_add
1456 lceIPCtd_svr = pceIPCtd_svr
1457 lceipctD_add_tmp = pceipctD_add_tmp
1458
1459 LOCAL llRetVal,lcSQL
1460 llRetVal = .t.
1461 lcSQL = ""
1462 *--- Get rid of the detail lines that does not exists in SO order
1463 *--- then get rid of the order (store) has no detail line.
1464 *--- TR 1036066 NH : we can only add detail to existing order for qualifier 'DI' and 'PC'
1465 lcSQL = "select d.*, h.po_num , h.store into " + lceipctD_add_tmp + " from " + lceIPCtd_svr + " d " + ;
1466 "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num " + ;
1467 " where d.qualifier in ('DI','PC') "
1468 llRetVal = llRetVal and v_sqlExec(lcSQL)
1469
1470 *--- vericalize order detail
1471 LOCAL lcOrderDtl
1472 lcOrderDtl = "#OrderDtl" + SYS(2015)
1473 *--- TR 1036066 NH - check for line_status = 'O'
1474 lcSql = " select od.* into " + lcOrderDtl + " from zzoordrd od (nolock) " + ;
1475 " inner join zzoordrh oh (nolock) on oh.pkey = od.fkey " + ;
1476 " inner join " + lceipcth_dbf_add + " th on th.po_num = oh.po_num and th.customer = oh.customer " + ;
1477 " and th.store = oh.store " + ;
1478 " WHERE od.line_status = 'O'"
1479 llRetVal = llRetVal and v_sqlExec(lcSQL)
1480 LOCAL lcZzoordrdv
1481 lcZzoordrdv = ""
1482 llRetVal = llRetVal and this.GetVerticalOpenOrder(lcOrderDtl,@lcZzoordrdv)
1483
1484 *--- Get rid of the detail lines that does not exists in SO order
1485 *--- then get rid of the order (store) has no detail line.
1486
1487
1488 lcSql = " delete d from " + lceipctD_add_tmp + " d " + ;
1489 " where not exists (select dv.fkey from " + lcZzoordrdv + " dv inner join zzoordrh oh (nolock) on dv.fkey = oh.Pkey " + ;
1490 " where oh.customer = d.customer and oh.po_num = d.po_num and oh.store = d.store " + ;
1491 " and dv.division = d.division and dv.style = d.style and dv.color_code = d.color_code " + ;
1492 " and dv.lbl_code = d.lbl_code and dv.dimension = d.dimension and dv.sizebucket = d.sizebucket) "
1493
1494 llRetVal = llRetVal and v_sqlExec(lcSQL)
1495
1496 lcSql = " delete h from " + lceipcth_dbf_add + " h where not exists (select d.pkey from " + lceipctD_add_tmp + " d " + ;
1497 " where d.doc_num = h.doc_num and d.store = h.store and d.po_num = h.po_num and d.customer = h.customer) "
1498 llRetVal = llRetVal and v_sqlExec(lcSQL)
1499
1500 RETURN llRetVal
1501 ENDPROC
1502 *=== TR 1032802 NH 04/25/08
1503 ********************************************************************************
1504
1505 PROCEDURE CheckAllStoreForError
1506 LPARAMETERS pceIPCth
1507 LOCAL llRetVal, lnOldSelect
1508 lnOldSelect = SELECT()
1509
1510 SELECT(lnOldSelect)
1511 RETURN llRetVal
1512 ENDPROC
1513
1514 ********************************************************************************
1515
1516 PROCEDURE DropSeverTempTable
1517 LPARAMETERS arrSeverTempTbl
1518 LOCAL llRetVal, nIndex
1519 llRetVal = .t.
1520 FOR nIndex = 1 TO ALEN(arrSeverTempTbl)
1521 this.dropTempTable(arrSeverTempTbl[nIndex])
1522 ENDFOR
1523
1524 RETURN llRetVal
1525 ENDPROC
1526
1527 ********************************************************************************
1528 PROCEDURE dropTempTable
1529 LPARAMETERS pcTempTable, plCheckTblExists
1530
1531 IF NOT VARTYPE(pcTempTable) = "C" OR EMPTY(pcTempTable)
1532 RETURN .F.
1533 ENDIF
1534
1535 LOCAL llRetVal,lnOldSelect, lcCursor
1536 llRetVal = .T.
1537 lnOldSelect = SELECT()
1538 IF plCheckTblExists
1539 lcCursor = SYS(2015)
1540 lcSQL = "Select * from tempdb..sysobjects where xtype = 'U' AND name like '" + ALLTRIM(pcTempTable) + "%'"
1541 llRetVal = llRetVal AND v_SqlExec(lcSQL,lcCursor)
1542 SELECT(lcCursor)
1543 ENDIF
1544
1545 IF NOT plCheckTblExists OR ( USED(lcCursor) AND RECCOUNT(lcCursor) > 0)
1546 lcSQL = "DROP TABLE " + pcTempTable
1547 llRetVal = llRetVal AND v_SqlExec(lcSQL)
1548 ENDIF
1549
1550 IF NOT EMPTY(lcCursor) AND USED(lcCursor)
1551 USE IN (lcCursor)
1552 ENDIF
1553
1554 SELECT(lnOldSelect)
1555 RETURN llRetVal
1556
1557 ENDPROC
1558
1559 ********************************************************************************
1560
1561 PROCEDURE DeleteALLStoreOrder
1562 LPARAMETERS pceIPCth, pceIPCtd,pcVzzeiPCth_iPCproc, pcVzzeiPCtd_iPCproc, pceipcth_dbf_add, pceipctD_dbf_Bad
1563
1564 LOCAL lnOldIpcdOrder, llRetVal, lnOldSelect, lcCustPo
1565 SELECT(pceIPCtd)
1566 SET ORDER TO fkey
1567 llRetVal = .t.
1568 lnOldSelect = SELECT()
1569 IF llRetVal
1570 SELECT(pceIPCth)
1571 *--- TR 1036066 NH
1572 *--- TR 1039809 APR-17-2009 BR - ADDED: AND ord_num <= 0
1573 SELECT customer, po_num, pkey FROM (pceIPCth) th WHERE edi_store = '' AND EMPTY(store) AND ForAllStore = 'Y' AND ord_num <= 0 ;
1574 ORDER BY customer, po_num INTO CURSOR tmpCurs
1575 LOCAL lcPrevOrderBy
1576 *SCAN FOR edi_store = this.cStore_ALL AND EMPTY(store)
1577 SELECT tmpCurs
1578 SCAN
1579 *=== TR 1036066 NH
1580 lcCustPo = customer+po_num
1581 SELECT(pceipcth_dbf_add)
1582 *--- if the customer po not found in the add list then do not delete
1583 *--- some kind of error occured user need to see the IPC record
1584 IF SEEK(lcCustPo, pceipcth_dbf_add, "CustPo")
1585 *--- 1036066 NH
1586 *DELETE FOR fkey = EVALUATE(pceIPCth + ".pkey") IN (pceIPCtd)
1587 SELECT (pceIPCtd)
1588 lcPrevOrderBy = ORDER()
1589 SET ORDER to fkey
1590 IF SEEK(tmpCurs.pkey,pceIPCtd,"FKEY")
1591 SCAN WHILE fkey = tmpCurs.pkey
1592 IF !SEEK(pkey,pceipctD_dbf_Bad,'pkey') &&--- TR 1036066 NH
1593 DELETE IN (pceIPCtd)
1594 ENDIF
1595 ENDSCAN
1596 ENDIF
1597 SET ORDER to lcPrevOrderBy
1598
1599 *--- delete from IPC view right here
1600 *DELETE FOR fkey = EVALUATE(pceIPCth + ".pkey") IN (pcVzzeiPCtd_iPCproc)
1601 select (pcVzzeiPCtd_iPCproc)
1602 lcPrevOrderBy = ORDER()
1603 SET ORDER TO fkey
1604 IF SEEK(tmpCurs.pkey,pcVzzeiPCtd_iPCproc,"FKEY")
1605 SCAN WHILE fkey = tmpCurs.pkey
1606 IF !SEEK(pkey,pceipctD_dbf_Bad,'pkey') &&--- TR 1036066 NH
1607 DELETE IN (pcVzzeiPCtd_iPCproc)
1608 ENDIF
1609 ENDSCAN
1610 ENDIF
1611 SET ORDER to lcPrevOrderBy
1612
1613 *DELETE FOR pkey = EVALUATE(pceIPCth + ".pkey") IN (pcVzzeiPCth_iPCproc)
1614 *---
1615 IF SEEK(tmpCurs.pkey,pcVzzeiPCth_iPCproc,"PKEY") AND !SEEK(tmpCurs.pkey,pceipctD_dbf_Bad,'Fkey') &&--- TR 1036066 NH
1616 DELETE IN (pcVzzeiPCth_iPCproc)
1617 ENDIF
1618 *--- now delete the header
1619 *DELETE IN (pceIPCth)
1620 IF SEEK(tmpCurs.pkey,pceIPCth,"PKEY") AND !SEEK(tmpCurs.pkey,pceipctD_dbf_Bad,'Fkey') &&--- TR 1036066 NH
1621 DELETE IN (pceIPCth)
1622 ENDIF
1623 *=== TR 1036066 NH
1624 ENDIF
1625 ENDSCAN
1626 ENDIF
1627 SELECT(lnOldSelect)
1628 RETURN llRetVal
1629 ENDPROC
1630
1631 ********************************************************************************
1632
1633 PROCEDURE UpdateActualStoreNotesWithALLStoreNotes
1634 lPARAMETERS pceIPCth,pceIPCtd, pcVnotes_IPCH_iPCproc, pcVnotes_iPCD_iPCproc
1635
1636 *--- delete all ALL records from detail.
1637 *--- add "DI" notes from ALL records to actual store records.
1638 *--- create notes detail view
1639 *--- add detail notes from ALL store records to acutal store records.
1640
1641 LOCAL llRetVal, lnOldSelect
1642 llRetVal = .t.
1643 lnOldSelect = SELECT()
1644 *--- header view
1645 *--- find the notes of ALL headers
1646 LOCAL lcOldOrder
1647 SELECT (pceIPCth)
1648 lcOldOrder = ORDER()
1649 INDEX ON edi_store TAG edi_store
1650
1651 *--- TechRec 1061523 28-May-2012 jjanand --- Enabled support to header notes
1652 SELECT h.customer, h.division, h.po_num, n.* from (pcVnotes_IPCh_iPCproc) n ;
1653 inner join (pceIPCth) h on h.pkey = n.fkey WHERE h.ForAllStore = 'Y' INTO CURSOR tcNotesIPCh_add
1654
1655 IF RECCOUNT("tcNotesIPCh_add") > 0
1656 SELECT (pceIPCth)
1657 INDEX ON customer + division + po_num TAG custPoHdr
1658
1659 SELECT("tcNotesIPCh_add")
1660 SCAN
1661 SCATTER NAME loNotesIPCh_add memo
1662 SELECT(pceIPCth)
1663
1664 IF SEEK(loNotesIPCh_add.customer + loNotesIPCh_add.division + loNotesIPCh_add.PO_num, pceIPCth, "custPoHdr")
1665 SCAN WHILE customer + division + po_num = loNotesIPCh_add.customer + loNotesIPCh_add.division + loNotesIPCh_add.PO_num
1666 IF ForAllStore <> 'Y'
1667 loNotesIPCh_add.fkey = EVALUATE(pceIPCth + ".pkey")
1668 loNotesIPCh_add.pkey = v_nextPkey("SYSNOTES")
1669 SELECT(pcVnotes_iPCh_iPCproc)
1670 APPEND BLANK
1671 GATHER NAME loNotesIPCh_add memo
1672 ENDIF
1673 ENDSCAN
1674 ENDIF
1675 ENDSCAN
1676 ENDIF
1677 *=== TechRec 1061523 28-May-2012 jjanand ===
1678
1679 *--- TR 1036066 NH
1680*!* SELECT h.customer, h.po_num, d.upc, d.sku, d.ean, d.qualifier, n.* from (pcVnotes_IPCD_iPCproc) n INNER JOIN (pceIPCtd) d ON d.pkey = n.fkey ;
1681*!* inner join (pceIPCth) h on h.pkey = d.fkey WHERE h.edi_store = this.cStore_ALL INTO CURSOR tcNotesIPCD_add
1682
1683 SELECT h.customer, h.po_num, d.upc, d.sku, d.ean, d.qualifier, n.* from (pcVnotes_IPCD_iPCproc) n INNER JOIN (pceIPCtd) d ON d.pkey = n.fkey ;
1684 inner join (pceIPCth) h on h.pkey = d.fkey WHERE h.ForAllStore = 'Y' INTO CURSOR tcNotesIPCD_add
1685 *=== TR 1036066 NH
1686 IF RECCOUNT("tcNotesIPCD_add") > 0
1687 SELECT (pceIPCth)
1688 INDEX ON customer + po_num TAG custPo
1689 *--- IPC tran detail notes
1690 SELECT(pceIPCtd)
1691 SELECT("tcNotesIPCD_add")
1692 SCAN
1693 SCATTER NAME loNotesIPCD_add memo
1694 SELECT(pceIPCth)
1695 IF SEEK(loNotesIPCD_add.customer + loNotesIPCD_add.PO_num, pceIPCth, "custPo")
1696 SCAN WHILE customer + Po_num = loNotesIPCD_add.customer + loNotesIPCD_add.PO_num
1697 *--- TR 1036066 NH
1698 *IF edi_store <> this.cStore_ALL
1699 IF ForAllStore <> 'Y'
1700 *=== TR 1036066 NH
1701 lnPkey_IPCH = pkey
1702 SELECT(pceIPCtd)
1703 IF SEEK(lnPkey_IPCH,pceIPCtd,"fkey")
1704 SCAN WHILE fkey = lnPkey_IPCH
1705 IF upc + sku + ean + qualifier = loNotesIPCD_add.upc + ;
1706 loNotesIPCD_add.sku + loNotesIPCD_add.ean + loNotesIPCD_add.qualifier
1707 *-- found the detail record where this notes will be linked
1708 loNotesIPCD_add.fkey = EVALUATE(pceIPCtd + ".pkey")
1709 loNotesIPCD_add.pkey = v_nextPkey("SYSNOTES")
1710 SELECT(pcVnotes_iPCD_iPCproc)
1711 APPEND BLANK
1712 GATHER NAME loNotesIPCD_add memo
1713 ENDIF
1714 ENDSCAN
1715 ENDIF
1716 ENDIF
1717 ENDSCAN
1718 ENDIF
1719 ENDSCAN
1720 ENDIF
1721 SELECT(lnOldSelect)
1722 RETURN llRetVal
1723 ENDPROC
1724
1725 ********************************************************************************
1726
1727 PROCEDURE ScatterGatherOnExistsCopyErrorMsg
1728 Lparameter tcSource, tcTarget
1729
1730 LOCAL lcSelect, lcSetCentury
1731 lcSelect = SELECT(0)
1732 lcSetCentury = SET('CENTURY')
1733 SET CENTURY ON
1734
1735 LOCAL loSrc
1736 SELECT (tcSource)
1737 SCAN
1738 SCATTER NAME loSrc MEMO
1739 SELECT (tcTarget)
1740 IF SEEK(loSrc.pkey, tcTarget,"Pkey")
1741 IF NOT EMPTY(loSrc.errs_msg_h) AND loSrc.errs_msg_h <> errs_msg_h
1742 replace errs_flg_h WITH 'Y', errs_msg_h WITH ALLTRIM(errs_msg_h) + loSrc.errs_msg_h IN (tcTarget)
1743 ENDIF
1744 ELSE
1745 APPEND BLANK
1746 GATHER NAME loSrc MEMO
1747 ENDIF
1748 ENDSCAN
1749 SET CENTURY &lcSetCentury
1750 SELECT (lcSelect)
1751 Endproc
1752
1753 *=== TR 1016904 NH
1754
1755 *--- TR 1017209 NH
1756 PROCEDURE PopulateActualStoreForEmptyStoreOnHdrCancel
1757 LPARAMETERS pcEipcTH
1758 LOCAL llRetVal, lnOldSelect
1759 llRetVal = .t.
1760 lnOldSelect = SELECT()
1761 *--- Notes: We do not handle Bulk Order cancelation. ?????????
1762 *--- As at this stage we do not have enough information on how to cancel a bulk order.
1763 *--- As for example : what should be done when an Bulk order has Assortment order also.
1764 *--- - We can cancel remainder of the bulk order or
1765 *--- - Cancel the Bulk order including all existing open assortment orders of the PO.
1766
1767 *--- get all the SO Order for the customer + po_num
1768 LOCAL lcSQL, lcAllStores, lnPkeyEmptyStore, llFound
1769 lcAllStores = "zzoordrhAllStores"
1770 lcIpcthEmptyStore = SYS(2015)
1771 SELECT * from (pcEipcTH) WHERE EMPTY(edi_store) AND poc_purp = "01" INTO CURSOR (lcIpcthEmptyStore)
1772 SELECT (lcIpcthEmptyStore)
1773 SCAN
1774 SCATTER NAME loEipcTH memo
1775 lcSQL = "Select h.po_num, h.customer, h.store, h.division, r.edi_store from zzoordrh h inner join zzxstorr r on " + ;
1776 " h.customer = r.customer and h.store = r.store " + ;
1777 " where h.customer = '" + TRANSFORM(loEipcTH.customer) + "' and h.po_num = '" + TRANSFORM(loEipcTH.po_num) + "'" + ;
1778 " and h.conf_type = 'A'"
1779 llRetVal = llRetVal and v_SQLExec(lcSQL,lcAllStores) and USED(lcAllStores)
1780
1781 IF llRetVal
1782 *--- create new trans header for each store SO order
1783 SELECT(lcAllStores)
1784 lnPkeyCount = RECCOUNT(lcAllStores)
1785 *-- we are going to use the blank store Trans header so, one less pkey needs to be generated.
1786 lnPkeyEmptyStore = loEipcTH.pkey
1787 lnPkeyCount = lnPkeyCount - 1
1788 lnPkey = 0
1789 IF lnPkeyCount > 0
1790 lnPkey = v_NextPkey('ZZEIPCTH',lnPkeyCount) - lnPkeyCount
1791 ENDIF
1792
1793 SELECT(lcAllStores)
1794 SCAN
1795 *--- create new tran Hdr line for each BC SO order
1796 loEipcTH.edi_store = edi_store
1797 loEipcTH.store = store
1798 loEipcTH.division = division && division is populated for entire order cancellation.
1799 llFound = .f.
1800 SELECT (pcEipcTH)
1801 *--- new record only when store count is more than one.
1802 IF lnPkeyEmptyStore > 0
1803 llFound = SEEK(lnPkeyEmptyStore,pcEipcTH,"pkey")
1804 ELSE
1805 lnPkey = lnPkey + 1
1806 loEipcTH.pkey = lnPkey
1807 APPEND BLANK
1808 ENDIF
1809
1810 IF lnPkeyEmptyStore > 0 AND NOT llFound && this is should not result in true at any time
1811 .LogEntry("pkey " + TRANSFORM(lnPkeyEntryStore) + " could not be found! Process will fail.")
1812 llRetVal = .f.
1813 EXIT
1814 ELSE
1815 lnPkeyEmptyStore = 0 && assign zero here so that this routine will be executed only once per empty store.
1816 GATHER NAME loEipcTH memo
1817 ENDIF
1818 ENDSCAN
1819 ENDIF
1820 IF USED(lcAllStores)
1821 USE IN (lcAllStores)
1822 ENDIF
1823 ENDSCAN
1824 SELECT(lnOldSelect)
1825 RETURN llRetVal
1826
1827 ENDPROC
1828 *=== TR 1017209 NH
1829 *--- TR 1016559 NH
1830 ******************************************************************************
1831 PROCEDURE PrepackConversion
1832 LPARAMETERS pcTransDetail
1833 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
1834 llRetVal = .T.
1835 lnOldSelect = SELECT()
1836 this.LogEntry("Starting program " + program())
1837 this.LogEntry("Prepack Conversion Allowed - " + IIF(this.lPrepackConversion,"Yes.","No."))
1838 *--- making this modification backward compatible.
1839 IF NOT this.lPrepackConversion
1840 RETURN llRetVal
1841 ENDIF
1842
1843 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
1844 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
1845
1846 SELECT DISTINCT d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.ppk_action ;
1847 FROM (pcTransDetail) d ;
1848 WHERE d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
1849 AND not exists (select * from __RangeP rp where rp.division = d.division and rp.rng_style = d.style ;
1850 and rp.rng_color = d.color_code and rp.rng_lbl = d.lbl_code and rp.rng_pack = d.dimension ) ;
1851 ORDER BY d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION INTO CURSOR __TmpCursor
1852
1853 IF RECCOUNT("__TmpCursor") > 0
1854 THIS.cSQLTempTable = ""
1855 llRetVal = llRetVal and THIS.GenerateSQLTempTable('__TmpCursor')
1856 llRetVal = llRetVal and THIS.PopulateSQLTempTable('__TmpCursor')
1857 llRetVal = llRetval and !EMPTY(THIS.cSQLTempTable)
1858
1859 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
1860 lcSQLString = "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
1861 "from zzxppakh ph, zzxscolr s, " + THIS.cSQLTempTable + " t " +;
1862 "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
1863 "s.style= t.style and s.color_code= t.color_code and " +;
1864 "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
1865 "s.division= ph.division and s.size_code= ph.size_code and "+;
1866 "s.dimension= ph.ppk_code and ph.Active_ok = 'Y' "
1867
1868 llRetVal = llRetVal AND v_SqlExec(lcSQLString, "_PPK_Qty") and USED("_PPK_Qty")
1869 IF llRetVal
1870 this.LogEntry("Number of prepack-style requires conversion is " + TRANSFORM(RECCOUNT("_PPK_Qty")))
1871 ENDIF
1872 llRetVal = llRetval and THIS.PrePackConvert("_PPK_Qty",pcTransDetail)
1873 ENDIF
1874 IF USED("__TmpCursor")
1875 USE IN __TmpCursor
1876 ENDIF
1877 IF USED("_PPK_Qty")
1878 USE IN _PPK_Qty
1879 ENDIF
1880 SELECT(lnOldSelect)
1881 RETURN llRetVal
1882 ENDPROC
1883
1884 ******************************************************************************
1885
1886 PROCEDURE PrePackConvert
1887 LPARAMETERS pcurPPK_Qty, pcTransDetail
1888 LOCAL llRetVal, lnOldSelect
1889 LOCAL lcppk_action, lnPack_Qty
1890 llRetVal = .t.
1891 lnOldSelect = SELECT()
1892 this.LogEntry("Starting program " + PROGRAM())
1893 SELECT(pcurPPK_Qty)
1894 INDEX ON division+STYLE+color_code+lbl_code+DIMENSION TAG Ppk
1895 llRetVal = llRetVal AND .SetRelation(pcurPPK_Qty, "Ppk", pcTransDetail, ;
1896 "division+style+color_code+lbl_code+dimension")
1897 IF llRetVal
1898 THIS.oLog.LogEntry("Validating prepack style.")
1899 lcErrs_Msg = "No valid prepack code found"
1900 SELECT (pcTransDetail)
1901 SCAN FOR !(Errs_Flg_D= "Y") AND ppk_action $ 'QPB'
1902 lnPack_Qty = EVALUATE(pcurPPK_Qty + ".pack_qty")
1903 IF EMPTY(lnPack_Qty)
1904 REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Msg + CRLF, ;
1905 Errs_Flg_D WITH "Y" ;
1906 IN (pcTransDetail)
1907 ELSE
1908 lcppk_action = EVALUATE(pcurPPK_Qty + ".ppk_action")
1909 DO CASE
1910 CASE lcppk_action = 'Q' && multiply qty
1911 REPLACE ppk_qty WITH lnPack_Qty, ;
1912 total_qty WITH total_qty*lnPack_Qty, ;
1913 qty_change WITH qty_change*lnPack_Qty, ;
1914 ppk_action WITH 'M' ; && 'M'ultiplied. Don't do it again.
1915 IN (pcTransDetail)
1916 CASE _PPK_Qty.ppk_action = 'P' && divide price
1917 REPLACE ppk_qty WITH lnPack_Qty, ;
1918 org_price WITH org_price/lnPack_Qty, ;
1919 poc_cost WITH poc_cost/lnPack_Qty, ;
1920 poc_price WITH poc_price/lnPack_Qty, ;
1921 poc_retail2 WITH poc_retail2/lnPack_Qty, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
1922 ppk_action WITH 'D' ; && 'D'ivided. Don't do it again.
1923 IN (pcTransDetail)
1924 CASE _PPK_Qty.ppk_action = 'B' && both multiply qty and divide price
1925 REPLACE ppk_qty WITH lnPack_Qty, ;
1926 org_price WITH org_price/lnPack_Qty, ;
1927 poc_cost WITH poc_cost/lnPack_Qty, ;
1928 poc_price WITH poc_price/lnPack_Qty, ;
1929 poc_retail2 WITH poc_retail2/lnPack_Qty, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
1930 total_qty WITH total_qty*lnPack_Qty, ;
1931 qty_change WITH qty_change*lnPack_Qty, ;
1932 ppk_action WITH 'X' ; && Divided and Multiplied. Don't do it again.
1933 IN (pcTransDetail)
1934 OTHERWISE
1935 ENDCASE
1936 ENDIF
1937 ENDSCAN
1938 ENDIF
1939 SET RELATION TO
1940 SELECT(lnOldSelect)
1941 RETURN llRetVal
1942 ENDPROC
1943
1944 ******************************************************************************
1945
1946 *=== TR 1016559 NH
1947 *---- TR 1016560 NH
1948
1949 ************************************************************************************
1950 * - Implosion single prepack
1951 * 860 Multiple Prepack Implosion
1952 ************************************************************************************
1953 ************************************************************************************
1954 * - Implosion logic for Simple Prepack (not Multiple prepack)
1955 *
1956 * -- Build work cursor prepack: Prepack SKU, pack_qty, pack01..24 qty
1957 * -- Build work cursor order: horizontal size like actual orders and mark vertical
1958 * tran detail with same DtlPkey (--will use for latter removing group of tran detail)
1959 * Only select order lines that are none prepack (--not previously resolve to prepack
1960 * nor original come in as prepack UPC/SKU)
1961 * -- Search for prepack to use: order total qty divisible by pack_qty; make sure also
1962 * all size bucket also divisible. When find a prepack will create new transaction
1963 * detail with order line qty stuff to 1st avail bucket of prepack style.
1964 * -- Implosion set to "Y"es and not found prepack report error message or skip
1965 * if imposion set to "O"pen stock
1966 *
1967 * Notes: condition for single vs. multiple prepack
1968 * zzxppakh.pack_qty <> zzxppakd.pack_total : MULTIPLE RECORD PrePack
1969 * zzxppakh.pack_qty = zzxppakd.pack_total : SINGLE RECORD PrePack
1970 *
1971 ************************************************************************************
1972
1973 ************************************************************************************
1974 * resolving prepack (multiple and single color prepack imposion)
1975 ***********************************************************************************
1976
1977
1978 PROCEDURE Resolve860Prepack
1979 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
1980
1981 *--- get all qualifier present in the detail
1982
1983 LOCAL llRetVal, lnOldSelect,lceipcTD_Qualifier, lceipcTD_temp, lcQualifier
1984 llRetVal = .t.
1985 lnOldSelect = SELECT()
1986 lceipcTD_Qualifier = "tceIPCtd_Qualifier"
1987 lceipcTD_temp = "tceipcTD_temp"
1988 lcQualifier = "tcQualifier"
1989
1990 WITH this
1991 SELECT DISTINCT qualifier from (pceipcTD) INTO CURSOR (lcQualifier)
1992 SELECT * from (pceipcTD) into CURSOR (lceipcTD_temp)
1993
1994 *--- clear all record from 860 trans detail so after each scan loop records realted to each will be appended back
1995 SELECT (pceipcTD)
1996 DELETE ALL
1997 SELECT (lcQualifier)
1998 SCAN
1999 *--- create dtl cursor for each type of qualifier pceipcTD_Qualifier
2000 llRetVal = llRetVal and .CreateQualifierDltFromIPCdtl(lceipcTD_temp, lceipcTD_Qualifier, EVALUATE(lcQualifier + ".qualifier"))
2001 .LogEntry("Resolving Prepack/Range style for Qualifier " + EVALUATE(lcQualifier + ".qualifier") + ".")
2002
2003 llRetVal = llRetVal and .ResolvePrepack(pceipcTH, lceipcTD_Qualifier, pceipcCR)
2004 .LogEntry("Resolving Prepack for Qualifier " + EVALUATE(lcQualifier + ".qualifier") + " " + IIF(llRetVal,"successful.","failed."))
2005
2006 llRetVal= llRetVal AND .ResolveRangeP(pceipcTH, lceipcTD_Qualifier, pceipcCR)
2007 .LogEntry("Resolving Range Style type 'P' for Qualifier " + EVALUATE(lcQualifier + ".qualifier") + ;
2008 " " + IIF(llRetVal,"successful.","failed."))
2009
2010 IF .lMultipack
2011 llRetVal = llRetVal AND .ResolveMultiPrepacks(pceipcTH, lceipcTD_Qualifier,.cMPPK)
2012 .LogEntry("Resolving Multipack Prepack for Qualifier " + EVALUATE(lcQualifier + ".qualifier") + ;
2013 " " + IIF(llRetVal,"successful.","failed."))
2014 ENDIF
2015 llRetVal = llRetVal and .AppendToIPCtd(lceipcTD_Qualifier,pceipcTD)
2016 llRetVal = llRetVal and .TableClose(lceipcTD_Qualifier)
2017 ENDSCAN
2018 .TableClose(lceipcTD_temp)
2019 ENDWITH
2020 SELECT(lnOldSelect)
2021 RETURN llRetVal
2022 ENDPROC
2023
2024 ************************************************************************************
2025
2026 FUNCTION ResolveRangeP
2027 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
2028 LOCAL llRetVal, lnOldSelect, lcSQLString, lnResult
2029 llRetVal = .T.
2030 lnOldSelect = SELECT()
2031
2032 WITH THIS
2033 .LogMajorStage("Range Style Implosion.")
2034 *- do we have any range styles 'P' in BC
2035 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
2036 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "tcTemp")
2037 IF !llRetVal OR RECC("tcTemp") = 0
2038 .LogEntry("No range styles for implosion")
2039 RETURN llRetVal
2040 ENDIF
2041
2042 *--- TR 1048865 Changed from d.division = C.division AND d.customer = C.customer ; to c.pkey = th.cr_pkey and join with pceipcTH
2043 SELECT DISTINCT fkey, C.Rng_impl ;
2044 FROM (pceipcTD) d ;
2045 JOIN (pceipcTH) h ;
2046 ON h.pkey = d.fkey ;
2047 JOIN (pceipcCR) C ;
2048 ON c.pkey = h.cr_pkey ;
2049 WHERE C.Rng_impl <> 'N' AND !EMPTY(d.STYLE) ;
2050 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
2051 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
2052 INTO CURSOR rng_det
2053
2054 SELECT division, STYLE, color_code, lbl_code, DIMENSION, Sizebucket, d.qty_change as total_qty, d.fkey ;
2055 FROM (pceipcTD) d ;
2056 JOIN rng_det r ON r.fkey = d.fkey ;
2057 WHERE !EMPTY(d.STYLE) ;
2058 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
2059 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
2060 INTO CURSOR __TmpCurs
2061
2062 IF RECCOUNT("__TmpCurs") < 1
2063 SELECT (lnOldSelect)
2064 RETURN llRetVal
2065 ENDIF
2066
2067 .cSQLTempTable=""
2068 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCurs')
2069 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCurs') and !EMPTY(.cSQLTempTable)
2070 IF llRetVal
2071 SELECT rng_det
2072 SCAN
2073 lnFkey = rng_det.fkey
2074 lcRng_Impl = rng_det.Rng_impl
2075 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFkey)
2076 dtl = SQLTableFromQuery(lcSQLStr )
2077 lnResult = .RangeImplosion(lnFkey, dtl, pceipcTD)
2078 SELECT (pceipcTD)
2079 DO CASE
2080 CASE lnResult = 0 && match not found
2081 IF lcRng_Impl = 'Y'
2082 REPLACE Errs_Msg_D WITH Errs_Msg_D + " Cannot find range style " + CRLF, ;
2083 Errs_Flg_D WITH "Y" ;
2084 FOR fkey = lnFkey AND !EMPTY(STYLE) ;
2085 AND !EMPTY(division) AND !EMPTY(customer) ;
2086 AND EMPTY(rng_style) AND implosion <> "Y" IN (pceipcTD)
2087 ENDIF
2088 CASE lnResult > 1 && ambiguous
2089 REPLACE Errs_Msg_D WITH Errs_Msg_D + " Ambiguous range style " + CRLF, ;
2090 Errs_Flg_D WITH "Y" ;
2091 FOR fkey = lnFkey AND !EMPTY(STYLE) ;
2092 AND !EMPTY(division) AND !EMPTY(customer) ;
2093 AND EMPTY(rng_style) AND implosion <> "Y" IN (pceipcTD)
2094 ENDCASE
2095 ENDSCAN
2096 ENDIF
2097 ENDWITH
2098 SELECT (lnOldSelect)
2099 RETURN llRetVal
2100 ENDFUNC
2101
2102 ******************************************************************************************
2103
2104 FUNCTION RangeImplosion
2105 LPARAMETERS pnFkey, dtl, pceipcTD
2106 LOCAL llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
2107 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
2108 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
2109
2110 llRetVal = .T.
2111 lnOldSelect = SELECT()
2112 WITH THIS
2113
2114 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
2115 *- turn them vertical into SQL-side temp table var. RangD
2116 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
2117 " Size_Num as Size_Bk, d.PKey, d.FKey, " + ;
2118 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " + ;
2119 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " + ;
2120 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " + ;
2121 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " + ;
2122 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " + ;
2123 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " + ;
2124 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " + ;
2125 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " + ;
2126 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " + ;
2127 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " + ;
2128 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " + ;
2129 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " + ;
2130 "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " + ;
2131 "from " + ;
2132 " (select dd.* from zzxrangd dd " + ;
2133 " where fkey in ( " + ;
2134 " select distinct ph.pkey " + ;
2135 " from zzxrangh ph " + ;
2136 " join zzxrangd pd " + ;
2137 " on ph.Pkey = Pd.Fkey " + ;
2138 " join " + dtl + " td1 " + ;
2139 " on pd.style = td1.style " + ;
2140 " and pd.color_code = td1.color_code " + ;
2141 " and pd.lbl_code = td1.lbl_code " + ;
2142 " and pd.dimension = td1.dimension " + ;
2143 " where ph.rng_type = 'P') ) d " + ;
2144 "cross join zzxbuckt b " + ;
2145 "where d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " + ;
2146 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " + ;
2147 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " + ;
2148 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " + ;
2149 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " + ;
2150 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " + ;
2151 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " + ;
2152 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " + ;
2153 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " + ;
2154 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " + ;
2155 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " + ;
2156 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 "
2157
2158 RangD = SQLTableFromQuery(lcSQLString)
2159
2160 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
2161 *- possible combinations of RangD that cover them.
2162 *- Result is SQL-side temp table var. RangeSet
2163 lcSQLString = ; &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
2164 'select td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
2165 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
2166 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
2167 ' from ' + dtl + ' td ' + ;
2168 ' cross join ( ' + ;
2169 ' select * from zzxrangh H where exists ' + ;
2170 '( select * from ' + RangD + ' dd ' + ;
2171 ' join ' + dtl + ' td1 ' + ;
2172 ' on dd.Division = td1.Division and dd.style = td1.style and dd.color_code = td1.color_code ' + ;
2173 'and dd.lbl_code = td1.lbl_code and dd.dimension = td1.dimension and dd.size_bk = td1.sizebucket ' + ;
2174 'where dd.FKey = H.PKey )) mtch ' + ;
2175 'left join ' + RangD + ' D on d.FKey = mtch.PKey and d.Division = td.Division and d.style = td.style ' + ;
2176 ' and d.color_code = td.color_code and d.lbl_code = td.lbl_code and d.dimension = td.dimension ' + ;
2177 'and d.size_bk = td.sizebucket ' + ;
2178 ' where not exists ( ' + ;
2179 ' select * from ' + RangD + ' dd where dd.Fkey = mtch.Pkey and not exists( ' + ;
2180 ' select * from ' + dtl + ' td2 ' + ;
2181 ' where dd.style = td2.style ' + ;
2182 ' and dd.color_code = td2.color_code ' + ;
2183 ' and dd.lbl_code = td2.lbl_code ' + ;
2184 ' and dd.dimension = td2.dimension ' + ;
2185 ' and dd.size_bk = td2.sizebucket ' + ;
2186 ' and dd.Division = td2.Division )) '
2187
2188 RangeSet = SQLTableFromQuery(lcSQLString)
2189
2190 *- how many different range styles were found for this order
2191 lcSQLString = ;
2192 ' select count(*) PPKCnt ' + ;
2193 ' from (select distinct fkey from ' + RangeSet + ') t'
2194
2195 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
2196 lnPPKCnt = tmp_cnt.PPKCnt
2197
2198 *--- the result (Query #2):
2199 *- See if any single range style in the RangeSet fully matches DTL
2200 lcSQLString = ;
2201 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
2202 ' from ' + dtl + ' dtl ' + ;
2203 ' join ' + RangeSet + ' t1 ' + ;
2204 ' on dtl.style = t1.style ' + ;
2205 ' and dtl.color_code = t1.color_code ' + ;
2206 ' and dtl.lbl_code = t1.lbl_code ' + ;
2207 ' and dtl.dimension = t1.dimension ' + ;
2208 ' and dtl.sizebucket = t1.sizebucket ' + ;
2209 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
2210 ' having count(*) = (select count(*) from ' + dtl + ') '
2211
2212 llRetVal = v_SqlExec(lcSQLString, "__tmp")
2213 lnCnt = RECCOUNT()
2214
2215 llSingleMatch = .F.
2216 llAmbig = .F.
2217 CREATE CURSOR q_Result( ValidRange MEMO)
2218 DO CASE
2219 CASE lnCnt > 1
2220 llAmbig = .T. && ambiguos, give error message and do not continue
2221 CASE lnCnt = 1
2222 llSingleMatch = .T.
2223 INSERT INTO q_Result (ValidRange) VALUES( ALLTR(STR(__tmp.fkey)) + ", " + TRANS(__tmp.ratio))
2224 OTHERWISE
2225 ENDCASE
2226
2227 lnResult = lnCnt
2228
2229 IF !llAmbig
2230 *- If none single range style in the RangeSet fully matches DTL,
2231 *- or even if a match was found
2232 *- start going through combinations of 2,3... - may be ambiguous
2233 lcFldStr = ' select Count(*), t1.Fkey'
2234 lcTopStr = ;
2235 ' from ' + dtl + ' dtl ' + ;
2236 ' join ' + RangeSet + ' t1 ' + ;
2237 ' on dtl.style = t1.style ' + ;
2238 ' and dtl.color_code = t1.color_code ' + ;
2239 ' and dtl.lbl_code = t1.lbl_code ' + ;
2240 ' and dtl.dimension = t1.dimension ' + ;
2241 ' and dtl.sizebucket = t1.sizebucket '
2242
2243 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
2244 lcMiddleStr = ''
2245 lcCoalStr_pkey = 't1.pkey'
2246 lcCoalRevStr_pkey = 't1.pkey'
2247 lcCoalStr_ratio = 't1.ratio'
2248 lcCoalRevStr_ratio = 't1.ratio'
2249 lcGroupFkeyStr = ' t1.FKey'
2250 lcGroupStr = ''
2251 lnPrepacks = MIN(lnPPKCnt, 6)
2252
2253 FOR j = 2 TO lnPrepacks && 6 different range styles in a single order is enough?
2254 llFoundNext = .F.
2255
2256 lcnum = TRANS(j, "9")
2257 lcPrevNum = TRANS(j - 1, "9")
2258 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
2259 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
2260
2261 lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
2262 lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
2263
2264 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
2265 lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
2266 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
2267 lcMiddleStr = lcMiddleStr + ;
2268 "join " + RangeSet + " t" + lcnum + ;
2269 ' on dtl.style = t' + lcnum + '.style ' + ;
2270 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
2271 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
2272 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
2273 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
2274 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
2275
2276 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
2277 ' Group by ' + lcGroupStr
2278
2279 lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
2280 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
2281 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
2282 lnCnt = RECCOUNT()
2283 llFoundNext = (lnCnt = 1)
2284 *- ambig when either prev or this SQL returned more than 1 row or
2285 *- one match was found before AND one is found now - making it two.
2286 IF lnCnt > 0
2287 SCAN
2288 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
2289 *- divisible by the number of items in the range style!!!
2290 IF MOD(ratio, 1) <> 0 && not divisible, exclude
2291 ELSE
2292 lcInsertStr = TRANS(fkey)
2293 FOR lnCounter = 2 TO j
2294 lcInsertStr = lcInsertStr + ", " + TRANS(EVAL("t" + lcnum + '_Fkey ' ))
2295 ENDFOR
2296 lcInsertStr = lcInsertStr + ", " + TRANS(ratio)
2297 INSERT INTO q_Result (ValidRange) VALUES(lcInsertStr)
2298 ENDIF
2299 ENDSCAN
2300 ENDIF
2301 lnResultCnt = RECC("q_Result")
2302 llAmbig = (lnResultCnt > 1)
2303 llSingleMatch = (lnResultCnt = 1)
2304 IF llAmbig
2305 lnResult = lnResultCnt
2306 EXIT
2307 ENDIF
2308 ENDFOR
2309 IF llSingleMatch
2310 lnResult = 1
2311 .ConsolidateRangeP(pceipcTD, "q_Result", pnFkey)
2312 ENDIF
2313 ELSE && ambiguous
2314 lnResult = lnCnt
2315 ENDIF
2316 ENDWITH
2317 RETURN lnResult
2318 ENDPROC
2319
2320 *****************************************************************************************
2321
2322 PROCEDURE ConsolidateRangeP
2323 LPARAMETERS pceipcTD, q_Result, pnFkey
2324 LOCAL llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
2325 LOCAL lnPocCost
2326
2327 llRetVal = .T.
2328 lnOldSelect = SELECT()
2329
2330 *- insert range styles that match zzxrangd.fkey from q_result
2331 *- into pceipcTD.
2332 *- parse the string from cursor q_result to get the list of fkeys
2333 SELECT (pceipcTD)
2334 LOCATE FOR fkey = pnFkey
2335 SCATTER NAME oDtl MEMO
2336 DECLARE aRange[1]
2337 aRange = ''
2338 SELECT q_Result
2339 SCATTER MEMVAR MEMO
2340 StringToArray(m.ValidRange, @aRange, ",")
2341 lnLen = ALEN(aRange) - 1 && the last element is ratio
2342 lnRatio = VAL( aRange[lnLen + 1] )
2343 FOR j = 1 TO lnLen
2344 lcFkey = aRange[j]
2345 v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
2346 oDtl.STYLE = __RangH.rng_style
2347 oDtl.color_code = __RangH.rng_color
2348 oDtl.lbl_code = __RangH.rng_lbl
2349 oDtl.DIMENSION = __RangH.rng_pack
2350 oDtl.rng_style = __RangH.rng_style
2351 oDtl.rng_color = __RangH.rng_color
2352 oDtl.rng_lbl = __RangH.rng_lbl
2353 oDtl.rng_pack = __RangH.rng_pack
2354 oDtl.rng_qty = __RangH.rng_qty
2355 oDtl.rng_type = __RangH.rng_type
2356 *- don't have to have upc or sku for the imploded range style
2357 oDtl.upc = ''
2358 oDtl.sku = ''
2359 *-- No need for price information here.
2360 *- clear err msg and err flag which may have error after unsuccessful implosion
2361 lnPocCost = this.GetRangePocCost("__RangH", this.SaleOrderControlRef)
2362 oDtl.Errs_Msg_D = ""
2363
2364 *- 1009211 03/09/05 YIK
2365 *- Initializ3e errs_flg_d to N, not blank
2366 *- oDtl.Errs_Flg_D = " "
2367 oDtl.Errs_Flg_D = "N"
2368 *- org_price is based on zzocntrc (cust sales) price_code
2369 *- we'll get the proper price_code in ValidOrderControl()
2370 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
2371
2372 *- 1009211 02/24/05 YIK
2373 *- Keep quantity in cases and use price per case.
2374 *- and zero out orig price which will be resolved.
2375 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
2376 oDtl.total_qty = lnRatio
2377 oDtl.qty_change = lnRatio
2378 oDtl.poc_cost = lnPocCost
2379 *= 1009211
2380 oDtl.Sizebucket = __RangH.rng_bk
2381 oDtl.rng_bk = oDtl.Sizebucket
2382 IF !v_GetSizeHeadings(oDtl.division, oDtl.STYLE, "__xSizer")
2383 llRetVal = .F.
2384 EXIT
2385 ENDIF
2386 lcSizeBucket = "Size" + TRANS(oDtl.Sizebucket, "@L 99") && zzxsizer bucket field names
2387 oDtl.size_desc = TRIM(EVAL("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
2388 *--
2389 oDtl.pkey = v_nextPkey("ZZEIPCTD")
2390 SELECT (pceipcTD)
2391 APPEND BLANK
2392 GATHER NAME oDtl
2393 ENDFOR
2394 IF llRetVal
2395 *- delete components
2396 DELETE FOR fkey = pnFkey AND !EMPTY(STYLE) ;
2397 AND !EMPTY(division) AND !EMPTY(customer) ;
2398 AND EMPTY(rng_style) AND implosion <> "Y" ;
2399 IN (pceipcTD)
2400 ENDIF
2401 SELECT (lnOldSelect)
2402 RETURN llRetVal
2403 ENDPROC
2404
2405 ******************************************************************************************
2406
2407 PROCEDURE GetRangePocCost
2408 LPARAMETERS tcRangH, tcSaleOrderControlRef
2409
2410 LOCAL lnOldSelect, lnCost, lcPrice_code
2411 lnOldSelect = SELECT()
2412 lnCost = 0
2413 lcPrice_code = ""
2414 SELECT(tcRangH)
2415 lcDivision = EVALUATE(tcRangH + ".division")
2416 IF NOT EMPTY(lcDivision) AND SEEK(lcDivision, tcSaleOrderControlRef, "div")
2417 lcPrice_code = ALLTRIM(EVALUATE(tcSaleOrderControlRef + ".Price_code"))
2418 IF NOT EMPTY(lcPrice_code)
2419 lnCost = EVALUATE(tcRangH + "." + lcPrice_code + "_price")
2420 ENDIF
2421 ENDIF
2422 SELECT(lnOldSelect)
2423 RETURN lnCost
2424
2425 ENDPROC
2426
2427 ******************************************************************************************
2428
2429 PROCEDURE UpdateFlds
2430 LPARAMETERS pceipctd
2431 LOCAL llRetVal, lnOldselect
2432 lnOldselect = SELECT()
2433 llRetVal = .t.
2434 REPLACE Qty_change WITH Total_qty FOR implosion = 'Y' IN (pceipctd)
2435 SELECT(lnOldselect)
2436 RETURN llRetVal
2437 ENDPROC
2438
2439
2440 ************************************************************************************
2441
2442 PROCEDURE CreateQualifierDltFromIPCdtl
2443 LPARAMETERS pceipcTD, pceipcTD_Qualifier, pcQualifier
2444
2445 LOCAL llRetVal, lnOldSelect,loipcTD
2446
2447 llRetVal = .t.
2448 lnOldSelect = SELECT()
2449 WITH this
2450 llRetVal = llRetVal and .CreateCursorStructure(pceipcTD,,pceipcTD_Qualifier)
2451 SELECT (pceipcTD)
2452 SCAN FOR qualifier = pcQualifier
2453 SCATTER NAME loipcTD memo
2454 SELECT(pceipcTD_Qualifier)
2455 APPEND BLANK
2456 GATHER NAME loipcTD memo
2457 ENDSCAN
2458 ENDWITH
2459 RELEASE loipcTD
2460
2461 SELECT (pceipcTD_Qualifier)
2462 INDEX ON dtlpkey TAG dtlpkey
2463 INDEX ON STR(dtlpkey) + STR(Sizebucket) TAG dtlSzPkey
2464 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
2465 INDEX ON pkey TAG pkey
2466 INDEX ON fkey TAG fkey
2467
2468 SELECT(lnOldSelect)
2469 RETURN llRetVal
2470
2471 ENDPROC
2472
2473 ************************************************************************************
2474
2475 PROCEDURE AppendToIPCtd
2476 LPARAMETERS pceipcTD_Qualifier,pceipcTD
2477 LOCAL llRetVal, lnOldSelect,loipcTD
2478
2479 lnOldSelect = SELECT()
2480 llRetVal = .t.
2481 SELECT (pceipcTD_Qualifier)
2482 SCAN
2483 SCATTER NAME loipcTD memo
2484 SELECT (pceipcTD)
2485 APPEND BLANK
2486 GATHER NAME loipcTD memo
2487 ENDSCAN
2488 RELEASE loipcTD
2489 SELECT(lnOldSelect)
2490 RETURN llRetVal
2491 ENDPROC
2492
2493 ************************************************************************************
2494
2495 PROCEDURE ResolvePrepack
2496 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
2497 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2498 llRetVal = .T.
2499 lnOldSelect = SELECT()
2500 WITH THIS
2501 .LogMajorStage("Prepack Implosion.")
2502
2503 *--- Single prepack implosion without prepack any logic (--Alpha)
2504 *--- with prepack any logic for (--Amerex)
2505 llRetVal= llRetVal AND .IsPrepackAny()
2506 .LogEntry("Getting multiple records prepack.")
2507 *--- prepack has multiple lines in the prepack detail
2508 *--- this is regardless of ALL exists or not in prepack detail
2509 llRetVal= llRetVal AND .GetMultiplePrepacks(pceipcTH, pceipcTD, "tcMultPPK")
2510 *--- Single prepack implosion without prepack any logic (--Alpha)
2511 *--- with prepack any logic for (--Amerex)
2512 IF .lSinglePrepackAny
2513 *--- check for each prepack that it resolve the SKU is in scolr
2514 .LogEntry("Getting all prepack SKUs from Style master for verify existing prepack.")
2515 .cQualPPKSkus = "tcQPPKSKU"
2516 *--- only BC sku with dim/pk as prepack from scolr
2517 llRetVal = llRetVal AND .GetQualifyPrepackSKU(pceipcTH, pceipcTD, .cQualPPKSkus)
2518 llRetVal = llRetVal AND .GetQualifyMultiPackPrePack(.cQualPPKSkus,.cMPPK)
2519 *-- Cannot join to zzxscolr and prepack detail color/label "ALL" is
2520 *-- a resolution not actual color/lbl to join.
2521 .LogEntry("Getting single record prepack with prepack any logic.")
2522 .GetSinglePrepacks(pceipcTH, pceipcTD, "tcSnglPPK")
2523 ELSE
2524 .LogEntry("Getting single record prepack without prepack any logic.")
2525 llRetVal = llRetVal AND .IsMultiPack(pceipcTH)
2526 IF THIS.lMultipack
2527 .MoreSinglePrepacksWithoutPrepackAny(pceipcTH, pceipcTD, "tcSnglPPK")
2528 ELSE
2529 .GetSinglePrepacksWithoutPrepackAny(pceipcTH, pceipcTD, "tcSnglPPK")
2530 ENDIF
2531 ENDIF
2532
2533 .LogEntry("Verifying implosion flag.")
2534 llRetVal = llRetVal AND .CascadingCustomerToDetail(pceipcTH, pceipcTD)
2535 .LogEntry("Creating temporaty order cursor for prepack match.")
2536 llRetVal = llRetVal AND .BuildOrderForPrepack(pceipcTH, pceipcTD, pceipcCR, "tcOrdDtl")
2537 .LogEntry("Implosion multiple records prepack.")
2538 llRetVal = llRetVal AND .ImplosionMultiPrepack(pceipcTH, pceipcTD, pceipcCR, "tcMultPPK", "tcOrdDtl")
2539 *--- Single prepack implosion without prepack any logic (--Alpha)
2540 *--- with prepack any logic for (--Amerex)
2541 IF .lSinglePrepackAny
2542 .LogEntry("Implosion single record prepack with prepack any logic.")
2543 llRetVal= llRetVal AND .ImplosionSinglePrepack(pceipcTH, pceipcTD, pceipcCR, "tcSnglPPK", "tcOrdDtl")
2544 .LogEntry("Getting single record single size prepack with prepack any logic.")
2545 .GetSingleSizePrepacks("tcSnglPPK", "tcSSizePPK")
2546 .LogEntry("Getting Vertical details for single size prepack with prepack any logic.")
2547 llRetVal= llRetVal AND .BuildVerticalOrderForPrepack("tcOrdDtl", "tcVertOrdDtl")
2548 .LogEntry("Implosion single record single size prepack with prepack any logic.")
2549 llRetVal= llRetVal AND .ImplosionSingleSizePrepackWithPrepackAny(pceipcTH, pceipcTD, pceipcCR, "tcSSizePPK", "tcVertOrdDtl")
2550 ELSE
2551 .LogEntry("Implosion single record prepack without prepack any logic.")
2552 llRetVal= llRetVal AND .ImplosionSinglePrepackWithoutPrepackAny(pceipcTH, pceipcTD, pceipcCR, "tcSnglPPK", "tcOrdDtl")
2553 *- Add new layer - single size implosion.
2554 *- Only for Alpha
2555 .LogEntry("Getting single record single size prepack without prepack any logic.")
2556 .GetSingleSizePrepacks("tcSnglPPK", "tcSSizePPK")
2557 .LogEntry("Getting Vertical details for single size prepack without prepack any logic.")
2558 llRetVal= llRetVal AND .BuildVerticalOrderForPrepack("tcOrdDtl", "tcVertOrdDtl")
2559 .LogEntry("Implosion single record single size prepack without prepack any logic.")
2560 llRetVal= llRetVal AND .ImplosionSingleSizePrepackWithoutPrepackAny(pceipcTH, pceipcTD, pceipcCR, "tcSSizePPK", "tcVertOrdDtl")
2561 ENDIF
2562
2563 .TableClose("tcMultPPK")
2564 .TableClose("tcSnglPPK")
2565 .TableClose("tcOrdDtl")
2566 ENDWITH
2567 SELECT(lnOldSelect)
2568 RETURN llRetVal
2569 ENDPROC
2570
2571 ************************************************************************************
2572 *-- Is prepack any logic set (prepack detail color_code='ALL' or lbl_code='ALL')
2573 ***********************************************************************************
2574 *--- Single prepack implosion without prepack any logic (--Alpha)
2575 *--- with prepack any logic for (--Amerex)
2576 PROCEDURE IsPrepackAny
2577 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2578 llRetVal = .T.
2579 lnOldSelect = SELECT()
2580 WITH THIS
2581 lcSQLString= "Select count(*) as ppk_any From zzxppakd where (color_code='ALL' or lbl_code='ALL')"
2582 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "tcTemp")
2583 .lSinglePrepackAny= IIF(USED("tcTemp") AND tcTemp.ppk_any > 0, .T., .F.) && for optimizing client that does not use Prepack Any logic
2584 *- To be able to test Alpha ppk logic (where .lSinglePrepackAny= .F.)
2585 *- Our DEV has records with color_code='ALL', so QA always uses the Amerex (.lSinglePrepackAny =.T.) logic.
2586 .lSinglePrepackAny = .lSinglePrepackAny AND (goEnv.SV("ALPHA_PPK_LOGIC", "N") = "N")
2587 .lSinglePrepackAny = .T. && TR 1041687 JUL-28-2009 BR
2588 ENDWITH
2589 SELECT(lnOldSelect)
2590 RETURN llRetVal
2591 ENDPROC
2592
2593 ***********************************************************************************
2594 * Get all Multiple Prepacks (by division,style) for resolving prepack
2595 ***********************************************************************************
2596 PROCEDURE GetMultiplePrepacks
2597 LPARAMETERS pcHeader, pcDetail, pcPrePack
2598 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2599 llRetVal = .T.
2600 lnOldSelect = SELECT()
2601
2602 SELECT DISTINCT d.division,d.STYLE FROM (pcDetail) d , (pcHeader) h ;
2603 WHERE h.pkey=d.fkey INTO CURSOR _TmpCursor && -- and !(d.Errs_Flg_D= "Y")
2604
2605 WITH THIS
2606 .cSQLTempTable=""
2607 IF .GenerateSQLTempTable('_TmpCursor')
2608 IF .PopulateSQLTempTable('_TmpCursor')
2609 IF !EMPTY(.cSQLTempTable)
2610 * Get ALL Multiple record Prepack for valid div,style
2611 lcSQLString= "Select ph.ppk_desc, ph.pack_qty, ph.mulcllb_ok, ph.ppk_color, pd.*,z.* " +;
2612 " FROM zzxppakh ph " +;
2613 " JOIN zzxppakd pd " +;
2614 " ON ph.pkey = pd.fkey " +;
2615 " JOIN zzxsizer z " +;
2616 " ON ph.division=z.division and ph.size_code=z.size_code " +;
2617 " WHERE ph.active_ok='Y' And ph.pack_qty > pd.pack_total and ph.division+ph.size_code IN " +;
2618 " (SELECT s.division + s.size_code " +;
2619 " FROM zzxscolr s " +;
2620 " JOIN " + .cSQLTempTable + " t " +;
2621 " ON (s.division=t.division And s.style=t.style) " +;
2622 " WHERE s.ppack_ok= 'Y' " +;
2623 " )"
2624 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "_PrePack")
2625 llRetVal= llRetVal AND .MakeCursorWritable("_PrePack", pcPrePack)
2626 ENDIF
2627 ENDIF
2628 ENDIF
2629 .TableClose('_TmpCursor')
2630 .TableClose('_PrePack')
2631 ENDWITH
2632 * index for optimizing
2633 IF USED(pcPrePack)
2634 SELECT (pcPrePack)
2635 *--- 860 Inbound implosion of Prepack - single color with multi dimension
2636 LOCATE FOR color_code= "ALL" OR lbl_code= "ALL"
2637 .lMultiPrepackAny= IIF(FOUND(), .T., .F.) && for optimizing client that does not use Prepack Any logic
2638 .oLog.LogEntry("Prepack any logic for multiple records: " + IIF(.lMultiPrepackAny, "Yes", "No"))
2639 LOCATE FOR color_code= "ALL" OR color_code= " "
2640 .lSingleColorMultiPrepack = FOUND()
2641 GO TOP IN (pcPrePack)
2642 INDEX ON division+ppk_code TAG DivPPK
2643 INDEX ON division+color_code+lbl_code+DIMENSION+ppk_code TAG ColLblDim
2644 ENDIF
2645
2646 SELECT(lnOldSelect)
2647 RETURN llRetVal
2648 ENDPROC
2649
2650 ***************************************************************************************
2651 *--- check for each prepack that it resolve the SKU is in scolr
2652 *-- COULD BE VERY SLOW, FOR EACH DETAIL LINE AND EACH RESOLUTION OF PREPACK NEED
2653 *-- TO VERIFY FOR EXISTING OF SKU IN SCOLR, DUE TO UNABLE TO JOIN BECAUSE PREPACK
2654 *-- PREPACK ANY LOGIC (COLOR,LBL_CODE COULD BE "ALL")
2655 PROCEDURE GetQualifyPrepackSKU
2656 LPARAMETERS pcHeader, pcDetail, pcPrePack
2657 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2658 llRetVal = .T.
2659 lnOldSelect = SELECT()
2660
2661 SELECT DISTINCT d.division,d.STYLE,h.customer FROM (pcDetail) d , (pcHeader) h ;
2662 WHERE h.pkey=d.fkey INTO CURSOR _TmpCursor && -- and !(d.Errs_Flg_D= "Y")
2663
2664 WITH THIS
2665 .cSQLTempTable=""
2666 IF .GenerateSQLTempTable('_TmpCursor')
2667 IF .PopulateSQLTempTable('_TmpCursor')
2668 IF !EMPTY(.cSQLTempTable)
2669 * Get ALL Single Prepack for valid div,style
2670 lcSQLString= "SELECT s.*,t.customer FROM zzxscolr s " +;
2671 " JOIN " + .cSQLTempTable + " t " +;
2672 " ON s.division=t.division And s.style=t.style " +;
2673 " WHERE s.ppack_ok= 'Y' "
2674 llRetVal= llRetVal AND v_SqlExec(lcSQLString, pcPrePack)
2675 ENDIF
2676 ENDIF
2677 ENDIF
2678 .TableClose('_TmpCursor')
2679 ENDWITH
2680
2681 IF USED(pcPrePack)
2682 SELECT (pcPrePack)
2683 INDEX ON division+STYLE+color_code+lbl_code+DIMENSION TAG OurSku
2684 ENDIF
2685
2686 SELECT(lnOldSelect)
2687 RETURN llRetVal
2688 ENDPROC
2689
2690 *************************************************************************************
2691
2692 FUNCTION GetQualifyMultiPackPrePack
2693 LPARAMETERS pcPrePack, pcMultPack
2694 LOCAL llRetVal, lnSelect, lcSQLString
2695
2696 llRetVal = True
2697 lnSelect = SELECT()
2698 SELECT * FROM (pcPrePack) INTO CURSOR _TmpCursor
2699 WITH THIS
2700 .cSQLTempTable=""
2701 IF .GenerateSQLTempTable('_TmpCursor')
2702 IF .PopulateSQLTempTable('_TmpCursor')
2703 IF !EMPTY(.cSQLTempTable)
2704
2705 *--- TR 1080606 16-8-2014 VKK changed m.* into indivdual fields to avoid error
2706 lcSQLString= "SELECT p.*,m.customer,m.mpack_code,total_qty FROM zzemppkh m " +;
2707 " JOIN " + .cSQLTempTable+ " p " +;
2708 " ON m.customer=p.customer "
2709
2710
2711 llRetVal = llRetVal AND v_SqlExec(lcSQLString, pcMultPack)
2712 ENDIF
2713 ENDIF
2714 ENDIF
2715 ENDWITH
2716
2717 THIS.lMultipack = USED(pcMultPack) AND RECCOUNT(pcMultPack) > 0
2718
2719 IF THIS.lMultipack
2720 SELECT (pcMultPack)
2721 INDEX ON STYLE+mpack_code TAG MStyPPK
2722 ENDIF
2723 .TableClose('__TmpCursor')
2724 SELECT (lnSelect)
2725 RETURN llRetVal
2726 ENDFUNC
2727
2728 ************************************************************************************
2729 * Get all Single Prepacks with prepack any logic (-See Amerex Implementation)
2730 ***********************************************************************************
2731 PROCEDURE GetSinglePrepacks
2732 LPARAMETERS pcHeader, pcDetail, pcPrePack
2733 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2734 llRetVal = .T.
2735 lnOldSelect = SELECT()
2736
2737 SELECT DISTINCT d.division,d.STYLE FROM (pcDetail) d , (pcHeader) h ;
2738 WHERE h.pkey=d.fkey INTO CURSOR _TmpCursor && -- and !(d.Errs_Flg_D= "Y")
2739
2740 WITH THIS
2741 .cSQLTempTable=""
2742 IF .GenerateSQLTempTable('_TmpCursor')
2743 IF .PopulateSQLTempTable('_TmpCursor')
2744 IF !EMPTY(.cSQLTempTable)
2745 * Get ALL Single Prepack for valid div,style
2746 lcSQLString= "Select ph.ppk_desc, ph.pack_qty, ph.mulcllb_ok,pd.*,z.* " +;
2747 " FROM zzxppakh ph " +;
2748 " JOIN zzxppakd pd " +;
2749 " ON ph.pkey = pd.fkey " +;
2750 " JOIN zzxsizer z " +;
2751 " ON ph.division=z.division and ph.size_code=z.size_code " +;
2752 " WHERE ph.active_ok='Y' And ph.pack_qty= pd.pack_total and ph.division+ph.size_code IN " +;
2753 " (SELECT s.division + s.size_code " +;
2754 " FROM zzxscolr s " +;
2755 " JOIN " + .cSQLTempTable + " t " +;
2756 " ON (s.division=t.division And s.style=t.style) " +;
2757 " WHERE s.ppack_ok= 'Y' " +;
2758 " )"
2759 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "_PrePack")
2760 llRetVal= llRetVal AND .MakeCursorWritable("_PrePack", pcPrePack)
2761 ENDIF
2762 ENDIF
2763 ENDIF
2764 .TableClose('_TmpCursor')
2765 .TableClose('_PrePack')
2766 ENDWITH
2767
2768 * index for optimizing
2769 IF USED(pcPrePack)
2770 SELECT (pcPrePack)
2771 INDEX ON division+color_code+lbl_code+DIMENSION+ppk_code TAG ColLblDim && with prepack any process without style
2772 ENDIF
2773
2774 SELECT(lnOldSelect)
2775 RETURN llRetVal
2776 ENDPROC
2777
2778 ******************************************************************************************
2779
2780 PROCEDURE IsMultiPack
2781 LPARAMETERS pcHeader
2782 LOCAL llRetVal, lnSelect, lcSQLString
2783
2784 llRetVal = .T.
2785 lnSelect = SELECT()
2786
2787 SELECT DISTINCT customer FROM (pcHeader) INTO CURSOR __TmpCursor
2788 WITH THIS
2789 .cSQLTempTable=""
2790
2791 IF .GenerateSQLTempTable('__TmpCursor')
2792 IF .PopulateSQLTempTable('__TmpCursor')
2793 IF !EMPTY(.cSQLTempTable)
2794 lcSQLString= "select mp.* from zzemppkh mp," + .cSQLTempTable + " t " +;
2795 "Where mp.customer = t.customer "
2796
2797 llRetVal = v_SqlExec(lcSQLString, "__TmpMppk")
2798 ENDIF
2799 ENDIF
2800 ENDIF
2801 .lMultipack = USED("__TmpMppk") AND RECCOUNT("__TmpMppk") > 0
2802 ENDWITH
2803 SELECT(lnSelect)
2804 RETURN llRetVal
2805 ENDPROC
2806
2807 ******************************************************************************************
2808
2809 PROCEDURE MoreSinglePrepacksWithoutPrepackAny
2810 LPARAMETERS pcHeader, pcDetail, pcPrePack
2811 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv, cSQLTempTable , cSQLTempTable1, lcSQLString, ;
2812 lnFirstAvlBucket
2813
2814 llRetVal = .T.
2815 lnOldSelect = SELECT()
2816 cSQLTempTable = ""
2817 cSQLTempTable1 = ""
2818
2819 SELECT DISTINCT d.division,d.STYLE,d.color_code FROM (pcDetail) d , (pcHeader) h ;
2820 WHERE h.pkey=d.fkey INTO CURSOR __TmpCursor && and !(h.Errs_Flg_H= "Y")
2821
2822 SELECT DISTINCT h.customer, d.division,d.STYLE,d.color_code, d.lbl_code FROM (pcDetail) d , (pcHeader) h ;
2823 WHERE h.pkey=d.fkey INTO CURSOR __TmpCursor2
2824
2825 WITH THIS
2826 .cSQLTempTable=""
2827 IF .GenerateSQLTempTable('__TmpCursor') AND .PopulateSQLTempTable('__TmpCursor')
2828 cSQLTempTable = .cSQLTempTable
2829 ENDIF
2830
2831 .cSQLTempTable=""
2832 IF .GenerateSQLTempTable('__TmpCursor2') AND .PopulateSQLTempTable('__TmpCursor2')
2833 cSQLTempTable1 = .cSQLTempTable
2834 ENDIF
2835
2836 IF !EMPTY(cSQLTempTable) AND !EMPTY(cSQLTempTable1)
2837 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
2838 lcSQLString= "Select ph.ppk_desc, ph.pack_qty, ph.mulcllb_ok," +;
2839 "99 as sizebucket, ' ' as size_desc, s.sizes, s.style, s.color_code as PPK_Color, "+;
2840 "s.lbl_code as PPK_Label,s.dimension as PPK_Dimension, pd.*, z.* " +;
2841 "from zzxppakh ph, zzxppakd pd, zzxscolr s, zzxsizer z, " + cSQLTempTable + " t " +;
2842 "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
2843 "s.style= t.style and s.color_code= t.color_code and " +;
2844 "s.division= ph.division and s.size_code= ph.size_code and "+;
2845 "s.dimension= ph.ppk_code and ph.pkey= pd.fkey and ph.pack_qty= pd.pack_total and " +; && Single Prepack
2846 "ph.division= z.division and ph.size_code= z.size_code and ph.Active_ok = 'Y' " +;
2847 " UNION ALL " +;
2848 "SELECT ph.ppk_desc " + ;
2849 ", ph.pack_qty " + ;
2850 ", ph.mulcllb_ok " + ;
2851 ", 99 AS sizebucket " + ;
2852 ", ' ' AS size_desc " + ;
2853 ", 'YNNNNNNNNNNNNNNNNNNNNNNN' AS sizes " + ;
2854 ", t1.style " + ;
2855 ", t1.color_code AS PPK_Color " + ;
2856 ", t1.lbl_code AS PPK_Label " + ;
2857 ", m.mpack_code AS PPK_Dimension " + ;
2858 ", pd.* " + ;
2859 ", z.* " + ;
2860 "FROM zzxppakh ph " + ;
2861 " , zzxppakd pd " + ;
2862 " ," + cSQLTempTable1 + " t1 " +;
2863 " , zzxsizer z " + ;
2864 " , zzeMPPKh m " + ;
2865 "WHERE " + ;
2866 " ph.pkey= pd.fkey " + ;
2867 " AND ph.pack_qty= pd.pack_total " + ;
2868 " AND ph.division= z.division " + ;
2869 " AND ph.size_code= z.size_code " + ;
2870 " AND m.customer = t1.customer " + ;
2871 " AND m.mpack_code = ph.ppk_code and ph.Active_ok = 'Y'" && *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
2872
2873 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "__PrePack")
2874 llRetVal= llRetVal AND .MakeCursorWritable("__PrePack", pcPrePack)
2875
2876 SELECT (pcPrePack)
2877 SCAN
2878 * Find 1st avail buckets and desc to store prepack items latter
2879 lnFirstAvlBucket= AT("Y", sizes, 1)
2880 lnFirstAvlBucket= IIF(lnFirstAvlBucket> 0, lnFirstAvlBucket, 1) && Otherwise stuff in 1st bucket
2881 lcSizeStr= "Size"+ PADL(lnFirstAvlBucket, 2, '0')
2882 REPLACE Sizebucket WITH lnFirstAvlBucket, size_desc WITH EVAL(lcSizeStr)
2883
2884 IF Mulcllb_Ok <> "Y"
2885 REPLACE color_code WITH PPK_color, lbl_code WITH ppk_label, DIMENSION WITH PPK_dimension IN (pcPrePack)
2886 ENDIF
2887 ENDSCAN
2888 ENDIF
2889
2890 .TableClose('__TmpCursor')
2891 .TableClose('__TmpCursor2')
2892 .TableClose('__Prepack')
2893
2894 ENDWITH
2895
2896 * index for optimizing
2897 IF USED(pcPrePack)
2898 SELECT (pcPrePack)
2899 INDEX ON division+STYLE+color_code+lbl_code+DIMENSION TAG CompSKU && without prepack any process with style
2900 ENDIF
2901
2902 SELECT(lnOldSelect)
2903 RETURN llRetVal
2904 ENDPROC
2905
2906
2907 ************************************************************************************
2908 * Get all Single Prepacks with no prepack any logic (-See Alpha Implementation)
2909 ***********************************************************************************
2910 PROCEDURE GetSinglePrepacksWithoutPrepackAny
2911 LPARAMETERS pcHeader, pcDetail, pcPrePack
2912 LOCAL llRetVal, lnOldSelect, lcCurStyleDiv
2913 llRetVal = .T.
2914 lnOldSelect = SELECT()
2915
2916 SELECT DISTINCT d.division,d.STYLE,d.color_code FROM (pcDetail) d , (pcHeader) h ;
2917 WHERE h.pkey=d.fkey INTO CURSOR __TmpCursor && and !(h.Errs_Flg_H= "Y")
2918
2919 WITH THIS
2920 .cSQLTempTable=""
2921 IF .GenerateSQLTempTable('__TmpCursor')
2922 IF .PopulateSQLTempTable('__TmpCursor')
2923 IF !EMPTY(.cSQLTempTable)
2924 * Only PrePack header,details components (zzxppakh/ppakd)
2925 * Blank label prepack (otherwise, will get 2 prepack for same style/color with diff
2926 * label (--ambiguous prepack)
2927 *-- Remove s.lbl_code='' (Use to select ONLY BLANK LABEL PREPACK)
2928 *-- Now select BLANK (GENERIC) and NONE BLANK LABEL
2929 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
2930
2931 lcSQLString= "Select ph.ppk_desc, ph.pack_qty, ph.mulcllb_ok," +;
2932 "99 as sizebucket, ' ' as size_desc, s.sizes, s.style, s.color_code as PPK_Color, "+;
2933 "s.lbl_code as PPK_Label,s.dimension as PPK_Dimension, pd.*, z.* " +;
2934 "from zzxppakh ph, zzxppakd pd, zzxscolr s, zzxsizer z, " + .cSQLTempTable + " t " +;
2935 "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
2936 "s.style= t.style and s.color_code= t.color_code and " +;
2937 "s.division= ph.division and s.size_code= ph.size_code and "+;
2938 "s.dimension= ph.ppk_code and ph.pkey= pd.fkey and ph.pack_qty= pd.pack_total and " +; && Single Prepack
2939 "ph.division= z.division and ph.size_code= z.size_code and ph.Active_ok = 'Y' "
2940 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "__PrePack")
2941 llRetVal= llRetVal AND .MakeCursorWritable("__PrePack", pcPrePack)
2942 SELECT (pcPrePack)
2943 SCAN
2944 * Find 1st avail buckets and desc to store prepack items latter
2945 lnFirstAvlBucket= AT("Y", sizes, 1)
2946 lnFirstAvlBucket= IIF(lnFirstAvlBucket> 0, lnFirstAvlBucket, 1) && Otherwise stuff in 1st bucket
2947 lcSizeStr= "Size"+ PADL(lnFirstAvlBucket, 2, '0')
2948 REPLACE Sizebucket WITH lnFirstAvlBucket, size_desc WITH EVAL(lcSizeStr)
2949 * Not Multi color/label prepack then use color and dimension from zzxscolr
2950 *--> only evaluate prepack with no label otherwise will get more than one
2951 *--> single prepack with same content (--Ambiguous prepack)
2952 *--* Allow all prepacks BLANK (GENERIC) and NONE BLANK (CUSTOMER)
2953 *--* Resolve Prepack 1st None blank then blank when use in combination (850 control)
2954 *--* Customer label and Implotion
2955 IF Mulcllb_Ok <> "Y"
2956 REPLACE color_code WITH PPK_color, lbl_code WITH ppk_label, DIMENSION WITH PPK_dimension IN (pcPrePack)
2957 ENDIF
2958 ENDSCAN
2959 ENDIF
2960 ENDIF
2961 ENDIF
2962 .TableClose('__TmpCursor')
2963 .TableClose('__Prepack')
2964 ENDWITH
2965
2966 * index for optimizing
2967 IF USED(pcPrePack)
2968 SELECT (pcPrePack)
2969 INDEX ON division+STYLE+color_code+lbl_code+DIMENSION TAG CompSKU && without prepack any process with style
2970 ENDIF
2971
2972 SELECT(lnOldSelect)
2973 RETURN llRetVal
2974 ENDPROC
2975
2976
2977 ************************************************************************************
2978 * Build horizontal work order detail to resolve prepack
2979 ***********************************************************************************
2980 PROCEDURE BuildOrderForPrepack
2981 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcOrdDtl
2982 LOCAL llRetVal, lnOldSelect
2983 llRetVal = .T.
2984 lnOldSelect = SELECT()
2985 IF TYPE(pceipcTD + ".rng_style") == 'U'
2986 SELECT DISTINCT d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
2987 FROM (pceipcTD) d , (pceipcTH) h ;
2988 WHERE h.pkey=d.fkey AND (d.division<>'' AND d.STYLE<>'') AND !(d.Errs_Flg_D= "Y") ; && or just none error???
2989 INTO CURSOR _TmpCursor && !(d.Errs_Flg_D= "Y") SKU with no errs.
2990 ELSE
2991 SELECT DISTINCT d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
2992 FROM (pceipcTD) d , (pceipcTH) h ;
2993 WHERE h.pkey=d.fkey AND (d.division<>'' AND d.STYLE<>'') AND !(d.Errs_Flg_D= "Y") ; && or just none error???
2994 AND d.rng_style = ' ' ;
2995 INTO CURSOR _TmpCursor && !(d.Errs_Flg_D= "Y") SKU with no errs.
2996 ENDIF
2997
2998 WITH THIS
2999 .oLog.LogEntry("Creating horizontal order cursor for Prepack Implosion.")
3000
3001 IF RECC("_TmpCursor")> 0
3002
3003 * 1. Get all none distinct prepack style for order that ready to process to live
3004 * send to server for server side join
3005 .cSQLTempTable= ""
3006 llRetVal= llRetVal AND .GenerateSQLTempTable('_TmpCursor')
3007 llRetVal= llRetVal AND .PopulateSQLTempTable('_TmpCursor')
3008 IF !EMPTY(.cSQLTempTable)
3009 * Bring in Style/color (zzxscolr) for SKU that need to implode
3010 lcSQLString= "Select s.* " +;
3011 "from zzxscolr s, " + .cSQLTempTable + " t " +;
3012 "Where (s.ppack_ok= 'N') and s.division= t.division and s.style= t.style and " +;
3013 "s.color_code= t.color_code and s.lbl_code=t.lbl_code and s.dimension=t.dimension "
3014 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "tcPPKSKU")
3015 ENDIF
3016 * 2. Get all detail line (--vertical) that require implostion to prepack
3017 *--- choices by '860 Control Resolve Label'
3018 *-- (Cust_lbl) use 860 control Customer Label (in addition to force customer label to our SKU)
3019 *-- to resolve customer label prepack (NONE BLANK LABEL) 1st then generic prepack (BLANK LABEL)
3020 IF llRetVal AND RECC("tcPPKSKU")> 0
3021
3022 *--- TR 1048865 27-Dec-2010 Goutam
3023 *SELECT d.*, IIF(h.impl_ok $ 'YO', h.impl_ok, C.impl_ok) AS impl_ok, C.lbl_code AS cust_lbl ;
3024 FROM (pceipcTD) d ;
3025 JOIN (pceipcCR) C ON d.customer= C.customer AND d.division= C.division ;
3026 JOIN tcPPKSKU s ON s.division=d.division AND s.STYLE=d.STYLE AND s.color_code=d.color_code AND ;
3027 s.lbl_code=d.lbl_code AND s.DIMENSION=d.DIMENSION ;
3028 JOIN (pceipcTH) h ON h.pkey = d.fkey ;
3029 WHERE ( h.impl_ok $ 'YO' OR (h.impl_ok = ' ' AND C.impl_ok $'YO') ) ;
3030 AND d.fkey NOT IN ;
3031 (SELECT d1.fkey FROM (pceipcTD) d1 ;
3032 WHERE d1.Errs_Flg_D = 'Y') ;
3033 ORDER BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION,;
3034 d.poc_cost,d.org_price ;
3035 INTO CURSOR _DtlImpl
3036
3037 SELECT d.*, IIF(h.impl_ok $ 'YO', h.impl_ok, C.impl_ok) AS impl_ok, C.lbl_code AS cust_lbl ;
3038 FROM (pceipcTD) d ;
3039 JOIN tcPPKSKU s ON s.division=d.division AND s.STYLE=d.STYLE AND s.color_code=d.color_code AND ;
3040 s.lbl_code=d.lbl_code AND s.DIMENSION=d.DIMENSION ;
3041 JOIN (pceipcTH) h ON h.pkey = d.fkey ;
3042 JOIN (pceipcCR) c ON c.pkey = h.cr_pkey ;
3043 WHERE ( h.impl_ok $ 'YO' OR (h.impl_ok = ' ' AND C.impl_ok $'YO') ) ;
3044 AND d.fkey NOT IN ;
3045 (SELECT d1.fkey FROM (pceipcTD) d1 ;
3046 WHERE d1.Errs_Flg_D = 'Y') ;
3047 ORDER BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION,;
3048 d.poc_cost,d.org_price ;
3049 INTO CURSOR _DtlImpl
3050 *--- TR 1048865 27-Dec-2010 Goutam
3051
3052 * 3. consolidate them to horizontal size (as if they process into live order)
3053 * for comparing to prepack
3054 *--- Added two more columns Qty_change, qualifier
3055 *- TR 1046528 FH - Added fields poc_cost and poc_price per Yuri
3056 *--- TechRec 1054692 21-Sep-2011 jisingh Added , retail2 as poc_retail2 ===
3057 lcSQLString= "Select *,bulk_key as sizebucket,color_code as size_desc,"+;
3058 "dimension as ppk_code,color_code as ppk_color,bulk_key as col_cnt,"+;
3059 "line_status as ppk_status,line_status as impl_ok, " +;
3060 AsField('C(60)') + " AS avail_ppk, 0 as Qty_change, ' ' as qualifier " + ; && 10/21 Store ambiguous ppk for new manual implosion UI
3061 ", price as poc_cost, retail1 as poc_price, retail2 as poc_retail2 " + ;
3062 "from zzoordrd where 0=1"
3063 llRetVal= llRetVal AND v_SqlExec(lcSQLString, pcOrdDtl)
3064 * index for optimizing
3065 IF USED(pcOrdDtl)
3066 SELECT (pcOrdDtl)
3067 *- Index on Str(fkey)+Style+lbl_code tag fkeystyle
3068 INDEX ON STR(fkey)+STYLE+color_code+lbl_code TAG fkeystyle
3069 ENDIF
3070
3071 lcCurrKeys= ""
3072 SELECT _DtlImpl
3073 llRetVal= .SetRelation(pceipcTD, "pkey", "_DtlImpl" , "pkey")
3074 SCAN
3075 SCATTER MEMVAR
3076 IF ! (STR(fkey)+STYLE+color_code+lbl_code+DIMENSION+;
3077 STR(poc_cost)+STR(org_price) == lcCurrKeys)
3078 * Use 1st pkey from this group as dtlpkey
3079 lnCurDtlPkey= m.pkey
3080 m.total_qty= 0
3081 m.Qty_change=0
3082 m.avail_ppk= "" && reset previous run avail_ppk
3083 *-- TR 1046794 APR-23-2010 BR
3084 lnCurDtlPrice = m.poc_cost
3085 lnCurDtlRetail = m.poc_price
3086 lnCurDtlRetail2 = m.poc_retail2 &&--- TechRec 1054692 21-Sep-2011 jisingh ===
3087 *==
3088 *--use order work cursor LINE_STATUS to store implosion status, clear latter when done.
3089 *--- Resolve Prepack with label
3090 * m.sub_lbl= m.cust_lbl && use order work cursor SUB_LABEL to store customer label && TR 1016560 NH
3091 SELECT (pcOrdDtl)
3092 * Create order detail line when keys change
3093 APPEND BLANK
3094 GATHER MEMVAR
3095 lcCurrKeys= STR(fkey)+STYLE+color_code+lbl_code+DIMENSION+;
3096 STR(poc_cost)+STR(org_price)
3097 ENDIF
3098
3099 * DtlPkey: Use to identify group of Trans. detail (which combine into single line)
3100 * by: str(fkey)+style+color_code+lbl_code+dimension+;
3101 * str(price)+str(org_price)+po1_sku+po1_upc
3102 REPLACE dtlpkey WITH lnCurDtlPkey IN (pceipcTD)
3103
3104 * store DtlPkey to pcOrdDtl.pkey for latter remove group of trans detail
3105 REPLACE pkey WITH lnCurDtlPkey IN (pcOrdDtl)
3106
3107 *--TR 1046794 APR-23-2010 BR
3108 REPLACE price WITH lnCurDtlPrice IN (pcOrdDtl)
3109 REPLACE retail1 WITH lnCurDtlRetail IN (pcOrdDtl)
3110 REPLACE retail2 WITH lnCurDtlRetail2 IN (pcOrdDtl) &&--- TechRec 1054692 21-Sep-2011 jisingh ===
3111 *==
3112
3113 * For each detail line write acumm. total_qty and size qty to proper bucket
3114 * ie. Replace size01_qty with size01_qty + pceipcTD..total_qty ...
3115
3116 IF EVALUATE(pceipcTD + ".Sizebucket") > 0 && 12/10/02
3117 lcSizeStr = "size" + PADL(EVALUATE(pceipcTD + ".Sizebucket"), 2, '0') + "_qty"
3118 *lcSizeQty= STR(EVALUATE(pceipcTD + ".total_qty"))
3119 lnSizeQty = EVALUATE(pceipcTD + ".Qty_change")
3120*!* lcReplaceStr= "Replace " + lcSizeStr + " With " + lcSizeStr +;
3121*!* " + " + lcSizeQty + ",Total_qty With Total_qty+ " + lcSizeQty +;
3122*!* " In " + pcOrdDtl
3123 replace (lcSizeStr) WITH EVALUATE(lcSizeStr) + lnSizeQty ,;
3124 Total_qty WITH Total_qty + lnSizeQty ;
3125 Qty_change WITH Qty_change + lnSizeQty IN (pcOrdDtl)
3126 ENDIF
3127 ENDSCAN
3128
3129 *--- 850 Multiple Prepack Implosion
3130 * 4. mark all qualify order line with same style,lable with number of colors
3131 * for Multi color pack match
3132 IF RECC(pcOrdDtl)>0
3133 GO TOP IN (pcOrdDtl)
3134 *- Group by color code as well, one color per prepack ???
3135 IF .lSingleColorMultiPrepack
3136 lcSQLString= "SELECT fkey, style, color_code, lbl_code, COUNT(*) as col_cnt FROM " + pcOrdDtl +;
3137 " GROUP BY fkey, style, color_code, lbl_code HAVING COUNT(*) > 1 "
3138 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "_MultCol",, .T.) && local
3139 SELECT _MultCol
3140 SCAN
3141 REPLACE col_cnt WITH _MultCol.col_cnt ;
3142 FOR STR(fkey)+STYLE+color_code+lbl_code= ;
3143 (STR(_MultCol.fkey)+_MultCol.STYLE+_MultCol.color_code+_MultCol.lbl_code) ;
3144 IN (pcOrdDtl)
3145 ENDSCAN
3146 ELSE
3147 lcSQLString= "SELECT fkey, style, lbl_code, COUNT(*) as col_cnt FROM " + pcOrdDtl +;
3148 " GROUP BY fkey, style, lbl_code HAVING COUNT(*) > 1 "
3149 llRetVal= llRetVal AND v_SqlExec(lcSQLString, "_MultCol",, .T.) && local
3150 SELECT _MultCol
3151 SCAN
3152 REPLACE col_cnt WITH _MultCol.col_cnt ;
3153 FOR STR(fkey)+STYLE+lbl_code= ;
3154 (STR(_MultCol.fkey)+_MultCol.STYLE+_MultCol.lbl_code) ;
3155 IN (pcOrdDtl)
3156 ENDSCAN
3157 ENDIF
3158 ENDIF
3159 ENDIF
3160 .TableClose('_TmpCursor')
3161 .TableClose('tcPPKSKU')
3162 .TableClose('_DtlImpl')
3163 .TableClose('_MultCol')
3164 ENDIF
3165 ENDWITH
3166
3167 SELECT(lnOldSelect)
3168 RETURN llRetVal
3169 ENDPROC
3170
3171 ************************************************************************************
3172 * Only for multi records color prepack match:
3173 ************************************************************************************
3174 *- Step 1. Color(Exact), Label(Exact), Dimension(Exact)
3175 *- Step 2. Color(BLANK), Label(BLANK), Dimension(Exact)
3176 *- Step 3. Color(Exact), Label("ALL"), Dimension(Exact)
3177 *- Step 4. Color("ALL"), Label(Exact), Dimension(Exact)
3178 *- Step 5. Color("ALL"), Label("ALL"), Dimension(Exact)
3179 *- Notes: Optimizing for client that does NOT USE Prepack Any logic,
3180 *- base on .lMultiPrepackAny to continue step 3- 5 or not.
3181 *
3182 * Need to record all posible match for each color within style (ambiguous)
3183 * any ambiguous (ppk_status='M') or missing color (ppk_status='F')
3184 * All evaluation base on the entire style (multi color/lbl/dim).
3185 * For any style that have no match (ppk_status='') will continue latter with single
3186 * record match
3187 *
3188 *- Use ppk_status for Multi record match:
3189 *- "1": Found one match (Good)
3190 *- "M": Found many match
3191 *- "F": Found many match but cannot use any of them
3192 *- "" : Not Found (will continue on next pass- single color prepack match)
3193 ***********************************************************************************
3194 PROCEDURE ImplosionMultiPrepack
3195 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcPrePack, pcOrdDtl
3196 LOCAL llRetVal, lnOldSelect, lcCurDtlPkey, lcPrepack, lcCurStyleColor, loOrder, ;
3197 lnPackMultiple, llFoundPrepack, lcSize_desc, lnSizeBucket, llUseCustomerLabel, ;
3198 lcCustomerLabel, lcPPKSearch, lcErrorMsg, lcMultPPKColor
3199 llRetVal = .T.
3200 lnOldSelect = SELECT()
3201 WITH THIS
3202 lcEnt_user= EDI_USER
3203 SELECT (pcPrePack)
3204 SET ORDER TO ColLblDim && resolve prepack by division,color,Label
3205 SELECT (pceipcTD)
3206 .PushRecordSet()
3207 SET ORDER TO dtlpkey && by dtlpkey
3208 .lAmbiguousPrepack= .F.
3209
3210 IF USED(pcPrePack) AND USED(pcOrdDtl) && could have nothing to do
3211 SELECT (pcOrdDtl) && Horizontal size cursor that group lines in order to find prepack
3212 * ONLY Multi Colors style order line will be qualify to for Multi color prepack match
3213 SET FILTER TO col_cnt>0
3214 GO TOP IN (pcOrdDtl)
3215 SCAN
3216 STORE "" TO lcErrorMsg, lcPPKSearch, lcPrepack, lcSize_desc, lcMultPPKColor
3217 lnSizeBucket= 0
3218 llFoundPrepack= .F.
3219 SCATTER NAME loOrder
3220
3221 *- Step 1. Color(Exact), Label(Exact), Dimension(Exact) {compare with Prepack detail}
3222 *- Label could get it label from CustSKU or 850 Control (Cust label)
3223 *- ie. col: RED, lbl: KU (KIDsR US), Dim:
3224 lcCustomerLabel= "" && loOrder.sub_lbl && store customer label from 850 control
3225 llUseCustomerLabel= !EMPTY(lcCustomerLabel)
3226 lcCustomerLabel= IIF(llUseCustomerLabel, lcCustomerLabel, loOrder.lbl_code) && or tran detail
3227 llFoundPrepack=.GetPrepack( loOrder.division, loOrder.color_code, ;
3228 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3229 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch, .T., @lcMultPPKColor)
3230 IF llFoundPrepack
3231 .UpdateResolvedPrepack(lnSizeBucket, lcSize_desc, lcPrepack, lcPPKSearch, lcMultPPKColor,;
3232 pcOrdDtl)
3233 ENDIF
3234
3235 *--- PL 11/28/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3236 *- Step 2. Color(BLANK), Label(BLANK), Dimension(Exact)
3237 *- ie. col: BLANK, lbl: BLANK, Dim: EXACT
3238 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && Prepack BLANK LABEL && TR 1016560 nh
3239 lcColorMatch= SPACE(LEN(loOrder.sub_color)) && Prepack BLANK Color
3240 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3241 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3242 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch, .T., @lcMultPPKColor)
3243 IF llFoundPrepack
3244 .UpdateResolvedPrepack(lnSizeBucket, lcSize_desc, lcPrepack, lcPPKSearch, lcMultPPKColor,;
3245 pcOrdDtl)
3246 ENDIF
3247 *=== PL 11/28/02 35734
3248
3249 *--- PL 12/06/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3250 *-- optimizing for client that does NOT USE Prepack Any logic, no need to continue step 3- 5.
3251 IF .lMultiPrepackAny
3252 *- Step 3. Color(Exact), Label("ALL"), Dimension(Exact)
3253 *- ie. col: RED, lbl: ALL , Dim:
3254 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3255 llFoundPrepack=.GetPrepack( loOrder.division, loOrder.color_code, ;
3256 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3257 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch, .T., @lcMultPPKColor)
3258 IF llFoundPrepack
3259 .UpdateResolvedPrepack(lnSizeBucket, lcSize_desc, lcPrepack, lcPPKSearch, lcMultPPKColor,;
3260 pcOrdDtl)
3261 ENDIF
3262
3263 *--- PL 11/28/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3264 *- Step 4. Color("ALL"), Label(Exact), Dimension(Exact)
3265 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3266 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3267 loOrder.lbl_code, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3268 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch, .T., @lcMultPPKColor)
3269 IF llFoundPrepack
3270 .UpdateResolvedPrepack(lnSizeBucket, lcSize_desc, lcPrepack, lcPPKSearch, lcMultPPKColor,;
3271 pcOrdDtl)
3272 ENDIF
3273 *=== PL 11/28/02 35734
3274
3275 *--- PL 11/28/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3276 *- Step 5. Color("ALL"), Label("ALL"), Dimension(Exact)
3277 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3278 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3279 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3280 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3281 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch, .T., @lcMultPPKColor)
3282 IF llFoundPrepack
3283 .UpdateResolvedPrepack(lnSizeBucket, lcSize_desc, lcPrepack, lcPPKSearch, lcMultPPKColor,;
3284 pcOrdDtl)
3285 ENDIF
3286 ENDIF && lMultiPrepackAny - only when Prepack Any logic exist
3287 *=== PL 12/06/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3288
3289 ENDSCAN
3290
3291 *--reset filter
3292 SELECT (pcOrdDtl)
3293 SET FILTER TO
3294 GO TOP IN (pcOrdDtl)
3295
3296 *--- PL 12/06/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3297 llRetVal= llRetVal AND .MultiPrepackEvaluating(pcOrdDtl, pceipcTD, pcPrePack)
3298 llRetVal= llRetVal AND .MultiPrepackAmbiguous(pcOrdDtl, pceipcTD)
3299 llRetVal= llRetVal AND .MultiPrepackMissing(pcOrdDtl, pceipcTD)
3300 *-- When run into one record Mod() to diff. number than other record for same style
3301 *-- due to resolving/narrow down of multiple match
3302 *-- then need to implement (Will take more time)
3303 *--- 39548 06/03/03 YIK
3304 *-- Verify Min_multiple by style/ resolved prepack prior implosion as the last check
3305 llRetVal= llRetVal AND .MultiPrepackMinMultiple(pcOrdDtl, pceipcTD, pcPrePack)
3306 *=
3307 llRetVal= llRetVal AND .MultiPrepackFinalize(pcOrdDtl, pceipcTD)
3308 *=== PL 12/06/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3309
3310 ENDIF
3311
3312 SELECT (pceipcTD)
3313 .PopRecordSet()
3314
3315 ENDWITH
3316 SELECT(lnOldSelect)
3317 RETURN llRetVal
3318 ENDPROC
3319
3320 ************************************************************************************
3321 * For single record match (Prepack detail with only one record) the below show steps
3322 * when it found a match and all buckets divisible evently will not continue.
3323 * Which is difference than multi records match will try to find all matches at
3324 * all levels, then eliminate by narrow down to the correct one if posible.
3325 *- Step 1. Color(Exact), Label(NONE BLANK), Dimension(Exact) {cust label from zzeipocr)
3326 *- Step 2. Color(Exact), Label(BLANK), Dimension(Exact)
3327 *- Step 3. Color(BLANK), Label(BLANK), Dimension(Exact)
3328 *- Step 4. Color(Exact), Label(ALL), Dimension(Exact)
3329 *- Step 5. Color(ALL), Label(Exact), Dimension(Exact)
3330 *- Step 6. Color(ALL), Label(ALL), Dimension(Exact)
3331 *- Notes: Optimizing for client that does NOT USE Prepack Any logic,
3332 *- base on .lSinglePrepackAny to continue step 4- 6 or not.
3333 ***********************************************************************************
3334 PROCEDURE ImplosionSinglePrepack
3335 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcPrePack, pcOrdDtl
3336 LOCAL llRetVal, lnOldSelect, lcCurDtlPkey, lcPrepack, lcCurStyleColor, loOrder, ;
3337 lnPackMultiple, llFoundPrepack, lcSize_desc, lnSizeBucket, llUseCustomerLabel, ;
3338 lcCustomerLabel, lcPPKSearch, lcErrorMsg
3339 llRetVal = .T.
3340 lnOldSelect = SELECT()
3341 WITH THIS
3342 lcEnt_user= EDI_USER
3343 SELECT (pcPrePack)
3344 SET ORDER TO ColLblDim && resolve prepack by division,color,Label
3345 SELECT (pceipcTD)
3346 .PushRecordSet()
3347 SET ORDER TO dtlpkey && by dtlpkey
3348
3349 .lAmbiguousPrepack= .F. && 28265 09/12/02
3350
3351 IF USED(pcOrdDtl) && could have nothing to do
3352 SELECT (pcOrdDtl) && Horizontal size cursor that group lines in order to find prepack
3353 SET FILTER TO col_cnt=0 && ?RON: WILL NOT SEE Multi COLOR Prepack eligigle record
3354 GO TOP
3355 SCAN
3356
3357 *--- 32617 07/10/02 PL 850 PPK Implosion - Modify logic to limit valid
3358 *--- choices by '850 Control Resolve Label'
3359 STORE "" TO lcErrorMsg, lcPPKSearch, lcPrepack, lcSize_desc
3360 lnSizeBucket= 0
3361 lcCurDtlPkey= &pcOrdDtl..pkey
3362 lcImplosion= &pcOrdDtl..impl_ok && -- added line_status && implosion status "O"pen stock, "Y", "N"
3363 *-- TR 1046794 APR-23-2010 BR
3364 lnCurDtlPrice = &pcOrdDtl..price
3365 lnCurDtlRetail = &pcOrdDtl..retail1
3366 lnCurDtlRetail2 = &pcOrdDtl..retail2 &&--- TechRec 1054692 21-Sep-2011 jisingh ===
3367 *==
3368
3369 SCATTER NAME loOrder
3370
3371 llFoundPrepack= .F.
3372 lcCustomerLabel= "" && loOrder.sub_lbl && store customer label from 850 control
3373 llUseCustomerLabel= !EMPTY(lcCustomerLabel)
3374
3375 *--- 28265 09/12/02 PL -- 850 complex Implosion
3376 *-- or 850 trans have label (SKU/UPC -> d,s,c,l (none blank),)
3377
3378 *- Step 1. Color(Exact), Label(NONE BLANK), Dimension(Exact) {compare with Prepack detail}
3379 *- Label(NONE BLANK) could get it label from CustSKU or 850 Control (Cust label)
3380 lcCustomerLabel= IIF(llUseCustomerLabel, lcCustomerLabel, loOrder.lbl_code)
3381 IF NOT EMPTY(lcCustomerLabel) && Use Customer Label From 850 control ref.
3382 llFoundPrepack=.GetPrepack( loOrder.division, loOrder.color_code, ;
3383 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3384 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3385 ENDIF
3386
3387 *- Step 2. Color(Exact), Label(BLANK), Dimension(Exact)
3388 IF NOT llFoundPrepack && NO Prepack found then
3389 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && Prepack BLANK LABEL
3390 llFoundPrepack=.GetPrepack( loOrder.division, loOrder.color_code, ;
3391 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3392 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3393 ENDIF
3394
3395 *- Step 3. Color(BLANK), Label(BLANK), Dimension(Exact)
3396 IF NOT llFoundPrepack && NO Prepack found then
3397 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && Prepack BLANK LABEL
3398 lcColorMatch= SPACE(LEN(loOrder.sub_color)) && Prepack BLANK Color
3399 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3400 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3401 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3402
3403 *--- TR 1041965 AUG-17-2009 BR
3404 IF !EMPTY(loOrder.lbl_code)
3405 lcCustomerLabel= loOrder.lbl_code
3406 ENDIF
3407 *=== TR 1041965 AUG-17-2009 BR
3408 ENDIF
3409
3410 *--- PL 12/06/02 35734 - 850 Inbound implosion of Prepack - single color with multi dimension
3411 *-- optimizing for client that does NOT USE Prepack Any logic, no need to continue step 4- 6.
3412 IF .lSinglePrepackAny
3413 *- Step 4. Color(Exact), Label(ALL), Dimension(Exact)
3414 *- ie. col: RED, lbl: ALL, Dim:
3415 IF NOT llFoundPrepack && NO Prepack found then
3416 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3417 llFoundPrepack=.GetPrepack( loOrder.division, loOrder.color_code, ;
3418 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3419 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3420 lcCustomerLabel= loOrder.lbl_code && actual label to use from trans detail component
3421 ENDIF
3422
3423 *- Step 5. Color(ALL), Label(Exact), Dimension(Exact)
3424 *- ie. col: ALL, lbl: KU, Dim:
3425 IF NOT llFoundPrepack && NO Prepack found then
3426 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3427 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3428 loOrder.lbl_code, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3429 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3430 ENDIF
3431
3432 *- Step 6. Color(ALL), Label(ALL), Dimension(Exact)
3433 *- ie. col: ALL, lbl: ALL, Dim:
3434 IF NOT llFoundPrepack && NO Prepack found then
3435 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3436 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3437 llFoundPrepack=.GetPrepack( loOrder.division, lcColorMatch, ;
3438 lcCustomerLabel, loOrder.DIMENSION, pcPrePack, pcOrdDtl, ;
3439 @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3440 lcCustomerLabel= loOrder.lbl_code && actual label to use from trans detail component
3441 ENDIF
3442 ENDIF && .lSinglePrepackAny - only when Prepack Any logic exist
3443 *=== PL 12/06/02 35734
3444
3445 *-- Finallize the results of single record match:
3446 *-- llFoundPrepack - True: when found one or more match from the previous steps
3447 *-- lAmbiguousPrepack - True: when found more match from the previous steps.
3448 *-- Ambiguous only when find many matches at the same level.
3449 * seek to 1st record in trans. detail using dtlpkey
3450 * either replace with error message or remove them and insert with new
3451 * prepack trans. detail
3452 SELECT (pceipcTD)
3453 IF SEEK(lcCurDtlPkey, pceipcTD, "DtlPkey")
3454
3455 *-- Update trans. with error msg: No prepack found or Ambiguous prepack found:
3456 IF (NOT llFoundPrepack) OR (.lAmbiguousPrepack) && Empty(lcPrepack) && no prepack found
3457 * Only error out when Implosion set "Y", when set "O"pen stock skip error
3458 IF lcImplosion= "Y"
3459 SCAN WHILE dtlpkey= lcCurDtlPkey
3460 IF NOT llFoundPrepack
3461 lcErrorMsg= NO_PREPACK + CRLF && "Searching Prepacks below: " + CRLF + lcPPKSearch
3462 ELSE
3463 lcErrorMsg= lcPPKSearch
3464 ENDIF
3465
3466 *- 1005452 06/04/04 YIK
3467 *- Concatenate error message, not overwrite
3468 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH Errs_Msg_D + CRLF + lcErrorMsg IN (pceipcTD)
3469
3470 *--- PL 02/05/03 36302 -- check for each prepack that it resolve the SKU is in scolr
3471 IF .lAmbiguousPrepack
3472 lcTmpStr= STRTRAN(lcPPKSearch, "Ambiguous Prepacks: ", "")
3473 lcTmpStr= STRTRAN(lcTmpStr, CRLF , "")
3474 REPLACE avail_ppk WITH lcTmpStr IN (pceipcTD)
3475
3476 *--- 1050956 24-Nov-10 SK Mark as Ambiguous. Won't process further ===
3477 Replace ppk_status With 'M' In (pcOrdDtl)
3478 ENDIF
3479 *=== PL 02/05/03 36302 -- check for each prepack that it resolve the SKU is in scolr
3480
3481 ENDSCAN
3482 ENDIF
3483 ELSE
3484
3485 *-- Found prepack:
3486 * - remove all trans detail records for same detail line by DtlPkey
3487 * - insert new trans. detail from (Implode many components into single prepack)
3488 lcDoc_num= &pceipcTD..doc_num
3489 lnPkey= v_nextPkey("ZZEIPCTD") && &pceipcTD..pkey
3490 lnFkey= &pceipcTD..fkey
3491 DELETE FOR dtlpkey= lcCurDtlPkey IN (pceipcTD)
3492 SELECT (pceipcTD)
3493 APPEND BLANK
3494 GATHER NAME loOrder
3495 *- 1001378 11/24/03 YIK
3496 *- Add ..implosion with "Y" to the replace to indicate that the item was imploded.
3497 *-- TR 1046794 APR-23-2010 BR - ADDED poc_cost and poc_price
3498 *--- TechRec 1054692 21-Sep-2011 jisingh Added poc_retail2 WITH IIF(qualifier = 'AI',lnCurDtlRetail2,poc_retail2) ===
3499 REPLACE lbl_code WITH lcCustomerLabel, ; && 28265 09/12/02
3500 DIMENSION WITH lcPrepack, doc_num WITH lcDoc_num,;
3501 Sizebucket WITH lnSizeBucket, size_desc WITH lcSize_desc,;
3502 pkey WITH lnPkey, fkey WITH lnFkey, ; && done using it for customer label
3503 User_id WITH lcEnt_user, Last_mod WITH DATETIME(), ;
3504 implosion WITH "Y", ;
3505 Errs_Flg_D WITH "N", Errs_Msg_D WITH "" , ;
3506 poc_cost WITH IIF(qualifier = 'AI',lnCurDtlPrice,poc_cost) , ;
3507 poc_price WITH IIF(qualifier = 'AI',lnCurDtlRetail,poc_price), ;
3508 poc_retail2 WITH IIF(qualifier = 'AI',lnCurDtlRetail2,poc_retail2) IN (pceipcTD)
3509 ENDIF
3510 ENDIF
3511
3512 ENDSCAN && Each temp order detail
3513
3514 *--Reset filter
3515 SELECT (pcOrdDtl) && Horizontal size cursor that group lines in order to find prepack
3516 SET FILTER TO
3517 GO TOP IN (pcOrdDtl)
3518
3519 ENDIF
3520
3521 SELECT (pceipcTD)
3522 .PopRecordSet()
3523
3524 ENDWITH
3525 SELECT(lnOldSelect)
3526 RETURN llRetVal
3527 ENDPROC
3528
3529 PROCEDURE ImplosionSingleSizePrepackWithPrepackAny
3530 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcPrePack, pcOrdDtl
3531 LOCAL llRetVal, lnOldSelect, lcCurDtlPkey, lcPrepack, lcCurStyleColor, loOrder, ;
3532 lnPackMultiple, llFoundPrepack, lcSize_desc, lnSizeBucket, llUseCustomerLabel, ;
3533 lcCustomerLabel, lcPPKSearch, lcErrorMsg
3534 *- NOTE: pcPrepack contains only single-size prepacks
3535 llRetVal = .T.
3536 lnOldSelect = SELECT()
3537 WITH THIS
3538 lcEnt_user= EDI_USER
3539 SELECT (pcPrePack)
3540 SET ORDER TO CompSKU && resolve prepack by division,style,color
3541 SELECT (pceipcTD)
3542 .PushRecordSet()
3543 SET ORDER TO dtlpkey && by dtlpkey
3544 IF USED(pcOrdDtl) && could have nothing to do
3545 SELECT (pcOrdDtl) && Vertical size cursor that group lines in order to find prepack
3546 SCAN
3547 STORE "" TO lcErrorMsg, lcPPKSearch, lcPrepack, lcSize_desc
3548 lnSizeBucket= 0
3549 lnOrigSzBucket = size_bk
3550 lcCurDtlSzPkey = STR(pkey) + STR(size_bk)
3551 lcImplosion= impl_ok
3552
3553 SCATTER NAME loOrder
3554
3555 loOrder.Sizebucket = size_bk
3556 loOrder.total_qty= Qty
3557 loOrder.Qty_change = Qty
3558 IF SEEK(lcCurDtlSzPkey, pceipcTD, "DtlSzPkey")
3559 loOrder.size_desc = &pceipcTD..size_desc
3560 ENDIF
3561 llFoundPrepack= .F.
3562 .lAmbiguousPrepack = .F.
3563
3564 lcCustomerLabel= "" && loOrder.sub_lbl && store customer label from 860 control
3565 llUseCustomerLabel= !EMPTY(lcCustomerLabel)
3566 IF llUseCustomerLabel && 1st find Customer Label Prepack when 860 customer label and implotion set
3567 llFoundPrepack=.ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3568 loOrder.color_code, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3569 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3570 ENDIF
3571
3572 IF NOT llFoundPrepack && NO Prepack found then
3573 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && (GENERIC) Prepack BLANK LABEL
3574 llFoundPrepack=.ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3575 loOrder.color_code, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3576 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3577 ENDIF
3578
3579 IF NOT llFoundPrepack && NO Prepack found then
3580 lcCustomerLabel = SPACE(LEN(loOrder.sub_lbl)) && (GENERIC) Prepack BLANK LABEL
3581 lcColorMatch = SPACE(LEN(loOrder.sub_color))
3582 llFoundPrepack = .ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3583 lcColorMatch, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3584 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3585 ENDIF
3586
3587 IF NOT llFoundPrepack && NO Prepack found then
3588 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3589 llFoundPrepack = .ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3590 loOrder.color_code, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3591 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3592 lcCustomerLabel= loOrder.lbl_code && actual label to use from trans detail component
3593 ENDIF
3594
3595 *- Step 5. Color(ALL), Label(Exact), Dimension(Exact)
3596 *- ie. col: ALL, lbl: KU, Dim:
3597 IF NOT llFoundPrepack && NO Prepack found then
3598 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3599 llFoundPrepack = .ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3600 lcColorMatch, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3601 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3602 ENDIF
3603
3604 *- Step 6. Color(ALL), Label(ALL), Dimension(Exact)
3605 *- ie. col: ALL, lbl: ALL, Dim:
3606 IF NOT llFoundPrepack && NO Prepack found then
3607 lcCustomerLabel= PADR("ALL",LEN(loOrder.sub_lbl))
3608 lcColorMatch= PADR("ALL",LEN(loOrder.sub_color))
3609 llFoundPrepack = .ResolveSingleSizePrepackWithPrepackAny( loOrder.division, loOrder.STYLE, ;
3610 lcColorMatch, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3611 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3612 lcCustomerLabel= loOrder.lbl_code && actual label to use from trans detail component
3613 ENDIF
3614
3615
3616 * seek to 1st record in trans. detail using dtlpkey
3617 * either replace with error message or remove them and insert with new
3618 * prepack trans. detail
3619 SELECT (pceipcTD)
3620 IF SEEK(lcCurDtlSzPkey, pceipcTD, "DtlSzPkey")
3621 IF NOT llFoundPrepack && Empty(lcPrepack) && no prepack found
3622 * Only error out when Implosion to prepack set
3623 * when set "O"pen stock skip error
3624 IF lcImplosion= "Y"
3625 lcErrorMsg= NO_PREPACK + CRLF + "Searching Prepacks below: " + CRLF + lcPPKSearch
3626 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH lcErrorMsg IN (pceipcTD) && current record only
3627 ENDIF
3628 ELSE
3629 *- Can be ambiguous
3630 IF .lAmbiguousPrepack
3631 lcErrorMsg= "Ambiguous prepack." + CRLF + "Searching Prepacks below: " + CRLF + lcPPKSearch
3632 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH lcErrorMsg IN (pceipcTD) && current record only
3633 ELSE
3634 * Found prepack:
3635 * - remove all trans detail records for same detail line by DtlPkey
3636 * - insert new trans. detail from (Implode many components into single prepack)
3637 lcDoc_num= &pceipcTD..doc_num
3638 lnPkey= v_nextPkey("ZZEIPCTD") && &pceipcTD..pkey
3639 lnFkey= &pceipcTD..fkey
3640 DELETE IN (pceipcTD) && current record only
3641 SELECT (pceipcTD)
3642 APPEND BLANK
3643 GATHER NAME loOrder
3644 REPLACE DIMENSION WITH lcPrepack, doc_num WITH lcDoc_num,;
3645 Sizebucket WITH lnSizeBucket, size_desc WITH lcSize_desc,;
3646 pkey WITH lnPkey, fkey WITH lnFkey, ; && done using it for customer label
3647 User_id WITH lcEnt_user, Last_mod WITH DATETIME(), ;
3648 implosion WITH "Y", ;
3649 Errs_Flg_D WITH "N", Errs_Msg_D WITH "" IN (pceipcTD)
3650 ENDIF
3651 ENDIF
3652 ENDIF
3653 ENDSCAN && Each temp order detail
3654 ENDIF
3655
3656 SELECT (pceipcTD)
3657 .PopRecordSet()
3658
3659 ENDWITH
3660 SELECT(lnOldSelect)
3661 RETURN llRetVal
3662 ENDPROC
3663
3664 *--- Single prepack implosion without prepack any logic (--Alpha)
3665 ************************************************************************************
3666 *
3667 ***********************************************************************************
3668 PROCEDURE ImplosionSinglePrepackWithoutPrepackAny
3669 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcPrePack, pcOrdDtl
3670 LOCAL llRetVal, lnOldSelect, lcCurDtlPkey, lcPrepack, lcCurStyleColor, loOrder, ;
3671 lnPackMultiple, llFoundPrepack, lcSize_desc, lnSizeBucket, llUseCustomerLabel, ;
3672 lcCustomerLabel, lcPPKSearch, lcErrorMsg
3673 llRetVal = .T.
3674 lnOldSelect = SELECT()
3675 WITH THIS
3676 lcEnt_user= EDI_USER
3677 SELECT (pcPrePack)
3678 SET ORDER TO CompSKU && resolve prepack by division,style,color
3679 SELECT (pceipcTD)
3680 .PushRecordSet()
3681 SET ORDER TO dtlpkey && by dtlpkey
3682
3683 IF USED(pcOrdDtl) && could have nothing to do
3684 SELECT (pcOrdDtl) && Horizontal size cursor that group lines in order to find prepack
3685 SCAN
3686
3687 *--- 860 PPK Implosion - Modify logic to limit valid
3688 *--- choices by '860 Control Resolve Label'
3689 STORE "" TO lcErrorMsg, lcPPKSearch, lcPrepack, lcSize_desc
3690 lnSizeBucket= 0
3691 lcCurDtlPkey= &pcOrdDtl..pkey
3692 *- line_status is empty which causes no error message if prepack is not found
3693 *- lcImplosion= &pcOrdDtl..line_status && implosion status "O"pen stock, "Y", "N"
3694 lcImplosion= &pcOrdDtl..impl_ok
3695 *=
3696 SCATTER NAME loOrder
3697
3698 llFoundPrepack= .F.
3699 lcCustomerLabel= "" && loOrder.sub_lbl && store customer label from 850 control
3700 llUseCustomerLabel= !EMPTY(lcCustomerLabel)
3701 IF llUseCustomerLabel && 1st find Customer Label Prepack when 850 customer label and implotion set
3702 llFoundPrepack=.ResolveSinglePrepackWithoutPrepackAny( loOrder.division, loOrder.STYLE, loOrder.color_code, ;
3703 lcCustomerLabel, pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3704 ENDIF
3705
3706 IF NOT llFoundPrepack && NO Prepack found then
3707 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && (GENERIC) Prepack BLANK LABEL
3708 llFoundPrepack=.ResolveSinglePrepackWithoutPrepackAny( loOrder.division, loOrder.STYLE, loOrder.color_code, ;
3709 lcCustomerLabel, pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3710 ENDIF
3711
3712 * seek to 1st record in trans. detail using dtlpkey
3713 * either replace with error message or remove them and insert with new
3714 * prepack trans. detail
3715 SELECT (pceipcTD)
3716 IF SEEK(lcCurDtlPkey, pceipcTD, "DtlPkey")
3717 IF NOT llFoundPrepack && Empty(lcPrepack) && no prepack found
3718 * Only error out when Implosion to prepack set
3719 * when set "O"pen stock skip error
3720 IF lcImplosion= "Y"
3721 SCAN WHILE dtlpkey= lcCurDtlPkey
3722 lcErrorMsg= NO_PREPACK + CRLF + "Searching Prepacks below: " + CRLF + lcPPKSearch
3723 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH lcErrorMsg IN (pceipcTD)
3724 ENDSCAN
3725 ENDIF
3726 ELSE
3727 * Found prepack:
3728 * - remove all trans detail records for same detail line by DtlPkey
3729 * - insert new trans. detail from (Implode many components into single prepack)
3730 lcDoc_num= &pceipcTD..doc_num
3731 lnPkey= v_nextPkey("ZZEIPCTD") && &pceipcTD..pkey
3732 lnFkey= &pceipcTD..fkey
3733 DELETE FOR dtlpkey= lcCurDtlPkey IN (pceipcTD)
3734 SELECT (pceipcTD)
3735 APPEND BLANK
3736 GATHER NAME loOrder
3737 *- Add ...implosion with "Y" to the replace to indicate that the item was imploded
3738 REPLACE DIMENSION WITH lcPrepack, doc_num WITH lcDoc_num,;
3739 Sizebucket WITH lnSizeBucket, size_desc WITH lcSize_desc,;
3740 pkey WITH lnPkey, fkey WITH lnFkey, ; && done using it for customer label
3741 User_id WITH lcEnt_user, Last_mod WITH DATETIME(), ;
3742 implosion WITH "Y", ;
3743 Errs_Flg_D WITH "N", Errs_Msg_D WITH "" IN (pceipcTD)
3744 *- Remove the imploded detail from tcOrdDtl so that the next pass deals only
3745 *- with non-imploded items
3746 DELETE IN (pcOrdDtl)
3747 ENDIF
3748 ENDIF
3749 ENDSCAN && Each temp order detail
3750 ENDIF
3751
3752 SELECT (pceipcTD)
3753 .PopRecordSet()
3754
3755 ENDWITH
3756 SELECT(lnOldSelect)
3757 RETURN llRetVal
3758 ENDPROC
3759
3760 PROCEDURE BuildVerticalOrderForPrepack
3761 LPARAMETERS tcOrdDtl, tcVertOrdDtl
3762 LOCAL llRetVal, lnOldSelect
3763 llRetVal = .T.
3764 lnOldSelect = SELECT()
3765 WITH THIS
3766 llRetVal = v_SqlExec("Select * from zzxbuckt", "tcBucket")
3767 IF llRetVal AND USED(tcOrdDtl)
3768 SELECT d.*, Size_Num AS size_bk, ;
3769 d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ ;
3770 d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ ;
3771 d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ ;
3772 d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ ;
3773 d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ ;
3774 d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ ;
3775 d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ ;
3776 d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ ;
3777 d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ ;
3778 d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ ;
3779 d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ ;
3780 d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 AS Qty ;
3781 FROM (tcOrdDtl) d, tcBucket b ;
3782 WHERE d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ ;
3783 d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ ;
3784 d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ ;
3785 d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ ;
3786 d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ ;
3787 d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ ;
3788 d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ ;
3789 d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ ;
3790 d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ ;
3791 d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ ;
3792 d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ ;
3793 d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 ;
3794 AND d.ppk_status = ' ' ; && 1050956 24-Nov-10 SK Exclude ambiguous ppks
3795 INTO CURSOR (tcVertOrdDtl)
3796
3797 ENDIF
3798 ENDWITH
3799 SELECT(lnOldSelect)
3800 RETURN llRetVal
3801 ENDPROC
3802
3803 ***********************************************************************************************************
3804
3805 PROCEDURE ImplosionSingleSizePrepackWithoutPrepackAny
3806 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pcPrePack, pcOrdDtl
3807 LOCAL llRetVal, lnOldSelect, lcCurDtlPkey, lcPrepack, lcCurStyleColor, loOrder, ;
3808 lnPackMultiple, llFoundPrepack, lcSize_desc, lnSizeBucket, llUseCustomerLabel, ;
3809 lcCustomerLabel, lcPPKSearch, lcErrorMsg
3810 *- NOTE: pcPrepack contains only single-size prepacks
3811 llRetVal = .T.
3812 lnOldSelect = SELECT()
3813 WITH THIS
3814 lcEnt_user= EDI_USER
3815 SELECT (pcPrePack)
3816 SET ORDER TO CompSKU && resolve prepack by division,style,color
3817 SELECT (pceipcTD)
3818 .PushRecordSet()
3819 SET ORDER TO dtlpkey && by dtlpkey
3820
3821 IF USED(pcOrdDtl) && could have nothing to do
3822 SELECT (pcOrdDtl) && Vertical size cursor that group lines in order to find prepack
3823 SCAN
3824 STORE "" TO lcErrorMsg, lcPPKSearch, lcPrepack, lcSize_desc
3825 lnSizeBucket= 0
3826 lnOrigSzBucket = size_bk
3827 lcCurDtlSzPkey = STR(pkey) + STR(size_bk)
3828 lcImplosion= impl_ok
3829
3830 SCATTER NAME loOrder
3831
3832 loOrder.Sizebucket = size_bk
3833 loOrder.total_qty= Qty
3834 loOrder.Qty_change = Qty
3835 IF SEEK(lcCurDtlSzPkey, pceipcTD, "DtlSzPkey")
3836 loOrder.size_desc = &pceipcTD..size_desc
3837 ENDIF
3838 llFoundPrepack= .F.
3839 lcCustomerLabel= "" && loOrder.sub_lbl && store customer label from 850 control
3840 llUseCustomerLabel= !EMPTY(lcCustomerLabel)
3841 IF llUseCustomerLabel && 1st find Customer Label Prepack when 850 customer label and implotion set
3842 llFoundPrepack=.ResolveSingleSizePrepackWithoutPrepackAny( loOrder.division, loOrder.STYLE, ;
3843 loOrder.color_code, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3844 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3845 ENDIF
3846
3847 IF NOT llFoundPrepack && NO Prepack found then
3848 lcCustomerLabel= SPACE(LEN(loOrder.sub_lbl)) && (GENERIC) Prepack BLANK LABEL
3849 llFoundPrepack=.ResolveSingleSizePrepackWithoutPrepackAny( loOrder.division, loOrder.STYLE, ;
3850 loOrder.color_code, lcCustomerLabel, loOrder.size_bk, loOrder.size_desc, ;
3851 pcPrePack, pcOrdDtl, @lnSizeBucket, @lcSize_desc, @lcPrepack, @lcPPKSearch)
3852 ENDIF
3853 *=== 32617 07/10/02 PL
3854
3855 * seek to 1st record in trans. detail using dtlpkey
3856 * either replace with error message or remove them and insert with new
3857 * prepack trans. detail
3858 SELECT (pceipcTD)
3859 IF SEEK(lcCurDtlSzPkey, pceipcTD, "DtlSzPkey")
3860 IF NOT llFoundPrepack && Empty(lcPrepack) && no prepack found
3861 * Only error out when Implosion to prepack set
3862 * when set "O"pen stock skip error
3863 IF lcImplosion= "Y"
3864 lcErrorMsg= NO_PREPACK + CRLF + "Searching Prepacks below: " + CRLF + lcPPKSearch
3865 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH lcErrorMsg IN (pceipcTD) && current record only
3866 ENDIF
3867 ELSE
3868 * Found prepack:
3869 * - remove all trans detail records for same detail line by DtlPkey
3870 * - insert new trans. detail from (Implode many components into single prepack)
3871 lcDoc_num= &pceipcTD..doc_num
3872 lnPkey= v_nextPkey("ZZEIPCTD") && &pceipcTD..pkey
3873 lnFkey= &pceipcTD..fkey
3874 DELETE IN (pceipcTD) && current record only
3875 SELECT (pceipcTD)
3876 APPEND BLANK
3877 GATHER NAME loOrder
3878 *- 1001378 11/24/03 YIK
3879 *- Add ...implosion with "Y" to the replace to indicate that the item was imploded
3880 REPLACE DIMENSION WITH lcPrepack, doc_num WITH lcDoc_num,;
3881 Sizebucket WITH lnSizeBucket, size_desc WITH lcSize_desc,;
3882 pkey WITH lnPkey, fkey WITH lnFkey, ; && done using it for customer label
3883 User_id WITH lcEnt_user, Last_mod WITH DATETIME(), ;
3884 implosion WITH "Y", ;
3885 Errs_Flg_D WITH "N", Errs_Msg_D WITH "" IN (pceipcTD)
3886
3887 ENDIF
3888 ENDIF
3889 ENDSCAN && Each temp order detail
3890 ENDIF
3891
3892 SELECT (pceipcTD)
3893 .PopRecordSet()
3894
3895 ENDWITH
3896 SELECT(lnOldSelect)
3897 RETURN llRetVal
3898 ENDPROC
3899
3900
3901 ************************************************************************************
3902 *
3903 ***********************************************************************************
3904 PROCEDURE GetPrepack
3905 PARAMETERS pcDivision, pcColor_code, pcLbl_code, pcDimension, ;
3906 pcPrepackAlias, pcOrdDtlAlias, ;
3907 pcSizeBucket, pcSize_desc, pcPrePack, pcPPKSearch, plMultiColorComp, pcMultPPKColor
3908
3909 LOCAL llRetVal, lnOldSelect, lcPrepack, lcCurStyColLbl, lnPackMultiple, llEligiblePrepack, ;
3910 lnMatchPPK, lcCurPPK_code, lnPrepacks, lnxx, lcOurSKU, llFound
3911 llEligiblePrepack= .F.
3912 lnOldSelect = SELECT()
3913 WITH THIS
3914 pcPrePack= ""
3915 pcSize_desc= ""
3916 pcSizeBucket= 0
3917
3918 DIMENSION .aPrepacks[1]
3919 STORE .F. TO .aPrepacks
3920 lcCurPPK_code= ""
3921 lnMatchPPK= 0
3922 lnPrepacks= 0
3923
3924 lcColLblDim= pcDivision + pcColor_code + pcLbl_code + pcDimension
3925
3926 * Find prepack matching division,color,label (Group/order by fkey- diff. prepack)
3927 IF USED(pcPrepackAlias) AND SEEK(lcColLblDim, pcPrepackAlias, "ColLblDim")
3928
3929 SELECT (pcPrepackAlias)
3930 * Found prepack of same div,color,label,dimension
3931 SCAN WHILE (division + color_code + lbl_code + DIMENSION == lcColLblDim)
3932 IF NOT (ppk_code == lcCurPPK_code)
3933 lcCurPPK_code= &pcPrepackAlias..ppk_code
3934 lcCurColor_code = IIF(&pcPrepackAlias..Mulcllb_Ok='Y' AND UPPER(pcPrepackAlias)= "TCMULTPPK" ;
3935 AND !EMPTY(&pcPrepackAlias..PPK_color), ;
3936 &pcPrepackAlias..PPK_color, &pcOrdDtlAlias..color_code)
3937 ENDIF
3938
3939 * Verify total and all size bucket divide evently by prepack qty
3940 llEligiblePrepack= .VerifyPrepackBuckets(pcOrdDtlAlias, pcPrepackAlias, plMultiColorComp)
3941
3942 *--- check for each prepack that it resolve the SKU is in scolr
3943 IF llEligiblePrepack
3944 lcOurSKU= &pcOrdDtlAlias..division + &pcOrdDtlAlias..STYLE + ;
3945 lcCurColor_code + &pcOrdDtlAlias..lbl_code + lcCurPPK_code
3946
3947 *- FH 1073662 - added AND tcQPPKSKU.size_code = tcSnglPPK.size_code
3948 llFound= SEEK(lcOurSKU, .cQualPPKSkus, "OurSKU") AND tcQPPKSKU.active_ok = 'Y' AND tcQPPKSKU.size_code = EVALUATE(pcPrepackAlias + '.size_code')
3949
3950 IF !llFound AND THIS.lMultipack
3951 lcMultStylPPK = &pcOrdDtlAlias..STYLE+lcCurPPK_code
3952 llFound= SEEK(lcMultStylPPK , .cMPPK, "MStyPPK")
3953 ENDIF
3954 llEligiblePrepack= IIF(llFound, .T., .F.) && turn prepack to NOT eligible if SKU not setup
3955 ENDIF
3956 * Load all eligible prepacks to array
3957 * could have many prepacks that sastisfy this keys, but that mean ambiguous prepack
3958 * condition for ambiguous: when aPrepacks[] > 1
3959 IF llEligiblePrepack
3960 lnMatchPPK= lnMatchPPK + 1
3961 DIMENSION .aPrepacks[lnMatchPPK]
3962 .aPrepacks[lnMatchPPK]= lcCurPPK_code && store all eligible prepacks
3963 IF lnMatchPPK=1
3964 .aPrepackRecno= RECNO(pcPrepackAlias) && store 1st prepack record pointer
3965 .cPPK_color= IIF(plMultiColorComp, &pcPrepackAlias..PPK_color, "")
3966 ENDIF
3967 * logging found eligible prepack
3968 IF NOT plMultiColorComp
3969 pcPPKSearch= pcPPKSearch + IIF(EMPTY(pcPPKSearch),"", CRLF) + "Div: " + division + "," +;
3970 " Col: " + color_code + "," + " Lbl: " + lbl_code + "," + " Dim: " + DIMENSION + "," +;
3971 "PPK: " + lcCurPPK_code + " Pack Units: " + ALLT(STR(pack_qty))
3972 ELSE
3973 pcPPKSearch= pcPPKSearch + IIF(EMPTY(pcPPKSearch),"",",") + lcCurPPK_code
3974 ENDIF
3975 ENDIF
3976 ENDSCAN
3977
3978 ELSE
3979 * logging not found eligible prepack
3980 IF NOT plMultiColorComp
3981 pcPPKSearch= pcPPKSearch + IIF(EMPTY(pcPPKSearch),"", CRLF) + "Div: " + division + "," +;
3982 " Col: " + color_code + "," + " Lbl: " + lbl_code + "," + " Dim: " + DIMENSION + "," +;
3983 "PPK: (NOT FOUND)"
3984 ENDIF
3985 ENDIF
3986
3987 * aPrepack[] - have exactly one match, good single prepack to use
3988 * aPrepack[] - have more than one matches, Ambiguous Prepack error out.
3989 lnPrepacks= ALEN(.aPrepacks, 1)
3990 llEligiblePrepack= .F.
3991
3992 * need all attribute of prepacks event when multiple prepacks found
3993 IF NOT EMPTY(.aPrepacks[1])
3994 * Find 1st avail buckets and desc to store prepack items latter
3995 lnFirstAvlBucket= 1 && unable to join to scolr because of "ALL" at("Y", &pcPrepackAlias..sizes, 1)
3996 lcSizeStr= pcPrepackAlias+ ".size"+ PADL(lnFirstAvlBucket, 2, '0')
3997 pcSizeBucket= lnFirstAvlBucket
3998 IF .aPrepackRecno> 0
3999 GO (.aPrepackRecno) IN (pcPrepackAlias)
4000 ENDIF
4001 pcSize_desc= EVAL(lcSizeStr)
4002 pcPrePack= .aPrepacks[1]
4003 pcMultPPKColor= .cPPK_color
4004 ENDIF
4005
4006 * when found one eligible prepack, then load to output parameters:
4007 * pcSizeBucket, pcSize_desc, pcPrepack, pcPPKSearch
4008 IF lnPrepacks= 1
4009 llEligiblePrepack= IIF(NOT EMPTY(.aPrepacks[1]), .T., .F.)
4010 .lAmbiguousPrepack= .F.
4011 ELSE
4012 * when found multiple eligible prepack (Ambiguous prepack), then load to output paramters:
4013 * pcSizeBucket, pcSize_desc, pcPrepack with blanks,
4014 * pcPPKSearch with all prepack codes (for user to reporting and make manual adjustment)
4015 llEligiblePrepack= .T.
4016 .lAmbiguousPrepack= .T.
4017 lcAmbiguousPPK= ""
4018 FOR lnxx=1 TO lnPrepacks
4019 lcAmbiguousPPK= lcAmbiguousPPK + IIF(EMPTY(lcAmbiguousPPK), "" , ",") + .aPrepacks[lnxx]
4020 ENDFOR
4021 lcCurDtlPkey= &pcOrdDtlAlias..pkey
4022
4023 * only single color prepack match will fail for Ambiguous at this point
4024 * but not multi color prepack match, need to do more evaluation prior to this group
4025 * of prepack will fail
4026 IF plMultiColorComp
4027 pcPPKSearch= lcAmbiguousPPK
4028 ELSE
4029 pcPPKSearch= "Ambiguous Prepacks: " + lcAmbiguousPPK + CRLF
4030 ENDIF
4031 ENDIF
4032
4033 ENDWITH
4034 SELECT(lnOldSelect)
4035 RETURN llEligiblePrepack && Return TRUE when one or more than one prepack match(s)
4036 ENDPROC
4037
4038 ***********************************************************************************
4039 *
4040 ***********************************************************************************
4041 *--- 860 Inbound implosion of Prepack - single color with multi dimension
4042 PROCEDURE UpdateResolvedPrepack
4043 LPARAMETERS pnSizeBucket, pcSize_desc, pcPrePack, pcPPKSearch, pcMultPPKColor, pcOrdDtl
4044 LOCAL llRetVal, lnOldSelect, lcPrevPPK_status, lcNotes, lcPrevSinglPPK_code, lcPrevMultlPPK_code
4045 llRetVal = .T.
4046 lnOldSelect = SELECT()
4047 WITH THIS
4048
4049 * Should be on proper record in (pcOrdDtl)
4050 lcPrevPPK_status= &pcOrdDtl..ppk_status
4051 lcPrevSinglPPK_code= &pcOrdDtl..ppk_code
4052 lcPrevMultlPPK_code= &pcOrdDtl..notes
4053
4054 * consolidate all resolved prepack at difference level together.
4055 DO CASE
4056
4057 *- 1st time order line resolve to prepack, current level could be single or multiple
4058 *- as original code was prior 11/28/02
4059 *- Only one condition will be ambiguous.
4060 CASE EMPTY(lcPrevPPK_status) && 1st time updating resolved prepack
4061 IF .lAmbiguousPrepack && more than one match found for current level
4062 REPLACE ppk_status WITH "M", notes WITH pcPPKSearch IN (pcOrdDtl) && found more than one match
4063 ELSE
4064 REPLACE ppk_status WITH "1", Sizebucket WITH pnSizeBucket,;
4065 size_desc WITH pcSize_desc, ppk_code WITH pcPrePack, ;
4066 PPK_color WITH pcMultPPKColor,notes WITH pcPrePack IN (pcOrdDtl)
4067 ENDIF
4068
4069 *- previous level resolution found exact one match, and the current level resolution
4070 *- found one or more matches.
4071 *- Both condition will be ambiguous.
4072 * ie. 1st level resolve to one prepack (JP01), 2nd. level resolve to another prepack (JP04,JP05)
4073 * the horizontal order line now become ambiguous (PPK_status='M', JP01,JP04,JP05)
4074 * ie. 1st level resolve to one prepack (JP01), 2nd. level resolve to another prepack (JP05)
4075 * the horizontal order line now become ambiguous (PPK_status='M')
4076 CASE lcPrevPPK_status= "1" AND !EMPTY(lcPrevSinglPPK_code)
4077 * current level found multiple prepack matches, have to append with previous single
4078 * prepack code match (Should never resolve back to same code due to level and ckey of
4079 * prepack ref)
4080 IF .lAmbiguousPrepack && more than one match found for current level
4081 REPLACE ppk_status WITH "M", notes WITH ALLT(lcPrevSinglPPK_code) + "," +;
4082 ALLT(pcPPKSearch) IN (pcOrdDtl) && found more than one match
4083 ELSE
4084 * current level found single prepack matches, have to append with previous single
4085 * prepack code match (Should never resolve back to same code due to level and ckey of
4086 * prepack ref)
4087 REPLACE ppk_status WITH "M", notes WITH ALLT(lcPrevSinglPPK_code) + "," +;
4088 ALLT(pcPrePack) IN (pcOrdDtl)
4089 ENDIF
4090
4091 *- previous level resolution found multiple matches, and the current level resolution
4092 *- found one or more matches. Both condition will be ambiguous prepack.
4093 * (IF) 1st level resolve to many prepack (JP01,JP11),
4094 * 2nd. level resolve to another prepack (JP02,JP05)
4095 * the horizontal order line now become ambiguous (PPK_status='M', JP01,JP11,JP02,JP05)
4096 * (ELSE) 1st level resolve to many prepack (JP01,JP11),
4097 * 2nd. level resolve to another prepack (JP05)
4098 * the horizontal order line now become ambiguous (PPK_status='M', JP01,JP11,JP05)
4099 CASE lcPrevPPK_status= "M" AND !EMPTY(lcPrevMultlPPK_code)
4100 * current level found multiple prepack matches, have to append with previous multiple
4101 * prepack code match (Should never resolve back to same code due to level and ckey of
4102 * prepack ref)
4103 IF .lAmbiguousPrepack && more than one match found for current level
4104 REPLACE ppk_status WITH "M", notes WITH ALLT(lcPrevMultlPPK_code) + "," +;
4105 ALLT(pcPPKSearch) IN (pcOrdDtl) && found more than one match
4106 ELSE
4107 * current level found single prepack matches, have to append with previous multiple
4108 * prepack code match (Should never resolve back to same code due to level and ckey of
4109 * prepack ref)
4110 REPLACE ppk_status WITH "M", notes WITH ALLT(lcPrevMultlPPK_code) + "," +;
4111 ALLT(pcPrePack) IN (pcOrdDtl)
4112 ENDIF
4113
4114 ENDCASE
4115
4116 ENDWITH
4117 SELECT(lnOldSelect)
4118 RETURN llRetVal
4119 ENDPROC
4120
4121 ***********************************************************************************
4122 *
4123 ***********************************************************************************
4124 PROCEDURE MultiPrepackEvaluating
4125 LPARAMETERS pcOrdDtl, pceipcTD, pcPrePack
4126
4127 LOCAL llRetVal, lnOldSelect, lcErrorMsg, llNoPPK, lcAmbiguousPPK, lcExact, lnPPKElm, ;
4128 lnPPKMatch, lcCurDiv
4129 llRetVal = .T.
4130 lnOldSelect = SELECT()
4131
4132 WITH THIS
4133 .oLog.LogEntry("Eliminating not eligible prepack.")
4134 SELECT (pcOrdDtl)
4135 .PushRecordSet()
4136 SELECT (pceipcTD)
4137 .PushRecordSet()
4138
4139 *--Evaluating Ambiguous within same style group of colors:
4140 *- ppk_status
4141 LOCAL ARRAY laKey[1]
4142 CREATE CURSOR tcGoodPPK (color_code C(50), ppk_code C(5)) && TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
4143 SELECT (pcOrdDtl)
4144 SET ORDER TO fkeystyle && Fkey,style
4145 *- 39548 YIK 6/6/03
4146 *- Scan While col_cnt> 1 and impl_ok="Y" && And (ppk_status="1" or ppk_status="M")
4147 *- 1004785 04/20/04 YIK
4148 *- Scan FOR col_cnt> 1 and impl_ok="Y" && And (ppk_status="1" or ppk_status="M")
4149 SCAN FOR col_cnt> 1 AND impl_ok <> "N" && And (ppk_status="1" or ppk_status="M")
4150 *= 1004785
4151 *- 07/13/04 1006129 YIK
4152 IF .lSingleColorMultiPrepack
4153 lcCurKeys= STR(fkey)+STYLE+color_code
4154 lcKeyExpr = "Str(fkey)+style+color_code"
4155 ELSE
4156 lcCurKeys= STR(fkey)+STYLE
4157 lcKeyExpr = "Str(fkey)+style"
4158 ENDIF
4159
4160 lnNumColors= col_cnt && number of colors per style set
4161 lcCurDiv= division && 11/28/02
4162
4163 * scan while same style that have multi color and creating cursor list
4164 * of color and all of it eligeble prepack codes
4165 SELECT (pcOrdDtl)
4166 IF SEEK(lcCurKeys, pcOrdDtl, "fkeystyle")
4167 lcPPK_code= ""
4168 lcPPK_color= ""
4169 lcSize_desc= ""
4170 lnSizeBucket= 0
4171 lnMatchPPK= 0
4172
4173 SCAN WHILE EVAL(lcKeyExpr) = lcCurKeys
4174 lcCurColor= color_code
4175 lcCurPPKs= notes
4176 IF !EMPTY(lcCurPPKs)
4177 StringToArray(lcCurPPKs, @laKey)
4178 FOR lnCnt= 1 TO ALEN(laKey)
4179 lcCurPPK= laKey[lnCnt]
4180 INSERT INTO tcGoodPPK (color_code, ppk_code ) VALUES (lcCurColor, lcCurPPK)
4181 ENDFOR
4182 ENDIF
4183
4184 * Keep one good match ppk_code,color,sizebucket... for replace all latter
4185 * This case is the norm of all client set up (90%), the reset is slower but
4186 * track for all exception (like array of (laStylePPKs) all posible ppks for
4187 * this style, or goback to prepack cursor).
4188 IF EMPTY(lcPPK_code) AND !EMPTY(ppk_code)
4189 lcPPK_code= &pcOrdDtl..ppk_code
4190 lcPPK_color= &pcOrdDtl..PPK_color
4191 lcSize_desc= &pcOrdDtl..size_desc
4192 lnSizeBucket= &pcOrdDtl..Sizebucket
4193 ENDIF
4194
4195 *--- 860 Inbound implosion of Prepack - single color with multi dimension
4196 * keep all good match ppk_code,color,sizebucket... for replace all latter when many found
4197 lnMatchPPK= lnMatchPPK + 1
4198 DIMENSION laStylePPKs[lnMatchPPK, 4]
4199 laStylePPKs[lnMatchPPK, 1]= &pcOrdDtl..ppk_code
4200 laStylePPKs[lnMatchPPK, 2]= &pcOrdDtl..PPK_color
4201 laStylePPKs[lnMatchPPK, 3]= &pcOrdDtl..size_desc
4202 laStylePPKs[lnMatchPPK, 4]= &pcOrdDtl..Sizebucket
4203 ENDSCAN
4204
4205 * After scan throught all colors for style, know if prepack is ok, not ok or
4206 * ambiguous, store record pointer of pcOrdrDtl and get back to it in mid scan
4207 SELECT (pcOrdDtl)
4208 lnRecNo = IIF(!EOF(pcOrdDtl), RECNO(), 0)
4209
4210 * For each occurence of prepack code that match lnNumColors that prepack is ok
4211 * when list of prepack ok > 1 then it is true ambiguous.
4212 LOCAL ARRAY laElgPPK[1]
4213 STORE .F. TO laElgPPK
4214 SELECT ppk_code FROM tcGoodPPK ;
4215 GROUP BY ppk_code ;
4216 HAVING COUNT(*)= lnNumColors ;
4217 INTO ARRAY laElgPPK
4218 llNoPPK= IIF(RECC("tcGoodPPK")=0, .T., .F.)
4219 DO CASE
4220
4221 *--- 860 Inbound implosion of Prepack - single color with multi dimension
4222 CASE ALEN(laElgPPK)= 1 AND !EMPTY(laElgPPK[1]) && only single prepack match use it
4223
4224 *--Most case all all color,label of same style will be single match
4225 IF laElgPPK[1]= lcPPK_code
4226 REPLACE ppk_status WITH "1", ppk_code WITH lcPPK_code, ;
4227 PPK_color WITH IIF(EMPTY(lcPPK_color),color_code,lcPPK_color), Sizebucket WITH lnSizeBucket, ; && 11/28/02
4228 size_desc WITH lcSize_desc, notes WITH "" ;
4229 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4230 ELSE
4231 *--When get to Multiple matches (all qualify for prepack substitution)
4232 *-- will try to narrow it down by:
4233
4234 *-- 1st search by array that have all posible prepack for this style:
4235 * search in array of laStylePPKs[] for match of laElgPPK[1] code before replace
4236 * multi level search may have each line ppk_code difference but other level resolve
4237 * and store in "notes" field may be the one to use after process of elimination.
4238 lcExact= SET("Exact")
4239 SET EXACT ON
4240 STORE 0 TO lnPPKElm, lnPPKMatch
4241 lnPPKElm= ASCAN(laStylePPKs, laElgPPK[1])
4242 IF lnPPKElm>0
4243 lnPPKMatch= ASUB(laStylePPKs, lnPPKElm,1)
4244 IF lnPPKMatch> 0
4245 REPLACE ppk_status WITH "1", ppk_code WITH laStylePPKs[lnPPKMatch ,1], ;
4246 PPK_color WITH IIF(EMPTY(laStylePPKs[lnPPKMatch ,2]), color_code, ;
4247 laStylePPKs[lnPPKMatch ,2]), Sizebucket WITH laStylePPKs[lnPPKMatch ,4], ;
4248 size_desc WITH laStylePPKs[lnPPKMatch ,3], notes WITH "" ;
4249 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4250 ENDIF
4251 ENDIF
4252
4253 *-- 2nd search multi color prepack cursor:
4254 * leave all resolved ppk_code,desc,sizebucket and notes for debugging
4255 IF lnPPKElm=0 OR lnPPKMatch = 0
4256 IF USED(pcPrePack) AND SEEK( (lcCurDiv + laElgPPK[1]), pcPrePack, "DivPPK")
4257 lcSize_desc= EVAL(pcPrePack + ".Size01")
4258 lcPPK_code= &pcPrePack..ppk_code
4259 lcPPK_color= &pcPrePack..PPK_color
4260 REPLACE ppk_status WITH "1", ppk_code WITH lcPPK_code, ;
4261 PPK_color WITH IIF(EMPTY(lcPPK_color),color_code,lcPPK_color), ;
4262 Sizebucket WITH 1, ;
4263 size_desc WITH lcSize_desc, notes WITH "" ;
4264 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4265 ELSE
4266 REPLACE ppk_status WITH "F", notes WITH "Unable to resolve multiple matches!" +;
4267 notes ;
4268 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4269 ENDIF
4270 ENDIF
4271 SET EXACT &lcExact
4272
4273 ENDIF
4274 CASE llNoPPK && no prepack hit at all
4275 REPLACE ppk_status WITH "" ;
4276 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4277 * will not able to show the one that it found, latter select distinct fkey,style
4278 * to mark group of colors belong same style this technique only work for all
4279 * error message of same style is the same (ambiguous check)
4280 CASE ALEN(laElgPPK)= 1 AND EMPTY(laElgPPK[1]) && only one color match in multi color ppk, fail
4281 REPLACE ppk_status WITH "F" ;
4282 FOR &lcKeyExpr = lcCurKeys IN (pcOrdDtl)
4283
4284 CASE ALEN(laElgPPK)> 1 && more than one color match in multi color ppk, fail
4285 lcAmbiguousPPK= ""
4286 FOR lnxx=1 TO ALEN(laElgPPK)
4287 lcAmbiguousPPK= lcAmbiguousPPK + IIF(EMPTY(lcAmbiguousPPK), "" , ",") + ALLTRIM(laElgPPK[lnxx])
4288 ENDFOR
4289 REPLACE ppk_status WITH "M", notes WITH "Ambiguous Multiple Color Prepacks: " + ;
4290 lcAmbiguousPPK + CRLF, avail_ppk WITH lcAmbiguousPPK ; && store all ppks for UI
4291 FOR &lcKeyExpr = lcCurKeys AND ;
4292 (ppk_status= "1" OR ppk_status= "M") IN (pcOrdDtl)
4293 ENDCASE
4294 ENDIF
4295 ZAP IN tcGoodPPK && clearout all records
4296
4297 * restore record pointer less 1 back for scan
4298 lnRecNo= lnRecNo-1
4299 IF lnRecNo> 0
4300 GO lnRecNo IN (pcOrdDtl)
4301 ENDIF
4302
4303 ENDSCAN
4304 USE IN SELECT('tcGoodPPK')
4305 SELECT (pcOrdDtl)
4306 .PopRecordSet()
4307 SELECT (pceipcTD)
4308 .PopRecordSet()
4309
4310 ENDWITH
4311 SELECT(lnOldSelect)
4312 RETURN llRetVal
4313 ENDPROC
4314
4315 ***********************************************************************************
4316 * Flag 850 transaction vertical detail within same style group of colors
4317 * that fail for ambiguous (more than one match of color prepack found)
4318 * col_cnt>1 and ppk_status="M" FIND many (Ambiguous) multi color prepack match
4319 ***********************************************************************************
4320 PROCEDURE MultiPrepackAmbiguous
4321 LPARAMETERS pcOrdDtl, pceipcTD
4322 LOCAL llRetVal, lnOldSelect, lcErrorMsg, lcAvail_ppk
4323 llRetVal = .T.
4324 lnOldSelect = SELECT()
4325
4326 WITH THIS
4327 .oLog.LogEntry("Evaluating Ambiguous Prepack.")
4328 SELECT (pcOrdDtl)
4329 .PushRecordSet()
4330 SELECT (pceipcTD)
4331 .PushRecordSet()
4332
4333 *- 1004785 04/21/04 YIK
4334 *- change impl_ok="Y" to impl_ok <> "N" to error out ambiguous prepacks
4335 SELECT DISTINCT fkey,STYLE,notes,avail_ppk FROM (pcOrdDtl) ; && 10/21 Store ambiguous ppk for new manual implosion UI
4336 WHERE col_cnt> 1 AND ppk_status="M" AND impl_ok <> "N" ;
4337 INTO CURSOR tcTemp
4338 SELECT tcTemp
4339 SCAN
4340 lcErrorMsg= tcTemp.notes
4341 lcAvail_ppk= tcTemp.avail_ppk && 10/21 Store ambiguous ppk for new manual implosion UI
4342 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH Errs_Msg_D + lcErrorMsg, ;
4343 avail_ppk WITH lcAvail_ppk ; && 10/21 Store ambiguous ppk for new manual implosion UI
4344 FOR STR(fkey)+STYLE = STR(tcTemp.fkey)+tcTemp.STYLE IN (pceipcTD)
4345 DELETE FOR STR(fkey)+STYLE = STR(tcTemp.fkey)+tcTemp.STYLE IN (pcOrdDtl)
4346 ENDSCAN
4347 USE IN SELECT("tcTemp")
4348
4349 SELECT (pcOrdDtl)
4350 .PopRecordSet()
4351 SELECT (pceipcTD)
4352 .PopRecordSet()
4353
4354 ENDWITH
4355 SELECT(lnOldSelect)
4356 RETURN llRetVal
4357 ENDPROC
4358
4359 ***********************************************************************************
4360 * Flag 850 transaction vertical detail within same style group of colors
4361 * that fail for missing color components (one or more than one color pack not found
4362 * for multi color line)
4363 * Multi Color ppk match need all color resolve to one or many match.
4364 * col_cnt>1 and ppk_status="F"
4365 ***********************************************************************************
4366 PROCEDURE MultiPrepackMissing
4367 LPARAMETERS pcOrdDtl, pceipcTD
4368 LOCAL llRetVal, lnOldSelect, lcErrorMsg
4369 llRetVal = .T.
4370 lnOldSelect = SELECT()
4371 WITH THIS
4372 .oLog.LogEntry("Verifying Missing or Un-event Prepack distribution.")
4373 SELECT (pcOrdDtl)
4374 .PushRecordSet()
4375 SELECT (pceipcTD)
4376 .PushRecordSet()
4377
4378 * flag all components as not found when NOTES is empty
4379 SELECT DISTINCT fkey,STYLE FROM (pcOrdDtl) ;
4380 WHERE col_cnt> 1 AND ppk_status="F" AND impl_ok="Y" AND EMPTY(notes) ;
4381 INTO CURSOR tcTemp
4382 SELECT tcTemp
4383 SCAN
4384 lcErrorMsg= "Missing or Not the same ratio for all components in Multi Color Prepack."
4385 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH Errs_Msg_D + lcErrorMsg + CRLF ;
4386 FOR STR(fkey)+STYLE = STR(tcTemp.fkey)+tcTemp.STYLE IN (pceipcTD)
4387 ENDSCAN
4388 USE IN SELECT("tcTemp")
4389
4390 SELECT (pcOrdDtl)
4391 .PopRecordSet()
4392 SELECT (pceipcTD)
4393 .PopRecordSet()
4394
4395 ENDWITH
4396 SELECT(lnOldSelect)
4397 RETURN llRetVal
4398 ENDPROC
4399
4400 ******************************************************************************************
4401 PROCEDURE MultiPrepackMinMultiple
4402 LPARAMETERS pcOrdDtl, pceipcTD, pcPrePack
4403 LOCAL llRetVal, lnOldSelect, lcErrorMsg, lcKeyExpr, lnTotal_qty, lnRatio, lnppk_total, lcOrdStyleColor
4404 llRetVal = .T.
4405 lnOldSelect = SELECT()
4406
4407 WITH THIS
4408 .oLog.LogEntry("Checking multiple records Prepack Min/Multiple.")
4409 SELECT (pcOrdDtl)
4410 .PushRecordSet()
4411 SELECT (pceipcTD)
4412 .PushRecordSet()
4413 *--Process when group of colors have ppk_status="1" - single multi color pack match
4414 *-- only Multi Color with match left for col_cnt>1
4415 lnCurFkeyStyle= ""
4416 SELECT (pcOrdDtl)
4417 INDEX ON STR(fkey) + STYLE + ppk_code + PPK_color TAG fkeyStyPpk
4418 SET ORDER TO fkeyStyPpk
4419 lcKeyExpr = ''
4420 llToSkip = .F.
4421 *- 1004785 04/21/04 YIK
4422 *- Scan For col_cnt> 1 and ppk_status= "1" and impl_ok="Y"
4423 SCAN FOR col_cnt> 1 AND ppk_status= "1" AND impl_ok <> "N"
4424 *= 1004785
4425 IF llToSkip AND !BOF()
4426 SKIP -1
4427 ENDIF
4428 IF NOT (lnCurFkeyStyle == STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE + &pcOrdDtl..ppk_code + &pcOrdDtl..PPK_color)
4429 lnCurFkeyStyle= STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE + &pcOrdDtl..ppk_code + &pcOrdDtl..PPK_color
4430 SCATTER NAME loOrder
4431 lnTotal_qty= 0
4432 lnRatio = 0
4433 SELECT (pcPrePack)
4434 LOCATE FOR ppk_code = loOrder.ppk_code
4435 *-- 1001635 10/23/03 YIK
4436 *- If not found - this is a single prepack and shouldn't be checked.
4437 IF FOUND()
4438 lcKeyExpr = 'ppk_code' + ;
4439 IIF(!EMPTY(PPK_color), '+ppk_color','') + ;
4440 IIF(!(EMPTY(color_code) OR ALLTR(color_code)='ALL'), '+color_code','') + ;
4441 IIF(!(EMPTY(lbl_code) OR ALLTR(lbl_code)= 'ALL'), '+lbl_code','') + ;
4442 IIF(!EMPTY(DIMENSION), '+dimension','')
4443 SELECT (pcOrdDtl)
4444 llFoundPrepack = .T.
4445 SCAN WHILE STR(fkey)+ STYLE + ppk_code + PPK_color = lnCurFkeyStyle
4446 lcKeyVal = EVAL(lcKeyExpr)
4447 SELECT (pcPrePack)
4448 LOCATE FOR &lcKeyExpr = lcKeyVal
4449 IF FOUND()
4450 lnppk_total = &pcPrePack..pack_total
4451 SELECT (pcOrdDtl)
4452 IF lnRatio = 0
4453 *IF MOD(total_qty, lnppk_total) = 0
4454 IF MOD(Qty_change, lnppk_total) = 0
4455 *lnRatio = total_qty/lnppk_total
4456 lnRatio = Qty_change/lnppk_total
4457 ELSE
4458 llFoundPrepack = .F.
4459 ENDIF
4460 ELSE
4461 *IF lnRatio <> total_qty/lnppk_total
4462 IF lnRatio <> Qty_change/lnppk_total
4463 llFoundPrepack = .F.
4464 ENDIF
4465 ENDIF
4466 ELSE
4467 llFoundPrepack = .F.
4468 ENDIF
4469 IF !llFoundPrepack
4470 lcErrorMsg= NO_PREPACK + CRLF && "Searching Prepacks below: " + CRLF + lcPPKSearch
4471 *- 1003832 03/01/04 YIK
4472 SELECT (pcOrdDtl)
4473 *=
4474 IF SEEK(lnCurFkeyStyle)
4475 SCAN WHILE STR(fkey)+ STYLE + ppk_code + PPK_color = lnCurFkeyStyle
4476 lcOrdStyleColor = STR(fkey)+ STYLE + color_code
4477 *- 1004785 04/21/04 YIK
4478 *- Add IF impl_ok = "Y"
4479
4480 IF impl_ok = "Y"
4481 *- 1005452 06/04/04 YIK
4482 *- don't put this error msg on top of another
4483 REPLACE Errs_Flg_D WITH "Y", Errs_Msg_D WITH lcErrorMsg ;
4484 FOR STR(fkey)+STYLE+ color_code = lcOrdStyleColor ;
4485 AND Errs_Flg_D <> "Y" ;
4486 IN (pceipcTD)
4487 ENDIF
4488 *- 1009508 03/24/05 YIK
4489 *- DELETE IN (pcOrdDtl)
4490 ENDSCAN
4491 ENDIF
4492 EXIT
4493 ENDIF
4494 ENDSCAN
4495 llToSkip = .T.
4496 *- 1001635 10/23/03 YIK
4497 ELSE
4498 llToSkip = .F.
4499 ENDIF
4500 *= 1001635
4501 ENDIF
4502 ENDSCAN
4503
4504 SELECT (pcOrdDtl)
4505 .PopRecordSet()
4506 SELECT (pceipcTD)
4507 .PopRecordSet()
4508
4509 ENDWITH
4510 SELECT(lnOldSelect)
4511 RETURN llRetVal
4512 ENDPROC
4513
4514 ******************************************************************************************
4515 PROCEDURE MultiPrepackFinalize
4516 LPARAMETERS pcOrdDtl, pceipcTD
4517 LOCAL llRetVal, lnOldSelect, lcErrorMsg, lcDetNotes
4518 llRetVal = .T.
4519 lnOldSelect = SELECT()
4520
4521 WITH THIS
4522 .oLog.LogEntry("Finalizing multiple records Prepack.")
4523 SELECT (pcOrdDtl)
4524 .PushRecordSet()
4525 SELECT (pceipcTD)
4526 .PushRecordSet()
4527
4528 *--Process when group of colors have ppk_status="1" - single multi color pack match
4529 *-- only Multi Color with match left for col_cnt>1
4530 lnCurFkeyStyle= ""
4531 lnCurFkeyStyClr = ""
4532 SELECT (pcOrdDtl)
4533 *- 39548 6/6/03 YIK
4534 SET ORDER TO fkeystyle
4535 INDEX ON STR(fkey)+STYLE+PPK_color+color_code+lbl_code TAG fkeyStyClr
4536 SET ORDER TO fkeyStyClr
4537 *- 1004785 04/20/04 YIK
4538 *- Scan For col_cnt> 1 and ppk_status= "1" and impl_ok="Y"
4539 SCAN FOR col_cnt> 1 AND ppk_status= "1" AND impl_ok <> "N"
4540 *=
4541 *--Creating single style and rollup all color when Multi Color prepack match to
4542 *--single record. Remove all veritcal trans detail for fkey+style and insert a new one
4543 *- 39548 05/30/03 YIK
4544 llCombine = .F.
4545 IF NOT (lnCurFkeyStyle == STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE +&pcOrdDtl..color_code ;
4546 AND lnCurFkeyStyClr == STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE +&pcOrdDtl..PPK_color)
4547 lnCurFkeyStyle= STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE + &pcOrdDtl..color_code
4548 IF !EMPTY(lnCurFkeyStyClr) AND lnCurFkeyStyClr= STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE + &pcOrdDtl..PPK_color
4549 llCombine = .T.
4550 ELSE
4551 lnCurFkeyStyClr= STR(&pcOrdDtl..fkey)+ &pcOrdDtl..STYLE + &pcOrdDtl..PPK_color
4552 ENDIF
4553
4554 *=
4555 SCATTER NAME loOrder
4556 lnTotal_qty= 0
4557 SELECT (pceipcTD)
4558 IF SEEK(lnCurFkeyStyle, pceipcTD, "GrpDetail") &&Str(fkey)+style+....
4559 lcCustomer= &pceipcTD..customer
4560 lcDoc_num= &pceipcTD..doc_num
4561 lnFkey= &pceipcTD..fkey
4562
4563 *- 1005452 05/25/04 YIK
4564 *- detail notes are not populated, because they are empty in tcOrdDtl
4565 lcDetNotes = &pceipcTD..notes
4566
4567 * remove all implode records in trans. detail
4568 *?here to verify last time for min_multiple check
4569 SELECT (pceipcTD)
4570*!* CALCULATE SUM(total_qty) TO lnTotal_qty ;
4571*!* FOR STR(fkey)+ STYLE + color_code = lnCurFkeyStyle
4572 CALCULATE SUM(Qty_change) TO lnTotal_qty ;
4573 FOR STR(fkey)+ STYLE + color_code = lnCurFkeyStyle
4574
4575 DELETE FOR STR(fkey)+ STYLE + color_code = lnCurFkeyStyle IN (pceipcTD)
4576 IF llCombine
4577 lnPpk_qty = lnPpk_qty + lnTotal_qty
4578 ELSE
4579 lnPpk_qty = lnTotal_qty
4580 APPEND BLANK
4581 lnPkey= v_nextPkey("ZZEIPCTD") && &pceipcTD..pkey
4582 GATHER NAME loOrder
4583 *- 1001378 11/24/03 YIK
4584 *- Add ..implosion with "Y" to the replace to indicate that the line was imploded.
4585 *- 1005452 05/25/04 YIK
4586 *- Add ..notes with lcDetNotes
4587 REPLACE color_code WITH loOrder.PPK_color, DIMENSION WITH loOrder.ppk_code,;
4588 Sizebucket WITH loOrder.Sizebucket, size_desc WITH loOrder.size_desc,;
4589 doc_num WITH lcDoc_num,pkey WITH lnPkey,fkey WITH lnFkey, ;
4590 customer WITH lcCustomer, ; && done using it for customer label
4591 User_id WITH lcEnt_user, Last_mod WITH DATETIME(), ;
4592 implosion WITH "Y", ;
4593 notes WITH lcDetNotes, ;
4594 Errs_Flg_D WITH "N", Errs_Msg_D WITH "" IN (pceipcTD)
4595 ENDIF
4596 ENDIF
4597
4598 ENDIF
4599 lnTotal_qty= lnPpk_qty && + loOrder.total_qty Use sum(total_qty) for ..
4600 IF llCombine
4601 SELECT (pceipcTD)
4602 LOCATE FOR STR(fkey) + STYLE + color_code = lnCurFkeyStyClr
4603 ENDIF
4604 REPLACE total_qty WITH lnTotal_qty IN (pceipcTD)
4605 REPLACE Qty_change WITH lnTotal_qty IN (pceipcTD)
4606 SELECT (pcOrdDtl)
4607 ENDSCAN
4608
4609 USE IN SELECT("_MulCol")
4610
4611 *--Done with multi color implosion
4612 *-- col_cnt>1 and ppk_status="" NOT FIND any multi color prepack match (NEXT SINGLE LEVEL MATCH)
4613 *-- reset col_cnt back to 0 for ppk_status="", in order for single level match to happend.
4614 *- 1004785 04/20/04 YIK
4615 *!* Replace col_cnt with 0 For col_cnt> 1 and ppk_status="" ;
4616 *!* and impl_ok="Y" and ppk_code="" IN (pcOrdDtl)
4617 REPLACE col_cnt WITH 0 FOR col_cnt> 1 AND ppk_status="" ;
4618 AND impl_ok <> "N" AND ppk_code="" IN (pcOrdDtl)
4619 *= 1004785
4620 SELECT (pcOrdDtl)
4621 .PopRecordSet()
4622 SELECT (pceipcTD)
4623 .PopRecordSet()
4624
4625 ENDWITH
4626 SELECT(lnOldSelect)
4627 RETURN llRetVal
4628 ENDPROC
4629
4630 ******************************************************************************************
4631
4632 PROCEDURE GetSingleSizePrepacks
4633 LPARAMETERS tcSnglPPK, tcSSizePPK
4634 LOCAL llRetVal, lnOldSelect, lnPackQty, lnxx
4635 llRetVal = .T.
4636 lnOldSelect = SELECT()
4637
4638 SELECT *, 99 AS size_bk ;
4639 FROM (tcSnglPPK) ;
4640 WHERE (Pack01_Qty = pack_total ;
4641 OR Pack02_Qty = pack_total ;
4642 OR Pack03_Qty = pack_total ;
4643 OR Pack04_Qty = pack_total ;
4644 OR Pack05_Qty = pack_total ;
4645 OR Pack06_Qty = pack_total ;
4646 OR Pack07_Qty = pack_total ;
4647 OR Pack08_Qty = pack_total ;
4648 OR Pack09_Qty = pack_total ;
4649 OR Pack10_Qty = pack_total ;
4650 OR Pack11_Qty = pack_total ;
4651 OR Pack12_Qty = pack_total ;
4652 OR Pack13_Qty = pack_total ;
4653 OR Pack14_Qty = pack_total ;
4654 OR Pack15_Qty = pack_total ;
4655 OR Pack16_Qty = pack_total ;
4656 OR Pack17_Qty = pack_total ;
4657 OR Pack18_Qty = pack_total ;
4658 OR Pack19_Qty = pack_total ;
4659 OR Pack20_Qty = pack_total ;
4660 OR Pack21_Qty = pack_total ;
4661 OR Pack22_Qty = pack_total ;
4662 OR Pack23_Qty = pack_total ;
4663 OR Pack24_Qty = pack_total) ;
4664 INTO CURSOR __SSizePPK
4665 WITH THIS
4666 llRetVal= llRetVal AND .MakeCursorWritable("__SSizePPK", tcSSizePPK)
4667 SELECT (tcSSizePPK)
4668 SCAN
4669 FOR lnxx = 1 TO goEnv.MaxBuckets
4670 lnPackQty = EVAL(.aPackStr[lnxx])
4671 IF lnPackQty > 0 && the single size bucket
4672 REPLACE size_bk WITH lnxx
4673 EXIT
4674 ENDIF
4675 ENDFOR
4676 ENDSCAN
4677 .TableClose("__SSizePPK")
4678 ENDWITH
4679
4680 * index for optimizing
4681 IF USED(tcSSizePPK)
4682 SELECT (tcSSizePPK)
4683 *- 1009508 02/24/05 YIK
4684 *- Added IF This.lSinglePrepackAny
4685 IF THIS.lSinglePrepackAny
4686 INDEX ON division+color_code+lbl_code+STR(size_bk) TAG CompSKU
4687 ELSE
4688 INDEX ON division+STYLE+color_code+lbl_code+STR(size_bk) TAG CompSKU
4689 ENDIF
4690 ENDIF
4691
4692 SELECT(lnOldSelect)
4693 RETURN llRetVal
4694 ENDPROC
4695
4696
4697 ************************************************************************************
4698 * Assume: both (pcOrdDtlAlias) and (pcPrepackAlias) point to proper record
4699 * 1. order trans work table(pcOrdDtlAlias) in horizontal size bucket
4700 * 2. prepack work table (pcPrepackAlias) found a match
4701 * the purpuse of this routine to verify Total_qty of order divide evently by prepack
4702 * qty and also all corresponding size buckets
4703 * Return: True when prepack is eligible
4704 ***********************************************************************************
4705 PROCEDURE VerifyPrepackBuckets
4706 PARAMETERS pcOrdDtlAlias, pcPrepackAlias, plMultiColorComp
4707 LOCAL llRetVal, lnOldSelect, lcPrepack, lcCurStyColLbl, lnPackMultiple, llEligiblePrepack, ;
4708 lnCurFkey
4709 llEligiblePrepack= .F.
4710 lnOldSelect = SELECT()
4711 WITH THIS
4712
4713 * order line total_qty divisible by pack_qty (single color comp, one record in prepack dtl)
4714 * pack_total (multi color comp, detail ppk many records)
4715 * Single color use header pack_qty, Multi Color use detail pack_total
4716 lnPackQty= IIF(plMultiColorComp, &pcPrepackAlias..pack_total, &pcPrepackAlias..pack_qty)
4717
4718 * If Total_qty divide evently then start evaluating all buckets qty
4719 IF MOD(&pcOrdDtlAlias..total_qty, lnPackQty) = 0
4720 llEligiblePrepack= .T.
4721 lnPackMultiple= INT(&pcOrdDtlAlias..total_qty / lnPackQty)
4722
4723 * For each order line size with qty also need to be divisible by pack size qty
4724 FOR lnxx = 1 TO goEnv.MaxBuckets
4725 lnPackQty= EVAL(pcPrepackAlias+ "." + .aPackStr[lnxx])
4726 lnSizeQty= EVAL(pcOrdDtlAlias+ "." + .aSizeStr[lnxx])
4727 IF lnSizeQty> 0 OR lnPackQty> 0
4728 * as soon as order size with qty not divisible evently by prepack size
4729 * set llEligiblePrepack to false and exit
4730 IF (lnSizeQty>0 AND lnPackQty> 0)
4731 * compare each order bucket = multiple of prepack bucket
4732 llEligiblePrepack= IIF(lnSizeQty = lnPackMultiple * lnPackQty, .T., .F.)
4733 IF NOT llEligiblePrepack
4734 pcPPKSearch= pcPPKSearch + CRLF + " Size bucket: " + ALLT(STR(lnxx)) +;
4735 " Ordr Qty: " + ALLT(STR(lnSizeQty)) + " Pack Qty: " + ALLT(STR(lnPackQty))
4736 ENDIF
4737 ELSE
4738 * No order qty for this size but prepack qty (size qty =0 but pack qty >0)
4739 * cannot use this prepack even when all other size divisible by prepack
4740 llEligiblePrepack= .F.
4741 ENDIF
4742 ENDIF
4743
4744 IF NOT llEligiblePrepack
4745 EXIT FOR && this one not eligible
4746 ENDIF
4747 ENDFOR
4748 ENDIF
4749 ENDWITH
4750
4751 SELECT(lnOldSelect)
4752 RETURN llEligiblePrepack
4753 ENDPROC
4754
4755 *-- 3 OUTPUT Parameters:
4756 *-- pcSizeBucket: Prepack Size bucket
4757 *-- pcSize_desc: Prepack size description
4758 *-- pcPrepack: Prepack code (Dimension)
4759 PROCEDURE ResolveSingleSizePrepackWithPrepackAny
4760 PARAMETERS pcDivision, pcStyle, pcColor_code, pcLbl_code, pcSize_bk, pcOrigSize_desc, pcPrepackAlias, ;
4761 pcOrdDtlAlias, pcSizeBucket, pcSize_desc, pcPrePack, pcPPKSearch
4762 LOCAL llRetVal, lnOldSelect, lcPrepack, lcCurStyColLbl, lnPackMultiple, llEligiblePrepack, llPpkExists
4763 llEligiblePrepack= .F.
4764 lnOldSelect = SELECT()
4765 WITH THIS
4766 pcPrePack= ""
4767 pcSize_desc= ""
4768 pcSizeBucket= 0
4769 *- No style for prepack any. See Phu's comments
4770 lcCurStyColLblExpr = "Division + Color_code + Lbl_code + STR(Size_bk)"
4771 lcCurStyColLbl = pcDivision + pcColor_code + pcLbl_code + STR(pcSize_bk) && exact size bucket
4772 .lAmbiguousPrepack = .F.
4773 llPpkExists = .F.
4774 * Find prepack matching division,style,color,label. There only 1 sizebucket available.
4775 IF SEEK(lcCurStyColLbl, pcPrepackAlias, "CompSKU")
4776 * veriry Found prepack of same div,style,color,label
4777 SELECT (pcPrepackAlias)
4778 SCAN FOR lcCurStyColLbl = EVALUATE(lcCurStyColLblExpr)
4779 llEligiblePrepack= .T.
4780
4781 pcPPKSearch= pcPPKSearch + IIF(EMPTY(pcPPKSearch),"", CRLF) + division + ;
4782 "/" + color_code + "/" + lbl_code + "/" + DIMENSION +;
4783 " Pack Units: " + ALLT(STR(pack_qty))
4784
4785 * order line total_qty divisible by pack_qty
4786 IF MOD(&pcOrdDtlAlias..Qty, pack_qty) = 0
4787
4788 lnPackMultiple= INT(&pcOrdDtlAlias..Qty / pack_qty)
4789 *- If already found a matching prepack (llPpkExists = .T.) and this prepack is
4790 *- also good (llEligiblePrepack = .T.) - this is Ambiguous
4791 .lAmbiguousPrepack = .lAmbiguousPrepack OR (llPpkExists AND llEligiblePrepack)
4792 IF llEligiblePrepack
4793 pcSizeBucket= 1
4794 IF vl_Sizer(&pcOrdDtlAlias..division, ,"_sizer", size_code)
4795 pcSize_desc= _sizer.size01
4796 ELSE
4797 pcSize_desc='' && default
4798 ENDIF
4799 pcPrePack = ppk_code
4800 llPpkExists = .T.
4801 ENDIF
4802
4803 ELSE
4804 llEligiblePrepack = .F.
4805 ENDIF
4806 ENDSCAN
4807 ELSE
4808 pcPPKSearch= pcPPKSearch + IIF(EMPTY(pcPPKSearch),"", CRLF) + pcDivision + "/" +;
4809 pcColor_code + "/" + pcLbl_code + ;
4810 "Size " + pcOrigSize_desc + "/ (Not Found)"
4811 ENDIF
4812 ENDWITH
4813 SELECT(lnOldSelect)
4814 RETURN llPpkExists &&llEligiblePrepack
4815 ENDPROC
4816
4817 ******************************************************************************************
4818
4819 PROCEDURE PopulatingImplosionFlag
4820 LPARAMETERS pceipcTH, pceipcCR
4821 LOCAL llRetVal, lnOldSelect,lnLastOrder && TR 1041492 JUL-20-2009 BR
4822 llRetVal = .T.
4823 lnOldSelect = SELECT()
4824 WITH THIS
4825 IF this.lPrepackConversion
4826 * set header/detail Relation
4827
4828 *--- TR 1048865 27-Dec-2010 Goutam
4829 *llRetVal = llRetVal AND .SetRelation(pceipcCR, "divcust", pceipcTH, "division + customer")
4830 llRetVal = llRetVal AND .SetRelation(pceipcCR, "pkey", pceipcTH, "cr_pkey")
4831 *=== TR 1048865 27-Dec-2010 Goutam
4832
4833 *--- TR 1041492 JUL-20-2009 BR
4834 lnLastOrder = ORDER()
4835 SET ORDER TO TAG ImplOK
4836
4837 *- TR 1072045 - FH can't SEEK on a field you're going to be doing replace on
4838*!* IF SEEK('', pceipcTH, "ImplOK")
4839*!* SCAN WHILE(impl_ok = '')
4840*!* REPLACE impl_ok WITH &pceipcCR..impl_ok IN (pceipcTH)
4841*!* ENDSCAN
4842*!* ENDIF
4843
4844 DO WHILE SEEK(' ', pceipcTH, "ImplOK") && have to use ' ', instead of '', SEEKing on '' always return .T. for some reason.
4845 REPLACE impl_ok WITH &pceipcCR..impl_ok IN (pceipcTH)
4846 ENDDO
4847 *- TR 1072045 - FH can't SEEK on a field you're going to be doing replace on
4848
4849 SET ORDER TO lnLastOrder
4850 *=== TR 1041492 JUL-20-2009 BR
4851 SET RELATION TO
4852 ENDIF
4853 ENDWITH
4854 SELECT(lnOldSelect)
4855 RETURN llRetVal
4856 ENDPROC
4857
4858 ******************************************************************************************
4859
4860 PROCEDURE GetDeleteSQLForMatchingTransHistoryPkey
4861 LPARAMETERS pcRefSql, pcRefTempTable, pctmpIpctdPkey
4862 LOCAL llRetVal, lnOldSelect
4863
4864 llRetVal = .t.
4865 lnOldSelect = SELECT()
4866 .cSQLTempTable = ""
4867 IF RECCOUNT(pctmpIpctdPkey) > 0
4868 llRetVal = llRetVal and .GenerateSQLTempTable(pctmpIpctdPkey)
4869 llRetVal = llRetVal and .PopulateSQLTempTable(pctmpIpctdPkey) and !EMPTY(.cSQLTempTable)
4870 pcRefTempTable = .cSQLTempTable
4871 IF llRetVal
4872 pcRefSql = "delete d from zzeipchd d inner join " + pcRefTempTable + " t on d.pkey = t.pkey"
4873 ENDIF
4874 ENDIF
4875
4876 SELECT(lnOldSelect)
4877 RETURN llRetVal
4878 ENDPROC
4879
4880 ******************************************************************************************
4881
4882 FUNCTION ResolveMultiPrepacks
4883 LPARAMETERS pcTransHeader, pcTransDetail, pcMppk
4884 LOCAL llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
4885
4886 llRetVal = .T.
4887 lnOldSelect = SELECT()
4888
4889 SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
4890 FROM (pcTransHeader) h, (pcTransDetail) d ;
4891 WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" ;
4892 AND d.implosion = 'Y';
4893 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
4894
4895 IF RECCOUNT("__TmpCursor") = 0
4896 SELECT(lnOldSelect)
4897 RETURN llRetVal
4898 ENDIF
4899
4900 WITH THIS
4901 .cSQLTempTable=""
4902 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor') AND .PopulateSQLTempTable('__TmpCursor') and NOT EMPTY(.cSQLTempTable)
4903 IF llRetVal
4904 .LogEntry("Exploding MultiPack.")
4905 lcSQLString = "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
4906 "Where h.customer = t.customer and h.mpack_code = t.dimension "
4907
4908 llRetVal = llRetVal AND v_SqlExec(lcSQLString, "__MppkH")
4909 llMultPpkToExplode = THIS.CountTotalRecs ("__MppkH")>0
4910 IF llRetVal AND llMultPpkToExplode
4911 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
4912 "Where h.pkey = d.fkey AND h.customer = t.customer and h.mpack_code = t.dimension "
4913 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__MppkD")
4914
4915 SELECT Sizebucket, size_desc, total_qty, ppk_qty , SPACE(5) AS ppk_code, 00000 AS multQty FROM (pcTransDetail) ;
4916 WHERE 0=1 INTO CURSOR __ppk2
4917 THIS.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer")
4918
4919 IF USED("__ppk1")
4920 USE IN __ppk1
4921 ENDIF
4922 IF USED("__ppk2")
4923 USE IN __ppk2
4924 ENDIF
4925 SELECT __MppkH
4926 INDEX ON pkey TAG pkey
4927 SELECT __MppkD
4928 INDEX ON division+STYLE TAG DivStyle
4929 SELECT tcMppkVer
4930 INDEX ON division+STYLE+color_code+lbl_code+DIMENSION TAG MpackRef
4931 SET ORDER TO MpackRef
4932 THIS.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
4933
4934 SELECT DISTINCT d.pkey ;
4935 FROM __MppkD mp, (pcTransDetail) d ;
4936 WHERE d.Errs_Flg_D= "N" ;
4937 AND mp.STYLE = d.STYLE ;
4938 AND mp.color_code = d.color_code ;
4939 AND mp.lbl_code = d.lbl_code ;
4940 AND mp.DIMENSION = d.DIMENSION;
4941 AND d.implosion = 'Y';
4942 INTO CURSOR __DtlExpl
4943
4944 llRetVal = llRetVal and .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail)
4945 ENDIF
4946 ENDIF
4947 ENDWITH
4948
4949 IF USED("__MppkH")
4950 USE IN __MppkH
4951 ENDIF
4952 IF USED("__MppkD")
4953 USE IN __MppkD
4954 ENDIF
4955 IF USED("tcMppkVer")
4956 USE IN tcMppkVer
4957 ENDIF
4958 IF USED("__DtlExpl")
4959 USE IN __DtlExpl
4960 ENDIF
4961 IF USED("__TmpCursor")
4962 USE IN __TmpCursor
4963 ENDIF
4964
4965 SELECT(lnOldSelect)
4966 RETURN llRetVal
4967
4968 ENDFUNC
4969
4970 ******************************************************************************************
4971
4972 *****************************************************************
4973 *
4974 *****************************************************************
4975 PROCEDURE ExplodeMultPackRef
4976 LPARAMETERS pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
4977 LOCAL llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
4978 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
4979
4980 lnOldSele = SELECT()
4981 lcDivStyle = ""
4982 lnSourceCnt = THIS.CountTotalRecs (pcMultPackDetail)
4983
4984 llRetVal= .T.
4985 lnCurDtlFkey= 0
4986 lnMultiplyQty = 0
4987
4988 .oLog.LogEntry("Exploding multi pack details.")
4989
4990 SELECT (pcMultPackDetail)
4991 SET ORDER TO DivStyle
4992 SCAN
4993
4994 IF lnCurDtlFkey<> fkey
4995 lnCurDtlFkey = fkey
4996 IF SEEK(fkey, pcMultPackHeader , "PKEY")
4997 lnMultiplyQty = EVALUATE(pcMultPackHeader + " .total_qty")
4998 ELSE
4999 llRetVal = .F.
5000 EXIT
5001 ENDIF
5002 ENDIF
5003
5004
5005 * only run once per Div + Style
5006 IF !(lcDivStyle == division + STYLE)
5007 lcDivStyle = division + STYLE
5008 * Insert a record for each size bucket with a caption *
5009 IF !v_GetSizeHeadings(division, STYLE, "__xSizer")
5010 llRetVal = .F.
5011 EXIT
5012 ENDIF
5013 ENDIF
5014
5015
5016 lnSizeQty = 1
5017 SELECT (pcMultPackDetail)
5018 SCATTER MEMVAR MEMO
5019
5020 lnSizePosition = 1
5021 lcSizeBucket = "Size" + TRANS(lnSizePosition, "@L 99") && zzxsizer bucket field names
5022 lcSizeName = TRIM(EVAL("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5023 lnSizeQty = ppk_qty
5024
5025 m.Sizebucket = lnSizePosition
5026 m.size_desc = lcSizeName
5027 m.total_qty = lnSizeQty
5028 m.multQty = lnMultiplyQty
5029 m.qty_change = lnSizeQty
5030
5031 IF lnSizeQty > 0 && Only want buckets with activity!
5032 INSERT INTO (pcMultPackTarget) FROM MEMVAR
5033 ENDIF
5034 SELECT (pcMultPackDetail)
5035
5036 ENDSCAN
5037
5038 THIS.TableClose("__xSizer")
5039 SELECT (pcMultPackDetail)
5040 SELECT (lnOldSele)
5041 RETURN llRetVal
5042 ENDPROC
5043
5044 *****************************************************************
5045 PROCEDURE ExplodeMultiPackVertical
5046 LPARAMETERS pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
5047 LOCAL llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
5048 llRetVal = .T.
5049 lnOldSelect = SELECT()
5050
5051 .oLog.LogEntry("Exploding multi pack details into vertical cursor.")
5052 SELECT (pcDetailtoExplode)
5053
5054 SCAN
5055
5056 IF SEEK(pkey, pcTransDetail, "Pkey")
5057
5058 * Current working trans detail
5059 SELECT (pcTransDetail)
5060 lcCurOurSKU= division+STYLE+color_code+lbl_code+DIMENSION
5061 lnCurDtlTotal_qty= total_qty
5062
5063
5064 SCATTER NAME loTransDetail MEMO
5065 * delete current working trans detail already have image
5066 * in loTransDetail
5067 DELETE IN (pcTransDetail)
5068
5069
5070 SELECT (pcMultDetailVert)
5071 * Find 1st match of OURSKU
5072 IF SEEK(lcCurOurSKU, pcMultDetailVert, "MpackRef")
5073 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
5074
5075
5076 SCAN WHILE llRetVal AND !EOF(pcMultDetailVert) AND ;
5077 (lcCurOurSKU= division+ STYLE + color_code + lbl_code + DIMENSION)
5078 * Exploding detail line
5079 loTransDetail.pkey = v_nextPkey("ZZEIPCTD") && Never reassign Pkey in TD
5080 IF !EMPTY(loTransDetail.pkey)
5081
5082 SELECT (pcMultDetailVert)
5083 SCATTER NAME loVert MEMO
5084
5085 SELECT (pcTransDetail)
5086 APPEND BLANK
5087 GATHER NAME loTransDetail MEMO
5088
5089 REPLACE total_qty WITH loVert.total_qty * lnMultiplier , ;
5090 qty_change WITH loVert.total_qty * lnMultiplier, ;
5091 Sizebucket WITH loVert.Sizebucket, ;
5092 size_desc WITH loVert.size_desc, ;
5093 division WITH loVert.division, ;
5094 STYLE WITH loVert.STYLE, ;
5095 color_code WITH loVert.color_code, ;
5096 lbl_code WITH loVert.lbl_code, ;
5097 DIMENSION WITH loVert.ppk_code IN (pcTransDetail)
5098 ELSE
5099 .oLog.LogEntry("Pkey cannot be empty.")
5100 llRetVal= .F. && Cannot get Pkey from bcsysnum
5101 EXIT
5102 ENDIF
5103
5104 SELECT (pcMultDetailVert)
5105 ENDSCAN
5106 ELSE
5107 .oLog.LogEntry(" Seek Failed Not able to find SKU. "+ lcCurSKU)
5108 llRetVal= .F. && Should be in pcMultDetailVert
5109 EXIT
5110 ENDIF
5111 ENDIF
5112
5113 IF !llRetVal &&Get out of scan when have some problem
5114 EXIT
5115 ENDIF
5116 ENDSCAN
5117
5118 SELECT(lnOldSelect)
5119 RETURN llRetVal
5120 ENDPROC
5121
5122 *==== TR 1016560 NH
5123
5124 *--- TR 1021052 21-AUG-2007 HNISAR & Goutam
5125 PROCEDURE CreateNewStoreOrder
5126 LPARAMETERS taDuplicateFields
5127
5128 LOCAL llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier ,lcSqlString , ;
5129 lnOrd_num ,lnHdrPkey ,lnNextHdrPkey ,lnDtlPkey ,lnNextDtlPkey, loOrdDtl, ;
5130 lcSizeStr ,lcReplaceStr, lcUser, ldLastUpdate, lnLine_Seq, llFound, lnDtlPkey
5131
5132 llRetVal = .T.
5133 lnOldSelect = SELECT()
5134
5135 lcUser = goEnv.SV("cUser")
5136 ldLastUpdate = DATETIME()
5137
5138 WITH THIS
5139 .oLog.LogEntry("Creating New Store order.")
5140
5141 lcSqlString = " SELECT h.*, tmp.DPkey, d.pkey DtlPkey FROM ZZOORDRH h " + ;
5142 " JOIN ZZOORDRD d " + ;
5143 " ON d.fkey = h.pkey " + ;
5144 " JOIN " + .cSQLTempTable + " tmp " + ;
5145 " ON h.Customer = tmp.customer " + ;
5146 " AND h.Division = tmp.Division " + ;
5147 " AND h.Po_Num = tmp.PO_Num " + ;
5148 " AND d.Style = tmp.style " + ;
5149 " AND d.Color_code = tmp.color_code " + ;
5150 " AND d.lbl_code = tmp.lbl_code " + ;
5151 " AND d.Dimension = tmp.Dimension " + ;
5152 " WHERE tmp.HPKey = " + SQLFormatNum(tcEiPCth.pkey)+ ;
5153 " ORDER BY h.last_mod DESC"
5154
5155 llRetVal = llRetVal AND NOT .lOrderHdrFound AND v_SqlExec(lcSQLString, "tcOrdHdr") AND RECCOUNT("tcOrdHdr") > 0
5156
5157 IF llRetVal
5158 SELECT tcOrdHdr
5159 LOCATE FOR DPkey = tcEiPCtd.pkey
5160 IF FOUND()
5161 lnHdrPkey = tcOrdHdr.pkey
5162 lnDtlPkey = tcOrdHdr.Dtlpkey
5163 ELSE
5164 GO top
5165 lnHdrPkey = tcOrdHdr.pkey
5166 lnDtlPkey = tcOrdHdr.Dtlpkey
5167 ENDIF
5168 SELECT Vzzoordrh_860I
5169 LOCATE FOR Customer = tcOrdHdr.Customer AND Po_Num = tcOrdHdr.Po_Num AND Store = tcEiPCth.Store
5170 llFound = FOUND()
5171 .lOrderHdrFound = true
5172 ENDIF
5173
5174 IF .lOrderHdrFound
5175 lcSqlString = " SELECT * FROM ZZOORDRD " + ;
5176 " WHERE pkey = " + SQLFormatNum(lnDtlPkey)
5177
5178 llRetVal = v_SqlExec(lcSQLString, "tcOrdDtl") AND RECCOUNT("tcOrdDtl") > 0
5179 ENDIF
5180
5181 IF llRetVal OR .lOrderHdrFound
5182 IF NOT llFound AND llRetVal
5183 .oLog.LogEntry("Inserting New Store order header Record .")
5184
5185 lnOrd_num = v_NextId('ZZXCOMPR','ORD_NUM')
5186 lnNextHdrPkey = v_nextPkey('ZZOORDRH')
5187
5188 SELECT tcOrdHdr
5189 SCATTER NAME loOrdHdr MEMO
5190
5191 .oBPOSalesOrder.ClearShippingFields(@loOrdHdr)
5192 loOrdHdr.ack_prn = "N"
5193 loOrdHdr.Store = tcEiPCth.Store
5194 loOrdHdr.Ord_Status = 'O'
5195
5196 SELECT Vzzoordrh_860I
5197 APPEND BLANK
5198 GATHER NAME loOrdHdr MEMO
5199
5200 REPLACE pkey WITH lnNextHdrPkey, ;
5201 ord_num WITH lnOrd_num, ;
5202 ord_qty WITH 0, ;
5203 User_Id WITH lcUser, ;
5204 last_mod WITH ldLastUpdate ;
5205 IN Vzzoordrh_860I
5206
5207 .oLog.LogEntry("Copying Header Notes .")
5208
5209 lcSqlString = "select * from sysnotes where table_name = 'ZZOORDRH' " + ;
5210 " AND fkey = " + SQLFormatNum(lnHdrPkey)
5211 llRetVal = llRetVal AND v_SqlExec(lcSQLString, "tcHdrNotes")
5212
5213 SELECT tcHdrNotes
5214 SCAN
5215 SCATTER NAME loHdrNotes MEMO
5216
5217 SELECT Vnotes_zzoordrh_860I
5218
5219 APPEND BLANK
5220 GATHER NAME loHdrNotes MEMO
5221
5222 REPLACE pkey WITH v_NextPkey("SYSNOTES"), ;
5223 fkey with lnNextHdrPkey, ;
5224 User_Id WITH lcUser, ;
5225 last_mod WITH ldLastUpdate ;
5226 IN Vnotes_zzoordrh_860I
5227 ENDSCAN
5228 ELSE
5229 lnOrd_num = Vzzoordrh_860I.Ord_Num
5230 lnNextHdrPkey = Vzzoordrh_860I.Pkey
5231 llRetVal = true
5232 ENDIF
5233
5234 .oLog.LogEntry("Inserting Detail Record .")
5235
5236 lcSizeStr = ""
5237 FOR lnCnt = 1 TO .nMaxSizes
5238 lcSizeStr = lcSizeStr + "Size" + PADL(lnCnt, 2, "0") + "_Qty WITH 0 , "
5239 ENDFOR
5240
5241 lcSizeStr = lcSizeStr + " Total_Qty WITH 0 "
5242
5243 lnLine_Seq = 0
5244 IF RECCOUNT("tcOrdDtl") = 0
5245 SELECT tcOrdDtl
5246 APPEND BLANK
5247 ENDIF
5248
5249 SELECT tcOrdDtl
5250 SCAN
5251 lnDtlPkey = tcOrdDtl.pkey
5252 DELETE ALL IN Vzzoordrd_860I FOR ;
5253 Division = tcEiPCtd.Division ;
5254 AND Style = tcEiPCtd.Style ;
5255 AND Color_Code = tcEiPCtd.Color_Code ;
5256 AND Lbl_Code = tcEiPCtd.Lbl_Code ;
5257 AND Dimension = tcEiPCtd.Dimension
5258
5259 SCATTER NAME loOrdDtl MEMO
5260 loOrdDtl.Line_Status = 'O'
5261 loOrdDtl.Cncl_type = ''
5262 loOrdDtl.Cncl_rsn = ''
5263
5264 SELECT Vzzoordrd_860I
5265 APPEND BLANK
5266
5267 GATHER NAME loOrdDtl MEMO
5268
5269 SELECT tcEiPCtd
5270 SCATTER NAME loOrdDtl MEMO
5271
5272 SELECT Vzzoordrd_860I
5273 GATHER NAME loOrdDtl MEMO
5274
5275 lnNextDtlPkey = v_NextPkey("ZZOORDRD")
5276 lnLine_Seq = lnLine_Seq + 1
5277 lcReplaceStr = " REPLACE pkey with lnNextDtlPkey , " + ;
5278 " fkey with lnNextHdrPkey , " + ;
5279 " ord_num with lnOrd_num , " + ;
5280 " line_Seq with lnLine_Seq , " + ;
5281 " User_Id with lcUser, " + ;
5282 " last_mod with ldLastUpdate, " + ;
5283 lcSizeStr + ;
5284 " IN Vzzoordrd_860I "
5285
5286 &lcReplaceStr
5287
5288 Replace Vzzoordrh_860I.ord_qty WITH Vzzoordrh_860I.ord_qty+Vzzoordrd_860I.total_qty IN Vzzoordrh_860I
5289
5290 .DefaultHeaderDataToDetail("Vzzoordrh_860I","Vzzoordrd_860I", @taDuplicateFields)
5291
5292 .oLog.LogEntry("Copying Detail Notes .")
5293
5294 lcSqlString = "select * from sysnotes where table_name = 'ZZOORDRD' " + ;
5295 " AND fkey = " + SQLFormatNum(lnDtlPkey)
5296 llRetVal = llRetVal AND v_SqlExec(lcSQLString, "tcDtlNotes")
5297
5298 SELECT tcDtlNotes
5299 SCAN
5300 SCATTER NAME loDtlNotes MEMO
5301 SELECT Vnotes_zzoordrd_860I
5302
5303 APPEND BLANK
5304 GATHER NAME loDtlNotes MEMO
5305
5306 REPLACE pkey WITH v_NextPkey("SYSNOTES"), ;
5307 fkey with lnNextDtlPkey, ;
5308 User_Id WITH lcUser, ;
5309 last_mod WITH ldLastUpdate ;
5310 IN Vnotes_zzoordrd_860I
5311 ENDSCAN
5312
5313 ENDSCAN
5314
5315 ENDIF
5316 ENDWITH
5317
5318 .TableClose("tcOrdHdr")
5319 .TableClose("tcOrdDtl")
5320 .TableClose("tcHdrNotes")
5321 .TableClose("tcDtlNotes")
5322
5323 SELECT(lnOldSelect)
5324 RETURN llRetVal
5325 ENDPROC
5326 *=== TR 1021052 21-AUG-2007 HNISAR & Goutam
5327
5328 *--- TR 1023071 04/03/07 NH
5329 ***********************************************************************************
5330 *PROCEDURE PopulateTranHdrDivision
5331 PROCEDURE CheckPoAndPopulateHdrDivision
5332 LPARAMETERS pceipcth, pceipcTD, pceipcCR
5333 *--- TR 1048865 27-May-2011 Goutam. Added parameter pceipcTD, pceipcCR
5334
5335 LOCAL llRetVal, lnOldSelect, lcSql
5336 LOCAL lcCustPo
5337
5338 *--- TR 1048865 27-Dec-2010 Goutam
5339 LOCAL llEmptyDivision
5340 *=== TR 1048865 27-Dec-2010 Goutam
5341
5342 lcCustPo = ""
5343 llRetVal = .t.
5344 lnOldSelect = SELECT()
5345
5346 *--- TR 1048865 24-Dec-2010 Goutam
5347 IF .CheckUpc(pceipcTH, pceipcTD, pceipcCR) AND .CheckSKU(pceipcTH, pceipcTD) AND .CheckEAN(pceipcTH, pceipcTD)
5348 llRetVal= llRetVal AND this.UpdtHeaderDivs(pceipcTH, pceipcTD)
5349 ENDIF
5350
5351 *SELECT DISTINCT customer, po_num, division FROM (pceipcth) WHERE division = '' AND customer > '' INTO CURSOR _CustPO
5352 SELECT DISTINCT customer, po_num, division FROM (pceipcth) WHERE customer > '' INTO CURSOR _CustPO
5353 *=== TR 1048865 24-Dec-2010 Goutam
5354
5355 IF RECCOUNT("_CustPO") = 0
5356 USE IN ("_CustPO")
5357 lnOldSelect = SELECT()
5358 RETURN llRetVal
5359 ENDIF
5360 WITH this
5361
5362 this.cSQLTempTable=""
5363 llRetVal = llRetVal and .GenerateSQLTempTable('_CustPO')
5364 llRetVal = llRetVal and .PopulateSQLTempTable('_CustPO') and !EMPTY(.cSQLTempTable)
5365 lcTmpTbl = .cSQLTempTable
5366
5367 *--- TR 1048865 24-Dec-2010 Goutam
5368
5369*!* TEXT TO lcSql NOSHOW
5370*!* select distinct h.customer, h.po_num, coalesce(oh.division, '') as division
5371*!* FROM zzeipcth h left outer join zzoordrh oh (nolock)
5372*!* on h.po_num = oh.po_num and h.customer = oh.customer and oh.ord_status = 'O'
5373*!* order by h.customer,h.po_num
5374*!* ENDTEXT
5375
5376*!* lcSql = STRTRAN(lcSql,"zzeipcth",lcTmpTbl)
5377*!* lcCustPoDiv = SYS(2015)
5378*!* llRetVal = llRetVal and v_sqlexec(lcSql, lcCustPoDiv) AND USED(lcCustPoDiv)
5379
5380*!* IF llRetval
5381*!* SELECT (pceipcth)
5382*!* lnPrevIpcthOrder = ORDER()
5383*!* SET ORDER TO ("custpo")
5384*!* SELECT(lcCustPoDiv)
5385*!* SCAN
5386*!* SCATTER NAME loCustPoDiv
5387*!* lcCustPo = loCustPoDiv.customer + loCustPoDiv.po_num
5388*!* IF SEEK(lcCustPo,pceipcth,'custpo')
5389*!* SELECT (pceipcth)
5390*!* SCAN WHILE customer + po_num = lcCustPo
5391*!* IF EMPTY(loCustPoDiv.division)
5392*!* replace errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + 'Corresponding sales order not found.' + CRLF IN (pceipcth)
5393*!* ELSE
5394*!* replace division with loCustPoDiv.division IN (pceipcth)
5395*!* ENDIF
5396*!* ENDSCAN
5397*!* ENDIF
5398*!* ENDSCAN
5399*!* SELECT (pceipcth)
5400*!* SET ORDER TO (lnPrevIpcthOrder)
5401*!* ENDIF
5402
5403 TEXT TO lcSql NOSHOW
5404 select distinct h.customer, h.po_num, coalesce(oh.division, '') as division
5405 from zzeipcth h left join
5406 (select customer, po_num, division from zzoordrh (nolock)
5407 union
5408 select customer, po_num, division from zzoshprh (nolock)) oh
5409 on h.po_num = oh.po_num and h.customer = oh.customer
5410 ENDTEXT
5411
5412 lcSql = STRTRAN(lcSql,"zzeipcth",lcTmpTbl)
5413 lcCustPoDiv = SYS(2015)
5414 llRetVal = llRetVal and v_sqlexec(lcSql, lcCustPoDiv) AND USED(lcCustPoDiv)
5415
5416 SELECT (pceipcth)
5417 lnPrevIpcthOrder = ORDER()
5418 SET ORDER TO ("custpo")
5419
5420 SELECT * FROM (lcCustPoDiv) WHERE EMPTY(division) INTO CURSOR __tmpEmptyDivCurs
5421 IF RECCOUNT('__tmpEmptyDivCurs') > 0
5422 llEmptyDivision = true
5423 ENDIF
5424
5425 SELECT (lcCustPoDiv)
5426 SCAN FOR NOT EMPTY(division)
5427 SCATTER NAME loCustPoDiv
5428 lcCustPo = loCustPoDiv.customer + loCustPoDiv.po_num
5429 IF SEEK(lcCustPo,pceipcth,'custpo') AND EMPTY(&pceipcth..Division)
5430 replace division with loCustPoDiv.division WHILE customer + po_num = lcCustPo IN (pceipcth)
5431 ENDIF
5432 ENDSCAN
5433
5434 IF llEmptyDivision
5435 *--- TR 1054768 4-Jul-2011 Goutam. Added and oh.division = case when th.division = '' then oh.division else th.division end
5436 TEXT TO lcSql NOSHOW
5437 select distinct h.parent, h.customer, h.po_num, coalesce(oh.division, '') as division
5438 from (select c.parent, c.customer, tmp.po_num from zzxcustr c join
5439 (select distinct h.customer, h.po_num, coalesce(oh.division, '') as division
5440 from zzeipcth h left join
5441 (select customer, po_num, division from zzoordrh (nolock)
5442 union
5443 select customer, po_num, division from zzoshprh (nolock)) oh
5444 on h.po_num = oh.po_num and h.customer = oh.customer
5445 ) tmp
5446 on tmp.customer = c.parent
5447 where tmp.division = '') h left join
5448 (select customer, po_num, division from zzoordrh (nolock)
5449 union
5450 select customer, po_num, division from zzoshprh (nolock)) oh
5451 on h.po_num = oh.po_num and h.customer = oh.customer
5452 join zzeipcth th on oh.po_num = th.po_num
5453 and oh.division = case when th.division = '' then oh.division else th.division end
5454 ENDTEXT
5455
5456 lcSql = STRTRAN(lcSql,"zzeipcth",lcTmpTbl)
5457 lcCustPoDiv = SYS(2015)
5458 llRetVal = llRetVal and v_sqlexec(lcSql, lcCustPoDiv) AND USED(lcCustPoDiv)
5459
5460 IF llRetVal
5461 SELECT distinct parent, po_num FROM (lcCustPoDiv) INTO CURSOR __tmpCustPODiv
5462 SELECT * FROM __tmpEmptyDivCurs WHERE customer+po_num NOT in (SELECT parent+po_num FROM __tmpCustPODiv) INTO CURSOR __tmpNoCustCurs
5463
5464 SELECT __tmpCustPODiv
5465 SCAN
5466 lcPo_Num = Po_Num
5467 lcParent = Parent
5468 lcCustPo = lcParent + lcPo_Num
5469 SELECT * FROM (lcCustPoDiv) WHERE po_num = lcPo_Num AND Parent = lcParent AND NOT EMPTY(Division) INTO CURSOR __tmpParentCustCurs
5470 DO CASE
5471 CASE RECCOUNT('__tmpParentCustCurs') > 1
5472 SELECT __tmpParentCustCurs
5473 IF SEEK(lcCustPo,pceipcth,'custpo')
5474 replace errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + 'Multiple customer found for PO# : ' + ALLTRIM(lcPo_Num) + CRLF ;
5475 FOR customer + po_num = lcCustPo IN (pceipcth)
5476 SCAN
5477 IF SEEK(lcCustPo,pceipcth,'custpo')
5478 replace errs_msg_h WITH errs_msg_h + 'Customer : ' + ALLTRIM(__tmpParentCustCurs.Customer) + CRLF FOR customer + po_num = lcCustPo IN (pceipcth)
5479 ENDIF
5480 ENDSCAN
5481 ENDIF
5482 CASE RECCOUNT('__tmpParentCustCurs') = 1
5483 IF SEEK(lcCustPo,pceipcth,'custpo') AND EMPTY(&pceipcth..Division)
5484 replace division with __tmpParentCustCurs.division FOR customer + po_num = lcCustPo IN (pceipcth)
5485 ENDIF
5486 IF SEEK(lcCustPo,pceipcth,'custpo')
5487 replace Customer with __tmpParentCustCurs.Customer FOR customer + po_num = lcCustPo IN (pceipcth)
5488 ENDIF
5489 ENDCASE
5490 ENDSCAN
5491 SELECT __tmpNoCustCurs
5492 SCAN
5493 lcPo_Num = Po_Num
5494 lcParent = Customer
5495 lcCustPo = lcParent + lcPo_Num
5496 IF SEEK(lcCustPo,pceipcth,'custpo')
5497 replace errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + 'PO# ' + ALLTRIM(lcPo_Num) + ' is not found for the customer ' + ALLTRIM(lcParent) + CRLF FOR customer + po_num = lcCustPo IN (pceipcth)
5498 ENDIF
5499 ENDSCAN
5500
5501 USE IN SELECT("__tmpParentCustCurs")
5502 USE IN SELECT("__tmpCustPODiv")
5503 USE IN SELECT("__tmpNoCustCurs")
5504 ENDIF
5505 ENDIF
5506 .tableclose(lcCustPoDiv)
5507 .tableclose('__tmpEmptyDivCurs')
5508 SELECT (pceipcth)
5509 SET ORDER TO (lnPrevIpcthOrder)
5510 *=== TR 1048865 24-Dec-2010 Goutam
5511
5512 ENDWITH
5513 SELECT(lnOldSelect)
5514 RETURN llRetVal
5515 ENDPROC
5516 *=== TR 1023071 NH
5517
5518 *--- TR 1025576 NH
5519 *----------------------------------------------------------------------------------
5520
5521 PROCEDURE CheckForPartialPickInvoice_Hdrlevel
5522 LPARAMETERS pcEipcth
5523 LOCAL llRetVal, lnOldSelect, lcFilter, lcSQL
5524 llRetVal = .t.
5525 lnOldSelect = SELECT()
5526 *-- TR 1042936 OCT-27-2009 BR ADDED: store, ForAllStore to select statement.
5527 SELECT pkey, customer, po_num, store, ForAllStore, ' ' PICKFOUND, ' ' INVOICEFOUND FROM (pcEipcth) INTO CURSOR __temp_zzeipcth
5528
5529 IF RECCOUNT("__temp_zzeipcth") = 0
5530 SELECT(lnOldSelect)
5531 RETURN .t.
5532 ENDIF
5533 LOCAL lcZzeipcth
5534 lcZzeipcth = ""
5535 this.cSQLTempTable =""
5536 llRetVal = llRetVal and this.GenerateSQLTempTable('__temp_zzeipcth')
5537 llRetVal = llRetVal and this.PopulateSQLTempTable('__temp_zzeipcth')
5538 lcZzeipcth = this.cSQLTempTable
5539 USE IN __temp_zzeipcth
5540
5541 *-- TR 1042936 OCT-27-2009 BR
5542 TEXT TO lcSQL NOSHOW
5543 update th set PICKFOUND = 'Y' from zzeipcth Th
5544 inner join zzoordrh h WITH (NOLOCK) on h.po_num = th.po_num and h.customer = th.customer and h.ord_status = 'P'
5545 WHERE th.ForAllStore = 'P'
5546 ENDTEXT
5547 lcSQL = STRTRAN(lcSQL,"zzeipcth",lcZzeipcth)
5548 llRetVal = llRetVal and v_sqlexec(lcSQL)
5549
5550 TEXT TO lcSQL NOSHOW
5551 update th set PICKFOUND = 'Y' from zzeipcth Th
5552 inner join zzoordrh h WITH (NOLOCK) on h.po_num = th.po_num and h.customer = th.customer
5553 and h.ord_status = 'P' and h.store = th.store
5554 WHERE th.ForAllStore <> 'P'
5555 ENDTEXT
5556
5557 lcSQL = STRTRAN(lcSQL,"zzeipcth",lcZzeipcth)
5558 llRetVal = llRetVal and v_sqlexec(lcSQL)
5559
5560
5561 TEXT TO lcSQL NOSHOW
5562 update th set INVOICEFOUND = 'Y' from zzeipcth Th
5563 inner join zzoshprh h WITH (NOLOCK) on h.po_num = th.po_num and h.customer = th.customer
5564 WHERE th.ForAllStore = 'P'
5565
5566 ENDTEXT
5567 lcSQL = STRTRAN(lcSQL,"zzeipcth",lcZzeipcth)
5568 llRetVal = llRetVal and v_sqlexec(lcSQL)
5569
5570 TEXT TO lcSQL NOSHOW
5571 update th set INVOICEFOUND = 'Y' from zzeipcth Th
5572 inner join zzoshprh h WITH (NOLOCK) on h.po_num = th.po_num and h.customer = th.customer and h.store = th.store
5573 WHERE th.ForAllStore <> 'P'
5574 ENDTEXT
5575 *== TR 1042936 OCT-27-2009 BR
5576
5577 lcSQL = STRTRAN(lcSQL,"zzeipcth",lcZzeipcth)
5578 llRetVal = llRetVal and v_sqlexec(lcSQL)
5579 lcSQL = "select * from " + lcZzeipcth + " where PICKFOUND > '' OR INVOICEFOUND > ''"
5580 lcZzeipcth = SYS(2015)
5581 llRetVal = llRetVal and v_sqlexec(lcSQL,lcZzeipcth)
5582
5583 *--- update 860 transaction cursor with error
5584 UPDATE h SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + IIF(PICKFOUND == 'Y', "Pick order found for this PO." + CHR(13) + CHR(10) ,"") + ;
5585 IIF(INVOICEFOUND == 'Y',"Invoice found for this PO." + CHR(13) + CHR(10) ,"") ;
5586 from (pcEipcth) h inner join (lcZzeipcth) he on h.customer = he.customer AND h.po_num = he.po_num
5587
5588 *--- check for
5589 SELECT(lnOldSelect)
5590 RETURN llRetVal
5591 ENDPROC
5592
5593 *-----------------------------------------------------------------------------------
5594
5595 *--- TR 1027127 NH
5596 PROCEDURE CheckForEmptyStore
5597 LPARAMETERS pceipcTH
5598 LOCAL llRetVal, lnOldSelect
5599 llRetVal = .t.
5600 lnOldSelect = SELECT()
5601
5602 UPDATE h SET ERRS_FLG_H = 'Y', ERRS_MSG_H = ERRS_MSG_H + "Invalid Store code." + CRLF FROM (pceipcTH) h ;
5603 WHERE h.poc_purp <> '01' AND h.store = ' ' AND h.errs_flg_h <> 'Y' AND NOT (po_type = 'BK' OR po_type ='BL' OR po_type = 'KC')
5604
5605 SELECT(lnOldSelect)
5606 RETURN llRetVal
5607 ENDPROC
5608
5609 *=== TR 1027127 NH
5610 *-----------------------------------------------------------------------------------
5611
5612 Procedure GetVerticalOpenOrder(pcZzoordrd_orig,pcRefZzoordrdv_Orig)
5613
5614 Local llRetVal, lnOldSelect, lcUnique, lcSQL
5615 lnOldSelect = Select()
5616 llRetVal = .T.
5617 lcUnique = Sys(2015)
5618 lcZzoordrdv_orig = "#Zzoordrdv_orig" + lcUnique
5619
5620 *--- TR 1072221 27-Jun-14 SK Added field 'edipo4udf1' in the select list ===
5621 *--- need to consider cncl_rsn, cncl_type
5622 *- 1041968 08/26/10 YIK
5623 *- Added field implosion
5624 TEXT TO lcSQL NOSHOW
5625 select fkey, ord_num, pick_num, inv_num, line_seq, line_status, division, style, color_code, lbl_code, dimension,
5626 b.size_num as sizebucket, cncl_rsn, cncl_type,implosion,
5627 d.size01_qty * b.sz01 + d.size02_qty * b.sz02 + d.size03_qty * b.sz03 + d.size04_qty * b.sz04 + d.size05_qty * b.sz05 +
5628 d.size06_qty * b.sz06 + d.size07_qty * b.sz07 + d.size08_qty * b.sz08 + d.size09_qty * b.sz09 + d.size10_qty * b.sz10 +
5629 d.size11_qty * b.sz11 + d.size12_qty * b.sz12 + d.size13_qty * b.sz13 + d.size14_qty * b.sz14 + d.size15_qty * b.sz15 +
5630 d.size16_qty * b.sz16 + d.size17_qty * b.sz17 + d.size18_qty * b.sz18 + d.size19_qty * b.sz19 + d.size20_qty * b.sz20 +
5631 d.size21_qty * b.sz21 + d.size22_qty * b.sz22 + d.size23_qty * b.sz23 + d.size24_qty * b.sz24
5632 as size_qty, edipo4udf1
5633 into #Zzoordrdv_orig
5634 from #zzoordrd_orig d cross join zzxbuckt b
5635 where
5636 d.size01_qty * b.sz01 + d.size02_qty * b.sz02 + d.size03_qty * b.sz03 + d.size04_qty * b.sz04 + d.size05_qty * b.sz05 +
5637 d.size06_qty * b.sz06 + d.size07_qty * b.sz07 + d.size08_qty * b.sz08 + d.size09_qty * b.sz09 + d.size10_qty * b.sz10 +
5638 d.size11_qty * b.sz11 + d.size12_qty * b.sz12 + d.size13_qty * b.sz13 + d.size14_qty * b.sz14 + d.size15_qty * b.sz15 +
5639 d.size16_qty * b.sz16 + d.size17_qty * b.sz17 + d.size18_qty * b.sz18 + d.size19_qty * b.sz19 + d.size20_qty * b.sz20 +
5640 d.size21_qty * b.sz21 + d.size22_qty * b.sz22 + d.size23_qty * b.sz23 + d.size24_qty * b.sz24 > 0
5641 ENDTEXT
5642
5643 lcSQL = Strtran(lcSQL,"#zzoordrd_orig",pcZzoordrd_orig)
5644 lcSQL = Strtran(lcSQL,"#Zzoordrdv_orig",lcZzoordrdv_orig)
5645 llRetVal = llRetVal And v_SQLExec(lcSQL)
5646
5647 pcRefZzoordrdv_orig = lcZzoordrdv_orig
5648 Select(lnOldSelect)
5649 Return llRetVal
5650
5651 Endproc
5652
5653 *-----------------------------------------------------------------------------------------
5654
5655 *---- TR 1022030 NH
5656 Procedure RangeStyle
5657 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipcCR &&, pcViewTransDetail
5658 Local llRetVal, lnOldSelect, lcErrs_Msg
5659 llRetVal = .T.
5660 lnOldSelect = Select()
5661
5662 *****************************************************************************
5663 * 1st Getting all range style (hdr/dtl) that relate to the
5664 * passing order line for this run
5665
5666 * additional past for range style verification/explotion
5667 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
5668 FROM (pcTransHeader) h, (pcTransDetail) d ;
5669 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5670 And d.Errs_Flg_D= "N" And ;
5671 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5672 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5673
5674 With This
5675 .cSQLTempTable=""
5676 If .GenerateSQLTempTable('__TmpCursor')
5677 If .PopulateSQLTempTable('__TmpCursor')
5678 If !Empty(.cSQLTempTable)
5679
5680 .oLog.LogEntry("Exploding range style.")
5681 * Get range style header
5682 *- 1000984 9/11/03 YIK
5683 *- do not explode range styles type 'P'rint
5684 *- Added ..and h.rng_type <> 'P'
5685 LOCAL lcTranTmp
5686 lcTranTmp = .cSQLTempTable
5687 lcSQLString= "select h.* from zzxrangh h," + lcTranTmp + " t " +;
5688 "Where h.division= t.division and h.rng_style = t.style and "+;
5689 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5690 "h.rng_pack= t.dimension and h.rng_type <> 'P'"
5691 *= 1000984
5692 llRetVal = v_SqlExec(lcSQLString, "__RangH")
5693
5694 * TAN 31891 - JAZ - 5/20/02
5695 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5696 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5697 * End TAN 31891 - JAZ - 5/20/02
5698
5699 If llHaveRangeStyleToExplode
5700
5701 * Get range style detail
5702 *- 1000984 9/11/03 YIK
5703 *- do not explode range styles type 'P'rint
5704 *- Added ..and h.rng_type <> 'P'
5705 lcSQLString= "Select * From zzxrangd where fkey in " +;
5706 "(select h.pkey from zzxrangh h," + lcTranTmp + " t " +;
5707 "Where h.division= t.division and h.rng_style = t.style and "+;
5708 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5709 "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5710 *= 1000984
5711 llRetVal = v_SqlExec(lcSQLString, "__RangD")
5712
5713 * turn Range detail to vertical (with sizebucket,size_desc)
5714 * have to explode in vertical format
5715 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5716 Select sizebucket, size_desc, qty_change as total_qty From (pcTransDetail) ;
5717 WHERE 0=1 Into Cursor __Range2
5718 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5719 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5720 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5721 If Used("__Range1")
5722 Use In __Range1
5723 Endif
5724 If Used("__Range2")
5725 Use In __Range2
5726 Endif
5727
5728 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5729 Select __RangH
5730 Index On pkey Tag pkey
5731 Select __RangD
5732 Index On division+Style Tag DivStyle
5733 Select tcRangeVer
5734 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5735 Set Order To RangeSKU
5736 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5737
5738 *****************************************************************************
5739 * 2). Validate "Run"- type of range style. divisible by range header qty
5740 If .ValidateRangeStyle("__RangH", pcTransDetail, pcTransHeader)
5741
5742 *****************************************************************************
5743 * 3). Explode range style only once good tran detail that have
5744 * matching range style. Vertical range style explosion
5745 Select Distinct d.pkey ;
5746 FROM __RangD r, (pcTransDetail) d ;
5747 WHERE d.Errs_Flg_D= "N" And ; &&no error
5748 d.rng_style= '' And ; &&never explode before
5749 r.division= d.division And r.rng_style = d.Style And ; && matching range
5750 r.rng_color= d.color_code And r.rng_lbl= d.lbl_code And ; && style
5751 r.rng_pack= d.Dimension ;
5752 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5753 INTO Cursor __DtlExpl
5754 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail) &&, pcViewTransDetail
5755 Endif
5756 Endif
5757 Endif
5758 Endif
5759 Endif
5760 Endwith
5761
5762 If Used("__RangH")
5763 Use In __RangH
5764 Endif
5765 If Used("__RangD")
5766 Use In __RangD
5767 Endif
5768 If Used("tcRangeVer")
5769 Use In tcRangeVer
5770 Endif
5771 If Used("__DtlExpl")
5772 Use In __DtlExpl
5773 Endif
5774 If Used("__TmpCursor")
5775 Use In __TmpCursor
5776 Endif
5777
5778 Select(lnOldSelect)
5779 Return llRetVal
5780 Endproc
5781
5782 *-----------------------------------------------------------------------------------
5783
5784 Procedure ExplodeRangeRef
5785 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5786 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5787 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5788
5789 lnOldSele= Select()
5790 lcDivStyle= ""
5791 lnSourceCnt= RecCount(pcRangeDetail)
5792 llRetVal= .T.
5793 lnCurDtlFkey= 0
5794
5795 Select (pcRangeDetail)
5796 Set Order To DivStyle
5797 Scan
5798 If lnCurDtlFkey<> fkey
5799 lnCurDtlFkey= fkey
5800 If Seek(fkey, pcRangeHeader , "PKEY")
5801 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5802 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5803 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5804 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5805 Else
5806 llRetVal = .F.
5807 Exit
5808 Endif
5809 Endif
5810
5811 * only run once per Div + Style
5812 If !(lcDivStyle == division + Style)
5813 lcDivStyle = division + Style
5814 * Insert a record for each size bucket with a caption *
5815 If !v_GetSizeHeadings(division, Style, "__xSizer")
5816 llRetVal = .F.
5817 Exit
5818 Endif
5819 Endif
5820
5821 Select (pcRangeDetail)
5822 Scatter Memvar Memo
5823 For lnSizePosition = 1 To goEnv.MaxBuckets
5824 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5825 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5826 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5827 m.sizebucket = lnSizePosition
5828 m.size_desc = lcSizeName
5829 m.total_qty = lnSizeQty
5830 If lnSizeQty > 0 && Only want buckets with activity!
5831 Insert Into (pcRangeDetailTarget) From Memvar
5832 Endif
5833 Endfor
5834
5835 Endscan
5836 This.TableClose("__xSizer")
5837 Select (pcRangeDetail)
5838 Select (lnOldSele)
5839 Return llRetVal
5840 Endproc
5841
5842 *-----------------------------------------------------------------------------------
5843
5844 Procedure ValidateRangeStyle
5845 Lparameters pcRangeStyle, pcTransDetail, pcTransHeader
5846 Local llRetVal, lnOldSelect, lcErrs_Msg
5847 llRetVal = .T.
5848 lnOldSelect = Select()
5849 lcErrs_Msg= "Total Units must be divisible by "
5850
5851 Select (pcRangeStyle)
5852 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5853 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5854 "division+style+color_code+lbl_code+dimension")
5855
5856 If llRetVal
5857 .oLog.LogEntry("Validating range style.")
5858 * Verify range style "R"un order in min multiple of rng_qty
5859 * no need for "S"et verification of range type --just explode to
5860 * range detail
5861 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5862 *- 1023438 04/06/07 YIK
5863 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5864 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5865 If Mod(EVALUATE(pcTransDetail + ".qty_change"), __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5866 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5867 Errs_Flg_D With "Y" ;
5868 IN (pcTransDetail)
5869 Endif
5870 Endscan
5871 Endif
5872
5873 Set Relation To
5874
5875 *--- Error out range style for price variance
5876 *--- User has to change the Range style Reference price to match with the price coming in flat file.
5877 llRetVal = llRetVal and .CheckRangeStylePriceVariance(pcRangeStyle, pcTransDetail, pcTransHeader)
5878
5879 Select(lnOldSelect)
5880 Return llRetVal
5881 Endproc
5882
5883 *-----------------------------------------------------------------------------------
5884
5885 PROCEDURE CheckRangeStylePriceVariance
5886 LPARAMETERS pcRangeStyle, pcTransDetail, pcTransHeader
5887
5888 *--- get customer sales ref
5889 LOCAL lcErrs_Msg, llRetVal, lnOldSelect
5890 llRetVal = .t.
5891 lnOldSelect = SELECT()
5892 lcErrs_Msg = "Cannot check price variance - Price code is missing in transaction header."
5893
5894 UPDATE h SET errs_flg_h = 'Y', Errs_msg_h = h.Errs_msg_h + lcErrs_Msg + CRLF FROM (pcTransHeader) h WHERE h.price_code = ''
5895
5896 IF !This.lRslv_pricecode_cssld && TR 1088126 8-JUL-2015 Venuk
5897
5898 UPDATE d SET Errs_flg_d = 'Y', Errs_msg_d = d.Errs_msg_d + lcErrs_Msg + CRLF ;
5899 FROM (pcTransHeader) h inner join (pcTransDetail) d on h.pkey = d.fkey ;
5900 WHERE h.price_code = ''
5901
5902 *--- compare transaction price with range style price before exploding to its component
5903
5904 UPDATE d SET errs_flg_d = 'Y', Errs_msg_d = d.Errs_msg_d + 'Range style price variance failed - Range style reference ' + h.price_code + ' price is ' + ;
5905 TRANSFORM(IIF(h.price_code = 'A', r.a_price, IIF(h.price_code = 'B', r.b_price,IIF(h.price_code = 'C', r.c_price,;
5906 IIF(h.price_code = 'D', r.d_price, IIF(h.price_code = 'E', r.e_price, 0 )))))) + ;
5907 ', but transaction line item price is ' + TRANSFORM(IIF(d.poc_cost = 0,'0',d.poc_cost)) + CRLF ;
5908 FROM (pcTransHeader) h inner join (pcTransDetail) d on h.pkey = d.fkey ;
5909 inner join (pcRangeStyle) r on r.division = d.division AND r.rng_style = d.style AND r.rng_color = d.color_code ;
5910 AND r.rng_lbl = d.lbl_code AND r.rng_pack = d.rng_pack ;
5911 WHERE d.qualifier in ('AI','RZ','PC') ;
5912 and IIF(h.price_code = 'A', r.a_price, IIF(h.price_code = 'B', r.b_price, IIF(h.price_code = 'C', r.c_price,;
5913 IIF(h.price_code = 'D', r.d_price, IIF(h.price_code = 'E', r.e_price, 0 ))))) <> d.POC_Cost ;
5914 and d.Errs_flg_d <> 'Y' AND d.rng_style = ''
5915
5916 *--- TR 1088126 8-JUL-Venuk
5917 ELSE
5918 lcErrs_Msg = "Cannot check price variance - Price code is missing in transaction detail."
5919
5920 UPDATE d SET Errs_flg_d = 'Y', Errs_msg_d = d.Errs_msg_d + lcErrs_Msg + CRLF ;
5921 FROM (pcTransHeader) h inner join (pcTransDetail) d on h.pkey = d.fkey ;
5922 WHERE d.price_code = ''
5923
5924 UPDATE d SET errs_flg_d = 'Y', Errs_msg_d = d.Errs_msg_d + 'Range style price variance failed - Range style reference ' + d.price_code + ' price is ' + ;
5925 TRANSFORM(IIF(d.price_code = 'A', r.a_price, IIF(d.price_code = 'B', r.b_price,IIF(d.price_code = 'C', r.c_price,;
5926 IIF(d.price_code = 'D', r.d_price, IIF(d.price_code = 'E', r.e_price, 0 )))))) + ;
5927 ', but transaction line item price is ' + TRANSFORM(IIF(d.poc_cost = 0,'0',d.poc_cost)) + CRLF ;
5928 FROM (pcTransHeader) h inner join (pcTransDetail) d on h.pkey = d.fkey ;
5929 inner join (pcRangeStyle) r on r.division = d.division AND r.rng_style = d.style AND r.rng_color = d.color_code ;
5930 AND r.rng_lbl = d.lbl_code AND r.rng_pack = d.rng_pack ;
5931 WHERE d.qualifier in ('AI','RZ','PC') ;
5932 and IIF(d.price_code = 'A', r.a_price, IIF(d.price_code = 'B', r.b_price, IIF(d.price_code = 'C', r.c_price,;
5933 IIF(d.price_code = 'D', r.d_price, IIF(d.price_code = 'E', r.e_price, 0 ))))) <> d.POC_Cost ;
5934 and d.Errs_flg_d <> 'Y' AND d.rng_style = ''
5935
5936 ENDIF
5937 *=== TR 1088126 8-JUL-Venuk
5938
5939 Select(lnOldSelect)
5940 Return llRetVal
5941 Endproc
5942
5943 *-----------------------------------------------------------------------------------
5944
5945 PROCEDURE SetValuesFromCustomerSalesRef
5946 LPARAMETERS pcTransHeader, pcTransDetail
5947 *--- TR 1088126 7-JUL-2015 Venuk. Added param pcTransDetail ===
5948 LOCAL llRetVal , lnOldSelect
5949 llRetVal = .t.
5950 lnOldSelect = SELECT()
5951
5952 IF goEnv.sv("RANK_PRICE_RESOLUTION","N") = 'N'
5953 this.LogEntry("Cannot resolve customer sales ref - missing necessary rank field.")
5954 RETURN llRetVal
5955 ENDIF
5956
5957 * TR 1048519 23-AUG-10 KISHOR - Added ord_type
5958 *--- TR 1053720 6-Sep-2011 Goutam. ord_type is not available so crashing here!!!
5959 *SELECT pkey, customer, store, department, division, ord_type FROM (pcTransHeader) WHERE errs_msg_h <> 'Y' INTO CURSOR __TmpCursor
5960 SELECT pkey, customer, store, department, division, po_num FROM (pcTransHeader) WHERE errs_msg_h <> 'Y' INTO CURSOR __TmpCursor
5961 *=== TR 1053720 6-Sep-2011 Goutam
5962
5963 IF RECCOUNT("__TmpCursor") = 0
5964 lcCheckVariance = .f.
5965 RETURN llRetVal
5966 ENDIF
5967
5968 WITH this
5969 .cSQLTempTable = ""
5970 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor') AND .PopulateSQLTempTable('__TmpCursor') and !Empty(.cSQLTempTable)
5971
5972 * TR 1048519 23-AUG-10 KISHOR - Added ord_type
5973 *--- TR 1053720 6-Sep-2011 Goutam
5974 *lcSql = " select a.rank_seq, a.* from " + ;
5975 " (select t.pkey as h_pkey, ir.* from zzxcslsr ir inner join " + .cSQLTempTable + " t on t.customer = ir.customer " + ;
5976 " and (t.store = ir.store or ir.store = '') and (t.department = ir.department or ir.department = '') " + ;
5977 " and (t.division = ir.division or ir.division = '') " + ;
5978 " and (t.ord_type = ir.ord_type or ir.ord_type = '')) a " + ;
5979 " where exists ( select b.h_pkey from " + ;
5980 " ( select t.pkey as h_pkey, ir.* from zzxcslsr ir " + ;
5981 " inner join " + .cSQLTempTable + " t on t.customer = ir.customer and (t.store = ir.store or ir.store = '') " + ;
5982 " and (t.department = ir.department or ir.department = '') " + ;
5983 " and (t.division = ir.division or ir.division = '') " + ;
5984 " and (t.ord_type = ir.ord_type or ir.ord_type = '') " + ;
5985 " ) b where b.h_pkey = a.h_pkey group by b.h_pkey having min(b.rank_seq) = a.rank_seq) " + ;
5986 " order by a.h_pkey, a.customer, a.store, a.department, a.division, a.ord_type "
5987
5988 *--- TR 1088126 7-JUL-2015 Venuk. Added ir.CRS_pkey field ===
5989 lcSql = " select a.rank_seq, a.* from " + ;
5990 " (select t.pkey as h_pkey, ir.pkey as CRS_pkey, ir.* from zzxcslsr ir inner join " + .cSQLTempTable + " t on t.customer = ir.customer " + ;
5991 " and (t.store = ir.store or ir.store = '') and (t.department = ir.department or ir.department = '') " + ;
5992 " and (t.division = ir.division or ir.division = '') " + ;
5993 " join zzoordrh oh ON(oh.po_num = t.po_num) and (oh.department = t.department or t.department = '') " + ;
5994 " and (oh.division = t.division) and (oh.customer = t.customer) and (oh.ord_type = ir.ord_type or ir.ord_type = '')) a " + ;
5995 " where exists ( select b.h_pkey from " + ;
5996 " ( select t.pkey as h_pkey, ir.* from zzxcslsr ir " + ;
5997 " inner join " + .cSQLTempTable + " t on t.customer = ir.customer and (t.store = ir.store or ir.store = '') " + ;
5998 " and (t.department = ir.department or ir.department = '') " + ;
5999 " and (t.division = ir.division or ir.division = '') " + ;
6000 " join zzoordrh oh ON(oh.po_num = t.po_num) and (oh.department = t.department or t.department = '') " + ;
6001 " and (oh.division = t.division) and (oh.customer = t.customer) and (oh.ord_type = ir.ord_type or ir.ord_type = '') " + ;
6002 " ) b where b.h_pkey = a.h_pkey group by b.h_pkey having min(b.rank_seq) = a.rank_seq) " + ;
6003 " order by a.h_pkey, a.customer, a.store, a.department, a.division, a.ord_type "
6004
6005 *=== TR 1053720 6-Sep-2011 Goutam
6006
6007 *customer, store, department, division, GROUP_TYPE
6008 lcCustSalesRef = "tcCustSalesRef" + SYS(2015)
6009 llRetVal = llRetVal and v_sqlexec(lcSql, lcCustSalesRef)
6010 IF llRetVal
6011 UPDATE h SET price_code = r.price_code FROM (pcTransHeader) h inner join (lcCustSalesRef) r on h.pkey = r.h_pkey
6012 ENDIF
6013
6014 *--- TR 1088126 7-JUL-2015 Venuk
6015 IF This.lRslv_pricecode_cssld
6016 SELECT CRS_pkey,h_pkey, d.pkey pkey , t.division, t.group_type ;
6017 , d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, t.price_code ;
6018 FROM (lcCustSalesRef) t;
6019 JOIN (pcTransDetail) d ;
6020 On t.h_pkey=d.fkey ;
6021 WHERE Errs_flg_d <> 'Y' And t.CRS_pkey> 0 ;
6022 INTO CURSOR __TmpCursorDet
6023
6024 .cSQLTempTable = ""
6025 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursorDet') AND .PopulateSQLTempTable('__TmpCursorDet') and !Empty(.cSQLTempTable)
6026
6027
6028 lcPriceCode = IIF(This.lRslv_pricecode_cssld," case when d.price_Code='' then h.price_code else d.price_code end as price_Code", ;
6029 " h.price_code")
6030 IF llRetVal
6031 lcSql = "select " + ;
6032 " case when d.price_Code='' then h.price_code else d.price_code end as price_Code, "+ ;
6033 " t.* " + ;
6034 " from " + .cSQLTempTable + " t " +;
6035 " join zzxscolr s on s.division = t.division" +;
6036 " and s.style = t.style and s.color_code = t.color_code and s.lbl_code=t.lbl_code " + ;
6037 " and s.dimension = t.dimension " + ;
6038 " join zzxcslsd d on d.fkey = t.crs_pkey and d.group_code = case t.group_type "+;
6039 " when 'A' then s.group_code1"+;
6040 " when 'B' then s.group_code2"+;
6041 " when 'C' then s.group_code3"+;
6042 " when 'D' then s.group_code4"+;
6043 " when 'E' then s.group_code5"+;
6044 " when 'F' then s.group_code6"+;
6045 " when 'G' then s.group_code7"+;
6046 " when 'H' then s.group_code8"+;
6047 " when 'I' then s.group_code9"+;
6048 " when 'J' then s.group_code10"+;
6049 " when 'K' then s.group_code11"+;
6050 " when 'L' then s.group_code12"+;
6051 " when 'M' then s.group_code13"+;
6052 " end and d.group_type = t.group_type " + ;
6053 " join zzxcslsr h on d.fkey = h.pkey "
6054
6055 llRetVal = v_sqlExec(lcSql , "tmpcslsd")
6056 Select tmpcslsd
6057 Index On pkey Tag pkey
6058 Select (pcTransDetail)
6059 llRetVal= llRetVal And .SetRelation(pcTransDetail, "pkey", "tmpcslsd", "pkey")
6060
6061 IF llRetVal
6062 REPLACE ALL price_code WITH tmpcslsd.Price_code IN (pcTransDetail)
6063 ENDIF
6064
6065 SET RELATION TO
6066 ENDIF
6067 .TableClose("tmpcslsd")
6068 .TableClose("__TmpCursorDet")
6069 ELSE
6070 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey WHERE d.price_code=''
6071 ENDIF
6072 *=== TR 1088126 7-JUL-2015 Venuk
6073
6074 ENDWITH
6075
6076 Select(lnOldSelect)
6077 Return llRetVal
6078 Endproc
6079
6080 *-----------------------------------------------------------------------------------
6081 *- TR 1054193 FH 5/13/11
6082 PROCEDURE ValidateIfControlReferenceExist
6083 LPARAMETERS pceipcTH, pceipcCR
6084 LOCAL llRetVal, lnOldSelect, lcDivision, lcCustomer
6085 llRetVal = .t.
6086 lnOldSelect = SELECT()
6087
6088 *--- TR 1054768 4-Jul-2011 Goutam. now onwards we will take only cr_pkey for finding control record. not customer and division
6089 *Select distinct Customer, division from (pceipcTH) into cursor _tmpCustDiv
6090 Select distinct Customer, division, cr_pkey from (pceipcTH) into cursor _tmpCustDiv
6091 *=== TR 1054768 4-Jul-2011 Goutam
6092
6093 Select _tmpCustDiv
6094 SCAN
6095
6096 lcDivision = _tmpCustDiv.Division
6097 lcCustomer = _tmpCustDiv.Customer
6098
6099 *--- TR 1056420 26-Sep-11 SK Seeking for division and customer (Reverting 1054768)
6100 *--- TR 1054768 4-Jul-2011 Goutam.
6101 IF NOT SEEK(lcdivision+lccustomer, "zzeipccr", "divcust")
6102 *IF NOT (SEEK(_tmpCustDiv.cr_pkey , "zzeipccr", "pkey") AND zzeipccr.division = lcDivision)
6103 *=== TR 1054768 4-Jul-2011 Goutam.
6104 *=== TR 1056420 26-Sep-11 SK
6105
6106 *--- TR 1054768 4-Jul-2011 Goutam. Errs_Msg_H is overwriting existing error. This is wrong. we should always append error
6107 replace errs_flg_h WITH 'Y', Errs_Msg_H WITH Errs_Msg_H + 'EDI Control for Customer '+ customer +'and Division '+ ;
6108 division + ' not found.' + CRLF IN (pceipcTH) FOR CUSTOMER = lcCustomer and Division = lcDivision
6109
6110 *--- TR 1056420 26-Sep-11 SK Updating correct Pkey to CR_PKEY
6111 ELSE
6112 UPDATE (pceipcTH) SET cr_PKEY = zzeipccr.PKey WHERE division = lcdivision AND customer = lccustomer
6113 ENDIF
6114 *=== TR 1056420 26-Sep-11 SK
6115 ENDSCAN
6116
6117
6118 If Used("_tmpCustDiv")
6119 Use In _tmpCustDiv
6120 Endif
6121
6122
6123 SELECT(lnOldSelect)
6124 RETURN llRetval
6125 ENDPROC
6126 *- TR 1054193 FH 5/13/11
6127 *-----------------------------------------------------------------------------------
6128
6129 Procedure ExplodeRangeStyleVertical
6130 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
6131 Local llRetVal, lnOldSelect, lcErrs_Msg
6132 llRetVal = .T.
6133 lnOldSelect = Select()
6134
6135 Select (pcDetailtoExplode)
6136 Scan
6137 * Find detail line that need range style exploding using PKEY
6138 If Seek(pkey, pcTransDetail, "Pkey")
6139 * Current working trans detail
6140 Select (pcTransDetail)
6141 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
6142 *lnCurDtlTotal_qty= total_qty
6143 lnCurDtlTotal_qty= qty_change
6144
6145 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
6146 *- 1009508 3/16/05 YIK
6147 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
6148 lnRangeBucket = sizebucket
6149
6150 Scatter Name loTransDetail Memo
6151 * delete current working trans detail already have image
6152 * in loTransDetail
6153 Delete In (pcTransDetail)
6154 * --- TR 1018184 RLN 01/10/07
6155*!* lnDetailPkey = loTransDetail.pkey
6156*!* Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
6157 * === TR 1018184
6158
6159 Select (pcRangeDetailVert)
6160 * Find 1st match of OURSKU
6161 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
6162 * calculate lnMultiplier regardless of rng_type
6163 * --"R"un only divisible by rng_qty will get to this point
6164 * --otherwise will stay in errs_dtl_F/msg
6165
6166 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
6167 lnCurDtlTotal_qty/rng_qty)
6168
6169 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
6170 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
6171 * Exploding detail line
6172 *loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
6173 loTransDetail.pkey = v_nextPkey("ZZEIPCTD") && Never reassign Pkey in TD
6174 If !Empty(loTransDetail.pkey)
6175 *- 1009508 3/16/05 YIK
6176 Select (pcRangeDetailVert)
6177 Scatter Name loVert Memo
6178 *= 1009508
6179
6180 Select (pcTransDetail)
6181 Append Blank
6182 Gather Name loTransDetail Memo
6183
6184 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
6185 * resolve proper a..e_price latter when have price_code(CustSalesResv)
6186 * only recording a..e_price to zzeipoth and resetting org_price
6187 *org_price with &pcRangeDetailVert..a_price,
6188
6189 *- do not zero out org_price for MultiUPC
6190 Replace rng_style With loVert.rng_style, ;
6191 rng_color With loVert.rng_color, ;
6192 rng_lbl With loVert.rng_lbl, ;
6193 rng_pack With loVert.rng_pack, ;
6194 rng_bk With lnRangeBucket, ;
6195 rng_qty With loVert.rng_qty, ;
6196 rng_type With loVert.rng_type, ;
6197 qty_change With lnMultiplier * loVert.total_qty, ;
6198 sizebucket With loVert.sizebucket, ;
6199 size_desc With loVert.size_desc, ;
6200 division With loVert.division, ;
6201 STYLE With loVert.Style, ;
6202 color_code With loVert.color_code, ;
6203 lbl_code With loVert.lbl_code, ;
6204 DIMENSION With loVert.Dimension, ;
6205 org_price WITH org_price, ; && 4186- reset org_price when exploding range style
6206 upc With '', ;
6207 sku With '' ;
6208 a_price WITH loVert.a_price,; && 4186- store a..e_price
6209 b_price WITH loVert.b_price,; && from range style detail
6210 c_price WITH loVert.c_price,; && to use latter when have
6211 d_price WITH loVert.d_price,; && price_code
6212 e_price WITH loVert.e_price ;
6213 IN (pcTransDetail)
6214 *= 1009508 03/16/05 YIK
6215 * --- TR 1018184 RLN 01/10/07
6216*!* Select tmpRngSacs
6217*!* Scan
6218*!* Scatter Name loTmpSACs Memo
6219*!* loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
6220*!* loTmpSACs.dfkey = loTransDetail.pkey
6221*!* Insert Into (tcTransSAC) From Name loTmpSACs
6222*!* Endscan
6223 * === TR 1018184
6224 Else
6225 llRetVal= .F. && Cannot get Pkey from bcsysnum
6226 Exit
6227 Endif
6228
6229 Select (pcRangeDetailVert)
6230 Endscan
6231 Else
6232 llRetVal= .F. && Should be in pcrangdetailvert
6233 Exit
6234 Endif
6235 *Delete From (tcTransSAC) Where dfkey = lnDetailPkey
6236 Endif
6237
6238 If !llRetVal &&Get out of scan when have some problem
6239 Exit
6240 Endif
6241 Endscan
6242
6243 Select(lnOldSelect)
6244 Return llRetVal
6245 ENDPROC
6246
6247 *-----------------------------------------------------------------------------------
6248
6249 PROCEDURE ResolvePriceFromRangeStyle
6250 LPARAMETERS pcTransHeader, pcTransDetail
6251 LOCAL llRetVal, lnOldSelect, lcErrs_Msg, lcPrice_code
6252 llRetVal = .T.
6253 lnOldSelect = SELECT()
6254
6255 SELECT (pcTransDetail)
6256 SET ORDER TO
6257 llRetVal= .SetRelation(pcTransHeader, "pkey", pcTransDetail, "fkey")
6258 IF llRetVal
6259 * For each range style previously exploded if have header price_code
6260 * then start resolving proper price to org_price using a..e_price
6261 SELECT (pcTransDetail)
6262 *- 1009508 03/16/05 YIK
6263 *-- SCAN FOR !EMPTY(&pcTransDetail..rng_style) && Range style only
6264 *-- IF !EMPTY(&pcTransHeader..price_code) AND ; && empty when error on header
6265 *-- EMPTY(&pcTransDetail..org_price) && resolve only once--future could open up UI
6266 SCAN FOR !EMPTY(rng_style) && Range style only
6267 *--- TR 1088126 8-JUL-2015 Venuk.
6268 IF This.lRslv_pricecode_cssld
6269 lcPrice_code = EVALUATE(pcTransDetail + ".price_code")
6270 ELSE
6271 *=== TR 1088126 8-JUL-2015 Venuk.
6272 lcPrice_code = EVALUATE(pcTransHeader + ".price_code")
6273 ENDIF && TR 1088126 8-JUL-2015 Venuk.
6274 IF !EMPTY(lcPrice_code) AND ; && empty when error on header
6275 EMPTY(org_price) && resolve only once--future could open up UI
6276 *= 1009508
6277 lnPrice= EVAL(pcTransDetail+ "." + lcPrice_code + "_price")
6278 IF lnPrice>0
6279 *REPLACE org_price WITH lnPrice IN (pcTransDetail)
6280 REPLACE poc_cost WITH lnPrice IN (pcTransDetail)
6281 ENDIF
6282 ENDIF
6283 ENDSCAN
6284 ENDIF
6285
6286 SET RELATION TO
6287 SELECT(lnOldSelect)
6288 RETURN llRetVal
6289 ENDPROC
6290
6291 *==== TR 1022030 NH
6292 *-----------------------------------------------------------------------------------
6293
6294 *--- TR 1028744 19-FEB-2008 VKK
6295 ***********************************************************************************
6296 PROCEDURE CheckHardLink
6297 LPARAMETERS pnOrd_num
6298 LOCAL llRetVal, lnOldSelect, llCheckhardLink
6299 llRetVal= .T.
6300 lnOldSelect= SELECT()
6301
6302 WITH THIS
6303
6304 *--- TR 1048865 27-Dec-2010 Goutam
6305 *IF SEEK(Vzzoordrh_860I.division + Vzzoordrh_860I.customer , "zzeipccr","divCust")
6306 IF SEEK(Vzzoordrh_860I.cr_pkey , "zzeipccr", "pkey")
6307 *=== TR 1048865 27-Dec-2010 Goutam
6308
6309 llCheckHardlink = (zzeipccr.check_hdlk = 'Y')
6310 ENDIF
6311
6312 IF llCheckHardlink
6313 lcSQLString= "Select TOP 1 ord_num FROM zzoordud Where ord_num = " + SQLFormatNum(pnord_num)
6314
6315 llRetVal = v_SQLExec(lcSQLString, "_HardLink") AND EOF("_HardLink")
6316
6317 IF NOT llRetVal
6318 .RecordHeaderError("Order linked with Production Order cannot be changed.")
6319 ENDIF
6320
6321 .TableClose("_HardLink")
6322 ENDIF
6323
6324 ENDWITH
6325
6326 SELECT(lnOldSelect)
6327 RETURN llRetVal
6328 ENDPROC
6329
6330 *=== TR 1028744 19-FEB-2008 VKK
6331
6332 **********************************************************************************************
6333 *--- TR 1039757 18-Aug-2009 Goutam.
6334
6335 PROCEDURE MoveNZtoRZ
6336 LOCAL llRetVal, lnOldSelect, lcSql, lcFilter
6337
6338 lnOldSelect = SELECT()
6339 .cNZLocalCursor = GetUniqueFileName()
6340
6341 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
6342 lcFilter = STRTRAN(lcFilter,"H.","TH.")
6343 lcFilter = STRTRAN(lcFilter,"Where","")
6344
6345 lcSql = "Select td.pkey from zzeipctd td join zzeipcth th on th.pkey = td.fkey " + ;
6346 "where td.qualifier = 'NZ' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
6347 llRetVal = v_sqlexec(lcSQL, .cNZLocalCursor)
6348
6349 lcSql = "update td set td.qualifier = 'RZ' " + ;
6350 "from zzeipctd td join zzeipcth th on th.pkey = td.fkey where td.qualifier = 'NZ' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
6351
6352 llRetVal = llRetVal and v_sqlexec(lcSQL)
6353
6354 SELECT(lnOldSelect)
6355 RETURN llRetVal
6356 ENDPROC
6357
6358 PROCEDURE RevertFromRZtoNZ
6359 LOCAL llRetVal, lnOldSelect, lcSql
6360
6361 lnOldSelect = SELECT()
6362
6363 IF .GenerateSQLTempTable(.cNZLocalCursor) AND .PopulateSQLTempTable(.cNZLocalCursor) AND !EMPTY(.cSQLTempTable)
6364 lcSQL = "update td set td.qualifier = 'NZ' from zzeipctd td join " + .cSQLTempTable + " tmp " + ;
6365 " on tmp.pkey = td.pkey where td.qualifier = 'RZ'"
6366
6367 llRetVal = v_sqlexec(lcSQL)
6368
6369 ENDIF
6370
6371 .tableclose(.cNZLocalCursor)
6372
6373 SELECT(lnOldSelect)
6374 RETURN llRetVal
6375 ENDPROC
6376
6377 PROCEDURE AddNewOrderForNZ
6378
6379 LOCAL llRetVal, lnOldSelect, lcipcth_key, lcSql, lcipcth_New, lcipctd_New, lcFilter, lcSubSql, lcUser_ID, ;
6380 ltLast_mod, lnHCount, lnDCount, lcSQLTempTable, lcInsertSql, lcDtlInsertSql, lcDtlSQL, lcUpdateSql, ;
6381 lcUpdateDtlSql, lcipcPkey_New, lcipcMain_New, lcipcOrder_New, lnTotalOrder
6382
6383 *--- TR 1048865 03-May-2011 Goutam
6384 LOCAL lcipcOrder_Exists
6385 *=== TR 1048865 03-May-2011 Goutam
6386
6387 llRetVal = true
6388 lnOldSelect = SELECT()
6389 lcUser_ID = EDI_USER
6390 ltLast_mod = DATETIME()
6391 lnTotalOrder = 1
6392
6393 IF NOT USED(.cNZLocalCursor) OR RECCOUNT(.cNZLocalCursor) = 0
6394 .tableclose(.cNZLocalCursor)
6395 RETURN llRetVal
6396 ENDIF
6397
6398 llRetVal = llRetVal and .RevertFromRZtoNZ()
6399
6400 *--- TechRec 1073669 02-Oct-2013 GSternik ---
6401 *-- This all should not be so complicated:
6402 *-- The transaction maintenance table already has ALL the matching and the new order lines.
6403 *-- the Matching ones have Ord_Num > 0, and the New ones : 0 (as you can guess)
6404 *-- So, for the matching ones we just need to replace 'NZ' with 'RZ'
6405 *-- for the new ones: replace 'NZ' with AI
6406 *-- after that we have to find the Order Stores/SKUs/Lines which are not specified in the Transaction Maint.
6407 *-- and add them to it with 'DI' qualifier.
6408 *-- the "missing ones" (in zzoordrh/d) search criteria is:
6409 *-- Same Customer, PO_Num, and SKU/Bkt exists for the different store in TM but not for SO Store.
6410 #DEFINE GS_1073669
6411 *--==============================================
6412 #IFNDEF GS_1073669 && Per Yuri's request made the TR 1073669 changes easily undoable
6413 *--==============================================
6414
6415 lcipcth_New = "#Zzeipcth_newNZ" + SYS(2015)
6416 lcipctd_New = "#Zzeipctd_newNZ" + SYS(2015)
6417 lcipcMain_New = "#ZzeipcMain_newNZ" + SYS(2015)
6418 lcipcPkey_New = "#ZzeipcPkey_newNZ" + SYS(2015)
6419 lcipcOrder_New = "#ZzeipcOrder_newNZ" + SYS(2015)
6420
6421 *--- TR 1048865 03-May-2011 Goutam
6422 lcipcOrder_Exists = "#ZzeipcOrder_ExistsNZ" + SYS(2015)
6423 *=== TR 1048865 03-May-2011 Goutam
6424
6425 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
6426 lcFilter = STRTRAN(lcFilter,"H.","TH.")
6427 lcFilter = STRTRAN(lcFilter,"Where","")
6428
6429 *-- GS: The "query" below tries to get the Trx Details with Stores where SOD already exists, just to change NZ to RZ later.
6430 *-- lcipcOrder_Exists is used only for this purpose, so there is no need to create it.
6431 *--- TR 1048865 03-May-2011 Goutam
6432 lcSql = " select distinct tmp.pkey, tmpd.pkey as dtlPkey, t.ord_num, t.store, t.edi_store, tmpd.fkey " + ;
6433 " into " + lcipcOrder_Exists + ;
6434 " from " + ;
6435 " (select h.customer, h.po_num, h.ord_num, h.store, st.edi_store, d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.Size_Bk, d.line_seq, d.total_qty " + ;
6436 " from zvoordrdv d join zzoordrh h on h.pkey = d.fkey " + ;
6437 " join zzxstorr st on st.customer = h.customer and st.store = h.store where " + ;
6438 " exists(select 1 from zzeipcth th join zzeipctd td on td.fkey = th.pkey where" + ;
6439 " td.division = d.division and td.style = d.style and td.color_code = d.color_code and " + ;
6440 " td.lbl_code = d.lbl_code and td.dimension = d.dimension and td.sizebucket = d.Size_Bk and h.po_num = th.po_num and h.customer = th.customer " + ;
6441 " and td.qualifier = 'NZ' and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter) + ;
6442 " and h.ord_status = 'O')) t" + ;
6443 " join zzeipcth tmp " + ;
6444 " join zzeipctd tmpd on tmpd.fkey = tmp.pkey " + ;
6445 " on t.division = tmp.division and t.store = tmp.store and t.customer = tmp.customer and t.po_num = tmp.po_num " + ;
6446 " and t.style = tmpd.style and t.color_code = tmpd.color_code and t.lbl_code = tmpd.lbl_code and t.dimension = tmpd.dimension and t.Size_Bk = tmpd.sizebucket "
6447
6448 llRetVal = llRetVal and v_sqlexec(lcSQL)
6449 *-- This "query" tries to get the SOD/SOH keys with matching Trx Details, but Store(!) (see subselect "t"),
6450 *-- and then joins them to TranD/H
6451 *-- the first part of this SQL is the same as the 1st one, but there is no:
6452 *-- " and t.store = tmp.store" match between the subquery "t" and zzeipcth, these recors excluded by the last EXISTS subselect.
6453 *-- Because my first SQL already marked these records as RZ, they will be excluded by default.
6454
6455 *-- the result is the catesian join between Ord_num, Store, Edi_Store from SOH and the coresponding zzeipctd Keys (by Customer,PO_Num,SKU/UPC)
6456 *-- I.E. if for the same Customer/PO/UPC my new zzeipcth/d data has 3 details with PKeys 1,2,3 for stores '01','04','05'
6457 *-- and SOH have stores '01','02','03' (ord nums 101,102,103) the result will be 4 records:
6458 *-- 2, 102, '02'; 3, 102, '02'; 2, 103, '03'; 3, 103, '03';
6459
6460 *=== TR 1048865 03-May-2011 Goutam
6461
6462 * --- TR 1048874 9/23/10 CM --- Added tmpd.fkey
6463 *--- TR 1048865 26-Apr-2011 Goutam. Removed zzoordrd from the following sql and replaced with zvoordrdv and additional join with sizebucket = Size_Bk
6464 lcSql = " select distinct tmp.pkey, tmpd.pkey as dtlPkey, t.ord_num, t.store, t.edi_store, tmpd.fkey " + ;
6465 " into " + lcipcMain_New + ;
6466 " from " + ;
6467 " (select h.customer, h.po_num, h.ord_num, h.store, st.edi_store, d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.Size_Bk, d.line_seq, d.total_qty " + ;
6468 " from zvoordrdv d join zzoordrh h on h.pkey = d.fkey " + ;
6469 " join zzxstorr st on st.customer = h.customer and st.store = h.store where " + ;
6470 " exists(select 1 from zzeipcth th join zzeipctd td on td.fkey = th.pkey where" + ;
6471 " td.division = d.division and td.style = d.style and td.color_code = d.color_code and " + ;
6472 " td.lbl_code = d.lbl_code and td.dimension = d.dimension and td.sizebucket = d.Size_Bk and h.po_num = th.po_num and h.customer = th.customer " + ;
6473 " and td.qualifier = 'NZ' and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter) + ;
6474 " and h.ord_status = 'O')) t" + ;
6475 " join zzeipcth tmp " + ;
6476 " join zzeipctd tmpd on tmpd.fkey = tmp.pkey " + ;
6477 " on t.division = tmp.division and t.customer = tmp.customer and t.po_num = tmp.po_num " + ;
6478 " and t.style = tmpd.style and t.color_code = tmpd.color_code and t.lbl_code = tmpd.lbl_code and t.dimension = tmpd.dimension and t.Size_Bk = tmpd.sizebucket " + ;
6479 " where not exists(select 1 from zzeipcth th join zzeipctd td on td.fkey = th.pkey where " + ;
6480 " td.division = t.division and td.style = t.style and td.color_code = t.color_code and " + ;
6481 " td.lbl_code = t.lbl_code and td.dimension = t.dimension and td.sizebucket = t.Size_Bk and th.po_num = t.po_num and th.customer = t.customer " + ;
6482 " and th.store = t.store and th.edi_store = t.edi_store and td.qualifier = 'NZ' and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter) + ")"
6483
6484 llRetVal = llRetVal and v_sqlexec(lcSQL)
6485
6486
6487 *-- GS: this query enumerates the existing orders with no zzeipctd/h match
6488 lcSql = " select distinct counter = IDENTITY(int,1,1), ord_num, store, edi_store " + ;
6489 " into " + lcipcOrder_New + " from " + lcipcMain_New + " select @@Rowcount as TotalOrder"
6490 llRetVal = llRetVal and v_sqlexec(lcSQL, "__TotalOrderCursor")
6491
6492 IF llRetVal
6493 lnTotalOrder = IIF(__TotalOrderCursor.TotalOrder = 0, 1, __TotalOrderCursor.TotalOrder)
6494 ENDIF
6495
6496 *-- GS: this query enumerates the new orders(stores) from zzeipctH/D with no SOH match which can be covered by the SOH/SOD orders we do not need anymore
6497
6498 * --- TR 1048874 9/23/10 CM --- Added fkey
6499 * By adding fkey, this query can be used to cover more angles when we determine whether we need to
6500 * add details to PO's or delete them.
6501*!* lcSql = " select distinct top " + ALLTRIM(STR(lnTotalOrder)) + " counter = IDENTITY(int,1,1), pkey, dtlPkey " + ;
6502*!* " into " + lcipcPkey_New + " from " + lcipcMain_New
6503 lcSql = " select distinct top " + ALLTRIM(STR(lnTotalOrder)) + " counter = IDENTITY(int,1,1), pkey, dtlPkey, fkey " + ;
6504 " into " + lcipcPkey_New + " from " + lcipcMain_New
6505 llRetVal = llRetVal and v_sqlexec(lcSQL)
6506 * === TR 1048874 9/23/10 CM
6507
6508 *-- GS: Trx Headers to match to the existing non-matching orders (query simplified):
6509 *lcSubSql = "select 1 from " + lcipcPkey_New + " where pkey = h.pkey"
6510 *lcSQL = "SELECT * into " + lcipcth_New + " FROM zzeipcth h where exists(" + lcSubSql + ") "
6511 lcSQL = "SELECT * into " + lcipcth_New + " FROM zzeipcth h where exists (select 1 from " + lcipcPkey_New + " where pkey = h.pkey) "
6512
6513 llRetVal = llRetVal and v_sqlexec(lcSQL)
6514
6515
6516 *-- GS: WTF is this????
6517 * --- TR 1048874 9/23/10 CM --- We could be deleting more than 1 detail at a time for
6518 * the same po, before the process was not able to handle this.
6519*!* lcSubSql = "select 1 from " + lcipcPkey_New + " where dtlPkey = d.pkey"
6520 lcSubSql = "Select * from " + lcipcPkey_New + " where fkey = d.fkey"
6521 * === TR 1048874 9/23/10 CM
6522
6523 *--- TR 1048865 21-Apr-2011 Goutam
6524 *lcSQL = "SELECT * into " + lcipctd_New + " FROM zzeipctd d where exists(" + lcSubSql + ") "
6525 lcSQL = "SELECT * into " + lcipctd_New + " FROM zzeipctd d where exists(" + lcSubSql + ") " + ;
6526 " and pkey = (select top 1 pkey from zzeipctd td where td.FKEY = d.FKEY)"
6527 *=== TR 1048865 21-Apr-2011 Goutam
6528
6529 *-- GS: in other words:
6530 lcSQL = ;
6531 "select *"+;
6532 " into " + lcipctd_New +;
6533 " from zzeipctd d"+;
6534 " where exists ( "+;
6535 "select *"+;
6536 " from " + lcipcPkey_New +;
6537 " where fkey = d.pkey) "+;
6538 " and pkey = ("+;
6539 "select top 1 pkey"+;
6540 " from zzeipctd td"+;
6541 " where td.FKEY = d.FKEY)"
6542
6543 llRetVal = llRetVal and v_sqlexec(lcSQL)
6544
6545 lcSQL = "UPDATE h SET store = oh.store, edi_store = oh.edi_store, ord_num = oh.ord_num " + ;
6546 ", User_ID = " + sqlformatchar(lcUser_ID) + ", Last_mod = " + sqlformatts(ltLast_mod) + ;
6547 " FROM " + lcipcth_New + " h join " + lcipcPkey_New + " tmp " + ;
6548 " on tmp.pkey = h.pkey join " + lcipcOrder_New + " oh on oh.counter=tmp.counter"
6549
6550 llRetVal = llRetVal and v_sqlexec(lcSQL)
6551
6552 *--- TR 1048865 21-Apr-2011 Goutam. Deleted below
6553*!* lcSQL = "Select pkey, pkey-pkey as newPkey, (select COUNT(*) from " + lcipctd_New + ") as Rec_Count from " + lcipctd_New
6554*!* llRetVal = llRetVal and v_sqlexec(lcSQL, '__tmpDPkeyUpdate')
6555
6556*!* lcSQL = "Select pkey, pkey-pkey as newPkey, (select COUNT(*) from " + lcipcth_New + ") as Rec_Count from " + lcipcth_New
6557*!* llRetVal = llRetVal and v_sqlexec(lcSQL, '__tmpHPkeyUpdate')
6558
6559*!* IF llRetVal
6560*!* lnHCount = __tmpHPkeyUpdate.Rec_Count
6561*!* lnDCount = __tmpDPkeyUpdate.Rec_Count
6562*!* ENDIF
6563
6564
6565*!* IF llRetVal AND lnHCount > 0 AND lnDCount > 0
6566
6567*!* lnMaxNumber = v_nextPkey("zzeipcth",lnHCount)
6568*!* SELECT __tmpHPkeyUpdate
6569*!* replace ALL newPkey WITH (lnMaxNumber-lnHCount+RECNO()) IN __tmpHPkeyUpdate
6570*!*
6571*!* lnMaxNumber = v_nextPkey("zzeipctd",lnDCount)
6572*!* SELECT __tmpDPkeyUpdate
6573*!* replace ALL newPkey WITH (lnMaxNumber-lnDCount+RECNO()) IN __tmpDPkeyUpdate
6574
6575*!* .cSQLTempTable=""
6576*!* llRetVal = llRetVal and ;
6577*!* .GenerateSQLTempTable('__tmpHPkeyUpdate') AND .PopulateSQLTempTable('__tmpHPkeyUpdate') AND !EMPTY(.cSQLTempTable)
6578*!* IF llRetVal
6579*!* lcSQLTempTable = .cSQLTempTable
6580*!* lcSQL = "Update th set th.pkey = tmp.newPkey " + ;
6581*!* " From " + lcipcth_New + " th join " + lcSQLTempTable + " tmp " + ;
6582*!* " on tmp.pkey = th.pkey"
6583*!*
6584*!* lcInsertSql = "insert into zzeipcth select * from " + lcipcth_New
6585
6586*!* ENDIF
6587
6588*!* .cSQLTempTable=""
6589*!* llRetVal = llRetVal and ;
6590*!* .GenerateSQLTempTable('__tmpDPkeyUpdate') AND .PopulateSQLTempTable('__tmpDPkeyUpdate') AND !EMPTY(.cSQLTempTable)
6591*!* IF llRetVal
6592*!* lcDtlSQL = "Update td set td.pkey = tmp.newPkey " + ;
6593*!* " From " + lcipctd_New + " td join " + .cSQLTempTable + " tmp " + ;
6594*!* " on tmp.pkey = td.pkey"
6595*!*
6596*!* lcUpdateSql = "update td set td.fkey = tmp.newpkey, td.qualifier = 'DI' " + ;
6597*!* " from " + lcSQLTempTable + " tmp " + ;
6598*!* " join " + lcipctd_New + " td " + ;
6599*!* " on td.fkey = tmp.pkey "
6600
6601*!* lcDtlInsertSql = "insert into zzeipctd select * from " + lcipctd_New
6602
6603*!* lcSubSql = "Select 1 from zzeipcth th where pkey = td.fkey and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
6604*!* lcUpdateDtlSql = "Update td set td.qualifier = 'RZ' " + ;
6605*!* " From zzeipctd td where td.qualifier = 'NZ' " + ;
6606*!* " and exists( " + lcSubSql + ")"
6607*!* ENDIF
6608
6609 IF llRetVal
6610
6611 lcSubSql = "Select 1 from zzeipcth th where pkey = td.fkey and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
6612 lcUpdateSql = "Update td set td.qualifier = 'RZ' " + ;
6613 " From zzeipctd td where td.qualifier = 'NZ' " + ;
6614 " and exists(select 1 from " + lcipcOrder_Exists + " where dtlpkey = td.pkey) " + ;
6615 " and exists( " + lcSubSql + ")"
6616
6617 lcSubSql = "Select 1 from zzeipcth th where pkey = td.fkey and th.errs_flg_h <> 'Y' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
6618 lcUpdateDtlSql = "Update td set td.qualifier = 'AI' " + ;
6619 " From zzeipctd td where td.qualifier = 'NZ' " + ;
6620 " and exists( " + lcSubSql + ")"
6621 *=== TR 1048865 21-Apr-2011 Goutam. Added above and Deleted before added above
6622
6623 IF llRetVal
6624
6625 llBeganTransaction = THIS.BeginTransaction()
6626
6627 *--- TechRec 1073669 02-Oct-2013 GSternik : What if the transaction alredy started before????
6628 IF llBeganTransaction
6629
6630 *--- TR 1048865 13-Apr-2011 Goutam
6631*!* llRetVal = llRetVal and v_sqlexec(lcSQL)
6632*!* llRetVal = llRetVal and v_sqlexec(lcDtlSQL)
6633*!* llRetVal = llRetVal and v_sqlexec(lcUpdateSql)
6634*!* llRetVal = llRetVal and v_sqlexec(lcInsertSql)
6635*!* llRetVal = llRetVal and v_sqlexec(lcDtlInsertSql)
6636
6637 llRetVal = llRetVal and v_sqlexec(lcUpdateSql)
6638 llRetVal = llRetVal and v_sqlexec(lcUpdateDtlSql)
6639 llRetVal = llRetVal and .InsertExtraRecordFromSO(lcFilter, lcipcOrder_New, lcipcth_New, lcipctd_New)
6640 *=== TR 1048865 13-Apr-2011 Goutam
6641
6642 IF llRetVal
6643 THIS.EndTransaction()
6644 ELSE
6645 THIS.RollbackTransaction()
6646 ENDIF
6647 ENDIF
6648 ENDIF
6649
6650 ENDIF
6651
6652 *--- TechRec 1073669 04-Nov-2013 GSternik ---
6653 *-- Per Yuri's request made the TR 1073669 Changes easily undoable
6654 *--==============================================
6655 #ELSE
6656 *--==============================================
6657
6658 lcFilter = Iif(Empty(this.cFilterCriteria),"",This.cFilterCriteria)
6659 *-- Not sure if this is needed:
6660 lcFilter = StrTran(lcFilter, "where", "", 1, 1, 1)
6661
6662
6663 *-- Let's replace 'NZ' with 'RZ' for the existing ones, and replace 'NZ' with 'AI' for the new ones
6664 lcSQL = ;
6665 "update d"+;
6666 " set d.Qualifier = case"+;
6667 " when h.Ord_Num > 0 then 'RZ'"+;
6668 " else 'AI'"+;
6669 " end"+;
6670 " from zzeipctd d"+;
6671 " join zzeipcth h"+;
6672 " on h.PKey = d.FKey"+;
6673 " where d.Qualifier = 'NZ'"+;
6674 " and h.Errs_Flg_H < 'Y' " +;
6675 Iif(Empty(lcFilter), "", "and " + lcFilter)
6676
6677
6678 Local lcTmpDtl, lcTmpHdr
6679 lcTmpDtl = SubStr(SYS(2015), 6)
6680 lcTmpHdr = Iif(Version(2)=2,"##","#") + "DI_HDR_" + lcTmpDtl
6681 lcTmpDtl = Iif(Version(2)=2,"##","#") + "DI_DTL_" + lcTmpDtl
6682
6683 *-- Let's find the missing UPC/SKUs:
6684 &&--- TechRec 1073591 16-Feb-2014 TShenbagavalli added noshow existing issue fixed ===
6685 Text to lcDtlSql Flags 1 noshow
6686; with m as (
6687select b.Size_Num as SizeBucket
6688 , Size01_Qty*Sz01+Size02_Qty*Sz02+Size03_Qty*Sz03+Size04_Qty*Sz04
6689 +Size05_Qty*Sz05+Size06_Qty*Sz06+Size07_Qty*Sz07+Size08_Qty*Sz08
6690 +Size09_Qty*Sz09+Size10_Qty*Sz10+Size11_Qty*Sz11+Size12_Qty*Sz12
6691 +Size13_Qty*Sz13+Size14_Qty*Sz14+Size15_Qty*Sz15+Size16_Qty*Sz16
6692 +Size17_Qty*Sz17+Size18_Qty*Sz18+Size19_Qty*Sz19+Size20_Qty*Sz20
6693 +Size21_Qty*Sz21+Size22_Qty*Sz22+Size23_Qty*Sz23+Size24_Qty*Sz24 as Qty_Change
6694 , od.*
6695 from zzoordrh oh
6696 join zzoordrd od
6697 on od.FKey = oh.PKey
6698 join zzxBuckt b
6699 on Size01_Qty*Sz01+Size02_Qty*Sz02+Size03_Qty*Sz03+Size04_Qty*Sz04
6700 +Size05_Qty*Sz05+Size06_Qty*Sz06+Size07_Qty*Sz07+Size08_Qty*Sz08
6701 +Size09_Qty*Sz09+Size10_Qty*Sz10+Size11_Qty*Sz11+Size12_Qty*Sz12
6702 +Size13_Qty*Sz13+Size14_Qty*Sz14+Size15_Qty*Sz15+Size16_Qty*Sz16
6703 +Size17_Qty*Sz17+Size18_Qty*Sz18+Size19_Qty*Sz19+Size20_Qty*Sz20
6704 +Size21_Qty*Sz21+Size22_Qty*Sz22+Size23_Qty*Sz23+Size24_Qty*Sz24 > 0
6705 where od.Line_Status = 'O'
6706 and exists (
6707select NULL
6708 from zzeipcth h
6709 join zzeipctd d
6710 on d.FKey = h.PKey
6711 where h.Customer = oh.Customer
6712 and h.PO_Num = oh.PO_Num
6713 and d.Qualifier = 'NZ'
6714 --- No Store included in this lookup
6715 and d.Division = od.Division
6716 and d.Style = od.Style
6717 and d.Color_Code = od.Color_Code
6718 and d.Lbl_Code = od.Lbl_Code
6719 and d.Dimension = od.Dimension
6720 and d.SizeBucket = b.Size_Num
6721 --- Filter
6722 )
6723 and not exists (
6724 select NULL
6725 from zzeipcth h
6726 join zzeipctd d
6727 on d.FKey = h.PKey
6728 where h.Customer = oh.Customer
6729 and h.PO_Num = oh.PO_Num
6730 and h.Store = oh.Store -- here is the difference
6731 and d.Qualifier = 'NZ'
6732 and d.Division = od.Division
6733 and d.Style = od.Style
6734 and d.Color_Code = od.Color_Code
6735 and d.Lbl_Code = od.Lbl_Code
6736 and d.Dimension = od.Dimension
6737 and d.SizeBucket = b.Size_Num
6738 --- Filter
6739 )
6740)
6741select UPC, u.Size_Desc, 'DI' AS Qualifier, m.*
6742 ---- into
6743 from m
6744 left join zveupcnr u
6745 on u.Division = m.Division
6746 and u.Style = m.Style
6747 and u.Color_Code = m.Color_Code
6748 and u.Lbl_Code = m.Lbl_Code
6749 and u.Dimension = m.Dimension
6750 and u.SizeBucket = m.SizeBucket
6751;
6752select @@RowCount as Cnt
6753EndText
6754
6755 lcDtlSql = StrTran(lcDtlSql, "---- into", "into " + lcTmpDtl)
6756
6757 If !Empty(lcFilter)
6758 lcDtlSql = StrTran(lcDtlSql, "--- Filter", "and " + lcFilter)
6759 EndIf
6760
6761 *--- TechRec 1075895 17-Mar-2014 vkrishnamurthy ---
6762 lcFieldList = this.oApplyPoChange.GetSOFieldListWithoutUDF("oh.", "zzoordrh")
6763 *=== TechRec 1075895 17-Mar-2014 vkrishnamurthy ===
6764
6765 *-- Let's find the missing Headers for the found UPC/SKUs:
6766 &&--- TechRec 1075895 17-Mar-2014 vkrishnamurthy === added lcFieldList
6767 lcHdrSql =;
6768 "select "+ lcFieldList +", EDI_Store "+;
6769 " into " + lcTmpHdr +;
6770 " from zzoordrh oh"+;
6771 " join zzxStorR s" +;
6772 " on s.Customer = oh.Customer" +;
6773 " and s.Store = oh.Store" +;
6774 " where exists ( "+;
6775 "select NULL"+;
6776 " from " + lcTmpDtl + " d"+;
6777 " where d.FKey = oh.PKey)"+;
6778 " and not exists ( "+;
6779 "select NULL"+;
6780 " from zzeipcth h"+;
6781 " where h.Customer = oh.Customer"+;
6782 " and h.PO_Num = oh.PO_Num"+;
6783 " and h.Ord_num = oh.Ord_num)" +;
6784 "; select @@RowCount as Cnt"
6785
6786 Local lnDtlDICount, lnHdrDICount
6787 This.oLog.LogEntry("Looking for SKU/Buckets existing in both 860 and Open Orders(OO) for the Stores in OO but not in 860.")
6788 llRetVal = llRetVal and v_SqlExec(lcDtlSql, "RowCount")
6789 If llRetVal
6790 lnDtlDICount = RowCount.Cnt
6791 If lnDtlDICount > 0
6792 This.oLog.LogEntry("Found " + Transform(lnDtlDICount) + " open orders SKU/Buckets to delete.")
6793 Else
6794 This.oLog.LogEntry("Not found any open orders SKU/Buckets to delete.")
6795 EndIf
6796 Else
6797 lnDtlDICount = 0
6798 EndIf
6799
6800 lnHdrDICount = 0
6801 If lnDtlDICount > 0
6802 llRetVal = llRetVal and v_SqlExec(lcHdrSql, "RowCount")
6803 If llRetVal
6804 lnHdrDICount = RowCount.Cnt
6805 This.oLog.LogEntry("Found " + Transform(RowCount.Cnt) + " open order headers to delete.")
6806 EndIf
6807 EndIf
6808
6809 If llRetVal and lnDtlDICount > 0
6810 WITH this
6811
6812 *------ Let's Use the SQL String Builder ------*
6813 If lnHdrDICount > 0
6814 .oGenStr.SB_Reset()
6815
6816 .oGenStr.cSB_Target = "ZZEIPCTH"
6817 .oGenStr.cSB_Source = lcTmpHdr
6818 .oGenStr.cSB_SourceAlias = "th"
6819
6820 llRetVal = .oGenStr.SB_GenerateSQLInsertString()
6821
6822 If llRetVal
6823 lcInsertSql = .oGenStr.cSQLString
6824 Else
6825 lcMessage = "Failed to generate SQL string for 860(i) header NZ Qualifier. Cannot continue."
6826 .oLog.LogEntry(lcMessage)
6827 EndIf
6828 EndIf
6829
6830 If llRetVal
6831 .oGenStr.SB_Reset()
6832
6833 .oGenStr.cSB_Target = "ZZEIPCTD"
6834 .oGenStr.cSB_Source = lcTmpDtl
6835 .oGenStr.cSB_SourceAlias = "td"
6836
6837 *-- Maybe Ord_Num would be enough here?
6838 *-- the LEFT join to ZZEIPCTH is used to ensure that the BC_KeySet (new PKeys) is
6839 *-- properly generated for the details (ZZEIPCTD) BEFORE the new headers inserted (if any)!
6840 .oGenStr.cSB_FROMExpandedString = ;
6841 " join zzoordrd d on d.PKey = td.PKey" +;
6842 " join zzoordrh h on h.PKey = td.FKey" +;
6843 " LEFT join zzeipcth th on th.Ord_Num = h.Ord_Num and th.PO_Num = h.PO_Num and th.Store = h.Store"
6844
6845 .oGenStr.SB_SetLiteralFieldValue("fkey","th.PKey")
6846
6847 llRetVal = .oGenStr.SB_GenerateSQLInsertString()
6848
6849 If llRetVal
6850 lcDtlInsertSql = .oGenStr.cSQLString
6851 Else
6852 lcMessage = "Failed to generate SQL string for 860(i) detail NZ Qualifier. Cannot continue."
6853 .oLog.LogEntry(lcMessage)
6854 EndIf
6855 EndIf && llRetVal
6856 EndWith
6857
6858
6859 If llRetVal
6860 If TxnLevel() > 0
6861 llBeganTransaction = .F.
6862 Else
6863 llBeganTransaction = This.BeginTransaction()
6864 If !llBeganTransaction
6865 llRetVal = .F.
6866 EndIf
6867 EndIf
6868 EndIf
6869
6870 If llRetVal
6871 *-- replace 'NZ' with 'RZ' or 'AI'
6872 llRetVal = v_SqlExec(lcSQL)
6873 If lnHdrDICount > 0
6874 *-- Insert the headers to delete
6875 llRetVal = llRetVal and v_SqlExec(lcInsertSql )
6876 EndIf
6877 *-- Insert the Details to delete ('DI')
6878 llRetVal = llRetVal and v_SqlExec(lcDtlInsertSql)
6879 EndIf && llRetVal: Trx Started
6880
6881 If llBeganTransaction
6882 If llRetVal
6883 This.EndTransaction()
6884 ELSE
6885 This.RollbackTransaction()
6886 EndIf
6887 EndIf
6888
6889 EndIf && Found detal(s) for DI (lnDtlDICount > 0)
6890
6891 Use in Select("RowCount")
6892
6893 *-- Per Yuri's request made the TR 1073669 Changes easily undoable
6894 *--==============================================
6895 #ENDIF
6896 *--==============================================
6897 *=== TechRec 1073669 04-Nov-2013 GSternik ===
6898
6899
6900 IF llRetVal
6901 *-- GS what is this for?:
6902 REQUERY('Vzzeipcth_ipcproc')
6903 SELECT ('Vzzeipcth_ipcproc')
6904 SCAN
6905 SCATTER NAME loEiPCth MEMO
6906 SELECT tceipcTH
6907 IF SEEK(loEiPCth.pkey,'tceipcTH','PKEY')
6908 GATHER NAME loEiPCth MEMO
6909 ELSE
6910 APPEND BLANK
6911 GATHER NAME loEiPCth MEMO
6912 ENDIF
6913 ENDSCAN
6914
6915 REQUERY('Vzzeipctd_ipcproc')
6916 SELECT Vzzeipctd_ipcproc
6917 SCAN
6918 SCATTER NAME loEiPCtd MEMO
6919 SELECT tceipcTD
6920 IF SEEK(loEiPCtd.pkey,'tceipcTD','PKEY')
6921 GATHER NAME loEiPCtd MEMO
6922 ELSE
6923 APPEND BLANK
6924 GATHER NAME loEiPCtd MEMO
6925 ENDIF
6926
6927 ENDSCAN
6928 ENDIF
6929
6930 #IFDEF GS_1073669
6931 .dropTempTable(lcTmpDtl, .T.)
6932 .dropTempTable(lcTmpHdr, .T.)
6933 #ELSE
6934 .dropTempTable(lcipcth_New, true)
6935 .dropTempTable(lcipctd_New, true)
6936 .dropTempTable(lcipcPkey_New, true)
6937 .dropTempTable(lcipcMain_New, true)
6938 .dropTempTable(lcipcOrder_New, true)
6939
6940 *--- TR 1048865 03-May-2011 Goutam
6941 .dropTempTable(lcipcOrder_Exists, true)
6942 *--- TR 1048865 03-May-2011 Goutam
6943
6944 .tableclose("__tmpDPkeyUpdate")
6945 .tableclose("__tmpHPkeyUpdate")
6946 .tableclose("__TotalOrderCursor")
6947 #ENDIF
6948
6949 SELECT(lnOldSelect)
6950 RETURN llRetVal
6951 ENDPROC
6952 *=== TR 1039757 18-Aug-2009 Goutam.
6953
6954* --- TR 1047609 7/7/10 CM
6955************************************************************************************
6956* Resolve BC SKU from SLN records and create customer style data.
6957************************************************************************************
6958 Procedure ResolveBCSkuFromSLN
6959 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
6960 Lparameters pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE
6961
6962 Local llRetVal, lnOldSelect, lcDivision, lcStyle, lcColor_Code, ;
6963 lcLbl_Code, lcDimension, loEiPCTS, lcErrs_Msg, lcOldCust, lcOldUPC
6964
6965 lnOldSelect = Select()
6966
6967 lcErrs_Msg = ""
6968 lcDivision = ""
6969
6970 This.cSQLTempTable = ""
6971 If .GenerateSQLTempTable(pceipcTS) AND .PopulateSQLTempTable(pceipcTS) AND !Empty(.cSQLTempTable)
6972 This.cTmpSLNTable = .cSQLTempTable
6973 Endif
6974
6975 *-- #1 Resolve SLN SKUs
6976 *--- TR 1048865 27-Dec-2010 Goutam, Added h.cr_pkey
6977 select h.Customer;
6978 , s.FKey;
6979 , s.SLN_UPC as UPC;
6980 , s.SLN_SKU as SKU ;
6981 , h.department ;
6982 , h.store ;
6983 , s.PKey;
6984 , .F. as SLN_Error;
6985 , Empty(d.SizeBucket) as Unresolved;
6986 , s.Division;
6987 , s.Style;
6988 , s.Color_Code;
6989 , s.SizeBucket;
6990 , d.Pkey as dtlPkey;
6991 , 'N' as IsPPK;
6992 , SPACE(5) as ppk_code;
6993 , h.cr_pkey ;
6994 from (pceipcTH) h;
6995 join (pceipcTD) d ;
6996 on d.FKey = h.PKey;
6997 join (pceipcTS) s ;
6998 on s.FKey = d.PKey ;
6999 where !Empty(h.Customer) ;
7000 order by 1, 2;
7001 into Cursor tmpCurs ReadWrite
7002
7003 Select tmpCurs
7004 If This.lUserInterface
7005 This.UpdateThermoCaption("Validating SLN UPC(s)...")
7006 This.InitThermo(RecCount())
7007 EndIf
7008
7009 lcOldCust = ""
7010 lcOldUPC = ""
7011 lcOldItem = ''
7012 Local lcSku_resolv, lcOldSku_resolv
7013 lcSku_resolv = ""
7014 *=
7015
7016 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
7017 If This.lUserInterface
7018 * Advance progress bar, if we're using one.
7019 This.AdvanceThermo(RecNo())
7020 EndIf
7021 IF !EMPTY(tmpCurs.UPC)
7022
7023 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
7024 lcErrs_Msg = ""
7025 lcOldCust = tmpCurs.Customer
7026 lcOldUPC = tmpCurs.UPC
7027
7028 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
7029 lcDivision = tmpCstdr.division
7030 lcStyle = tmpCstdr.Style
7031 lcColor_Code = tmpCstdr.Color_Code
7032 lcLbl_Code = tmpCstdr.Lbl_Code
7033 lcDimension = tmpCstdr.Dimension
7034 lnSizeBucket = tmpCstdr.Size_Bk
7035 lnSize_Desc = tmpCstdr.Size_Desc
7036 Else
7037 lcErrs_Msg = ""
7038 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7039 lcDivision = tmpUpcnr.Division
7040 lcStyle = tmpUpcnr.Style
7041 lcColor_Code = tmpUpcnr.Color_Code
7042 lcLbl_Code = tmpUpcnr.Lbl_Code
7043 lcDimension = tmpUpcnr.Dimension
7044 lnSizeBucket = tmpUpcnr.SizeBucket
7045 lnSize_Desc = tmpUpcnr.Size_Desc
7046 Else
7047 lcErrs_Msg = lcErrs_Msg + CRLF
7048 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7049 lnSizeBucket = 0
7050 Endif
7051 Endif
7052 Endif && level break
7053 *- Added resolution on SKU
7054 ENDIF && TmpCurs.UPC
7055 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
7056 *- but UPC resolution failed.
7057 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
7058
7059 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
7060 lcErrs_Msg = ""
7061 lcOldCust = tmpCurs.customer
7062 lcOldItem = tmpCurs.sku
7063 If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
7064 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
7065
7066 lcDivision = tmpCstdr.division
7067 lcStyle = tmpCstdr.Style
7068 lcColor_code = tmpCstdr.color_code
7069 lcLbl_code = tmpCstdr.lbl_code
7070 lcDimension = tmpCstdr.Dimension
7071 lnSizeBucket = tmpCstdr.size_bk
7072 lnSize_desc = tmpCstdr.size_desc
7073 Else
7074 lcErrs_Msg = lcErrs_Msg + CRLF
7075 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7076 Store 0 To lnSizeBucket
7077 Endif
7078
7079 ENDIF
7080 ENDIF
7081
7082 Select (pceipcTS)
7083 =Seek(tmpCurs.PKey, pceipcTS, "PKey")
7084
7085 Scatter Name loEiPCTS Memo
7086 If !Empty(lcErrs_Msg)
7087 loEiPCTS.Errs_Msg_S = Alltrim(loEiPCTS.Errs_Msg_S) + lcErrs_Msg
7088 loEiPCTS.Errs_Flg_S = "Y"
7089 replace Sln_Error with .T. in tmpCurs
7090 Else
7091 replace Division with lcDivision in tmpCurs
7092 Endif
7093
7094 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7095 loEiPCTS.Division = lcDivision
7096 loEiPCTS.Style = lcStyle
7097 loEiPCTS.Color_Code = lcColor_code
7098 loEiPCTS.Lbl_Code = lcLbl_code
7099 loEiPCTS.Dimension = lcDimension
7100 loEiPCTS.SizeBucket = lnSizeBucket
7101 loEiPCTS.Size_Desc = lnSize_Desc
7102 Endif
7103
7104 Gather Name loEiPCTS Memo
7105
7106 ENDSCAN
7107
7108 SELECT tmpCurs
7109 SCAN FOR IsPPK = 'N'
7110 Select (pceipcTS)
7111 =Seek(tmpCurs.PKey, pceipcTS, "PKey")
7112 Scatter Name loEiPCTS Memo
7113
7114 IF NOT EMPTY(loEiPCTS.Dimension)
7115 lcppk_code = vl_ppakh(loEiPCTS.Division,'PPK_CODE',, vl_stylr(loEiPCTS.Division,'size_code',,loEiPCTS.Style), loEiPCTS.Dimension)
7116 IF !EMPTY(lcppk_code)
7117 replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
7118 ENDIF
7119 ENDIF
7120
7121 *--- TechRec 1071427 03-Jun-2013 jjanand === Added AND loEiPCTS.Errs_Flg_S != 'Y'
7122 *- TR 1073826 FH - added USED('__tmpDimCurs')
7123 *IF tmpCurs.IsPPK = 'N' AND loEiPCTS.Errs_Flg_S != 'Y' AND vl_scolr(loEiPCTS.Division,,'__tmpDimCurs' ,loEiPCTS.Style, loEiPCTS.Color_Code, loEiPCTS.Lbl_Code) AND USED('__tmpDimCurs')
7124 IF tmpCurs.IsPPK = 'N' AND vl_scolr(loEiPCTS.Division,,'__tmpDimCurs' ,loEiPCTS.Style, loEiPCTS.Color_Code, loEiPCTS.Lbl_Code) AND USED("__tmpDimCurs") && *--- TR 1080606/1078492 16-8-2014 VKK
7125
7126 SELECT __tmpDimCurs
7127 LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
7128 lcppk_code = dimension
7129 USE IN SELECT('__tmpDimCurs')
7130 IF !EMPTY(lcppk_code) AND vl_ppakd(loEiPCTS.Division,,'__tmpDimCurs', vl_stylr(loEiPCTS.Division,'size_code',,loEiPCTS.Style), lcppk_code, loEiPCTS.Color_Code, loEiPCTS.Lbl_Code,loEiPCTS.dimension)
7131 SELECT __tmpDimCurs
7132 IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPCTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPCTS.SizeBucket, 2, '0') + "_qty") > 0
7133 replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
7134 ENDIF
7135 USE IN SELECT('__tmpDimCurs')
7136 ENDIF
7137 ENDIF
7138 ENDSCAN
7139
7140 UPDATE td SET Style_SLN_OK = 'N' ;
7141 FROM (pceipcTD) td INNER JOIN (pceipcTS) ts on td.pkey = ts.fkey ;
7142 WHERE ts.errs_flg_s ='Y'
7143
7144 llRetVal = This.CreateCursorSLNToDtl(pceipcTD, pceipcCR, "tmpCurs")
7145 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
7146 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE )
7147 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipcTH, pceipcTD, pceipcTS, pceipcCR, "tmpCurs")
7148 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipcTH, pceipcTD, pceipcTS, pceipcCR, "tmpCurs")
7149 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
7150 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
7151 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE )
7152
7153 This.TableClose("tmpCurs")
7154
7155 ENDPROC
7156
7157 *--- This is the splited function from MoveSLNToDTLs
7158 PROCEDURE CreateCursorSLNToDtl
7159 LPARAMETERS pceipcTD, pceipcCR, pcTmpCursor
7160
7161 LOCAL llRetVal, lnOldSelect
7162 lnOldSelect = SELECT()
7163 llRetVal = true
7164
7165 *--- TR 1048865 27-Dec-2010 Goutam. Changed the join of (pcTmpCursor) and zzeipccr from division and customer to pkey = cr_pkey
7166 select t.Customer ;
7167 , t.FKey ;
7168 , t.PKey ;
7169 from (pcTmpCursor) t ;
7170 join zzeipccr c ;
7171 on c.pkey = t.cr_pkey ;
7172 join (pceipcTD) d ;
7173 on d.pkey = t.dtlPkey ;
7174 where c.slntodtl = 'Y' ;
7175 and d.slntodtl <> 'Y' ;
7176 into Cursor __tmpipcts ;
7177 order by t.fkey, t.Customer, t.PKey
7178
7179 SELECT(lnOldSelect)
7180 RETURN llRetVal
7181
7182 ENDPROC
7183
7184 PROCEDURE MoveSLNToDTLs
7185 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
7186 LPARAMETERS pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE
7187
7188 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnStartPkey, lnDetailPrice, ;
7189 lnLine_Seq
7190
7191 LOCAL lcSQL ,loIPCtdn
7192
7193 LOCAL lnTotSLNQty
7194
7195 llRetVal = true
7196 lnOldSelect = Select()
7197 lnDetailPrice = 0
7198
7199 *-- #1 Create detail record from pceipcTS
7200 SELECT __tmpipcts
7201 lnStartPkey = v_nextPkey("ZZEIPCTD", RECCOUNT("__tmpipcts")) - RECCOUNT("__tmpipcts")
7202 GO top
7203 lnSkipedPSFkey = 0
7204 lnPSFkey = 0
7205 lnLine_Seq = 0
7206 lnTotSLNQty = 0
7207
7208 IF SEEK(__tmpipcts.Fkey, pceipcTD, "PKey") AND Seek(__tmpipcts.PKey, pceipcTS, "PKey")
7209 lnDetailPrice = .getPriceFromIPCts(pceipcTS, &pceipcTD..Org_Price)
7210 ENDIF
7211 DO WHILE NOT EOF()
7212 lnPSFkey = Fkey
7213 IF lnPSFkey <> lnSkipedPSFkey
7214 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipcTS)
7215 ENDIF
7216 lnStartPkey = lnStartPkey + 1
7217 IF SEEK(lnPSFkey, pceipcTD, "PKey") AND Seek(__tmpipcts.PKey, pceipcTS, "PKey")
7218 lnLine_Seq = lnLine_Seq + 1
7219 SELECT (pceipcTD)
7220 SCATTER NAME loIPCtd MEMO
7221 loIPCtd.pkey = lnStartPkey
7222 loIPCtd.Line_Seq = lnLine_Seq
7223
7224 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
7225 IF SEEK(STR(loIPCtd.doc_num)+loIPCtd.po1_line, pceipcTWHSE, "SLN_Line")
7226 SELECT (pceipcTWHSE)
7227 lnDocNum = doc_num
7228 lnEdiLine = edi_line
7229 lnSlnLine = sln_line
7230
7231 REPLACE line_seq WITH loIPCtd.line_seq, sizebucket WITH &pceipcTS..sizebucket, ;
7232 dfkey WITH loIPCtd.pkey, sfkey WITH &pceipcTS..pkey IN (pceipcTWHSE) ;
7233 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine
7234
7235 SELECT (pceipcTD)
7236 ENDIF
7237 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
7238
7239 loIPCtd.slntodtl = 'Y'
7240 IF EMPTY(loIPCtd.Assortment) AND EMPTY(loIPCtd.assort_qty)
7241 loIPCtd.Assortment = ALLTRIM(loIPCtd.UPC) +"@"+ ALLTRIM(loIPCtd.SKU) +"@"+ ALLTRIM(loIPCtd.po1_line)
7242 loIPCtd.assort_qty = loIPCtd.qty_change
7243 ENDIF
7244 loIPCtd.PO1_UPC = loIPCtd.UPC
7245 loIPCtd.PO1_SKU = loIPCtd.SKU
7246 loIPCtd.Qualifier = loIPCtd.Qualifier
7247 loIPCtd.po1_price = loIPCtd.org_price
7248 loIPCtd.Division = &pceipcTS..Division
7249 loIPCtd.Style = &pceipcTS..Style
7250 loIPCtd.Color_code = &pceipcTS..Color_code
7251 loIPCtd.Lbl_Code = &pceipcTS..Lbl_Code
7252 loIPCtd.Dimension = &pceipcTS..Dimension
7253 loIPCtd.SizeBucket = &pceipcTS..SizeBucket
7254 loIPCtd.Size_Desc = &pceipcTS..Size_Desc
7255 loIPCtd.UPC = &pceipcTS..SLN_UPC
7256 loIPCtd.SKU = &pceipcTS..SLN_SKU
7257
7258 DO CASE
7259 CASE loIPCtd.ppk_action = 'B'
7260
7261 loIPCtd.qty_change = &pceipcTS..SLN_Qty * loIPCtd.qty_change
7262 loIPCtd.ppk_action = 'X'
7263 lnDetailPrice = loIPCtd.Org_Price/ lnTotSLNQty
7264 loIPCtd.poc_price = loIPCtd.poc_price / lnTotSLNQty
7265 loIPCtd.poc_retail2 = loIPCtd.poc_retail2 / lnTotSLNQty &&--- TechRec 1054692 21-Sep-2011 jisingh ===
7266 loIPCtd.ppk_qty = loIPCtd.qty_change
7267
7268 CASE loIPCtd.ppk_action = 'Q'
7269
7270 loIPCtd.qty_change = &pceipcTS..SLN_Qty * loIPCtd.qty_change
7271
7272 IF loIPCtd.ppk_action = 'Q'
7273 loIPCtd.ppk_action = 'M'
7274 ENDIF
7275
7276 loIPCtd.ppk_qty = loIPCtd.qty_change
7277 lnDetailPrice = &pceipcTD..Org_Price
7278
7279 CASE loIPCtd.ppk_action = 'P'
7280 loIPCtd.qty_change = (loIPCtd.qty_change/lnTotSLNQty) * &pceipcTS..SLN_Qty
7281 loIPCtd.ppk_action = 'D'
7282 lnDetailPrice = loIPCtd. Org_Price/ lnTotSLNQty
7283
7284 *--- TR 1050827 25-NOV-2010 HNISAR
7285 * Retail Field is not available. Here Retail1 is POC_price
7286*!* loIPCtd.Retail1 = loIPCtd.retail1 / lnTotSLNQty
7287 loIPCtd.poc_price = loIPCtd.poc_price / lnTotSLNQty
7288 loIPCtd.poc_retail2 = loIPCtd.poc_retail2 / lnTotSLNQty &&--- TechRec 1054692 21-Sep-2011 jisingh ===
7289 *=== TR 1050827 25-NOV-2010 HNISAR
7290
7291 OTHERWISE
7292 loIPCtd.qty_change = (loIPCtd.qty_change/lnTotSLNQty) * &pceipcTS..SLN_Qty
7293 lnDetailPrice = &pceipcTD..Org_Price
7294 loIPCtd.ppk_qty = lnTotSLNQty
7295 ENDCASE
7296
7297 loIPCtd.org_Price = IIF(&pceipcTS..Poc_Cost=0, lnDetailPrice, NVL(&pceipcTS..Poc_Cost,0))
7298 loIPCtd.poc_cost = loIPCtd.org_Price
7299 loIPCtd.Line_id = IIF(!EMPTY(loIPCtd.Assortment), loIPCtd.Assortment, &pceipcTS..Line_id)
7300
7301 loIPCtd.Errs_flg_d = "N"
7302 loIPCtd.Errs_msg_d = ""
7303
7304 APPEND BLANK
7305 GATHER NAME loIPCtd MEMO
7306
7307
7308 * Deleting SLNs now because we just created DTLs from
7309 * SLNs so, SLNs are no longer needed.
7310 Select (pceipcTS)
7311 If Seek(__tmpipcts.PKey, pceipcTS, "PKey")
7312 Delete In (pceipcTS)
7313 Endif
7314
7315 ENDIF
7316
7317
7318 *--- TR 1050827 30-NOV-2010 HNISAR
7319*!* SELECT __tmpipcts
7320*!* SKIP IN __tmpipcts
7321*!* lnSkipedPSFkey = Fkey
7322*!* IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipcTD, "PKey")
7323*!*
7324 SELECT __tmpipcts
7325 lnSkipedPSFkey = Fkey
7326 SKIP IN __tmpipcts
7327
7328 IF (lnPSFkey <> __tmpipcts.Fkey) AND SEEK(lnPSFkey, pceipcTD, "PKey")
7329 *=== TR 1050827 30-NOV-2010 HNISAR
7330 DELETE IN (pceipcTD)
7331
7332 IF SEEK(__tmpipcts.Fkey, pceipcTD, "PKey") AND Seek(__tmpipcts.PKey, pceipcTS, "PKey")
7333 lnDetailPrice = .getPriceFromIPCts(pceipcTS, &pceipcTD..Org_Price)
7334 ENDIF
7335 lnLine_Seq = 0
7336 ENDIF
7337 ENDDO
7338
7339 * Delete SLNs from the server since we've already created
7340 * details from our SLNs.
7341 This.cSQLTempTable = ""
7342 If .GenerateSQLTempTable(pceipcTD) AND .PopulateSQLTempTable(pceipcTD) AND !Empty(This.cSQLTempTable)
7343 lcSQL = "DELETE s " + ;
7344 "FROM zzeipcts s " + ;
7345 "WHERE NOT EXISTS (" + ;
7346 "SELECT * FROM " + This.cSQLTempTable + " t " + ;
7347 "WHERE s.fkey = t.pkey) "
7348
7349 llRetVal = llRetVal And v_SQLExec(lcSQL)
7350 ENDIF
7351
7352 USE IN __tmpipcts
7353
7354 SELECT (lnOldSelect)
7355 RETURN llRetVal
7356 ENDPROC
7357
7358 *---- get total sln qty for a detail line
7359 FUNCTION getPriceFromIPCts
7360 LPARAMETERS pceipcTS, pnPrice
7361 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
7362 lnUnitPrice = 0
7363 IF pnPrice > 0
7364 lnOldSelect = SELECT()
7365
7366 SELECT (pceipcTS)
7367 lnFkey = Fkey
7368 lnSLNQty = SLN_Qty
7369 .PushRecordSet()
7370 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
7371 lnUnitPrice = pnPrice/lnSLNTotalQty
7372 .PopRecordSet()
7373
7374 SELECT (lnOldSelect)
7375 ENDIF
7376
7377 RETURN lnUnitPrice
7378 ENDFUNC
7379
7380 PROCEDURE ResolvePPKSkuAndUpdateDetail
7381 LPARAMETERS pceipcTH, pceipcTD, pceipcTS, pceipcCR, tmpCurs
7382
7383 LOCAL llRetVal, lnOldSelect, lcSql, i, lnPackTotal, lnQtyChange,;
7384 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPCTS,;
7385 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess
7386
7387 llRetVal = .T.
7388 lnOldSelect = SELECT()
7389
7390 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
7391 SELECT tmpCurs
7392 lnFKey = 0
7393
7394 DIMENSION laBuckets(goEnv.MaxBuckets)
7395
7396 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
7397 SCAN
7398 IF FKey # lnFKey
7399 lnFKey = FKey
7400
7401 IF SLN_Error or !Unresolved
7402 llDeleteSLN = .T.
7403 ELSE
7404
7405 *--- TR 1048865 27-Dec-2010 Goutam
7406 *llDeleteSLN = !Seek(Division+Customer, pceipcCR, "DivCust")
7407 llDeleteSLN = !Seek(cr_pkey, pceipcCR, "pkey")
7408 *=== TR 1048865 27-Dec-2010 Goutam
7409
7410 IF !llDeleteSLN
7411 SELECT (pceipcCR)
7412 llDeleteSLN = ((StyleFromSLN < "Y") and (StyleFromSLN <> "O"))
7413
7414 Select tmpCurs
7415 EndIf
7416 EndIf
7417
7418 If !llDeleteSLN
7419 lnRecNo = RecNo()
7420
7421 Scan while FKey = lnFKey
7422 If SLN_Error
7423 *-- One SLN with error exists.
7424 llDeleteSLN = .T.
7425 Exit
7426 EndIf
7427 EndScan
7428
7429 Go lnRecNo
7430 EndIf
7431 EndIf
7432
7433 If llDeleteSLN
7434 Delete
7435 EndIf
7436 EndScan
7437
7438
7439 *-- #3 -- Updating Details with PPK BC SKU:
7440 lcOldCust = ""
7441 lcOldSKU = ""
7442 lnFKey = 0
7443 lnRecNo = This.CountTotalRecs('tmpCurs')
7444
7445 If lnRecNo > 0
7446 *-- Need for optimization:
7447
7448 If This.lUserInterface
7449 This.UpdateThermoCaption("Resolving Style From SLN...")
7450 This.InitThermo(lnRecNo + 1)
7451 lnRecNo = 1
7452 Endif
7453 v_SQLExec("create table #ImplodeSLN " + ;
7454 "( Color_Code Char(50), Lbl_Code Char(7), Dimension Char(5), SizeBucket Int, " + ; && TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
7455 " Size_Desc Char(10), Qty Int, PKey Int)")
7456
7457 Select (pceipcTD)
7458 lcOldOrder = Order()
7459
7460 Index on Customer+SKU+UPC tag CustSKU
7461 lcOldUPC = ''
7462 *==
7463
7464 If This.lUserInterface
7465 This.AdvanceThermo(lnRecNo)
7466 EndIf
7467
7468 Select tmpCurs
7469 Locate
7470
7471 Do while .T. && Scan replacement
7472 if FKey # lnFKey
7473 If llProcess
7474 If llImplodeOK
7475
7476 *- This is a modified SQL from Perform_Implosion()
7477 *- Added LEFT JOIN #ImplodeSLN and
7478 *- the last 'not exist' to check for exact match (by ratio) between #ImplodeSLN and prepacks.
7479 = v_SqlExec(;
7480 "select c.Dimension as PPk, c.Color_Code as PPK_Color, c.Lbl_Code as PPK_Lbl, Size_Num,"+;
7481 " Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+"+;
7482 " Sz04*Pack04_Qty+Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+"+;
7483 " Sz08*Pack08_Qty+Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+"+;
7484 " Sz12*Pack12_Qty+Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+"+;
7485 " Sz16*Pack16_Qty+Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+"+;
7486 " Sz20*Pack20_Qty+Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+"+;
7487 " Sz24*Pack24_Qty as PPK_Bk_Qty"+;
7488 " , pd.Color_Code as PDtl_Color"+;
7489 " , pd.Lbl_Code as PDtl_Lbl"+;
7490 " , i.Color_Code"+;
7491 " , i.Lbl_Code"+;
7492 " , i.Dimension"+;
7493 " , z.Size01 " + ;
7494 " , i.PKey"+;
7495 " , i.Qty"+;
7496 " , ph.Pack_Qty"+;
7497 " from zzxScolr c"+;
7498 " join zzxstylr st"+;
7499 " on st.pkey = c.fkey" + ;
7500 " join zzxPPakH ph"+;
7501 " on ph.Division = c.Division"+;
7502 " and ph.Size_Code = st.Size_Code"+;
7503 " and ph.ppK_Code = c.Dimension"+;
7504 " and c.color_code = case " + ;
7505 " when ph.MulClLb_Ok = 'Y' and ph.ppk_color <> '' " + ;
7506 " then ph.ppk_color else c.color_code end " + ;
7507 " join zzxPPakD pd"+;
7508 " on pd.FKey = ph.PKey"+;
7509 " join zzxSizer z"+;
7510 " on z.Division = c.Division"+;
7511 " and z.Size_Code = st.Size_Code"+;
7512 " cross join zzxBuckt b"+;
7513 " LEFT join #ImplodeSLN i"+;
7514 " on i.Color_Code = case "+;
7515 " when pd.Color_Code = 'ALL' or pd.Color_Code = '' "+;
7516 " then c.Color_Code else pd.Color_Code end "+;
7517 " and i.Lbl_Code = case "+;
7518 " when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' "+;
7519 " then c.Lbl_Code else i.Lbl_Code end"+;
7520 " and i.Dimension = pd.Dimension"+;
7521 " and i.SizeBucket = b.Size_Num"+;
7522 " where c.Style = '" + ALLTR(lcStyle) + "'" + ;
7523 " and c.Division = '" + ALLTR(lcDivision) + "'" + ;
7524 " and c.PPack_OK = 'Y'"+;
7525 " and c.Active_OK = 'Y'"+;
7526 " and ph.Active_OK = 'Y'" + ;
7527 " and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+"+;
7528 " Sz04*Pack04_Qty+Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+"+;
7529 " Sz08*Pack08_Qty+Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+"+;
7530 " Sz12*Pack12_Qty+Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+"+;
7531 " Sz16*Pack16_Qty+Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+"+;
7532 " Sz20*Pack20_Qty+Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+"+;
7533 " Sz24*Pack24_Qty > 0 "+;
7534 " and not Exists("+;
7535 " Select *"+;
7536 " from zzxPPakD p"+;
7537 " cross join zzxBuckt bk"+;
7538 " left join #ImplodeSLN ii"+;
7539 " on ii.Color_Code = case when p.Color_Code = 'ALL' or p.Color_Code = '' then c.Color_Code else p.Color_Code end "+;
7540 " and ii.Lbl_Code = case when ph.MulClLb_Ok < 'Y' or p.Lbl_Code = 'ALL' then c.Lbl_Code else ii.Lbl_Code end"+;
7541 " and ii.Dimension = p.Dimension"+;
7542 " and ii.SizeBucket = bk.Size_Num"+;
7543 " where p.Fkey = ph.Pkey"+;
7544 " and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+"+;
7545 " Sz04*Pack04_Qty+Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+"+;
7546 " Sz08*Pack08_Qty+Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+"+;
7547 " Sz12*Pack12_Qty+Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+"+;
7548 " Sz16*Pack16_Qty+Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+"+;
7549 " Sz20*Pack20_Qty+Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+"+;
7550 " Sz24*Pack24_Qty > Coalesce(ii.Qty,0))"+;
7551 "and not exists( "+;
7552 "select * "+;
7553 " from #ImplodeSLN ii "+;
7554 " left join zzxPPakD p "+;
7555 " on ii.Color_Code = case "+;
7556 " when p.Color_Code = 'ALL' or p.Color_Code = '' then ii.Color_Code "+;
7557 " else p.Color_Code "+;
7558 " end "+;
7559 " and ii.Lbl_Code = case "+;
7560 " when ph.MulClLb_Ok < 'Y' or p.Lbl_Code = 'ALL' then ii.Lbl_Code "+;
7561 " else p.Lbl_Code "+;
7562 " end "+;
7563 " and ii.Dimension = p.Dimension "+;
7564 " and p.Fkey = ph.Pkey"+;
7565 " join zzxBuckt bk "+;
7566 " on ii.SizeBucket = bk.Size_Num "+;
7567 " where IsNull(ii.Qty % NullIf(" + ;
7568 " Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+ Sz04*Pack04_Qty" + ;
7569 " +Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+ Sz08*Pack08_Qty" + ;
7570 " +Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+ Sz12*Pack12_Qty" + ;
7571 " +Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+ Sz16*Pack16_Qty" + ;
7572 " +Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+ Sz20*Pack20_Qty" + ;
7573 " +Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty, 0), 1) > 0 ) "+;
7574 " order by 1, 2, i.PKey", "vPPacks")
7575
7576 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
7577
7578 If Seek(tmpCurs.PKey, pceipcTS, "PKey")
7579 Select (pceipcTS)
7580 *- insert into #implodeSLN
7581 v_SQLExec("insert into #ImplodeSLN values ('"+;
7582 Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
7583 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
7584 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
7585 Endif
7586
7587 SELECT lcDivision as division, ;
7588 lcStyle as style, ;
7589 ppk_color as color_code, ;
7590 ppk_lbl as lbl_code, ;
7591 ppk as dimension, ;
7592 ppk_bk_qty as sizebucket, ;
7593 size01 ;
7594 FROM VPPacks group by 5,3,4 ;
7595 into cursor qppk
7596 ENDIF && llImplodeOK
7597
7598 SELECT (pceipcTD)
7599 =Seek(lnFKey, pceipcTD, "PKey") && lnFKey contains the Previous Dtl PKey
7600 lcOldCust = Customer
7601 lcOldSKU = SKU
7602
7603 *-- Update all records with the same CustSKU
7604 *- =Seek(lcOldCust+lcOldSKU) && First matching record
7605 lcOldUPC = UPC
7606 =Seek(lcOldCust+lcOldSKU+lcOldUPC)
7607 If llImplodeOK and RecCount("qPPK") = 1
7608 replace Division with qPPK.Division, ;
7609 Style with qPPK.Style, ;
7610 Color_Code with qPPK.Color_Code, ;
7611 Lbl_Code with qPPK.Lbl_Code, ;
7612 Dimension with qPPK.Dimension,;
7613 SizeBucket with 1;
7614 Size_Desc with qPPk.Size01;
7615 Style_SLN_OK with 'Y' ;
7616 while Customer + SKU + UPC = lcOldCust+lcOldSKU+lcOldUPC
7617 Else
7618
7619 IF Seek(Division+Customer, pceipcCR, "DivCust") AND (SysGetFieldValue(pceipcCR, StyleFromSLN) <> "O")
7620 replace Style_SLN_OK with 'N' ;
7621 while Customer + SKU + UPC = lcOldCust+lcOldSKU+lcOldUPC
7622 ENDIF
7623
7624 ENDIF
7625 Else
7626 If Seek(tmpCurs.PKey, pceipcTS, "PKey")
7627 Select (pceipcTS)
7628 *- insert into #implodeSLN
7629 v_SQLExec("insert into #ImplodeSLN values ('"+;
7630 Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
7631 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
7632 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
7633
7634 EndIf
7635 EndIf && Process Detail
7636
7637 Select tmpCurs
7638 if Eof()
7639 Exit
7640 EndIf
7641
7642 lnFKey = FKey
7643 Select (pceipcTD)
7644 =Seek(lnFKey, pceipcTD, "PKey")
7645
7646 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
7647
7648 llImplodeOK = llProcess
7649
7650 If llImplodeOK
7651 store 0 to laBuckets
7652 lnPackTotal = 0
7653
7654 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
7655 Select (pceipcTS)
7656 =Seek(tmpCurs.PKey, pceipcTS, "PKey")
7657
7658 lcDivision = Division
7659 lcStyle = Style
7660 lcColor_Code = Color_Code
7661 lcLbl_Code = Lbl_Code
7662 lcDimension = Dimension
7663 EndIf
7664
7665 Else && The same FKey
7666 If llImplodeOK and Seek(tmpCurs.PKey, pceipcTS, "PKey")
7667 Select (pceipcTS)
7668 if Division # lcDivision;
7669 or Style # lcStyle
7670 llImplodeOK = .F.
7671 ELSE
7672 *- insert into #implodeSLN
7673 v_SQLExec("insert into #ImplodeSLN values ('"+;
7674 Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
7675 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
7676 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
7677 EndIf
7678 EndIf
7679 EndIf && FKey Changed
7680
7681 if llImplodeOK
7682 *-- (pceipcTS) is selected!
7683 laBuckets[SizeBucket] = Sln_Qty
7684 lnPackTotal = lnPackTotal + Sln_Qty
7685 EndIf
7686
7687 Select tmpCurs
7688 Skip
7689
7690 If This.lUserInterface
7691 lnRecNo = lnRecNo + 1
7692 This.AdvanceThermo(lnRecNo)
7693 Endif
7694 EndDo && Endscan
7695
7696 Select (pceipcTD)
7697 Set Order to (lcOldOrder)
7698
7699 v_SQLExec("DROP table #ImplodeSLN ")
7700
7701 EndIf && Have data to Implode
7702
7703 If This.lUserInterface
7704 * Reset Thermometer
7705 This.ResetThermo()
7706 Endif
7707
7708 Select(lnOldSelect)
7709 Return llRetVal
7710
7711 ENDPROC
7712
7713 Procedure CreateSingleSLNCursor
7714 Lparameters pcTmpCursor
7715
7716 Local llRetVal, lnOldSelect, lcSQLString
7717
7718 llRetVal = true
7719 lnOldSelect = Select()
7720
7721 *--- TR 1048865 27-Dec-2010 Goutam. Changed the join of (pcTmpCursor) and zzeipccr from division and customer to pkey = cr_pkey
7722 select t.Customer ;
7723 , t.FKey ;
7724 , t.PKey ;
7725 from (pcTmpCursor) t ;
7726 join zzeipccr c ;
7727 on c.pkey = t.cr_pkey ;
7728 where c.slntodtl = 'N' ;
7729 and (c.stylefromsln = 'O' ;
7730 and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
7731 into Cursor __tmpipcts ;
7732 order by t.fkey, t.Customer, t.PKey
7733
7734 Select(lnOldSelect)
7735 Return llRetVal
7736 Endproc
7737
7738 Procedure ResolveSingleSLNDetail
7739 Lparameters pceipcTH, pceipcTD, pceipcTS, pceipcCR, pcTmpCursor
7740
7741 Local llRetVal, lnOldSelect, lnQtyChange, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
7742
7743 llRetVal = true
7744 lnOldSelect = Select()
7745
7746 *--- TR 1048865 27-Dec-2010 Goutam. Changed the join of (pcTmpCursor) and zzeipccr from division and customer to pkey = cr_pkey
7747 select t.Customer ;
7748 , t.FKey ;
7749 , t.PKey ;
7750 , t.ppk_code ;
7751 from (pcTmpCursor) t ;
7752 join zzeipccr c ;
7753 on c.pkey = t.cr_pkey ;
7754 where c.slntodtl = 'N' ;
7755 AND ((c.stylefromsln in ('Y','O') ;
7756 and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
7757 into Cursor __tmpipcts ;
7758 order by t.fkey, t.Customer, t.PKey
7759
7760 SELECT __tmpipcts
7761 SCAN
7762 lnFKey = Fkey
7763
7764 Select (pceipcTS)
7765 IF SEEK(__tmpipcts.PKey, pceipcTS, "PKey")
7766
7767 lcDivision = Division
7768 lcStyle = Style
7769 lcColor_Code = Color_Code
7770 lcLbl_Code = Lbl_Code
7771 lcDimension = __tmpipcts.PPK_Code
7772 lcSize_Desc = Size_Desc
7773
7774 select (pceipcTD)
7775 IF SEEK(lnFKey, pceipcTD, "PKey") AND !(Style_SLN_OK = 'Y')
7776
7777 replace Division with lcDivision, ;
7778 Style with lcStyle, ;
7779 Color_Code with lcColor_Code, ;
7780 Lbl_Code with lcLbl_Code, ;
7781 Dimension with lcDimension,;
7782 SizeBucket with 1;
7783 Size_Desc with lcSize_Desc;
7784 Style_SLN_OK with 'Y' ;
7785 IN (pceipcTD)
7786 ENDIF
7787 ENDIF
7788 ENDSCAN
7789
7790 IF USED("__tmpipcts")
7791 USE IN __tmpipcts
7792 ENDIF
7793
7794 Select(lnOldSelect)
7795 Return llRetVal
7796 Endproc
7797* === TR 1047609 7/7/10 CM
7798
7799* --- TR 1047609 7/7/10 CM
7800* Routine from 850 also implemented within 860
7801*---------------------------------------------------------------------------------
7802 FUNCTION GetTotSLNQty
7803 LPARAMETERS tnPSFkey, pceipcTS
7804
7805 LOCAL lnTotSlnQty, lnOldSelect
7806 LOCAL ARRAY laTotSlnQty[1]
7807
7808 lnOldSelect = SELECT()
7809 lnTotSlnQty = 0
7810
7811 SELECT SUM(sln_qty) FROM (pceipcTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
7812 lnTotSlnQty = laTotSlnQty[1]
7813
7814 Select(lnOldSelect)
7815 Return lnTotSlnQty
7816 ENDFUNC
7817*=================================================================================
7818* === TR 1047609 7/7/10 CM
7819
7820 *============================================================
7821 *--- TechRec 1050485 17-Dec-2010 vkrishnamurthy/Goutam ---
7822 FUNCTION MoveRZtoAI
7823 LOCAL llRetVal, lnSelect,lcFilter ,lcSql
7824 llRetVal = true
7825 lnSelect = SELECT()
7826
7827 WITH This
7828 lcFilter = IIF (EMPTY(.cFilterCriteria),"",.cFilterCriteria)
7829 lcFilter = STRTRAN(lcFilter,"H.","TH.")
7830 lcFilter = STRTRAN(lcFilter,"Where","")
7831
7832 *--- TR 1083913 02-Feb-2015 Partha ---
7833 * CHANGED: and c.template = " + SQLFormatChar('JCP 4030 860')
7834 * TO: and c.template IN ('JCP 4030 860','Biglots 5010 860')
7835 *
7836 * CHANGED: h.po_type = 'KC'
7837 * TO: h.po_type = 'KC' OR c.template = 'BIGLOTS 5010 860'
7838 *=== TR 1083913 02-Feb-2015 Partha ===
7839
7840 lcSql = "update td set td.qualifier = 'AI' " + ;
7841 " from zzeipctd td join zzeipcth th on th.pkey = td.fkey " + ;
7842 " Join zzeipccr c " + ;
7843 " on c.division = th.division "+ ;
7844 " and c.customer = th.customer "+ ;
7845 " and c.template IN ('JCP 4030 860','Biglots 5010 860')" + ; && 1083913
7846 " LEFT Join zzeipohh h "+ ; && 1083913 - Changed to LEFT Join
7847 " on h.po_num = th.po_num " +;
7848 " and h.po_type = 'KC' " + ;
7849 " where td.qualifier = 'RZ' " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)+;
7850 " AND ( c.template = 'Biglots 5010 860' OR h.po_num is not null ) " + ; && 1083913
7851 " and NOT exists (select od.pkey from zzoordrd od (nolock) "+ ;
7852 " join zzoordrh oh (nolock) " + ;
7853 " on oh.pkey = od.fkey " + ;
7854 " join zzxstylr lr " + ;
7855 " on od.division = lr.division " + ;
7856 " and od.style = lr.style" + ;
7857 " join zzxsizer sr" + ;
7858 " on sr.division = od.division" + ;
7859 " and sr.size_code = lr.size_code " + ;
7860 " cross join zzxbuckt b " + ;
7861 " where od.size01_qty * b.sz01 + od.size02_qty * b.sz02 + od.size03_qty * b.sz03 + od.size04_qty * b.sz04 + od.size05_qty * b.sz05 + " + ;
7862 " od.size06_qty * b.sz06 + od.size07_qty * b.sz07 + od.size08_qty * b.sz08 + od.size09_qty * b.sz09 + od.size10_qty * b.sz10 + " + ;
7863 " od.size11_qty * b.sz11 + od.size12_qty * b.sz12 + od.size13_qty * b.sz13 + od.size14_qty * b.sz14 + od.size15_qty * b.sz15 + " + ;
7864 " od.size16_qty * b.sz16 + od.size17_qty * b.sz17 + od.size18_qty * b.sz18 + od.size19_qty * b.sz19 + od.size20_qty * b.sz20 + " + ;
7865 " od.size21_qty * b.sz21 + od.size22_qty * b.sz22 + od.size23_qty * b.sz23 + od.size24_qty * b.sz24 > 0 " + ;
7866 " and oh.po_num = th.po_num " + ;
7867 " and oh.customer = th.customer "+ ;
7868 " and oh.store = th.store "+ ;
7869 " and oh.ord_status = 'O' " + ;
7870 " and od.division = td.division " + ;
7871 " and od.style = td.style " + ;
7872 " and od.color_code = td.color_code " + ;
7873 " and od.lbl_code = td.lbl_code " + ;
7874 " and od.dimension = td.dimension " + ;
7875 " and case when b.SZ01 > 0 then sr.size01 " + ;
7876 " when b.SZ02 > 0 then sr.size02 " + ;
7877 " when b.SZ03 > 0 then sr.size03 " + ;
7878 " when b.SZ04 > 0 then sr.size04 " + ;
7879 " when b.SZ05 > 0 then sr.size05 " + ;
7880 " when b.SZ06 > 0 then sr.size06 " + ;
7881 " when b.SZ07 > 0 then sr.size07 " + ;
7882 " when b.SZ08 > 0 then sr.size08 " + ;
7883 " when b.SZ09 > 0 then sr.size09 " + ;
7884 " when b.SZ10 > 0 then sr.size10 " + ;
7885 " when b.SZ11 > 0 then sr.size11 " + ;
7886 " when b.SZ12 > 0 then sr.size12 " + ;
7887 " when b.SZ13 > 0 then sr.size13 " + ;
7888 " when b.SZ14 > 0 then sr.size14 " + ;
7889 " when b.SZ15 > 0 then sr.size15 " + ;
7890 " when b.SZ16 > 0 then sr.size16 " + ;
7891 " when b.SZ17 > 0 then sr.size17 " + ;
7892 " when b.SZ18 > 0 then sr.size18 " + ;
7893 " when b.SZ19 > 0 then sr.size19 " + ;
7894 " when b.SZ20 > 0 then sr.size20 " + ;
7895 " when b.SZ21 > 0 then sr.size21 " + ;
7896 " when b.SZ22 > 0 then sr.size22 " + ;
7897 " when b.SZ23 > 0 then sr.size23 " + ;
7898 " when b.SZ24 > 0 then sr.size24 end = td.size_desc) "
7899
7900 llRetVal = llRetVal and v_sqlexec(lcSQL)
7901
7902 IF llRetVal
7903 REQUERY('Vzzeipcth_ipcproc')
7904 SELECT ('Vzzeipcth_ipcproc')
7905 SCAN
7906 SCATTER NAME loEiPCth MEMO
7907 SELECT tceipcTH
7908 IF SEEK(loEiPCth.pkey,'tceipcTH','PKEY')
7909 GATHER NAME loEiPCth MEMO
7910 ELSE
7911 APPEND BLANK
7912 GATHER NAME loEiPCth MEMO
7913 ENDIF
7914 ENDSCAN
7915
7916 REQUERY('Vzzeipctd_ipcproc')
7917 SELECT Vzzeipctd_ipcproc
7918 SCAN
7919 SCATTER NAME loEiPCtd MEMO
7920 SELECT tceipcTD
7921 IF SEEK(loEiPCtd.pkey,'tceipcTD','PKEY')
7922 GATHER NAME loEiPCtd MEMO
7923 ELSE
7924 APPEND BLANK
7925 GATHER NAME loEiPCtd MEMO
7926 ENDIF
7927
7928 ENDSCAN
7929 ENDIF
7930
7931 ENDWITH
7932
7933 SELECT (lnSelect)
7934 RETURN llRetVal
7935 ENDFUNC
7936 *=== TechRec 1050485 17-Dec-2010 vkrishnamurthy/Goutam ===
7937 *============================================================
7938
7939 *--- TR 1048865 13-Apr-2011 Goutam
7940 FUNCTION InsertExtraRecordFromSO
7941 LPARAMETERS pcFilter, pcipcOrder_New, pcipcth_New, pcipctd_New
7942
7943 LOCAL lnOldSelect, llRetVal, lcSql, lcAddlSOHCurs, lcAddlSODCurs
7944 lnOldSelect = SELECT()
7945 llRetVal = true
7946
7947 lcAddlSOHCurs = "#AddlSOH" + SYS(2015)
7948 lcAddlSODCurs = "#AddlSOD" + SYS(2015)
7949
7950 WITH this
7951 lcSql = "select * into " + lcAddlSOHCurs + ;
7952 " from zzoordrh h " + ;
7953 " where h.ord_status = 'O' " + ;
7954 " and exists( " + ;
7955 " select 1 " + ;
7956 " from " + pcipcOrder_New + " oh " + ;
7957 " where oh.ORD_NUM = h.ord_num " + ;
7958 " and oh.store = h.store) "
7959
7960 llRetVal = llRetVal and v_sqlexec(lcSql)
7961
7962 lcSql = "select u.UPC_NUM+u.CHK_DIGIT as upc, h.po_num, h.store " + ;
7963 " , d.* into " + lcAddlSODCurs + ;
7964 " from zzoordrh h " + ;
7965 " join zvoordrdv d " + ;
7966 " on d.fkey = h.pkey " + ;
7967 " join zveupcnr u " + ;
7968 " on u.DIVISION = d.division " + ;
7969 " and u.STYLE = d.style " + ;
7970 " and u.COLOR_CODE = d.color_code " + ;
7971 " and u.LBL_CODE = d.lbl_code " + ;
7972 " and u.DIMENSION = d.dimension " + ;
7973 " and u.SIZEBUCKET = d.Size_Bk " + ;
7974 " where h.ord_status = 'O' " + ;
7975 " and exists( " + ;
7976 " select 1 " + ;
7977 " from " + pcipcOrder_New + " oh " + ;
7978 " where oh.ORD_NUM = h.ord_num " + ;
7979 " and oh.store = h.store) " + ;
7980 " and not exists( " + ;
7981 " select 1 " + ;
7982 " from zzeipcth th " + ;
7983 " join zzeipctd td " + ;
7984 " on th.pkey = td.fkey " + ;
7985 " and th.po_num = h.po_num " + ;
7986 " and th.ord_num = h.ord_num " + ;
7987 " and th.store = h.store " + ;
7988 " and th.customer = h.customer " + ;
7989 " and td.UPC = u.upc_num+u.chk_digit where " + IIF(EMPTY(pcFilter),"1=1", pcFilter) + ")" + ;
7990 " and exists( " + ;
7991 " select 1 " + ;
7992 " from zzeipcth th " + ;
7993 " join zzeipctd td " + ;
7994 " on th.pkey = td.fkey " + ;
7995 " and td.UPC = u.upc_num+u.chk_digit where " + IIF(EMPTY(pcFilter),"1=1", pcFilter) + ")"
7996
7997
7998 llRetVal = llRetVal and v_sqlexec(lcSql)
7999
8000 llRetVal = llRetVal and .GenSQLZZEIPCTH(lcAddlSOHCurs, pcipcth_New)
8001 llRetVal = llRetVal and .GenSQLZZEIPCTD(lcAddlSODCurs, pcipctd_New)
8002
8003 .dropTempTable(lcAddlSOHCurs, true)
8004 .dropTempTable(lcAddlSODCurs, true)
8005
8006 ENDWITH
8007
8008 SELECT(lnOldSelect)
8009 RETURN llRetVal
8010 ENDPROC
8011
8012 FUNCTION GenSQLZZEIPCTH
8013 LPARAMETERS pcAddlSOHCurs, pcSourceIPCth
8014
8015 LOCAL lnOldSelect, llRetVal
8016 lnOldSelect = SELECT()
8017 llRetVal = true
8018
8019 WITH this
8020
8021 *------ Use SQL String Builder -------------------------*
8022 .oGenStr.SB_Reset()
8023
8024 .oGenStr.cSB_Target = "ZZEIPCTH"
8025 .oGenStr.cSB_Source = pcSourceIPCth
8026 .oGenStr.cSB_SourceAlias = "th"
8027 .oGenStr.cSB_FROMExpandedString = " join " + pcAddlSOHCurs + " oh on 1 = 1 join zzxstorr s on s.store = oh.store and s.customer = oh.customer"
8028
8029 .oGenStr.cSB_WHEREString = "th.pkey = (Select top 1 pkey from " + pcSourceIPCth + " where division = oh.division and po_num = oh.po_num and customer = oh.customer)"
8030
8031 .oGenStr.SB_SetLiteralFieldValue("edi_store","s.edi_store")
8032 .oGenStr.SB_SetLiteralFieldValue("ord_num","oh.ord_num")
8033 .oGenStr.SB_SetLiteralFieldValue("store","oh.store")
8034
8035 .oGenStr.SB_KeySetAddKeySpec("pkey","INT","th.pkey","th.pkey")
8036 .oGenStr.SB_KeySetAddKeySpec("ord_num","INT","oh.ord_num","oh.ord_num")
8037 .oGenStr.SB_KeySetAddKeySpec("po_num","Char(20)","oh.po_num","oh.po_num")
8038 .oGenStr.SB_KeySetAddKeySpec("store","Char(9)","oh.store","oh.store")
8039
8040 llRetVal = .oGenStr.SB_GenerateSQLInsertString()
8041
8042 IF llRetVal
8043 .cHBCKeySet = .oGenStr.aSB_BCKeySet[ALEN(.oGenStr.aSB_BCKeySet)]
8044 .nH_FirstPkey = .oGenStr.nSB_FirstPkey
8045 llRetVal = v_sqlexec(.oGenStr.cSQLString)
8046 ELSE
8047 lcMessage = "Failed to generate SQL string for 860(i) header NZ Qualifier. Cannot continue."
8048 .oLog.LogEntry(lcMessage)
8049 ENDIF
8050
8051 ENDWITH
8052
8053 SELECT(lnOldSelect)
8054 RETURN llRetVal
8055 ENDPROC
8056
8057 FUNCTION GenSQLZZEIPCTD
8058 LPARAMETERS lcAddlSODCurs, pcSourceIPCtd
8059
8060 LOCAL lnOldSelect, llRetVal
8061 lnOldSelect = SELECT()
8062 llRetVal = true
8063
8064 WITH this
8065
8066 *------ Use SQL String Builder -------------------------*
8067 .oGenStr.SB_Reset()
8068
8069 .oGenStr.cSB_Target = "ZZEIPCTD"
8070 .oGenStr.cSB_Source = pcSourceIPCtd
8071 .oGenStr.cSB_SourceAlias = "td"
8072
8073 .oGenStr.cSB_FROMExpandedString = "JOIN " + .cHBCKeySet + " th ON th.pkey = td.fkey join " + lcAddlSODCurs + " od on od.ord_num = th.ord_num and od.po_num = th.po_num and od.store = th.store "
8074 .oGenStr.SB_SetLiteralFieldValue("fkey","th.bc_pkey + " + SQLFormatNum(.nH_FirstPkey))
8075
8076 .oGenStr.SB_SetLiteralFieldValue("division","od.division")
8077 .oGenStr.SB_SetLiteralFieldValue("style","od.style")
8078 .oGenStr.SB_SetLiteralFieldValue("color_code","od.color_code")
8079 .oGenStr.SB_SetLiteralFieldValue("lbl_code","od.lbl_code")
8080 .oGenStr.SB_SetLiteralFieldValue("dimension","od.dimension")
8081 .oGenStr.SB_SetLiteralFieldValue("size_desc","od.size_desc")
8082 .oGenStr.SB_SetLiteralFieldValue("sizebucket","od.size_bk")
8083 .oGenStr.SB_SetLiteralFieldValue("upc","od.upc")
8084 .oGenStr.SB_SetLiteralFieldValue("qty_change","od.bk_qty")
8085 .oGenStr.SB_SetLiteralFieldValue("qualifier","'DI'")
8086
8087 .oGenStr.SB_KeySetAddKeySpec("pkey","INT","td.fkey","td.fkey")
8088 .oGenStr.SB_KeySetAddKeySpec("ord_num","INT","od.ord_num","od.ord_num")
8089 .oGenStr.SB_KeySetAddKeySpec("upc","Char(12)","od.upc","od.upc")
8090 .oGenStr.SB_KeySetAddKeySpec("line_seq","INT","od.line_Seq","od.line_Seq")
8091
8092 llRetVal = .oGenStr.SB_GenerateSQLInsertString()
8093
8094 IF llRetVal
8095 llRetVal = v_sqlexec(.oGenStr.cSQLString)
8096 ELSE
8097 lcMessage = "Failed to generate SQL string for 860(i) detail NZ Qualifier. Cannot continue."
8098 .oLog.LogEntry(lcMessage)
8099 ENDIF
8100
8101 ENDWITH
8102
8103 SELECT(lnOldSelect)
8104 RETURN llRetVal
8105 ENDPROC
8106 *=== TR 1048865 13-Apr-2011 Goutam
8107
8108 *--- TechRec 1056904 24-Oct-2011 jisingh ---
8109 *============================================================
8110
8111 PROCEDURE Check850TM
8112 LPARAMETERS pceipcTH, pceipcCR
8113 LOCAL llRetVal, lnSelect, lcSQLString
8114
8115 llRetVal = true
8116 lnSelect = SELECT()
8117
8118 WITH This
8119
8120 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
8121 *--- TR 1070268 27-Jun-2013 Goutam. Added template BURLINGTON 4010
8122 lcSQLString = " SELECT th.customer, th.division, th.po_num, th.Store FROM (pceipcTH) th " + ;
8123 " JOIN (pceipcCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
8124 " WHERE th.po_purp = '05' AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860' or cr.template = 'BURLINGTON 4010')"
8125
8126 llRetVal = llRetVal AND v_SQLExec(lcSQLString, "tc860TM",,true)
8127
8128 IF llRetVal AND RECCOUNT("tc860TM") > 0
8129 .cSQLTempTable = ""
8130 llRetVal = llRetVal AND .GenerateSQLTempTable("tc860TM")
8131 llRetVal = llRetVal AND .PopulateSQLTempTable("tc860TM")
8132
8133 lcSQLString = " SELECT DISTINCT th.division, th.customer, th.po_num, th.Store " + ;
8134 " FROM zzeipoth th " + ;
8135 " JOIN " + This.cSQLTempTable + " t " + ;
8136 " ON t.customer = th.customer " + ;
8137 " AND t.division = th.division " + ;
8138 " AND t.po_num = th.po_num "
8139
8140 llRetVal = llRetVal AND v_SQLExec(lcSQLString, "tc850")
8141
8142 SELECT tc850
8143 INDEX ON customer+division+po_num+store TAG cdp
8144
8145 SELECT tc860TM
8146 SCAN
8147 IF !SEEK(tc860TM.customer+tc860TM.division+tc860TM.po_num+tc860TM.store, "tc850", "cdp")
8148
8149 REPLACE errs_flg_h WITH 'Y', ;
8150 errs_msg_h WITH errs_msg_h + 'Replacement order for this PO is not found in the 850 Transaction Maintenance.' + CRLF ;
8151 FOR customer = tc860TM.customer AND division = tc860TM.division AND po_num = tc860TM.po_num AND store = tc860TM.store AND po_purp = '05' ;
8152 IN (pceipcTH)
8153
8154 ENDIF
8155 ENDSCAN
8156 .TableClose("tc860TM")
8157 ENDIF
8158 .TableClose("tc850")
8159 ENDWITH
8160
8161 SELECT (lnSelect)
8162 RETURN llRetVal
8163 ENDPROC
8164 *=== TechRec 1056904 24-Oct-2011 jisingh ===
8165
8166 *--- TR 1062197 7-Sep-2012 Goutam
8167 PROCEDURE ExplodeOrderForPOCStore
8168
8169 LOCAL llRetVal, lnSelect, lcSQLString, lcFilter
8170
8171 llRetVal = true
8172 lnSelect = SELECT()
8173
8174 WITH This
8175
8176 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
8177 lcFilter = STRTRAN(lcFilter,"Where","")
8178
8179 lcSQLString = "Update h set edi_store = poc_store FROM zzeipcth h " + ;
8180 " WHERE poc_purp = '04' and poc_store > '' and store = ''" + ;
8181 IIF(EMPTY(lcFilter),""," and " + lcFilter)
8182
8183 llRetVal = llRetVal and v_sqlexec(lcSQLString)
8184
8185 ENDWITH
8186
8187 SELECT (lnSelect)
8188 RETURN llRetVal
8189 ENDPROC
8190
8191 PROCEDURE CheckDistribution
8192 LPARAMETERS tcTransHeader
8193
8194 LOCAL llRetVal, lnSelect, lcSQLStoreStr, llVerifyDC, lcShipTo, lcStore, lcCustomer, lcStoreRef, lcShip_dc_Type, lcUpdateStr, ;
8195 lcCenter_Field, lcErrs_Msg
8196
8197 llRetVal = true
8198 lnSelect = SELECT()
8199
8200 WITH This
8201 Select distinct customer, store, poc_shipto, po_num ;
8202 From (tcTransHeader) Where !Empty(customer) AND !EMPTY(poc_shipto) Into Cursor tcTemp
8203 Select tcTemp
8204 SCAN
8205 lcCustomer = tcTemp.customer
8206 lcStore = tcTemp.store
8207 lcPO_num = tcTemp.po_num
8208 lcShipTo = tcTemp.poc_shipto && could be either EDI_STORE or EDI_CENTER
8209
8210 lcSQLStoreStr = "SELECT customer, store, edi_store " + ;
8211 "FROM zzxstorr WHERE customer = " + Sqlformatchar(lcCustomer) + " AND edi_store = " + Sqlformatchar(lcShipTo)
8212
8213 llRetVal = llRetVal And v_SQLExec(lcSQLStoreStr, "tcStorr")
8214
8215 lcStoreRef = iif(llRetVal and Used("tcStorr"), tcStorr.store, "")
8216
8217 * Set Verify DC flag
8218 llVerifyDC = .T.
8219
8220 IF !Empty(lcStoreRef) And (Allt(lcStoreRef) == Allt(lcStore))
8221 * do nothing to EDI_CENTER from transaction
8222 llVerifyDC= .F.
8223 ENDIF
8224
8225 If llVerifyDC
8226 * SHIPTO should be poc_shipto
8227 * Check poc_shipto
8228 lcErrs_Msg= ""
8229
8230 lcCenter_Field = 'tcTemp.poc_shipto'
8231 DO CASE
8232 CASE .ValidEDIDist_Cons(@lcErrs_Msg, lcCustomer, lcShipTo, "D", "tcDistr")
8233 * replace center_code with shipthru.center_code when found edi_center
8234 Replace center_code with tcDistr.center_code, poc_shipto WITH "" ;
8235 For Customer= lcCustomer and poc_shipto = lcShipTo and po_num= lcPO_num ;
8236 In (tcTransHeader)
8237 CASE .ValidEDIDist_Cons(@lcErrs_Msg, lcCustomer, lcShipTo, "C", "tcDistr")
8238 * replace center_code with shipthru.center_code when found edi_center
8239 Replace consol_code with tcDistr.center_code ;
8240 For Customer= lcCustomer and ;
8241 poc_shipto = lcShipTo and po_num= lcPO_num ;
8242 In (tcTransHeader)
8243 lcErrs_Msg = ""
8244 *- The shipto also can be a store. Check it last in case we set up both
8245 *- edi center and stroe with the same code. We do it sometimes.
8246 CASE .ValidEDIStore(@lcErrs_Msg, lcCustomer, lcShipTo, "tcDistr")
8247 Replace store with tcDistr.store, ;
8248 edi_store WITH tcDistr.edi_store, ;
8249 poc_store WITH IIF(EMPTY(poc_store),tcDistr.edi_store, poc_store), ;
8250 center_code with "", ;
8251 consol_code with "", ;
8252 poc_shipto WITH "" ;
8253 For Customer= lcCustomer ;
8254 and poc_shipto = lcShipTo and po_num= lcPO_num ;
8255 In (tcTransHeader)
8256 *=
8257 OTHERWISE
8258 lcErrs_Msg= "Invalid POC Ship To Code" + CRLF
8259 Replace Errs_msg_h With Errs_msg_h + lcErrs_Msg, Errs_Flg_H With "Y" ;
8260 For customer= lcCustomer and poc_shipto = lcShipTo and po_num= lcPO_num ;
8261 In (tcTransHeader)
8262 EndCase && ValidEDIDistribute()
8263
8264 Endif && llVerifyDC
8265
8266
8267 ENDSCAN
8268 ENDWITH
8269
8270 SELECT (lnSelect)
8271 RETURN llRetVal
8272 ENDPROC
8273
8274 ************************************************************************************
8275 * Valid EDI Distrubtion Center or Consolidator
8276 ************************************************************************************
8277 PROCEDURE ValidEDIDist_Cons
8278 Lparameter tcErrorMsg, tcCustomer, tcCenter_code, tcShip_DC, tcTmpTable
8279 Local llRetVal
8280
8281 llRetVal= !(Empty(tcCenter_code) or ;
8282 !vl_diste(tcCustomer, "", tcTmpTable, tcCenter_code, tcShip_DC))
8283 Return llRetVal
8284 EndProc
8285
8286 PROCEDURE ValidEDIStore
8287 Lparameter tcErrorMsg, tcCustomer, tcStore, tcTmpTable
8288 Local llRetVal
8289 llRetVal= vl_store(tcCustomer, "", tcTmpTable, tcStore)
8290 Return llRetVal
8291 EndProc
8292
8293 PROCEDURE UpdatePOCShiptoWithConsolCode
8294 LPARAMETERS tcTransHeader
8295
8296 LOCAL llRetVal, lnSelect
8297
8298 llRetVal = true
8299 lnSelect = SELECT()
8300
8301 WITH This
8302 replace poc_shipto WITH consol_code FOR errs_flg_h <> 'Y' AND Auto_proc = 'Y' AND !EMPTY(consol_code) AND !EMPTY(poc_shipto) IN (tcTransHeader)
8303 ENDWITH
8304
8305 SELECT (lnSelect)
8306 RETURN llRetVal
8307 ENDPROC
8308 *=== TR 1062197 7-Sep-2012 Goutam
8309
8310 *--- TR 1066871 8-May-2013 Goutam. This is local instances of SplitFlatFile from clsedi.prg
8311 Procedure SplitFlatFile
8312 Lparameters tcSource, tcRenameOnly
8313 Local llRetVal, lnOldSelect, lcEDIPath, lcSource, lnHandle, lnMaxBytes, lcBuffer, lcTag, lnTagPos, ;
8314 lnTagDelimPos, lcNewFileName, lcUniqueSuff, llEmptyFile, ll850Created, lcDoc_Num, ln2ndTagDelimPos, llNewHDR
8315
8316 lcUniqueSuff = Sys(2015)
8317 llEmptyFile = .f.
8318
8319 Declare laTags[1, 1]
8320 laTags = ""
8321 llRetVal = .T.
8322 lnOldSelect = Select()
8323 lcEDIPath = This.GetEDIFlatFileDirectory("Inbound")
8324 lcEDIPath = Iif(Right(Alltrim(lcEDIPath ), 1) = "\", Alltrim(lcEDIPath ), Alltrim(lcEDIPath ) + "\")
8325 lcSourceDat = Upper( lcEDIPath + Alltrim(tcSource) )
8326
8327 If File(lcSourceDat)
8328
8329 * If we've gotten to this point there's a flat file to
8330 * process, store it and use it later during our file rename.
8331 This.lDATExists = true
8332
8333 *lcSource = FORCEEXT(lcSourceDat, ".PRI") && rename .dat to .pri right away, new .dat may be on its way
8334 lcSource = Forceext(Alltrim(tcSource), ".PRI") && copy server side .dat to local .pri right away, new .dat may be on its way
8335
8336 lcSource = Iif(!tcRenameOnly, Stuff(lcSource,At(".",lcSource),0,lcUniqueSuff), Forceext(lcSourceDat, ".PRI"))
8337
8338 IF tcRenameOnly
8339 Copy File (lcSourceDat) To (lcSource)
8340 ENDIF
8341
8342 If !tcRenameOnly && need to split
8343
8344 * Remove source
8345 IF FILE(lcSource)
8346 DELETE FILE (lcSource)
8347 ENDIF
8348
8349 RENAME (lcSourceDat) To (lcSource)
8350
8351 IF FILE(lcSourceDat)
8352 RETURN false
8353 ENDIF
8354
8355 lnHandle = Fopen(lcSource)
8356 llRetVal = (lnHandle > 0)
8357 lnMaxBytes = 8192 && max bytes FGETS can read. It reads until CRLF is encountered inside the lnMaxBytes.
8358 lnPos = At(".", tcSource)
8359 llRetVal = llRetVal And (lnPos > 0)
8360
8361 IF llRetVal AND Feof(lnHandle)
8362 llEmptyFile = .t.
8363 ENDIF
8364
8365 If llRetVal
8366 Do While !Feof(lnHandle)
8367 lcBuffer = Fgets(lnHandle, lnMaxBytes) + CRLF && Store one line to string
8368
8369 *- Tag may be 2 or 3 characters
8370 lcTag = Left(lcBuffer, 3)
8371 lnTagDelimPos = At("|", lcBuffer)
8372 lcTag = Left(lcBuffer, lnTagDelimPos - 1)
8373 *==
8374
8375 IF lcTag == "850HDR"
8376 llNewHDR = true
8377 ENDIF
8378
8379 lcBufferData = Strtran(lcBuffer, CRLF)
8380 lcBufferData = Strtran(lcBufferData, "|", "")
8381 If Empty(lcBufferData) Or lcBufferData == lcTag && nothing except the tag
8382 Loop && skip empty line
8383 Endif
8384
8385 lnALen = Alen(laTags,1)
8386 If !Empty(laTags[1]) && at least one tag has been processed
8387 lnTagPos = Ascan(laTags, lcTag, 1, lnALen, 1, 6)
8388 Else && the first record.
8389 lnTagPos = 0
8390 lnALen = 0
8391 Endif
8392 If lnTagPos = 0
8393 *- define the split file name
8394
8395 lcSplitFName = Stuff(tcSource, lnPos, 0, lcTag + lcUniqueSuff )
8396
8397 lcSplitFile = Alltrim(Stuff(tcSource, lnPos, 0, lcTag))
8398
8399 *--- make sure the local unique file is deleted.
8400 Delete File (lcSplitFName)
8401 IF (!ll850Created OR !LEFT(lcSplitFName, 6) = "860850")
8402 Declare laTags[lnALen + 1, 3]
8403 laTags[lnALen + 1, 1] = lcTag
8404 laTags[lnALen + 1, 2] = lcSplitFile
8405 laTags[lnALen + 1, 3] = lcSplitFName
8406 ENDIF
8407 Else
8408 lcSplitFName = laTags[lnTagPos + 2]
8409 ENDIF
8410
8411 IF LEFT(lcSplitFName, 6) = "860850"
8412 lcNewFileName = "850.dat"
8413 ll850Created = true
8414
8415 lcBuffer = SUBSTR(lcBuffer, 4)
8416 lcTag = "850"
8417
8418 IF ASCAN(laTags,lcNewFileName) = 0
8419 Delete File (lcNewFileName)
8420
8421 laTags[lnALen + 1, 1] = lcTag
8422 laTags[lnALen + 1, 2] = lcNewFileName
8423 laTags[lnALen + 1, 3] = lcNewFileName
8424 ENDIF
8425
8426 IF llNewHDR
8427 llNewHDR = false
8428 lnTagDelimPos = At("|", lcBuffer)
8429 ln2ndTagDelimPos = At("|", lcBuffer,2)
8430 lcDoc_Num = SUBSTR(lcBuffer, lnTagDelimPos + 1, (ln2ndTagDelimPos - lnTagDelimPos - 1))
8431
8432 this.oLog.LogEntry("EDI 850 flat file created from EDI 860. Doc # :" + lcDoc_Num)
8433
8434 INSERT INTO (this.c850RefCursor) (doc_num, proc_850) VALUES (VAL(lcDoc_Num), 'Y')
8435 ENDIF
8436
8437 Strtofile(lcBuffer, lcNewFileName, .T.)
8438 ELSE
8439 Strtofile(lcBuffer, lcSplitFName, .T.)
8440 ENDIF
8441 Enddo
8442 Else
8443 Endif
8444 Fclose(lnHandle)
8445
8446 IF NOT llEmptyFile
8447
8448 *- Copy LOCAL .pri and split files to server to be renamed later.
8449 lcServerFile = Forceext(lcSourceDat, ".PRI")
8450 Copy File (lcSource) To (lcServerFile)
8451 Delete File (lcSource)
8452 lnALen = Alen(laTags,1)
8453 For N = 1 To lnALen
8454 lcSplitFile = laTags[n, 2]
8455 lcServerSplitFile = lcEDIPath + lcSplitFile
8456 lcSplitFName = laTags[n, 3]
8457 This.CopyToFlatFileInBlock(lcSplitFName, lcServerSplitFile)
8458 Delete File (lcSplitFName)
8459
8460 Endfor
8461 ELSE
8462 Delete File (lcSource)
8463 ENDIF
8464 Endif
8465 Endif
8466 Select (lnOldSelect)
8467 Return llRetVal
8468 Endproc
8469 *=== TR 1066871 8-May-2013 Goutam
8470
8471*--- TechRec 1073591 15-Oct-2013 TShenbagavalli ---
8472*===========================================================================================
8473 PROCEDURE ResolveCustShipper
8474 Lparameters pceipcTH, pceipcCR
8475 LOCAL lnSelect, llRetVal, lcSQLString
8476
8477 lnSelect = SELECT()
8478 llRetVal = True
8479
8480 WITH This
8481
8482 lcSQLString = " SELECT distinct h.customer, h.division, " + ;
8483 " h.cust_shipper " + ;
8484 " FROM " + pceipcTH + " h, " + pceipcCR + " r " + ;
8485 " WHERE r.resv_cust_ship = 'Y' and " + ;
8486 " NOT EMPTY(h.cust_shipper) and " + ;
8487 " h.customer = r.customer and " + ;
8488 " h.division = r.division "
8489
8490 llRetVal = v_SqlExec(lcSQLString, "_tmpCustShipper",,.T.)
8491
8492 INDEX ON customer + division + cust_shipper TAG 'cust_ship'
8493
8494 llRetVal= RECCOUNT('_tmpCustShipper') > 0 AND .SetRelation("_tmpCustShipper", "cust_ship", pceipcTH, "customer + division + cust_shipper")
8495
8496 IF llRetVal
8497 REPLACE ALL shipper WITH '' ;
8498 FOR !EOF('_tmpCustShipper') ;
8499 AND NOT EMPTY(cust_shipper) In (pceipcTH)
8500
8501 SET RELATION TO
8502 ENDIF
8503
8504 SELECT '_tmpCustShipper'
8505
8506 .cSQLTempTable = ""
8507
8508 IF .GenerateSQLTempTable('_tmpCustShipper')
8509 IF .PopulateSQLTempTable('_tmpCustShipper')
8510 IF !EMPTY(.cSQLTempTable)
8511
8512 lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
8513 " Coalesce(s1.shipper, s2.shipper, '') as shipper " + ;
8514 "from " + .cSQLTempTable + " t " + ;
8515 " left join zzecshpd s1 " +;
8516 " on s1.customer = t.customer " + ;
8517 " AND s1.division = t.division " + ;
8518 " AND s1.cust_shipper = t.cust_shipper " + ;
8519 " left join zzecshpd s2 " +;
8520 " on s2.customer = t.customer " + ;
8521 " AND s2.division = '' " + ;
8522 " AND s2.cust_shipper = t.cust_shipper "
8523
8524 llRetVal = v_SqlExec(lcSQLString, "_custShipper")
8525
8526 IF llRetVal and RECCOUNT('_custShipper') > 0
8527 SELECT _custShipper
8528 INDEX ON customer + division + cust_shipper TAG 'cust_ship'
8529 llRetVal= .SetRelation("_custShipper", "cust_ship", pceipcTH, "customer + division + cust_shipper")
8530 IF llRetVal
8531 Replace All shipper with _custShipper.shipper ;
8532 FOR !EOF('_custShipper') AND NOT EMPTY(cust_shipper) In (pceipcTH)
8533 SET RELATION TO
8534 ENDIF
8535 ENDIF
8536 ENDIF
8537 ENDIF
8538 ENDIF
8539
8540 USE in '_tmpCustShipper'
8541
8542 lcSQLString = " SELECT distinct h.customer, h.division, " + ;
8543 " h.cust_shipper " + ;
8544 " FROM " + pceipcTH + " h, " + pceipcCR + " r " + ;
8545 " WHERE r.resv_cust_ship = 'Y' and " + ;
8546 " NOT EMPTY(h.cust_shipper) and " + ;
8547 " h.customer = r.customer and " + ;
8548 " h.division = r.division and " + ;
8549 " EMPTY(h.shipper) "
8550
8551 llRetVal = v_SqlExec(lcSQLString, "_tmpCustShipper",,.T.)
8552
8553 INDEX ON customer + division + cust_shipper TAG 'cust_ship'
8554
8555 IF RECCOUNT('_tmpCustShipper') > 0
8556 llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipcTH, "customer + division + cust_shipper")
8557
8558 IF llRetVal
8559 Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
8560 Errs_flg_h WITH "Y" ;
8561 FOR customer = _tmpCustShipper.customer and ;
8562 division = _tmpCustShipper.division and ;
8563 NOT EMPTY(cust_shipper) AND ;
8564 cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipcTH)
8565
8566 SET RELATION TO
8567 ENDIF
8568
8569 ENDIF
8570
8571 ENDWITH
8572
8573 If Used("_tmpCustShipper")
8574 Use in '_tmpCustShipper'
8575 Endif
8576
8577 If Used("_custShipper")
8578 Use in '_custShipper'
8579 Endif
8580
8581 SELECT(lnSelect)
8582
8583 RETURN llRetVal
8584 ENDPROC
8585*============================================================
8586 PROCEDURE UpdateActualStoreDatawhseWithAllStoreDatawhse
8587 lPARAMETERS pceIPCth, pceIPCtd, pceIPCtwhse
8588
8589 *--- delete all ALL records from detail.
8590 *--- add "DI" notes from ALL records to actual store records.
8591 *--- create notes detail view
8592 *--- add detail notes from ALL store records to acutal store records.
8593
8594 LOCAL llRetVal, lnOldSelect, lcSQL
8595 llRetVal = .t.
8596 lnOldSelect = SELECT()
8597 *--- header view
8598 *--- find the notes of ALL headers
8599 LOCAL lcOldOrder
8600 SELECT (pceIPCth)
8601 lcOldOrder = ORDER()
8602 INDEX ON edi_store TAG edi_store
8603
8604 lcSQL = " SELECT h.customer, h.division, h.po_num, w.* from " + pceIPCtwhse + " w " + ;
8605 " inner join " + pceIPCth + " h on h.pkey = w.hfkey WHERE h.ForAllStore = 'Y' "
8606
8607 llRetVal = v_SqlExec(lcSQL, "tcIPCtwhse_add",,.T.)
8608
8609 IF RECCOUNT("tcIPCtwhse_add") > 0
8610 SELECT (pceIPCth)
8611 INDEX ON customer + division + po_num TAG custPoHdr
8612
8613 SELECT("tcIPCtwhse_add")
8614 SCAN
8615 SCATTER NAME loIPCtwhse_add memo
8616 SELECT(pceIPCth)
8617
8618 IF SEEK(loIPCtwhse_add.customer + loIPCtwhse_add.division + loIPCtwhse_add.PO_num, pceIPCth, "custPoHdr")
8619 SCAN WHILE customer + division + po_num = loIPCtwhse_add.customer + loIPCtwhse_add.division + loIPCtwhse_add.PO_num
8620 IF ForAllStore <> 'Y'
8621 loIPCtwhse_add.fkey = EVALUATE(pceIPCth + ".pkey")
8622 loIPCtwhse_add.pkey = v_nextPkey("ZZEIPCWHSE")
8623 SELECT(pceIPCtwhse)
8624 APPEND BLANK
8625 GATHER NAME loIPCtwhse_add memo
8626 ENDIF
8627 ENDSCAN
8628 ENDIF
8629 ENDSCAN
8630 ENDIF
8631
8632 lcSQL = " SELECT h.customer, h.po_num, d.upc, d.sku, d.ean, d.qualifier, n.* from " + pceIPCtwhse + " n " + ;
8633 " INNER JOIN " + pceIPCtd + " d ON d.pkey = n.dfkey " + ;
8634 " inner join " + pceIPCth + " h on h.pkey = d.fkey WHERE h.ForAllStore = 'Y' "
8635
8636 llRetVal = v_SqlExec(lcSQL, "tcWhseIPCD_add",,.T.)
8637
8638 IF RECCOUNT("tcWhseIPCD_add") > 0
8639 SELECT (pceIPCth)
8640 INDEX ON customer + po_num TAG custPo
8641 *--- IPC tran detail whse
8642 SELECT(pceIPCtd)
8643 SELECT("tcWhseIPCD_add")
8644 SCAN
8645 SCATTER NAME loWhseIPCD_add memo
8646 SELECT(pceIPCth)
8647 IF SEEK(loWhseIPCD_add.customer + loWhseIPCD_add.PO_num, pceIPCth, "custPo")
8648 SCAN WHILE customer + Po_num = loWhseIPCD_add.customer + loWhseIPCD_add.PO_num
8649
8650 IF ForAllStore <> 'Y'
8651 lnPkey_IPCH = pkey
8652 SELECT(pceIPCtd)
8653 IF SEEK(lnPkey_IPCH,pceIPCtd,"fkey")
8654 SCAN WHILE fkey = lnPkey_IPCH
8655 IF upc + sku + ean + qualifier = loWhseIPCD_add.upc + ;
8656 loWhseIPCD_add.sku + loWhseIPCD_add.ean + loWhseIPCD_add.qualifier
8657 loWhseIPCD_add.fkey = EVALUATE(pceIPCtd + ".pkey")
8658 loWhseIPCD_add.pkey = v_nextPkey("ZZEIPCWHSE")
8659 SELECT(pceIPCtwhse)
8660 APPEND BLANK
8661 GATHER NAME loWhseIPCD_add memo
8662 ENDIF
8663 ENDSCAN
8664 ENDIF
8665 ENDIF
8666 ENDSCAN
8667 ENDIF
8668 ENDSCAN
8669 ENDIF
8670 SELECT(lnOldSelect)
8671 RETURN llRetVal
8672 ENDPROC
8673
8674*===========================================================================================
8675*=== TechRec 1073591 15-Oct-2013 TShenbagavalli ===
8676
8677ENDDEFINE
8678*===========================================================================
8679
8680*- 1014475 12/20/05 YIK
8681*- Create new class, subclass of clscancl.
8682*- put this FUNCTION DeclareViewsAndCursors in there.
8683DEFINE CLASS BPOicProcess_860 AS BPOCancel
8684 FUNCTION DeclareViewsAndCursors
8685 WITH THIS
8686 DIMENSION .aRatioViews[RATIO_VIEWS]
8687 .aRatioViews[RATIO_ZZOORDRH] = "Vzzoordrh_Ratio_Confirm"
8688 .aRatioViews[RATIO_ZZOORDRD] = "Vzzoordrd_Ratio_Confirm"
8689 .aRatioViews[RATIO_ZZOORDSP] = "Vzzoordsp_Ratio_Confirm"
8690 .aRatioViews[RATIO_ZZOOPENH] = "VtcOpenH_Ratio_Confirm"
8691 .aRatioViews[RATIO_ZZOOPEND] = "VtcOpenD_Ratio_Confirm"
8692 .aRatioViews[RATIO_ZZOORDWH] = "Vzzoordwh_Ratio_Confirm"
8693 .aRatioViews[RATIO_ZZOORDWD] = "Vzzoordwd_Ratio_Confirm"
8694 .aRatioViews[RATIO_ZZXNIBLR] = "Vzzxniblr_Ratio_Confirm"
8695
8696 DIMENSION .aRatioCursors[RATIO_CURSORS]
8697 .aRatioCursors[RATIO_ZZOORDOH] = "Vzzoordoh_Ratio_Confirm"
8698 .aRatioCursors[RATIO_ZZOORDOD] = "Vzzoordod_Ratio_Confirm"
8699 .aRatioCursors[RATIO_ZZOUNITS] = "Vzzounits_Ratio_Confirm"
8700
8701 *--- TechRec 1022069 12-Apr-2007 kpattabiraman ---
8702 IF TYPE("this.lUseFRMCode") = "L" AND this.lUseFRMCode
8703 lnRatioViews = ALEN(.aRatioViews)
8704 This.nRatioFrmChrg = lnRatioViews + 1
8705 DIMENSION .aRatioViews[This.nRatioFrmChrg]
8706
8707 .aRatioViews[This.nRatioFrmChrg] = This.cFrmChrgView
8708 ENDIF
8709 *=== TechRec 1022069 12-Apr-2007 kpattabiraman ===
8710
8711 *--- TR 1031103 2-May-2008 Goutam
8712 lnRatioViews = ALEN(.aRatioViews)
8713 This.nRatioChrgDtl = lnRatioViews + 1
8714 DIMENSION .aRatioViews[This.nRatioChrgDtl]
8715 .aRatioViews[This.nRatioChrgDtl] = This.cDtlChrgView
8716 *=== TR 1031103 2-May-2008 Goutam
8717 ENDWITH
8718
8719ENDDEFINE