· 7 years ago · Sep 18, 2018, 07:12 PM
1**********************************************************************************************
2* Program....: clsIpopr_PreValidation.PRG
3* Author.....: Nasim Huq
4* Date.......: Nov, 2008
5* Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
6* Techreq....: 1032800
7* Abstract...: EDI 850 inbound Pre-Validation
8* Changes....:
9***********************************************************************************************
10
11#include edi.h
12#include system.h
13
14#Define LARGEST_DATE {^2999-01-01}
15#Define EDI_NOT_PROCESSORIGINAL_MSG "Control Flag set to Not Process Original EDI orders into Live Table."
16#Define EDI_NOT_PROCESSCONFIRM_MSG "Control Flag set to Not Process Confirm EDI orders into Live Table."
17#Define EDI_NOT_PROCESSDUPLICATE_MSG "Control Flag set to Not Process Duplicate EDI orders into Live Table."
18#Define NOT_YET_PROCESS "Not yet process."
19#Define NO_UOM_CONVERSION_REF "Require Style UOM."
20#Define UOM_NOT_DIVISIBLE "Total Units must be divisible by "
21#Define NO_UOM_CONVERSION_FACTOR "No conversion factor."
22#Define NO_PREPACK "Unable to determine Prepack code." && 30854 3/25/02
23
24#Define EDI_BULK_ORDER "BK"
25#Define EDI_BLANKET_ORDER "BL"
26*- 1002007 11/13/03 YIK
27#Define EDI_DISCOUNT_CODE "EDI"
28
29
30Define Class clsIpopr_PreValidation As clsIpopr_delegatebase
31
32 oResolvePrepack = Null
33
34 *--- TR 1045965 09-MAR-2010 HNISAR
35 lFrom940i = False
36 *=== TR 1045965 09-MAR-2010 HNISAR
37
38 *--- TechRec 1030517 25-Aug-2010 jisingh ---
39 c850Control = ""
40 *=== TechRec 1030517 25-Aug-2010 jisingh ===
41
42 cImplodeSQL = ""
43 cImplodeRangeSQL = "" &&--- TechRec 1073664 20-Sep-2013 GSternik ===
44
45 *--- TR 1065217 27-Nov-2012 BNarayanan ---
46 nMaxStylesImplode = 0
47 *=== TR 1065217 27-Nov-2012 BNarayanan ===
48
49 *--- TechRec 1089737 20-Nov-2015 jisingh ---
50 cOverridePpkAction = ""
51 *=== TechRec 1089737 20-Nov-2015 jisingh ===
52
53 *--- TechRec 1090303 08-Jan-2016 jisingh ---
54 lValidateDivision = false
55 *=== TechRec 1090303 08-Jan-2016 jisingh ===
56
57 *--------------------------------------------------------------------------
58
59 Procedure Init
60 Lparameters toHostProcess
61 LOCAL llRetVal
62 llRetVal = .t.
63 llRetVal = llRetVal and DODEFAULT(toHostProcess)
64
65 *--- TR 1052729 10-Mar-11 SK
66 This.oPopulateSqlTempTable = Null
67
68 *--- TR 1065271 27-Nov-2012 BNarayanan ---
69 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
70 *=== TR 1065271 27-Nov-2012 BNarayanan ===
71
72 this.GetImplodeSQL()
73
74 RETURN llRetVal
75 Endproc
76
77 *--------------------------------------------------------------------------
78
79 *-- [Main procedure]
80 Procedure PreValidation
81 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
82 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
83 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
84 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
85 Local llRetVal, lcSQLSelect, lcSQLOrder
86 llRetVal = .T.
87 PRIVATE vcLogName
88 vcLogName = this.cLogName
89 With This
90 .LogEntry("Resetting all error messages in transaction tables.")
91 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
92 vcLogName)
93 *--- TechRec 1005163 17-May-2004 GS ---
94 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
95 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
96 *=== TechRec 1005163 17-May-2004 GS ===
97
98 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
99 vcLogName)
100
101 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
102 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
103 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
104 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
105
106 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
107 vcLogName)
108 *--- TechRec 1005163 17-May-2004 GS ---
109 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
110 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
111 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
112 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
113 *=== TechRec 1005163 17-May-2004 GS ===
114 Endwith
115 Return llRetVal
116 Endproc
117
118 *--------------------------------------------------------------------------
119
120 * Clear all previous errors
121 Procedure ClearErrors
122 Lparameters pceipoTH, pceipoTD,;
123 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
124 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
125 Local llRetVal, lnOldSelect, laTables[2]
126 llRetVal = .T.
127 lnOldSelect = Select()
128 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
129 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
130 * we don't allow explosion happen again therefore cannot clearout division)
131 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
132 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
133 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
134 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
135 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
136 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
137 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
138 *=== 1010206 11/10/2005 Ilya.
139
140 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
141
142 *--- TR 1064141 3-Oct-2012 Goutam
143 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
144 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
145
146 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
147 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
148 *=== TR 1064141 3-Oct-2012 Goutam
149
150 *=== TR 1003801 - BD
151 *--- TechRec 1005163 17-May-2004 GS ---
152 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
153 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
154 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
155 *=== TechRec 1005163 17-May-2004 GS ===
156
157 *--- TechRec 1028745 05-Feb-2008 GSternik ---
158 If .oHostProcess.lHaveChrgs
159 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
160 Endif
161 *=== TechRec 1028745 05-Feb-2008 GSternik ===
162
163 *---TR 1008342 10-JAN-2005 RG
164 Replace All Pending_Flg With 'N' In (pceipoTH)
165 *===TR 1008342 10-JAN-2005 RG
166
167 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
168 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
169 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
170 IN (pceipoTH)
171 *=== TR 1073346 05-Sep-13 SK
172
173 *- 1041285 07/10/09 YIK
174 *- Populate force errors into error fields
175 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
176 FOR Errs_flg_fh = 'Y' ;
177 IN (pceipoTH)
178
179 *--- TR 1043191 23-Oct-2009 JK ---
180 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
181 *=== TR 1043191 23-Oct-2009 JK ===
182
183 Select(lnOldSelect)
184 Return llRetVal
185 Endproc
186
187 *--------------------------------------------------------------------------
188
189 ************************************************************************************
190 * Error check EDI headers
191 ************************************************************************************
192 Procedure CheckHeader
193 Lparameters pceipoTH, pceipoCR, pceipoTD
194 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
195
196 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
197 llRetVal = .T.
198 lnOldSelect = Select()
199 With This
200
201 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
202 *--- LOCAL MOD
203 *If llRetVal And .lRBACustSku
204 If llRetVal And .oHostProcess.lRBACustSku
205 .LogEntry("Resolve RBA Customer")
206 llRetVal= .ResolveBCCustomer(pceipoTH)
207 Else
208 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
209
210 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
211
212 *--- TR 1045965 09-MAR-2010 HNISAR
213*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
214 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
215 *=== TR 1045965 09-MAR-2010 HNISAR
216
217 If llRetVal
218 .LogEntry("Validating customer.")
219 llRetVal= .CheckCustomer(pceipoTH)
220 *- 01/29/02 YIK TAN 29056
221 If llRetVal
222 .LogEntry("Verifying Multiple customer.")
223 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
224 *= TAN 29056
225 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
226 Endif
227 Endif
228 Endif
229 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
230
231 *--- TR 1041542 NSD 7/22/09
232 IF llRetVal
233 .LogEntry("Resolving Register Number")
234 llRetVal = .ResolveRegisterNumber(pceipoTH)
235 ENDIF
236 *=== TR 1041542 NSD 7/22/09
237
238 If llRetVal
239 .LogEntry("Validating EDI store.")
240 llRetVal= .CheckStore(pceipoTH, pceipoCR)
241 If llRetVal
242 .LogEntry("Validating EDI center.")
243 llRetVal= .CheckDistribution(pceipoTH)
244 *- 1007452 10/22/04 YIK
245 *- Checking notes type
246 If llRetVal
247 .LogEntry("Validating Header Notes type.")
248 llRetVal= .CheckNoteType(pceipoTH)
249 Endif
250 *= 1007452
251 Endif
252 Endif
253
254 *--- TR 1022625 4-Mar-2007 TT
255 If llRetVal
256 .LogEntry("Checking for Terminations in PO_TYPE")
257 llRetVal= .CheckTerminationInPoType(pceipoTH)
258 Endif
259
260 *--- TR 1022625 4-Mar-2007 TT
261 *!* ENDIF
262 *!* ENDIF
263
264 *--- TR 1030441 17-Apr-2008 Goutam
265 If llRetVal
266 .LogEntry("Validating shipper code.")
267 llRetVal= .CheckShipper(pceipoTH)
268 Endif
269 *=== TR 1030441 17-Apr-2008 Goutam
270
271 *--- TechRec 1066487 05-Feb-2013 MANI. ---
272 IF llRetVal
273 .LogEntry("Validating Location.")
274 llRetVal= .ValidateLocation(pceipoTH)
275 Endif
276 *=== TechRec 1066487 05-Feb-2013 MANI. ===
277
278 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
279 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
280*!* If llRetVal
281*!* .LogEntry("Validating 855 Header status code.")
282*!* llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
283*!* ENDIF
284 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
285 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
286
287 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
288 * TR 1037925 - As per Krishna/Shenba
289 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
290 * This is getting moved in TR 1037925
291*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
292*!* IF llRetVal
293*!* .LogEntry("Resolving Customer Shipper.")
294*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
295*!* ENDIF
296*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
297 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
298
299 *- TR 1111325 FH
300 llRetVal = llRetVal AND .ResolveControlPkey(pceipoTH)
301 Endwith
302 Select(lnOldSelect)
303 Return llRetVal
304 Endproc
305
306 *--------------------------------------------------------------------------------------
307
308 Function ResolveBCCustomer
309
310 Lparameters pceipoTH
311 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
312
313 llRetVal = True
314 lnSelect = Select()
315 With This
316 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
317 lcSQLString = " Select * From ZZXCSTCR "
318 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
319
320 If llRetVal
321 lcCursor = GetUniqueFileName()
322
323 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
324
325 Select lcCursor
326 lcErrs_Msg = " No matching record in Customer Store cross reference "
327
328 lnCnt = Recc()
329 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
330
331 Scan
332 lccustomer = Alltrim(rtl_cust)
333 lcDepartment = Alltrim(rtl_dept)
334 lcOrd_type = Alltrim(rtl_ord_type)
335
336 .LogEntry("Retail Customer: " + lccustomer )
337 .LogEntry("Retail Dept: " + lcDepartment)
338 .LogEntry("Retail order type: " + lcOrd_type)
339
340 Select tcCustcr
341 .LogEntry("Select: tcCustcr")
342
343 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
344 If Not Found()
345 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
346 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
347 IN (pceipoTH)
348 .LogEntry(lcErrs_Msg)
349 Else
350 lcBCCustomer = tcCustcr.customer
351 lcBCEDIStore = tcCustcr.Store
352
353 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
354
355 * TR 1019260 Added- , ord_type WITH '' ;
356
357 Replace customer With lcBCCustomer ;
358 EDI_STORE With lcBCEDIStore , ord_type With '' ;
359 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
360 IN (pceipoTH)
361
362 Endif
363 Endscan
364 .TableClose(lcCursor)
365 .TableClose("tcCustcr")
366
367 Endif
368 Endwith
369
370 Select (lnSelect)
371 Return llRetVal
372 Endfunc
373
374 *-----------------------------------------------------------------------------------
375
376 * TAN 29056 YIK
377 Procedure CheckForMultiCust
378 Lparameter pceipoTH, pceipoCR
379 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
380 llRetVal, llMultiCust
381 Private pcCustomer
382
383 lnSelect = Select()
384 Select (pceipoCR)
385 Scan For mult_cust = 'Y'
386
387 *--- TR 1031442 25-Jun-2008 Goutam
388 *llMultiCust = .T.
389 *--- TR 1031442 25-Jun-2008 Goutam
390
391 pcCustomer = customer
392 lcDiv = division
393 lcCursor = GetUniqueFileName()
394 *- YIK 01/30/02
395 *- We may have multiple POs/regions per customer in one tceipoth file
396 Select Distinct Region From (pceipoTH) ;
397 WHERE customer = pcCustomer ;
398 AND !Empty(Region) ;
399 INTO Cursor &lcCursor
400 Select (lcCursor)
401 Scan
402
403 *--- TR 1031442 25-Jun-2008 Goutam
404 llMultiCust = .T.
405 *--- TR 1031442 25-Jun-2008 Goutam
406
407 pcRegion = Region
408 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
409 Replace &pceipoTH..customer With lcNewCustID ;
410 FOR customer = pcCustomer And Region = pcRegion;
411 IN (pceipoTH)
412 Endscan
413 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
414 Select (pceipoCR)
415 Endscan
416 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
417 Select (lnSelect)
418 Return llRetVal
419 Endproc
420
421 *-----------------------------------------------------------------------------------
422
423 Procedure CheckStore
424 Lparameters pcHeader, pcControl
425 Local llRetVal, lnOldSelect
426 llRetVal= .T.
427 lnOldSelect= Select()
428
429 * 1st - group get store using cust,edi_store but not overwrite existing store
430 * users could change store in Trans Maint.
431 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
432 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
433 Select __TmpCursor
434 With This
435 .cSQLTempTable=""
436 If .GenerateSQLTempTable('__TmpCursor')
437 If .PopulateSQLTempTable('__TmpCursor')
438 If !Empty(.cSQLTempTable)
439 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
440 * also, populate center_code, consol_code if empty
441 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
442 " from zzxstorr s, " + .cSQLTempTable + " t " +;
443 "Where s.customer= t.customer and s.edi_store= t.edi_store"
444 llRetVal = v_SqlExec(lcSQLString, "_Storr")
445 If llRetVal
446 Select _Storr
447 Index On customer+EDI_STORE Tag CustStore
448 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
449 "customer+edi_store")
450 If llRetVal
451 Select (pcHeader)
452
453
454 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
455 * Otherwise we will not be able to resolve currency later and that will
456
457
458 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
459 * Confirm order(with store) for the same customer
460 * the Bulk order will have "Invalid Store" message.
461 * Only Scan for !Empty(edi_store)
462 Scan For !Empty(EDI_STORE)
463 Do Case
464 Case Empty(_Storr.customer)
465 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
466 Errs_flg_h With "Y" In (pcHeader)
467 Case _Storr.active_ok <> 'Y'
468 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
469 Errs_flg_h With "Y" In (pcHeader)
470 Otherwise
471 If Empty(Store) && don't want to overwrite previous data
472 Replace Store With _Storr.Store
473 Endif
474 *- YIK 1017307 07/18/06
475 *- Added AND EMPTY(edi_center)
476 *--- TR 1042564 14-Sep-2008 JK ---
477 * if the dts flag on the order is not Y, then populate.
478 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
479 *=== TR 1042564 14-Sep-2008 JK ===
480 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
481 Replace center_code With _Storr.center_code
482 Endif
483 If Empty(consol_code) And !Empty(_Storr.consol_code)
484 Replace consol_code With _Storr.consol_code
485 Endif
486 *--- TR 1042564 14-Sep-2008 JK ---
487 ENDIF
488 *=== TR 1042564 14-Sep-2008 JK ===
489 *== 1009508
490 Endcase
491
492 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
493
494 Endscan
495 Set Relation To
496 Use In _Storr
497 Endif
498 Endif
499 Endif
500 Endif
501 Endif
502 Endwith
503 If Used("__TmpCursor")
504 Use In __TmpCursor
505 Endif
506
507 * 2nd - validate store by cust,store
508 * Notes: cannot reuse the above server side cursor because have
509 * to resolve it to tran header local 1st before validate happen
510 Select Distinct customer, Store From (pcHeader) ;
511 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
512 Select __TmpCursor
513 With This
514 .cSQLTempTable=""
515 If .GenerateSQLTempTable('__TmpCursor')
516 If .PopulateSQLTempTable('__TmpCursor')
517 If !Empty(.cSQLTempTable)
518 lcSQLString= "Select s.customer, s.store " +;
519 " from zzxstorr s, " + .cSQLTempTable + " t " +;
520 "Where s.customer= t.customer and s.store= t.store"
521 llRetVal = v_SqlExec(lcSQLString, "_Storr")
522 If llRetVal
523 Select _Storr
524 Index On customer+Store Tag CustStore
525 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
526 "customer+store")
527 If llRetVal
528 Select (pcHeader)
529 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
530 * Confirm order(with store) for the same customer
531 * the Bulk order will have "Invalid Store" message.
532 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
533 * Don't have conf_type as "A" or "B" yet
534 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
535 *- assortment orders with no store.
536
537 *--- TR1055827 NSD/FGCjr
538 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
539 SCAN FOR (NOT (po_type= EDI_BLANKET_ORDER OR po_type= EDI_BULK_ORDER OR EMPTY(EDI_STORE))) OR (conf_type = 'A' AND NOT EMPTY(store) AND EMPTY(edi_store))
540 *=== TR1055827
541 If Empty(_Storr.customer)
542 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
543 Errs_flg_h With "Y" In (pcHeader)
544 Endif
545 Endscan
546 Set Relation To
547 Use In _Storr
548 Endif
549 Endif
550 Endif
551 Endif
552 Endif
553 Endwith
554 If Used("__TmpCursor")
555 Use In __TmpCursor
556 Endif
557
558 If Used("_Storr")
559 Use In _Storr
560 Endif
561
562 Select(lnOldSelect)
563 Return llRetVal
564 Endproc
565
566 *------------------------------------------------------------------------------------------
567
568 ************************************************************************************
569 * Validate EDI Distribution Center
570 * ATS# 2757 PL 06/09/99- validate against edi_center
571 * use edi_center in tran header for validation, when found
572 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
573 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
574 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
575 ************************************************************************************
576 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
577 * 1. Select Distinct customer, distribution center from work header.
578 * 2. Check for valid distribution center. If faile the check update all headers for
579 * the same customer, distribution center with "Invalid Store code." and
580 * Errs_Flg with "Y"
581 * Return: True= All pass validation
582 * False= If one of them fail the check
583 ************************************************************************************
584 Procedure CheckDistribution
585 Lparameters pceipoTH
586 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
587 llRetVal = .T.
588 lnOldSelect = Select()
589
590 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
591 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
592 Into Cursor CntrList
593 Select CntrList
594 If This.lUserInterface
595 * Init Thermometer
596 This.UpdateThermoCaption("Validating Distribution Center(s)...")
597 * TAN 31891 - JAZ - 5/20/02
598 * This.InitThermo(RECC('CntrList'))
599 This.InitThermo(Reccount('CntrList'))
600 * End TAN 31891 - JAZ - 5/20/02
601 l_nThermoCnt = 0
602 Endif
603 Scan
604 If This.lUserInterface
605 * Advance progress bar, if we're using one.
606 l_nThermoCnt = l_nThermoCnt + 1
607 This.AdvanceThermo(l_nThermoCnt)
608 Endif
609 * Empty(center_code) resolve using edi_center
610 If Empty(center_code)
611 lcErrs_Msg= ""
612 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
613 lcErrs_Msg= lcErrs_Msg + CRLF
614 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
615 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
616 IN (pceipoTH)
617 Else
618 * replace center_code with shipthru.center_code when found edi_center
619 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
620 * COMMENT OUT replace ship_dc with "D" also.
621 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
622 * Do not update center code unless dts_flag <> Y
623 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
624 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
625 IN (pceipoTH)
626
627 Endif
628 Else
629 * user may overwrite with wrong center_code, validate distribution center
630 lcErrs_Msg= ""
631 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
632 lcErrs_Msg= lcErrs_Msg + CRLF
633 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
634 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
635 IN (pceipoTH)
636 Endif
637 Endif
638
639 Endscan
640 Use In CntrList
641
642 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
643 * also, populate center_code, consol_code if empty
644 * populate Ship_dc base on center/consol_code
645 Select (pceipoTH)
646 Scan
647 lcShip_dc = ""
648 *- 1009508 03/16/05
649 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
650 *-- DO CASE
651 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
652 *-- lcShip_dc = "B"
653 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
654 *-- lcShip_dc = "D"
655 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
656 *-- lcShip_dc = "C"
657 *-- ENDCASE
658
659 If !Empty(center_code) Or !Empty(consol_code)
660 Do Case
661 Case !Empty(center_code) And !Empty(consol_code)
662 lcShip_dc = "B"
663 Case !Empty(center_code) And Empty(consol_code)
664 lcShip_dc = "D"
665 Case Empty(center_code) And !Empty(consol_code)
666 lcShip_dc = "C"
667 Endcase
668 *= 1009508 YIK
669 If !Empty(lcShip_dc)
670 Replace ship_dc With lcShip_dc In (pceipoTH)
671 Endif
672 Endif
673 Endscan
674
675 If This.lUserInterface
676 * Reset Thermometer
677 This.ResetThermo()
678 Endif
679
680 If Used("CntrList")
681 Use In CntrList
682 Endif
683 If Used("tcDistr")
684 Use In tcDistr
685 Endif
686 Select(lnOldSelect)
687 Return llRetVal
688 Endproc
689
690 *---------------------------------------------------------------------------------
691
692 Procedure CheckNoteType
693 Lparameters tcEiPOth
694 Local llRetVal, lcNotes, laNotes
695 llRetVal = .T.
696 Select (tcEiPOth)
697 Scan For !Empty(notes)
698 lcNotes = notes
699 Declare laNotes[2]
700 laNotes = ""
701 If At("|", lcNotes) > 0 && has note_type
702 *- 1030497 02/29/08 TT
703 *--StringToArray(lcNotes, @laNotes, "|")
704 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
705 *- 1030497 02/29/08 TT
706 lnNotes = Alen(laNotes)/2
707 For lnCnt = 1 To lnNotes
708 If !vl_notyp(laNotes[2*lnCnt - 1])
709 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
710 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
711 Endif
712 Endfor
713 Endif
714 Endscan
715 Return llRetVal
716 Endproc
717 *---------------------------------------------------------------------------------
718
719 *--- TR 1022625 4-Mar-2007 TT
720 Function CheckTerminationInPoType
721 Lparameters pceipoTH
722 LOCAL llRetVal, lnOldSelect
723 lnOldSelect = SELECT()
724 llRetVal = .t.
725 Local lnLastOrder
726 Select (pceipoTH)
727 lnLastOrder = Order()
728 Set Order To Tag po_type
729 If Seek("TR", pceipoTH, "po_type")
730 Scan While po_type = 'TR'
731 Replace Errs_msg_H With Errs_msg_H + ;
732 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
733 Errs_flg_h With "Y" In (pceipoTH)
734 Endscan
735 Endif
736 Set Order To lnLastOrder
737 SELECT(lnOldSelect)
738 RETURN llRetVal
739 Endfunc
740 *--- TR 1022625 4-Mar-2007 TT
741
742 *---------------------------------------------------------------------------------
743
744 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
745 PROCEDURE Validate855Status
746 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
747
748 Local llRetVal, lnOldSelect, lcSourceFilter
749 llRetVal= true
750 lnOldSelect= Select()
751
752 IF pcHeaderDetail = 'H'
753 SELECT Distinct status_855 FROM (pcHeader) ;
754 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
755 lcSourceFilter = " s.source = 'BAK02'"
756 ELSE
757 SELECT DISTINCT d.status_855 ;
758 FROM (pcDetail) d ;
759 JOIN (pcHeader) h ;
760 ON h.pkey = d.fkey ;
761 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
762 INTO CURSOR __tmp855Status
763 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
764 ENDIF
765
766 SELECT __tmp855Status
767 WITH This
768 .cSQLTempTable=""
769 IF .GenerateSQLTempTable('__tmp855Status')
770 IF .PopulateSQLTempTable('__tmp855Status')
771 IF !EMPTY(.cSQLTempTable)
772
773 lcSQLString= "Select s.status_855 from " +;
774 " zzeopakr s, " + .cSQLTempTable + " t " +;
775 "Where s.status_855 = t.status_855 and " + lcSourceFilter
776
777 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
778 IF llRetVal
779 SELECT _Ststus855
780 INDEX On status_855 TAG status_855
781 IF pcHeaderDetail = 'H'
782 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
783 ELSE
784 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
785 ENDIF
786
787 IF llRetVal
788 IF pcHeaderDetail = 'H'
789 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
790 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
791 ELSE
792 *- TR 1083937 FH - added INLIST(status_855,'AK','RJ'
793 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
794 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) ;
795 AND NOT INLIST(status_855,'AK','RJ') In (pcDetail)
796
797 * mark headers errors here as the Run855Process which runs next will rely on header errors.
798 SELECT (pcDetail)
799 SCAN FOR errs_flg_d = 'Y'
800 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
801 AND EVALUATE(pcHeader+'.req_855') = 'R'
802 ENDSCAN
803 ENDIF
804
805 SET RELATION TO
806 ENDIF
807 ENDIF
808 ENDIF
809 ENDIF
810 ENDIF
811 ENDWITH
812
813 IF USED("__tmp855Status")
814 USE IN __tmp855Status
815 ENDIF
816 IF USED("_Ststus855")
817 USE IN _Ststus855
818 ENDIF
819
820 Select(lnOldSelect)
821 Return llRetVal
822 ENDPROC
823 *=== TR 1074251 03-Jan-2014 Goutam
824
825 *---------------------------------------------------------------------------------
826
827 *--- TR 1030441 17-Apr-2008 Goutam
828 Procedure CheckShipper
829 LPARAMETERS pcHeader
830 Local llRetVal, lnOldSelect
831 llRetVal= true
832 lnOldSelect= Select()
833
834 SELECT Distinct shipper FROM (pcHeader) ;
835 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
836
837 SELECT __tmpShipper
838 WITH This
839 .cSQLTempTable=""
840 IF .GenerateSQLTempTable('__tmpShipper')
841 IF .PopulateSQLTempTable('__tmpShipper')
842 IF !EMPTY(.cSQLTempTable)
843 lcSQLString= "Select s.shipper from " +;
844 " zzxshipr s, " + .cSQLTempTable + " t " +;
845 "Where s.shipper= t.shipper"
846 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
847 IF llRetVal
848 SELECT _Shiper
849 INDEX On shipper TAG Shipper
850 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
851 IF llRetVal
852 SELECT (pcHeader)
853 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
854 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
855 SET RELATION TO
856 ENDIF
857 ENDIF
858 ENDIF
859 ENDIF
860 ENDIF
861 ENDWITH
862
863 IF USED("__tmpShipper")
864 USE IN __tmpShipper
865 ENDIF
866 IF USED("_Shiper")
867 USE IN _Shiper
868 ENDIF
869
870 Select(lnOldSelect)
871 Return llRetVal
872 Endproc
873 *=== TR 1030441 17-Apr-2008 Goutam
874
875 *---------------------------------------------------------------------------------
876
877 ************************************************************************************
878 * Error check all raw EDI details
879 ************************************************************************************
880 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
881 * Move codes to CheckUPC() and CheckSKU()
882 * Add:ResolveCustomerLabel()
883 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
884 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
885 * [div,sty,col,lbl,dim,size] allow or not
886 *
887 Procedure CheckDetail
888 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
889 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
890 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
891 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
892 Local llRetVal, lnOldSelect
893 llRetVal = .T.
894 lnOldSelect = Select()
895 With This
896 *--- TechRec 1048792 17-Dec-2010 jisingh ---
897 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
898 *=== TechRec 1048792 17-Dec-2010 jisingh ===
899
900 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
901 *--- TR 1019697 NH
902 .LogEntry("Cascading Customer To Detail.")
903 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
904 .LogEntry("Cascading Customer To SLN.")
905 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
906 *=== TR 1019697 NH
907 *=== TechRec 1048667 03-May-2011 GSternik ===
908
909
910 *--- TechRec 1024522 18-Sep-2007 GSternik ---
911 *--- LOCAL MOD
912 *If This.lHaveSLN
913 If This.oHostProcess.lHaveSLN
914 .LogEntry("Resolving SLNs/Prepack Style.")
915 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
916 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
917 EndIf
918 *=== TechRec 1024522 18-Sep-2007 GSternik ===
919
920 .LogEntry("Resolving style using UPC.")
921 *--- TechRec 1005163 17-May-2004 GS ---
922 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
923 *--- TR 1019697 NH
924 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
925 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
926*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
927 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
928 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
929
930 *--- TR 1036917 04-Feb-2009 Partha ---
931 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
932 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
933
934 *=== TR 1036917 04-Feb-2009 Partha ===
935
936 *=== TR 1019697 NH
937 *=== TechRec 1005163 17-May-2004 GS ===
938 *--- TR 1023892 NH
939 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
940 *=== TR 1023892 NH
941
942 *--- TR 1044885 13-JAN-2010 BR Moved from above
943 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
944
945 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
946 *--- TechRec 1005163 17-May-2004 GS ---
947 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
948 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
949 *=== TechRec 1005163 17-May-2004 GS ===
950 *= 39222
951
952 *- TR 1003801 - 03/25/04 BD - Resolve EAN
953 .LogEntry("Resolving style using EAN.")
954
955 *--- TechRec 1005163 17-May-2004 GS ---
956 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
957 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
958 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
959 *=== TR 1061652 05/18/12 ATHIRUNAVU
960
961 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
962 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
963 *--- TR 1035223 NH
964 .LogEntry("Setting Skip SLN Check flag.")
965 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
966 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
967 *=== TR 1035223 NH
968
969 *--- TR 1053820 26-May-2011 Goutam
970 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
971 .LogEntry("Generate Customer SKU (Style_ColorSize).")
972 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
973 ENDIF
974 *=== TR 1053820 26-May-2011 Goutam
975
976 .LogEntry("Confirming SKU for UPC/EAN.")
977 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
978 *=== TechRec 1005163 17-May-2004 GS ===
979 *=== TR 1003801
980
981 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
982 If llRetVal And .oHostProcess.lRBACustSku
983 .LogEntry("Verifying Customer SKU.")
984 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
985 Endif
986 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
987
988 .LogEntry("Resolving style using SKU.")
989 *--- TechRec 1005163 17-May-2004 GS ---
990 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
991
992 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
993 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
994 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
995 *=== TR 1010097 07/27/05 TK
996 *=== TechRec 1005163 17-May-2004 GS ===
997
998 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
999 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
1000 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
1001
1002 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1003 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1004 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1005
1006 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1007 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
1008 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1009
1010 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
1011 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1012 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD, pceipoCR)
1013 *=== TR 1040432 MAY-20-2009 BR
1014
1015 *--- TR 1090280 30-Sep-2015 Goutam
1016 .LogEntry("Validating Implosion Type.")
1017 llRetVal= llRetVal And .ValidateImplosionType(pceipoTH, pceipoTD, pceipoCR)
1018 *=== TR 1090280 30-Sep-2015 Goutam
1019
1020 *--- TR 1098918 26-Sep-2016 HGORE ---
1021 llRetVal = llRetVal And .UpdateReq_855ForAllocation(pceipoTH)
1022 *=== TR 1098918 26-Sep-2016 HGORE ===
1023
1024 *--- TR 1013007 NH
1025 *--- check if req_855 if 'R' and status flag is empty then set error flag
1026 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1027 *=== TR 1013007 NH
1028
1029 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1030 If llRetVal
1031 .LogEntry("Validating detail 855 status code.")
1032 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1033 Endif
1034 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1035
1036 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1037 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1038 vcLogName)
1039
1040 *--- TR 1013007 NH 2005-10-11
1041 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1042 If .lSend855
1043 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1044
1045 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1046 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1047 *=== TR 1040432 MAY-20-2009 BR
1048
1049 *--- Error out IPO records which has no corresponding OPRCR control ref
1050 *--- IPO and OPRCR link is customer, division, oVnd_Key
1051 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1052 *=== TR 1034481 NH
1053 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1054 *--- If req_855 = 'R'
1055 *--- then run process 855
1056 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1057 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1058 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1059 Endif
1060 *=== TR 1013007 NH
1061
1062 *--- TR 1098918 26-Sep-2016 HGORE ---
1063 llRetVal = llRetVal And .ResetReq_855(pceipoTH)
1064 *=== TR 1098918 26-Sep-2016 HGORE ===
1065
1066 *-1089110 FH - error out 0 total_qty
1067 llRetVal= llRetVal And .ValidateZeroQty(pceipoTD)
1068
1069 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1070 .LogEntry("Resolving Is 860.")
1071 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1072
1073 .LogEntry("Creating 860 Transaction records.")
1074 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
1075 llRetVal = llRetVal And .Create860TM(pceipoTH, pceipoTD)
1076 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1077
1078 *--- TechRec 1082601 24-Dec-2014 jisingh ---
1079 .LogEntry("Validating detail 860 qual.")
1080 llRetVal = llRetVal And .Validate860Qual(pceipoTH, pceipoTD)
1081 *=== TechRec 1082601 24-Dec-2014 jisingh ===
1082
1083 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1084 .LogEntry("Resolving Multi-UPCs.")
1085 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1086 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1087
1088 .LogEntry("Resolving range style.")
1089 *--- TR 1023892 NH -
1090 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1091 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1092 *=== TR 1023892 NH
1093
1094 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1095 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1096 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1097 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1098
1099 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1100 vcLogName)
1101 *- 36262 6/11/03 YIK
1102 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1103 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1104 vcLogName)
1105 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1106 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1107 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1108 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1109 * === TR 1046519 7/26/10 CM
1110
1111 *=
1112
1113 *- 1044723 01/06/10 YIK
1114 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1115 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1116
1117 *- TR 1042748 09/23/09 YIK
1118 *- Call it here to populate Impl_ok flag (3d parameter).
1119 *- MOved it to clsipopr, so need to call with .oHostProcess
1120 *- This method will be called again after implosion. Ok per JRoth
1121 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1122
1123
1124 * 3/25/02 30854 - Implosion single prepack
1125 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1126 vcLogName)
1127 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
1128
1129 *- 1006607 09/01/04 YIK
1130 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1131 vcLogName)
1132 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1133 *=========
1134
1135 *--- TechRec 1005163 17-May-2004 GS ---
1136 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1137 If .oHostProcess.lHaveSLN
1138 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1139
1140 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1141*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1142*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1143 *=== TR 1049029 27-Aug-2010 Partha ===
1144
1145 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1146
1147 .LogEntry("Validating SLN vs. Prepack.")
1148 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1149 Endif
1150 *=== TechRec 1005163 17-May-2004 GS ===
1151
1152 *--- TR 1011644 23-AUG-2005 KA
1153 *If this.oResolvePrepack.lMultipack
1154 If this.lMultipack
1155 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1156 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1157 Endif
1158 *=== TR 1011644 23-AUG-2005 KA
1159
1160 .LogMajorStage("Resolving and getting default fields.")
1161 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1162 .LogEntry("Resolving customer label.")
1163 *--- TechRec 1005163 18-May-2004 GS ---
1164 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1165 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1166 *=== TechRec 1005163 18-May-2004 GS ===
1167
1168 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1169 vcLogName)
1170
1171 .LogEntry("Validating style.")
1172 *--- TechRec 1005163 21-Jun-2004 GS ---
1173 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1174 *--- TechRec 1016817 04-May-2006 GS ---
1175 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1176 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1177 *=== TechRec 1016817 04-May-2006 GS ===
1178 *=== TechRec 1005163 21-Jun-2004 GS ===
1179
1180 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1181 If This.oHostProcess.lHaveChrgs
1182 .LogEntry("Validating Charges.")
1183 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1184 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1185 EndIf
1186 *-- This is not needed anymore:
1187 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1188 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1189 * vcLogName)
1190 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1191
1192 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1193 *!* .LogEntry("Validating MinMultiple.")
1194 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1195 *===TR 1012978 VK 23/11/05
1196
1197 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1198 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1199 vcLogName)
1200 .LogEntry("Converting inbound UOM.")
1201 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1202
1203 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1204 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1205 lcSqlString = " UPDATE h SET " + ;
1206 " ReResvStyle = c.ReResvStyle " + ;
1207 " FROM (pcEipoTH) h " + ;
1208 " JOIN (pcEipoCR) c " + ;
1209 " ON h.division = c.division " + ;
1210 " AND h.customer = c.customer " + ;
1211 " WHERE h.ReResvStyle = '' "
1212
1213 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1214 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1215 EndWith
1216
1217 Select(lnOldSelect)
1218 Return llRetVal
1219 ENDPROC
1220
1221 *----------------------------------------------------------------------------------------
1222 * TR 1037976 JAN-22-2008 BR
1223 *----------------------------------------------------------------------------------------
1224 Procedure UpdtHeaderDivs
1225 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1226 Lparameters pceipoTH, pceipoTD, pceipoCR
1227 Local llRetVal, lnOldSelect, llUpdate
1228 llRetVal = .T.
1229 lnOldSelect = Select()
1230ASSERT .f.
1231 .LogEntry("Resolving header division.")
1232 *- 1005164 07/12/04 YIK
1233 *- Removed ..And Empty(Errs_Msg_D)
1234 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1235*!* Select Distinct fkey, division From (pceipoTD) ;
1236*!* WHERE !Empty(division) Into Cursor tmpCurs
1237
1238 *--- TR 1101199 9-Feb-2017 Goutam
1239*!* SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, ;
1240*!* IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
1241*!* FROM (pceipoTH) h ;
1242*!* JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1243*!* JOIN (pceipoCR) c ON c.pkey = h.control_pkey ;
1244*!* WHERE !EMPTY(d.division) INTO CURSOR tmpCurs
1245
1246 SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, c.pkey as control_pkey, h.customer, ;
1247 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
1248 FROM (pceipoTH) h ;
1249 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1250 JOIN (pceipoCR) c ON c.customer = h.customer ;
1251 ORDER BY d.fkey, c.customer, c.division ;
1252 WHERE !EMPTY(d.division) INTO CURSOR tmpCurs
1253 *--- TR 1101199 9-Feb-2017 Goutam
1254 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1255 Select tmpCurs
1256 If This.lUserInterface
1257 * Init Thermometer
1258 * TAN 31891 - JAZ - 5/20/02
1259 * This.InitThermo(RECC('tmpCurs'))
1260 This.InitThermo(Reccount('tmpCurs'))
1261 * End TAN 31891 - JAZ - 5/20/02
1262 l_nThermoCnt = 0
1263 Endif
1264 Scan
1265 If This.lUserInterface
1266 * Advance progress bar, if we're using one.
1267 l_nThermoCnt = l_nThermoCnt + 1
1268 This.AdvanceThermo(l_nThermoCnt)
1269 Endif
1270 Select (pceipoTH)
1271
1272 * --- TR 1022896 NSD 05-10-07
1273 * Convert LOCATE to SEEK
1274 *LOCATE FOR pkey = tmpCurs.fkey
1275 *IF FOUND()
1276 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1277
1278 *--- TR 1101199 9-Feb-2017 Goutam
1279 SELECT tmpCurs
1280 lnFkey = fkey
1281 lcCustomer = customer
1282 LOCATE FOR ctrl_division = division WHILE fkey = lnFkey AND customer = lcCustomer
1283 llDivfound = FOUND()
1284 IF !llDivfound
1285 skip-1
1286 ENDIF
1287 Select (pceipoTH)
1288 *=== TR 1101199 9-Feb-2017 Goutam
1289
1290 * === TR 1022896 NSD 05-10-07
1291 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1292 *--- TR 1101199 9-Feb-2017 Goutam. Added !llDivfound AND in the following condition
1293 IF !llDivfound AND tmpCurs.validate_division = "Y" AND tmpCurs.ctrl_division <> tmpCurs.division
1294 REPLACE errs_msg_h WITH errs_msg_h + ;
1295 "Mismatch between division(" + ALLTRIM(tmpCurs.ctrl_division) + ;
1296 ") and resolved UPC/SKU division(" + ALLTRIM(tmpCurs.division) + ")." + CRLF,;
1297 errs_flg_h WITH "Y" IN (pceipoTH)
1298 ELSE
1299 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1300 *--- TR 1101199 9-Feb-2017 Goutam. added control_pkey update
1301 Replace division With tmpCurs.division, control_pkey WITH tmpCurs.control_pkey In (pceipoTH)
1302 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1303 ENDIF
1304 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1305
1306 *--- TR 1101199 9-Feb-2017 Goutam
1307 IF llDivfound
1308 SELECT tmpCurs
1309 LOCATE FOR customer <> lcCustomer WHILE fkey = lnFkey
1310 IF !FOUND()
1311 skip-1
1312 ENDIF
1313 ENDIF
1314 *=== TR 1101199 9-Feb-2017 Goutam
1315
1316 Endif
1317 Endscan
1318 Use In tmpCurs
1319
1320 If This.lUserInterface
1321 * Reset Thermometer
1322 This.ResetThermo()
1323 Endif
1324 Select(lnOldSelect)
1325 Return llRetVal
1326 ENDPROC
1327 *----------------------------------------------------------------------------------------
1328 * TR 1037976 JAN-22-2008 BR
1329 *----------------------------------------------------------------------------------------
1330
1331 *---------------------------------------------------------------------------------
1332
1333 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1334 ************************************************************************************
1335 * Resolve BC SKU from SLN records and create customer style data.
1336 ************************************************************************************
1337 Procedure ResolveStyleFromSLN
1338 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1339 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1340 *--- TR 1035491 4-Nov-2008 Goutam
1341 *--- This entire function splitted into two different part ;
1342 1. ResolveBCSkuFromSLN ;
1343 2. ResolvePPKSkuAndUpdateDetail
1344
1345 Local llRetVal, lnOldSelect
1346 lnOldSelect = Select()
1347 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1348 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1349
1350
1351 Select(lnOldSelect)
1352 Return llRetVal
1353 Endproc
1354
1355 *----------------------------------------------------------------------------------
1356 ************************************************************************************
1357 * Validate UPC for all details
1358 ************************************************************************************
1359 Procedure CheckUpc
1360 Lparameters pceipoTH, pceipoTD,;
1361 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1362
1363 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1364 * Added Parameter pceipocr
1365 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1366
1367 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1368 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1369 lnSize_desc, llSLN
1370
1371 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1372 LOCAL lcIs_upcsku
1373 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1374
1375 llRetVal = .T.
1376 lcErrs_Msg= ""
1377 lnOldSelect = Select()
1378
1379 * cannot check for UPC if customer is empty
1380 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1381 * on Cust SKU or UPC.
1382 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1383
1384 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1385 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1386 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1387
1388 *--- TechRec 1005163 17-May-2004 GS ---
1389 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1390 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1391 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1392 *Order by h.customer, d.upc Into Cursor tmpCurs
1393
1394 *---- TR 1024667 NSD 5/31/07
1395 * If sizebucket = 0 then re-resolve.
1396
1397 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1398 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1399*!* If This.lHaveSLN
1400*!* Select h.customer,;
1401*!* d.upc,;
1402*!* d.pkey,;
1403*!* (pceipoTD) As Src;
1404*!* FROM (pceipoTH) h ;
1405*!* JOIN (pceipoTD) d ;
1406*!* ON h.pkey = d.fkey ;
1407*!* WHERE !Empty(d.upc) ;
1408*!* AND !Empty(h.customer) ;
1409*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1410*!* UNION All ;
1411*!* SELECT h.customer,;
1412*!* s.SLN_UPC As upc,;
1413*!* s.pkey,;
1414*!* (pceipoTS) As Src ;
1415*!* FROM (pceipoTH) h ;
1416*!* JOIN (pceipoTD) d ;
1417*!* ON d.fkey = h.pkey ;
1418*!* JOIN (pceipoTS) s ;
1419*!* ON s.fkey = d.pkey ;
1420*!* WHERE !Empty(s.SLN_UPC) ;
1421*!* AND !Empty(h.customer) ;
1422*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1423*!* ORDER By 1, 2 ;
1424*!* INTO Cursor tmpCurs
1425*!* Else
1426*!* Select h.Customer,;
1427*!* d.UPC,;
1428*!* d.PKey,;
1429*!* (pceipoTD) As Src;
1430*!* FROM (pceipoTH) h ;
1431*!* JOIN (pceipoTD) d ;
1432*!* ON h.pkey = d.fkey ;
1433*!* WHERE !Empty(d.upc) ;
1434*!* AND !Empty(h.customer) ;
1435*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1436*!* ORDER By 1, 2;
1437*!* INTO Cursor tmpCurs
1438*!* Endif
1439 *=== TechRec 1005163 17-May-2004 GS ===
1440
1441 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1442 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1443 FROM (pceipocr) ;
1444 GROUP BY customer ;
1445 INTO CURSOR __ResvCustSKU
1446 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1447
1448 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1449*!* select h.Customer;
1450*!* , d.UPC;
1451*!* , d.PKey;
1452*!* from (pceipoTH) h;
1453*!* join (pceipoTD) d;
1454*!* on h.PKey = d.FKey;
1455*!* where !Empty(d.UPC);
1456*!* and !Empty(h.Customer);
1457*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1458*!* order by 1, 2;
1459*!* into Cursor tmpCurs ReadWrite
1460
1461 *- 1035314 08/28/08 YIK
1462 *- Added r.ResvCustSKU to the list of fields
1463 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1464
1465.oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1466
1467 Select h.customer;
1468 , d.upc;
1469 , d.pkey;
1470 ,(pceipoTD) AS Src;
1471 ,r.ResvCustSKU ;
1472 from (pceipoTH) h;
1473 join (pceipoTD) d;
1474 on h.pkey = d.fkey;
1475 JOIN __ResvCustSKU r ;
1476 ON r.Customer = H.Customer ;
1477 where !Empty(d.upc);
1478 and !Empty(h.customer);
1479 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1480 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1481 order By 1, 2;
1482 into Cursor tmpCurs Readwrite
1483 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1484 *= 08/12/08 YIK TR 1035314
1485*=== TechRec 1024522 25-Sep-2007 GSternik ===
1486
1487*-1040686
1488 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1489 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1490 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1491 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1492 IF llRetVal
1493 .PopulateSQLTempTable("tcCustUpc")
1494 ENDIF
1495
1496 llRetVal = llRetVal AND v_sqlexec(;
1497 "SELECT x.upc,d.* "+;
1498 " FROM zzxcstdr d"+ ;
1499 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1500 " JOIN " + this.cSQLTempTable + " x " + ;
1501 " ON d.customer = x.customer " +;
1502 " AND d.cust_style = x.upc " + ;
1503 " WHERE h.IB_resolv = 'Y'" + ;
1504 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1505 SELECT tmpCstdr_upc
1506 INDEX on customer + upc TAG cust_upc
1507
1508
1509 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1510 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1511 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1512 IF llRetVal
1513 .PopulateSQLTempTable("tcDistUpc")
1514 ENDIF
1515
1516 llRetVal = llRetVal AND v_sqlexec(;
1517 "SELECT x.upc,d.* "+;
1518 " FROM zzeupcnr d"+ ;
1519 " JOIN " + this.cSQLTempTable + " x " + ;
1520 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1521 SELECT tmpUpcnr
1522 INDEX on upc TAG upc
1523 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1524*-1040686
1525
1526 lcOldCust = ""
1527 lcOldItem = ""
1528 Select tmpCurs
1529 If This.lUserInterface
1530 * Init Thermometer
1531 This.UpdateThermoCaption("Validating UPC(s)...")
1532 * TAN 31891 - JAZ - 5/20/02
1533 * This.InitThermo(RECC('tmpCurs'))
1534 This.InitThermo(RecCount('tmpCurs'))
1535 * End TAN 31891 - JAZ - 5/20/02
1536 l_nThermoCnt = 0
1537 EndIf
1538
1539 Scan
1540 If This.lUserInterface
1541 * Advance progress bar, if we're using one.
1542 l_nThermoCnt = l_nThermoCnt + 1
1543 This.AdvanceThermo(l_nThermoCnt)
1544 Endif
1545 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1546 lcErrs_Msg = ""
1547 lcOldCust = tmpCurs.customer
1548 lcOldItem = tmpCurs.upc
1549 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1550 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1551
1552 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1553 lcIs_upcsku = ' '
1554 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1555
1556 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1557 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1558
1559 *- 1040686 - tmpCstdr_upc...
1560 lcDivision = tmpCstdr_upc.division
1561 lcStyle = tmpCstdr_upc.Style
1562 lcColor_code = tmpCstdr_upc.color_code
1563 lcLbl_code = tmpCstdr_upc.lbl_code
1564 lcDimension = tmpCstdr_upc.Dimension
1565 lnSizeBucket = tmpCstdr_upc.size_bk
1566 lnSize_desc = tmpCstdr_upc.size_desc
1567 *- 1040686 - tmpCstdr_upc...
1568
1569 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1570 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1571 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1572
1573 ELSE
1574 *- 08/12/08 YIK TR 1035314
1575 IF ResvCustSKU <> 'Y'
1576 lcErrs_Msg = ""
1577 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1578 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1579 lcDivision = tmpUpcnr.division
1580 lcStyle = tmpUpcnr.Style
1581 lcColor_code = tmpUpcnr.color_code
1582 lcLbl_code = tmpUpcnr.lbl_code
1583 lcDimension = tmpUpcnr.Dimension
1584 lnSizeBucket = tmpUpcnr.sizebucket
1585 lnSize_desc = tmpUpcnr.size_desc
1586 Else
1587 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1588 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1589 Store 0 To lnSizeBucket
1590 Endif
1591 *- 08/12/08 YIK TR 1035314
1592 ELSE
1593 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1594 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1595 STORE 0 TO lnSizeBucket
1596 ENDIF
1597 *= 08/12/08 YIK TR 1035314
1598 Endif
1599 Endif && level break
1600
1601 *--- TechRec 1005163 17-May-2004 GS ---
1602 *Select (pceipoTD)
1603*!* llSLN = (tmpCurs.Src = pceipoTS)
1604*!* If llSLN
1605*!* Select (pceipoTS)
1606*!* Else
1607 Select (pceipoTD)
1608*!* Endif
1609 *=== TechRec 1005163 17-May-2004 GS ===
1610 *- 1010682 04/25/05 YIK
1611 *- Locate For pkey = tmpCurs.pkey
1612 lnWorkArea = Select()
1613 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1614 Scatter Name loEiPOtd Memo
1615 If !Empty(lcErrs_Msg)
1616*!* *--- TechRec 1005163 17-May-2004 GS ---
1617*!* If llSLN
1618*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1619*!* loEiPOtd.Errs_Flg_S = "Y"
1620*!* Else
1621*!* *=== TechRec 1005163 17-May-2004 GS ===
1622 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1623 loEiPOtd.Errs_Flg_D = "Y"
1624*!* Endif
1625 Endif
1626 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1627 loEiPOtd.Division = lcDivision
1628 loEiPOtd.Style = lcStyle
1629 loEiPOtd.Color_Code = lcColor_code
1630 loEiPOtd.Lbl_Code = lcLbl_code
1631 loEiPOtd.Dimension = lcDimension
1632 loEiPOtd.SizeBucket = lnSizeBucket
1633 loEiPOtd.Size_Desc = lnSize_desc
1634
1635 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1636 IF !EMPTY(lcIs_upcsku)
1637 loEiPOtd.Is_upcsku = lcIs_upcsku
1638 ENDIF
1639 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1640
1641 *--- TR 1019697 NH : clear rang style when bc style is set
1642 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1643 loEiPOtd.rng_style = ''
1644 loEiPOtd.rng_color = ''
1645 loEiPOtd.rng_lbl = ''
1646 loEiPOtd.rng_pack = ''
1647 Endif
1648 *=== TR 1019697 NH
1649 Endif
1650
1651 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1652 * only replace our SKU when no range style explosion happen
1653 *--- TechRec 1005163 17-May-2004 GS ---
1654 *If empty(&pceipoTD..rng_style)
1655 * Replace division With loEiPOtd.division, ;
1656 * style With loEiPOtd.style, ;
1657 * color_code With loEiPOtd.color_code, ;
1658 * lbl_code With loEiPOtd.lbl_code, ;
1659 * dimension With loEiPOtd.dimension, ;
1660 * sizebucket With loEiPOtd.sizebucket, ;
1661 * size_desc With loEiPOtd.size_desc, ;
1662 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1663 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1664 * In (pceipoTD)
1665 *Endif
1666 *- 1009508 3/16/05 YIK
1667 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1668 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1669 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1670 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1671 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1672
1673 Gather Name loEiPOtd Memo
1674 Endif
1675 *=== TechRec 1005163 17-May-2004 GS ===
1676
1677 Endscan
1678 Use In tmpCurs
1679
1680 If This.lUserInterface
1681 * Reset Thermometer
1682 This.ResetThermo()
1683 Endif
1684
1685 If Used("tmpCstdr")
1686 Use In tmpCstdr
1687 Endif
1688 If Used("tmpUpcnr")
1689 Use In tmpUpcnr
1690 ENDIF
1691
1692 *- 1040686
1693 USE IN SELECT("tcCustUpc")
1694 USE IN SELECT("tmpCstdr_upc")
1695 USE IN SELECT("tcDistUpc")
1696 USE IN SELECT("tmpUpcnr")
1697 *- 1040686
1698
1699 Select(lnOldSelect)
1700 Return llRetVal
1701 Endproc
1702
1703 *----------------------------------------------------------------------------------
1704
1705 *--- TR 1035223 NH
1706 PROCEDURE ClearErrorsForSkipSlnCheck
1707 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1708
1709 LOCAL llRetVal, lnOldSelect
1710 lnOldSelect = SELECT()
1711 llRetVal = .t.
1712
1713 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1714 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1715
1716 *--- TR 1038353 NH
1717 UPDATE td SET Errs_flg_d = 'Y', Errs_msg_d = Errs_msg_d + 'Error in SLN' + CRLF FROM (pceipoTD) td WHERE Style_SLN_OK = 'N'
1718 *=== TR 1038353 NH
1719
1720 Select(lnOldSelect)
1721 Return llRetVal
1722 Endproc
1723
1724 *----------------------------------------------------------------------------------
1725
1726 PROCEDURE SetupSkipSLNCheck
1727 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1728
1729 LOCAL lnOldSelect, llRetVal
1730 lnOldSelect = SELECT()
1731 llRetVal = .t.
1732 *--- take division from trans detail
1733 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1734 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1735 inner join (pceipoCR) r on r.customer = th.customer AND r.division = td.division ;
1736 WHERE th.customer > '' AND td.division > ''
1737
1738 *--- Setup in pceipoTS
1739 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1740 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1741
1742 Select(lnOldSelect)
1743 Return llRetVal
1744
1745 Endproc
1746 *=== TR 1035223 NH
1747
1748 *----------------------------------------------------------------------------------
1749
1750 *--- TR 1023892 NH
1751 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1752 PROCEDURE Populate_Cust_lbl
1753 LPARAMETERS pcTransHeader, pcTransDetail
1754 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1755 llRetVal = .t.
1756 lnOldSelect = SELECT()
1757 lcSQLString = ""
1758 lcFkeySku = ""
1759 lcCust_lbl = ""
1760
1761
1762 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl ;
1763 FROM (pcTransHeader) h, (pcTransDetail) d ;
1764 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1765 and d.lbl_code = '' ;
1766 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1767
1768 IF RECCOUNT("__TmpCursor") = 0
1769 *-- no valid style to process
1770 this.LogEntry("No detail record found to populate customer label.")
1771 SELECT(lnOldSelect)
1772 RETURN llRetVal
1773 ENDIF
1774
1775 WITH this
1776 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1777 .cSQLTempTable = ""
1778 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1779 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1780 lcCustSku = "#CustSku" + SYS(2015)
1781
1782 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1783 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1784 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1785 *--- Used sc.Division instead of c.Division.
1786 TEXT TO lcSQLString NOSHOW
1787 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1788 case when d.orig_lbl <> '' then d.orig_lbl
1789 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1790 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1791 else d.lbl_code end as cust_lbl
1792 FROM #Temp d INNER JOIN zzeipocr_expl c on d.customer = c.customer and d.division = c.division
1793 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1794 AND sc.style = d.style AND sc.color_code = d.color_code
1795 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1796 ENDTEXT
1797
1798 lcCustLbl = SYS(2015)
1799 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1800 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1801 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1802 IF llRetVal
1803 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1804 SELECT(pcTransDetail)
1805 lcZzeipotd_order = ORDER()
1806 SET ORDER TO fkeySku
1807 SELECT (lcCustLbl)
1808 SCAN
1809 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1810 lcCust_lbl = Cust_lbl
1811 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1812 SELECT(pcTransDetail)
1813 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1814 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1815 ENDSCAN
1816 ENDIF
1817 ENDSCAN
1818 SELECT(pcTransDetail)
1819 SET ORDER TO (lcZzeipotd_order)
1820 ENDIF
1821 ENDWITH
1822 SELECT(lnOldSelect)
1823 RETURN llRetVal
1824 ENDPROC
1825
1826 *-----------------------------------------------------------------------------------
1827 *=== TR 1023892 NH
1828
1829 ************************************************************************************
1830 * Validate EAN for all details
1831 * Created on 03/24/04 - BD- TR 1003801
1832 ************************************************************************************
1833 Procedure CheckEAN
1834 Lparameters pceipoTH, pceipoTD,;
1835 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1836 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1837
1838 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1839 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1840 lnSize_desc, llSLN
1841 llRetVal = .T.
1842 lcErrs_Msg= ""
1843 lnOldSelect = Select()
1844
1845 *--- TR 1061652 05/18/12 ATHIRUNAVU
1846 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1847 FROM (pceipocr) ;
1848 GROUP BY customer ;
1849 INTO CURSOR __ResvCustSKU
1850 *=== TR 1061652 05/18/12 ATHIRUNAVU
1851
1852 *- Check EAN only if customer is empty
1853 *--- TechRec 1005163 17-May-2004 GS ---
1854 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1855 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1856 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1857 *Order by h.customer, d.ean Into Cursor tmpCurs
1858
1859 *---- TR 1024667 NSD 5/31/07
1860 * If sizebucket = 0 then re-resolve.
1861
1862 If This.oHostProcess.lHaveSLN
1863 *--- TR 1061652 05/18/12 ATHIRUNAVU
1864 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1865 Select h.customer,;
1866 d.ean,;
1867 d.pkey, ;
1868 r.ResvCustSKU, ;
1869 (pceipoTD) As Src;
1870 FROM (pceipoTD) d ;
1871 JOIN (pceipoTH) h ;
1872 ON h.pkey = d.fkey ;
1873 JOIN __ResvCustSKU r ;
1874 ON r.Customer = H.Customer ;
1875 WHERE !Empty(d.ean) ;
1876 AND !Empty(h.customer) ;
1877 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1878 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1879 Union All ;
1880 SELECT h.customer,;
1881 s.SLN_EAN As ean,;
1882 s.pkey, ;
1883 r.ResvCustSKU, ;
1884 (pceipoTS) As Src;
1885 FROM (pceipoTD) d ;
1886 JOIN (pceipoTH) h ;
1887 ON h.pkey = d.fkey ;
1888 JOIN (pceipoTS) s ;
1889 ON s.fkey = d.pkey ;
1890 JOIN __ResvCustSKU r ;
1891 ON r.Customer = H.Customer ;
1892 WHERE !Empty(s.SLN_EAN) ;
1893 AND !Empty(h.customer) ;
1894 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1895 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1896 ORDER By 1, 2 ;
1897 INTO Cursor tmpCurs
1898 Else
1899 *--- TR 1061652 05/18/12 ATHIRUNAVU
1900 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1901 Select h.customer,;
1902 d.ean,;
1903 d.pkey, ;
1904 r.ResvCustSKU, ;
1905 (pceipoTD) As Src;
1906 FROM (pceipoTD) d ;
1907 JOIN (pceipoTH) h ;
1908 ON h.pkey = d.fkey ;
1909 JOIN __ResvCustSKU r ;
1910 ON r.Customer = H.Customer ;
1911 WHERE !Empty(d.ean) ;
1912 AND !Empty(h.customer) ;
1913 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1914 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1915 Order By h.customer, d.ean ;
1916 INTO Cursor tmpCurs
1917 Endif
1918 *=== TechRec 1005163 17-May-2004 GS ===
1919
1920 lcOldCust = ""
1921 lcOldItem = ""
1922 Select tmpCurs
1923 If This.lUserInterface
1924 * Init Thermometer
1925 This.UpdateThermoCaption("Validating EAN(s)...")
1926 This.InitThermo(RecCount('tmpCurs'))
1927 l_nThermoCnt = 0
1928 Endif
1929 Scan
1930 If This.lUserInterface
1931 * Advance progress bar, if we're using one.
1932 l_nThermoCnt = l_nThermoCnt + 1
1933 This.AdvanceThermo(l_nThermoCnt)
1934 Endif
1935 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
1936 lcErrs_Msg = ""
1937 lcOldCust = tmpCurs.customer
1938 lcOldItem = tmpCurs.ean
1939 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1940 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1941
1942 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
1943 lcDivision = tmpCstdr.division
1944 lcStyle = tmpCstdr.Style
1945 lcColor_code = tmpCstdr.color_code
1946 lcLbl_code = tmpCstdr.lbl_code
1947 lcDimension = tmpCstdr.Dimension
1948 lnSizeBucket = tmpCstdr.size_bk
1949 lnSize_desc = tmpCstdr.size_desc
1950 Else
1951
1952 *--- TR 1061652 05/18/12 ATHIRUNAVU
1953 IF ResvCustSKU <> 'Y'
1954 *=== TR 1061652 05/18/12 ATHIRUNAVU
1955
1956 lcErrs_Msg = ""
1957 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
1958 lcDivision = tmpUpcnr.division
1959 lcStyle = tmpUpcnr.Style
1960 lcColor_code = tmpUpcnr.color_code
1961 lcLbl_code = tmpUpcnr.lbl_code
1962 lcDimension = tmpUpcnr.Dimension
1963 lnSizeBucket = tmpUpcnr.sizebucket
1964 lnSize_desc = tmpUpcnr.size_desc
1965 Else
1966 lcErrs_Msg = lcErrs_Msg + CRLF
1967 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1968 Store 0 To lnSizeBucket
1969 Endif
1970
1971 *--- TR 1061652 05/18/12 ATHIRUNAVU
1972 ELSE
1973 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
1974 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1975 STORE 0 TO lnSizeBucket
1976 ENDIF
1977 *=== TR 1061652 05/18/12 ATHIRUNAVU
1978
1979 Endif
1980 Endif && level break
1981
1982 *--- TechRec 1005163 17-May-2004 GS ---
1983 *Select (pceipoTD)
1984 llSLN = (tmpCurs.Src = pceipoTS)
1985 If llSLN
1986 Select (pceipoTS)
1987 Else
1988 Select (pceipoTD)
1989 Endif
1990 *=== TechRec 1005163 17-May-2004 GS ===
1991
1992 *- 1010682 04/25/05 YIK
1993 *- Locate For pkey = tmpCurs.pkey
1994 lnWorkArea = Select()
1995 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1996 Scatter Name loEiPOtd Memo
1997 If !Empty(lcErrs_Msg)
1998 *--- TechRec 1005163 17-May-2004 GS ---
1999 If llSLN
2000 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
2001 loEiPOtd.Errs_Flg_S = "Y"
2002 Else
2003 *=== TechRec 1005163 17-May-2004 GS ===
2004 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
2005 loEiPOtd.Errs_Flg_D = "Y"
2006 Endif &&--- TechRec 1005163 17-May-2004 GS ===
2007 Endif
2008 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
2009 loEiPOtd.division = lcDivision
2010 loEiPOtd.Style = lcStyle
2011 loEiPOtd.color_code = lcColor_code
2012 loEiPOtd.lbl_code = lcLbl_code
2013 loEiPOtd.Dimension = lcDimension
2014 loEiPOtd.sizebucket = lnSizeBucket
2015 loEiPOtd.size_desc = lnSize_desc
2016 Endif
2017
2018 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
2019 * only replace our SKU when no range style explosion happen
2020 *--- TechRec 1005163 17-May-2004 GS ---
2021 *If empty(&pceipoTD..rng_style)
2022 * Replace division With loEiPOtd.division, ;
2023 * style With loEiPOtd.style, ;
2024 * color_code With loEiPOtd.color_code, ;
2025 * lbl_code With loEiPOtd.lbl_code, ;
2026 * dimension With loEiPOtd.dimension, ;
2027 * sizebucket With loEiPOtd.sizebucket, ;
2028 * size_desc With loEiPOtd.size_desc, ;
2029 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
2030 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
2031 * In (pceipoTD)
2032 *- 1009508 3/16/05 YIK
2033 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
2034 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
2035
2036 Gather Name loEiPOtd Memo
2037 *=== TechRec 1005163 17-May-2004 GS ===
2038 Endif
2039 Endscan
2040 Use In tmpCurs
2041
2042 If This.lUserInterface
2043 * Reset Thermometer
2044 This.ResetThermo()
2045 Endif
2046
2047 If Used("tmpCstdr")
2048 Use In tmpCstdr
2049 Endif
2050 If Used("tmpUpcnr")
2051 Use In tmpUpcnr
2052 Endif
2053
2054 Select(lnOldSelect)
2055 Return llRetVal
2056 Endproc
2057
2058 *-----------------------------------------------------------------------------------
2059
2060 *--- 39222 5/1/03 YIK
2061 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
2062 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
2063 *- matches the sku sent in transmission.
2064
2065 *--- TechRec 1005163 17-May-2004 GS:
2066 *- Combined ConfirmUPC and ConfirmEAN
2067
2068 Procedure ConfirmSku
2069 Lparameters pceipoTH, pceipoTD, pceipoCR,;
2070 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
2071
2072 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
2073 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
2074 lcSku, lcErrs_Msg, llSLN
2075
2076 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
2077 llRetVal = .T.
2078 lcErrs_Msg= ""
2079
2080 *--- TR 1085322 24-Sep-2015 Goutam
2081 LOCAL llCustStyleDupeCheck, llCustStyleFound,lcStyle, lcColor, lcLabel
2082 *=== TR 1085322 24-Sep-2015 Goutam
2083
2084 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2085 lcWarnMsg = ""
2086 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2087
2088 lnOldSelect = Select()
2089
2090 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
2091
2092 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
2093 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
2094 *- 1003788 2/25/04 YIK
2095 *- use d.division, not h.division which is still empty
2096
2097 *--- TechRec 1005163 17-May-2004 GS ---
2098 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2099
2100 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2101 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2102 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2103 *--- TR 1078000 16-4-2014 VKK Added cust_size
2104 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2105 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass, cust_size ;
2106 from (pceipoTD) Into Cursor __eipoTD
2107
2108 If This.oHostProcess.lHaveSLN
2109 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2110 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2111 *--- TR 1078000 16-4-2014 VKK Added cust_size
2112 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2113 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass, cust_size From (pceipoTS) Into Cursor __EiPOts
2114 Endif
2115 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2116 *--- NH - 08/10/07
2117 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2118 Select(lnOldSelect)
2119 RETURN llRetVal
2120 ENDIF
2121 *=== TR 1022625
2122
2123 With This
2124 .cSQLTempTable = ""
2125 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2126 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2127 lceipoTD_tmp = .cSQLTempTable
2128 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2129
2130 If This.oHostProcess.lHaveSLN
2131 .cSQLTempTable = ""
2132 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2133 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2134 lceipoTS_tmp = .cSQLTempTable
2135 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2136 Endif
2137 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2138 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2139 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2140 ENDWITH
2141
2142
2143 This.MakeCursorWritable("tmpCursR","tmpCurs")
2144 *=== TR 1019697 NH
2145 *=== TechRec 1005163 17-May-2004 GS ===
2146
2147 *-FH 1103931 - Grab sql from GetConfrimSkuSql, lets make a temp table from it.
2148 LOCAL lcTemptbl
2149 lcTemptbl = SQLTableFromQuery(lcSQL)
2150 *-FH 1103931
2151
2152 *--- TR 1085322 24-Sep-2015 Goutam
2153 * FH 1103931 - Let's use lcTemptbl, instead of lceipoTD_tmp( lceipoTD_tmp is all of DTL, lcTemptbl will only be confirm sku)
2154 *- - also add distinct
2155 IF llRetVal AND !EMPTY(lcTemptbl)
2156 lcSql = "select distinct b.cust_style, b.division, b.style, b.color_code, b.lbl_code, b.dimension, b.size_bk " +;
2157 " from " + lcTemptbl + " a join zzxcstdr b " +;
2158 " on a.sku = b.cust_style"
2159
2160 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpBCSKUCurs")
2161 IF llRetVal
2162 SELECT tmpBCSKUCurs
2163 INDEX on cust_style+division+style+color_code+lbl_code+dimension+STR(size_bk) TAG cust_style
2164 SET ORDER TO
2165 ENDIF
2166 ENDIF
2167 *=== TR 1085322 24-Sep-2015 Goutam
2168
2169 .LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2170 Select tmpCurs
2171 If This.lUserInterface
2172 * Init Thermometer
2173 This.UpdateThermoCaption("Comparing SKU(s)...")
2174 This.InitThermo(RecCount('tmpCurs'))
2175 l_nThermoCnt = 0
2176 Endif
2177 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2178 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2179 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2180 *=== TR 1019697 NH
2181
2182 *-1040686
2183 *=-=-=-=-=-=-=-=-=-=
2184 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2185 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2186 IF llRetVal
2187 .PopulateSQLTempTable("tcDistCustSku")
2188 ENDIF
2189 llRetVal = llRetVal AND v_sqlexec(;
2190 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2191 " , d.aux_sku, d.pkey " +;
2192 " FROM zzxcstdr d"+ ;
2193 " JOIN " + this.cSQLTempTable + " x " + ;
2194 " ON d.customer = x.customer " +;
2195 " AND d.division = x.division " + ;
2196 " AND d.style = x.style " + ;
2197 " AND d.color_code = x.color_code " + ;
2198 " AND d.lbl_code = x.lbl_code " + ;
2199 " AND d.dimension = x.dimension " + ;
2200 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2201 SELECT tmpCstdr
2202 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2203 INDEX on cust_style TAG custsty && TR 1085322 KISHORE 22-SEP-2015
2204
2205 *=-=-=-=-=-=-=-=-=-=
2206
2207 * TR 1085322 KISHORE 12-MAR-2015
2208 llCustStyleDupeCheck = (goEnv.sv("CUST_STYLE_DUPE_CHECK","N") = "Y")
2209
2210 SELECT tmpCurs
2211 *- 1040686
2212
2213
2214 Local lnSizeBk
2215 lnSizeBk = 0
2216 SCAN
2217 llCustStyleFound = false &&*--- TR 1085322 24-Sep-2015 Goutam
2218
2219 If This.lUserInterface
2220 * Advance progress bar, if we're using one.
2221 l_nThermoCnt = l_nThermoCnt + 1
2222 This.AdvanceThermo(l_nThermoCnt)
2223 Endif
2224 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2225 lcErrs_Msg = ""
2226 *=== TechRec 1005163 17-May-2004 GS, YK ===
2227
2228 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2229 lcWarnMsg = ""
2230 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2231
2232 *-1040686
2233 *=-=-=-=-=-=-=-=-=-
2234 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2235 DIMENSION, sizebucket, "tmpCstdr")
2236 lcSku = ""
2237 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2238 lcSku = tmpCstdr.cust_style
2239 ELSE
2240 lcErrs_Msg = "Missing SKU code."
2241 ENDIF
2242 *=-=-=-=-=-=-=-=-=-
2243 *-1040686
2244
2245 *--- TR 1085322 24-Sep-2015 Goutam.
2246 *Note: Cust_sku must be unique in zzxcstdr if the system parameter CUST_STYLE_DUPE_CHECK = ‘Y’
2247 IF SEEK(tmpCurs.sku, "tmpBCSKUCurs", "cust_style")
2248 lcStyle = ALLTRIM(tmpBCSKUCurs.style)
2249 lcColor = ALLTRIM(tmpBCSKUCurs.color_code)
2250 lcLabel = ALLTRIM(tmpBCSKUCurs.lbl_code)
2251 IF llCustStyleDupeCheck AND !SEEK(tmpCurs.sku+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpBCSKUCurs", "cust_style")
2252 lcErrs_Msg = "Customer Style " + ALLTRIM(tmpCurs.sku) + " already exists for Style " + lcstyle + ", Color " + lcColor + " and label " + lcLabel
2253 llCustStyleFound = true
2254 ENDIF
2255
2256 *--- TR 1095258 04/28/16 ATHIRUNAVU Added tmpcurs.customer
2257 *IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2258 IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2259 *=== TR 1095258 04/28/16 ATHIRUNAVU
2260 Replace AddCustSKU With .T. In (tmpCurs.Src)
2261 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2262 llCustStyleFound = true
2263 *--- TR-1098891 4-Oct-2016 JPaul. lcErrs_Msg should be cleared
2264 lcErrs_Msg= ''
2265 *=== TR-1098891 4-Oct-2016 JPaul.
2266 ENDIF
2267 ENDIF
2268 *=== TR 1085322 24-Sep-2015 Goutam
2269
2270 IF !llCustStyleFound &&*--- TR 1085322 24-Sep-2015 Goutam
2271 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2272 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2273 If !(lcSku == tmpCurs.sku)
2274 * TR 1085322 KISHORE 12-MAR-2015 added OR Upd_CustSku = 'Y'
2275 If (Empty(lcSku) And GenCustSKU = 'Y') OR Upd_CustSku = 'Y'
2276 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2277
2278 *--- TR 1085322 24-Sep-2015 Goutam
2279 IF Upd_CustSku = 'Y'
2280 IF SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.Style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.DIMENSION+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku") ;
2281 AND (tmpCurs.SKU <> tmpCstdr.cust_style)
2282
2283 lcSQL = "Update zzxcstdr set cust_style = " + SQLFormatChar(tmpCurs.sku) + ;
2284 ", last_mod = " + SQLFormatTs(DATETIME()) + ", user_id = " + SQLFormatChar(EDI_USER) + ;
2285 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2286 llRetVal = llRetVal And v_SqlExec(lcSQL)
2287 ENDIF
2288 ELSE
2289 *=== TR 1085322 24-Sep-2015 Goutam
2290 Replace AddCustSKU With .T. In (tmpCurs.Src)
2291 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2292
2293 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2294
2295 lcErrs_Msg = ""
2296 Else
2297 If Confirm_SKU = 'Y'
2298 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2299 Else
2300 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2301 CRLF + "Unable to generate new customer Sku." + CRLF
2302 Endif
2303 ENDIF
2304 *--- TR 1061151 2-MAY-12 Venuk.
2305 Else
2306 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2307 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2308 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2309 v_SqlExec(lcSQL)
2310 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2311 ELSE
2312 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2313 lcWarnMsg = "Aux sku already exist."
2314 ENDIF
2315 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2316 ENDIF
2317 *=== TR 1061151 2-MAY-12 Venuk.
2318 Endif
2319
2320 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2321
2322 *--- TechRec 1005163 17-May-2004 GS ---
2323 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2324 * Replace ;
2325 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2326 * Errs_Flg_D With "Y" ;
2327 * In (pceipoTD)
2328
2329 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2330 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2331 llSLN = (tmpCurs.Src = pceipoTS)
2332 If llSLN
2333 Select (pceipoTS)
2334 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2335 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2336 IF !EMPTY(lcErrs_Msg)
2337 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2338 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2339 Replace ;
2340 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2341 Errs_Flg_S With "Y"
2342 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2343 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2344 Errs_Flg_D With 'Y' In (pceipoTD)
2345 Endif
2346 ENDIF
2347 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2348 ELSE
2349 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2350 Warn_Flg_D With "Y" In (pceipoTD)
2351 ENDIF
2352 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2353 Else
2354 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2355 Select (pceipoTD)
2356 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2357 IF !EMPTY(lcErrs_Msg)
2358 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2359 Replace ;
2360 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2361 Errs_Flg_D With "Y"
2362 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2363 ELSE
2364 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2365 Warn_Flg_D With "Y"
2366 ENDIF
2367 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2368 Endif
2369 *=== TechRec 1005163 17-May-2004 GS ===
2370 Endif
2371 ENDSCAN
2372 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2373 *--- TR 1019697 NH :
2374 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2375 *=== TR 1019697 NH
2376 Use In tmpCurs
2377
2378 If This.lUserInterface
2379 * Reset Thermometer
2380 This.ResetThermo()
2381 Endif
2382
2383 If Used("tmpCstdr")
2384 Use In tmpCstdr
2385 ENDIF
2386
2387 *--- TR 1085322 24-Sep-2015 Goutam
2388 USE IN SELECT("tmpBCSKUCurs")
2389 *=== TR 1085322 24-Sep-2015 Goutam
2390
2391 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2392
2393 Select(lnOldSelect)
2394 Return llRetVal
2395 Endproc
2396
2397 *-----------------------------------------------------------------------------------
2398
2399 *--- TR 1019697 NH
2400 **************************************************************************************
2401 Procedure GetConfrimSkuSql
2402 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2403 Local lcSQL, lcSqlSln, lnOldSelect
2404 lnOldSelect = Select()
2405
2406 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2407 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2408
2409 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2410 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2411 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2412 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2413 *--- TR 1078000 16-4-2014 VKK Added cust_size
2414 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2415 lcSQL = ;
2416 "select d.customer"+;
2417 " , d.division"+;
2418 " , d.sku"+;
2419 " , d.STYLE"+;
2420 " , d.color_code"+;
2421 " , case"+;
2422 " when r.rng_style is null"+;
2423 " and d.lbl_code = ''"+;
2424 " and c.resv_label = 'Y' then c.lbl_code"+;
2425 " when r.rng_style is null"+;
2426 " and d.lbl_code = ''"+;
2427 " and c.resv_label = 'V'"+;
2428 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2429 " else d.lbl_code"+;
2430 " end as lbl_code"+;
2431 " , d.lbl_code as lbl_codeOrig"+;
2432 " , c.resv_label"+;
2433 " , d.DIMENSION"+;
2434 " , d.Sizebucket"+;
2435 " , d.upc"+;
2436 " , d.pkey"+;
2437 " , C.GenCustSKU"+;
2438 " , C.Confirm_SKU"+;
2439 " , C.upd_custsku " + ;
2440 " , 'N' as AddCustSKU"+;
2441 " , d.size_desc"+;
2442 " , '" + Trim(pceipoTD) + "' as Src"+;
2443 " , d.aux_sku " + ;
2444 " , d.subclass " + ;
2445 " , d.cust_size " + ;
2446 " from " + pceipoTD_tmp + " d"+;
2447 " join " + This.c850Control + " C"+;
2448 " on d.customer = C.customer"+;
2449 " and d.division = C.division"+;
2450 " left join zzxrangh r"+;
2451 " on r.division = d.division"+;
2452 " and r.rng_style = d.style"+;
2453 " and r.rng_color = d.color_code"+;
2454 " and r.rng_lbl = d.lbl_code"+;
2455 " and r.rng_pack = d.dimension"+;
2456 " left join zzxscolr sc"+;
2457 " on sc.division = d.division"+;
2458 " and sc.style = d.style"+;
2459 " and sc.color_code = d.color_code"+;
2460 " and sc.lbl_code = c.lbl_code"+;
2461 " and sc.dimension = d.dimension"+;
2462 " where d.customer > ''"+;
2463 " and d.SKU > ''"+;
2464 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2465 " and d.Division > ''"+;
2466 " and d.Style > ''"+;
2467 " and d.Color_Code > ''"+;
2468 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2469 " and d.Rng_Style = '' "
2470
2471 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2472 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2473 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2474 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2475 *--- Used sc.Division instead of c.Division.
2476 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2477 *--- TR 1078000 16-4-2014 VKK Added cust_size
2478 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2479 *- TR 1098656 FH - change to s.Division
2480 lcSqlSln = ;
2481 "select d.Customer"+;
2482 " , s.Division"+;
2483 " , s.SLN_SKU as sku"+;
2484 " , s.STYLE"+;
2485 " , s.Color_Code"+;
2486 " , case when s.Lbl_Code = ''"+;
2487 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2488 " when s.Lbl_Code = ''"+;
2489 " and c.Resv_Label = 'V'"+;
2490 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2491 " else s.lbl_code"+;
2492 " end as lbl_code"+;
2493 " , s.lbl_code as lbl_codeOrig"+;
2494 " , c.resv_label"+;
2495 " , s.DIMENSION"+;
2496 " , s.Sizebucket"+;
2497 " , s.SLN_UPC as upc"+;
2498 " , s.pkey"+;
2499 " , C.GenCustSKU"+;
2500 " , C.Confirm_SKU"+;
2501 " , C.upd_custsku " + ;
2502 " , 'N' as AddCustSKU"+;
2503 " , s.size_desc"+;
2504 " , '" + Trim(pceipoTS) + "' as Src"+;
2505 " , s.aux_sku " + ;
2506 " , s.subclass " + ;
2507 " , s.cust_size " + ;
2508 " from " + pceipoTD_tmp + " d"+;
2509 " join " + pceipoTS_tmp + " s"+;
2510 " on s.fkey = d.pkey"+;
2511 " join " + This.c850Control + " C"+;
2512 " on d.customer = C.customer"+;
2513 " and d.division = C.division"+;
2514 " left join zzxscolr sc"+;
2515 " on sc.division = d.division"+;
2516 " and sc.style = s.style"+;
2517 " and sc.color_code = s.color_code"+;
2518 " and sc.lbl_code = c.lbl_code"+;
2519 " and sc.dimension = s.dimension"+;
2520 " where d.Customer > ''"+;
2521 " and s.SLN_SKU > ''"+;
2522 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2523 " and d.Division > ''"+;
2524 " and s.Style > ''"+;
2525 " and s.Color_Code > ''"+;
2526 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2527 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2528 Endif
2529
2530 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2531 Select(lnOldSelect)
2532 Return lcSQL
2533 Endproc
2534
2535 *-----------------------------------------------------------------------------------
2536
2537 Procedure CreateOurSkuFromTmpCurs
2538 If Not Used("TmpCurs")
2539 Return .F.
2540 Endif
2541 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2542 llRetVal = .T.
2543 lnOldSelect = Select()
2544 With This
2545 Select tmpCurs
2546 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2547
2548 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2549 lcDistSku = Getuniquefilename()
2550 lcExistingSku = Getuniquefilename()
2551 lcCustLbl = Getuniquefilename()
2552
2553 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2554 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2555 *- We need this because cursor lcCustLbl has customer field.
2556 *- This is going to prevent the case for us having 2 different Customer same BC SKU, both of them have label in customer label reference
2557 *- with auto_style = 'Y', we will add both auto_style twice.
2558
2559 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2560 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2561 *- because style exists in zzxscolr (we just addeded)
2562 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2563 *- so we will add it twice by accident.
2564
2565 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2566 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2567 *-FH 1066967
2568
2569
2570 *-FH 1066967 - added customer
2571 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2572 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2573 IF llRetVal
2574 .PopulateSQLTempTable(lcDistSku)
2575 ENDIF
2576
2577 llRetVal = llRetVal AND v_sqlexec(;
2578 "SELECT x.* "+;
2579 " FROM zzxscolr d"+ ;
2580 " JOIN " + this.cSQLTempTable + " x " + ;
2581 " ON d.division = x.division " +;
2582 " AND d.style = x.style " + ;
2583 " AND d.color_code = x.color_code " + ;
2584 " AND d.lbl_code = x.lbl_code " + ;
2585 " AND d.dimension = x.dimension " ,lcExistingSku )
2586 SELECT (lcExistingSku)
2587 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2588
2589 IF llRetVal
2590 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2591 ENDIF
2592
2593 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2594 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2595 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2596 SELECT(lcCustLbl)
2597 INDEX on customer + lbl_code TAG cust_lbl
2598
2599 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2600 SELECT (lcDistSku) && FH 1066967
2601 Scan
2602 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2603 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2604 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2605*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2606*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2607*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2608*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2609*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2610*!* Else
2611*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2612*!* Endif
2613*!* ENDIF
2614
2615 IF NOT EMPTY(&lcDistSku..lbl_code)
2616 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2617 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2618 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2619 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2620
2621 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2622 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2623 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2624 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2625
2626 .oLog.LogEntry("Created style: " + lcOurSKU )
2627 Else
2628 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2629 ENDIF
2630 ENDIF
2631 Endif
2632 ENDIF
2633
2634 ENDSCAN
2635 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2636
2637 USE IN SELECT(lcDistSku)
2638 USE IN SELECT(lcExistingSku)
2639 USE IN SELECT(lcCustLbl)
2640
2641 USE IN SELECT('lcStyleAdded') && FH 1066967
2642
2643 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2644 Endwith
2645 Select (lnOldSelect)
2646 Return llRetVal
2647 Endproc
2648
2649 *-----------------------------------------------------------------------------------
2650
2651 Procedure GenerateCustomerSkuFromCursor
2652 Parameters tcSkuCursor
2653 Local lnOldSelect, llRetVal
2654 llRetVal = .T.
2655 lnOldSelect = Select()
2656
2657 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2658 lcPrevSkuIpotd = ""
2659 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2660 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2661 *--- TR 1078000 16-4-2014 VKK Added cust_size
2662 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2663 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2664 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2665 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2666
2667 With This
2668 lnCount = Reccount("tmpCurs1")
2669
2670 If lnCount = 0
2671 Select (lnOldSelect)
2672 Return
2673 Endif
2674
2675 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2676 Select (lnOldSelect)
2677 Return
2678 Endif
2679
2680 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2681 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2682 lnCount = lnCount - 1
2683 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2684 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2685
2686 Select VZZXCSTHR
2687 Scatter Memvar Blank
2688 Select VZZXCSTDR
2689 Scatter Memvar Blank
2690
2691 m.Last_mod = Datetime()
2692 m.User_id = 'CGSADMIN'
2693 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2694
2695 * --- TR 1039603 4/6/09 CM
2696 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2697 m.active_ok = 'Y'
2698 m.anti_theft = 'N'
2699 * === TR 1039603 4/6/09 CM
2700
2701 m.notes = ''
2702
2703 lcPrevSKU = ' '
2704
2705 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2706 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2707 Select("tmpCursSrc")
2708 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2709 Scan
2710 Select (Alltrim(tmpCursSrc.Src))
2711 lcOldOrder = Order()
2712 Set Order To CstBcSku
2713 Replace oldOrder With lcOldOrder In tmpCursSrc
2714 ENDSCAN
2715 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2716
2717 Select tmpCurs1
2718 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2719 Scan
2720 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2721 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2722 *--- TR 1078000 16-4-2014 VKK Added cust_size
2723 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2724 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2725 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2726 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2727 If lcPrevSKU # lcSku
2728 lcPrevSKU = lcSku
2729 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2730 If Empty(lnHDRpKey)
2731 lnHDRpKey = lnCstHrPkey
2732 Insert Into VZZXCSTHR From Memvar
2733 Replace pkey With lnHDRpKey In VZZXCSTHR
2734 Endif
2735 Endif
2736 *--- clear AddCustSKU for all matching rows in zzeipotd
2737 Select (tmpCurs1.Src)
2738 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2739 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2740 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2741 Endscan
2742 lcPrevSkuIpotd = lcSkuIpotd
2743
2744 *-TR 1059834 FH -moved in IF statement
2745 Select tmpCurs1
2746 Insert Into VZZXCSTDR From Memvar
2747 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2748 lnCstDrPkey = lnCstDrPkey +1
2749 lnCstHrPkey = lnCstHrPkey +1
2750 *-TR 1059834 FH -moved in IF statement
2751
2752 Endif
2753 ENDSCAN
2754 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2755 Select("tmpCursSrc")
2756 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2757 Scan
2758 Select (Alltrim(tmpCursSrc.Src))
2759 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2760* If Not Empty(lcOldOrder)
2761 Set Order To (lcOldOrder)
2762* Endif
2763 ENDSCAN
2764 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2765 Use In tmpCursSrc
2766
2767 Dimension laTables[2]
2768 laTables[1]= "VZZXCSTHR"
2769 laTables[2]= "VZZXCSTDR"
2770
2771 llBeganTransaction = .BeginTransaction()
2772 llRetVal = .Tableupdate(@laTables)
2773
2774 If llRetVal
2775 If llBeganTransaction
2776 This.EndTransaction()
2777 Endif
2778 Else
2779 If llBeganTransaction
2780 This.RollbackTransaction()
2781 Endif
2782 Endif
2783 Endwith
2784 If Used("tmpCurs1")
2785 Use In tmpCurs1
2786 Endif
2787 Select(lnOldSelect)
2788 Return llRetVal
2789 Endproc
2790
2791 *-----------------------------------------------------------------------------------
2792 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2793
2794 Function GenerateRBACustSKU
2795 Lparameters pceipoTH,pceipoTD
2796
2797 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2798 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2799
2800
2801 llRetVal = True
2802 lnSelect = Select()
2803 lcRBADivision = 'TFG'
2804 With This
2805
2806 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2807
2808 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2809 *- 12/12/06 YIK
2810 *- No distinct since includes pkey. Change order.
2811 *-- SELECT DISTINCT ;
2812 *-- h.customer,;
2813 *-- lcRBADivision as division,;
2814 *-- d.pkey as dtlpkey ,;
2815 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2816 *-- d.color_code,;
2817 *-- .GetCustLabel(h.customer) as lbl_code,;
2818 *-- "" as DIMENSION,;
2819 *-- h.store as cust_store ,;
2820 *-- d.sku as cust_style ,;
2821 *-- d.price as cust_price , ;
2822 *-- d.size_desc, ;
2823 *-- 0 as size_bk ;
2824 *-- FROM (pceipoTH) h ;
2825 *-- JOIN (pceipoTD) d ;
2826 *-- ON d.fkey = h.pkey ;
2827 *-- INTO CURSOR __tmpCur ;
2828 *-- ORDER BY 1,2,3,4,5,6
2829
2830 *** Size_BK needs to be 00 and NOT 0
2831 Select ;
2832 h.customer,;
2833 lcRBADivision As division,;
2834 d.pkey As dtlpkey ,;
2835 d.Style As Style, ;
2836 d.color_code,;
2837 .GetCustLabel(h.customer) As lbl_code,;
2838 "" As Dimension,;
2839 h.Store As cust_store ,;
2840 d.sku As Cust_style ,;
2841 d.price As cust_price , ;
2842 d.size_desc, ;
2843 00 As size_bk ;
2844 FROM (pceipoTH) h ;
2845 JOIN (pceipoTD) d ;
2846 ON d.fkey = h.pkey ;
2847 WHERE h.Errs_flg_h < 'Y' And ;
2848 d.Errs_Flg_D < 'Y' ;
2849 INTO Cursor __tmpCur ;
2850 ORDER By 1,2,4,5,6,7, 11
2851 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2852
2853 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2854
2855 lnCount = Reccount("tmpCurs")
2856
2857 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
2858
2859 If lnCount = 0
2860 If Used("tmpCurs")
2861 Use In tmpCurs
2862 Endif
2863 Select (lnSelect)
2864 Return
2865 Endif
2866
2867 Select tmpCurs
2868 *
2869 * Make it a loop for safety
2870 *
2871 Scan
2872 *** .LogEntry("Original Style " + style)
2873 lcStyle = .GetBCStyle(lcRBADivision,Style)
2874 *** .LogEntry("Resolved Style " + lcStyle)
2875 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
2876 Replace Style With lcStyle , size_bk With lnSize_BK
2877 Endscan
2878 .LogEntry("Resolved Styles/Size_BK")
2879
2880 *- 12/12/06 YIK
2881 *- Index just in case somebody changes the SELECT above
2882 Select tmpCurs
2883 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
2884 TAG sku
2885
2886 .LogEntry("Load Customer Style.")
2887
2888 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2889 If Used("tmpCurs")
2890 Use In tmpCurs
2891 Endif
2892 Select (lnSelect)
2893 Return
2894 Endif
2895
2896 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2897 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2898 lnCount = lnCount - 1
2899 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2900 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2901
2902 Select VZZXCSTHR
2903 Scatter Memvar Blank
2904 Select VZZXCSTDR
2905 Scatter Memvar Blank
2906
2907 m.Last_mod = Datetime()
2908 m.User_id = 'CGSADMIN'
2909 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2910 m.notes = ''
2911
2912 lcPrevSKU = ' '
2913 lcPrevSkuSize = ''
2914
2915 *- 12/12/06 YIK
2916 *- inserted details counter
2917 Local lnInsertCount
2918 lnInsertCount = 0
2919
2920 Select tmpCurs
2921
2922 Scan
2923 .LogEntry("Loading Customer Style...")
2924 .LogEntry("Style :" + Style )
2925 .LogEntry("Color_code :" + color_code )
2926
2927 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
2928 .LogEntry("Invalid Style or Color_code or Size_bk " )
2929 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
2930 FOR pkey = dtlpkey In (pceipoTD)
2931 Loop
2932 Endif
2933
2934 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2935 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
2936 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2937 If lcPrevSKU # lcSku
2938 lcPrevSKU = lcSku
2939 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
2940 .LogEntry("Customer :" + m.customer )
2941 .LogEntry("Division : " + m.division)
2942 .LogEntry("Style :" + Style )
2943 .LogEntry("Color_code :" + m.color_code )
2944 .LogEntry("Label code :" + m.lbl_code )
2945 .LogEntry("dimension : " + m.dimension)
2946 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
2947 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2948 If Empty(lnHDRpKey)
2949 lnHDRpKey = lnCstHrPkey
2950 .LogEntry("Inserting into header..")
2951 Insert Into VZZXCSTHR From Memvar
2952 Replace pkey With lnHDRpKey In VZZXCSTHR
2953 Endif
2954 Endif
2955 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
2956 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
2957 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
2958 If Empty(lnDtlKey)
2959 lnDtlpKey = lnCstDrPkey
2960 .LogEntry("Inserting into detail..")
2961 Insert Into VZZXCSTDR From Memvar
2962 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
2963 *- 12/12/06 YIK
2964 lnInsertCount = lnInsertCount + 1
2965 Endif
2966 Endif
2967 lnCstDrPkey = lnCstDrPkey +1
2968 lnCstHrPkey = lnCstHrPkey +1
2969
2970 Endscan
2971
2972 Dimension laTables[2]
2973 laTables[1]= "VZZXCSTHR"
2974 laTables[2]= "VZZXCSTDR"
2975
2976 llBeganTransaction = .BeginTransaction()
2977 llRetVal = .Tableupdate(@laTables)
2978
2979 If llRetVal
2980 If llBeganTransaction
2981 This.EndTransaction()
2982 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
2983 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
2984 Endif
2985 Else
2986 If llBeganTransaction
2987 This.RollbackTransaction()
2988 .LogEntry("Table Update failed - Roll back Transaction " )
2989 Endif
2990 Endif
2991
2992 Endwith
2993
2994 If Used("tmpCurs")
2995 Use In tmpCurs
2996 Endif
2997
2998 Select (lnSelect)
2999 Return llRetVal
3000 Endfunc
3001
3002 *-----------------------------------------------------------------------------------
3003
3004 Function GetBCStyle
3005 Lparameters tcDivision, tcUDFStyle
3006 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
3007
3008 llRetVal = True
3009 lnSelect = Select()
3010 l_vRetVal = ''
3011
3012 lcCursor = GetUniqueFileName()
3013 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
3014 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
3015
3016 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
3017
3018 If llRetVal
3019 Select(lcCursor)
3020 l_vRetVal = Alltrim(Style)
3021 Use In (lcCursor)
3022 Endif
3023
3024 Select (lnSelect)
3025 Return l_vRetVal
3026 Endfunc
3027
3028 *-----------------------------------------------------------------------------------
3029
3030 Function GetSizeBkt
3031 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
3032 p_cKeyField4, p_cKeyField5, p_cKeyField6
3033 Local l_cSQLString, l_vRetVal
3034
3035 l_nOldSele = Select()
3036 pnSizeBucket = 0
3037
3038 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
3039 l_vRetVal = 0
3040 Return l_vRetVal
3041 Endif
3042
3043 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
3044 p_cKeyField2)
3045 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
3046 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
3047 p_cKeyField3, p_cKeyField4, p_cKeyField5)
3048 Select TmpSavlr
3049 For l_n=1 To 24
3050 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
3051 If l_lAlwSz
3052 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
3053 If l_cSize_Desc = p_cKeyField6
3054 ***l_vRetVal = .T.
3055 pnSizeBucket = l_n
3056 Endif
3057 Endif
3058 Endfor
3059 Use In TmpSavlr
3060 Use In TmpSizer
3061 Endif
3062 Endif
3063
3064 l_vRetVal = pnSizeBucket
3065
3066 Select (l_nOldSele)
3067 Return l_vRetVal
3068
3069 Endfunc
3070
3071 *-----------------------------------------------------------------------------------
3072 * Validate SKU for all details
3073 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
3074
3075 Procedure CheckSku
3076 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
3077 Lparameters pceipoTH, pceipoTD,;
3078 pceipoTS, pceipoCR
3079 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
3080 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
3081 lnSize_desc, llSLN
3082
3083 *--- TR 1013117 NH
3084 Local lcSku_resolv
3085 Dimension lasku_resolv[1]
3086 lcSku_resolv = ""
3087 lasku_resolv[1] = ""
3088 *=== TR 1013117 NH
3089
3090 * --- TR 1045305 2/3/10 CM
3091 LOCAL lnSkuPkey
3092 lnSkuPkey = 0
3093 * === TR 1045305 2/3/10 CM
3094
3095
3096 llRetVal = .T.
3097 lcErrs_Msg= ""
3098 lnOldSelect = Select()
3099
3100 * cannot check for SKU if customer is empty
3101 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
3102 * on Cust SKU or UPC.
3103 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
3104
3105 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
3106 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
3107 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
3108
3109 *--- TechRec 1005163 17-May-2004 GS ---
3110 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
3111 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
3112 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
3113 *Order by h.customer, d.sku Into Cursor tmpCurs
3114
3115 *---- TR 1024667 NSD 5/31/07
3116 * If sizebucket = 0 then re-resolve.
3117
3118 If This.oHostProcess.lHaveSLN
3119 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3120 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3121 *!* SELECT h.customer,;
3122 *!* c.sku_resolv, ;
3123 *!* JOIN (pceipoCR) C;
3124 *!* ON d.division= C.division ;
3125 *!* AND h.customer= C.customer ;
3126
3127 *!* c.sku_resolv, ; && after union
3128 *!* JOIN (pceipoCR) C;
3129 *!* ON d.division= C.division ;
3130 *!* AND h.customer= C.customer ;
3131
3132 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3133 Select h.customer,;
3134 h.department, ;
3135 h.Store, ;
3136 d.sku,;
3137 d.upc, ;
3138 d.pkey, ;
3139 (pceipoTD) As Src ;
3140 FROM (pceipoTD) d ;
3141 JOIN (pceipoTH) h ;
3142 ON h.pkey = d.fkey ;
3143 WHERE !Empty(h.customer) ;
3144 AND !Empty(d.sku) ;
3145 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
3146 UNION All ;
3147 SELECT h.customer,;
3148 h.department, ;
3149 h.Store, ;
3150 s.SLN_SKU As sku,;
3151 s.SLN_UPC As upc,;
3152 s.pkey, ;
3153 (pceipoTS) As Src ;
3154 FROM (pceipoTS) s ;
3155 JOIN (pceipoTD) d ;
3156 ON d.pkey = s.fkey ;
3157 JOIN (pceipoTH) h ;
3158 ON h.pkey = d.fkey ;
3159 WHERE !Empty(h.customer) ;
3160 AND !Empty(s.SLN_SKU) ;
3161 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
3162 ORDER By 1, 2 ;
3163 INTO Cursor tmpCurs
3164 *=== TR 1010097 07/27/05 TK
3165 Else
3166 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3167 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3168 *!* SELECT h.customer,;
3169 *!* c.sku_resolv, ;
3170 *!* JOIN (pceipoCR) C;
3171 *!* ON d.division= C.division ;
3172 *!* AND h.customer= C.customer ;
3173 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3174 Select h.customer,;
3175 h.department, ;
3176 h.Store, ;
3177 d.sku,;
3178 d.upc, ;
3179 d.pkey, ;
3180 (pceipoTD) As Src ;
3181 FROM (pceipoTD) d ;
3182 JOIN (pceipoTH) h ;
3183 ON h.pkey = d.fkey ;
3184 WHERE !Empty(h.customer) ;
3185 AND !Empty(d.sku) ;
3186 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3187 Order By h.customer, d.sku ;
3188 INTO Cursor tmpCurs
3189 *=== TR 1010097 07/27/05 TK
3190 Endif
3191 *=== TechRec 1005163 17-May-2004 GS ===
3192
3193*- 1040686
3194 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3195 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3196 IF llRetVal
3197 .PopulateSQLTempTable("tcDistCustSku")
3198 ENDIF
3199 llRetVal = llRetVal AND v_sqlexec(;
3200 "SELECT x.sku,d.* "+;
3201 " FROM zzxcstdr d"+ ;
3202 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3203 " JOIN " + this.cSQLTempTable + " x " + ;
3204 " ON d.customer = x.customer " +;
3205 " AND d.cust_style = x.sku " + ;
3206 " WHERE h.IB_resolv = 'Y'" + ;
3207 " AND d.Size_Desc>'' " + ;
3208 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3209 SELECT tmpCstdr_sku
3210 INDEX ON customer + cust_style TAG cust_sku
3211
3212 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3213 UNION ;
3214 SELECT customer,sku FROM tmpCstdr_sku ;
3215 GROUP BY customer,sku ;
3216 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3217 INDEX ON customer+sku TAG cust_sku
3218 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3219*- 1040686
3220
3221
3222 lcOldCust = ""
3223 lcOldItem = ""
3224 lcOldSku_resolv = ""
3225 Select tmpCurs
3226 If This.lUserInterface
3227 * Init Thermometer
3228 This.UpdateThermoCaption("Validating SKU(s)...")
3229 * TAN 31891 - JAZ - 5/20/02
3230 * This.InitThermo(RECC('tmpCurs'))
3231 This.InitThermo(RecCount('tmpCurs'))
3232 * End TAN 31891 - JAZ - 5/20/02
3233 l_nThermoCnt = 0
3234 Endif
3235 SCAN
3236 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3237 *-- Skip sku resolution
3238 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3239 LOOP
3240 ENDIF
3241 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3242
3243 If This.lUserInterface
3244 * Advance progress bar, if we're using one.
3245 l_nThermoCnt = l_nThermoCnt + 1
3246 This.AdvanceThermo(l_nThermoCnt)
3247 Endif
3248
3249 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3250 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3251 *--- TR 1013117 NH 20050908
3252 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3253 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3254 *=== TR 1013117 NH 20050908
3255 *=== TR 1010097 07/27/05 TK
3256
3257 *---TR 1037976 JAN-07-08 BR
3258 IF !(tmpCurs.customer == lcOldCust)
3259 lcCustomer = tmpCurs.customer
3260 IF SEEK(lcCustomer,pceipocr,"customer")
3261 lcSku_resolv = &pceipocr..sku_resolv
3262 ENDIF
3263 ENDIF
3264 *===TR 1037976 JAN-07-08 BR
3265
3266 lcErrs_Msg = ""
3267 lcOldCust = tmpCurs.customer
3268 lcOldItem = tmpCurs.sku
3269 *--- TR 1013117 NH
3270 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3271 *=== TR 1013117 NH
3272
3273 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3274
3275
3276
3277 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3278 *--- TR 1013117 NH 20050908
3279 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3280 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3281
3282 *- 1040686 - COMMENT
3283*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3284*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3285*!* *=== TR 1013117 NH 20050908
3286*!* *--- TR 1010097 07/27/05 TK
3287
3288*!* lcDivision = tmpCstdr.division
3289*!* lcStyle = tmpCstdr.Style
3290*!* lcColor_code = tmpCstdr.color_code
3291*!* lcLbl_code = tmpCstdr.lbl_code
3292*!* lcDimension = tmpCstdr.Dimension
3293*!* lnSizeBucket = tmpCstdr.size_bk
3294*!* lnSize_desc = tmpCstdr.size_desc
3295*!*
3296*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3297*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3298*!* If tmpCstdr.fkey > 0
3299*!* lnSkuPkey = tmpCstdr.fkey
3300*!* Endif
3301*!* * === TR 1045305 2/3/10 CM
3302*!*
3303*!*
3304*!* Else
3305*!* lcErrs_Msg = lcErrs_Msg + CRLF
3306*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3307*!* Store 0 To lnSizeBucket
3308*!* Endif
3309
3310 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3311 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3312 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3313 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3314 Store 0 To lnSizeBucket
3315 ELSE
3316 *- TR 1074276 FH - adding UPPER()
3317 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3318 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3319 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3320 Store 0 To lnSizeBucket
3321 ELSE
3322 lcDivision = tmpCstdr_sku.division
3323 lcStyle = tmpCstdr_sku.Style
3324 lcColor_code = tmpCstdr_sku.color_code
3325 lcLbl_code = tmpCstdr_sku.lbl_code
3326 lcDimension = tmpCstdr_sku.Dimension
3327 lnSizeBucket = tmpCstdr_sku.size_bk
3328 lnSize_desc = tmpCstdr_sku.size_desc
3329
3330 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3331 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3332 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3333 If tmpCstdr_sku.fkey > 0
3334 lnSkuPkey = tmpCstdr_sku.fkey
3335 Endif
3336 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3337 *!* * === TR 1045305 2/3/10 CM
3338
3339 ENDIF
3340 ENDIF
3341*- 1040686 - COMMENT
3342
3343 Endif && level break
3344
3345 *--- TechRec 1005163 17-May-2004 GS ---
3346 *Select (pceipoTD)
3347 llSLN = (tmpCurs.Src = pceipoTS)
3348 If llSLN
3349 Select (pceipoTS)
3350 Else
3351 Select (pceipoTD)
3352 Endif
3353 *!* Locate For pkey = tmpCurs.pkey
3354 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3355 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3356 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3357 *=== TechRec 1005163 17-May-2004 GS ===
3358 Scatter Name loEiPOtd Memo
3359 If !Empty(lcErrs_Msg)
3360 *--- TechRec 1005163 17-May-2004 GS ---
3361 If llSLN
3362 *- 1008827 04/22/05 YIK
3363 *- correct a typo
3364 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3365
3366 loEiPOtd.Errs_Flg_S = "Y"
3367 Else
3368 *=== TechRec 1005163 17-May-2004 GS ===
3369 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3370 loEiPOtd.Errs_Flg_D = "Y"
3371 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3372 Endif
3373 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3374 loEiPOtd.division = lcDivision
3375 loEiPOtd.Style = lcStyle
3376 loEiPOtd.color_code = lcColor_code
3377 loEiPOtd.lbl_code = lcLbl_code
3378 loEiPOtd.Dimension = lcDimension
3379 loEiPOtd.sizebucket = lnSizeBucket
3380 loEiPOtd.size_desc = lnSize_desc
3381
3382 * --- TR 1045305 2/3/10 CM
3383 loEiPOtd.sku_pkey = lnSkuPkey
3384 * === TR 1045305 2/3/10 CM
3385
3386 Endif
3387
3388 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3389 * only replace our SKU when no range style explosion happen
3390 *--- TechRec 1005163 17-May-2004 GS ---
3391 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3392 * Replace division With loEiPOtd.division, ;
3393 * style With loEiPOtd.style, ;
3394 * color_code With loEiPOtd.color_code, ;
3395 * lbl_code With loEiPOtd.lbl_code, ;
3396 * dimension With loEiPOtd.dimension, ;
3397 * sizebucket With loEiPOtd.sizebucket, ;
3398 * size_desc With loEiPOtd.size_desc, ;
3399 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3400 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3401 * In (pceipoTD)
3402 *- 1009508 3/16/05 YIK
3403 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3404 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3405 Gather Name loEiPOtd Memo
3406 *=== TechRec 1005163 17-May-2004 GS ===
3407 Endif
3408
3409 *=== TechRec 1005163 17-May-2004 GS ===
3410 Endif
3411 Endscan
3412 Use In tmpCurs
3413
3414 If This.lUserInterface
3415 * Reset Thermometer
3416 This.ResetThermo()
3417 Endif
3418
3419 If Used("tmpCstdr")
3420 Use In tmpCstdr
3421 ENDIF
3422
3423 *-1040686
3424 USE IN SELECT("tcDistCustSku")
3425 USE IN SELECT("tmpCstdr_sku")
3426 USE IN SELECT("tcAmbigSku")
3427 *-1040686
3428
3429 Select(lnOldSelect)
3430 Return llRetVal
3431 Endproc
3432
3433 *-----------------------------------------------------------------------------------
3434 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3435 PROCEDURE PopulateOrigLabel
3436 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3437 LOCAL llRetVal, lnOldSelect
3438 lnOldSelect = SELECT()
3439
3440 SELECT (pceipoTD)
3441 *-TR FH 1093621 - Push then pop
3442 .PushRecordSet()
3443
3444 SELECT d.pkey ;
3445 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3446 WHERE c.accept_lbl = 'Y' and ;
3447 c.customer = h.customer and ;
3448 c.division = d.division and ;
3449 h.pkey = d.fkey and ;
3450 h.errs_flg_h <> 'Y' and ;
3451 d.errs_flg_d <> 'Y' ;
3452 ORDER BY d.pkey ;
3453 INTO CURSOR 'cursTmpTD'
3454
3455 Index On pkey Tag pkey
3456
3457 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3458
3459 goto top in "cursTmpTD"
3460
3461 If llRetVal AND !EOF('cursTmpTD')
3462 SELECT (pceipoTD)
3463 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3464 In (pceipoTD)
3465 Endif
3466
3467 *-TR FH 1093621 - Push then pop
3468 .PopRecordSet()
3469
3470 Set Relation to
3471 USE IN 'cursTmpTD'
3472 SELECT (lnOldSelect)
3473 RETURN llRetVal
3474 ENDPROC
3475 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3476 *-----------------------------------------------------------------------------------
3477
3478 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3479 Procedure ConfirmUPC
3480 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3481
3482 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3483 lcUPC, lcErrs_Msg, llSLN
3484
3485 llRetVal = .T.
3486 lcErrs_Msg= ""
3487 lnOldSelect = Select()
3488
3489 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3490
3491 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3492
3493 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3494 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3495 from (pceipoTD) Into Cursor __eipoTD
3496
3497 If This.oHostProcess.lHaveSLN
3498 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3499 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3500 Endif
3501
3502 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3503 Select(lnOldSelect)
3504 Return llRetVal
3505 Endif
3506
3507 With This
3508 .cSQLTempTable = ""
3509 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3510 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3511 lceipoTD_tmp = .cSQLTempTable
3512 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3513
3514 If This.oHostProcess.lHaveSLN
3515 .cSQLTempTable = ""
3516 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3517 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3518 lceipoTS_tmp = .cSQLTempTable
3519 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3520 Endif
3521 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3522 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3523 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3524 Endwith
3525
3526
3527 This.MakeCursorWritable("tmpCursR","tmpCurs")
3528
3529 Select tmpCurs
3530 If This.lUserInterface
3531 * Init Thermometer
3532 This.UpdateThermoCaption("Comparing UPC(s)...")
3533 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3534 l_nThermoCnt = 0
3535 Endif
3536
3537
3538*- 1040686
3539 *=-=-=-=-=-=-=-=-=-=
3540 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3541 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3542 IF llRetVal
3543 .PopulateSQLTempTable("tcDistUpc")
3544 ENDIF
3545 llRetVal = llRetVal AND v_sqlexec(;
3546 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3547 " FROM zveupcnr d"+ ;
3548 " JOIN " + this.cSQLTempTable + " x " + ;
3549 " ON d.division = x.division " + ;
3550 " AND d.style = x.style " + ;
3551 " AND d.color_code = x.roll_color " + ;
3552 " AND d.lbl_code = x.lbl_code " + ;
3553 " AND d.dimension = x.dimension " + ;
3554 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3555 SELECT tmpCstdr
3556 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3557 *=-=-=-=-=-=-=-=-=-=
3558 SELECT tmpCurs
3559
3560*- 1040686
3561 Local lnSizeBk
3562 lnSizeBk = 0
3563 Scan
3564 If This.lUserInterface
3565 * Advance progress bar, if we're using one.
3566 l_nThermoCnt = l_nThermoCnt + 1
3567 This.AdvanceThermo(l_nThermoCnt)
3568 Endif
3569
3570 lcErrs_Msg = ""
3571
3572 *- 1040686
3573 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3574 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3575 DIMENSION, sizebucket, "tmpCstdr")
3576 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3577 DIMENSION, sizebucket, "tmpCstdr")
3578
3579 lcUPC = ""
3580 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3581 lcErrs_Msg = "Missing UPC number."
3582 ELSE
3583 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3584 ENDIF
3585
3586 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3587 *-1040686
3588
3589 If !(lcUPC == tmpCurs.UPC)
3590 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3591 Endif
3592
3593 If !Empty(lcErrs_Msg)
3594 llSLN = (tmpCurs.Src = pceipoTS)
3595 If llSLN
3596 Select (pceipoTS)
3597 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3598 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3599 Replace ;
3600 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3601 Errs_Flg_S With "Y"
3602 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3603 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3604 Errs_Flg_D With 'Y' In (pceipoTD)
3605 Endif
3606 ENDIF &&--- TR 1035223 NH
3607 Else
3608 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3609 Select (pceipoTD)
3610 Replace ;
3611 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3612 Errs_Flg_D With "Y"
3613 Endif
3614 Endif
3615 Endscan
3616
3617 Use In tmpCurs
3618
3619 If This.lUserInterface
3620 * Reset Thermometer
3621 This.ResetThermo()
3622 Endif
3623
3624 If Used("tmpCstdr")
3625 Use In tmpCstdr
3626 ENDIF
3627
3628 USE IN SELECT("tcDistUpc") &&1040686
3629
3630 Select(lnOldSelect)
3631 Return llRetVal
3632 ENDPROC
3633
3634 *-----------------------------------------------------------------------------------
3635
3636 Procedure GetConfrimUPCSql
3637 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3638 Local lcSql, lcSqlSln, lnOldSelect
3639 lnOldSelect = Select()
3640
3641 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3642 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3643 * this is a straight join and not a date resolution.
3644 lcSql = ;
3645 "select d.customer"+;
3646 " , d.division"+;
3647 " , d.sku"+;
3648 " , d.STYLE"+;
3649 " , d.color_code"+;
3650 " , case"+;
3651 " when r.rng_style is null"+;
3652 " and d.lbl_code = ''"+;
3653 " and c.resv_label = 'Y' then c.lbl_code"+;
3654 " when r.rng_style is null"+;
3655 " and d.lbl_code = ''"+;
3656 " and c.resv_label = 'V'"+;
3657 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3658 " else d.lbl_code"+;
3659 " end as lbl_code"+;
3660 " , d.lbl_code as lbl_codeOrig"+;
3661 " , c.resv_label"+;
3662 " , d.DIMENSION"+;
3663 " , d.Sizebucket"+;
3664 " , d.upc"+;
3665 " , d.pkey"+;
3666 " , C.Confirm_UPC"+;
3667 " , d.size_desc"+;
3668 " , '" + Trim(pceipoTD) + "' as Src"+;
3669 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3670 " from " + pceipoTD_tmp + " d"+;
3671 " join zzeipocr C"+;
3672 " on d.customer = C.customer"+;
3673 " and d.division = C.division"+;
3674 " left join zzxrangh r"+;
3675 " on r.division = d.division"+;
3676 " and r.rng_style = d.style"+;
3677 " and r.rng_color = d.color_code"+;
3678 " and r.rng_lbl = d.lbl_code"+;
3679 " and r.rng_pack = d.dimension"+;
3680 " left join zzxscolr sc"+;
3681 " on sc.division = d.division"+;
3682 " and sc.style = d.style"+;
3683 " and sc.color_code = d.color_code"+;
3684 " and sc.lbl_code = c.lbl_code"+;
3685 " and sc.dimension = d.dimension"+;
3686 " left join zzxrupcd rc " + ;
3687 " on rc.division = d.division"+;
3688 " and rc.style = d.style"+;
3689 " and rc.new_color = d.color_code"+;
3690 " and rc.lbl_code = d.lbl_code"+;
3691 " and rc.dimension = d.dimension"+;
3692 " where d.customer > ''"+;
3693 " and d.SKU > ''"+;
3694 " and (d.UPC > '' or d.EAN > '' )"+;
3695 " and d.Division > ''"+;
3696 " and d.Style > ''"+;
3697 " and d.Color_Code > ''"+;
3698 " and C.Confirm_UPC = 'Y' "+;
3699 " and d.Rng_Style = '' "
3700
3701 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3702 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3703 *--- Used sc.Division instead of c.Division.
3704 lcSqlSln = ;
3705 "select d.Customer"+;
3706 " , d.Division"+;
3707 " , s.SLN_SKU as sku"+;
3708 " , s.STYLE"+;
3709 " , s.Color_Code"+;
3710 " , case when s.Lbl_Code = ''"+;
3711 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3712 " when s.Lbl_Code = ''"+;
3713 " and c.Resv_Label = 'V'"+;
3714 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3715 " else s.lbl_code"+;
3716 " end as lbl_code"+;
3717 " , s.lbl_code as lbl_codeOrig"+;
3718 " , c.resv_label"+;
3719 " , s.DIMENSION"+;
3720 " , s.Sizebucket"+;
3721 " , s.SLN_UPC as upc"+;
3722 " , s.pkey"+;
3723 " , C.Confirm_UPC"+;
3724 " , s.size_desc"+;
3725 " , '" + Trim(pceipoTS) + "' as Src"+;
3726 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3727 " from " + pceipoTD_tmp + " d"+;
3728 " join " + pceipoTS_tmp + " s"+;
3729 " on s.fkey = d.pkey"+;
3730 " join zzeipocr C"+;
3731 " on d.customer = C.customer"+;
3732 " and d.division = C.division"+;
3733 " left join zzxscolr sc"+;
3734 " on sc.division = d.division"+;
3735 " and sc.style = s.style"+;
3736 " and sc.color_code = s.color_code"+;
3737 " and sc.lbl_code = c.lbl_code"+;
3738 " and sc.dimension = s.dimension"+;
3739 " left join zzxrupcd rc " + ;
3740 " on rc.division = d.division"+;
3741 " and rc.style = s.style"+;
3742 " and rc.new_color = s.color_code"+;
3743 " and rc.lbl_code = c.lbl_code"+;
3744 " and rc.dimension = s.dimension"+;
3745 " where d.Customer > ''"+;
3746 " and s.SLN_SKU > ''"+;
3747 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3748 " and d.Division > ''"+;
3749 " and s.Style > ''"+;
3750 " and s.Color_Code > ''"+;
3751 " and c.Confirm_UPC = 'Y'"+;
3752 " and d.Rng_Style > ''"
3753 Endif
3754
3755 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3756 Select(lnOldSelect)
3757 Return lcSql
3758 Endproc
3759 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3760
3761 *-----------------------------------------------------------------------------------
3762
3763 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3764 PROCEDURE MarkHeaderwithDetailOrSLNInError
3765 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3766 * This is customized method from clsEDI
3767
3768 LOCAL llRetVal, lnOldSelect
3769 LOCAL lnBadOrderCount
3770 llRetVal = .T.
3771 lnOldSelect = SELECT()
3772
3773 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3774 pcEW = "E"
3775 ENDIF
3776 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3777 LOCAL lcErrorMsg, lcErrorMsgSLN
3778 lnBadOrderCount = 0
3779 IF pcEW = 'W'
3780 lcErrorMsg = "Has Warnings in Details."
3781 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3782 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3783 ELSE
3784 lcErrorMsg = "Has Errors in Details."
3785 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3786 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3787
3788 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3789 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3790 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3791 ENDIF
3792
3793 SELECT tcBadOrders
3794 IF THIS.lUserInterface
3795 * Init Thermometer
3796 THIS.InitThermo(lnBadOrderCount)
3797 l_nThermoCnt = 0
3798 ENDIF
3799 SCAN
3800 IF THIS.lUserInterface
3801 * Advance progress bar, if we're using one.
3802 l_nThermoCnt = l_nThermoCnt + 1
3803 THIS.AdvanceThermo(l_nThermoCnt)
3804 ENDIF
3805 SELECT (pceipoTH)
3806 IF pcEW = 'W'
3807 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3808 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3809 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3810 IN (pceipoTH)
3811 ENDIF
3812 ENDIF
3813 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3814 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3815 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3816 IN (pceipoTH)
3817 ENDIF
3818 ENDIF
3819 ELSE
3820 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3821 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3822
3823 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3824 IN (pceipoTH)
3825 ENDIF
3826 ENDIF
3827 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3828 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3829
3830 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3831 IN (pceipoTH)
3832 ENDIF
3833 ENDIF
3834 ENDIF
3835 ENDSCAN
3836 USE IN tcBadOrders
3837 USE IN tcBadOrdersSLN
3838
3839 IF THIS.lUserInterface
3840 THIS.ResetThermo()
3841 ENDIF
3842 SELECT(lnOldSelect)
3843 RETURN llRetVal
3844 ENDPROC
3845 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3846
3847 *-----------------------------------------------------------------------------------
3848
3849 *--- TR 1013007 NH
3850 *--- checks if pceipoTH.req_855 is 'R'
3851 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
3852 *--- if default status value is not empty then set Send855 flag to true and return true
3853 *--- if default status value is empty then set Send855 flag to true and return false and
3854 *--- set error message 'Missing 855 status code'
3855 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
3856 *--- then set Send855 flag to true and return false and
3857 *--- set error message 'Missing 855 status code'
3858
3859 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
3860 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
3861 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
3862 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
3863 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
3864
3865
3866 Procedure Check855Required
3867 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
3868
3869 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
3870 llRetVal = .T.
3871 lnOldSelect = Select()
3872 lcOldPO_num = ""
3873 lcPO_Status_855 = ""
3874 This.LogEntry("Starting procedure" + Program())
3875 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
3876
3877 *--- prepare detail zzeipotd for cascading status_855 code
3878 Select(pceipoTD)
3879 lnOldOrder_TD = Val(Sys(21)) && getting the current order
3880 Set Order To Tagno('FKEY') && settting order by 'fkey'
3881
3882 Select(pceipoTH)
3883 Scan For req_855 = 'R'
3884 Scatter Name loEiPOth Memo
3885 *--- when this.lSend855 flag is true then data will be sent to server
3886 This.lSend855 = .T.
3887
3888 *--- TR 1040432 MAY-20-2009 BR
3889 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
3890 If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
3891 *=== TR 1040432 MAY-20-2009 BR
3892 Select(pceipoCR)
3893 If Auto_855 = 'Y'
3894 If Not Empty(def_855)
3895 *--- set default value
3896 loEiPOth.status_855 = def_855
3897 *--- TR 1080293 KISHORE 26-AUG-2014
3898 IF NOT EMPTY(def_855dtl)
3899 lcDetail855Code = EVALUATE(pceipoCR + ".def_855dtl")
3900 REPLACE ALL status_855 WITH lcDetail855Code ;
3901 IN (pceipoTD) ;
3902 FOR fkey = loeipoTH.pkey AND EMPTY(EVALUATE(pceipoTD + ".status_855"))
3903 ELSE
3904 *=== TR 1080293 KISHORE 26-AUG-2014
3905 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
3906 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
3907*!* llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
3908 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
3909 ENDIF && TR 1080293 KISHORE 26-AUG-2014
3910 Else
3911 loEiPOth.Errs_flg_h = 'Y'
3912 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
3913 Endif
3914 Endif
3915 Endif
3916
3917 *--- status_855 code is still empty
3918 If Empty(loEiPOth.status_855)
3919 loEiPOth.Errs_flg_h = 'Y'
3920 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
3921 Endif
3922
3923 *--- check if defferent status_855 code exists in orders with same po number
3924 If lcOldPO_num <> loEiPOth.po_num
3925 lcOldPO_num = loEiPOth.po_num
3926 lcPO_Status_855 = loEiPOth.status_855
3927 Else
3928 If lcPO_Status_855 <> loEiPOth.status_855
3929 loEiPOth.Errs_flg_h = 'Y'
3930 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
3931 Endif
3932 Endif
3933
3934 *--- all records will only be get updated. No insert is need here.
3935 Select(pceipoTH)
3936 Gather Name loEiPOth Memo
3937
3938 If Not llRetVal
3939 Exit
3940 Endif
3941 Endscan
3942 *--- set back to old order by
3943 Select(pceipoTD)
3944 Set Order To (lnOldOrder_TD)
3945 *-- when one order is flaged error then all order of PO will be make
3946 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
3947 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
3948 Select(lnOldSelect)
3949 Return llRetVal
3950
3951 ENDPROC
3952
3953 *-----------------------------------------------------------------------------------
3954
3955 *--- must set order by 'FKey' in pceipoTD
3956 Procedure Cascade855AckCode
3957 Lparameters poeipoTH, pceipoTD
3958
3959 Local llRetVal, lnOldSelect
3960 lnOldSelect = Select()
3961 llRetVal = .T.
3962
3963 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
3964 Return .F.
3965 Endif
3966 *- 1034481 10/06/08 YIK
3967 *- Cascade ALL status codes to details.
3968 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
3969 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
3970 Select(pceipoTD)
3971 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
3972 Scan While fkey = poeipoTH.pkey
3973 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
3974 Endscan
3975 ENDIF
3976 *- 1034481
3977 *- Endif
3978
3979 Select(lnOldSelect)
3980 Return llRetVal
3981 Endproc
3982
3983 *----------------------------------------------------------------------------------------
3984 *--- TR 1034481 NH
3985 PROCEDURE MarkHeaderForMissing855ControlRef
3986 LPARAMETERS pceipoTH
3987
3988 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
3989
3990 llRetVal = .t.
3991 lnOldSelect = SELECT()
3992 lcZzeoprcr = "Oprcr" + SYS(2015)
3993 lcZzxlookp = "LOOKP" + SYS(2015) && TR 1083402 20-Jan-2015 Partha
3994
3995 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
3996
3997 *--- TR 1083402 20-Jan-2015 Partha ---
3998*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
3999
4000 llRetVal = llRetVal and v_sqlexec("select customer, division, ack29_req from zzeoprcr", lcZzeoprcr)
4001 llRetVal = llRetVal and v_sqlexec("SELECT p.lk_code FROM zzxlookp p WHERE p.Lk_Type ='ACK29 Codes' ", lcZzxlookp)
4002 *=== TR 1083402 20-Jan-2015 Partha ===
4003
4004 IF USED(lcZzeoprcr)
4005
4006 SELECT (lcZzeoprcr) && TR 1083402 20-Jan-2015 Partha
4007
4008 INDEX on customer TAG customer
4009 INDEX on division TAG division
4010
4011 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
4012 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
4013 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
4014
4015 *--- TR 1083402 20-Jan-2015 Partha ---
4016 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Valid ACK29 Code required.' + CRLF ;
4017 from (pceipoTH) th ;
4018 JOIN (pceipoTD) td ON th.pkey=td.fkey ;
4019 WHERE th.req_855 ='R' ;
4020 AND EXISTS ( select c.customer from (lcZzeoprcr) c ;
4021 WHERE c.customer = th.customer AND c.division = th.division AND c.ack29_req='Y') ;
4022 AND ( EMPTY(td.ack29) ;
4023 OR NOT EXISTS (SELECT 1 FROM (lcZzxlookp) p WHERE p.LK_CODE = td.ack29 ))
4024 *=== TR 1083402 20-Jan-2015 Partha ===
4025
4026 USE IN (lcZzeoprcr)
4027 USE IN (lcZzxlookp) && TR 1083402 20-Jan-2015 Partha
4028 ENDIF
4029
4030 SELECT(lnOldSelect)
4031 RETURN llRetVal
4032
4033 ENDPROC
4034 *=== TR 1034481 NH
4035 *----------------------------------------------------------------------------------------
4036
4037 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
4038
4039 Local laTables[4]
4040 laTables[1] = "VzzeiPOth_iPOproc"
4041 laTables[2] = "VzzeiPOtd_iPOproc"
4042 laTables[3] = "VzzeiPOts_iPOproc"
4043 * --- TR 1018184 RLN 1018184
4044 laTables[4] = "VzzeiPOtsac_iPOproc"
4045
4046 Local llRetVal, llBeganTransaction, loEiPOth
4047 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
4048 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
4049
4050 llRetVal = .T.
4051
4052 With This
4053 .LogEntry("Starting Program : " + Program())
4054 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
4055
4056 Select(pceipoTH)
4057 Scan
4058 Scatter Name loEiPOth Memo
4059 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
4060 Select('VzzeiPOth_iPOproc')
4061 Gather Name loEiPOth Memo
4062 Endif
4063 Endscan
4064
4065 Select(pceipoTD)
4066 Scan
4067 Scatter Name loEiPOtd Memo
4068 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
4069 Select('VzzeiPOtd_iPOproc')
4070 Gather Name loEiPOtd Memo
4071 Endif
4072 Endscan
4073
4074 Select(pceipoTS)
4075 Scan
4076 Scatter Name loeipoTS Memo
4077 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
4078 Select('VzzeiPOts_iPOproc')
4079 Gather Name loeipoTS Memo
4080 Endif
4081 Endscan
4082
4083 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
4084 If This.BeginTransaction()
4085 llRetVal = This.Tableupdate(@laTables)
4086 If llRetVal
4087 This.EndTransaction()
4088 Else
4089 This.RollbackTransaction()
4090 Endif
4091 Endif
4092 *--- close views.
4093 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
4094 Endwith
4095
4096 Return llRetVal
4097
4098 Endfunc
4099
4100 *----------------------------------------------------------------------------------------
4101
4102 Procedure Run855Process
4103 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4104 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
4105 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4106
4107 Local lnOldSelect, llRetVal, loStatusCur
4108 lnOldSelect = Select()
4109 llRetVal = .T.
4110 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4111 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4112 Local lcStatusCur, loStatus
4113 lcStatusCur = Sys(2015)
4114 With This
4115
4116 *--- TR 1044017 07-JAN-2010 HNISAR
4117*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
4118 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
4119 *=== TR 1044017 07-JAN-2010 HNISAR
4120
4121 .LogEntry("Starting program " + Program())
4122
4123 * --- TR 1048571 9/9/10 CM
4124 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
4125 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
4126 * === TR 1048571 9/9/10 CM
4127
4128 If llRetVal
4129 Select (lcStatusCur )
4130 Scatter Name loStatus
4131 Use In (lcStatusCur)
4132 ENDIF
4133 *- 1034481 10/03/08 YIK
4134 *- Check if there are no 855(o) to process
4135 llHas855ToSend = .T.
4136
4137 *--- req_855 must be more the status missing count
4138 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
4139 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
4140 *-- move 850 data to 855 transaction
4141 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
4142
4143 *- 1034481 10/03/08 YIK
4144 *- Added parameter pceipoTH and llHas855ToSend
4145 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4146 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
4147 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
4148
4149 *--- TR 1044017 07-JAN-2010 HNISAR
4150*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4151 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4152 *===TR 1044017 07-JAN-2010 HNISAR
4153
4154 *- 1034481 10/03/08 YIK
4155 *- Check if there are no 855(o) to process
4156 IF llHas855ToSend
4157 *-- create flat files
4158 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4159 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
4160 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
4161 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
4162
4163 *--- update 855 flag of 850 tran header
4164 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
4165
4166 *--- TR 1044017 07-JAN-2010 HNISAR
4167*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
4168 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
4169 *=== TR 1044017 07-JAN-2010 HNISAR
4170
4171 *--- drop temp tables
4172 *- 1030497 02/29/08 TT
4173 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
4174 *!* .dropTempTable(lceoprth,.T.)
4175 *!* .dropTempTable(lceoprtd,.T.)
4176 *!* .dropTempTable(lceoprtc,.T.)
4177 *!* .dropTempTable(lceoprta,.T.)
4178 *!* .dropTempTable(lceoprth_notes,.T.)
4179 *!* .dropTempTable(lceoprtd_notes,.T.)
4180 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
4181 .oCopyUtil.dropTempTable(lceoprth,.T.)
4182 .oCopyUtil.dropTempTable(lceoprtd,.T.)
4183 .oCopyUtil.dropTempTable(lceoprtc,.T.)
4184 .oCopyUtil.dropTempTable(lceoprta,.T.)
4185 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
4186 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
4187
4188 *- 1034481 10/03/08 YIK
4189 ELSE
4190 .LogEntry("No 855(o) transaction data to send.")
4191 ENDIF
4192 *= 1034481 *- 1030497 02/29/08 TT
4193 Endif
4194
4195 *- 1034481 10/03/08 YIK
4196 *- Added ..AND loStatus.STATUS_855_MISSING > 0
4197 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
4198 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
4199 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
4200 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
4201 .oHostProcess.c855Msg
4202 Endif
4203 Release loStatus
4204 Endwith
4205
4206 Select(lnOldSelect)
4207 Return llRetVal
4208
4209 Endfunc
4210
4211 *----------------------------------------------------------------------------------------
4212
4213 Procedure get855Status
4214 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4215 Lparameters tcCursor, pceipoTH
4216
4217 * --- TR 1048571 9/9/10 CM
4218 *Local lcSQL, lnOldSelect,llRetVal
4219 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4220
4221 lceipoth = "#Ipoth" + SYS(2015)
4222 * === TR 1048571 9/9/10 CM
4223
4224 lnOldSelect = Select()
4225 llRetVal = .T.
4226
4227 * --- TR 1048571 9/9/10 CM
4228 With This
4229 .cSQLTempTable=""
4230 IF .GenerateSQLTempTable(pceipoTH)
4231 IF .PopulateSQLTempTable(pceipoTH)
4232 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4233 llRetVal = llRetVal And v_SqlExec(lcSQL)
4234 ENDIF
4235 ENDIF
4236 Endwith
4237 * === TR 1048571 9/9/10 CM
4238
4239 *- TR 1100974 FH - taking out This.cFilterCriteria
4240 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4241 lcSQL = " select sum(1) rec_count, " + ;
4242 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4243 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4244 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4245 " from " + lceipoth + " h "
4246
4247 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4248 Select(lnOldSelect)
4249 Return llRetVal
4250 Endproc
4251
4252 *----------------------------------------------------------------------------------------
4253
4254 Procedure MoveTo855TempTransaction
4255 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4256 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4257 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4258
4259 Local llRetVal, lnOldSelect
4260 lnOldSelect = Select()
4261 llRetVal = .T.
4262 With This
4263 *--- create temporary 855 transaction tables at server
4264 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4265 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4266
4267 *--- copy data from 850 trans table to 855 temp trans tables
4268 *- 1034481 10/03/08 YIK
4269 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4270 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4271 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4272
4273 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4274 IF plHas855ToSend
4275 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4276 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4277
4278 *--- update header division from detail
4279 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4280 ENDIF
4281 *= 1034481
4282 Endwith
4283
4284 Select(lnOldSelect)
4285 Return llRetVal
4286
4287 Endproc
4288
4289 *----------------------------------------------------------------------------------------
4290
4291 Procedure CreateOPRTempTables
4292 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4293
4294 Local llRetVal, lnOldSelect, lcUnique
4295 lnOldSelect = Select()
4296 llRetVal = .T.
4297 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4298 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4299 AND Vartype(pcRefeoprtd_notes) == "C" )
4300
4301 lcUnique = Sys(2015)
4302 With This
4303 .LogEntry("Starting " + Program())
4304 .LogEntry("Creating OPR Temp Tables.")
4305
4306 *--- zzeipoth
4307 pcRefeoprth = "#zzeoprth" + lcUnique
4308 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4309 llRetVal = llRetVal And v_SqlExec(lcSQL)
4310
4311 *--- TR 1044208
4312 .oHostProcess.AddToTempTables(pcRefeoprth)
4313 *=== TR 1044208
4314
4315 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4316 *--- zzeipotd
4317 pcRefeoprtd = "#zzeoprtd" + lcUnique
4318 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4319 llRetVal = llRetVal And v_SqlExec(lcSQL)
4320 *--- TR 1044208
4321 .oHostProcess.AddToTempTables(pcRefeoprtd)
4322 *=== TR 1044208
4323 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4324
4325 *--- zzeipotc
4326 pcRefeoprtc = "#zzeoprtc" + lcUnique
4327 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4328 llRetVal = llRetVal And v_SqlExec(lcSQL)
4329 *--- TR 1044208
4330 .oHostProcess.AddToTempTables(pcRefeoprtc )
4331 *=== TR 1044208
4332 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4333
4334 *--- zzeipota
4335 pcRefeoprta = "#zzeoprta" + lcUnique
4336 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4337 llRetVal = llRetVal And v_SqlExec(lcSQL)
4338 *--- TR 1044208
4339 .oHostProcess.AddToTempTables(pcRefeoprta )
4340 *=== TR 1044208
4341 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4342
4343 *---- sysnotes_oprth
4344 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4345 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4346 llRetVal = llRetVal And v_SqlExec(lcSQL)
4347 *--- TR 1044208
4348 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4349 *=== TR 1044208
4350 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4351
4352 *---- sysnotes_oprtd
4353 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4354 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4355 llRetVal = llRetVal And v_SqlExec(lcSQL)
4356 *--- TR 1044208
4357 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4358 *=== TR 1044208
4359 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4360
4361 Endwith
4362
4363 Select(lnOldSelect)
4364 Return llRetVal
4365
4366 Endproc
4367
4368 *----------------------------------------------------------------------------------------
4369
4370 Procedure IPODataToOPRTmpTable
4371 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4372 pceipoTD
4373 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4374 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4375 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4376
4377 lcOPR_TMP = ""
4378 lnOldSelect = Select()
4379 llRetVal = .T.
4380 lcCommonFields = ""
4381 *-TR 1100974 FH - filter for all
4382 *lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4383 lcFilter = " where 1 = 1 "
4384 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4385 lcLeftOnlyDefaults = ""
4386 lcLeftOnlyFields = ""
4387 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4388
4389 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4390
4391 * --- TR 1048571 9/9/10 CM
4392 lcipotd = "#Zzeipotd" + SYS(2015)
4393 * === TR 1048571 9/9/10 CM
4394
4395 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4396
4397 With This
4398 *-- TR 1044604 DEC-29-2009 BR
4399 .cSQLTempTable=""
4400 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4401*!* IF .GenerateSQLTempTable(pceipoTH)
4402*!* IF .PopulateSQLTempTable(pceipoTH)
4403 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4404 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4405 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4406
4407 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4408 &lcCmnd
4409
4410*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4411 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4412 IF .GenerateSQLTempTable(lcTempIPOTH)
4413
4414 IF .PopulateSQLTempTable(lcTempIPOTH)
4415 Use In Select(lcTempIPOTH)
4416 *=== TR 1043191 23-Oct-2009 JK ===
4417 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4418 llRetVal = llRetVal And v_SqlExec(lcSQL)
4419 ENDIF
4420 ENDIF
4421 *== TR 1044604 DEC-29-2009 BR
4422
4423 * --- TR 1048571 9/9/10 CM
4424 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4425 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4426 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4427 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4428 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4429 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4430 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4431 *.ScatterGather(pceipoTD, "tcIpoDtls")
4432 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4433 .ScatterGather("__tceipoTD", "tcIpoDtls")
4434 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4435
4436 SELECT tcIpoDtls
4437 LOCATE
4438 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4439 .cSQLTempTable=""
4440 IF .GenerateSQLTempTable("tcFinalDtls")
4441 IF .PopulateSQLTempTable("tcFinalDtls")
4442 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4443 llRetVal = llRetVal And v_SqlExec(lcSQL)
4444 ENDIF
4445 ENDIF
4446 * === TR 1048571 9/9/10 CM
4447
4448 *--- IPOTH -> OPRTH
4449 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4450 *--- lcCalFldsOPR : fields need calculation or map or constant values
4451 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4452
4453 *--- for example if term_type field data will go to terms_type field and blank term_type
4454 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4455 *!* lcCalFldsOPR = "term_type, terms_type"
4456 *!* lcCalFldsOPR_val = "' ',term_type"
4457 lcCalFldsOPR_SQL = "'PROC_855'"
4458 lcCalFldsOPR = "PROC_855"
4459 lcCalFldsOPR_val = "' '"
4460 lcFlds = ""
4461 lcValues = ""
4462
4463 lcOPR_TMP = pceoprth
4464 *- 1030497 02/29/08 TT
4465 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4466 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4467
4468 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4469 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4470 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4471 *- 1030497 02/29/08 TT
4472 *--- 1034481 set correct flag value 'P' for Proc_855
4473 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4474 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4475 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4476 llRetVal = llRetVal And v_SqlExec(lcSQL)
4477
4478 *--- IPOTD -> OPRTD
4479 lcCalFldsOPR_SQL = ""
4480 lcCalFldsOPR = ""
4481 lcCalFldsOPR_val = ""
4482 lcFlds = ""
4483 lcValues = ""
4484
4485 lcOPR_TMP = pceoprtd
4486 *- 1030497 02/29/08 TT
4487 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4488 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4489 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4490 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4491 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4492 *- 1030497 02/29/08 TT
4493 *- 1034481 10/03/08 YIK
4494 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4495 DECLARE la855Cnt[1]
4496 la855Cnt[1] = 0
4497 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4498 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4499 " INTO ARRAY la855Cnt"
4500 &lcSQL
4501
4502 plHas855ToSend = (la855Cnt[1] > 0)
4503
4504 IF plHas855ToSend
4505 *--- 1034481 set correct flag value 'P' for Proc_855
4506 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4507 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4508 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4509 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4510 " ( select * from " + lcipoth + " h " + lcFilter + ;
4511 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4512
4513 llRetVal = llRetVal And v_SqlExec(lcSQL)
4514
4515 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4516 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4517 " on d.fkey = h.pkey "
4518 llRetVal = llRetVal And v_SqlExec(lcSQL)
4519
4520 *--- IPOTC -> OPRTC
4521 lcOPR_TMP = pceoprtc
4522 lcCalFldsOPR_SQL = ""
4523 lcCalFldsOPR = ""
4524 lcCalFldsOPR_val = ""
4525 lcFlds = ""
4526 lcValues = ""
4527
4528 *- 1030497 02/29/08 TT
4529 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4530 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4531 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4532 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4533 *- 1030497 02/29/08 TT
4534 *--- 1034481 set correct flag value 'P' for Proc_855
4535 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4536 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4537 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4538 " (select * from " + lcipoth + " h " + lcFilter + ;
4539 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4540
4541 llRetVal = llRetVal And v_SqlExec(lcSQL)
4542
4543 *--- IPOTA -> OPRTA
4544 lcOPR_TMP = pceoprta
4545 lcCalFldsOPR_SQL = ""
4546 lcCalFldsOPR = ""
4547 lcCalFldsOPR_val = ""
4548 lcFlds = ""
4549 lcValues = ""
4550
4551 *- 1030497 02/29/08 TT
4552 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4553 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4554 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4555 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4556 *- 1030497 02/29/08 TT
4557 *--- 1034481 set correct flag value 'P' for Proc_855
4558
4559 *--- 1042063 10/12/09 CM
4560 *--- We're unconditionally going to remove characters greater than 25,
4561 * for 855 address1,address2 fields since max field size is 25.
4562 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4563 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4564 *=== 1042063 10/12/09 CM
4565
4566 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4567 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4568 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4569 " (select * from " + lcipoth + " h " + lcFilter + ;
4570 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4571
4572 llRetVal = llRetVal And v_SqlExec(lcSQL)
4573
4574 *--- sysnotes - zzeoprth
4575 lcOPR_TMP = pceoprth_notes
4576 *--- 1034481 set correct flag value 'P' for Proc_855
4577 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4578 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4579 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4580 " (select * from " + lcipoth + " h " + lcFilter + ;
4581 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4582
4583 llRetVal = llRetVal And v_SqlExec(lcSQL)
4584
4585 *--- sysnotes - zzeoprtd
4586 lcOPR_TMP = pceoprtd_notes
4587 *--- 1034481 set correct flag value 'P' for Proc_855
4588 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4589 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4590 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4591 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4592 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4593 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4594 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4595
4596 llRetVal = llRetVal And v_SqlExec(lcSQL)
4597 *- 1034481 10/03/08 YIK
4598 ENDIF &&plHas855ToSend
4599
4600 *-- TR 1044604 DEC-29-2009 BR
4601 lcSQL = "DROP TABLE " + lcipoth
4602 v_SqlExec(lcSQL)
4603 *== TR 1044604 DEC-29-2009 BR
4604 Endwith
4605
4606 * --- TR 1048571 9/9/10 CM
4607 USE IN SELECT("tcIpoDtls")
4608 USE IN SELECT("tcFinalDtls")
4609 USE IN SELECT("tcTmpDtls")
4610 * === TR 1048571 9/9/10 CM
4611
4612 Select(lnOldSelect)
4613 Return llRetVal
4614 Endproc
4615
4616
4617 *----------------------------------------------------------------------------------------
4618
4619 Procedure ResetPkey_OPRTmpTable
4620 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4621
4622 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4623 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4624
4625 lnOldSelect = Select()
4626 llRetVal = .T.
4627 lcOPR_TMP = pceoprth
4628 lnRecCount = 0
4629 lnMaxPkey = 0
4630 lcUnique = Sys(2015)
4631
4632 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4633 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4634 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4635 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4636 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4637 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4638 lcNewPkeyCol_TH = "PKEY_OPRTH"
4639 lcNewPkeyCol_TD = "PKEY_OPRTD"
4640 With This
4641 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4642 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4643 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4644 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4645 *- 1030497 02/29/08 TT
4646 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4647 *- TR 1092952 - FH typo, change sysnotes -> zzeoprth
4648 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "zzeoprth", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4649 *- 1030497 02/29/08 TT
4650
4651 *--- fkey updates for all chield tables
4652 *--- ipotd -> oprtd : fkey
4653 lcOPR_TMP = pceoprtd
4654 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4655 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4656 llRetVal = llRetVal And v_SqlExec(lcSQL)
4657
4658 *--- ipota -> oprta : fkey
4659 lcOPR_TMP = pceoprta
4660 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4661 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4662
4663 llRetVal = llRetVal And v_SqlExec(lcSQL)
4664
4665 *--- ipotc -> oprtc : fkey
4666 lcOPR_TMP = pceoprtc
4667 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4668 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4669 llRetVal = llRetVal And v_SqlExec(lcSQL)
4670
4671 *-- sysnotes :
4672 *-- table_name
4673 lcOPR_TMP = pceoprth_notes
4674 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4675 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4676 llRetVal = llRetVal And v_SqlExec(lcSQL)
4677
4678 *-- update detail pkey
4679 *- 1030497 02/29/08 TT
4680 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4681 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4682 *- 1030497 02/29/08 TT
4683
4684 *-- sysnotes : update table_name, fkey
4685 lcOPR_TMP = pceoprtd_notes
4686 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4687 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4688 llRetVal = llRetVal And v_SqlExec(lcSQL)
4689
4690 *--- update header notes pkey
4691 *- 1030497 02/29/08 TT
4692 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4693 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4694 *- 1030497 02/29/08 TT
4695 *--- update detail notes pkey
4696 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4697 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4698
4699 *-- update pkey
4700 *- 1030497 02/29/08 TT
4701 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4702 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4703
4704 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4705 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4706 *- 1030497 02/29/08 TT
4707
4708 *--- drop all temp tables
4709 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4710 *- 1030497 02/29/08 TT
4711 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4712 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4713 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4714 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4715 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4716
4717 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4718 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4719 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4720 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4721 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4722 *- 1030497 02/29/08 TT
4723
4724 Endwith
4725
4726 Select(lnOldSelect)
4727 Return llRetVal
4728 Endproc
4729
4730 *----------------------------------------------------------------------------------------
4731
4732 Procedure UpdateOPRTempHDRDivisionFromDtl
4733 Lparameters pcRefeoprth,pcRefeoprtd
4734
4735 Local llRetVal, lnOldSelect
4736 llRetVal = .T.
4737 lnOldSelect = Select()
4738 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4739 llRetVal = llRetVal And v_SqlExec(lcSQL)
4740 Select(lnOldSelect)
4741 Return llRetVal
4742
4743 Endproc
4744
4745 *----------------------------------------------------------------------------------------
4746
4747 Procedure Launch855Process
4748 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4749 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4750 Local llRetVal, lnOldSelect
4751 lnOldSelect = Select()
4752 llRetVal = .T.
4753
4754 Local lo855
4755 Local lc855DataTbls, lc855Msg
4756 lcFilterCriteria = ""
4757 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4758 llRetVal = (Vartype(lo855) = 'O')
4759 lc855Msg = ""
4760
4761 If llRetVal
4762 *--- TR 1037976 JAN-22-2008 BR
4763 *lo855 = This
4764 lo855.oLog = THIS.oLog
4765 *=== TR 1037976 JAN-22-2008 BR
4766 lo855.oFrmProgressBar = This.oFrmProgressBar
4767 Endif
4768 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4769 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4770 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4771 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4772 This.oHostProcess.c855Msg = lc855Msg
4773 Select(lnOldSelect)
4774 Return llRetVal
4775
4776 Endproc
4777
4778 *----------------------------------------------------------------------------------------
4779
4780 Procedure Update855ProcFlag
4781 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4782
4783 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4784 lnOldSelect = Select()
4785 llRetVal = .T.
4786 lcCursor = Sys(2015)
4787 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4788 *--- 1034481 set correct flag value 'P' for Proc_855
4789 *- 1034481 10/03/08 YIK
4790 *- Also populate error flag and error message from zzeoprth to the 850(i)
4791 *- otherwise 850(i) goes through while the 855(o) errors out.
4792 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4793 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4794 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4795 " t on o.pkey = t.pkey_oprth" + ;
4796 " LEFT JOIN zzeoprth th " + ;
4797 " on th.pkey = t.pkey_oprth"
4798
4799 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4800 If llRetVal
4801 Select (lcCursor)
4802 SCAN
4803 Scatter Name loCursor Memo
4804 DO CASE
4805 CASE proc_855 = 'P'
4806 *- 1014298 12/02/05 YIK, NH
4807 *- it was ..proc_855 WITH 'Y'
4808 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4809 CASE errs_flg_h = 'Y'
4810 REPLACE errs_flg_h WITH 'Y', ;
4811 errs_msg_h WITH errs_msg_h + ;
4812 " ---- 855(o) process ----" + CRLF + ;
4813 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4814 For pkey = loCursor.pkey In (pceipoTH)
4815 OTHERWISE
4816 ENDCASE
4817 Endscan
4818 Endif
4819 *= 1034481
4820 Select(lnOldSelect)
4821 Return llRetVal
4822
4823 Endproc
4824
4825 *----------------------------------------------------------------------------------------
4826
4827 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4828
4829 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4830 *!* In this case label must be with empty.
4831
4832 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4833
4834 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4835 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4836 *!* style '9040' color 'RED' label 'WM'.
4837
4838 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4839 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4840 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4841
4842 Procedure CheckMultiUPC
4843 Lparameters tcEiPOth, tcEiPOtd
4844
4845 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
4846
4847 llRetVal = True
4848 lnSelect = Select()
4849
4850 With This
4851
4852 lcWorkAlias = GetUniqueFileName()
4853
4854 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4855 *-- Change h.division to d.division
4856 SELECT d.pkey, ;
4857 h.customer, ;
4858 d.division, ;
4859 d.upc ;
4860 FROM tceipoth h ;
4861 JOIN tceipotd d ;
4862 ON h.pkey = d.fkey ;
4863 INTO ;
4864 CURSOR (lcworkAlias)
4865
4866 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
4867 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
4868 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
4869 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
4870
4871 If llRetVal
4872
4873 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4874 *-- Included 'V' in the condition of pocr.resv_label
4875 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
4876 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
4877
4878 lcSql = " SELECT upcd.lbl_code, t.* " + ;
4879 " FROM " + lcTempTbl + " t " + ;
4880 " JOIN zzemupch upch " + ;
4881 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
4882 " JOIN zzemupcd upcd " + ;
4883 " ON upch.pkey = upcd.fkey " + ;
4884 " AND upcd.active_ok = 'Y' " + ;
4885 " JOIN " + This.c850Control + " pocr " + ;
4886 " ON pocr.customer = t.customer " + ;
4887 " AND pocr.division = t.division " + ;
4888 " AND pocr.lbl_code = upcd.lbl_code " + ;
4889 " AND pocr.resv_label IN ('Y','V') "
4890
4891 lcWorkAlias = GetUniqueFileName()
4892
4893 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
4894
4895 If Reccount(lcWorkAlias) > 0
4896 Select (tcEiPOtd)
4897 Scan
4898 lnPKey = pkey
4899
4900 Select(lcWorkAlias)
4901 Locat For pkey = lnPKey
4902
4903 If Found()
4904 lcLbl_code = lbl_code
4905 Select (tcEiPOtd)
4906 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
4907 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
4908 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
4909 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
4910 Endif
4911
4912 Select (tcEiPOtd)
4913 Endscan
4914 Endif
4915
4916 Endif
4917
4918 .TableClose(lcWorkAlias)
4919
4920 Endwith
4921
4922 Select (lnSelect)
4923 Return llRetVal
4924 Endproc
4925 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
4926
4927 *----------------------------------------------------------------------------------------
4928
4929 Procedure RangeStyle
4930 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
4931 Local llRetVal, lnOldSelect, lcErrs_Msg
4932 llRetVal = .T.
4933 lnOldSelect = Select()
4934
4935 *****************************************************************************
4936 * 1st Getting all range style (hdr/dtl) that relate to the
4937 * passing order line for this run
4938
4939 *--- TR 1038376 05-May-2009 Goutam
4940 LOCAL lctmpCursor
4941 lctmpCursor = GetUniqueFileName()
4942
4943 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
4944 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
4945
4946 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
4947 * TR 1059142 FH - adding h.ord_type to the group by clause
4948 *--- TR 1088126 2-JUL-2015 Venuk -- Added 'as price_code' else MAX(h.price_code) will be max_price_Code ===
4949 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) as price_code, h.ord_type FROM (pcTransHeader) h ;
4950 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4951 WHERE d.errs_flg_d <> 'Y' ;
4952 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
4953 INTO CURSOR __TmpCursor
4954
4955SET ASSERTS ON
4956ASSERT .f.
4957 .cSQLTempTable=""
4958 If .GenerateSQLTempTable('__TmpCursor')
4959 If .PopulateSQLTempTable('__TmpCursor')
4960 If !Empty(.cSQLTempTable)
4961 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4962 lcSqlString = "Update " + .cSQLTempTable + ;
4963 " Set price_code = coalesce((Select Top 1 price_code " + ;
4964 " From zzxcslsr " + ;
4965 " Where Customer = h.customer " + ;
4966 " and (Store = h.store or Store = '') " + ;
4967 " and (Division = h.division or Division = '') " + ;
4968 " and (Department = h.department or Department = '') " + ;
4969 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4970 " and price_code <> '' " + ;
4971 " order by rank_seq),'') " + ;
4972 " From " + .cSQLTempTable + " h"
4973
4974 llRetVal = v_sqlExec(lcSqlString)
4975
4976 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
4977 lcSqlString = "UPDATE " + .cSQLTempTable + ;
4978 " Set price_code = c.price_code "+;
4979 " From " + .cSQLTempTable + " h "+;
4980 " , zzocntrc c "+;
4981 " Where h.division = c.division " +;
4982 " and h.price_code = '' "
4983 llRetVal = v_sqlExec(lcSqlString)
4984 *- TR 1056061 FH 08/17/11
4985
4986
4987 IF llRetVal
4988 lcSqlString = "Select * from " + .cSQLTempTable
4989 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
4990
4991 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
4992 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4993*!* lcSqlString = "UPDATE h " + ;
4994*!* " SET price_code = c.price_code " + ;
4995*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
4996*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
4997*!* " on d.division = c.division " + ;
4998*!* " And d.customer = c.customer " + ;
4999*!* " And h.Store = c.Store " + ;
5000*!* " And h.department = c.department " + ;
5001*!* " And h.ord_type = c.ord_type " + ;
5002*!* "Where d.errs_flg_d <> 'Y' "
5003
5004 lcSqlString = "UPDATE h " + ;
5005 " SET price_code = c.price_code " + ;
5006 " From " + pcTransheader + " h " + ;
5007 " join " + lcTmpCursor + " c " + ;
5008 " on h.division = c.division " + ;
5009 " And h.customer = c.customer " + ;
5010 " And h.Store = c.Store " + ;
5011 " And h.department = c.department " + ;
5012 " And h.ord_type = c.ord_type " + ;
5013 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
5014
5015 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
5016
5017 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
5018 ENDIF
5019
5020 IF llRetVal
5021 *-1061331 FH - simpilifed update query
5022 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
5023 *UPDATE h SET h.errs_flg_h = 'Y', h.errs_msg_h = IIF(!EMPTY(h.errs_msg_h), h.errs_msg_h + CRLF + 'Invalid Price Code.','Invalid Price Code.') + CRLF ;
5024 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
5025 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
5026 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
5027
5028 UPDATE h SET h.errs_flg_h = 'Y', h.errs_msg_h = IIF(!EMPTY(h.errs_msg_h), h.errs_msg_h + CRLF + 'Invalid Price Code.','Invalid Price Code.') + CRLF ;
5029 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
5030
5031 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
5032 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
5033 *- TR 1054873 FH - changed error message
5034 &&UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = IIF(!EMPTY(d.errs_msg_d), d.errs_msg_d + CRLF + 'Invalid Price Code in header, Can not resolve Range Style Price.','Invalid Price Code in header, Can not resolve Range Style Price.') + CRLF ;
5035 &&UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = IIF(!EMPTY(d.errs_msg_d), d.errs_msg_d + CRLF + 'Invalid Price Code in header, Can not resolve Price Code in Customer Style Reference.','Invalid Price Code in header, Can not resolve Price Code in Customer Style Reference.') + CRLF ;
5036 *UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = IIF(!EMPTY(d.errs_msg_d), d.errs_msg_d + CRLF + 'Invalid Price Code in header, Can not resolve Price Code in Customer Sales Reference and Sales Order Control Reference.','Invalid Price Code in header, Can not resolve Price Code in Customer Sales Reference and Sales Order Control Reference.') + CRLF ;
5037 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
5038 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
5039 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
5040 ENDIF
5041
5042 endif
5043 endif
5044 endif
5045
5046 *--- TR 1088126 2-JUL-2015 Venuk
5047 IF This.oBPOSalesOrder.lRslv_pricecode_cssld
5048 SELECT CRS_pkey, d.pkey as dtlpkey, d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type, ;
5049 d.style, d.color_code, d.lbl_code, d.dimension ;
5050 FROM (pcTransHeader) h ;
5051 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
5052 WHERE d.errs_flg_d <> 'Y' ;
5053 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type, d.pkey ;
5054 INTO CURSOR __TmpCursor
5055
5056 .cSQLTempTable=""
5057 If .GenerateSQLTempTable('__TmpCursor')
5058 If .PopulateSQLTempTable('__TmpCursor')
5059 If !Empty(.cSQLTempTable)
5060
5061 lcSqlString = "Update " + .cSQLTempTable + ;
5062 " Set CRS_pkey = coalesce((Select Top 1 pkey " + ;
5063 " From zzxcslsr " + ;
5064 " Where Customer = h.customer " + ;
5065 " and (Store = h.store or Store = '') " + ;
5066 " and (Division = h.division or Division = '') " + ;
5067 " and (Department = h.department or Department = '') " + ;
5068 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
5069 " and price_code <> '' " + ;
5070 " order by rank_seq),'') " + ;
5071 " From " + .cSQLTempTable + " h"
5072 llRetVal = v_sqlExec(lcSqlString)
5073
5074 lcSqlString = ;
5075 " Select r.dtlpkey as dtlpkey, " + ;
5076 " case when Coalesce(d.price_code,'')='' then h.price_code else d.price_code end as price_Code " + ;
5077 " from zzxcslsr h " + ;
5078 " join "+ .cSQLTempTable + " r" + ;
5079 " on h.pkey = r.CRS_pkey " + ;
5080 " join zzxscolr c " + ;
5081 " on c.division = h.division " + ;
5082 " and c.style = r.style" + ;
5083 " and c.color_Code = r.color_Code " + ;
5084 " and c.lbl_Code = r.lbl_code " + ;
5085 " and c.dimension = r.dimension " + ;
5086 " join zzxcslsd d " + ;
5087 " on h.pkey = d.fkey " + ;
5088 " and h.group_Type = d.group_type " + ;
5089 " and d.group_code = " + ;
5090 " case when d.Group_type='A' then c.Group_Code1 " + ;
5091 " when h.Group_type='B' then c.Group_Code2 " + ;
5092 " when h.Group_type='C' then c.Group_Code3 " + ;
5093 " when h.Group_type='D' then c.Group_Code4 " + ;
5094 " when h.Group_type='E' then c.Group_Code5 " + ;
5095 " when h.Group_type='F' then c.Group_Code6 " + ;
5096 " when h.Group_type='G' then c.Group_Code7 " + ;
5097 " when h.Group_type='H' then c.Group_Code8 " + ;
5098 " when h.Group_type='I' then c.Group_Code9 " + ;
5099 " when h.Group_type='J' then c.Group_Code10 " + ;
5100 " when h.Group_type='K' then c.Group_Code11 " + ;
5101 " when h.Group_type='L' then c.Group_Code12 " + ;
5102 " when h.Group_type='M' then c.Group_Code13 end "
5103
5104 llRetVal = v_sqlExec(lcSqlString, "tcPriceCode")
5105
5106 If(USED("tcPriceCode"))
5107 SELECT tcPriceCode
5108 INDEX on dtlpkey TAG dtlpkey
5109 llRetval = .SetRelation("tcPriceCode", "dtlpkey", pcTransDetail,"pkey")
5110
5111 REPLACE ALL PRICE_CODE WITH tcPriceCode.price_Code IN (pcTransDetail)
5112
5113 Set Relation To
5114 USE IN tcPriceCode
5115 ENDIF
5116 UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = IIF(!EMPTY(d.errs_msg_d), d.errs_msg_d + CRLF + 'Invalid Price Code.','Invalid Price Code.') + CRLF ;
5117 from (pcTransDetail) d WHERE EMPTY(d.price_code) AND d.errs_flg_d <> 'Y'
5118
5119 ENDIF
5120 ENDIF
5121 ENDIF
5122 USE IN __TmpCursor
5123 ELSE
5124 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey where d.price_code=''
5125 Endif
5126 *=== TR 1088126 2-JUL-2015 Venuk
5127
5128 .cSQLTempTable=""
5129 *=== TR 1038376 05-May-2009 Goutam
5130 * additional past for range style verification/explotion
5131 *-- TR 1023892 5-3-07 BR
5132 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5133 IF .lALLOW_RANGE_HDR_LABEL
5134 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5135 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5136 SELECT DISTINCT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.Cust_lbl, h.price_code, d.org_price, d.sizebucket ;
5137 FROM (pcTransHeader) h, (pcTransDetail) d ;
5138 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5139 AND d.Errs_Flg_D= 'N' AND ;
5140 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5141 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5142 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5143 ELSE
5144 *=== TR 1023892 NH
5145 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5146 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5147 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
5148 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5149 FROM (pcTransHeader) h, (pcTransDetail) d ;
5150 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5151 And d.Errs_Flg_D= "N" And ;
5152 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5153 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5154 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5155 ENDIF && TR 1023892 NH
5156 With This
5157 .cSQLTempTable=""
5158 If .GenerateSQLTempTable('__TmpCursor')
5159 If .PopulateSQLTempTable('__TmpCursor')
5160 If !Empty(.cSQLTempTable)
5161
5162 .LogEntry("Exploding range style.")
5163 * Get range style header
5164 *- 1000984 9/11/03 YIK
5165 *- do not explode range styles type 'P'rint
5166 *- Added ..and h.rng_type <> 'P'
5167 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
5168 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
5169 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
5170 IF .lALLOW_RANGE_HDR_LABEL
5171 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5172 "Where h.division= t.division and h.rng_style = t.style and "+;
5173 "h.rng_color= t.color_code and h.rng_lbl= (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) and "+;
5174 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5175 ELSE
5176 *=== TR 1023892 NH
5177 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5178 "Where h.division= t.division and h.rng_style = t.style and "+;
5179 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5180 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5181 *= 1000984
5182 ENDIF && TR 1023892 NH
5183 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
5184
5185 * TAN 31891 - JAZ - 5/20/02
5186 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5187 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5188 * End TAN 31891 - JAZ - 5/20/02
5189
5190 If llHaveRangeStyleToExplode
5191 * Get range style detail
5192 *- 1000984 9/11/03 YIK
5193 *- do not explode range styles type 'P'rint
5194 *- Added ..and h.rng_type <> 'P'
5195
5196 *--- TR 1038376 05-May-2009 Goutam
5197 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5198
5199 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
5200 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
5201*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
5202*!* " case t.price_code when 'A' then h.a_price " + ;
5203*!* " when 'B' then h.b_price " + ;
5204*!* " when 'C' then h.c_price " + ;
5205*!* " when 'D' then h.d_price " + ;
5206*!* " when 'E' then h.e_price " + ;
5207*!* " else h.a_price end rnghdr_Price " + ;
5208*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5209*!* "join " + .cSQLTempTable + " t " +;
5210*!* "on h.division= t.division and h.rng_style = t.style and "+;
5211*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5212*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5213*!* " (case t.price_code when 'A' then h.a_price " + ;
5214*!* " when 'B' then h.b_price " + ;
5215*!* " when 'C' then h.c_price " + ;
5216*!* " when 'D' then h.d_price " + ;
5217*!* " when 'E' then h.e_price " + ;
5218*!* " else h.a_price end " + ;
5219*!* " <> t.org_price)" +;
5220*!* " AND t.sizebucket = h.rng_bk"
5221
5222 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5223 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
5224 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
5225 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
5226 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
5227 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
5228 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
5229 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
5230 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
5231 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5232
5233 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
5234 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5235 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
5236 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
5237 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
5238 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
5239 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
5240 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5241 " Left join zzxcsrgh cs "+ ;
5242 " on cs.hdrpkey = h.pkey "+ ;
5243 " and cs.dtlpkey = 0 " +;
5244 "join " + .cSQLTempTable + " t " +;
5245 "on h.division= t.division and h.rng_style = t.style and "+;
5246 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5247 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5248 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5249 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
5250 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
5251 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
5252 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
5253 " else coalesce(cs.a_price,h.a_price) end " + ;
5254 " <> t.org_price)" +;
5255 " AND t.sizebucket = h.rng_bk"+ ;
5256 " Where cs.customer = t.customer "
5257 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
5258 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
5259
5260 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5261 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
5262 lcSQLString= "UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = d.errs_msg_d + 'Range Style Price Variance - EDI Price: ' + ALLTRIM(STR(r.org_price,9,2)) + ' System Price: ' + ALLTRIM(STR(r.rnghdr_Price,9,2)) + CHR(10) " + ;
5263 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
5264 " on d.division= r.division and d.style = r.rng_style and " + ;
5265 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
5266 " d.dimension= r.Rng_Pack " + ;
5267 " join zzeipocr c on c.division = d.division and h.customer = c.customer " + ;
5268 " where d.rng_type <> 'P' AND case when h.price_err = '' then c.price_err else h.price_err end = 'Y' AND r.sizebucket = d.sizebucket" && TR 1092937 21-Jan-2016 Gurinder
5269
5270 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
5271
5272 *- TR 1048790 FH 10/04/10
5273 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
5274 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
5275 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5276
5277 IF .lALLOW_RANGE_HDR_LABEL
5278 SELECT DISTINCT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.Cust_lbl, h.price_code, d.org_price, d.sizebucket ;
5279 FROM (pcTransHeader) h, (pcTransDetail) d ;
5280 WHERE h.pkey = d.fkey ;
5281 AND d.Errs_Flg_D= 'N' AND ;
5282 Not EMPTY(h.price_code) AND ;
5283 d.rng_style= '' ;
5284 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5285 ELSE
5286 *--- TechRec 1084745 14-May-2015 jjanand === Added h.customer
5287 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5288 FROM (pcTransHeader) h, (pcTransDetail) d ;
5289 WHERE h.pkey = d.fkey ;
5290 And d.Errs_Flg_D= "N" And ;
5291 Not EMPTY(h.price_code) AND ;
5292 d.rng_style= '' ;
5293 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5294 ENDIF
5295
5296 .cSQLTempTable=""
5297 If .GenerateSQLTempTable('__TmpCursor')
5298 If .PopulateSQLTempTable('__TmpCursor')
5299 *- TR 1048790 FH 10/04/10
5300
5301 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5302 *-- TR 1040759 JUN-29-2009 BR
5303 IF .lALLOW_RANGE_HDR_LABEL
5304 *- TR 1048790 FH 10/04/10 - removed price check
5305 *- TR 1050589 12/13/10 FH
5306 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5307*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5308*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5309*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5310*!* "h.rng_color= t.color_code and h.rng_lbl = (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5311*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5312 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5313*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5314*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5315*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5316*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5317*!* "h.rng_color= t.color_code and h.rng_lbl = (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5318*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5319
5320 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5321 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5322 "join " + .cSQLTempTable + " t " +;
5323 "on h.division= t.division and h.rng_style = t.style and "+;
5324 "h.rng_color= t.color_code and h.rng_lbl= (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5325 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5326 " t.sizebucket = h.rng_bk"+ ;
5327 " Left join zzxcsrgh cs "+ ;
5328 " on cs.hdrpkey = h.pkey "+ ;
5329 " and cs.dtlpkey = d.pkey " +;
5330 " and cs.customer = t.customer " + ;
5331 " where d.fkey in " +;
5332 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5333 "Where h.division= t.division and h.rng_style = t.style and "+;
5334 "h.rng_color= t.color_code and h.rng_lbl = (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5335 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5336 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5337 *- TR 1050589 12/13/10 FH
5338 ELSE
5339 *== TR 1040759 JUN-29-2009 BR
5340 *- TR 1048790 FH 10/04/10 - removed price check
5341 *- TR 1050589 12/13/10 FH
5342 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5343
5344*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5345*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5346*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5347*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5348*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5349*!*
5350 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5351*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5352*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5353*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5354*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5355*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5356*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5357
5358 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5359 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5360 "join " + .cSQLTempTable + " t " +;
5361 "on h.division= t.division and h.rng_style = t.style and "+;
5362 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5363 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5364 " t.sizebucket = h.rng_bk"+ ;
5365 " Left join zzxcsrgh cs "+ ;
5366 " on cs.hdrpkey = h.pkey "+ ;
5367 " and cs.dtlpkey = d.pkey " +;
5368 " and cs.customer = t.customer " + ;
5369 " where fkey in " +;
5370 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5371 "Where h.division= t.division and h.rng_style = t.style and "+;
5372 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5373 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5374 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5375 *- TR 1050589 12/13/10 FH
5376 ENDIF && TR 1040759 JUN-29-2009 BR
5377 *=== TR 1038376 05-May-2009 Goutam
5378 endif &&- TR 1048790 FH 10/04/10
5379 ENDIF &&- TR 1048790 FH 10/04/10
5380
5381 *= 1000984
5382 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5383
5384 * turn Range detail to vertical (with sizebucket,size_desc)
5385 * have to explode in vertical format
5386 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5387 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5388 WHERE 0=1 Into Cursor __Range2
5389 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5390 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5391 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5392 If Used("__Range1")
5393 Use In __Range1
5394 Endif
5395 If Used("__Range2")
5396 Use In __Range2
5397 Endif
5398
5399 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5400 Select __RangH
5401 Index On pkey Tag pkey
5402 Select __RangD
5403 Index On division+Style Tag DivStyle
5404 Select tcRangeVer
5405 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5406 Set Order To RangeSKU
5407 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5408
5409 *****************************************************************************
5410 * 2). Validate "Run"- type of range style. divisible by range header qty
5411 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5412
5413 *****************************************************************************
5414 * 3). Explode range style only once good tran detail that have
5415 * matching range style. Vertical range style explosion
5416 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5417 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5418 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5419 Select Distinct d.pkey ;
5420 FROM __RangD r, (pcTransDetail) d ;
5421 WHERE d.Errs_Flg_D= "N" And ; &&no error
5422 d.rng_style= '' And ; &&never explode before
5423 r.division= d.division And r.rng_style = d.Style And ; && matching range
5424 r.rng_color= d.color_code And ;
5425 IIF(.lALLOW_RANGE_HDR_LABEL, IIF(!EMPTY(d.lbl_code),r.rng_lbl= d.lbl_code,r.rng_lbl= d.cust_lbl), r.rng_lbl= d.lbl_code) And ; && style
5426 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5427 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5428 INTO Cursor __DtlExpl
5429 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5430 Endif
5431 Endif
5432 Endif
5433 Endif
5434 Endif
5435 Endwith
5436
5437 If Used("__RangH")
5438 Use In __RangH
5439 Endif
5440 If Used("__RangD")
5441 Use In __RangD
5442 Endif
5443 If Used("tcRangeVer")
5444 Use In tcRangeVer
5445 Endif
5446 If Used("__DtlExpl")
5447 Use In __DtlExpl
5448 Endif
5449 If Used("__TmpCursor")
5450 Use In __TmpCursor
5451 Endif
5452
5453 *--- TR 1038376 05-May-2009 Goutam
5454 If Used("__RangTmpD")
5455 Use In __RangTmpD
5456 ENDIF
5457 this.TableClose(lcTmpCursor)
5458 *=== TR 1038376 05-May-2009 Goutam
5459
5460 Select(lnOldSelect)
5461 Return llRetVal
5462 Endproc
5463 *----------------------------------------------------------------------------------------
5464
5465 Procedure ExplodeRangeRef
5466 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5467 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5468 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5469
5470 lnOldSele= Select()
5471 lcDivStyle= ""
5472 * TAN 31891 - JAZ - 5/20/02
5473 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5474 lnSourceCnt= RecCount(pcRangeDetail)
5475 * End TAN 31891 - JAZ - 5/20/02
5476 llRetVal= .T.
5477 lnCurDtlFkey= 0
5478
5479 Select (pcRangeDetail)
5480 Set Order To DivStyle
5481 Scan
5482 *- 1009508 03/16/05 YIK
5483 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5484 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5485 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5486 *-- m.rng_type= &pcRangeHeader..rng_type
5487 *-- m.rng_qty= &pcRangeHeader..rng_qty
5488
5489 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5490 *-- m.coord_code= &pcRangeHeader..coord_code
5491 *-- m.rng_type= &pcRangeHeader..rng_type
5492 If lnCurDtlFkey<> fkey
5493 lnCurDtlFkey= fkey
5494 If Seek(fkey, pcRangeHeader , "PKEY")
5495 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5496 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5497 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5498 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5499 *= 1009508 YIK
5500 Else
5501 llRetVal = .F.
5502 Exit
5503 Endif
5504 Endif
5505
5506 * only run once per Div + Style
5507 If !(lcDivStyle == division + Style)
5508 lcDivStyle = division + Style
5509 * Insert a record for each size bucket with a caption *
5510 If !v_GetSizeHeadings(division, Style, "__xSizer")
5511 llRetVal = .F.
5512 Exit
5513 Endif
5514 Endif
5515
5516 Select (pcRangeDetail)
5517 Scatter Memvar Memo
5518 For lnSizePosition = 1 To goEnv.MaxBuckets
5519 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5520 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5521 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5522 m.sizebucket = lnSizePosition
5523 m.size_desc = lcSizeName
5524 m.total_qty = lnSizeQty
5525 If lnSizeQty > 0 && Only want buckets with activity!
5526 Insert Into (pcRangeDetailTarget) From Memvar
5527 Endif
5528 Endfor
5529
5530 Endscan
5531 This.TableClose("__xSizer")
5532 Select (pcRangeDetail)
5533 Select (lnOldSele)
5534 Return llRetVal
5535 Endproc
5536
5537 *----------------------------------------------------------------------------------------
5538
5539 Procedure ValidateRangeStyle
5540 Lparameters pcRangeStyle, pcTransDetail
5541 Local llRetVal, lnOldSelect, lcErrs_Msg
5542 llRetVal = .T.
5543 lnOldSelect = Select()
5544 lcErrs_Msg= "Total Units must be divisible by "
5545
5546 Select (pcRangeStyle)
5547 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5548 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5549 "division+style+color_code+lbl_code+dimension")
5550
5551 If llRetVal
5552 .LogEntry("Validating range style.")
5553 * Verify range style "R"un order in min multiple of rng_qty
5554 * no need for "S"et verification of range type --just explode to
5555 * range detail
5556 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5557 *- 1023438 04/06/07 YIK
5558 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5559 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5560 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5561 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5562 Errs_Flg_D With "Y" ;
5563 IN (pcTransDetail)
5564 Endif
5565 Endscan
5566 Endif
5567
5568 Set Relation To
5569 Select(lnOldSelect)
5570 Return llRetVal
5571 Endproc
5572
5573 *----------------------------------------------------------------------------------------
5574
5575 Procedure ExplodeRangeStyleVertical
5576 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5577 Local llRetVal, lnOldSelect, lcErrs_Msg
5578 llRetVal = .T.
5579 lnOldSelect = Select()
5580
5581 * --- TR 1034963 12/15/08 CM
5582 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5583 * === TR 1034963 12/15/08 CM
5584
5585 Select (pcDetailtoExplode)
5586 Scan
5587 * Find detail line that need range style exploding using PKEY
5588 If Seek(pkey, pcTransDetail, "Pkey")
5589 * Current working trans detail
5590 Select (pcTransDetail)
5591
5592
5593 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5594 *-- TR 1040759 JUN-29-2009 BR
5595*!* IF !EMPTY(lbl_code)
5596*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5597*!* ELSE
5598*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5599*!* ENDIF
5600 *== TR 1040759 JUN-29-2009 BR
5601 IF .lALLOW_RANGE_HDR_LABEL
5602
5603 IF !EMPTY(lbl_code)
5604 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5605
5606 else
5607 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5608 ENDIF
5609 else
5610
5611 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5612
5613 endIF
5614 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5615
5616 lnCurDtlTotal_qty= total_qty
5617
5618 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5619 *- 1009508 3/16/05 YIK
5620 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5621 lnRangeBucket = sizebucket
5622
5623 Scatter Name loTransDetail Memo
5624
5625 *--- TR 1038376 16-Feb-2009 Goutam
5626 loTransDetail.Rng_Price = loTransDetail.org_price
5627 *--- TR 1038376 16-Feb-2009 Goutam
5628
5629 * delete current working trans detail already have image
5630 * in loTransDetail
5631 Delete In (pcTransDetail)
5632
5633 * --- TR 1034963 12/15/08 CM
5634 lnDetailPkey = loTransDetail.pkey
5635 * === TR 1034963 12/15/08 CM
5636
5637 * --- TR 1018184 RLN 01/10/07
5638 lnDetailPkey = loTransDetail.pkey
5639 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5640 * === TR 1018184
5641
5642 Select (pcRangeDetailVert)
5643 * Find 1st match of OURSKU
5644 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5645 * calculate lnMultiplier regardless of rng_type
5646 * --"R"un only divisible by rng_qty will get to this point
5647 * --otherwise will stay in errs_dtl_F/msg
5648
5649 *- 1009508 3/16/05 YIK
5650 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5651 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5652 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5653 lnCurDtlTotal_qty/rng_qty)
5654
5655 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5656 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5657 * Exploding detail line
5658 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5659 If !Empty(loTransDetail.pkey)
5660
5661 * --- TR 1034963 12/15/08 CM
5662 lcDetailNotes = GetUniqueFileName()
5663 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey)
5664 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5665 * === TR 1034963 12/15/08 CM
5666
5667 *- 1009508 3/16/05 YIK
5668 Select (pcRangeDetailVert)
5669 Scatter Name loVert Memo
5670 *= 1009508
5671
5672 Select (pcTransDetail)
5673 Append Blank
5674 Gather Name loTransDetail Memo
5675
5676 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5677 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5678 * only recording a..e_price to zzeipoth and resetting org_price
5679 *org_price with &pcRangeDetailVert..a_price,
5680
5681 *- 1009508 3/16/05 YIK
5682 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5683 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5684 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5685 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5686 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5687 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5688 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5689 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5690 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5691 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5692 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5693 *-- division WITH &pcRangeDetailVert..division, ;
5694 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5695 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5696 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5697 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5698 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5699 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5700 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5701 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5702 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5703 *-- e_price WITH &pcRangeDetailVert..e_price ;
5704 *-- IN (pcTransDetail)
5705
5706 *- 1022149 03/06/07 YIK
5707 *- do not zero out org_price for MultiUPC
5708 Replace rng_style With loVert.rng_style, ;
5709 rng_color With loVert.rng_color, ;
5710 rng_lbl With loVert.rng_lbl, ;
5711 rng_pack With loVert.rng_pack, ;
5712 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5713 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5714 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5715 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5716 total_qty With lnMultiplier * loVert.total_qty, ;
5717 sizebucket With loVert.sizebucket, ;
5718 size_desc With loVert.size_desc, ;
5719 division With loVert.division, ;
5720 STYLE With loVert.Style, ;
5721 color_code With loVert.color_code, ;
5722 lbl_code With loVert.lbl_code, ;
5723 DIMENSION With loVert.Dimension, ;
5724 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5725 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5726 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5727 a_price With loVert.a_price,; && 4186- store a..e_price
5728 b_price With loVert.b_price,; && from range style detail
5729 c_price With loVert.c_price,; && to use latter when have
5730 d_price With loVert.d_price,; && price_code
5731 e_price With loVert.e_price ;
5732 IN (pcTransDetail)
5733 *= 1009508 03/16/05 YIK
5734 * --- TR 1018184 RLN 01/10/07
5735 Select tmpRngSacs
5736 Scan
5737 Scatter Name loTmpSACs Memo
5738 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5739 loTmpSACs.dfkey = loTransDetail.pkey
5740 Insert Into (tcTransSAC) From Name loTmpSACs
5741 Endscan
5742 * === TR 1018184
5743
5744 * --- TR 1034963 12/15/08 CM
5745 If llDtlRangeNotes
5746 Select (lcDetailNotes)
5747 Scan
5748 Scatter Name loTmpDetNotes Memo
5749
5750 * --- TR 1045865 3/8/10 CM
5751 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5752 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5753 * === TR 1045865 3/8/10 CM
5754
5755 loTmpDetNotes.fkey = loTransDetail.pkey
5756 SELECT('Vzzeipotd_notes_iPOproc')
5757 Append Blank
5758 Gather Name loTmpDetNotes Memo
5759 Endscan
5760 Endif
5761
5762 IF USED(lcDetailNotes)
5763 USE IN (lcDetailNotes)
5764 ENDIF
5765 * === TR 1034963 12/15/08 CM
5766
5767 Else
5768 llRetVal= .F. && Cannot get Pkey from bcsysnum
5769 Exit
5770 Endif
5771
5772 Select (pcRangeDetailVert)
5773 Endscan
5774 Else
5775 llRetVal= .F. && Should be in pcrangdetailvert
5776 Exit
5777 Endif
5778 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5779 Endif
5780
5781 If !llRetVal &&Get out of scan when have some problem
5782 Exit
5783 Endif
5784 Endscan
5785
5786 * --- TR 1034963 12/15/08 CM
5787 If llDtlRangeNotes
5788 This.UpdateSysNotes()
5789 Endif
5790 * === TR 1034963 12/15/08 CM
5791
5792 Select(lnOldSelect)
5793 Return llRetVal
5794 Endproc
5795
5796 *----------------------------------------------------------------------------------------
5797
5798 Procedure PrepackConversion
5799 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5800 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5801 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5802 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5803 llRetVal = .T.
5804 lnOldSelect = Select()
5805
5806 * --- TR 1046519 7/26/10 CM
5807 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5808 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5809
5810 STORE "" To lcSumSln, lcError, lcPPKAction
5811 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5812 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5813 * === TR 1046519 7/26/10 CM
5814
5815 *****************************************************************************
5816 * 1st Getting all prepack headers
5817 *--- 1001112 9/26/03 YIK
5818 *- process all.
5819 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5820 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5821 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5822 *!* and d.rng_style= '' ; && none exploded range style
5823 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5824 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5825
5826 *- 1013522 10/10/05 12/02/05 YIK
5827 *- Exclude range style P from the consideration
5828 *- Do not close this cursor. It is needed in CheckSLN()
5829 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5830 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5831
5832 *- 1025153 10/22/07 YIK - comment out
5833 * --- TR 1022896 NSD 05-10-07
5834*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5835 * === TR 1022896 NSD 05-10-07
5836
5837 *- 1005499 07/06/04 YIK
5838 *- Change d.rng_style = '' to EMPTY(d.rng_style)
5839
5840 *- 1023438 04/05/07 YIK
5841 *- Allow to check Range Style type 'R'.
5842 *- Needed for MultiUPC and a good idea anyway.
5843 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
5844
5845 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
5846
5847*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5848*!* FROM (pcTransDetail) d ;
5849*!* WHERE Empty(d.rng_style) ; && none exploded range style
5850*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5851*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5852*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5853*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5854
5855 *--- TechRec 1044487 18-Mar-2010 JK ---
5856*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5857*!* FROM (pcTransDetail) d ;
5858*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
5859*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5860*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5861*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5862*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5863
5864 * --- TR 1046519 7/26/10 CM
5865 IF RECCOUNT(pcSLN) > 0
5866 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
5867 JOIN (pcTransDetail) d ;
5868 ON s.fkey = d.pkey ;
5869 JOIN (pceipoCR) c ;
5870 ON d.division = c.division ;
5871 AND d.customer = c.customer ;
5872 WHERE s.sln_qty > 0 ;
5873 GROUP BY s.fkey ;
5874 INTO CURSOR __SumSlnQty
5875
5876 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
5877
5878 WITH THIS
5879 .cSQLTempTable=""
5880 IF .GenerateSQLTempTable('__SumSlnQty')
5881 IF .PopulateSQLTempTable('__SumSlnQty')
5882 lcSumSln = .cSQLTempTable
5883 IF !EMPTY(lcSumSln)
5884 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
5885 ENDIF
5886 ENDIF
5887 ENDIF
5888 ENDWITH
5889 ENDIF
5890 * === TR 1046519 7/26/10 CM
5891
5892 *--- TechRec 1089737 21-Dec-2015 jisingh ---
5893 IF !EMPTY(This.cOverridePpkAction)
5894 REPLACE ALL ppk_action WITH This.cOverridePpkAction ;
5895 FOR EMPTY(ppk_action) OR ppk_action $ 'QPBO' IN (pcTransDetail)
5896 ENDIF
5897 *=== TechRec 1089737 21-Dec-2015 jisingh ===
5898
5899 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
5900 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
5901 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
5902 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
5903 FROM (pcTransDetail) d ;
5904 JOIN (pceipoCR) c ON c.customer = d.customer ;
5905 AND c.division = d.division ;
5906 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
5907 AND (c.rngp_conv = 'P' ;
5908 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
5909 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
5910 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5911 AND c.ppk_conv <> 'N' ;
5912 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5913 *=== TechRec 1044487 18-Mar-2010 JK ===
5914
5915 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
5916 *== 1023438
5917
5918 *=== 1013522
5919 *=== 1001112
5920 With This
5921 .cSQLTempTable=""
5922 If .GenerateSQLTempTable('__TmpCursor')
5923 If .PopulateSQLTempTable('__TmpCursor')
5924 If !Empty(.cSQLTempTable)
5925 *- TR 1025153 06/14/07 YIK
5926 *- Use the OUTER JOIN, then we have all details needed
5927 *- and can simply scan for !EOF() later on.
5928*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
5929*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
5930*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
5931*-- "s.style= t.style and s.color_code= t.color_code and " +;
5932*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
5933*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
5934*-- "s.dimension= ph.ppk_code"
5935 *--- TR 1026025 NH - use size_code from zzxstylr
5936 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
5937 * using sln_qty instead of ppk_qty
5938
5939 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
5940 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
5941 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
5942 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
5943 " ,st.size_code " +; && 1026025
5944 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
5945 " from " + .cSQLTempTable + " t " +;
5946 " JOIN zzxscolr s " + ;
5947 " ON s.division= t.division and " +;
5948 " s.style= t.style and s.color_code= t.color_code and " +;
5949 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
5950 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
5951 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
5952 " LEFT OUTER JOIN zzxppakh ph " + ;
5953 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
5954 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
5955 " Where s.ppack_ok= 'Y' "
5956
5957 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
5958 If Used("_PPK_Qty")
5959 Select ("_PPK_Qty")
5960 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
5961 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
5962 "division+style+color_code+lbl_code+dimension")
5963 SELECT ("__TmpCursor")
5964
5965 If llRetVal
5966 .LogEntry("Validating prepack style.")
5967 lcErrs_Msg = "No valid prepack code found"
5968 Select (pcTransDetail)
5969 *- 1005499 07/06/04 YIK
5970 *- Replace ..Errs_Flg_D= "N") and rng_style=''
5971 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
5972 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
5973*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
5974 *- TR 1025153 06/14/07 YIK
5975 *- Since we use the OUTER JOIN, can simply scan for !EOF()
5976 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
5977 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
5978
5979 If Empty(_PPK_Qty.pack_qty)
5980 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
5981 Errs_Flg_D With "Y" ;
5982 IN (pcTransDetail)
5983 Else
5984 Do Case
5985
5986 * --- TR 1040838 6/11/09 CM
5987 * --- Check prepack action based on Transaction detail
5988 * Removed _PPK_Qty Alias
5989 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
5990 Case ppk_action = 'Q' && multiply qty
5991 * === TR 1040838 6/11/09 CM
5992
5993 * --- TR 1046519 7/26/10 CM
5994 * At this point we know we have some slns to use for our alternate
5995 * conversion, lets just make sure that the conversion type is 'E'
5996 IF llConvertBySln
5997 lcPPKAction = ppk_action
5998 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5999 lnOrigQty = total_qty
6000 lnPpkQty = ppk_qty
6001 ENDIF
6002 * === TR 1046519 7/26/10 CM
6003
6004 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6005 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6006 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6007 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6008 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
6009 In (pcTransDetail)
6010
6011 * --- TR 1046519 7/26/10 CM
6012 IF llSlnConvert
6013 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6014 IF llRemain
6015 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6016 Errs_Flg_D WITH "Y" , ;
6017 ppk_action WITH lcPPKAction , ;
6018 total_qty WITH lnOrigQty ;
6019 In (pcTransDetail)
6020 ENDIF
6021 ENDIF
6022 * ==== TR 1046519 7/26/10 CM
6023
6024 * --- TR 1040838 6/11/09 CM
6025 * Removed _PPK_Qty Alias
6026 *Case _PPK_Qty.ppk_action = 'P' && divide price
6027 Case ppk_action = 'P' && divide price
6028 * === TR 1040838 6/11/09 CM
6029
6030 * --- TR 1046519 7/26/10 CM
6031 * At this point we know we have some slns to use for our alternate
6032 * conversion, lets just make sure that the conversion type is 'E'
6033 IF llConvertBySln
6034 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6035 ENDIF
6036 * === TR 1046519 7/26/10 CM
6037
6038 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6039 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6040 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6041 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6042 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6043 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6044 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6045 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
6046 In (pcTransDetail)
6047 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6048 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6049 *- Range style price will be populated later from a_price..e_price
6050 *- not from org_price. Need to updated these prices here.
6051 IF rng_type = 'R'
6052 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6053 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6054 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6055 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6056 e_price WITH e_price/_PPK_Qty.pack_qty ;
6057 In (pcTransDetail)
6058 ENDIF
6059 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6060
6061 * --- TR 1040838 6/11/09 CM
6062 * Removed _PPK_Qty Alias
6063 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
6064 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
6065 * === TR 1040838 6/11/09 CM
6066
6067 * --- TR 1046519 7/26/10 CM
6068 IF llConvertBySln
6069 lcPPKAction = ppk_action
6070 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6071 lnOrigQty = total_qty
6072 lnPrice = org_price
6073 lnretail1 = retail1
6074 lnretail2 = retail2
6075 lnPpkQty = ppk_qty
6076 ENDIF
6077 * === TR 1046519 7/26/10 CM
6078
6079 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6080 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6081 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6082 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6083 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6084 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6085 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6086 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6087 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
6088 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
6089 In (pcTransDetail)
6090
6091 * --- TR 1046519 7/26/10 CM
6092 IF llSlnConvert
6093 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6094 IF llRemain
6095 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6096 Errs_Flg_D WITH "Y", ;
6097 ppk_action WITH lcPPKAction , ;
6098 total_qty WITH lnOrigQty , ;
6099 org_price WITH lnPrice , ;
6100 retail1 WITH lnretail1 , ;
6101 retail2 WITH lnretail2 , ;
6102 ppk_qty WITH lnPpkQty ;
6103 In (pcTransDetail)
6104 ENDIF
6105 ENDIF
6106 * ==== TR 1046519 7/26/10 CM
6107
6108 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6109 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6110 IF rng_type = 'R'
6111 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6112 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6113 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6114 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6115 e_price WITH e_price/_PPK_Qty.pack_qty ;
6116 In (pcTransDetail)
6117 ENDIF
6118 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6119
6120 Otherwise
6121 Endcase
6122 Endif
6123 Endscan
6124 Endif
6125 Set Relation To
6126 Endif
6127 Endif
6128 Endif
6129 Endif
6130 Endwith
6131 If Used("__TmpCursor")
6132 Use In __TmpCursor
6133 Endif
6134 If Used("_PPK_Qty")
6135 Use In _PPK_Qty
6136 Endif
6137
6138 * --- TR 1046519 7/26/10 CM
6139 IF USED("__SumSlnQty")
6140 USE IN __SumSlnQty
6141 ENDIF
6142 * === TR 1046519 7/26/10 CM
6143
6144 Select(lnOldSelect)
6145 Return llRetVal
6146
6147 *----------------------------------------------------------------------------------------
6148 *- 1006607 09/02/04 YIK
6149 Function ResolveRangeP
6150 Lparameters pceipoTH, pceipoTD, pceipoCR
6151
6152 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
6153 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
6154 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
6155 llRetVal = .T.
6156 lnOldSelect = Select()
6157 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6158 lcRngp_conv = ""
6159 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6160
6161 With This
6162 .oLog.LogMajorStage("Range Style Implosion.")
6163 *- do we have any range styles 'P' in BC
6164 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
6165 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
6166 If !llRetVal Or Recc("tcTemp") = 0
6167 .oLog.LogEntry("No range styles for implosion")
6168 Return llRetVal
6169 Endif
6170
6171 *- 1007637 11/17/04 YIK
6172 *- Allow open stock: Rng_impl = 'O'
6173 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
6174 *- implode only orders that have not been range imploded (empty range style)
6175 *- and were not prepack imploded (implosion <> "Y")
6176 *!* select distinct fkey ;
6177 *!* from (pceipoTd) d ;
6178 *!* join (pceipoCR) c ;
6179 *!* on d.division = c.division and d.customer = c.customer ;
6180 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
6181 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
6182 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
6183 *!* into cursor rng_det
6184
6185*- 1047842/1048069 07/01/10 YIK
6186*- Implode only orders with no detail errors
6187*-- Select Distinct fkey, C.Rng_impl ;
6188*-- FROM (pceipoTD) d ;
6189*-- JOIN (pceipoCR) C ;
6190*-- ON d.division = C.division And d.customer = C.customer ;
6191*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6192*-- AND !Empty(d.division) And !Empty(d.customer) ;
6193*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
6194*-- INTO Cursor rng_det
6195
6196 *- TR 1058336 FH - added division to select, and group by
6197 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
6198 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6199 FROM (pceipoTD) d ;
6200 JOIN (pceipoCR) C ;
6201 ON d.division = C.division And d.customer = C.customer ;
6202 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6203 AND !Empty(d.division) And !Empty(d.customer) ;
6204 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6205 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6206 HAVING MAX(errs_flg_d) = 'N' ;
6207 INTO Cursor rng_det
6208*===
6209
6210 *==
6211 *--- TR 1023892 NH
6212 IF .lALLOW_RANGE_HDR_LABEL
6213 &&- TR 1058336 FH - added qualifier for division
6214 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
6215 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6216 SELECT d.customer,d.division, STYLE, color_code, IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code, DIMENSION, Sizebucket, total_qty, d.fkey, d.pkey ;
6217 FROM (pceipoTD) d ;
6218 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6219 WHERE !EMPTY(d.STYLE) ;
6220 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
6221 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
6222 INTO CURSOR __TmpCurs
6223 ELSE
6224 &&- TR 1058336 FH - added qualifier for division
6225 *=== TR 1023892 NH
6226 *- 1047842/1048069 07/01/10 YIK
6227 *- Added d.pkey
6228 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6229 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
6230 FROM (pceipoTD) d ;
6231 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6232 WHERE !Empty(d.Style) ;
6233 AND !Empty(d.division) And !Empty(d.customer) ;
6234 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6235 INTO Cursor __tmpCurs
6236 ENDIF && TR 1023892 NH
6237 .cSQLTempTable=""
6238 If .GenerateSQLTempTable('__TmpCurs')
6239 If .PopulateSQLTempTable('__TmpCurs')
6240 If !Empty(.cSQLTempTable)
6241 Select rng_det
6242 Scan
6243 lnFKey = rng_det.fkey
6244 *- 1007637 11/17/04 YIK
6245 lcRng_Impl = rng_det.Rng_impl
6246
6247 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6248 lcRngp_conv = rng_det.Rngp_conv
6249 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6250
6251 lcDivision = rng_det.division &&- TR 1058336 FH
6252
6253 *- one order at a time. Select on the server side.
6254 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
6255 dtl = SQLTableFromQuery(lcSQLStr )
6256 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
6257
6258 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
6259 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
6260
6261 Select (pceipoTD)
6262 Do Case
6263 Case lnResult = 0 && match not found
6264 *- 1007637 11/17/04 YIK
6265 If lcRng_Impl = 'Y'
6266
6267 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
6268 Errs_Flg_D With "Y" ;
6269 FOR fkey = lnFKey And !Empty(Style) ;
6270 AND !Empty(division) And !Empty(customer) ;
6271 AND Empty(rng_style) And implosion <> "Y"
6272 Endif
6273 Case lnResult > 1 && ambiguous
6274 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
6275 *- 1049007 08/24/10 YIK
6276 *- List all ambiguous Range Styles
6277 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
6278 Errs_Flg_D With "Y" ;
6279 FOR fkey = lnFKey And !Empty(Style) ;
6280 AND !Empty(division) And !Empty(customer) ;
6281 AND Empty(rng_style) And implosion <> "Y"
6282*!* lcErrorMsg = " Ambiguous range styles "
6283*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
6284*!* lcErrorMsg = lcErrorMsg + ": "
6285*!* SELECT __tmp
6286*!* SCAN
6287*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
6288*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
6289*!* EndScan
6290*!* SELECT(pceipoTD)
6291*!* ENDIF
6292*!*
6293*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
6294*!* Errs_Flg_D With "Y" ;
6295*!* FOR fkey = lnFKey And !Empty(Style) ;
6296*!* AND !Empty(division) And !Empty(customer) ;
6297*!* AND Empty(rng_style) And implosion <> "Y"
6298 *=== 1049007
6299 Endcase
6300 Endscan
6301 Endif
6302 Endif
6303 Endif
6304
6305 Endwith
6306 Select (lnOldSelect)
6307 Return llRetVal
6308 Endfunc
6309
6310 Function RangeImplosion
6311 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6312 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6313 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6314
6315 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6316 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6317 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6318
6319 llRetVal = .T.
6320 lnOldSelect = Select()
6321 With This
6322
6323 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6324 *- turn them vertical into SQL-side temp table var. RangD
6325 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6326 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6327*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6328*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6329*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6330*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6331*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6332*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6333
6334*!* Added following join
6335*!* " join " + dtl + " td1 " +;
6336*!* " on d.style = td1.style " +;
6337*!* " and d.color_code = td1.color_code " +;
6338*!* " and d.lbl_code = td1.lbl_code " +;
6339*!* " and d.dimension = td1.dimension "
6340
6341 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6342
6343 *--- TR 1084825 20-Feb-2015 BNarayanan adding the join on division, sizebucket for the dtl table join ---
6344 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6345 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6346 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6347 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6348 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6349 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6350 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6351 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6352 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6353 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6354 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6355 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6356 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6357 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6358 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6359 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6360 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6361 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6362 "coalesce(cs.e_price,d.e_price) as e_price "+;
6363 "from ( " +;
6364 " select dd.* from zzxrangd dd " +;
6365 " where fkey in ( " +;
6366 " select distinct ph.pkey " +;
6367 " from zzxrangh ph " +;
6368 " join zzxrangd pd " +;
6369 " on ph.Pkey = Pd.Fkey " +;
6370 " join " + dtl + " td1 " +;
6371 " on pd.division = td1.division " + ; && TR 1084825 03-Mar-2015 BNarayanan
6372 " and pd.style = td1.style " +;
6373 " and pd.color_code = td1.color_code " +;
6374 " and pd.lbl_code = td1.lbl_code " +;
6375 " and pd.dimension = td1.dimension " +;
6376 " where ph.rng_type = 'P' " +;
6377 " and not exists( " +;
6378 " select * " +;
6379 " from zzxrangd da " +;
6380 " left join " + dtl + " det " +;
6381 " on det.division= da.division" +; && TR 1084825 03-Mar-2015 BNarayanan
6382 " and det.style = da.style " +;
6383 " and det.color_code = da.color_code " +;
6384 " and det.lbl_code = da.lbl_code " +;
6385 " and det.dimension = da.dimension " +;
6386 " where da.Fkey = ph.pkey " +;
6387 " and (det.Pkey is null " +;
6388 " or case det.SizeBucket " +;
6389 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6390 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6391 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6392 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6393 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6394 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6395 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6396 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6397 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6398 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6399 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6400 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6401 " ) ) d " +;
6402 " join zzxbuckt b " +;
6403 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6404 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6405 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6406 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6407 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6408 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6409 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6410 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6411 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6412 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6413 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6414 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 " + ;
6415 " join " + dtl + " td1 " +;
6416 " on d.division = td1.division " +; && TR 1084825 20-Feb-2015 BNarayanan
6417 " and d.style = td1.style " +;
6418 " and d.color_code = td1.color_code " +;
6419 " and d.lbl_code = td1.lbl_code " +;
6420 " and d.dimension = td1.dimension "+;
6421 " and size_num = td1.sizebucket " +; && TR 1084825 20-Feb-2015 BNarayanan
6422 " Left join zzxcsrgh cs "+ ;
6423 " on cs.dtlpkey = d.pkey "+ ;
6424 " and cs.customer = td1.customer "
6425
6426 RangD = SQLTableFromQuery(lcSQLString)
6427
6428 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6429 *- possible combinations of RangD that cover them.
6430 *- Result is SQL-side temp table var. RangeSet
6431 *- 1047842/1048069 07/01/10 YIK
6432 *- Added td.pkey
6433 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6434 *--- 1049007 08/24/10 YIK
6435 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6436 *- to check for components divisibility
6437 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6438 *--- TR 1084825 03-Mar-2015 BNarayanan added td.division in the select ---
6439 lcSQLString = ;
6440 'select td.division,td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6441 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6442 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6443 ',td.pkey as dtl_pkey ' + ;
6444 ' from ' + dtl + ' td ' + ;
6445 ' cross join ( ' + ;
6446 ' select * ' + ;
6447 ' from zzxrangh H ' + ;
6448 ' where exists ( ' + ;
6449 ' select * ' + ;
6450 ' from ' + RangD + ' dd ' + ;
6451 ' join ' + dtl + ' td1 ' + ;
6452 ' on dd.Division = td1.Division ' + ;
6453 ' and dd.style = td1.style ' + ;
6454 ' and dd.color_code = td1.color_code ' + ;
6455 ' and dd.lbl_code = td1.lbl_code ' + ;
6456 ' and dd.dimension = td1.dimension ' + ;
6457 ' and dd.size_bk = td1.sizebucket ' + ;
6458 ' where dd.FKey = H.PKey )) mtch ' + ;
6459 ' left join ' + RangD + ' D ' + ;
6460 ' on d.FKey = mtch.PKey ' + ;
6461 ' and d.Division = td.Division ' + ;
6462 ' and d.style = td.style ' + ;
6463 ' and d.color_code = td.color_code ' + ;
6464 ' and d.lbl_code = td.lbl_code ' + ;
6465 ' and d.dimension = td.dimension ' + ;
6466 ' and d.size_bk = td.sizebucket ' + ;
6467 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6468 *==104900708/24/10YIK
6469 RangeSet = SQLTableFromQuery(lcSQLString)
6470
6471 * --- TR 1048126 8/23/10 CM
6472 v_SqlExec(lcSQLString, "tcRangeSet")
6473
6474 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6475*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6476*!*
6477*!* UPDATE d ;
6478*!* SET ppk_qty = -1 ;
6479*!* FROM (pceipoTD) d ;
6480*!* JOIN tcRangeSet r ;
6481*!* ON d.pkey = r.dtl_pkey ;
6482*!* WHERE d.ppk_action $ 'XM'
6483*!*
6484*!* ENDIF
6485 *=== TR 1051390 23-Dec-2010 Goutam
6486
6487 * === TR 1048126 8/23/10 CM
6488
6489 *- how many different range styles were found for this order
6490 *--- 1049007 08/24/10 YIK
6491 *- Modify logic to determine ambiguos Range Styles
6492*-- lcSQLString = ;
6493*-- ' select count(*) PPKCnt ' + ;
6494*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6495
6496 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6497 *= 1049007
6498
6499 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6500 lnPPKCnt = tmp_cnt.PPKCnt
6501
6502 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6503 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6504 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6505
6506 *--- the result (Query #2):
6507 *- See if any single range style in the RangeSet fully matches DTL
6508 *- 1047842/1048069 07/01/10 YIK
6509 *- added t1dtl_pkey
6510 lcSQLString = ;
6511 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6512 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6513 ' from ' + dtl + ' dtl ' + ;
6514 ' join ' + RangeSet + ' t1 ' + ;
6515 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6516 ' and dtl.style = t1.style ' + ;
6517 ' and dtl.color_code = t1.color_code ' + ;
6518 ' and dtl.lbl_code = t1.lbl_code ' + ;
6519 ' and dtl.dimension = t1.dimension ' + ;
6520 ' and dtl.sizebucket = t1.sizebucket ' + ;
6521 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6522 ' having count(*) = (select count(*) from ' + dtl + ') '
6523 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6524 lnCnt = Reccount()
6525
6526 *- 1049007 08/24/10 YIK
6527 *- Exclude Range styles that are not divisible
6528 IF (lnCnt > 0)
6529 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6530 lnCnt = _TALLY
6531 ENDIF
6532 *=
6533
6534 llSingleMatch = .F.
6535 llAmbig = .F.
6536 *- 1047842/1048069 07/01/10 YIK
6537 *- Added ValidDetail
6538 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6539 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6540 Do Case
6541 Case lnCnt > 1
6542 *- 1049007 08/24/10 YIK
6543 USE IN SELECT("__tmp")
6544 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6545 *=
6546 llAmbig = .T. && ambiguos, give error message and do not continue
6547 Case lnCnt = 1
6548 llSingleMatch = .T.
6549 *- 1047842/1048069 07/01/10 YIK
6550 *- Added ValidDetail
6551 *- 1049007 08/26/10 YIK
6552 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6553* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6554 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6555 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6556
6557 Otherwise
6558 Endcase
6559 *- 1049007 08/24/10 YIK
6560 *- commented out. This method is not called with this parameter = .T.
6561*--- IF tlNoConsol
6562*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6563*--- ENDIF
6564
6565 lnResult = lnCnt
6566
6567 If !llAmbig
6568 *- If none single range style in the RangeSet fully matches DTL,
6569 *- or even if a match was found
6570 *- start going through combinations of 2,3... - may be ambiguous
6571
6572 *- 1047842/1048069 07/01/10 YIK
6573 *- added t1dtl_pkey
6574 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6575
6576 lcTopStr = ;
6577 ' from ' + dtl + ' dtl ' + ;
6578 ' join ' + RangeSet + ' t1 ' + ;
6579 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6580 ' and dtl.style = t1.style ' + ;
6581 ' and dtl.color_code = t1.color_code ' + ;
6582 ' and dtl.lbl_code = t1.lbl_code ' + ;
6583 ' and dtl.dimension = t1.dimension ' + ;
6584 ' and dtl.sizebucket = t1.sizebucket '
6585
6586 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6587 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6588 lcMiddleStr = ''
6589 lcCoalStr_pkey = 't1.pkey'
6590 lcCoalRevStr_pkey = 't1.pkey'
6591 lcCoalStr_ratio = 't1.ratio'
6592 lcCoalRevStr_ratio = 't1.ratio'
6593 lcGroupFkeyStr = ' t1.FKey'
6594 lcGroupStr = ''
6595
6596 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6597 *lnPrepacks = Min(lnPPKCnt, 6)
6598 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6599 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6600 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6601
6602 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6603
6604 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6605 llFoundNext = .F.
6606
6607 lcnum = Trans(j, "9")
6608 lcPrevNum = Trans(j - 1, "9")
6609 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6610 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6611
6612 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6613
6614 *-- TR 1049817 Oct-12-2010 BR
6615 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6616 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6617 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6618 *== TR 1049817 Oct-12-2010 BR
6619
6620 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6621
6622 *--- TR 1049817 Oct-12-2010 BR
6623 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6624 lcGroupStr = lcGroupFkeyStr
6625 *=== TR 1049817 Oct-12-2010 BR
6626
6627 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6628 *- 06/30/10 YIK LOCAL ONLY
6629 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6630 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6631 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6632 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6633
6634 lcMiddleStr = lcMiddleStr + ;
6635 "join " + RangeSet + " t" + lcnum + ;
6636 ' on dtl.division = t' + lcnum + '.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6637 ' and dtl.style = t' + lcnum + '.style ' + ;
6638 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6639 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6640 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6641 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6642 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6643
6644 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6645 ' Group by ' + lcGroupStr
6646
6647 *--- TR 1049817 Oct-12-2010 BR
6648 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6649 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6650 *=== TR 1049817 Oct-12-2010 BR
6651
6652 *--- TR 1050754 NOV-15-2010 BR
6653 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6654 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6655 *=== TR 1050754 NOV-15-2010 BR
6656
6657 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6658 lnCnt = Reccount()
6659 llFoundNext = (lnCnt = 1)
6660 *- ambig when either prev or this SQL returned more than 1 row or
6661 *- one match was found before AND one is found now - making it two.
6662 If lnCnt > 0
6663 Scan
6664 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6665 *- divisible by the number of items in the range style!!!
6666
6667 *---TR 1049817 Oct-12-2010 BR
6668 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6669 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6670 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6671 *===TR 1049817 Oct-12-2010 BR
6672 Else
6673 lcInsertStr = Trans(fkey)
6674 *- 1047842 06/17/10 YIK
6675 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6676
6677 For lnCounter = 2 To j
6678
6679 *- TR 1055009 FH - added If statement
6680 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6681
6682 else
6683 *- 1047842 06/17/10 YIK
6684 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6685 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6686 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6687 *- Added ValidDetail
6688 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6689 ENDIF
6690 *- TR 1055009 FH
6691
6692 Endfor
6693
6694 *---TR 1049817 Oct-12-2010 BR
6695 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6696 lcInsertRatioStr = Trans(t1_ratio)
6697
6698 For lnCounter = 2 To j
6699 *- TR 1055009 FH - added If statement
6700 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6701
6702 ELSE
6703 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6704 ENDIF
6705 *- TR 1055009 FH - added If statement
6706 ENDFOR
6707 *== =TR 1049817 Oct-12-2010 BR
6708
6709 *- 1047842/1048069 07/01/10 YIK
6710 *- Added ValidDetail
6711 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6712 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6713
6714 Endif
6715 Endscan
6716 Endif
6717 lnResultCnt = Recc("q_Result")
6718 llAmbig = (lnResultCnt > 1)
6719 llSingleMatch = (lnResultCnt = 1)
6720 If llAmbig
6721 lnResult = lnResultCnt
6722 Exit
6723 Endif
6724 Endfor
6725 If llSingleMatch
6726 lnResult = 1
6727 IF NOT tlNoConsol
6728 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6729
6730 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6731 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6732 ENDIF
6733 Endif
6734 Else && ambiguous
6735 lnResult = lnCnt
6736 Endif
6737
6738 *--- TR 1051390 23-Dec-2010 Goutam
6739 *--- TR 1092774 27-Jan-2016 BNarayanan added VARTYPE(pceipoTD) <> 'L' AND as pceipoTD will not be available when called from Prod Ord Range P Implotion
6740 *IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6741 IF VARTYPE(pceipoTD) <> 'L' AND lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6742 *=== TR 1092774 27-Jan-2016 BNarayanan ===
6743 UPDATE d ;
6744 SET ppk_qty = -1 ;
6745 FROM (pceipoTD) d ;
6746 JOIN tcRangeSet r ;
6747 ON d.pkey = r.dtl_pkey ;
6748 WHERE d.ppk_action $ 'XM'
6749 ENDIF
6750 *=== TR 1051390 23-Dec-2010 Goutam
6751
6752 Endwith
6753 Return lnResult
6754
6755 Procedure ConsolidateRangeP
6756 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6757 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6758 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6759
6760 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6761
6762 LOCAL lcDvision && 1058336 FH
6763
6764 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6765 LOCAL lnOrgPrice
6766 IF EMPTY(pcRngp_conv )
6767 pcRngp_conv = "N"
6768 ENDIF
6769 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6770
6771 llRetVal = .T.
6772 lnOldSelect = Select()
6773
6774 *- insert range styles that match zzxrangd.fkey from q_result
6775 *- into pceipotd.
6776 *- parse the string from cursor q_result to get the list of fkeys
6777 *- 1047842/1048069 07/01/10 YIK
6778 *- Moved Locate down
6779*-- Select (pceipoTD)
6780*-- Locate For fkey = pnFkey
6781*-- Scatter Name oDtl Memo
6782
6783 Declare aRange[1]
6784 aRange = ''
6785 Select q_Result
6786 Scatter Memvar Memo
6787 *- 1030497 02/29/08 TT
6788 *--StringToArray(m.ValidRange, @aRange, ",")
6789
6790 *--TR 1040854 Jun-11-09 BR
6791 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6792 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6793 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6794 *==TR 1040854 Jun-11-09 BR
6795
6796 *- 1030497 02/29/08 TT
6797 *-- TR 1049817 Oct-12-2010 BR
6798 *lnLen = Alen(aRange) - 1 && the last element is ratio
6799 lnLen = Alen(aRange)
6800 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6801 *== TR 1049817 Oct-12-2010 BR
6802
6803 *- 1047842/1048069 07/01/10 YIK
6804 Declare aDetail[1]
6805 aDetail = ''
6806 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6807 *= 1047842/1048069
6808
6809 *-- TR 1049817 Oct-12-2010 BR
6810 DECLARE aRatios[1]
6811 aRatios = ''
6812 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6813 *== TR 1049817 Oct-12-2010 BR
6814
6815 For j = 1 To lnLen
6816 lcFkey = aRange[j]
6817 *- 1047842/1048069 07/01/10 YIK
6818 lnDtl_Pkey = EVALUATE(aDetail[j])
6819 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6820
6821 Select (pceipoTD)
6822 Locate For pkey = lnDtl_Pkey
6823 Scatter Name oDtl Memo
6824 *= 1047842/1048069
6825 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6826*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6827 *--- TR 1084825 20-Feb-2015 BNarayanan removed the column h.RNG_PACK_001, which is not available in zzxrangh table and where clause ---
6828 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6829 " coalesce(cs.a_price,h.a_price) as a_price, "+;
6830 " coalesce(cs.b_price,h.b_price) as b_price, "+;
6831 " coalesce(cs.c_price,h.c_price) as c_price, "+;
6832 " coalesce(cs.d_price,h.d_price) as d_price, "+;
6833 " coalesce(cs.e_price,h.e_price) as e_price, "+;
6834 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
6835 " h.SOURCETYPE,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
6836 " From zzxrangh h " + ;
6837 " Left Join zzxcsrgh cs "+ ;
6838 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
6839 " and cs.customer = "+ SQLFormatChar(oDtl.Customer) + ;
6840 " where h.pkey = " + lcFkey && 1084825
6841 v_SqlExec(lcSQL ,"__RangH")
6842 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
6843 lcDvision = __RangH.division && 1058336 FH
6844
6845 oDtl.Style = __RangH.rng_style
6846 oDtl.color_code = __RangH.rng_color
6847 oDtl.lbl_code = __RangH.rng_lbl
6848 oDtl.Dimension = __RangH.rng_pack
6849 oDtl.rng_style = __RangH.rng_style
6850 oDtl.rng_color = __RangH.rng_color
6851 oDtl.rng_lbl = __RangH.rng_lbl
6852 oDtl.rng_pack = __RangH.rng_pack
6853 oDtl.rng_qty = __RangH.rng_qty
6854 oDtl.rng_type = __RangH.rng_type
6855 *- don't have to have upc or sku for the imploded range style
6856 oDtl.upc = ''
6857 oDtl.sku = ''
6858 oDtl.coord_code = __RangH.coord_code
6859 oDtl.a_price = __RangH.a_price
6860 oDtl.b_price = __RangH.b_price
6861 oDtl.c_price = __RangH.c_price
6862 oDtl.d_price = __RangH.d_price
6863 oDtl.e_price = __RangH.e_price
6864 *- clear err msg and err flag which may have error after unsuccessful implosion
6865 oDtl.Errs_Msg_D = ""
6866
6867 *- 1009211 03/09/05 YIK
6868 *- Initializ3e errs_flg_d to N, not blank
6869 *- oDtl.Errs_Flg_D = " "
6870 oDtl.Errs_Flg_D = "N"
6871 *- org_price is based on zzocntrc (cust sales) price_code
6872 *- we'll get the proper price_code in ValidOrderControl()
6873 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
6874
6875 *- 1009211 02/24/05 YIK
6876 *- Keep quantity in cases and use price per case.
6877 *- and zero out orig price which will be resolved.
6878 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
6879
6880 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6881 lnOrgPrice = oDtl.org_price
6882 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6883
6884 oDtl.total_qty = lnRatio
6885 oDtl.org_price = 0
6886
6887 *--- TR 1060800 24-May-2012 Goutam.
6888 oDtl.Rng_Impl = pcRng_Impl
6889 oDtl.Rngp_conv = pcRngp_conv
6890 *=== TR 1060800 24-May-2012 Goutam.
6891
6892 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6893 IF pcRngp_conv = "R"
6894 *--- TechRec 1057383 15-Dec-2011 jisingh ---
6895*!* oDtl.ppk_qty = __RangH.rng_qty
6896*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
6897*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6898*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6899*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
6900*!* oDtl.ppk_action = 'X'
6901
6902 IF EMPTY(oDtl.ppk_action)
6903 oDtl.org_price = lnOrgPrice
6904 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
6905 ENDIF
6906
6907 IF oDtl.ppk_action = "B"
6908 oDtl.org_price = lnOrgPrice
6909 oDtl.ppk_qty = __RangH.rng_qty
6910 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6911 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6912 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6913 oDtl.ppk_action = 'X'
6914 ENDIF
6915
6916 IF oDtl.ppk_action = "Q" && Qty conversion only
6917 oDtl.org_price = lnOrgPrice
6918 oDtl.ppk_qty = __RangH.rng_qty
6919 oDtl.retail1 = oDtl.retail1
6920 oDtl.retail2 = oDtl.retail2
6921 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6922 oDtl.ppk_action = 'M'
6923 ENDIF
6924
6925 IF oDtl.ppk_action = "P" && Price conversion only
6926 oDtl.org_price = lnOrgPrice
6927 oDtl.ppk_qty = __RangH.rng_qty
6928 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6929 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6930 oDtl.total_qty = oDtl.total_qty
6931 oDtl.ppk_action = 'D'
6932 ENDIF
6933 *=== TechRec 1057383 15-Dec-2011 jisingh ===
6934 ENDIF
6935 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6936
6937 *= 1009211
6938 *- 1047842/1048069 07/01/10 YIK
6939 *- Clear po1_upc and po1_sku as they get populated on the way out
6940 oDtl.po1_upc = ''
6941 oDtl.po1_sku = ''
6942
6943
6944 *- Per JR, put into the 1st available size bucket
6945 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
6946 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
6947 If !llRetVal
6948 Exit
6949 Else
6950 *-- TR 1049817 Oct-12-2010 BR
6951 *oDtl.sizebucket = At("Y", __tmp.sizes)
6952 oDtl.sizebucket = __RangH.rng_bk
6953 oDtl.rng_bk = oDtl.sizebucket
6954 lcSzStr = __tmp.sizes
6955 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
6956 *== TR 1049817 Oct-12-2010 BR
6957 Endif
6958 *-- TR 1049817 Oct-12-2010 BR
6959 IF !llValidRngBk
6960 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
6961 oDtl.errs_flg_d = 'Y'
6962 ELSE
6963 *== TR 1049817 Oct-12-2010 BR
6964 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
6965 llRetVal = .F.
6966 Exit
6967 Endif
6968 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
6969 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
6970
6971 *--- TR 1059965 6-Mar-12 Venuk
6972 *oDtl.pkey = v_nextPkey("ZZEIPOID")
6973 * ENDIF
6974 ENDIF
6975 oDtl.pkey = v_nextPkey("ZZEIPOID")
6976 *=== TR 1059965 6-Mar-12 Venuk
6977
6978 Select (pceipoTD)
6979 Append Blank
6980
6981 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
6982 *Gather Name oDtl
6983 Gather Name oDtl memo
6984 *=== TR 1065271 11-Jan-2013 BNarayanan ===
6985
6986 Endfor
6987 If llRetVal
6988 *- delete components
6989 Delete For fkey = pnFkey And !Empty(Style) ;
6990 AND !Empty(division) And !Empty(customer) ;
6991 AND Empty(rng_style) And implosion <> "Y" ;
6992 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
6993 IN (pceipoTD)
6994 Endif
6995 Select (lnOldSelect)
6996 Return llRetVal
6997 *========== 1006607 09/02/04 YIK
6998
6999 *----------------------------------------------------------------------------------------
7000
7001 *--- TechRec 1005163 17-May-2004 GS ---
7002 *-- Validating SLN vs. Prepack
7003 Procedure CheckSLN
7004 Parameters pceipoTH, pceipoTD, pceipoTS
7005 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
7006 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
7007 lcDtl_lbl_code && *-TR 1075660 SK
7008
7009 lnOldDtlPKey = -1
7010 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
7011 *--- TR 1023892 NH
7012 lnOldSelect = SELECT()
7013 llRetVal = .t.
7014 *=== TR 1023892 NH
7015 Select (pceipoTS)
7016 Set Order To Tag fkey
7017
7018 SCAN
7019 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
7020 IF SkipSlnChk = "Y"
7021 LOOP
7022 ENDIF
7023 *=== TR 1035223 NH
7024
7025 If lnOldDtlPKey != fkey
7026 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
7027 *-- this checks that there is no more records left in BC PrePack info
7028 *-- after all matching to SLNs deleted. Made as a separate routine
7029 *-- because it must be called when detail key changed and when scan is finished.
7030 *-- Error info applied to Detail.
7031 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7032 Endif
7033 lnOldDtlPKey = fkey
7034 lcPPackError = ""
7035 lcDtlError = ""
7036 Select (pceipoTD)
7037 *- 1008909 01/18/05 YIK
7038 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
7039 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
7040 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
7041 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
7042 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
7043 *- TR 1097936 FH - added check if detail lbl is empty, then lets use cust_lbl
7044 lcDtl_lbl_code = IIF(llRangeStyle, NULL, IIF(EMPTY(lbl_code), cust_lbl, lbl_code)) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
7045
7046 *- 1013522 10/17/05 12/02/05 YIK
7047 *- Check for the range style type P. For it there's no explosion to components and the range
7048 *- style info is not written into detail table, but it is still a range style and we should skip it.
7049 Local Array laRangP[1]
7050 laRangP[1] = 0
7051 *--- TR 1023892 NH
7052 IF .lALLOW_RANGE_HDR_LABEL
7053 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
7054 SELECT COUNT(*) ;
7055 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7056 ON d.division = r.division ;
7057 AND d.STYLE = r.rng_style ;
7058 AND d.color_code = r.rng_color ;
7059 AND IIF(EMPTY(d.lbl_code), d.Cust_lbl = r.rng_lbl, d.lbl_code = r.rng_lbl) ; && TR 1040759 Jun-11-2009 NM/YK
7060 AND d.DIMENSION = r.rng_pack ;
7061 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
7062 INTO ARRAY laRangP
7063 ELSE
7064 *=== TR 1023892 NH
7065 Select Count(*) ;
7066 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7067 On d.division = r.division ;
7068 AND d.Style = r.rng_style ;
7069 AND d.color_code = r.rng_color ;
7070 AND d.lbl_code = r.rng_lbl ;
7071 AND d.Dimension = r.rng_pack ;
7072 WHERE d.pkey = lnOldDtlPKey ; && TR 1090099 FH
7073 INTO Array laRangP
7074 ENDIF && TR 1023892 NH
7075 llRangeStyle = llRangeStyle Or laRangP[1] > 0
7076 *= 1013522 YIK
7077
7078 llDtlHasError = (Errs_Flg_D = 'Y')
7079 *- 1008909 01/18/05 YIK
7080 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7081 If llDtlHasError Or llRangeStyle
7082 *= 1008909
7083 Loop && For unresolved Details do not even bother...
7084 Endif
7085
7086 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
7087 *-- set to NULL if any C and/or L can be used for the PrePack:
7088 *- 08/25/04 YIK
7089 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
7090 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
7091 lcSQL = ;
7092 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
7093 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
7094 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
7095 " d.Dimension, Pack_Total," +;
7096 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7097 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7098 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7099 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7100 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7101 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
7102 " Size_Num as Sizebucket" +;
7103 " from zzxscolr c" +;
7104 " join zzxstylr st"+;
7105 " on st.pkey = c.fkey "+;
7106 " join zzxppakh h" +;
7107 " on h.Division = c.Division" +;
7108 " and h.PPK_CODE = c.Dimension" +;
7109 " and h.Size_Code = st.Size_Code" +; && TR 1026025
7110 " join zzxppakd d" +;
7111 " on d.Fkey = h.PKey" +;
7112 " cross join zzxbuckt" +;
7113 " where c.Division = " + SQLFormatChar(division ) + ;
7114 " and c.Style = " + SQLFormatChar(Style ) + ;
7115 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
7116 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
7117 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
7118 " and c.PPack_Ok = 'Y'" +;
7119 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7120 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7121 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7122 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7123 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7124 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
7125 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
7126
7127 v_SqlExec(lcSQL, "tcPPK")
7128 If Reccount("tcPPK") > 0
7129 lnPPK_SLN_Diff = pack_qty
7130 Else
7131 lnPPK_SLN_Diff = 0
7132 Endif
7133 Endif
7134 *- 1008909 01/18/05 YIK
7135 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7136 If llDtlHasError Or llRangeStyle
7137 Loop && For unresolved Details do not even bother...
7138 Endif
7139
7140 Select (pceipoTS)
7141
7142 If Reccount("tcPPK") = 0
7143 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
7144 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7145 Loop
7146 Endif
7147
7148 If tcPPK.active_ok = 'N'
7149 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
7150 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7151 Loop
7152 Endif
7153
7154 If Errs_Flg_S = 'Y'
7155 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
7156 Loop && UPC/EAN/SKU is unesolved.
7157 Endif
7158
7159 lcStyle = style && *- TR 1064758 FH
7160 lcColor_code = color_code
7161 lcLbl_code = lbl_code
7162 lcDimension = Dimension
7163 lnSLN_Qty = SLN_Qty
7164 lnSizeBucket = sizebucket
7165
7166 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
7167 Select tcPPK
7168
7169 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
7170 *FH 1084440 - added EMPTY(lcLbl_code) - if sln lbl is '', don't need to compare between DTL lbl and SLN lbl.
7171 * If DTL grabbed cust label from 850 control, second time running process will fail validation (lbl no longer matches)
7172
7173 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
7174 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
7175 AND ((Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code) OR (NVL(lbl_Code,'') = ALLTRIM(lcLbl_code))) && TR 1084440
7176
7177 If Found()
7178 Delete && in PrePack info leave only unresolved ones.
7179 Else
7180 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
7181 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
7182 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
7183 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
7184 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
7185 If !"Has errors in SLNs."$lcDtlError
7186 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
7187 Endif
7188 Endif
7189
7190 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
7191 *if lnPPK_SLN_Diff < 0
7192 *endif
7193 Endscan
7194 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
7195
7196 *- 1008909 01/18/05 YIK
7197 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
7198 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
7199 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7200 Endif
7201 *- 1013522 10/17/05 12/02/05 YIK
7202 If Used("__RangeP")
7203 Use In __RangeP
7204 Endif
7205 *=
7206 *--- TR 1023892 NH
7207 SELECT(lnOldSelect)
7208 RETURN llRetVal
7209 *== TR 1023892 NH
7210
7211 Endproc
7212
7213 *----------------------------------------------------------------------------------------
7214 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
7215 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
7216 Procedure CheckSlnSet
7217 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
7218
7219 Local lnOldSelect
7220
7221 lnOldSelect = Select()
7222
7223 If !Empty(tcPPKError)
7224 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7225 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7226 Return
7227 Endif
7228
7229 Select tcPPK
7230 Scan
7231 tcDtlError = tcDtlError +;
7232 "Missing Prepack Component" + ;
7233 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
7234 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
7235 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
7236 "; Qty:"+Transform(Qty) + CRLF
7237 Endscan
7238
7239 If !Empty(tcDtlError)
7240 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7241 Local lcErr
7242 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
7243 If !Empty(lcErr)
7244 tcDtlError = CRLF + tcDtlError
7245 Endif
7246 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7247 Endif
7248
7249 Select (lnOldSelect)
7250
7251 Endproc
7252
7253 *----------------------------------------------------------------------------------------
7254
7255 ************************************************************************************
7256 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7257 * 1. Try to substitute lbl_code with customer label when have the following conditions:
7258 * Header: customer
7259 * Detail: division,style,color_code
7260 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
7261 * resolve all detail division into header )
7262 ************************************************************************************
7263 Procedure ResolveCustomerLabel
7264 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7265 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
7266 Local llRetVal, lnOldSelect
7267 llRetVal = .T.
7268 lnOldSelect = Select()
7269 With This
7270 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
7271 *--- TechRec 1048667 03-May-2011 GSternik ---
7272 *-- Not needed, already done in the calling CheckDetail
7273 *.LogEntry("Cascading Customer To Detail.")
7274 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
7275 *=== TechRec 1048667 03-May-2011 GSternik ===
7276 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
7277 .LogEntry("Substituding customer label.")
7278 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7279 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
7280 .LogEntry("Auto creating style.")
7281 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7282 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
7283 * PL 08/22/01 27847 Auto-create Customer SKU
7284 .LogEntry("Auto creating customer style.")
7285 *--- TechRec 1005163 18-May-2004 GS ---
7286 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7287 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
7288 *=== TechRec 1005163 18-May-2004 GS ===
7289
7290 Endwith
7291 Select(lnOldSelect)
7292 Return llRetVal
7293 Endproc
7294
7295
7296 *----------------------------------------------------------------------------------------
7297 ************************************************************************************
7298 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7299 ************************************************************************************
7300 Procedure CascadingCustomerToDetail
7301 Lparameters pceipoTH, pceipoTD
7302 Local llRetVal, lnOldSelect
7303 llRetVal = .T.
7304 lnOldSelect = Select()
7305 With This
7306 * set header/detail Relation
7307 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
7308 * --- TR 1019358 RLN 10/30/06
7309 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
7310 Replace All customer With &pceipoTH..customer, ;
7311 department With &pceipoTH..department ;
7312 IN (pceipoTD)
7313 * === TR 1019358
7314 Set Relation To
7315 Endwith
7316 Select(lnOldSelect)
7317 Return llRetVal
7318 Endproc
7319
7320 *----------------------------------------------------------------------------------------
7321 *---- TR 1019697 NH
7322 Procedure CascadingCustomerToSLN
7323 Lparameters pceipoTD, pceipoTS
7324 Local llRetVal, lnOldSelect
7325 llRetVal = .T.
7326 lnOldSelect = Select()
7327 With This
7328 * set detail/SLN Relation
7329 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7330 Replace All customer With &pceipoTD..customer In (pceipoTS)
7331 Set Relation To
7332 Endwith
7333 Select(lnOldSelect)
7334 Return llRetVal
7335 Endproc
7336 *==== TR 1019697 NH
7337
7338 *----------------------------------------------------------------------------------------
7339 ************************************************************************************
7340 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7341 ************************************************************************************
7342 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7343 * regardless of auto_create of style flag set in Customer Label Ref.
7344 Procedure SubstitudeValidLabel
7345 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7346 Local llRetVal, lnOldSelect
7347 llRetVal = .T.
7348 lnOldSelect = Select()
7349 With This
7350 *- 1010285 05/18/05 YIK
7351 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7352 *- if the SKU with the label is valid and active in the style master.
7353 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7354 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7355 *-- WHERE h.pkey= d.fkey AND ;
7356 *-- d.division= C.division AND h.customer= C.customer AND ;
7357 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7358 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7359 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7360 *-- INTO CURSOR tmpCurs
7361
7362 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7363 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7364 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7365 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7366 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7367 WHERE h.pkey= d.fkey And ;
7368 d.division= C.division And h.customer= C.customer And ;
7369 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7370 Not (MultiUPC = 'Y') And ;
7371 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7372 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7373 INTO Cursor tmpCurs
7374 *==
7375
7376 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7377 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7378 "customer+division+style+color_code+dimension")
7379 If llRetVal
7380 *- 1010285 05/18/05 YIK
7381 *- 1004785 05/04/04 YIK
7382 *- Added .. AND Empty(Errs_Msg_D)
7383 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7384 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7385 Select (pceipoTD)
7386 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7387 If tmpCurs.resv_label = "Y" Or ;
7388 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7389 AND tmpscolr.active_ok = "Y" )
7390 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7391 Endif
7392 Endscan
7393 *= 1010285
7394 Set Relation To
7395 Endif
7396 .TableClose('tmpCurs')
7397 Endwith
7398 Select(lnOldSelect)
7399 Return llRetVal
7400 Endproc
7401
7402 *----------------------------------------------------------------------------------------
7403 ************************************************************************************
7404 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7405 ************************************************************************************
7406 * encounter for both set up in customer label ref:
7407 * 1. empty label apply to all customer
7408 * 2. none empty customer will be specificly create only for that customer
7409 * either 1 or 2 exists but never both
7410 *
7411 * Get a list of distinct ourSKU to server side to join zzxcolr
7412 Procedure CreateOurSKU
7413 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7414 Local llRetVal, lnOldSelect
7415 llRetVal = .T.
7416 lnOldSelect = Select()
7417 With This
7418 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7419 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7420 WHERE h.pkey= d.fkey And ;
7421 d.division= C.division And h.customer= C.customer And ;
7422 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7423 l.auto_style= 'Y' And ;
7424 C.resv_label= 'Y' And ;
7425 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7426 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7427 INTO Cursor tmpCurs
7428 *--- TR 1019697 NH
7429 *!* SCAN
7430 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7431 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7432 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7433 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7434 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7435 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7436 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7437 *!* .LogEntry("Created style: " + lcOurSKU )
7438 *!* ELSE
7439 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7440 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7441 *!* ENDIF
7442 *!* ENDIF
7443 *!* ENDSCAN
7444 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7445 *=== TR 1019697 NH
7446 Endwith
7447 Select(lnOldSelect)
7448 Return llRetVal
7449 Endproc
7450
7451 *----------------------------------------------------------------------------------------
7452
7453 Procedure CreateCustomerStyle
7454 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7455 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7456 Local llRetVal, lnOldSelect
7457 llRetVal = .T.
7458 lnOldSelect = Select()
7459 With This
7460 *--- TechRec 1005164 18-May-2004 GS ---
7461 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7462 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7463 * Where h.pkey= d.fkey and ;
7464 * d.division= C.division and h.customer= C.customer and ;
7465 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7466 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7467 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7468 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7469 * Into Cursor tmpCurs
7470 If This.oHostProcess.lHaveSLN
7471 Select Distinct C.customer,;
7472 d.division,;
7473 d.Style,;
7474 d.color_code,;
7475 C.lbl_code,;
7476 d.Dimension ;
7477 FROM (pceipoTD) d ;
7478 JOIN (pceipoTH) h ;
7479 ON h.pkey = d.fkey ;
7480 JOIN (pceipoCR) C;
7481 ON d.division= C.division ;
7482 AND h.customer= C.customer ;
7483 JOIN (pcxclblr) l ;
7484 ON C.lbl_code= l.lbl_code ;
7485 WHERE l.auto_style= 'Y' ;
7486 AND C.resv_label= 'Y' ;
7487 AND C.AutoCustSKU= 'Y' ;
7488 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7489 And h.customer > ' ' ;
7490 AND d.division > ' ' ;
7491 AND d.Style > ' ' ;
7492 AND d.color_code > ' ';
7493 UNION ;
7494 SELECT Distinct C.customer,;
7495 d.division,;
7496 d.Style,;
7497 s.color_code,;
7498 C.lbl_code,;
7499 s.Dimension ;
7500 FROM (pceipoTS) s ;
7501 JOIN (pceipoTD) d ;
7502 ON d.pkey = s.fkey ;
7503 JOIN (pceipoTH) h ;
7504 ON h.pkey = d.fkey ;
7505 JOIN (pceipoCR) C ;
7506 ON d.division= C.division ;
7507 AND h.customer= C.customer ;
7508 JOIN (pcxclblr) l ;
7509 ON C.lbl_code= l.lbl_code ;
7510 WHERE l.auto_style= 'Y' ;
7511 AND C.resv_label= 'Y' ;
7512 AND C.AutoCustSKU= 'Y' ;
7513 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7514 And h.customer > ' ' ;
7515 AND d.division > ' ' ;
7516 AND d.Style > ' ' ;
7517 AND s.color_code > ' ';
7518 INTO Cursor tmpCurs
7519
7520 Else
7521
7522 Select Distinct C.customer,;
7523 d.division,;
7524 d.Style,;
7525 d.color_code,;
7526 C.lbl_code,;
7527 d.Dimension ;
7528 FROM (pceipoTD) d ;
7529 JOIN (pceipoTH) h ;
7530 ON h.pkey = d.fkey ;
7531 JOIN (pceipoCR) C ;
7532 ON d.division= C.division ;
7533 AND h.customer= C.customer ;
7534 JOIN (pcxclblr) l ;
7535 ON C.lbl_code= l.lbl_code ;
7536 WHERE l.auto_style= 'Y' ;
7537 AND C.resv_label= 'Y' ;
7538 AND C.AutoCustSKU= 'Y' ;
7539 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7540 And h.customer > ' ' ;
7541 AND d.division > ' ' ;
7542 AND d.Style > ' ' ;
7543 AND d.color_code > ' ';
7544 INTO Cursor tmpCurs
7545
7546 Endif
7547 *=== TechRec 1005164 18-May-2004 GS ===
7548 Scan
7549 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7550 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7551 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7552 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7553 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7554 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7555 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7556 .LogEntry("Created customer style: " + lcCustSKU )
7557 Else
7558 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7559 .LogWarning("Unable to create customer style: " + lcCustSKU )
7560 Endif
7561 Endif
7562 Endscan
7563 Endwith
7564 Select(lnOldSelect)
7565 Return llRetVal
7566 Endproc
7567
7568 *----------------------------------------------------------------------------------------
7569 ************************************************************************************
7570 * Validate UPC for all details
7571 ************************************************************************************
7572 *--- TR 1088986 31-Jul-2015 BNarayanan Method name changed to avoid duplication. This method is obsolete ---
7573 *Procedure CheckUpc
7574 Procedure CheckUpc_obsolete
7575 *=== TR 1088986 31-Jul-2015 BNarayanan ===
7576 Lparameters pceipoTH, pceipoTD,;
7577 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7578
7579 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7580 * Added Parameter pceipocr
7581 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7582
7583 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7584 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7585 lnSize_desc, llSLN
7586
7587 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7588 LOCAL lcIs_upcsku
7589 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7590
7591 llRetVal = .T.
7592 lcErrs_Msg= ""
7593 lnOldSelect = Select()
7594
7595 * cannot check for UPC if customer is empty
7596 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7597 * on Cust SKU or UPC.
7598 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7599
7600 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7601 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7602 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7603
7604 *--- TechRec 1005163 17-May-2004 GS ---
7605 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7606 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7607 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7608 *Order by h.customer, d.upc Into Cursor tmpCurs
7609
7610 *---- TR 1024667 NSD 5/31/07
7611 * If sizebucket = 0 then re-resolve.
7612
7613 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7614 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7615*!* If This.lHaveSLN
7616*!* Select h.customer,;
7617*!* d.upc,;
7618*!* d.pkey,;
7619*!* (pceipoTD) As Src;
7620*!* FROM (pceipoTH) h ;
7621*!* JOIN (pceipoTD) d ;
7622*!* ON h.pkey = d.fkey ;
7623*!* WHERE !Empty(d.upc) ;
7624*!* AND !Empty(h.customer) ;
7625*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7626*!* UNION All ;
7627*!* SELECT h.customer,;
7628*!* s.SLN_UPC As upc,;
7629*!* s.pkey,;
7630*!* (pceipoTS) As Src ;
7631*!* FROM (pceipoTH) h ;
7632*!* JOIN (pceipoTD) d ;
7633*!* ON d.fkey = h.pkey ;
7634*!* JOIN (pceipoTS) s ;
7635*!* ON s.fkey = d.pkey ;
7636*!* WHERE !Empty(s.SLN_UPC) ;
7637*!* AND !Empty(h.customer) ;
7638*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7639*!* ORDER By 1, 2 ;
7640*!* INTO Cursor tmpCurs
7641*!* Else
7642*!* Select h.Customer,;
7643*!* d.UPC,;
7644*!* d.PKey,;
7645*!* (pceipoTD) As Src;
7646*!* FROM (pceipoTH) h ;
7647*!* JOIN (pceipoTD) d ;
7648*!* ON h.pkey = d.fkey ;
7649*!* WHERE !Empty(d.upc) ;
7650*!* AND !Empty(h.customer) ;
7651*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7652*!* ORDER By 1, 2;
7653*!* INTO Cursor tmpCurs
7654*!* Endif
7655 *=== TechRec 1005163 17-May-2004 GS ===
7656
7657 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7658 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7659 FROM (pceipocr) ;
7660 GROUP BY customer ;
7661 INTO CURSOR __ResvCustSKU
7662 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7663
7664 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7665*!* select h.Customer;
7666*!* , d.UPC;
7667*!* , d.PKey;
7668*!* from (pceipoTH) h;
7669*!* join (pceipoTD) d;
7670*!* on h.PKey = d.FKey;
7671*!* where !Empty(d.UPC);
7672*!* and !Empty(h.Customer);
7673*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7674*!* order by 1, 2;
7675*!* into Cursor tmpCurs ReadWrite
7676
7677 Select h.customer;
7678 , d.upc;
7679 , d.pkey,;
7680 (pceipoTD) AS Src;
7681 from (pceipoTH) h;
7682 join (pceipoTD) d;
7683 on h.pkey = d.fkey;
7684 JOIN __ResvCustSKU r ;
7685 ON r.Customer = H.Customer ;
7686 where !Empty(d.upc);
7687 and !Empty(h.customer);
7688 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7689 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7690 order By 1, 2;
7691 into Cursor tmpCurs Readwrite
7692 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7693
7694*=== TechRec 1024522 25-Sep-2007 GSternik ===
7695
7696 lcOldCust = ""
7697 lcOldItem = ""
7698 Select tmpCurs
7699 If This.lUserInterface
7700 * Init Thermometer
7701 This.UpdateThermoCaption("Validating UPC(s)...")
7702 * TAN 31891 - JAZ - 5/20/02
7703 * This.InitThermo(RECC('tmpCurs'))
7704 This.InitThermo(RecCount('tmpCurs'))
7705 * End TAN 31891 - JAZ - 5/20/02
7706 l_nThermoCnt = 0
7707 EndIf
7708
7709 Scan
7710 If This.lUserInterface
7711 * Advance progress bar, if we're using one.
7712 l_nThermoCnt = l_nThermoCnt + 1
7713 This.AdvanceThermo(l_nThermoCnt)
7714 Endif
7715 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7716 lcErrs_Msg = ""
7717 lcOldCust = tmpCurs.customer
7718 lcOldItem = tmpCurs.upc
7719 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7720 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7721
7722 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7723 lcIs_upcsku = ' '
7724 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7725
7726 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7727 lcDivision = tmpCstdr.division
7728 lcStyle = tmpCstdr.Style
7729 lcColor_code = tmpCstdr.color_code
7730 lcLbl_code = tmpCstdr.lbl_code
7731 lcDimension = tmpCstdr.Dimension
7732 lnSizeBucket = tmpCstdr.size_bk
7733 lnSize_desc = tmpCstdr.size_desc
7734
7735 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7736 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7737 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7738
7739 Else
7740 lcErrs_Msg = ""
7741 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7742 lcDivision = tmpUpcnr.division
7743 lcStyle = tmpUpcnr.Style
7744 lcColor_code = tmpUpcnr.color_code
7745 lcLbl_code = tmpUpcnr.lbl_code
7746 lcDimension = tmpUpcnr.Dimension
7747 lnSizeBucket = tmpUpcnr.sizebucket
7748 lnSize_desc = tmpUpcnr.size_desc
7749 Else
7750 lcErrs_Msg = lcErrs_Msg + CRLF
7751 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7752 Store 0 To lnSizeBucket
7753 Endif
7754 Endif
7755 Endif && level break
7756
7757 *--- TechRec 1005163 17-May-2004 GS ---
7758 *Select (pceipoTD)
7759*!* llSLN = (tmpCurs.Src = pceipoTS)
7760*!* If llSLN
7761*!* Select (pceipoTS)
7762*!* Else
7763 Select (pceipoTD)
7764*!* Endif
7765 *=== TechRec 1005163 17-May-2004 GS ===
7766 *- 1010682 04/25/05 YIK
7767 *- Locate For pkey = tmpCurs.pkey
7768 lnWorkArea = Select()
7769 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7770 Scatter Name loEiPOtd Memo
7771 If !Empty(lcErrs_Msg)
7772*!* *--- TechRec 1005163 17-May-2004 GS ---
7773*!* If llSLN
7774*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7775*!* loEiPOtd.Errs_Flg_S = "Y"
7776*!* Else
7777*!* *=== TechRec 1005163 17-May-2004 GS ===
7778 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7779 loEiPOtd.Errs_Flg_D = "Y"
7780*!* Endif
7781 Endif
7782 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7783 loEiPOtd.Division = lcDivision
7784 loEiPOtd.Style = lcStyle
7785 loEiPOtd.Color_Code = lcColor_code
7786 loEiPOtd.Lbl_Code = lcLbl_code
7787 loEiPOtd.Dimension = lcDimension
7788 loEiPOtd.SizeBucket = lnSizeBucket
7789 loEiPOtd.Size_Desc = lnSize_desc
7790
7791 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7792 IF !EMPTY(lcIs_upcsku)
7793 loEiPOtd.Is_upcsku = lcIs_upcsku
7794 ENDIF
7795 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7796
7797 *--- TR 1019697 NH : clear rang style when bc style is set
7798 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7799 loEiPOtd.rng_style = ''
7800 loEiPOtd.rng_color = ''
7801 loEiPOtd.rng_lbl = ''
7802 loEiPOtd.rng_pack = ''
7803 Endif
7804 *=== TR 1019697 NH
7805 Endif
7806
7807 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7808 * only replace our SKU when no range style explosion happen
7809 *--- TechRec 1005163 17-May-2004 GS ---
7810 *If empty(&pceipoTD..rng_style)
7811 * Replace division With loEiPOtd.division, ;
7812 * style With loEiPOtd.style, ;
7813 * color_code With loEiPOtd.color_code, ;
7814 * lbl_code With loEiPOtd.lbl_code, ;
7815 * dimension With loEiPOtd.dimension, ;
7816 * sizebucket With loEiPOtd.sizebucket, ;
7817 * size_desc With loEiPOtd.size_desc, ;
7818 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7819 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7820 * In (pceipoTD)
7821 *Endif
7822 *- 1009508 3/16/05 YIK
7823 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7824 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7825 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7826 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7827 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7828
7829 Gather Name loEiPOtd Memo
7830 Endif
7831 *=== TechRec 1005163 17-May-2004 GS ===
7832 Endscan
7833 Use In tmpCurs
7834
7835 If This.lUserInterface
7836 * Reset Thermometer
7837 This.ResetThermo()
7838 Endif
7839
7840 If Used("tmpCstdr")
7841 Use In tmpCstdr
7842 Endif
7843 If Used("tmpUpcnr")
7844 Use In tmpUpcnr
7845 Endif
7846
7847 Select(lnOldSelect)
7848 Return llRetVal
7849 Endproc
7850
7851 *----------------------------------------------------------------------------------------
7852 ************************************************************************************
7853 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7854 ************************************************************************************
7855 Procedure ValidateOurSKU
7856 Lparameters pceipoTH, pceipoTD, pceipoTS
7857 Local llRetVal, lnOldSelect, lcScolrSQL
7858 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
7859
7860 *--- TechRec 1022705 21-Jun-2007 jjanand ---
7861 LOCAL llActiveCheck
7862 *=== TechRec 1022705 21-Jun-2007 jjanand ===
7863
7864 *--- TR 1017598 14-Sep-2006 SS
7865 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
7866
7867 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
7868
7869 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
7870
7871 *--- TR 1018193 18-NOV-2006 VKK
7872 lcErrs_Allowed_Msg = ""
7873 *=== TR 1018193 18-NOV-2006 VKK
7874
7875 *=== TR 1017598 14-Sep-2006 SS
7876
7877 * --- TR 1039400 3/31/09 CM
7878 LOCAL lcCurrentSku
7879 lcCurrentSku = ""
7880 * === TR 1039400 3/31/09 CM
7881
7882 llRetVal = .T.
7883 lnOldSelect = Select()
7884
7885 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
7886 *--- See VSS for Changes.
7887
7888 * for anything that resove to None blank h.customer, d.div/sty/col-
7889 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
7890 *- TAN 27166
7891 *- 1010682 04/25/05 YIK
7892 *- Added .. WHERE d.rng_style = ' '
7893
7894 *- 1017363 06/02/06 YIK
7895 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
7896
7897 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
7898 Select h.customer;
7899 , d.division;
7900 , d.Style;
7901 , d.color_code;
7902 , d.lbl_code;
7903 , d.Dimension;
7904 , d.sizebucket;
7905 , d.size_desc; && TR 1058045 11-29-2011 RKI
7906 , d.upc; && TR 1058045 11-29-2011 RKI
7907 , d.sku; && TR 1058045 11-29-2011 RKI
7908 , d.ean; && TR 1058045 11-29-2011 RKI
7909 , d.pkey;
7910 , (pceipoTD) As Src ;
7911 from (pceipoTH) h;
7912 join (pceipoTD) d ;
7913 on h.pkey = d.fkey ;
7914 where h.customer >' ' ;
7915 and d.division >' ' ;
7916 and d.Style >' ' ;
7917 and d.color_code >' ' ;
7918 UNION All;
7919 select h.customer;
7920 , s.division;
7921 , s.Style;
7922 , s.color_code;
7923 , s.lbl_code;
7924 , s.Dimension;
7925 , s.sizebucket;
7926 , s.size_desc; && TR 1058045 11-29-2011 RKI
7927 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
7928 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
7929 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
7930 , s.pkey;
7931 , (pceipoTS) As Src ;
7932 from (pceipoTS) s;
7933 join (pceipoTD) d ;
7934 on d.pkey = s.fkey;
7935 join (pceipoTH) h ;
7936 on h.pkey = d.fkey ;
7937 and h.customer > ' ' ;
7938 and s.division > ' ' ;
7939 and s.Style > ' ' ;
7940 and s.color_code > ' ' ;
7941 where d.rng_style = ' ' ;
7942 order By 2, 3, 4, 5, 6, 7, 1 ;
7943 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
7944
7945 *-- Order by SKU + Bucket + Customer !!!
7946 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
7947
7948 lcCnt = Reccount("tmpCurs")
7949 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
7950
7951 *--- This cursor will be used to cache Customer-Label Validations:
7952 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
7953 Index On customer + lbl_code Tag CustLbl
7954
7955 lcErrs_Msg = ''
7956 Select tmpCurs
7957 Scatter Memo Name oTmpCurs Blank
7958 * --- TR 1014834 RLN 08/10/06
7959
7960 *--- TR 1017598 14-Sep-2006 SS
7961 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7962
7963 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7964 llBookUnavail = (lcbk_unavl_sku = 'Y')
7965 llErrUnavail = (lcbk_unavl_sku = 'E')
7966 *=== TR 1017598 14-Sep-2006 SS
7967
7968 With oTmpCurs
7969 llSize_OK = .T.
7970 Scan
7971 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
7972 * --- TR 1027498 NSD 10/3/07
7973 * Clear error message after every line, not just every sku.
7974 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
7975 * === TR 1027498 NSD 10/3/07
7976
7977 * --- TR 1014834 RLN 08/10/06
7978 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
7979 *llSize_OK = .T. FH 1090559 - absolutely have to comment this. IT should only be set when we change sizes
7980 If division # .division ;
7981 or Style # .Style ;
7982 or color_code # .color_code ;
7983 or lbl_code # .lbl_code ;
7984 or Dimension # .Dimension
7985 *-- SKU Changed... Let's make sure it is valid:
7986
7987 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
7988 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7989
7990 * --- TR 1039400 3/31/09 CM
7991 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
7992 * === TR 1039400 3/31/09 CM
7993
7994 * --- TR 1014834 RLN 08/10/06
7995 If division <> .division
7996 *--- TR 1017598 14-Sep-2006 SS
7997 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7998
7999 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
8000 llBookUnavail = (lcbk_unavl_sku = 'Y')
8001 llErrUnavail = (lcbk_unavl_sku = 'E')
8002 *=== TR 1017598 14-Sep-2006 SS
8003 Endif
8004 * === TR 1014834
8005 lcErrs_Msg = ""
8006 .division = division
8007 .Style = Style
8008 .color_code = color_code
8009 .Dimension = Dimension
8010 .lbl_code = lbl_code && TR 1057867 FH
8011 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
8012 * --- TR 1014834 RLN 08/09/06
8013 lnSelect = Select()
8014 * Available sizes stored in Scolr
8015 *--- TR: 1021620 BR/NH
8016 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
8017 Lbl_Code, .Dimension)
8018
8019
8020*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
8021*!* "division = " + SQLFormatChar(division) + " AND " + ;
8022*!* "style = " + SQLFormatChar(Style) + " AND " + ;
8023*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
8024*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
8025*!* "dimension = " + SQLFormatChar(Dimension)
8026
8027*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
8028*!* Select (lnSelect)
8029*!* * === TR 1014834
8030*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
8031*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
8032
8033 *--- TechRec 1022705 20-Jun-2007 jjanand ---
8034 *!* IF tcTmpScolr.active_ok = 'N'
8035 llActiveCheck = This.lAllowInactiveStyleColors
8036 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
8037 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
8038 IF llActiveCheck
8039 *=== TechRec 1022705 20-Jun-2007 jjanand ===
8040
8041 lcErrs_Msg = "Inactive Style/Color"
8042 llStyle_OK = .F.
8043 ELSE
8044 lcErrs_Msg = ""
8045 llStyle_OK = .T.
8046 ENDIF
8047
8048 *--- TR 1040614 MAY-29-2009 BR
8049 llUnAvlBkCheck = .T.
8050 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
8051 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
8052
8053 *- TR 1062018 FH 06/08/12 - We already set llStyle_OK = .F. , we don't need check the combination, we end up loosing our error message
8054 IF llStyle_OK
8055 IF llUnAvlBkCheck
8056 lcErrs_Msg = "Style/Color combination is unavailable"
8057 llStyle_OK = .F.
8058 ELSE
8059 lcErrs_Msg = ""
8060 llStyle_OK = .T.
8061 ENDIF
8062 ENDIF
8063 *- TR 1062018 FH 06/08/12
8064 *=== TR 1040614 MAY-29-2009 BR
8065 ELSE
8066 *=== TR 1021620
8067 llStyle_OK = .F.
8068 This.GetStyleError(@lcErrs_Msg)
8069 Endif
8070 Endif && SKU Changed
8071
8072 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
8073 *- took out (customer # .customer Or .lbl_code # lbl_code)
8074 If llStyle_OK AND llSKU_changed
8075*!* If llStyle_OK And (;
8076*!* customer # .customer Or .lbl_code # lbl_code)
8077 .lbl_code = lbl_code
8078 .customer = customer
8079 llLabel_OK = .T.
8080 If !Empty(.lbl_code)
8081 If !Seek(.customer+.lbl_code, "curCustLbl")
8082 *- populate cursor of cached Customer/Lbl
8083 *- vl_clblr2() returns .F. if lbl is invalid for the customer
8084 Insert Into curCustLbl Values(;
8085 .customer, .lbl_code,;
8086 vl_clblr2(.lbl_code, "", , .customer))
8087 Endif
8088
8089 If !curCustLbl.is_Valid && always check from the cached table.
8090 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
8091 llLabel_OK = .F.
8092 Endif
8093 Endif
8094 Endif && Style OK
8095
8096 *--- TR 1058045 11-29-2011 RKI ---*
8097 lnPkey = Pkey
8098 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
8099 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
8100 replace sizebucket WITH lnSize_BK
8101 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
8102 DO CASE
8103 CASE tmpCurs.Src = (pceipoTD)
8104 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8105 CASE tmpCurs.Src = (pceipoTS) && TR 1090066 FH - typo
8106 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8107 Endcase
8108 ENDIF
8109 ENDIF
8110 SELECT tmpCurs
8111 *=== TR 1058045 11-29-2011 RKI ===*
8112
8113 * --- TR 1018184
8114 *llAllowedSize_OK = .T. FH 1090559 - what if 2 records have same sku and size, first record finds llAllowedSize_OK to be .F.
8115 * Second record will set llAllowedSize_OK to .T. here, and it won't go in the below to revaluate llAllowedSize_OK because same sizebucket
8116 If llStyle_OK And llLabel_OK
8117 IF llSKU_changed OR sizebucket # .sizebucket OR EMPTY(SizeBucket) && TR 1058045 11-29-2011 RKI Empty(SizeBucket) added. && TR 1034769 JUL-21-2008 BR ADDED: llSKU_changed OR
8118 .sizebucket = sizebucket
8119 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8120
8121 llAllowedSize_OK = .T. && FH 1090559
8122 llSize_OK = .T. && FH 1090559
8123
8124 *- that's why we used Savlr
8125 * --- TR 1014834 RLN 08/09/06
8126 * I guess we really do not need Savlr...
8127 *llSize_OK = Evaluate("__Savlr.allow"
8128 *--- TR 1058045 11-29-2011 RKI ---*
8129 IF BETWEEN(.sizebucket,1,24)
8130 *=== TR 1058045 11-29-2011 RKI ===*
8131 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
8132 Transform(.sizebucket, "@L 99")) = 'Y'
8133
8134 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
8135 *if !llSize_OK
8136 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
8137 Transform(.sizebucket, "@L 99")) = 'Y'
8138 *--- TR 1058045 11-29-2011 RKI ---*
8139 ELSE
8140 llAllowedSize_OK = .F.
8141 ENDIF
8142 *=== TR 1058045 11-29-2011 RKI ===*
8143
8144 If !llAllowedSize_OK
8145 *--TR 1034769 JUL-21-2008 BR
8146 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
8147 lcErrs_Msg = "Invalid Available Sizes."
8148 *==TR 1034769 JUL-21-2008 BR
8149 Else
8150 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
8151 lcErrs_Msg = "Invalid Available Sizes."
8152 Endif
8153 Endif
8154
8155 *=== TR 1017598 14-Sep-2006 SS
8156 ENDIF
8157 && FH 1090559 - added this else because, it will go here if style, or lbl is invalid, this means I don't even care about if sizes
8158 * is valid or not. So let's set variable llAllowedSize_OK = .T. and llSize_OK = .T.
8159 * because it will force error (TR 1067995, DEV NOTE TECHNICAL, explains scenario where style is invalid but still won't
8160 * error out because of these size variables that was from previous records),
8161 * if any of the 2 variables is .F., it will try to add error message base on size variables
8162 * which doesn't make sense.
8163 ELSE
8164 llAllowedSize_OK = .T.
8165 llSize_OK = .T.
8166
8167 Endif
8168 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
8169
8170 * for each detail line replace detail error msg if have one
8171 *--- TechRec 1005163 21-Jun-2004 GS ---
8172 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
8173 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
8174 * Errs_Flg_D with 'Y' in (pceipoTD)
8175 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
8176 If tmpCurs.Src = (pceipoTD)
8177 *--- TR 1017598 14-Sep-2006 SS
8178 If Not llAllowedSize_OK && if size is not allowed - error out always
8179 *--- TR 1018193 18-NOV-2006 VKK
8180 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
8181 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
8182 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
8183 Errs_Flg_D With 'Y' In (pceipoTD)
8184 *=== TR 1018193 18-NOV-2006 VKK
8185 Else
8186 *=== TR 1017598 14-Sep-2006 SS
8187
8188 * --- TR 1014834 RLN 08/08/06
8189 If !llSize_OK
8190 If llBookUnavail
8191 Replace UnAvailSize With .T. In (pceipoTD)
8192 Else
8193 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
8194 If llErrUnavail && error as invalid available sizes.
8195 * === TR 1014834
8196 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
8197 Errs_Flg_D With 'Y' In (pceipoTD)
8198 Endif
8199 *=== TR 1017598 14-Sep-2006 SS
8200 ENDIF
8201 *--- TR 1021620 NH 04/12/07
8202 ELSE
8203
8204
8205 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
8206 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
8207 IF llSKU_changed
8208 * --- TR 1039400 3/31/09 CM
8209 * Commented out and added seek/scan while to determine how many particular style/color
8210 * combinations should be flagged as inactive
8211 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8212 Select(pceipoTD)
8213 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
8214 If Seek(lcCurrentSku)
8215 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
8216 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8217 Endscan
8218 Endif
8219 * === TR 1039400 3/31/09 CM
8220 endif
8221 *--TR 1057867 FH
8222
8223 *=== TR 1021620 NH 04/12/07
8224 Endif && TR 1014834
8225 Endif && TR 1017598
8226 ELSE
8227 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
8228 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
8229 Errs_Flg_S With 'Y' In (pceipoTS)
8230
8231 *- 1010682 04/25/05 YIK
8232 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
8233 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
8234 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
8235 Select(pceipoTS)
8236 lnFKey = fkey
8237 Select(pceipoTD)
8238 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
8239 *=== TechRec 1016817 04-May-2006 GS ===
8240 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
8241 Errs_Flg_D With 'Y' In (pceipoTD)
8242 ENDIF
8243 ENDIF
8244 Endif
8245 *=== TechRec 1005163 21-Jun-2004 GS ===
8246 Endif
8247 Endscan
8248 Endwith
8249
8250 Use In Select("curCustLbl")
8251
8252 Select(lnOldSelect)
8253 Return llRetVal
8254 Endproc
8255
8256 *----------------------------------------------------------------------------------------
8257
8258 Function GetCustLabel
8259 Lparameters pcCust
8260 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
8261
8262 llRetVal = True
8263 lnSelect = Select()
8264 l_vRetVal = ''
8265 lcCursor = GetUniqueFileName()
8266
8267 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
8268
8269 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
8270
8271 If llRetVal
8272 Select(lcCursor)
8273 l_vRetVal = Alltrim(lbl_code )
8274
8275 Use In (lcCursor)
8276 Endif
8277
8278 Select (lnSelect)
8279 Return l_vRetVal
8280 Endfunc
8281
8282 *----------------------------------------------------------------------------------------
8283 Function ResolveMultiPrepacks
8284 Lparameters pcTransHeader, pcTransDetail, pcMppk
8285 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
8286
8287 llRetVal = True
8288 lnOldSelect = Select()
8289
8290
8291
8292 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8293 FROM (pcTransHeader) h, (pcTransDetail) d ;
8294 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
8295 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
8296 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8297
8298 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
8299 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
8300 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
8301 *!* d.rng_style= '' ;
8302 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
8303
8304 With This
8305 .cSQLTempTable=""
8306
8307 If .GenerateSQLTempTable('__TmpCursor')
8308 If .PopulateSQLTempTable('__TmpCursor')
8309 If !Empty(.cSQLTempTable)
8310
8311 .LogEntry("Exploding MultiPack.")
8312
8313 *AND h.mpack_code = t.dimension
8314 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
8315 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8316
8317 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
8318
8319 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
8320
8321 If llMultPpkToExplode
8322
8323 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
8324 "Where h.pkey = d.fkey AND h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8325
8326 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
8327
8328
8329 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
8330
8331 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
8332 WHERE 0=1 Into Cursor __ppk2
8333
8334
8335 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
8336 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
8337
8338
8339 If Used("__ppk1")
8340 Use In __ppk1
8341 Endif
8342
8343 If Used("__ppk2")
8344 Use In __ppk2
8345 Endif
8346
8347 Select __MppkH
8348 Index On pkey Tag pkey
8349 Select __MppkD
8350 Index On division+Style Tag DivStyle
8351 Select tcMppkVer
8352 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8353 Set Order To MpackRef
8354 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8355
8356 *****************************************************************************
8357 *!* SELECT DISTINCT pkey FROM __MppkD ;
8358 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8359 *!* INTO CURSOR __DtlExpl
8360
8361
8362 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8363 *!* FROM __MppkD m, (pcTransDetail) d ;
8364 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8365 *!* INTO CURSOR __DtlExpl
8366
8367 && TR 1011644 VSS 27-09-2005
8368
8369 Select Distinct d.pkey ;
8370 FROM __MppkD mp, (pcTransDetail) d ;
8371 WHERE d.Errs_Flg_D= "N" ; &&no error
8372 And mp.Style = d.Style ;
8373 AND mp.color_code = d.color_code ;
8374 AND mp.lbl_code = d.lbl_code ;
8375 AND mp.Dimension = d.Dimension;
8376 AND d.implosion = 'Y';
8377 INTO Cursor __DtlExpl
8378
8379 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8380
8381 Endif
8382 Endif
8383 Endif
8384 Endif
8385 Endwith
8386
8387 If Used("__MppkH")
8388 Use In __MppkH
8389 Endif
8390 If Used("__MppkD")
8391 Use In __MppkD
8392 Endif
8393 If Used("tcMppkVer")
8394 Use In tcMppkVer
8395 Endif
8396 If Used("__DtlExpl")
8397 Use In __DtlExpl
8398 Endif
8399 If Used("__TmpCursor")
8400 Use In __TmpCursor
8401 Endif
8402
8403 Select(lnOldSelect)
8404 Return llRetVal
8405
8406 Endfunc
8407
8408 *----------------------------------------------------------------------------------------
8409 Procedure ExplodeMultiPackVertical
8410 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8411 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8412 llRetVal = .T.
8413 lnOldSelect = Select()
8414
8415 .LogEntry("Exploding multi pack details into vertical cursor.")
8416 Select (pcDetailtoExplode)
8417
8418 Scan
8419
8420 If Seek(pkey, pcTransDetail, "Pkey")
8421
8422 * Current working trans detail
8423 Select (pcTransDetail)
8424 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8425 lnCurDtlTotal_qty= total_qty
8426
8427
8428 Scatter Name loTransDetail Memo
8429 * delete current working trans detail already have image
8430 * in loTransDetail
8431 Delete In (pcTransDetail)
8432
8433
8434 Select (pcMultDetailVert)
8435 * Find 1st match of OURSKU
8436 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8437 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8438
8439
8440 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8441 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8442 * Exploding detail line
8443 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8444 If !Empty(loTransDetail.pkey)
8445
8446 Select (pcMultDetailVert)
8447 Scatter Name loVert Memo
8448
8449 Select (pcTransDetail)
8450 Append Blank
8451 Gather Name loTransDetail Memo
8452
8453 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8454 sizebucket With loVert.sizebucket, ;
8455 size_desc With loVert.size_desc, ;
8456 division With loVert.division, ;
8457 STYLE With loVert.Style, ;
8458 color_code With loVert.color_code, ;
8459 lbl_code With loVert.lbl_code, ;
8460 DIMENSION With loVert.ppk_code In (pcTransDetail)
8461 Else
8462 .LogEntry("Pkey cannot be empty.")
8463 llRetVal= .F. && Cannot get Pkey from bcsysnum
8464 Exit
8465 Endif
8466
8467 Select (pcMultDetailVert)
8468 Endscan
8469 Else
8470 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8471 llRetVal= .F. && Should be in pcMultDetailVert
8472 Exit
8473 Endif
8474 Endif
8475
8476 If !llRetVal &&Get out of scan when have some problem
8477 Exit
8478 Endif
8479 Endscan
8480
8481 Select(lnOldSelect)
8482 Return llRetVal
8483 Endproc
8484 *=== TR 1011644 23-AUG-2005 KA
8485
8486 *----------------------------------------------------------------------------------------
8487 Procedure ExplodeMultPackRef
8488 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8489 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8490 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8491
8492 lnOldSele = Select()
8493 lcDivStyle = ""
8494 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8495
8496 llRetVal= .T.
8497 lnCurDtlFkey= 0
8498 lnMultiplyQty = 0
8499
8500 .LogEntry("Exploding multi pack details.")
8501
8502 Select (pcMultPackDetail)
8503 Set Order To DivStyle
8504 Scan
8505
8506 If lnCurDtlFkey<> fkey
8507 lnCurDtlFkey = fkey
8508 If Seek(fkey, pcMultPackHeader , "PKEY")
8509 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8510 Else
8511 llRetVal = .F.
8512 Exit
8513 Endif
8514 Endif
8515
8516
8517 * only run once per Div + Style
8518 If !(lcDivStyle == division + Style)
8519 lcDivStyle = division + Style
8520 * Insert a record for each size bucket with a caption *
8521 If !v_GetSizeHeadings(division, Style, "__xSizer")
8522 llRetVal = .F.
8523 Exit
8524 Endif
8525 Endif
8526
8527
8528 lnSizeQty = 1
8529 Select (pcMultPackDetail)
8530 Scatter Memvar Memo
8531
8532 lnSizePosition = 1
8533 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8534 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8535 lnSizeQty = ppk_qty
8536
8537 m.sizebucket = lnSizePosition
8538 m.size_desc = lcSizeName
8539 m.total_qty = lnSizeQty
8540 m.multQty = lnMultiplyQty
8541
8542 If lnSizeQty > 0 && Only want buckets with activity!
8543 Insert Into (pcMultPackTarget) From Memvar
8544 Endif
8545 Select (pcMultPackDetail)
8546
8547 Endscan
8548
8549 This.TableClose("__xSizer")
8550 Select (pcMultPackDetail)
8551 Select (lnOldSele)
8552 Return llRetVal
8553 Endproc
8554
8555 *----------------------------------------------------------------------------------------
8556 *--- TechRec 1016817 04-May-2006 GS ---
8557 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8558 Procedure GetStyleError
8559
8560 Lparameter tcErrorMsg, toTmpCurs
8561
8562 Do Case
8563 Case vl_scolr(division,,, Style, color_code, lbl_code)
8564 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8565
8566 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8567 tcErrorMsg = "Invalid Label code." + CRLF
8568
8569 Case !Empty(Style) And vl_Stylr(division,,, Style)
8570 tcErrorMsg = "Invalid Color code." + CRLF
8571
8572 Otherwise
8573 tcErrorMsg = "Invalid Style." + CRLF
8574 Endcase
8575 Endproc
8576
8577 *----------------------------------------------------------------------------------------
8578
8579 **********************************************************************************
8580 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8581 **********************************************************************************
8582 Procedure PopulateInboundUOM
8583 Lparameters pceipoTH, pceipoTD, pceipoCR
8584 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8585 llRetVal = .T.
8586 lnOldSelect = Select()
8587
8588 With This
8589
8590 *****************************************************************************
8591 * unconditionally reset all base_uom and uom_factor
8592 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8593
8594 *****************************************************************************
8595 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8596 * Server-side join previous list to get cursor of scolr to populate base_uom
8597 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8598 FROM (pceipoTH) h, (pceipoTD) d ;
8599 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8600 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8601 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8602 * TAN 31891 - JAZ - 5/20/02 @@@
8603 * If Recc("__TmpCursor")> 0
8604 If Reccount("__TmpCursor")> 0
8605 * End TAN 31891 - JAZ - 5/20/02
8606 .cSQLTempTable=""
8607 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8608 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8609 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8610 "Where s.division= t.division and s.style= t.style and "+;
8611 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8612 "s.dimension= t.dimension"
8613 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8614 * Populate style UOM
8615 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8616 Endif
8617 .TableClose("tcUOM")
8618 .TableClose("__TmpCursor")
8619
8620 *****************************************************************************
8621 * Get distinct list of Inbound UOM and style UOM
8622 * Server-side join previous list to populate UOM conversion factor
8623 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8624 WHERE ib_uom<>'' And base_uom<>'' ;
8625 INTO Cursor __TmpCursor
8626 * TAN 31891 - JAZ - 5/20/02
8627 * If Recc("__TmpCursor")> 0
8628 If Reccount("__TmpCursor")> 0
8629 * End TAN 31891 - JAZ - 5/20/02
8630 .cSQLTempTable=""
8631 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8632 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8633 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8634 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8635 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8636 * Populate style UOM
8637 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8638 Endif
8639 .TableClose("tcUOMFactor")
8640 .TableClose("__TmpCursor")
8641
8642 Endwith
8643 Select(lnOldSelect)
8644 Return llRetVal
8645 Endproc
8646
8647 *----------------------------------------------------------------------------------------
8648
8649 Procedure PopulateBaseUOM
8650 Lparameters pceipoTD, pcUOM
8651 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8652 llRetVal = .T.
8653 lnOldSelect = Select()
8654
8655 With This
8656 Select (pcUOM)
8657 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8658 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8659 "division+style+color_code+lbl_code+dimension")
8660 Select (pceipoTD)
8661 If llRetVal
8662 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8663 FOR !Empty(&pcUOM..uom)
8664 Endif
8665 Set Relation To
8666 Endwith
8667 Select(lnOldSelect)
8668 Return llRetVal
8669 Endproc
8670
8671 *----------------------------------------------------------------------------------------
8672
8673 Procedure PopulateUOMFactor
8674 Lparameters pceipoTD, pcUOMFactor
8675 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8676 llRetVal = .T.
8677 lnOldSelect = Select()
8678
8679 With This
8680 Select (pcUOMFactor)
8681 Index On uom+uom_convert Tag IB_BaseUOM
8682 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8683 "ib_uom+base_uom")
8684 Select (pceipoTD)
8685 If llRetVal
8686 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8687 FOR !Empty(&pcUOMFactor..uom_factor)
8688 Endif
8689 Set Relation To
8690 Endwith
8691 Select(lnOldSelect)
8692 Return llRetVal
8693 Endproc
8694
8695 *----------------------------------------------------------------------------------------
8696
8697 Procedure ResolvePrepack
8698 Lparameters pceipoTH, pceipoTD, pceipoCR
8699
8700 LOCAL llRetVal
8701 llRetVal = .t.
8702 IF VARTYPE(This.oResolvePrepack) <> "O"
8703 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8704 ENDIF
8705
8706 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8707
8708 IF NOT llRetVal
8709 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8710 RETURN llRetVal
8711 ENDIF
8712
8713 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8714 this.oResolvePrepack.cLogName = this.cLogName
8715
8716 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8717 This.oResolvePrepack.c850Control = This.c850Control
8718 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8719
8720 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
8721
8722 RETURN llRetVal
8723
8724 ENDPROC
8725
8726 *------------------------------------------------------------------------
8727
8728 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8729 Procedure ValidateCharges
8730 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8731
8732 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8733 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8734 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8735 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8736 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8737 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8738 lcDtlError = "Has errors in Charges." + CRLF
8739 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8740 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8741 SELECT (tcEipoTH)
8742 lntcEipoTHrec = RECNO()
8743 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8744
8745 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8746 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8747 v_sqlExec(;
8748 "select d.FKey"+;
8749 " , d.Chrg_Type"+;
8750 " , d.Chrg_Flag"+;
8751 " , d.Active_Ok"+;
8752 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8753 " from zzxChrgD d"+;
8754 " join zzxChrTR t"+;
8755 " on t.Chrg_Type = d.Chrg_Type"+;
8756 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8757 Select qChrgD
8758 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8759 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8760 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8761 v_sqlExec(;
8762 "select Customer"+;
8763 " , Division"+;
8764 " , Store"+;
8765 " , Center_Code"+;
8766 " , Season"+;
8767 " , PKey"+;
8768 " , Rank_Seq"+;
8769 " from zzxchrgh", "qChrgH")
8770 Select qChrgH
8771 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8772 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8773 Index On division+customer+Store+Center_Code+Season Tag divcust
8774 If division = ' ' And customer = ' '
8775 lnDefaultKey = pkey
8776 Endif
8777
8778 Select (tcEiPOTR)
8779 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8780 Scan
8781 lcChrg_Type = Chrg_Type
8782 Select (tcEiPOtd)
8783 lcDivision = division
8784 lcCustomer = customer
8785 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8786 lnFkeyEipoTD = fkey
8787 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8788 lcCenter_Code = &tcEipoTH..center_Code
8789 lcStore = &tcEipoTH..Store
8790 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8791 lcSeason = &tcEipoTH..Season
8792 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8793 ELSE
8794 lcCenter_Code = ""
8795 lcStore = ""
8796 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8797 lcSeason = ""
8798 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8799 ENDIF
8800 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8801
8802 Select qChrgH
8803 Do Case
8804 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8805*!* Case Seek(lcDivision+lcCustomer)
8806*!* lnFKey = pkey
8807*!* Case Seek(' '+lcCustomer, "qChrgH")
8808*!* lnFKey = pkey
8809*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8810*!* Case Seek(lcDivision+' ')
8811*!* lnFKey = pkey
8812*!* Otherwise
8813*!* lnFKey = lnDefaultKey
8814 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8815*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8816*!* lnFKey = pkey
8817*!*
8818*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8819*!* lnFKey = pkey
8820*!*
8821*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8822*!* lnFKey = pkey
8823*!*
8824*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8825*!* lnFKey = pkey
8826
8827*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8828*!* lnFKey = pkey
8829*!*
8830*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8831*!* lnFKey = pkey
8832
8833 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
8834 lnFKey = pkey
8835
8836 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
8837 lnFKey = pkey
8838
8839 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
8840 lnFKey = pkey
8841
8842 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
8843 lnFKey = pkey
8844
8845 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
8846 lnFKey = pkey
8847
8848 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
8849 lnFKey = pkey
8850
8851 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
8852 lnFKey = pkey
8853
8854 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
8855 lnFKey = pkey
8856
8857 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
8858 lnFKey = pkey
8859
8860 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
8861 lnFKey = pkey
8862 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8863
8864 Otherwise
8865 lnFKey = lnDefaultKey
8866 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8867 Endcase
8868 Select (tcEiPOTR)
8869 If Empty(lnFKey)
8870 Replace Errs_Flg_R With "Y",;
8871 Errs_Msg_R With "No Charges set up for "+;
8872 Trim(lcDivision)+'/'+Trim(lcCustomer)
8873 Else
8874 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
8875 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
8876
8877 *--- Check if the Charge still active:
8878 If qChrgD.Active_Ok # 'Y'
8879 Replace Errs_Flg_R With "Y",;
8880 Errs_Msg_R With lcErrorMsg3
8881 Endif
8882
8883 If Empty(Chrg_Flag)
8884 *-- Set Charge Type from Resolution if success
8885 If Errs_Flg_R # "Y"
8886 Replace Chrg_Flag With lcResolved_Chrg_Flag
8887 Endif
8888 Else
8889 If Chrg_Flag # lcResolved_Chrg_Flag
8890 Replace Errs_Flg_R With "Y",;
8891 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
8892 Endif
8893 Endif
8894 Else
8895 Replace Errs_Flg_R With "Y",;
8896 Errs_Msg_R With lcErrorMsg1
8897 lnFKey = fkey
8898 lcResolved_Chrg_Flag = ""
8899 Endif
8900 Endif
8901
8902 If Errs_Flg_R = "Y"
8903 Select(tcEiPOtd)
8904 If !lcDtlError$Errs_Msg_D
8905 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
8906 Errs_Flg_D With 'Y'
8907 Endif
8908 ELSE
8909 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
8910* Replace Chrg_Cost With qChrgD.Chrg_Cost
8911 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
8912 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
8913 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
8914 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
8915 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
8916 Endif
8917 Endscan
8918
8919 Set Relation To
8920 Use In Select("qChrgH")
8921 Use In Select("qChrgD")
8922 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8923 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
8924 GO lntcEipoTHrec IN (tcEipoTH)
8925 ENDIF
8926 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8927
8928 Endproc
8929 *=== TechRec 1028745 05-Feb-2008 GSternik ===
8930
8931 *------------------------------------------------------------------------
8932
8933 *--- TR 1083402 20-Jan-2015 Partha ---
8934 * ROFL - This proc is duplicate :)
8935*!* *----------------------------------------------------------------------------------------
8936*!* *--- TR 1034481 NH
8937*!* PROCEDURE MarkHeaderForMissing855ControlRef
8938*!* LPARAMETERS pceipoTH
8939*!*
8940*!* LOCAL llRetVal, lnOldSelect,lcZzeoprcr
8941*!*
8942*!* llRetVal = .t.
8943*!* lnOldSelect = SELECT()
8944*!* lcZzeoprcr = "Oprcr" + SYS(2015)
8945*!* *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
8946*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
8947*!*
8948*!* IF USED(lcZzeoprcr)
8949*!* INDEX on customer TAG customer
8950*!* INDEX on division TAG division
8951*!*
8952*!* UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
8953*!* from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
8954*!* AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
8955
8956*!* USE IN (lcZzeoprcr)
8957*!* ENDIF
8958*!*
8959*!* SELECT(lnOldSelect)
8960*!* RETURN llRetVal
8961*!*
8962*!* ENDPROC
8963*!* *=== TR 1034481 NH
8964
8965 *=== TR 1083402 20-Jan-2015 Partha ===
8966
8967 *----------------------------------------------------------------------------------------
8968
8969 *--- TR 1035491 4-Nov-2008 Goutam
8970 ************************************************************************************
8971 * Move SLN to Detail.
8972 ************************************************************************************
8973 Procedure MoveSLNToDTLs
8974 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8975 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8976 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
8977 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
8978
8979 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
8980 lnLine_Seq
8981
8982 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8983 LOCAL lcSQL ,loIPOtdn
8984 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8985
8986 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
8987
8988 llRetVal = true
8989 lnOldSelect = Select()
8990 lnDetailPrice = 0
8991
8992 *--- TR 1036614 8-Jun-2009 Goutam
8993 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
8994
8995*!* select t.Customer ;
8996*!* , t.FKey ;
8997*!* , t.PKey ;
8998*!* , c.price_flg ;
8999*!* from (pcTmpCursor) t ;
9000*!* join zzeipocr c ;
9001*!* on c.division = t.division ;
9002*!* and c.customer = t.customer ;
9003*!* join (pceipoTD) d ;
9004*!* on d.pkey = t.dtlPkey ;
9005*!* where c.slntodtl = 'Y' ;
9006*!* and d.slntodtl <> 'Y' ;
9007*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
9008*!* into Cursor __tmpipots ;
9009*!* order by t.fkey, t.Customer, t.PKey
9010
9011 *=== TR 1036614 8-Jun-2009 Goutam
9012
9013 *-- #1 Create detail record from pceipoTS
9014 SELECT __tmpipots
9015 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
9016 GO top
9017 lnSkipedPSFkey = 0
9018 lnPSFkey = 0
9019 lnCoor_Code = 1
9020 lnLine_Seq = 0
9021 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
9022
9023 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9024 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9025 ENDIF
9026 DO WHILE NOT EOF()
9027 lnPSFkey = Fkey
9028
9029 *--- TR 1049029 24-Aug-2010 Partha ---
9030 IF lnPSFkey <> lnSkipedPSFkey
9031 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
9032 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
9033 ENDIF
9034 *=== TR 1049029 24-Aug-2010 Partha ===
9035
9036 lnStartPkey = lnStartPkey + 1
9037 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9038 lnLine_Seq = lnLine_Seq + 1
9039 SELECT (pceipoTD)
9040 SCATTER NAME loIPOtd MEMO
9041 loIPOtd.pkey = lnStartPkey
9042 loIPOtd.Line_Seq = lnLine_Seq
9043
9044 *-FH 1077588 - detail's header pkey
9045 lnHfkey = fkey
9046
9047 *--- TechRec 1056973 06-Dec-2011 jisingh ---
9048 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
9049 *- 1060291 04/02/2012 YIK/FH
9050*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9051*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
9052 SELECT (pczzeiPOtWhse)
9053 lnDocNum = doc_num
9054 lnEdiLine = edi_line
9055 lnSlnLine = sln_line
9056
9057 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9058 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
9059 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
9060
9061 SELECT (pceipoTD)
9062 *= 1060291
9063 ENDIF
9064 *=== TechRec 1056973 06-Dec-2011 jisingh ===
9065
9066 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
9067*!* loIPOtd.slntodtl = 'Y'
9068
9069 *--- TR 1045922 05-MAR-2010 HNISAR
9070 *- 1060291 03/30/2012 YIK
9071 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
9072*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9073*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
9074 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9075 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
9076 *=== TechRec 1056973 09-Nov-2011 jisingh ===
9077 *=== TR 1045922 05-MAR-2010 HNISAR
9078
9079
9080
9081 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
9082 *--- TechRec 1063327 16-Aug-2012 jjanand ---
9083 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
9084*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
9085*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
9086*!* loIPOtd.assort_qty = loIPOtd.total_qty
9087*!* ENDIF
9088 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
9089*!* IF EMPTY(loIPOtd.Assortment)
9090*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9091*!* IF loIPOtd.assort_qty = 0
9092*!* loIPOtd.assort_qty = loIPOtd.total_qty
9093*!* ENDIF
9094*!* ENDIF
9095
9096 IF EMPTY(loIPOtd.Assortment)
9097 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9098 ENDIF
9099 IF EMPTY(loIPOtd.assort_qty)
9100 loIPOtd.assort_qty = loIPOtd.total_qty
9101 ENDIF
9102 *=== TechRec 1063327 16-Aug-2012 jjanand ===
9103 *- TR 1062810 FH
9104
9105 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
9106 loIPOtd.PO1_UPC = loIPOtd.UPC
9107 loIPOtd.PO1_SKU = loIPOtd.SKU
9108 loIPOtd.po1_price = loIPOtd.org_price
9109 loIPOtd.Division = &pceipoTS..Division
9110 loIPOtd.Style = &pceipoTS..Style
9111 loIPOtd.Color_code = &pceipoTS..Color_code
9112 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
9113 loIPOtd.Dimension = &pceipoTS..Dimension
9114 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
9115 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
9116 loIPOtd.UPC = &pceipoTS..SLN_UPC
9117 *- 03/19/09 1038539, 1039344 YIK
9118 loIPOtd.SKU = &pceipoTS..SLN_SKU
9119 *- TR 1051757 FH 04/19/11
9120 loIPOtd.aux_sku = &pceipoTS..aux_sku
9121
9122 *--- TechRec 1056973 07-Dec-2011 jisingh ---
9123 loIPOtd.sln01 = &pceipoTS..sln01
9124 *=== TechRec 1056973 07-Dec-2011 jisingh ===
9125
9126 *--- TR 1049029 30-Aug-2010 Partha ---
9127
9128*!* *--- TR 1047912 23-Jun-2010 Partha ---
9129*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
9130*!* *=== TR 1047912 23-Jun-2010 Partha ===
9131*!*
9132*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9133*!*
9134*!* *=== TR 1047912 23-Jun-2010 Partha ===
9135*!* ENDIF
9136*!* *=== TR 1047912 23-Jun-2010 Partha ===
9137*!*
9138*!* *--- TR 1047912 23-Jun-2010 Partha ---
9139*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
9140*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9141*!* ELSE
9142*!* lnDetailPrice = &pceipoTD..Org_Price
9143*!* ENDIF
9144*!* *=== TR 1047912 23-Jun-2010 Partha ===
9145
9146 DO CASE
9147 CASE loIPOtd.ppk_action = 'B'
9148 *- 02/18/11 1052584 YIK
9149 *- Moved calculation of ppk_qty here
9150 loIPOtd.ppk_qty = lnTotSLNQty
9151
9152 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9153
9154 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
9155 *loIPOtd.ppk_action = 'X'
9156 loIPOtd.ppk_action = 'S'
9157 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
9158 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9159 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9160 *- 02/18/11 YIK 1052584
9161 *- moved calculation of ppk_qty higher
9162 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9163
9164 *-TR 1094622 FH - need to update org_price
9165 loIPOtd.org_price = lnDetailPrice
9166
9167 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
9168 *- 02/18/11 YIK 1052584
9169 *- Moved calculation of ppk_qty here
9170 loIPOtd.ppk_qty = lnTotSLNQty
9171
9172 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9173
9174 IF loIPOtd.ppk_action = 'Q'
9175 loIPOtd.ppk_action = 'M'
9176 ENDIF
9177
9178 *- 02/18/11 YIK 1052584
9179 *- moved calculation of ppk_qty higher
9180 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9181
9182 lnDetailPrice = &pceipoTD..Org_Price
9183
9184 CASE loIPOtd.ppk_action = 'P'
9185 *-TR 1062018/1064343 FH - moved up
9186 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9187 *- TR 1062018/1064343 FH - moved up
9188 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9189 loIPOtd.ppk_action = 'D'
9190 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty && TR 1094622 FH - why is there a space here
9191 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9192 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9193
9194 *-TR 1094622 FH - need to update org_price
9195 loIPOtd.org_price = lnDetailPrice
9196
9197 OTHERWISE
9198 *-TR 1062018/1064343 FH - moved up
9199 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9200 *- TR 1062018/1064343 FH - moved up
9201 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9202 lnDetailPrice = &pceipoTD..Org_Price
9203 loIPOtd.ppk_qty = lnTotSLNQty
9204
9205 ENDCASE
9206 *=== TR 1049029 30-Aug-2010 Partha ===
9207
9208 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
9209 IF __tmpipots.price_flg = "E"
9210 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9211 ELSE
9212 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9213 ENDIF
9214
9215 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
9216 loIPOtd.Errs_flg_d = "N"
9217 loIPOtd.Errs_msg_d = ""
9218 *=== TR 1038353 NH
9219
9220 APPEND BLANK
9221 GATHER NAME loIPOtd MEMO
9222
9223 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9224
9225 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
9226 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
9227 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
9228
9229 &lcSQL
9230 SELECT _tmpipodnt
9231 SCAN
9232 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
9233 SELECT "Vzzeipotd_notes_iPOproc"
9234 SCATTER NAME loIPOtdn MEMO
9235
9236 APPEND BLANK
9237 loIPOtdn.Fkey = lnStartPkey
9238 loIPOtdn.Pkey = v_nextPkey("SysNotes")
9239
9240 GATHER NAME loIPOtdn MEMO
9241 ENDIF
9242
9243 ENDSCAN
9244 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
9245
9246 ENDIF && TR 1043037 OCT-06-2009 BR
9247 ENDIF
9248 SELECT __tmpipots
9249 SKIP IN __tmpipots
9250 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
9251
9252 *- TR 1062018/1064343 FH
9253 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9254 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9255 *- TR 1062018/1064343 FH
9256 DELETE IN (pceipoTD)
9257
9258 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9259
9260 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
9261 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
9262 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
9263
9264 ENDIF && TR 1043037 OCT-06-2009 BR
9265
9266 lnCoor_Code = lnCoor_Code + 1
9267 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9268 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9269 ENDIF
9270 lnLine_Seq = 0
9271 ENDIF
9272 ENDDO
9273 USE IN __tmpipots
9274
9275 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9276
9277 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9278 This.Tableupdate("Vzzeipotd_notes_iPOproc")
9279 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9280
9281 ENDIF && TR 1043037 OCT-06-2009 BR
9282
9283 SELECT (lnOldSelect)
9284 RETURN llRetVal
9285 ENDPROC
9286
9287*=======================================================================
9288
9289 *---- get total sln qty for a detail line
9290 FUNCTION getPriceFromIPOts
9291 LPARAMETERS pceipoTS, pnPrice
9292 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
9293 lnUnitPrice = 0
9294 IF pnPrice > 0
9295 lnOldSelect = SELECT()
9296
9297 SELECT (pceipoTS)
9298 lnFkey = Fkey
9299 lnSLNQty = SLN_Qty
9300 .PushRecordSet()
9301 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
9302 lnUnitPrice = pnPrice/lnSLNTotalQty
9303 .PopRecordSet()
9304
9305 SELECT (lnOldSelect)
9306 ENDIF
9307
9308 RETURN lnUnitPrice
9309 ENDFUNC
9310
9311 ************************************************************************************
9312 * Resolve BC SKU from SLN records and create customer style data.
9313 *--- This is splitted 1st part from function ResolveStyleFromSLN
9314 ************************************************************************************
9315 Procedure ResolveBCSkuFromSLN
9316 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9317 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9318 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
9319 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9320 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
9321 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
9322
9323 lnOldSelect = Select()
9324 llRetVal = .T. && 1040686
9325 *--- TR 1036614 3-Mar-2010 Goutam
9326 lcErrs_Msg = ""
9327 lcDivision = ""
9328 *=== TR 1036614 3-Mar-2010 Goutam
9329
9330 *-- #1 Resolve SLN SKUs
9331 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
9332 *- 03/19/09 TR ? Retrofit TR1038539 YIK
9333 *- added SLN_SKU
9334 *- Removed WHERE ...and !Empty(s.SLN_UPC)
9335
9336 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
9337 * Added , s.sln_qty
9338 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
9339
9340 select h.Customer;
9341 , s.FKey;
9342 , s.SLN_UPC as UPC;
9343 , s.SLN_SKU as SKU ;
9344 , h.department ;
9345 , h.store ;
9346 , s.PKey;
9347 , .F. as SLN_Error;
9348 , Empty(d.SizeBucket) as Unresolved;
9349 , s.Division;
9350 , s.Style;
9351 , s.Color_Code;
9352 , s.SizeBucket;
9353 , d.Pkey as dtlPkey;
9354 , 'N' as IsPPK;
9355 , SPACE(5) as ppk_code;
9356 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9357 , s.sln_qty ;
9358 from (pceipoTH) h;
9359 join (pceipoTD) d ;
9360 on d.FKey = h.PKey;
9361 join (pceipoTS) s ;
9362 on s.FKey = d.PKey ;
9363 where !Empty(h.Customer) ;
9364 order by 1, 2;
9365 into Cursor tmpCurs ReadWrite
9366
9367* , s.Lbl_Code;
9368* , s.Dimension;
9369
9370*- 1040686
9371
9372 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9373 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9374 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9375 IF llRetVal
9376 .PopulateSQLTempTable("tcCustUpc")
9377 ENDIF
9378
9379 llRetVal = llRetVal AND v_sqlexec(;
9380 "SELECT x.upc,d.* "+;
9381 " FROM zzxcstdr d"+ ;
9382 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9383 " JOIN " + this.cSQLTempTable + " x " + ;
9384 " ON d.customer = x.customer " +;
9385 " AND d.cust_style = x.upc " + ;
9386 " WHERE h.IB_resolv = 'Y'" + ;
9387 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9388 SELECT tmpCstdr_upc
9389 INDEX on customer + upc TAG cust_upc
9390
9391
9392 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9393 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9394 IF llRetVal
9395 .PopulateSQLTempTable("tcDistUpc")
9396 ENDIF
9397
9398 llRetVal = llRetVal AND v_sqlexec(;
9399 "SELECT x.upc,d.* "+;
9400 " FROM zzeupcnr d"+ ;
9401 " JOIN " + this.cSQLTempTable + " x " + ;
9402 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9403 SELECT tmpUpcnr
9404 INDEX on upc TAG upc
9405
9406
9407 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9408 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9409 IF llRetVal
9410 .PopulateSQLTempTable("tcDistCustSku")
9411 ENDIF
9412 llRetVal = llRetVal AND v_sqlexec(;
9413 "SELECT x.sku,d.* "+;
9414 " FROM zzxcstdr d"+ ;
9415 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9416 " JOIN " + this.cSQLTempTable + " x " + ;
9417 " ON d.customer = x.customer " +;
9418 " AND d.cust_style = x.sku " + ;
9419 " WHERE h.IB_resolv = 'Y'" + ;
9420 " AND d.Size_Desc>'' " + ;
9421 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9422 SELECT tmpCstdr_sku
9423 INDEX ON customer + cust_style TAG cust_sku
9424
9425 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9426 UNION ;
9427 SELECT customer,sku FROM tmpCstdr_sku ;
9428 GROUP BY customer,sku ;
9429 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9430 INDEX ON customer+sku TAG cust_sku
9431 *=-===-=-=-=-=-=-=-
9432
9433*- 1040686
9434
9435 Select tmpCurs
9436 If This.lUserInterface
9437 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9438 This.InitThermo(RecCount())
9439 EndIf
9440
9441 lcOldCust = ""
9442 lcOldUPC = ""
9443 *- 03/19/09 1038539 YIK
9444 lcOldItem = ''
9445 Local lcSku_resolv, lcOldSku_resolv
9446 lcSku_resolv = ""
9447 *=
9448
9449 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9450 If This.lUserInterface
9451 * Advance progress bar, if we're using one.
9452 This.AdvanceThermo(RecNo())
9453 EndIf
9454 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9455 IF !EMPTY(tmpCurs.UPC)
9456
9457 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9458 lcErrs_Msg = ""
9459 lcOldCust = tmpCurs.Customer
9460 lcOldUPC = tmpCurs.UPC
9461
9462 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9463 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9464*- 1040686
9465*!* lcDivision = tmpCstdr.division
9466*!* lcStyle = tmpCstdr.Style
9467*!* lcColor_Code = tmpCstdr.Color_Code
9468*!* lcLbl_Code = tmpCstdr.Lbl_Code
9469*!* lcDimension = tmpCstdr.Dimension
9470*!* lnSizeBucket = tmpCstdr.Size_Bk
9471*!* lnSize_Desc = tmpCstdr.Size_Desc
9472 lcDivision = tmpCstdr_upc.division
9473 lcStyle = tmpCstdr_upc.Style
9474 lcColor_Code = tmpCstdr_upc.Color_Code
9475 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9476 lcDimension = tmpCstdr_upc.Dimension
9477 lnSizeBucket = tmpCstdr_upc.Size_Bk
9478 lnSize_Desc = tmpCstdr_upc.Size_Desc
9479*- 1040686
9480 Else
9481 lcErrs_Msg = ""
9482 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9483 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9484 lcDivision = tmpUpcnr.Division
9485 lcStyle = tmpUpcnr.Style
9486 lcColor_Code = tmpUpcnr.Color_Code
9487 lcLbl_Code = tmpUpcnr.Lbl_Code
9488 lcDimension = tmpUpcnr.Dimension
9489 lnSizeBucket = tmpUpcnr.SizeBucket
9490 lnSize_Desc = tmpUpcnr.Size_Desc
9491 ELSE
9492 *-&&1040686
9493 *lcErrs_Msg = lcErrs_Msg + CRLF
9494 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9495 *-&&1040686
9496 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9497 lnSizeBucket = 0
9498 Endif
9499 Endif
9500 Endif && level break
9501 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9502 *- Added resolution on SKU
9503 ENDIF && TmpCurs.UPC
9504 *- 03/17/09 TR 1038539 YIK
9505 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9506 *- but UPC resolution failed.
9507 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9508 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9509
9510 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9511 lcErrs_Msg = ""
9512 lcOldCust = tmpCurs.customer
9513 lcOldItem = tmpCurs.sku
9514
9515 *- 1040686
9516 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9517 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9518 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9519 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9520 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9521 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9522 Store 0 To lnSizeBucket
9523 ELSE
9524 *- TR 1074276 FH - adding UPPER()
9525 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9526 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9527 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9528 Store 0 To lnSizeBucket
9529 ELSE
9530*!* lcDivision = tmpCstdr.division
9531*!* lcStyle = tmpCstdr.Style
9532*!* lcColor_code = tmpCstdr.color_code
9533*!* lcLbl_code = tmpCstdr.lbl_code
9534*!* lcDimension = tmpCstdr.Dimension
9535*!* lnSizeBucket = tmpCstdr.size_bk
9536*!* lnSize_desc = tmpCstdr.size_desc
9537 lcDivision = tmpCstdr_sku.division
9538 lcStyle = tmpCstdr_sku.Style
9539 lcColor_code = tmpCstdr_sku.color_code
9540 lcLbl_code = tmpCstdr_sku.lbl_code
9541 lcDimension = tmpCstdr_sku.Dimension
9542 lnSizeBucket = tmpCstdr_sku.size_bk
9543 lnSize_desc = tmpCstdr_sku.size_desc
9544 ENDIF
9545 ENDIF
9546 *- 1040686
9547 ENDIF
9548 ENDIF
9549 *== 1038539 Resolution on SKU
9550
9551 Select (pceipoTS)
9552 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9553
9554 Scatter Name loEiPOTS Memo
9555 If !Empty(lcErrs_Msg)
9556 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9557 loEiPOTS.Errs_Flg_S = "Y"
9558 replace Sln_Error with .T. in tmpCurs
9559 Else
9560 replace Division with lcDivision in tmpCurs
9561 Endif
9562
9563 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9564 loEiPOTS.Division = lcDivision
9565 loEiPOTS.Style = lcStyle
9566 loEiPOTS.Color_Code = lcColor_code
9567 loEiPOTS.Lbl_Code = lcLbl_code
9568 loEiPOTS.Dimension = lcDimension
9569 loEiPOTS.SizeBucket = lnSizeBucket
9570 loEiPOTS.Size_Desc = lnSize_Desc
9571 Endif
9572
9573 Gather Name loEiPOTS Memo
9574
9575 EndScan
9576
9577*- 1060291 07/02/12 YIK
9578*- The code below makes no sense. It takes the first prepack found for the SLN.
9579*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9580 *--- TR 1036614 17-Mar-2010 Goutam
9581*-- SELECT tmpCurs
9582*-- SCAN FOR IsPPK = 'N'
9583*-- Select (pceipoTS)
9584*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9585*-- Scatter Name loEiPOTS Memo
9586*--
9587*-- IF NOT EMPTY(loEiPOTS.Dimension)
9588*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9589*-- IF !EMPTY(lcppk_code)
9590*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9591*-- ENDIF
9592*-- ENDIF
9593*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9594*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9595*-- IF tmpCurs.IsPPK = 'N' AND loEiPOTS.Errs_Flg_S != 'Y' AND vl_scolr(loEiPOTS.Division,,'__tmpDimCurs' ,loEiPOTS.Style, loEiPOTS.Color_Code, loEiPOTS.Lbl_Code) AND USED('__tmpDimCurs')
9596*-- SELECT __tmpDimCurs
9597*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9598*-- lcppk_code = dimension
9599*-- USE IN SELECT('__tmpDimCurs')
9600*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9601*-- IF !EMPTY(lcppk_code) AND vl_ppakd(loEiPOTS.Division,,'__tmpDimCurs', vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), lcppk_code, loEiPOTS.Color_Code, loEiPOTS.Lbl_Code, loEiPOTS.Dimension)
9602*-- SELECT __tmpDimCurs
9603*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9604*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9605*-- ENDIF
9606*-- USE IN SELECT('__tmpDimCurs')
9607*-- ENDIF
9608*-- ENDIF
9609*-- ENDSCAN
9610 *--- TR 1036614 17-Mar-2010 Goutam
9611
9612 *--- TR 1038353 NH - error out dtl line for SLN error
9613 UPDATE td SET Style_SLN_OK = 'N' ;
9614 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9615 WHERE ts.errs_flg_s ='Y'
9616 *=== TR 1038353 NH
9617
9618 If This.lUserInterface
9619 * Reset Thermometer
9620 This.ResetThermo()
9621 EndIf
9622
9623 *--- TR 1036614 8-Jun-2009 Goutam
9624 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9625 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9626
9627 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9628 lnSelect = SELECT()
9629
9630 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9631 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9632
9633 Select tmpErrSlnLines
9634 Scan
9635 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9636 Endscan
9637
9638 This.TableClose("tmpErrSlnLines")
9639
9640 Select (lnSelect )
9641 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9642
9643 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9644 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9645 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9646 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9647 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9648 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9649 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9650 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9651
9652 This.TableClose("tmpCurs")
9653
9654 *=== TR 1036614 8-Jun-2009 Goutam
9655
9656 *-1040686
9657 USE IN SELECT("tcCustUpc")
9658 USE IN SELECT("tmpCstdr_upc")
9659 USE IN SELECT("tcDistUpc")
9660 USE IN SELECT("tmpUpcnr")
9661 USE IN SELECT("tcDistCustSku")
9662 USE IN SELECT("tmpCstdr_sku")
9663 USE IN SELECT("tcAmbigSku")
9664 *-1040686
9665
9666 Select(lnOldSelect)
9667 Return llRetVal
9668 Endproc
9669
9670
9671 *--------------------------------------------
9672 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9673 *--------------------------------------------
9674 Procedure GetImplodeSQL
9675 *-- Populates cImplodeSQL
9676 SET TextMerge OFF NoShow
9677*-- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9678*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9679 Text to this.cImplodeSQL flags 1
9680declare @Division char(3), @Style varChar(50), @Customer char(7),
9681 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9682
9683set @Customer = ?cCustomer
9684set @Division = ?cDivision
9685set @Style = ?cStyle
9686
9687-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9688select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9689 from zzeipocr_expl
9690 where Customer = @Customer
9691 and Division = @Division
9692
9693select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9694
9695--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9696
9697-- Output Values:
9698--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9699declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9700
9701-- first SQL:
9702if @CR_Lbl > ''
9703select top 1 @Color_Code = c.Color_Code
9704 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9705 , @Dimension = c.Dimension
9706 , @Size = Min(z.Size01)
9707-- , c.Lbl_Code as SColR_Lbl
9708 from zzxSColR c
9709 join zzxStylR st
9710 on st.PKey = c.FKey
9711 join zzxPPakH ph
9712 on ph.Division = c.Division
9713 and ph.Size_Code = st.Size_Code
9714 and ph.Ppk_Code = c.Dimension
9715 and c.Color_Code = case
9716 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9717 else c.Color_Code end
9718 join zzxPPakD pd
9719 on pd.FKey = ph.PKey
9720 join zzxSizer z
9721 on z.Division = c.Division
9722 and z.Size_Code = st.Size_Code
9723 cross join zzxBuckt b
9724 left join #ImplodeSLN i
9725 on i.Color_Code = case
9726 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9727 else pd.Color_Code end
9728 and (i.Lbl_Code = case
9729 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9730 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9731 and i.Dimension = pd.Dimension
9732 and i.SizeBucket = b.Size_Num
9733 where c.Style = @Style
9734 and c.Division = @Division
9735 and c.PPack_OK = 'Y'
9736 and c.Active_OK = 'Y'
9737 and ph.Active_OK = 'Y'
9738 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9739 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9740 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9741 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9742 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9743 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9744 and (c.Lbl_Code = case
9745 when @SLN_Lbl > ''
9746 then @SLN_Lbl
9747 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9748 group by c.PKey, ph.Pack_qty
9749 , c.Color_code, c.Lbl_Code, c.Dimension
9750having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9751 and sum(i.Qty) = ph.Pack_qty
9752 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9753 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9754
9755IF @CR_Lbl > '' and @@ROWCOUNT > 0
9756 select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9757ELSE BEGIN
9758
9759select top 1 @Color_Code = c.Color_Code
9760 , @Lbl_Code = c.Lbl_Code
9761 , @Dimension = c.Dimension
9762 , @Size = Min(z.Size01)
9763 from zzxSColR c
9764 join zzxStylR st
9765 on st.PKey = c.FKey
9766 join zzxPPakH ph
9767 on ph.Division = c.Division
9768 and ph.Size_Code = st.Size_Code
9769 and ph.Ppk_Code = c.Dimension
9770 and c.Color_Code = case
9771 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9772 else c.Color_Code end
9773 join zzxPPakD pd
9774 on pd.FKey = ph.PKey
9775 join zzxSizer z
9776 on z.Division = c.Division
9777 and z.Size_Code = st.Size_Code
9778 cross join zzxBuckt b
9779 left join #ImplodeSLN i
9780 on i.Color_Code = case
9781 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9782 else pd.Color_Code end
9783 and (i.Lbl_Code = case
9784 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9785 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9786 and i.Dimension = pd.Dimension
9787 and i.SizeBucket = b.Size_Num
9788 where c.Style = @Style
9789 and c.Division = @Division
9790 and c.PPack_OK = 'Y'
9791 and c.Active_OK = 'Y'
9792 and ph.Active_OK = 'Y'
9793 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9794 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9795 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9796 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9797 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9798 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9799 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9800 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9801 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9802 group by c.PKey, ph.Pack_qty
9803 , c.Color_code, c.Lbl_Code, c.Dimension
9804having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9805 and sum(i.Qty) = ph.Pack_qty
9806 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9807 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9808 , c.Lbl_code -- blank one goes first if there is no match
9809
9810select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9811 where @Color_Code is not null
9812END
9813EndText
9814
9815*--- TechRec 1073664 20-Sep-2013 GSternik ---
9816 Text to this.cImplodeRangeSQL flags 1
9817declare @Division char(3)
9818set @Division = ?cDivision
9819
9820-- Output Values:
9821declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9822
9823select @Style = rh.Rng_Style
9824 , @Color_Code = rh.Rng_Color
9825 , @Lbl_Code = rh.Rng_Lbl
9826 , @Dimension = rh.Rng_Pack
9827 , @SizeBucket = rng_bk
9828 from zzxRangH rh with (NoLock)
9829 join zzxRangD rd with (NoLock)
9830 on rd.FKey = rh.PKey
9831 --join zzxSColR c
9832 -- on c.Division = rh.Division
9833 -- and c.Style = rh.Rng_Style
9834 -- and c.Color_Code = rh.Rng_Color
9835 -- and c.Lbl_Code = rh.Rng_Lbl
9836 -- and c.Dimension = rh.Rng_Pack
9837 join zzxBuckt b with (NoLock)
9838 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9839 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9840 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9841 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9842 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9843 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
9844 left join #ImplodeSLN i
9845 on i.Style = rd.Style
9846 and i.Color_Code = rd.Color_Code
9847 and i.Lbl_Code = rd.Lbl_Code
9848 and i.Dimension = rd.Dimension
9849 and i.SizeBucket = b.Size_Num
9850 and i.Division = rd.Division
9851 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9852 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9853 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9854 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9855 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9856 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
9857 where rh.Rng_Type = 'P'
9858 and rh.Division = @Division
9859-- and c.Active_OK = 'Y'
9860 group by rh.Rng_Style
9861 , rh.Rng_Color
9862 , rh.Rng_Lbl
9863 , rh.Rng_Pack
9864 , rng_bk
9865having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9866 and sum(i.Qty) = Max(rh.Rng_Qty)
9867
9868if @Style is not null -- @@RowCount > 0
9869select @Size = case @SizeBucket
9870 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
9871 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
9872 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
9873 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
9874 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
9875 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
9876 from zzxStylR s with (NoLock)
9877 join zzxSizeR z with (NoLock)
9878 on z.Division = s.Division
9879 and z.Size_Code = s.Size_Code
9880 where s.Division = @Division
9881 and s.Style = @Style
9882
9883select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
9884 where @Style is not null
9885EndText
9886*=== TechRec 1073664 20-Sep-2013 GSternik ===
9887
9888 EndProc
9889
9890 *---------------------------------
9891 *--- This function will generate PPK SKU and updates detail with it.
9892 *--- This is splitted 2nd part from function ResolveStyleFromSLN
9893 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
9894 *---------------------------------
9895 Procedure ResolvePPKSkuAndUpdateDetail
9896 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
9897 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9898 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9899 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
9900 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
9901 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
9902
9903 llRetVal = .T.
9904 lnOldSelect = Select()
9905
9906 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
9907 Dimension laBuckets(goEnv.MaxBuckets)
9908
9909 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
9910 Select tmpCurs
9911 lnFKey = 0
9912
9913 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
9914
9915 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
9916 Scan
9917 If FKey # lnFKey
9918 lnFKey = FKey
9919
9920 If SLN_Error or !Unresolved
9921 llDeleteSLN = .T.
9922 Else
9923 llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
9924
9925 If !llDeleteSLN
9926 Select (pceipoCR)
9927 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
9928
9929 *--- TR 1036614 10-Jun-2009 Goutam
9930 *llDeleteSLN = StyleFromSLN < "Y"
9931 llDeleteSLN = StyleFromSLN < "O"
9932 *=== TR 1036614 10-Jun-2009 Goutam
9933
9934 Select tmpCurs
9935 EndIf
9936 EndIf
9937
9938 If !llDeleteSLN
9939 lnRecNo = RecNo()
9940
9941 Scan while FKey = lnFKey
9942 If SLN_Error
9943 *-- One SLN with error exists.
9944 llDeleteSLN = .T.
9945 Exit
9946 EndIf
9947 EndScan
9948
9949 Go lnRecNo
9950 EndIf
9951 EndIf
9952
9953 If llDeleteSLN
9954 Delete
9955 EndIf
9956 EndScan
9957
9958
9959 *-- #3 -- Updating Details with PPK BC SKU:
9960 lcOldCust = ""
9961 lcOldSKU = ""
9962 lnFKey = 0
9963 lnRecNo = This.CountTotalRecs('tmpCurs')
9964
9965 If lnRecNo > 0
9966 *-- Need for optimization:
9967
9968 If This.lUserInterface
9969 This.UpdateThermoCaption("Resolving Style From SLN...")
9970 This.InitThermo(lnRecNo + 1)
9971 lnRecNo = 1
9972 Endif
9973 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
9974
9975 *- 1041704 07/30/09 YIK
9976 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9977 *-- Let's rely on the field types in the UPC table:
9978 *v_SQLExec("create table #ImplodeSLN " + ;
9979 * "( Division, Style 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)
9980 * " Size_Desc Char(10), Qty Int, PKey Int)")
9981 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
9982 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
9983 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9984
9985 Select (pceipoTD)
9986 lcOldOrder = Order()
9987
9988 *- 03/23/09 YIK
9989 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
9990 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
9991 Index on Customer+SKU+UPC+Assortment tag CustSKU
9992 lcOldUPC = ''
9993 *==
9994
9995 If This.lUserInterface
9996 This.AdvanceThermo(lnRecNo)
9997 EndIf
9998
9999 Select tmpCurs
10000 Locate
10001 cCustomer = Customer
10002
10003 Do while .T. && Scan replacement
10004 if FKey # lnFKey && Will trigger @ EOF :o)
10005 If llProcess
10006 If llImplodeOK
10007 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
10008
10009 *--- TechRec 1073664 20-Sep-2013 GSternik ---
10010 *-- Let's check if they belong to the Range Style 'P'
10011 If Reccount("qPPK") = 0 && Prepack not found
10012 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
10013 EndIf
10014 *=== TechRec 1073664 20-Sep-2013 GSternik ===
10015
10016 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
10017 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
10018 Select (pceipoTS)
10019 *- insert into #implodeSLN
10020 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
10021 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
10022 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
10023 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
10024 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
10025 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10026 Endif
10027 EndIf && llImplodeOK
10028 *========= 1041704 07/30/09 YIK
10029
10030 select (pceipoTD)
10031 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
10032 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
10033 lcOldCust = Customer
10034 lcOldSKU = SKU
10035
10036 *- 03/23/09 YIK
10037 *-- Update all records with the same CustSKU
10038 *- =Seek(lcOldCust+lcOldSKU) && First matching record
10039 lcOldUPC = UPC
10040 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
10041
10042 *==
10043 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
10044 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10045 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
10046 replace Division with cDivision, ;
10047 Style with qPPK.Style, ;
10048 Color_Code with qPPK.Color_Code, ;
10049 Lbl_Code with qPPK.Lbl_Code, ;
10050 Dimension with qPPK.Dimension,;
10051 SizeBucket with qPPK.SizeBucket;
10052 Size_Desc with qPPk.Size01;
10053 Style_SLN_OK with 'Y' ;
10054 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10055 Else
10056
10057 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
10058 *--- TR 1036614 12-Jun-2009 Goutam
10059 IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
10060 *=== TR 1036614 12-Jun-2009 Goutam
10061 *--- TR 1056329 02-Nov-11 SK
10062 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10063 replace Style_SLN_OK with 'N' ;
10064 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10065 *--- TR 1036614 12-Jun-2009 Goutam
10066 ENDIF
10067 *=== TR 1036614 12-Jun-2009 Goutam
10068
10069 ENDIF
10070 Else && llProcess flag is not set
10071 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
10072 Select (pceipoTS)
10073 *- insert into #implodeSLN
10074 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10075 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
10076 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
10077 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
10078 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
10079 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
10080 *=== 1041704
10081 EndIf
10082 EndIf && Process Detail
10083
10084 Select tmpCurs
10085 if Eof()
10086 Exit
10087 EndIf
10088
10089 lnFKey = FKey
10090 cCustomer = Customer
10091 Select (pceipoTD)
10092 =Seek(lnFKey, pceipoTD, "PKey")
10093
10094 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
10095
10096 llImplodeOK = llProcess
10097
10098 If llImplodeOK
10099 store 0 to laBuckets
10100 lnPackTotal = 0
10101
10102 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
10103 Select (pceipoTS)
10104 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
10105
10106 cDivision = Division
10107 cStyle = Style
10108 lcColor_Code = Color_Code
10109 lcLbl_Code = Lbl_Code
10110 lcDimension = Dimension
10111 EndIf
10112
10113 Else && The same FKey
10114 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
10115 Select (pceipoTS)
10116 if Division # cDivision;
10117 or Style # cStyle
10118 *- 1041704 YIK 07/29/09
10119 *- Allow multicolor prepacks
10120 *-- or Color_Code # lcColor_Code;
10121 *-- or Lbl_Code # lcLbl_Code;
10122 *-- or Dimension # lcDimension
10123
10124 llImplodeOK = .F.
10125 ELSE
10126 *- insert into #implodeSLN
10127 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10128 v_SQLExec("insert into #ImplodeSLN values ('"+;
10129 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
10130 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
10131 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10132 *=== 1041704
10133 EndIf
10134 EndIf
10135 EndIf && FKey Changed
10136
10137 if llImplodeOK
10138 *-- (pceipoTS) is selected!
10139 laBuckets[SizeBucket] = Sln_Qty
10140 lnPackTotal = lnPackTotal + Sln_Qty
10141 EndIf
10142
10143 Select tmpCurs
10144 Skip
10145
10146 If This.lUserInterface
10147 lnRecNo = lnRecNo + 1
10148 This.AdvanceThermo(lnRecNo)
10149 Endif
10150 EndDo && Endscan
10151
10152 Select (pceipoTD)
10153 Set Order to (lcOldOrder)
10154 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
10155 *v_SQLExec("DROP table #ImplodeSLN ")
10156 EndIf && Have data to Implode
10157
10158 *--- TR 1036614 11-Jun-2009 Goutam
10159 *Use In tmpCurs
10160 *=== TR 1036614 11-Jun-2009 Goutam
10161
10162 If This.lUserInterface
10163 * Reset Thermometer
10164 This.ResetThermo()
10165 Endif
10166
10167 Select(lnOldSelect)
10168 Return llRetVal
10169 Endproc
10170 *=== TR 1035491 4-Nov-2008 Goutam
10171
10172*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
10173*!*
10174* TR 1037925 - As per Krishna/Shenba
10175* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
10176* This is getting moved in TR 1037925
10177
10178*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
10179*!* *===========================================================================================
10180*!* Function ResolveCustShipper
10181*!* Lparameters pceipoTH, pceipoCR
10182*!* LOCAL lnSelect, llRetVal
10183
10184*!* lnSelect = SELECT()
10185
10186*!* WITH This
10187*!*
10188*!* SELECT distinct h.customer, h.division, ;
10189*!* h.cust_shipper ;
10190*!* FROM (pceipoTH) h, (pceipoCR) r ;
10191*!* WHERE r.resv_cust_ship = 'Y' and ;
10192*!* h.customer = r.customer and ;
10193*!* h.division = r.division ;
10194*!* INTO CURSOR '_tmpCustShipper'
10195*!*
10196*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10197*!*
10198*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10199*!*
10200*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
10201*!* REPLACE ALL shipper WITH '' In (pceipoTH)
10202*!* SET RELATION TO
10203*!* ENDIF
10204*!*
10205*!* SELECT '_tmpCustShipper'
10206
10207*!* .cSQLTempTable = ""
10208*!*
10209*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10210*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10211*!* IF !EMPTY(.cSQLTempTable)
10212*!*
10213*!* *---- Matching with customer, cust_shipper, division
10214*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10215*!* "s.shipper " + ;
10216*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10217*!* "Where s.customer = t.customer and " + ;
10218*!* "s.division = t.division and " + ;
10219*!* "s.cust_shipper = t.cust_shipper "
10220*!*
10221*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10222*!*
10223*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10224*!* SELECT _custShipper
10225*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10226*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10227*!* IF llRetVal
10228*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10229*!* SET RELATION TO
10230*!* ENDIF
10231*!* ENDIF
10232*!* ENDIF
10233*!* ENDIF
10234*!* ENDIF
10235*!*
10236*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10237*!* FROM (pceipoTH) h, (pceipoCR) r ;
10238*!* WHERE r.resv_cust_ship = 'Y' and ;
10239*!* h.customer = r.customer and ;
10240*!* h.division = r.division and ;
10241*!* EMPTY(h.shipper) ;
10242*!* INTO CURSOR '_tmpCustShipper'
10243*!*
10244*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10245*!*
10246*!* SELECT '_tmpCustShipper'
10247
10248*!* .cSQLTempTable = ""
10249*!*
10250*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10251*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10252*!* IF !EMPTY(.cSQLTempTable)
10253*!*
10254*!* *---- Matching with customer, cust shipper, and division = ''
10255*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10256*!* "s.shipper " + ;
10257*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10258*!* "Where s.customer = t.customer and " + ;
10259*!* "s.division = '' and " + ;
10260*!* "s.cust_shipper = t.cust_shipper "
10261*!*
10262*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10263*!*
10264*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10265*!* SELECT _custShipper
10266*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10267*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10268*!*
10269*!* IF llRetVal
10270*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10271*!* SET RELATION TO
10272*!* ENDIF
10273*!*
10274*!* ENDIF
10275*!* ENDIF
10276*!* ENDIF
10277*!* ENDIF
10278
10279*!* USE in '_tmpCustShipper'
10280*!*
10281*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10282*!* FROM (pceipoTH) h, (pceipoCR) r ;
10283*!* WHERE r.resv_cust_ship = 'Y' and ;
10284*!* h.customer = r.customer and ;
10285*!* h.division = r.division and ;
10286*!* EMPTY(h.shipper) ;
10287*!* INTO CURSOR '_tmpCustShipper'
10288*!*
10289*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10290*!*
10291*!* IF RECCOUNT('_tmpCustShipper') > 0
10292*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10293*!*
10294*!* IF llRetVal
10295*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
10296*!* Errs_flg_h WITH "Y" ;
10297*!* FOR customer = _tmpCustShipper.customer and ;
10298*!* division = _tmpCustShipper.division and ;
10299*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
10300*!*
10301*!* SET RELATION TO
10302*!* ENDIF
10303*!*
10304*!* ENDIF
10305*!*
10306*!* ENDWITH
10307*!*
10308*!* USE in '_tmpCustShipper'
10309*!* USE in '_custShipper'
10310*!* SELECT(lnSelect)
10311*!*
10312*!* RETURN llRetVal
10313*!* ENDFUNC
10314*!* *===========================================================================================
10315*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
10316*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
10317
10318*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
10319*============================================================
10320 FUNCTION CalculateSLNs
10321 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10322 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10323 lnTotal_qty
10324
10325 llRetVal = true
10326 lnSelect = SELECT()
10327
10328 lcCursor = GetUniqueFileName()
10329 WITH This
10330
10331 *--- TR 1047450 28-May-2010 Partha ---
10332 * removed c.Template = 'GAP'
10333 * from where clause of following qry
10334
10335*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10336*!* " FROM (pceipoTD) d " + ;
10337*!* " JOIN (pceipoTH) H " + ;
10338*!* " ON H.pkey = d.fkey " + ;
10339*!* " JOIN (pceipoCR) C " + ;
10340*!* " ON D.division = C.Division " + ;
10341*!* " AND H.Customer = C.Customer " + ;
10342*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
10343
10344 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10345 " FROM (pceipoTD) d " + ;
10346 " JOIN (pceipoTH) H " + ;
10347 " ON H.pkey = d.fkey " + ;
10348 " JOIN (pceipoCR) C " + ;
10349 " ON D.division = C.Division " + ;
10350 " AND H.Customer = C.Customer " + ;
10351 " WHERE NOT (d.Gap_ok = 'Y') "
10352 *=== TR 1047450 28-May-2010 Partha ===
10353
10354 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10355
10356 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10357 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10358 lcDeatil = .cSQLTempTable
10359
10360 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10361 " FROM " + lcDeatil + " t " + ;
10362 " JOIN zzxscolr s " + ;
10363 " ON s.division= t.division and " +;
10364 " s.style= t.style and s.color_code= t.color_code and " +;
10365 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10366 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10367 " LEFT OUTER JOIN zzxppakh ph " + ;
10368 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10369 " s.dimension= ph.ppk_code " + ;
10370 " Where s.ppack_ok= 'Y' "
10371
10372 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10373
10374 IF llRetVal
10375 *--- TR 1038394 YIK 01/29/09
10376 *- Select(lcCursor)
10377 *--INDEX on Pkey TAG Pkey
10378 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10379 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10380
10381 lnPrePack = 0
10382 SELECT(lcCursor)
10383 SCAN
10384 lnPkey = Pkey
10385 lnpack_qty = pack_qty
10386
10387 lnTotal_qty = &pceipoTD..Total_qty
10388
10389 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10390 lcErrs_Msg = " Can not Calculate number of prepacks. "
10391
10392 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10393 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10394 Errs_Flg_D With "Y" ;
10395 IN (pceipoTD)
10396 LOOP
10397 ELSE
10398 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10399 IF lnpack_qty >0
10400 lnTotal_qty = lnTotal_qty /lnpack_qty
10401 ENDIF
10402 ENDIF
10403 Endif
10404
10405 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10406 lnPrePack = (lnTotal_qty/lnpack_qty)
10407 SELECT(pceipoTS)
10408 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10409
10410 IF lnSlnqty >0
10411 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10412 SELECT(pceipoTS)
10413 SCAN FOR Fkey = lnPkey
10414 IF MOD(sln_qty,lnPrePack) >0
10415 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10416 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10417 Errs_Flg_S With "Y"
10418 ENDIF
10419 ENDSCAN
10420 LOOP
10421 ELSE
10422 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10423*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10424 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10425 ENDIF
10426
10427 ENDIF
10428 ENDSCAN
10429
10430 ENDIF
10431 ENDIF
10432 .TableClose(lcCursor)
10433 ENDWITH
10434
10435 SELECT (lnSelect)
10436 RETURN llRetVal
10437 ENDFUNC
10438*============================================================
10439
10440*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10441
10442
10443*--- TR 1036917 04-Feb-2009 Partha ---
10444
10445*============================================================
10446 FUNCTION ChangeColor
10447 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10448 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10449 lnTotal_qty
10450
10451 llRetVal = true
10452 lnSelect = SELECT()
10453
10454 WITH This
10455 *--- TR 1039262 NSD - Use current system date, not PO date.
10456 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10457 If This.oHostProcess.lHaveSLN
10458 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ; && 1049552 Removed extra comma.
10459 " 'D' AS Source " + ;
10460 " FROM (pceipoTD) d " + ;
10461 " JOIN (pceipoTH) H " + ;
10462 " ON H.pkey = d.fkey " + ;
10463 " WHERE d.Errs_flg_d <> 'Y' " + ;
10464 " AND d.org_color = ' ' " +;
10465 " UNION ALL " + ;
10466 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10467 " 'S' AS Source " + ;
10468 " FROM (pceipoTD) d " + ;
10469 " JOIN (pceipoTH) H " + ;
10470 " ON H.pkey = d.fkey " + ;
10471 " JOIN (pceipoTS) S " + ;
10472 " ON D.pkey = s.fkey " + ;
10473 " WHERE s.Errs_flg_s <> 'Y' " + ;
10474 " AND s.org_color = ' ' "
10475 ELSE
10476 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10477 " 'D' AS Source " + ;
10478 " FROM (pceipoTD) d " + ;
10479 " JOIN (pceipoTH) H " + ;
10480 " ON H.pkey = d.fkey " + ;
10481 " WHERE d.Errs_flg_d <> 'Y' " + ;
10482 " AND d.org_color = ' ' "
10483 ENDIF
10484
10485 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10486
10487 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10488 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10489 lcDeatil = .cSQLTempTable
10490 *--- TechRec 1049044 21-Sep-2010 jjanand --- Changing h.lbl_code = t.cust_lbl to (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END)
10491 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10492 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10493 " FROM " + lcDeatil + " t " + ;
10494 " JOIN zzxrupch h " + ;
10495 " ON h.division= t.division " + ;
10496 " and h.style= t.style " + ;
10497 " and h.color_code= t.color_code " + ;
10498 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10499 " and h.dimension = t.dimension " + ;
10500 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10501 " WHERE h.active_ok = 'Y' " + ;
10502 " AND d.active_color = 'Y' " + ;
10503 " AND d.effect_Date = " + ;
10504 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10505 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10506 " ORDER BY d1.effect_date DESC ) "
10507
10508 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10509
10510 IF llRetVal
10511 Select("__RollingUpc")
10512 INDEX on Pkey TAG Pkey
10513 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10514
10515 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10516 org_Color WITH __RollingUpc.TempColr ;
10517 FOR NOT EOF("__RollingUpc") ;
10518 AND __RollingUpc.Source = "D" IN (pceipoTD)
10519
10520 Set Relation To
10521
10522 If This.oHostProcess.lHaveSLN
10523 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10524 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10525 org_Color WITH __RollingUpc.TempColr ;
10526 FOR NOT EOF("__RollingUpc") ;
10527 AND __RollingUpc.Source = "S" IN (pceipoTS)
10528 Set Relation To
10529 ENDIF
10530
10531 ENDIF
10532
10533 .TableClose("__RollingUpc")
10534
10535 ENDIF
10536 ENDWITH
10537
10538 SELECT (lnSelect)
10539 RETURN true
10540 ENDFUNC
10541*============================================================
10542
10543*=== TR 1036917 04-Feb-2009 Partha ===
10544
10545**************************************************************************************
10546
10547 * --- TR 1034963 12/15/08 CM
10548 * This procedure will write back to sysnotes exploded components of Range Styles
10549
10550 Procedure UpdateSysNotes
10551
10552 Local laTables[1]
10553 laTables[1] = "Vzzeipotd_notes_iPOproc"
10554
10555 Local llRetVal, llBeganTransaction
10556
10557 llRetVal = .T.
10558
10559 If This.BeginTransaction()
10560 llRetVal = This.Tableupdate(@laTables)
10561 If llRetVal
10562 This.EndTransaction()
10563 Else
10564 This.RollbackTransaction()
10565 Endif
10566 Endif
10567
10568 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10569
10570 Endproc
10571 * --- TR 1034963 12/15/08 CM
10572
10573**************************************************************************************
10574
10575 *--------------------------------------------------
10576 *--- TR 1041542 NSD 7/22/09
10577 * Register Number can be assigned by a sort now.
10578 PROCEDURE ResolveRegisterNumber
10579 LPARAMETERS pceipoTH
10580
10581 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10582 llRetVal = .T.
10583 lnSelect = SELECT()
10584
10585 WITH THIS
10586
10587 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10588 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10589 lcColList = "pkey,customer,reg_num"
10590 SELECT tcAllCols
10591 SCAN
10592 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10593 ENDSCAN
10594
10595 * Retrieve just the columns we need
10596 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10597 &lcSQL
10598
10599 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10600 * Push records to server to work with.
10601 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10602 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10603 lcAllTmp = .cSQLTempTable
10604
10605 * Find distinct customer
10606 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10607 SELECT tcRegNum_cust
10608 SCAN
10609 * Process 1 customer
10610
10611 * Get the grouping
10612 lcCustTmp = "#" + GetUniqueFileName()
10613 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10614 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10615 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10616 IF llRetVal
10617 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10618 lcGrouping = "CUSTOMER,PO_NUM"
10619 ELSE
10620 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10621 ENDIF
10622
10623 * Need to have a SQL Filter for the groupings
10624 STRINGTOARRAY(lcGrouping,@laGroupFields)
10625 lcGroupFieldsFilter = ""
10626 FOR x = 1 TO ALEN(laGroupFields,1)
10627 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10628 ENDFOR
10629 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10630
10631 * Create temp table of unique reg nums
10632 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10633 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10634 " GROUP BY " + lcGrouping
10635 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10636
10637 * Count distinct records and generate enough reg_nums
10638 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10639 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10640
10641 * Calculate New reg_nums
10642 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10643
10644 * Write back to table
10645 llRetVal = llRetVal AND v_sqlexec(;
10646 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10647 lcGroupFieldsFilter )
10648
10649 ENDIF
10650
10651 USE IN SELECT("tcRegNum_Sort")
10652 USE IN SELECT("tcRegNum_cnt")
10653 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10654 ENDSCAN
10655
10656 * Get all records back from Temp table. Loop through and apply to main cursor
10657 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10658 IF llRetVal
10659 SELECT tcRegNum_res
10660 SCAN
10661 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10662 SELECT (pceipoTH)
10663 REPLACE reg_num WITH tcRegNum_res.reg_num
10664 ENDIF
10665 ENDSCAN
10666
10667 ENDIF
10668
10669 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10670 ENDIF
10671
10672
10673 USE IN SELECT("tcRegNum_res")
10674 USE IN SELECT("tcAllCols")
10675 USE IN SELECT("tcRegNum_All")
10676 USE IN SELECT("tcRegNum_cust")
10677
10678 ENDWITH
10679
10680 SELECT(lnSelect)
10681 RETURN llRetVal
10682 ENDPROC
10683 *=== TR 1041542 NSD 7/22/09
10684
10685*===============================================================
10686
10687 *--- TR 1036614 8-Jun-2009 Goutam
10688 Procedure CreateSingleSLNCursor
10689 Lparameters pcTmpCursor
10690
10691 Local llRetVal, lnOldSelect, lcSQLString
10692
10693 llRetVal = true
10694 lnOldSelect = Select()
10695
10696 *---TR 1050793 7/14/2011 YE - Add template and slntodtl to cursor just as TR's 1045603 and TR 1045922 did in the next routine.
10697
10698 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10699
10700 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10701*!* select t.Customer ;
10702*!* , t.FKey ;
10703*!* , t.PKey ;
10704*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10705*!* , c.template ; && TR 1050793
10706*!* , c.slntodtl ; && TR 1050793
10707*!* from (pcTmpCursor) t ;
10708*!* join zzeipocr c ;
10709*!* on c.division = t.division ;
10710*!* and c.customer = t.customer ;
10711*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10712*!* on s.division = t.division ;
10713*!* and s.customer = t.customer ;
10714*!* and s.store = t.store ;
10715*!* where c.slntodtl = 'N' ;
10716*!* and (c.stylefromsln = 'O' ;
10717*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10718*!* into Cursor __tmpipots ;
10719*!* order by t.fkey, t.Customer, t.PKey
10720
10721 select t.Customer ;
10722 , t.FKey ;
10723 , t.PKey ;
10724 , NVL(s.price_flg, c.price_flg) as price_flg ;
10725 , c.template ; && TR 1050793
10726 , c.slntodtl ; && TR 1050793
10727 from (pcTmpCursor) t ;
10728 join zzeipocr c ;
10729 on c.division = t.division ;
10730 and c.customer = t.customer ;
10731 left join (this.oHostProcess.cCustomerStoreTable) s ;
10732 on s.division = t.division ;
10733 and s.customer = t.customer ;
10734 and s.store = t.store ;
10735 where c.slntodtl = 'N' ;
10736 and (c.stylefromsln = 'O' ;
10737 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10738 JOIN zzeipocr c ;
10739 on c.division = t.division ;
10740 and c.customer = t.customer ;
10741 group by t.fkey having (count(t.pkey)=1) and ;
10742 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10743 into Cursor __tmpipots ;
10744 order by t.fkey, t.Customer, t.PKey
10745 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10746
10747 Select(lnOldSelect)
10748 Return llRetVal
10749 Endproc
10750 *=== TR 1036614 8-Jun-2009 Goutam
10751
10752 *--- TR 1036614 8-Jun-2009 Goutam
10753 *--- This is the splited function from MoveSLNToDTLs
10754 PROCEDURE CreateCursorSLNToDtl
10755 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10756
10757 LOCAL llRetVal, lnOldSelect
10758 lnOldSelect = SELECT()
10759 llRetVal = true
10760
10761 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10762*!* select t.Customer ;
10763*!* , t.FKey ;
10764*!* , t.PKey ;
10765*!* , c.price_flg ;
10766*!* from (pcTmpCursor) t ;
10767*!* join zzeipocr c ;
10768*!* on c.division = t.division ;
10769*!* and c.customer = t.customer ;
10770*!* join (pceipoTD) d ;
10771*!* on d.pkey = t.dtlPkey ;
10772*!* where c.slntodtl = 'Y' ;
10773*!* and d.slntodtl <> 'Y' ;
10774*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10775*!* into Cursor __tmpipots ;
10776*!* order by t.fkey, t.Customer, t.PKey
10777
10778 *--- TR 1045922 05-MAR-2010 HNISAR
10779 * Added 'I' to Inlis in below statements
10780*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10781*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10782 *=== TR 1045922 05-MAR-2010 HNISAR
10783
10784 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10785 select t.Customer ;
10786 , t.FKey ;
10787 , t.PKey ;
10788 , NVL(s.price_flg, c.price_flg) as price_flg ;
10789 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10790 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
10791 from (pcTmpCursor) t ;
10792 join zzeipocr c ;
10793 on c.division = t.division ;
10794 and c.customer = t.customer ;
10795 left join (this.oHostProcess.cCustomerStoreTable) s ;
10796 on s.division = t.division ;
10797 and s.customer = t.customer ;
10798 and s.store = t.store ;
10799 join (pceipoTD) d ;
10800 on d.pkey = t.dtlPkey ;
10801 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
10802 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10803 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10804 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
10805 into Cursor __tmpipots ;
10806 order by t.fkey, t.Customer, t.PKey
10807 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
10808
10809 SELECT(lnOldSelect)
10810 RETURN llRetVal
10811
10812 ENDPROC
10813
10814 Procedure ResolveSingleSLNDetail
10815 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
10816
10817 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
10818
10819 llRetVal = true
10820 lnOldSelect = Select()
10821
10822 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10823 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
10824 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10825 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10826
10827 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10828*!* select t.Customer ;
10829*!* , t.FKey ;
10830*!* , t.PKey ;
10831*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10832*!* , t.ppk_code ;
10833*!* from (pcTmpCursor) t ;
10834*!* join zzeipocr c ;
10835*!* on c.division = t.division ;
10836*!* and c.customer = t.customer ;
10837*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10838*!* on s.division = t.division ;
10839*!* and s.customer = t.customer ;
10840*!* and s.store = t.store ;
10841*!* where c.slntodtl = 'N' ;
10842*!* AND ((c.stylefromsln in ('Y','O') ;
10843*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10844*!* into Cursor __tmpipots ;
10845*!* order by t.fkey, t.Customer, t.PKey
10846
10847 select t.Customer ;
10848 , t.FKey ;
10849 , t.PKey ;
10850 , NVL(s.price_flg, c.price_flg) as price_flg ;
10851 , t.ppk_code ;
10852 from (pcTmpCursor) t ;
10853 join zzeipocr c ;
10854 on c.division = t.division ;
10855 and c.customer = t.customer ;
10856 left join (this.oHostProcess.cCustomerStoreTable) s ;
10857 on s.division = t.division ;
10858 and s.customer = t.customer ;
10859 and s.store = t.store ;
10860 where c.slntodtl = 'N' ;
10861 AND ((c.stylefromsln in ('Y','O') ;
10862 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10863 JOIN zzeipocr c ;
10864 on c.division = t.division ;
10865 and c.customer = t.customer ;
10866 group by t.fkey having (count(t.pkey)=1) and ;
10867 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10868 into Cursor __tmpipots ;
10869 order by t.fkey, t.Customer, t.PKey
10870 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10871
10872 SELECT __tmpipots
10873 SCAN
10874 lnFKey = Fkey
10875
10876 Select (pceipoTS)
10877 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
10878
10879 lcDivision = Division
10880 lcStyle = Style
10881 lcColor_Code = Color_Code
10882 lcLbl_Code = Lbl_Code
10883 lcDimension = __tmpipots.PPK_Code
10884 lcSize_Desc = Size_Desc
10885
10886 select (pceipoTD)
10887 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
10888
10889 replace Division with lcDivision, ;
10890 Style with lcStyle, ;
10891 Color_Code with lcColor_Code, ;
10892 Lbl_Code with lcLbl_Code, ;
10893 Dimension with lcDimension,;
10894 SizeBucket with 1;
10895 Size_Desc with lcSize_Desc;
10896 Style_SLN_OK with 'Y' ;
10897 IN (pceipoTD)
10898 ENDIF
10899 ENDIF
10900 ENDSCAN
10901
10902 IF USED("__tmpipots")
10903 USE IN __tmpipots
10904 ENDIF
10905
10906 Select(lnOldSelect)
10907 Return llRetVal
10908 Endproc
10909
10910 *=== TR 1036614 8-Jun-2009 Goutam
10911
10912 *- 1044723 05/20/10 YIK
10913 *- Moved this method from postvalidation()
10914 PROCEDURE ResolveNewStoreOrd_type
10915 LPARAMETERS pcEipoTH
10916 LOCAL llRetVal, lnOldSelect
10917 llRetVal = .t.
10918 lnOldSelect = SELECT()
10919 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
10920 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
10921
10922 LOCAL lcSql, lcEipoTh, lcSQLTempTable
10923 lcEipoTh = SYS(2015)
10924 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
10925
10926 IF RECCOUNT(lcEipoTh) = 0
10927 USE IN (lcEipoTh)
10928 SELECT(lnOldSelect)
10929 RETURN llRetVal
10930 ENDIF
10931
10932 LOCAL lcOrd_typeResult
10933 lcOrd_typeResult = SYS(2015)
10934 WITH this
10935 .cSQLTempTable=""
10936 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
10937 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
10938 lcSQLTempTable = .cSQLTempTable
10939
10940 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
10941 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
10942 " inner join zzotyper r on r.ns_ord_type = 'Y'"
10943 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
10944 IF llRetVal
10945 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
10946 ENDIF
10947 ENDWITH
10948
10949 IF USED(lcEipoTh)
10950 USE IN (lcEipoTh)
10951 ENDIF
10952 IF USED(lcOrd_typeResult)
10953 USE IN (lcOrd_typeResult)
10954 ENDIF
10955
10956 Select(lnOldSelect)
10957 Return llRetVal
10958 Endproc
10959 *=== TR 1035678 NH
10960
10961 *--- TR 1049029 24-Aug-2010 Partha ---
10962 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
10963 FUNCTION GetTotSLNQty
10964 LPARAMETERS tnPSFkey, pceipoTS
10965
10966 LOCAL lnTotSlnQty, lnOldSelect
10967 LOCAL ARRAY laTotSlnQty[1]
10968
10969 lnOldSelect = SELECT()
10970 lnTotSlnQty = 0
10971
10972 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
10973 lnTotSlnQty = laTotSlnQty[1]
10974
10975 Select(lnOldSelect)
10976 Return lnTotSlnQty
10977 ENDFUNC
10978
10979 *=== TR 1049029 24-Aug-2010 Partha ===
10980
10981 *--- TechRec 1048792 17-Dec-2010 jisingh ---
10982 FUNCTION ClearSkus
10983 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
10984 LOCAL llRetVal, lnSelect, lcSqlString
10985
10986 llRetVal = true
10987 lnSelect = SELECT()
10988
10989 *-- Populate new flag from Control in Transaction Maintenance
10990 lcSqlString = " UPDATE h SET " + ;
10991 " ReResvStyle = c.ReResvStyle " + ;
10992 " FROM (pcEipoTH) h " + ;
10993 " JOIN (pcEipoCR) c " + ;
10994 " ON h.division = c.division " + ;
10995 " AND h.customer = c.customer " + ;
10996 " WHERE h.ReResvStyle = '' "
10997
10998 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10999
11000 *-- Make SKUs blank in Transaction Maintenance detail
11001 lcSqlString = " UPDATE d SET " + ;
11002 " Style = '', " + ;
11003 " Color_Code = '', " + ;
11004 " Lbl_Code = '', " + ;
11005 " Dimension = '', " + ;
11006 " SizeBucket = 0, " + ;
11007 " Size_Desc = '' " + ;
11008 " FROM (pcEipoTD) d " + ;
11009 " JOIN (pcEipoTH) h " + ;
11010 " ON h.pkey = d.fkey " + ;
11011 " WHERE h.ReResvStyle = 'Y' " + ;
11012 " AND (d.upc > '' OR d.sku > '') "
11013
11014 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11015
11016 *-- Make SKUs blank in SLN
11017 lcSqlString = " UPDATE s SET " + ;
11018 " Style = '', " + ;
11019 " Color_Code = '', " + ;
11020 " Lbl_Code = '', " + ;
11021 " Dimension = '', " + ;
11022 " SizeBucket = 0, " + ;
11023 " Size_Desc = '' " + ;
11024 " FROM (pcEipoTD) d " + ;
11025 " JOIN (pcEipoTH) h " + ;
11026 " ON h.pkey = d.fkey " + ;
11027 " JOIN (pcEipoTS) s " + ;
11028 " ON s.fkey = d.pkey " + ;
11029 " WHERE h.ReResvStyle = 'Y' " + ;
11030 " AND (s.sln_upc > '' OR s.sln_sku > '') "
11031
11032 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11033
11034 SELECT (lnSelect)
11035 RETURN llRetVal
11036 ENDFUNC
11037 *=== TechRec 1048792 17-Dec-2010 jisingh ===
11038
11039 *--- TR 1053820 25-May-2011 Goutam
11040 Function GenerateCustomerSKU_Style_ColorSize
11041 Lparameters pceipoTH,pceipoTD
11042
11043 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
11044 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
11045
11046 llRetVal = True
11047 lnSelect = Select()
11048 With This
11049
11050 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
11051
11052 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
11053
11054 *** Size_BK needs to be 00 and NOT 0
11055 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
11056 Select ;
11057 h.customer,;
11058 d.division,;
11059 d.pkey As dtlpkey ,;
11060 d.Style As Style, ;
11061 d.color_code,;
11062 d.lbl_code,;
11063 d.Dimension,;
11064 h.Store As cust_store ,;
11065 d.price As cust_price , ;
11066 d.size_desc, ;
11067 d.sizebucket as size_bk, ;
11068 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
11069 d.aux_sku ;
11070 from (pceipoTH) h ;
11071 join (pceipoTD) d ;
11072 on d.fkey = h.pkey ;
11073 join zzeipocr c ;
11074 on c.division = d.division ;
11075 and c.customer = h.customer ;
11076 where c.GenCustSKU = 'Y' ;
11077 and d.sku = '' ;
11078 and h.Errs_flg_h < 'Y' ;
11079 and d.Errs_Flg_D < 'Y' ;
11080 into cursor tmpCurs ;
11081 order by 1,2,4,5,6,7, 11
11082 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
11083
11084 lnCount = Reccount("tmpCurs")
11085
11086 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
11087
11088 If lnCount = 0
11089 If Used("tmpCurs")
11090 Use In tmpCurs
11091 Endif
11092 Select (lnSelect)
11093 Return
11094 Endif
11095
11096 *- Index just in case somebody changes the SELECT above
11097 Select tmpCurs
11098 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
11099 TAG sku
11100
11101 .LogEntry("Load Customer Style.")
11102
11103 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
11104 If Used("tmpCurs")
11105 Use In tmpCurs
11106 Endif
11107 Select (lnSelect)
11108 Return
11109 Endif
11110
11111 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
11112 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
11113 lnCount = lnCount - 1
11114 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
11115 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
11116
11117 Select VZZXCSTHR
11118 Scatter Memvar Blank
11119 Select VZZXCSTDR
11120 Scatter Memvar Blank
11121
11122 m.Last_mod = Datetime()
11123 m.User_id = 'CGSADMIN'
11124 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
11125 m.notes = ''
11126
11127 *--- TR 1057011 7-10-2011 VKK
11128 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
11129 m.active_ok = 'Y'
11130 m.anti_theft = 'N'
11131 *=== TR 1057011 7-10-2011 VKK
11132
11133 lcPrevSKU = ' '
11134 lcPrevSkuSize = ''
11135
11136 *- inserted details counter
11137 Local lnInsertCount
11138 lnInsertCount = 0
11139
11140 Select tmpCurs
11141
11142 Scan
11143 .LogEntry("Loading Customer Style...")
11144 .LogEntry("Style :" + Style )
11145 .LogEntry("Color_code :" + color_code )
11146
11147 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
11148 .LogEntry("Invalid Style or Color_code or Size_bk " )
11149 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
11150 FOR pkey = dtlpkey In (pceipoTD)
11151 Loop
11152 Endif
11153
11154 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
11155 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
11156 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
11157
11158 *--- Client Soffe wants to display size description in dimension's place if it is empty
11159 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
11160 If lcPrevSKU # lcSku
11161 lcPrevSKU = lcSku
11162 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
11163 .LogEntry("Customer :" + m.customer )
11164 .LogEntry("Division : " + m.division)
11165 .LogEntry("Style :" + Style )
11166 .LogEntry("Color_code :" + m.color_code )
11167 .LogEntry("Label code :" + m.lbl_code )
11168 .LogEntry("dimension : " + m.dimension)
11169 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
11170 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, IIF(EMPTY(m.dimension), m.size_desc, m.dimension))
11171 If Empty(lnHDRpKey)
11172 lnHDRpKey = lnCstHrPkey
11173 .LogEntry("Inserting into header..")
11174 Insert Into VZZXCSTHR From Memvar
11175 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
11176 In VZZXCSTHR
11177 Endif
11178 Endif
11179 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
11180 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
11181 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
11182 *- There arise a scenario where we can add a SKU with empty dimension to a header with Dimension (because from above we use size_desc if empty(dimension)
11183 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
11184 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, IIF(EMPTY(m.dimension), m.size_desc, m.dimension),m.size_bk)
11185
11186 If Empty(lnDtlKey)
11187 lnDtlpKey = lnCstDrPkey
11188 .LogEntry("Inserting into detail..")
11189 Insert Into VZZXCSTDR From Memvar
11190 *- TR 1071542 FH- need to add replace for dimension here as well
11191 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
11192 lnInsertCount = lnInsertCount + 1
11193 Endif
11194 Endif
11195 lnCstDrPkey = lnCstDrPkey +1
11196 lnCstHrPkey = lnCstHrPkey +1
11197
11198 Endscan
11199
11200 Dimension laTables[2]
11201 laTables[1]= "VZZXCSTHR"
11202 laTables[2]= "VZZXCSTDR"
11203
11204 llBeganTransaction = .BeginTransaction()
11205 llRetVal = .Tableupdate(@laTables)
11206
11207 If llRetVal
11208 If llBeganTransaction
11209 This.EndTransaction()
11210 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
11211 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
11212 Endif
11213 Else
11214 If llBeganTransaction
11215 This.RollbackTransaction()
11216 .LogEntry("Table Update failed - Roll back Transaction " )
11217 Endif
11218 Endif
11219
11220 Endwith
11221
11222 If Used("tmpCurs")
11223 Use In tmpCurs
11224 Endif
11225
11226 Select (lnSelect)
11227 Return llRetVal
11228 Endfunc
11229
11230 *=== TR 1053820 25-May-2011 Goutam
11231
11232*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
11233 *============================================================
11234 Procedure RangePConversion
11235 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
11236 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
11237 llRetVal = .T.
11238 lnOldSelect = Select()
11239
11240 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11241
11242 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11243 * 1st Getting all range headers
11244 *- process all.
11245 *- Exclude range style P from the consideration
11246 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
11247 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
11248
11249 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
11250 FROM (pcTransDetail) d ;
11251 JOIN (pceipoCR) c ON c.customer = d.customer ;
11252 AND c.division = d.division ;
11253 WHERE ((d.rng_type = 'P' OR ;
11254 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
11255 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
11256 )AND c.rngp_conv = 'R') ; && requires Range P conversion
11257 AND d.ppk_action $ 'QPBO' ;
11258 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
11259
11260 With This
11261 .cSQLTempTable=""
11262 If .GenerateSQLTempTable('__TmpCursor')
11263 If .PopulateSQLTempTable('__TmpCursor')
11264 If !Empty(.cSQLTempTable)
11265
11266 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
11267 " st.size_code " +;
11268 " FROM " + .cSQLTempTable + " t " +;
11269 " JOIN zzxscolr s " + ;
11270 " ON s.division = t.division " +;
11271 " AND s.style = t.style " + ;
11272 " AND s.color_code = t.color_code " + ;
11273 " AND s.lbl_code = t.lbl_code " + ;
11274 " AND s.dimension = t.dimension " + ;
11275 " INNER JOIN zzxstylr st " + ;
11276 " ON st.pkey = s.fkey " + ;
11277 " JOIN zzxrangh rh " + ;
11278 " ON rh.division = t.division " + ;
11279 " AND rh.rng_Style = t.style " + ;
11280 " AND rh.rng_color = t.color_Code " + ;
11281 " AND rh.rng_lbl = t.lbl_Code " + ;
11282 " AND rh.rng_pack = t.dimension "
11283
11284 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
11285
11286 If Used("_PPK_Qty")
11287 Select ("_PPK_Qty")
11288 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
11289 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
11290 "division+style+color_code+lbl_code+dimension")
11291 SELECT ("__TmpCursor")
11292
11293 If llRetVal
11294 .LogEntry("Validating Range style.")
11295 lcErrs_Msg = "No valid Range Style found"
11296 Select (pcTransDetail)
11297 SCAN FOR !EOF("_PPK_Qty")
11298
11299 If Empty(_PPK_Qty.pack_qty)
11300 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
11301 Errs_Flg_D With "Y" ;
11302 IN (pcTransDetail)
11303 Else
11304 Do Case
11305
11306 Case ppk_action = 'Q' && multiply qty
11307
11308 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11309 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11310 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
11311 In (pcTransDetail)
11312
11313 Case ppk_action = 'P' && divide price
11314
11315 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11316 org_price With org_price/_PPK_Qty.pack_qty, ;
11317 retail1 With retail1/_PPK_Qty.pack_qty, ;
11318 retail2 With retail2/_PPK_Qty.pack_qty, ;
11319 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
11320 In (pcTransDetail)
11321
11322 *- Range style price will be populated later from a_price..e_price
11323 *- not from org_price. Need to updated these prices here.
11324 IF rng_type = 'R'
11325 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11326 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11327 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11328 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11329 e_price WITH e_price/_PPK_Qty.pack_qty ;
11330 In (pcTransDetail)
11331 ENDIF
11332
11333 Case ppk_action = 'B' OR ppk_action = 'O'
11334
11335 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11336 org_price With org_price/_PPK_Qty.pack_qty, ;
11337 retail1 With retail1/_PPK_Qty.pack_qty, ;
11338 retail2 With retail2/_PPK_Qty.pack_qty, ;
11339 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11340 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
11341 In (pcTransDetail)
11342
11343 IF rng_type = 'R'
11344 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11345 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11346 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11347 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11348 e_price WITH e_price/_PPK_Qty.pack_qty ;
11349 In (pcTransDetail)
11350 ENDIF
11351
11352 Otherwise
11353 Endcase
11354 Endif
11355 Endscan
11356 Endif
11357 Set Relation To
11358 Endif
11359 Endif
11360 Endif
11361 Endif
11362
11363 Endwith
11364
11365 If Used("__TmpCursor")
11366 Use In __TmpCursor
11367 Endif
11368
11369 If Used("_PPK_Qty")
11370 Use In _PPK_Qty
11371 Endif
11372
11373 If Used("__RangeP")
11374 Use In __RangeP
11375 Endif
11376
11377 Select(lnOldSelect)
11378 Return llRetVal
11379 *============================================================
11380 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11381
11382 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11383 PROCEDURE PopulateIs860
11384 LPARAMETERS pceipoTH, pceipoCR
11385 LOCAL llRetVal, lnSelect, lcUpdate
11386
11387 llRetVal = true
11388 lnSelect = SELECT()
11389
11390 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11391
11392 *--- TR 1070268 26-Jun-2013 Goutam
11393 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11394 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11395 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11396
11397 *--- TechRec 1088575 14-Jul-2015 TSV ===
11398*!* lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11399*!* " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11400*!* " WHERE NVL(th.is860, '') = '' AND ((INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' OR cr.template = 'COSTCO 860')) OR (INLIST(th.po_purp,'01','05') AND (cr.template = 'BURLINGTON 4010')))"
11401
11402 * TR 1088961 KISHORE 31-JUL-2015 Added OR (th.po_purp='01' AND (cr.template = 'BELK 4030'))
11403 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11404 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11405 " WHERE NVL(th.is860, '') = '' AND ((INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' OR cr.template = 'COSTCO 860')) OR (INLIST(th.po_purp, '01','05') AND (cr.template = 'BURLINGTON 4010')) " + ;
11406 " OR (th.po_purp='01' AND (cr.template = 'BELKS 4030')))"
11407 *=== TR 1070268 26-Jun-2013 Goutam
11408
11409 &lcUpdate
11410
11411 SELECT (lnSelect)
11412 RETURN llRetVal
11413 ENDPROC
11414
11415 *============================================================
11416
11417 PROCEDURE Create860TM
11418 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
11419 LPARAMETERS pceipoTH, pceipoTD
11420 *--- TechRec 1082601 15-Dec-2014 jisingh Added loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp ===
11421 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql, loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp
11422
11423 llRetVal = true
11424 lnSelect = SELECT()
11425 lcAlias = GetUniqueFileName()
11426 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11427 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11428 lcInsertDtl = BuildInsertString("zzeipctd", "voEiPctd")
11429 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11430
11431 WITH This
11432 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11433 *IF !EMPTY(lcInsert)
11434 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11435 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11436 ORDER By h.division, h.customer INTO CURSOR tcOrders
11437
11438 .cSQLTempTable = ""
11439 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11440 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11441 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11442
11443 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11444 " FROM zzoordrh rh " + ;
11445 " JOIN " + .cSQLTempTable + " t " + ;
11446 " ON t.customer = rh.customer " + ;
11447 " AND t.division = rh.division " + ;
11448 " AND t.po_num = rh.po_num " + ;
11449 " AND t.store = rh.store " + ;
11450 " WHERE t.is860 = 'Y' "
11451
11452 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11453
11454 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11455 SELECT tcOrders
11456 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11457 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11458 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11459 SELECT (lcAlias)
11460 SCATTER NAME voEiPcth MEMO
11461
11462 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11463 .vSqlExec("SELECT * FROM zzeipctd WHERE 1 = 2", lcAlias)
11464 SELECT (lcAlias)
11465 SCATTER NAME voEiPctd MEMO
11466 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11467
11468 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11469 SELECT tcCRPkey
11470 INDEX ON customer+division TAG cudiv
11471
11472 SELECT (pceipoTH)
11473 COUNT TO lnRecNo FOR Is860 = 'Y'
11474
11475 IF .lUserInterface
11476 .AdvanceThermo(lnRecNo)
11477 ENDIF
11478
11479 SELECT (pceipoTH)
11480 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11481 *SCAN FOR Is860 = 'Y'
11482 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11483 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11484 SCATTER NAME loEiPOth MEMO
11485
11486 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11487 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11488
11489 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11490
11491 IF RECCOUNT("__tcipcth") > 0
11492 REPLACE Is860 WITH 'X' IN (pceipoTH)
11493 USE IN SELECT("__tcipcth")
11494 LOOP
11495 ENDIF
11496
11497 *--- TechRec 1082601 08-Jan-2015 jisingh ---
11498 lcPocPurp = "01"
11499 SELECT (pceipoTD)
11500 IF SEEK(loEiPOth.pkey, pceipoTD, "fkey")
11501 SCAN WHILE fkey = loEiPOth.pkey
11502 IF !EMPTY(qual_860)
11503 lcPocPurp = "04"
11504 EXIT
11505 ENDIF
11506 ENDSCAN
11507 ENDIF
11508 SELECT (pceipoTH)
11509 *=== TechRec 1082601 08-Jan-2015 jisingh ===
11510
11511 WITH voEiPcth
11512 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11513 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11514 *--- TechRec 1082601 25-Dec-2014 jisingh ---
11515 *voEiPcth.poc_purp = "01"
11516 voEiPcth.poc_purp = lcPocPurp
11517 *=== TechRec 1082601 25-Dec-2014 jisingh ===
11518 voEiPcth.customer = loEiPOth.customer
11519 voEiPcth.division = loEiPOth.division
11520 voEiPcth.doc_num = loEiPOth.doc_num
11521 voEiPcth.edi_store = loEiPOth.edi_store
11522 voEiPcth.store = loEiPOth.store
11523 voEiPcth.isa_num = loEiPOth.isa_num
11524 voEiPcth.our_id = loEiPOth.our_id
11525 voEiPcth.our_qual = loEiPOth.our_qual
11526 voEiPcth.po_num = loEiPOth.po_num
11527 voEiPcth.vnd_id = loEiPOth.vnd_id
11528 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11529 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11530 voEiPcth.po_type = loEiPOth.po_type
11531 voEiPcth.vnd_key = loEiPOth.vnd_key
11532 ENDWITH
11533
11534 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11535
11536 REPLACE Is860 WITH 'X' IN (pceipoTH)
11537
11538 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11539 IF llRetVal AND !EMPTY(lcInsertDtl) AND voEiPcth.pkey > 0
11540 lnLineSeq = 1
11541
11542 SELECT (pceipoTD)
11543 SCAN FOR fkey = loEiPOth.pkey AND !EMPTY(qual_860)
11544 SCATTER NAME loEiPOtd MEMO
11545
11546 WITH voEiPctd
11547 voEiPctd.pkey = v_NextPkey("zzeipctd")
11548 voEiPctd.line_seq = lnLineSeq
11549 voEiPctd.fkey = voEiPcth.pkey
11550 voEiPctd.qualifier = loEiPOtd.qual_860
11551 voEiPctd.upc = loEiPOtd.upc
11552 voEiPctd.sku = loEiPOtd.sku
11553 voEiPctd.aux_sku = loEiPOtd.aux_sku
11554 voEiPctd.division = loEiPOtd.division
11555 voEiPctd.style = loEiPOtd.style
11556 voEiPctd.color_code = loEiPOtd.color_code
11557 voEiPctd.lbl_code = loEiPOtd.lbl_code
11558 voEiPctd.dimension = loEiPOtd.dimension
11559 voEiPctd.size_desc = loEiPOtd.size_desc
11560 voEiPctd.sizebucket = loEiPOtd.sizebucket
11561 voEiPctd.ean = loEiPOtd.ean
11562 voEiPctd.udfoordd1c = loEiPOtd.udfoordd1c
11563 voEiPctd.udfoordd2c = loEiPOtd.udfoordd2c
11564 voEiPctd.start_date = loEiPOtd.start_date
11565 voEiPctd.end_date = loEiPOtd.end_date
11566 voEiPctd.delv_code = loEiPOtd.delv_code
11567 voEiPctd.qty_change = loEiPOtd.total_qty
11568 voEiPctd.total_qty = loEiPOtd.total_qty
11569 voEiPctd.poc_cost = loEiPOtd.price
11570 voEiPctd.poc_price = loEiPOtd.retail1
11571 voEiPctd.poc_retail2 = loEiPOtd.retail2
11572 ENDWITH
11573
11574 llRetVal = llRetVal AND .vSqlExec(lcInsertDtl)
11575 lnLineSeq = lnLineSeq + 1
11576 ENDSCAN
11577 ENDIF
11578 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11579
11580 IF .lUserInterface
11581 lnRecNo = lnRecNo + 1
11582 .AdvanceThermo(lnRecNo)
11583 ENDIF
11584 USE IN SELECT("__tcipcth")
11585 ENDSCAN
11586 ENDIF
11587 .TableClose(lcAlias)
11588 .TableClose("tcCRPkey")
11589 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11590 .TableClose("tcOrders")
11591 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11592 ENDWITH
11593
11594 RELEASE voEiPcth
11595 SELECT (lnSelect)
11596 RETURN llRetVal
11597 ENDPROC
11598 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11599
11600 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11601 PROCEDURE ValidateLocation
11602 LPARAMETERS pcHeader
11603
11604 LOCAL llRetVal, lnOldSelect
11605
11606 llRetVal= true
11607 lnOldSelect= Select()
11608
11609 SELECT Distinct Location FROM (pcHeader) ;
11610 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11611
11612 SELECT __tmpLocation
11613 WITH This
11614 .cSQLTempTable=""
11615 IF .GenerateSQLTempTable('__tmpLocation')
11616 IF .PopulateSQLTempTable('__tmpLocation')
11617 IF !EMPTY(.cSQLTempTable)
11618 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11619 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11620 llRetVal = v_SqlExec(lcSQLString, "_Location")
11621 IF llRetVal
11622 SELECT _Location
11623 INDEX On Location TAG Location
11624 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11625 IF llRetVal
11626 SELECT (pcHeader)
11627 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11628 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11629 SET RELATION TO
11630 ENDIF
11631 ENDIF
11632 ENDIF
11633 ENDIF
11634 ENDIF
11635 ENDWITH
11636
11637 IF USED("__tmpLocation")
11638 USE IN __tmpLocation
11639 ENDIF
11640 IF USED("_Location")
11641 USE IN _Location
11642 ENDIF
11643
11644 Select(lnOldSelect)
11645 Return llRetVal
11646 ENDPROC
11647 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11648
11649 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11650 PROCEDURE GetFldsList
11651 LPARAMETERS lcpceipoTH, lczzeoprth
11652
11653 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11654
11655 lnOldSelect= Select()
11656
11657 *- get common fields from both aliases
11658 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11659
11660 *- get fields from source table to validate 850 filter bros
11661 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11662
11663 *- Retrieve all 850 filter bros
11664 lcSQLString = "Select OBJID from zzxsfxrf " +;
11665 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11666
11667 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11668
11669 SELECT _Filter
11670
11671 SCAN
11672 lcFld = UPPER(TRIM(objid))
11673 *- Check filter bros and add them in required fields list if valid
11674 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11675 lcFldsList = lcFldsList + ", " + lcFld
11676 ENDIF
11677 ENDSCAN
11678
11679 *- Adding additional fields used in 850 filter string and insert sql in calling method
11680 IF NOT "IS940I" $ UPPER(lcFldsList)
11681 lcFldsList = lcFldsList + ", IS940I"
11682 ENDIF
11683
11684 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11685 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11686 ENDIF
11687
11688 IF NOT "REQ_855" $ UPPER(lcFldsList)
11689 lcFldsList = lcFldsList + ", REQ_855"
11690 ENDIF
11691
11692 IF NOT "PROC_855" $ UPPER(lcFldsList)
11693 lcFldsList = lcFldsList + ", PROC_855"
11694 ENDIF
11695
11696 IF USED("_Filter")
11697 USE IN _Filter
11698 ENDIF
11699
11700 Select(lnOldSelect)
11701
11702 Return lcFldsList
11703
11704 ENDPROC
11705 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11706
11707 *============================================================
11708
11709 *--- TechRec 1082601 24-Dec-2014 jisingh ---
11710 PROCEDURE Validate860Qual
11711 LPARAMETERS pcHeader, pcDetail
11712 LOCAL llRetVal, lnSelect
11713
11714 lnSelect = SELECT()
11715 llRetVal = .SetRelation(pcHeader, "pkey", pcDetail, "fkey")
11716
11717 REPLACE ALL errs_msg_d WITH errs_msg_d + "Item has 860 change code (" + ALLTRIM(qual_860) + ")" + CRLF, ;
11718 errs_flg_d WITH "Y" FOR !EMPTY(qual_860) AND &pcHeader..po_purp = "05" IN (pcDetail)
11719 SET RELATION TO
11720
11721 SELECT (lnSelect)
11722 RETURN llRetVal
11723 ENDPROC
11724 *=== TechRec 1082601 24-Dec-2014 jisingh ===
11725
11726 *- TR 1089110 FH
11727 PROCEDURE ValidateZeroQty
11728 LPARAMETERS pceipoTD
11729
11730 LOCAL llRetVal, lnOldSelect
11731 lnOldSelect = SELECT()
11732 llRetVal = .t.
11733
11734 UPDATE td SET Errs_flg_d = 'Y', Errs_msg_d = Errs_msg_d + 'Item has 0 Quantity' + CRLF ;
11735 FROM (pceipoTD) td WHERE total_qty = 0
11736
11737 Select(lnOldSelect)
11738 Return llRetVal
11739 ENDPROC
11740 *- TR 1089110 FH
11741
11742*============================================================
11743 *--- TR 1090280 3-Oct-2015 Goutam
11744 FUNCTION ValidateImplosionType
11745 LPARAMETERS tceipoTH, tceipoTD, tceipoCR
11746 LOCAL llRetVal, lnSelect
11747
11748 llRetVal = true
11749 lnSelect = SELECT()
11750
11751 WITH This
11752
11753 llRetVal= llRetVal And .SetRelation(tceipoCR, "divcust", tceipoTH, "division + customer")
11754 IF llRetVal
11755 Replace Errs_msg_H With Errs_msg_H + "Empty implosion bulk for implosion flag B." +CRLF ,;
11756 Errs_flg_h With "Y" FOR &pceipoCR..impl_ok = 'B' AND EMPTY(impl_bulk) In (pceipoTH)
11757 Set Relation To
11758 ENDIF
11759
11760 llRetVal = llRetVal And .SetRelation(tceipoTH, "pkey", tceipoTD, "fkey")
11761 IF llRetVal
11762 Replace Errs_msg_D With Errs_msg_D + "Empty implosion bulk in header for implosion flag B." +CRLF ,;
11763 Errs_flg_d With "Y" FOR 'Empty implosion bulk for implosion flag B' $ &tceipoTH..Errs_msg_H In (pceipoTD)
11764 Set Relation To
11765 ENDIF
11766
11767 ENDWITH
11768
11769 SELECT (lnSelect)
11770 RETURN llRetVal
11771 ENDFUNC
11772 *=== TR 1090280 3-Oct-2015 Goutam
11773
11774 *--- TR 1098918 26-Sep-2016 HGORE ---
11775 PROCEDURE UpdateReq_855ForAllocation
11776 LPARAMETERS pcHeader
11777
11778 LOCAL llRetVal, lnOldSelect
11779
11780 llRetVal= true
11781 lnOldSelect= Select()
11782
11783 SELECT DISTINCT Customer, Division FROM (pcHeader) ;
11784 WHERE NOT EMPTY(Customer) AND NOT EMPTY(Division) INTO CURSOR __tmpCustDivn
11785
11786 SELECT __tmpCustDivn
11787 WITH This
11788 .cSQLTempTable=""
11789 IF .GenerateSQLTempTable('__tmpCustDivn')
11790 IF .PopulateSQLTempTable('__tmpCustDivn')
11791 IF !EMPTY(.cSQLTempTable)
11792 lcSQLString= "SELECT c.Customer, c.Division FROM zzeoprcr c, " + .cSQLTempTable + " t " +;
11793 "WHERE c.Customer = t.Customer AND c.Division = t.Division "+;
11794 " AND c.Use_Allocation = 'Y' "
11795 llRetVal = v_SqlExec(lcSQLString, "_CustDivn")
11796 IF llRetVal
11797 SELECT _CustDivn
11798 INDEX On Customer + Division TAG CustDivn
11799 llRetVal= .SetRelation("_CustDivn", "CustDivn", pcHeader, "Customer+Division")
11800 IF llRetVal
11801 SELECT (pcHeader)
11802 REPLACE req_855 WITH 'A' FOR req_855 = 'R' AND customer = _CustDivn.Customer AND Division = _CustDivn.Division
11803 SET RELATION TO
11804 ENDIF
11805 ENDIF
11806 ENDIF
11807 ENDIF
11808 ENDIF
11809 ENDWITH
11810
11811 .TableClose("__tmpCustDivn")
11812 .TableClose("_CustDivn")
11813
11814 Select(lnOldSelect)
11815 Return llRetVal
11816
11817 ENDPROC
11818 *
11819 *--------------------------------------------------------------
11820 * Considered that only we have replaced req_855 = 'A' where req_855 = 'R' in .UpdateReq_855ForAllocation() and in .ResetReq_855() we are resetting it as it is.
11821 PROCEDURE ResetReq_855
11822 LPARAMETERS pcHeader
11823
11824 LOCAL llRetVal, lnOldSelect
11825
11826 llRetVal= true
11827 lnOldSelect= Select()
11828
11829 SELECT (pcHeader)
11830 REPLACE req_855 WITH 'R' FOR req_855 = 'A' IN (pcHeader)
11831
11832 Select(lnOldSelect)
11833 Return llRetVal
11834
11835 ENDPROC
11836 *=== TR 1098918 26-Sep-2016 HGORE ===
11837 *
11838*============================================================
11839
11840 *- 1111325 FH
11841 *- I have 3 scenarios here, either control_pkey is populated from FindCustomerUsingTradingPartnerID (great),
11842 *- or it wasn't able to find it, or customer is passed on flat file.
11843 *- If customer is passed on flat file, see if it exists in zzeipocr_expl, if it does just take top 1 pkey as control_pkey
11844 *- Error out all records that have control_pkey = 0. This will prevent 850 from processing base on control_pkey = 0
11845 FUNCTION ResolveControlPkey
11846 LPARAMETERS pceipoTH
11847 LOCAL llRetVal, lnSelect, lcCust, lcSql, lnControlPkey, lcErrs_Msg
11848
11849 llRetVal = .T.
11850 lnSelect = SELECT()
11851
11852 WITH This
11853 SELECT h.pkey ,h.control_pkey, h.customer FROM (pceipoTH) h WHERE h.control_pkey = 0 AND !EMPTY(h.customer) INTO CURSOR tmpCurs
11854 Select tmpCurs
11855
11856 SCAN
11857 lcCust = customer
11858 lcSql = "select top 1 pkey from zzeipocr_expl where customer = '" + lcCust + "'"
11859 llRetVal = llRetVal And v_SqlExec(lcSql, "_tmpCust")
11860 IF RECCOUNT("_tmpCust") <> 0
11861 lnControlPkey = _tmpCust.pkey
11862 SELECT tmpCurs
11863 IF SEEK(pkey, (pceipoth), "pkey")
11864 replace control_pkey WITH lnControlPkey IN (pceipoTH)
11865 ENDIF
11866 ENDIF
11867 SELECT tmpCurs
11868 ENDSCAN
11869
11870 SELECT (pceipoTH)
11871 lcErrs_Msg = "Control pkey is 0, 850 Can not find matching 850 control base on trading partner." + CRLF
11872 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg, Errs_flg_H With "Y" For control_pkey = 0 In (pcEiPOth)
11873
11874 ENDWITH
11875
11876 SELECT (lnSelect)
11877 RETURN llRetVal
11878 ENDFUNC
11879
11880Enddefine