· 8 years ago · Jan 23, 2018, 10:34 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 *--- TR 1101199 9-Feb-2017 Goutam
58 oGenStr = false
59 *=== TR 1101199 9-Feb-2017 Goutam
60
61 *--------------------------------------------------------------------------
62
63 Procedure Init
64 Lparameters toHostProcess
65 LOCAL llRetVal
66 llRetVal = .t.
67 llRetVal = llRetVal and DODEFAULT(toHostProcess)
68
69 *--- TR 1052729 10-Mar-11 SK
70 This.oPopulateSqlTempTable = Null
71
72 *--- TR 1065271 27-Nov-2012 BNarayanan ---
73 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
74 *=== TR 1065271 27-Nov-2012 BNarayanan ===
75
76 this.GetImplodeSQL()
77
78 *--- TR 1101199 9-Feb-2017 Goutam
79 this.oGenStr = NEWOBJECT("SQLStringBuilder", "clsgnstr.fxp")
80 llRetVal = llRetVal AND IsObject(this.oGenStr, true)
81 *=== TR 1101199 9-Feb-2017 Goutam
82
83 RETURN llRetVal
84 Endproc
85
86 *--------------------------------------------------------------------------
87 *--- TR 1101199 9-Feb-2017 Goutam
88 FUNCTION DESTROY
89 LOCAL lcSQLString
90 WITH THIS
91 IF IsObject(.oGenStr, true)
92 .oGenStr.Destroy()
93 .oGenStr = NULL
94 ENDIF
95 .DropTempTables()
96
97 DoDefault()
98 ENDWITH
99 ENDFUNC
100 *=== TR 1101199 9-Feb-2017 Goutam
101 *--------------------------------------------------------------------------
102
103 *-- [Main procedure]
104 Procedure PreValidation
105 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
106 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
107 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
108
109 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
110 Local llRetVal, lcSQLSelect, lcSQLOrder
111 llRetVal = .T.
112 PRIVATE vcLogName
113 vcLogName = this.cLogName
114 With This
115 .LogEntry("Resetting all error messages in transaction tables.")
116 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
117 vcLogName)
118 *--- TechRec 1005163 17-May-2004 GS ---
119 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
120 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
121 *=== TechRec 1005163 17-May-2004 GS ===
122
123 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
124 vcLogName)
125
126 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
127 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
128 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
129 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
130
131 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
132 vcLogName)
133 *--- TechRec 1005163 17-May-2004 GS ---
134 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
135 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
136 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
137 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
138 *=== TechRec 1005163 17-May-2004 GS ===
139
140 *--- TR 1103895 23-JUN-2017 HGORE ---
141 If (This.oHostProcess.lHaveChrgs OR This.oHostProcess.lHaveHDRChrgs) AND vl_compr(,,'__compr') AND (__compr.chrg_ok='Y' AND __compr.Dtl850Chrg_Ok='Y')
142 .LogEntry("Validating Customer Specific Charges (Header).")
143 llRetVal = llRetVal and .ValidateCustomerSpecificCharges(pceipoTH, tceipoTR, pceipoCR)
144 ENDIF
145 USE IN SELECT('__compr')
146 *=== TR 1103895 23-JUN-2017 HGORE ===
147
148 Endwith
149 Return llRetVal
150 Endproc
151
152 *--------------------------------------------------------------------------
153
154 * Clear all previous errors
155 Procedure ClearErrors
156 Lparameters pceipoTH, pceipoTD,;
157 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
158 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
159 Local llRetVal, lnOldSelect, laTables[2]
160 llRetVal = .T.
161 lnOldSelect = Select()
162 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
163 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
164 * we don't allow explosion happen again therefore cannot clearout division)
165 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
166 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
167 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
168 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
169 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
170 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
171 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
172 *=== 1010206 11/10/2005 Ilya.
173
174 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
175
176 *--- TR 1064141 3-Oct-2012 Goutam
177 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
178 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
179
180 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
181 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
182 *=== TR 1064141 3-Oct-2012 Goutam
183
184 *=== TR 1003801 - BD
185 *--- TechRec 1005163 17-May-2004 GS ---
186 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
187 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
188 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
189 *=== TechRec 1005163 17-May-2004 GS ===
190
191 *--- TechRec 1028745 05-Feb-2008 GSternik ---
192 If .oHostProcess.lHaveChrgs
193 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
194 Endif
195 *=== TechRec 1028745 05-Feb-2008 GSternik ===
196
197 *---TR 1008342 10-JAN-2005 RG
198 Replace All Pending_Flg With 'N' In (pceipoTH)
199 *===TR 1008342 10-JAN-2005 RG
200
201 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
202 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
203 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
204 IN (pceipoTH)
205 *=== TR 1073346 05-Sep-13 SK
206
207 *- 1041285 07/10/09 YIK
208 *- Populate force errors into error fields
209 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
210 FOR Errs_flg_fh = 'Y' ;
211 IN (pceipoTH)
212
213 *--- TR 1043191 23-Oct-2009 JK ---
214 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
215 *=== TR 1043191 23-Oct-2009 JK ===
216
217 Select(lnOldSelect)
218 Return llRetVal
219 Endproc
220
221 *--------------------------------------------------------------------------
222
223 ************************************************************************************
224 * Error check EDI headers
225 ************************************************************************************
226 Procedure CheckHeader
227 Lparameters pceipoTH, pceipoCR, pceipoTD
228 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
229
230 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
231 llRetVal = .T.
232 lnOldSelect = Select()
233 With This
234
235 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
236 *--- LOCAL MOD
237 *If llRetVal And .lRBACustSku
238 If llRetVal And .oHostProcess.lRBACustSku
239 .LogEntry("Resolve RBA Customer")
240 llRetVal= .ResolveBCCustomer(pceipoTH)
241 Else
242 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
243
244 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
245
246 *--- TR 1045965 09-MAR-2010 HNISAR
247*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
248 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
249 *=== TR 1045965 09-MAR-2010 HNISAR
250
251 If llRetVal
252 .LogEntry("Validating customer.")
253 llRetVal= .CheckCustomer(pceipoTH)
254 *- 01/29/02 YIK TAN 29056
255 If llRetVal
256 .LogEntry("Verifying Multiple customer.")
257 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
258 *= TAN 29056
259 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
260
261 *--- TR 1101199 6-Feb-2017 Goutam
262 .LogEntry("Verifying customer group.")
263 llRetVal = llRetVal And .CheckCustGroup(pceipoTH, pceipoCR)
264 *=== TR 1101199 6-Feb-2017 Goutam
265
266 Endif
267 Endif
268 Endif
269 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
270
271 *--- TR 1041542 NSD 7/22/09
272 IF llRetVal
273 .LogEntry("Resolving Register Number")
274 llRetVal = .ResolveRegisterNumber(pceipoTH)
275 ENDIF
276 *=== TR 1041542 NSD 7/22/09
277
278 If llRetVal
279 .LogEntry("Validating EDI store.")
280 llRetVal= .CheckStore(pceipoTH, pceipoCR)
281 If llRetVal
282 .LogEntry("Validating EDI center.")
283 llRetVal= .CheckDistribution(pceipoTH)
284 *- 1007452 10/22/04 YIK
285 *- Checking notes type
286 If llRetVal
287 .LogEntry("Validating Header Notes type.")
288 llRetVal= .CheckNoteType(pceipoTH)
289 Endif
290 *= 1007452
291 Endif
292 Endif
293
294 *--- TR 1022625 4-Mar-2007 TT
295 If llRetVal
296 .LogEntry("Checking for Terminations in PO_TYPE")
297 llRetVal= .CheckTerminationInPoType(pceipoTH)
298 Endif
299
300 *--- TR 1022625 4-Mar-2007 TT
301 *!* ENDIF
302 *!* ENDIF
303
304 *--- TR 1030441 17-Apr-2008 Goutam
305 If llRetVal
306 .LogEntry("Validating shipper code.")
307 llRetVal= .CheckShipper(pceipoTH)
308 Endif
309 *=== TR 1030441 17-Apr-2008 Goutam
310
311 *--- TechRec 1066487 05-Feb-2013 MANI. ---
312 IF llRetVal
313 .LogEntry("Validating Location.")
314 llRetVal= .ValidateLocation(pceipoTH)
315 Endif
316 *=== TechRec 1066487 05-Feb-2013 MANI. ===
317
318 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
319 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
320*!* If llRetVal
321*!* .LogEntry("Validating 855 Header status code.")
322*!* llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
323*!* ENDIF
324 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
325 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
326
327 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
328 * TR 1037925 - As per Krishna/Shenba
329 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
330 * This is getting moved in TR 1037925
331*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
332*!* IF llRetVal
333*!* .LogEntry("Resolving Customer Shipper.")
334*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
335*!* ENDIF
336*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
337 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
338
339 Endwith
340 Select(lnOldSelect)
341 Return llRetVal
342 Endproc
343
344 *--------------------------------------------------------------------------------------
345
346 Function ResolveBCCustomer
347
348 Lparameters pceipoTH
349 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
350
351 llRetVal = True
352 lnSelect = Select()
353 With This
354 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
355 lcSQLString = " Select * From ZZXCSTCR "
356 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
357
358 If llRetVal
359 lcCursor = GetUniqueFileName()
360
361 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
362
363 Select lcCursor
364 lcErrs_Msg = " No matching record in Customer Store cross reference "
365
366 lnCnt = Recc()
367 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
368
369 Scan
370 lccustomer = Alltrim(rtl_cust)
371 lcDepartment = Alltrim(rtl_dept)
372 lcOrd_type = Alltrim(rtl_ord_type)
373
374 .LogEntry("Retail Customer: " + lccustomer )
375 .LogEntry("Retail Dept: " + lcDepartment)
376 .LogEntry("Retail order type: " + lcOrd_type)
377
378 Select tcCustcr
379 .LogEntry("Select: tcCustcr")
380
381 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
382 If Not Found()
383 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
384 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
385 IN (pceipoTH)
386 .LogEntry(lcErrs_Msg)
387 Else
388 lcBCCustomer = tcCustcr.customer
389 lcBCEDIStore = tcCustcr.Store
390
391 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
392
393 * TR 1019260 Added- , ord_type WITH '' ;
394
395 Replace customer With lcBCCustomer ;
396 EDI_STORE With lcBCEDIStore , ord_type With '' ;
397 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
398 IN (pceipoTH)
399
400 Endif
401 Endscan
402 .TableClose(lcCursor)
403 .TableClose("tcCustcr")
404
405 Endif
406 Endwith
407
408 Select (lnSelect)
409 Return llRetVal
410 Endfunc
411
412 *-----------------------------------------------------------------------------------
413
414 * TAN 29056 YIK
415 Procedure CheckForMultiCust
416 Lparameter pceipoTH, pceipoCR
417 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
418 llRetVal, llMultiCust
419 Private pcCustomer
420
421 lnSelect = Select()
422 Select (pceipoCR)
423 Scan For mult_cust = 'Y'
424
425 *--- TR 1031442 25-Jun-2008 Goutam
426 *llMultiCust = .T.
427 *--- TR 1031442 25-Jun-2008 Goutam
428
429 pcCustomer = customer
430 lcDiv = division
431 lcCursor = GetUniqueFileName()
432 *- YIK 01/30/02
433 *- We may have multiple POs/regions per customer in one tceipoth file
434 Select Distinct Region From (pceipoTH) ;
435 WHERE customer = pcCustomer ;
436 AND !Empty(Region) ;
437 INTO Cursor &lcCursor
438 Select (lcCursor)
439 Scan
440
441 *--- TR 1031442 25-Jun-2008 Goutam
442 llMultiCust = .T.
443 *--- TR 1031442 25-Jun-2008 Goutam
444
445 pcRegion = Region
446 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
447 Replace &pceipoTH..customer With lcNewCustID ;
448 FOR customer = pcCustomer And Region = pcRegion;
449 IN (pceipoTH)
450 Endscan
451 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
452 Select (pceipoCR)
453 Endscan
454 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
455 Select (lnSelect)
456 Return llRetVal
457 Endproc
458
459 *-----------------------------------------------------------------------------------
460
461 Procedure CheckStore
462 Lparameters pcHeader, pcControl
463 Local llRetVal, lnOldSelect
464 llRetVal= .T.
465 lnOldSelect= Select()
466
467 * 1st - group get store using cust,edi_store but not overwrite existing store
468 * users could change store in Trans Maint.
469 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
470 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
471 Select __TmpCursor
472 With This
473 .cSQLTempTable=""
474 If .GenerateSQLTempTable('__TmpCursor')
475 If .PopulateSQLTempTable('__TmpCursor')
476 If !Empty(.cSQLTempTable)
477 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
478 * also, populate center_code, consol_code if empty
479 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
480 " from zzxstorr s, " + .cSQLTempTable + " t " +;
481 "Where s.customer= t.customer and s.edi_store= t.edi_store"
482 llRetVal = v_SqlExec(lcSQLString, "_Storr")
483 If llRetVal
484 Select _Storr
485 Index On customer+EDI_STORE Tag CustStore
486 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
487 "customer+edi_store")
488 If llRetVal
489 Select (pcHeader)
490
491
492 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
493 * Otherwise we will not be able to resolve currency later and that will
494
495
496 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
497 * Confirm order(with store) for the same customer
498 * the Bulk order will have "Invalid Store" message.
499 * Only Scan for !Empty(edi_store)
500 Scan For !Empty(EDI_STORE)
501 Do Case
502 Case Empty(_Storr.customer)
503 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
504 Errs_flg_h With "Y" In (pcHeader)
505 Case _Storr.active_ok <> 'Y'
506 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
507 Errs_flg_h With "Y" In (pcHeader)
508 Otherwise
509 If Empty(Store) && don't want to overwrite previous data
510 Replace Store With _Storr.Store
511 Endif
512 *- YIK 1017307 07/18/06
513 *- Added AND EMPTY(edi_center)
514 *--- TR 1042564 14-Sep-2008 JK ---
515 * if the dts flag on the order is not Y, then populate.
516 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
517 *=== TR 1042564 14-Sep-2008 JK ===
518 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
519 Replace center_code With _Storr.center_code
520 Endif
521 If Empty(consol_code) And !Empty(_Storr.consol_code)
522 Replace consol_code With _Storr.consol_code
523 Endif
524 *--- TR 1042564 14-Sep-2008 JK ---
525 ENDIF
526 *=== TR 1042564 14-Sep-2008 JK ===
527 *== 1009508
528 Endcase
529
530 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
531
532 Endscan
533 Set Relation To
534 Use In _Storr
535 Endif
536 Endif
537 Endif
538 Endif
539 Endif
540 Endwith
541 If Used("__TmpCursor")
542 Use In __TmpCursor
543 Endif
544
545 * 2nd - validate store by cust,store
546 * Notes: cannot reuse the above server side cursor because have
547 * to resolve it to tran header local 1st before validate happen
548 Select Distinct customer, Store From (pcHeader) ;
549 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
550 Select __TmpCursor
551 With This
552 .cSQLTempTable=""
553 If .GenerateSQLTempTable('__TmpCursor')
554 If .PopulateSQLTempTable('__TmpCursor')
555 If !Empty(.cSQLTempTable)
556 lcSQLString= "Select s.customer, s.store " +;
557 " from zzxstorr s, " + .cSQLTempTable + " t " +;
558 "Where s.customer= t.customer and s.store= t.store"
559 llRetVal = v_SqlExec(lcSQLString, "_Storr")
560 If llRetVal
561 Select _Storr
562 Index On customer+Store Tag CustStore
563 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
564 "customer+store")
565 If llRetVal
566 Select (pcHeader)
567 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
568 * Confirm order(with store) for the same customer
569 * the Bulk order will have "Invalid Store" message.
570 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
571 * Don't have conf_type as "A" or "B" yet
572 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
573 *- assortment orders with no store.
574
575 *--- TR1055827 NSD/FGCjr
576 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
577 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))
578 *=== TR1055827
579 If Empty(_Storr.customer)
580 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
581 Errs_flg_h With "Y" In (pcHeader)
582 Endif
583 Endscan
584 Set Relation To
585 Use In _Storr
586 Endif
587 Endif
588 Endif
589 Endif
590 Endif
591 Endwith
592 If Used("__TmpCursor")
593 Use In __TmpCursor
594 Endif
595
596 If Used("_Storr")
597 Use In _Storr
598 Endif
599
600 Select(lnOldSelect)
601 Return llRetVal
602 Endproc
603
604 *------------------------------------------------------------------------------------------
605
606 ************************************************************************************
607 * Validate EDI Distribution Center
608 * ATS# 2757 PL 06/09/99- validate against edi_center
609 * use edi_center in tran header for validation, when found
610 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
611 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
612 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
613 ************************************************************************************
614 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
615 * 1. Select Distinct customer, distribution center from work header.
616 * 2. Check for valid distribution center. If faile the check update all headers for
617 * the same customer, distribution center with "Invalid Store code." and
618 * Errs_Flg with "Y"
619 * Return: True= All pass validation
620 * False= If one of them fail the check
621 ************************************************************************************
622 Procedure CheckDistribution
623 Lparameters pceipoTH
624 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
625 llRetVal = .T.
626 lnOldSelect = Select()
627
628 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
629 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
630 Into Cursor CntrList
631 Select CntrList
632 If This.lUserInterface
633 * Init Thermometer
634 This.UpdateThermoCaption("Validating Distribution Center(s)...")
635 * TAN 31891 - JAZ - 5/20/02
636 * This.InitThermo(RECC('CntrList'))
637 This.InitThermo(Reccount('CntrList'))
638 * End TAN 31891 - JAZ - 5/20/02
639 l_nThermoCnt = 0
640 Endif
641 Scan
642 If This.lUserInterface
643 * Advance progress bar, if we're using one.
644 l_nThermoCnt = l_nThermoCnt + 1
645 This.AdvanceThermo(l_nThermoCnt)
646 Endif
647 * Empty(center_code) resolve using edi_center
648 If Empty(center_code)
649 lcErrs_Msg= ""
650 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
651 lcErrs_Msg= lcErrs_Msg + CRLF
652 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
653 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
654 IN (pceipoTH)
655 Else
656 * replace center_code with shipthru.center_code when found edi_center
657 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
658 * COMMENT OUT replace ship_dc with "D" also.
659 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
660 * Do not update center code unless dts_flag <> Y
661 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
662 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
663 IN (pceipoTH)
664
665 Endif
666 Else
667 * user may overwrite with wrong center_code, validate distribution center
668 lcErrs_Msg= ""
669 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
670 lcErrs_Msg= lcErrs_Msg + CRLF
671 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
672 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
673 IN (pceipoTH)
674 Endif
675 Endif
676
677 Endscan
678 Use In CntrList
679
680 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
681 * also, populate center_code, consol_code if empty
682 * populate Ship_dc base on center/consol_code
683 Select (pceipoTH)
684 Scan
685 lcShip_dc = ""
686 *- 1009508 03/16/05
687 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
688 *-- DO CASE
689 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
690 *-- lcShip_dc = "B"
691 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
692 *-- lcShip_dc = "D"
693 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
694 *-- lcShip_dc = "C"
695 *-- ENDCASE
696
697 If !Empty(center_code) Or !Empty(consol_code)
698 Do Case
699 Case !Empty(center_code) And !Empty(consol_code)
700 lcShip_dc = "B"
701 Case !Empty(center_code) And Empty(consol_code)
702 lcShip_dc = "D"
703 Case Empty(center_code) And !Empty(consol_code)
704 lcShip_dc = "C"
705 Endcase
706 *= 1009508 YIK
707 If !Empty(lcShip_dc)
708 Replace ship_dc With lcShip_dc In (pceipoTH)
709 Endif
710 Endif
711 Endscan
712
713 If This.lUserInterface
714 * Reset Thermometer
715 This.ResetThermo()
716 Endif
717
718 If Used("CntrList")
719 Use In CntrList
720 Endif
721 If Used("tcDistr")
722 Use In tcDistr
723 Endif
724 Select(lnOldSelect)
725 Return llRetVal
726 Endproc
727
728 *---------------------------------------------------------------------------------
729
730 Procedure CheckNoteType
731 Lparameters tcEiPOth
732 Local llRetVal, lcNotes, laNotes
733 llRetVal = .T.
734 Select (tcEiPOth)
735 Scan For !Empty(notes)
736 lcNotes = notes
737 Declare laNotes[2]
738 laNotes = ""
739 If At("|", lcNotes) > 0 && has note_type
740 *- 1030497 02/29/08 TT
741 *--StringToArray(lcNotes, @laNotes, "|")
742 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
743 *- 1030497 02/29/08 TT
744 lnNotes = Alen(laNotes)/2
745 For lnCnt = 1 To lnNotes
746 If !vl_notyp(laNotes[2*lnCnt - 1])
747 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
748 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
749 Endif
750 Endfor
751 Endif
752 Endscan
753 Return llRetVal
754 Endproc
755 *---------------------------------------------------------------------------------
756
757 *--- TR 1022625 4-Mar-2007 TT
758 Function CheckTerminationInPoType
759 Lparameters pceipoTH
760 LOCAL llRetVal, lnOldSelect
761 lnOldSelect = SELECT()
762 llRetVal = .t.
763 Local lnLastOrder
764 Select (pceipoTH)
765 lnLastOrder = Order()
766 Set Order To Tag po_type
767 If Seek("TR", pceipoTH, "po_type")
768 Scan While po_type = 'TR'
769 Replace Errs_msg_H With Errs_msg_H + ;
770 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
771 Errs_flg_h With "Y" In (pceipoTH)
772 Endscan
773 Endif
774 Set Order To lnLastOrder
775 SELECT(lnOldSelect)
776 RETURN llRetVal
777 Endfunc
778 *--- TR 1022625 4-Mar-2007 TT
779
780 *---------------------------------------------------------------------------------
781
782 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
783 PROCEDURE Validate855Status
784 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
785
786 Local llRetVal, lnOldSelect, lcSourceFilter
787 llRetVal= true
788 lnOldSelect= Select()
789
790 IF pcHeaderDetail = 'H'
791 SELECT Distinct status_855 FROM (pcHeader) ;
792 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
793 lcSourceFilter = " s.source = 'BAK02'"
794 ELSE
795 SELECT DISTINCT d.status_855 ;
796 FROM (pcDetail) d ;
797 JOIN (pcHeader) h ;
798 ON h.pkey = d.fkey ;
799 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
800 INTO CURSOR __tmp855Status
801 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
802 ENDIF
803
804 SELECT __tmp855Status
805 WITH This
806 .cSQLTempTable=""
807 IF .GenerateSQLTempTable('__tmp855Status')
808 IF .PopulateSQLTempTable('__tmp855Status')
809 IF !EMPTY(.cSQLTempTable)
810
811 lcSQLString= "Select s.status_855 from " +;
812 " zzeopakr s, " + .cSQLTempTable + " t " +;
813 "Where s.status_855 = t.status_855 and " + lcSourceFilter
814
815 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
816 IF llRetVal
817 SELECT _Ststus855
818 INDEX On status_855 TAG status_855
819 IF pcHeaderDetail = 'H'
820 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
821 ELSE
822 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
823 ENDIF
824
825 IF llRetVal
826 IF pcHeaderDetail = 'H'
827 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
828 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
829 ELSE
830 *- TR 1083937 FH - added INLIST(status_855,'AK','RJ'
831 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
832 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) ;
833 AND NOT INLIST(status_855,'AK','RJ') In (pcDetail)
834
835 * mark headers errors here as the Run855Process which runs next will rely on header errors.
836 SELECT (pcDetail)
837 SCAN FOR errs_flg_d = 'Y'
838 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
839 AND EVALUATE(pcHeader+'.req_855') = 'R'
840 ENDSCAN
841 ENDIF
842
843 SET RELATION TO
844 ENDIF
845 ENDIF
846 ENDIF
847 ENDIF
848 ENDIF
849 ENDWITH
850
851 IF USED("__tmp855Status")
852 USE IN __tmp855Status
853 ENDIF
854 IF USED("_Ststus855")
855 USE IN _Ststus855
856 ENDIF
857
858 Select(lnOldSelect)
859 Return llRetVal
860 ENDPROC
861 *=== TR 1074251 03-Jan-2014 Goutam
862
863 *---------------------------------------------------------------------------------
864
865 *--- TR 1030441 17-Apr-2008 Goutam
866 Procedure CheckShipper
867 LPARAMETERS pcHeader
868 Local llRetVal, lnOldSelect
869 llRetVal= true
870 lnOldSelect= Select()
871
872 SELECT Distinct shipper FROM (pcHeader) ;
873 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
874
875 SELECT __tmpShipper
876 WITH This
877 .cSQLTempTable=""
878 IF .GenerateSQLTempTable('__tmpShipper')
879 IF .PopulateSQLTempTable('__tmpShipper')
880 IF !EMPTY(.cSQLTempTable)
881 lcSQLString= "Select s.shipper from " +;
882 " zzxshipr s, " + .cSQLTempTable + " t " +;
883 "Where s.shipper= t.shipper"
884 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
885 IF llRetVal
886 SELECT _Shiper
887 INDEX On shipper TAG Shipper
888 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
889 IF llRetVal
890 SELECT (pcHeader)
891 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
892 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
893 SET RELATION TO
894 ENDIF
895 ENDIF
896 ENDIF
897 ENDIF
898 ENDIF
899 ENDWITH
900
901 IF USED("__tmpShipper")
902 USE IN __tmpShipper
903 ENDIF
904 IF USED("_Shiper")
905 USE IN _Shiper
906 ENDIF
907
908 Select(lnOldSelect)
909 Return llRetVal
910 Endproc
911 *=== TR 1030441 17-Apr-2008 Goutam
912
913 *---------------------------------------------------------------------------------
914
915 ************************************************************************************
916 * Error check all raw EDI details
917 ************************************************************************************
918 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
919 * Move codes to CheckUPC() and CheckSKU()
920 * Add:ResolveCustomerLabel()
921 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
922 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
923 * [div,sty,col,lbl,dim,size] allow or not
924 *
925 Procedure CheckDetail
926 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
927 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
928 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
929 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
930 Local llRetVal, lnOldSelect
931 llRetVal = .T.
932 lnOldSelect = Select()
933 With This
934 *--- TechRec 1048792 17-Dec-2010 jisingh ---
935 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
936 *=== TechRec 1048792 17-Dec-2010 jisingh ===
937
938 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
939 *--- TR 1019697 NH
940 .LogEntry("Cascading Customer To Detail.")
941 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
942 .LogEntry("Cascading Customer To SLN.")
943 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
944 *=== TR 1019697 NH
945 *=== TechRec 1048667 03-May-2011 GSternik ===
946
947
948 *--- TechRec 1024522 18-Sep-2007 GSternik ---
949 *--- LOCAL MOD
950 *If This.lHaveSLN
951 If This.oHostProcess.lHaveSLN
952 .LogEntry("Resolving SLNs/Prepack Style.")
953 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
954 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
955 EndIf
956 *=== TechRec 1024522 18-Sep-2007 GSternik ===
957
958 .LogEntry("Resolving style using UPC.")
959 *--- TechRec 1005163 17-May-2004 GS ---
960 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
961 *--- TR 1019697 NH
962 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
963 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
964*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
965 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
966 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
967
968 *- TR 1110216 FH
969 llRetVal= llRetVal And .ResolveIsUpcSku(pceipoTD)
970
971 *--- TR 1036917 04-Feb-2009 Partha ---
972 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
973 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
974
975 *=== TR 1036917 04-Feb-2009 Partha ===
976
977 *=== TR 1019697 NH
978 *=== TechRec 1005163 17-May-2004 GS ===
979 *--- TR 1023892 NH
980 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
981 *=== TR 1023892 NH
982
983 *--- TR 1044885 13-JAN-2010 BR Moved from above
984 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
985
986 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
987 *--- TechRec 1005163 17-May-2004 GS ---
988 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
989 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
990 *=== TechRec 1005163 17-May-2004 GS ===
991 *= 39222
992
993 *- TR 1003801 - 03/25/04 BD - Resolve EAN
994 .LogEntry("Resolving style using EAN.")
995
996 *--- TechRec 1005163 17-May-2004 GS ---
997 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
998 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
999 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
1000 *=== TR 1061652 05/18/12 ATHIRUNAVU
1001
1002 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
1003 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
1004 *--- TR 1035223 NH
1005 .LogEntry("Setting Skip SLN Check flag.")
1006 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1007 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
1008 *=== TR 1035223 NH
1009
1010 *--- TR 1053820 26-May-2011 Goutam
1011 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
1012 .LogEntry("Generate Customer SKU (Style_ColorSize).")
1013 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
1014 ENDIF
1015 *=== TR 1053820 26-May-2011 Goutam
1016
1017 .LogEntry("Confirming SKU for UPC/EAN.")
1018 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1019 *=== TechRec 1005163 17-May-2004 GS ===
1020 *=== TR 1003801
1021
1022 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
1023 If llRetVal And .oHostProcess.lRBACustSku
1024 .LogEntry("Verifying Customer SKU.")
1025 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
1026 Endif
1027 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
1028
1029 .LogEntry("Resolving style using SKU.")
1030 *--- TechRec 1005163 17-May-2004 GS ---
1031 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
1032
1033 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
1034 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
1035 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1036 *=== TR 1010097 07/27/05 TK
1037 *=== TechRec 1005163 17-May-2004 GS ===
1038
1039 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
1040 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
1041 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
1042
1043 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1044 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1045 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1046
1047 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1048 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
1049 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1050
1051 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
1052 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1053 *--- TR 1105078 1-Jul-2017 Goutam. Added parameter pceipoTS below
1054 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1055 *=== TR 1040432 MAY-20-2009 BR
1056
1057 *--- TR 1101199 10-Feb-2017 Goutam
1058 llRetVal = llRetVal And .PopulateControlpkey(pceipoTH, pceipoTD, pceipoCR)
1059 *=== TR 1101199 10-Feb-2017 Goutam
1060
1061 *--- TR 1090280 30-Sep-2015 Goutam
1062 .LogEntry("Validating Implosion Type.")
1063 llRetVal= llRetVal And .ValidateImplosionType(pceipoTH, pceipoTD, pceipoCR)
1064 *=== TR 1090280 30-Sep-2015 Goutam
1065
1066 *--- TR 1098918 26-Sep-2016 HGORE ---
1067 llRetVal = llRetVal And .UpdateReq_855ForAllocation(pceipoTH)
1068 *=== TR 1098918 26-Sep-2016 HGORE ===
1069
1070 *--- TR 1013007 NH
1071 *--- check if req_855 if 'R' and status flag is empty then set error flag
1072 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1073 *=== TR 1013007 NH
1074
1075 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1076 If llRetVal
1077 .LogEntry("Validating detail 855 status code.")
1078 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1079 Endif
1080 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1081
1082 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1083 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1084 vcLogName)
1085
1086 *--- TR 1013007 NH 2005-10-11
1087 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1088 If .lSend855
1089 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1090
1091 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1092 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1093 *=== TR 1040432 MAY-20-2009 BR
1094
1095 *--- Error out IPO records which has no corresponding OPRCR control ref
1096 *--- IPO and OPRCR link is customer, division, oVnd_Key
1097 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1098 *=== TR 1034481 NH
1099 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1100 *--- If req_855 = 'R'
1101 *--- then run process 855
1102 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1103 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1104 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1105 Endif
1106 *=== TR 1013007 NH
1107
1108 *--- TR 1098918 26-Sep-2016 HGORE ---
1109 llRetVal = llRetVal And .ResetReq_855(pceipoTH)
1110 *=== TR 1098918 26-Sep-2016 HGORE ===
1111
1112 *-1089110 FH - error out 0 total_qty
1113 llRetVal= llRetVal And .ValidateZeroQty(pceipoTD)
1114
1115 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1116 .LogEntry("Resolving Is 860.")
1117 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1118
1119 .LogEntry("Creating 860 Transaction records.")
1120 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
1121 llRetVal = llRetVal And .Create860TM(pceipoTH, pceipoTD)
1122 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1123
1124 *--- TechRec 1082601 24-Dec-2014 jisingh ---
1125 .LogEntry("Validating detail 860 qual.")
1126 llRetVal = llRetVal And .Validate860Qual(pceipoTH, pceipoTD)
1127 *=== TechRec 1082601 24-Dec-2014 jisingh ===
1128
1129 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1130 .LogEntry("Resolving Multi-UPCs.")
1131 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1132 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1133
1134 .LogEntry("Resolving range style.")
1135 *--- TR 1023892 NH -
1136 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1137 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1138 *=== TR 1023892 NH
1139
1140 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1141 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1142 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1143 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1144
1145 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1146 vcLogName)
1147 *- 36262 6/11/03 YIK
1148 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1149 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1150 vcLogName)
1151 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1152 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1153 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1154 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1155 * === TR 1046519 7/26/10 CM
1156
1157 *=
1158
1159 *- 1044723 01/06/10 YIK
1160 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1161 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1162
1163 *- TR 1042748 09/23/09 YIK
1164 *- Call it here to populate Impl_ok flag (3d parameter).
1165 *- MOved it to clsipopr, so need to call with .oHostProcess
1166 *- This method will be called again after implosion. Ok per JRoth
1167 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1168
1169 * 3/25/02 30854 - Implosion single prepack
1170 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1171 vcLogName)
1172 *--- TR 1097960 10-Feb-2017 Partha : Added tceipoTSAC, pczzeiPOtWhse ===
1173 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR, tceipoTSAC, pczzeiPOtWhse )
1174
1175 *- 1006607 09/01/04 YIK
1176 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1177 vcLogName)
1178 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1179 *=========
1180
1181 *--- TechRec 1005163 17-May-2004 GS ---
1182 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1183 If .oHostProcess.lHaveSLN
1184 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1185
1186 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1187*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1188*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1189 *=== TR 1049029 27-Aug-2010 Partha ===
1190
1191 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1192
1193 .LogEntry("Validating SLN vs. Prepack.")
1194 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1195 Endif
1196 *=== TechRec 1005163 17-May-2004 GS ===
1197
1198 *--- TR 1011644 23-AUG-2005 KA
1199 *If this.oResolvePrepack.lMultipack
1200 If this.lMultipack
1201 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1202 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1203 Endif
1204 *=== TR 1011644 23-AUG-2005 KA
1205
1206 .LogMajorStage("Resolving and getting default fields.")
1207 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1208 .LogEntry("Resolving customer label.")
1209 *--- TechRec 1005163 18-May-2004 GS ---
1210 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1211 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1212 *=== TechRec 1005163 18-May-2004 GS ===
1213
1214 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1215 vcLogName)
1216
1217 .LogEntry("Validating style.")
1218 *--- TechRec 1005163 21-Jun-2004 GS ---
1219 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1220 *--- TechRec 1016817 04-May-2006 GS ---
1221 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1222 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1223 *=== TechRec 1016817 04-May-2006 GS ===
1224 *=== TechRec 1005163 21-Jun-2004 GS ===
1225
1226 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1227 If This.oHostProcess.lHaveChrgs
1228 .LogEntry("Validating Charges.")
1229 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1230 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1231 EndIf
1232 *-- This is not needed anymore:
1233 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1234 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1235 * vcLogName)
1236 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1237
1238 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1239 *!* .LogEntry("Validating MinMultiple.")
1240 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1241 *===TR 1012978 VK 23/11/05
1242
1243 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1244 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1245 vcLogName)
1246 .LogEntry("Converting inbound UOM.")
1247 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1248
1249 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1250 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1251 lcSqlString = " UPDATE h SET " + ;
1252 " ReResvStyle = c.ReResvStyle " + ;
1253 " FROM (pcEipoTH) h " + ;
1254 " JOIN (pcEipoCR) c " + ;
1255 " ON h.control_pkey = c.pkey " + ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
1256 " WHERE h.ReResvStyle = '' "
1257
1258 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1259 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1260 EndWith
1261
1262 Select(lnOldSelect)
1263 Return llRetVal
1264 ENDPROC
1265
1266 *----------------------------------------------------------------------------------------
1267 * TR 1037976 JAN-22-2008 BR
1268 *----------------------------------------------------------------------------------------
1269 Procedure UpdtHeaderDivs
1270 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1271 Lparameters pceipoTH, pceipoTD, pceipoCR, pceipoTS
1272 *--- TR 1105078 1-Jul-2017 Goutam. Added above parameter pceipoTS
1273
1274 Local llRetVal, lnOldSelect, llUpdate
1275
1276 *--- TR 1101199 9-Feb-2017 Goutam
1277 LOCAL lnFkey, lcCustomer, llDivfound
1278 *=== TR 1101199 9-Feb-2017 Goutam
1279
1280 *--- TR 1105078 1-Jul-2017 Goutam
1281 local llEmptyCustomer, lcSql
1282 *=== TR 1105078 1-Jul-2017 Goutam
1283
1284
1285 llRetVal = .T.
1286 lnOldSelect = Select()
1287
1288 .LogEntry("Resolving header division.")
1289 *- 1005164 07/12/04 YIK
1290 *- Removed ..And Empty(Errs_Msg_D)
1291 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1292*!* Select Distinct fkey, division From (pceipoTD) ;
1293*!* WHERE !Empty(division) Into Cursor tmpCurs
1294
1295 *--- TR 1101199 9-Feb-2017 Goutam
1296 *SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, ;
1297 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
1298 FROM (pceipoTH) h ;
1299 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1300 JOIN (pceipoCR) c ON c.pkey = h.control_pkey ;
1301 WHERE !EMPTY(d.division) INTO CURSOR tmpCurs
1302
1303 *--- TR 1105078 1-Jul-2017 Goutam
1304 *SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, c.pkey as control_pkey, h.customer, ;
1305 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
1306 FROM (pceipoTH) h ;
1307 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1308 JOIN (pceipoCR) c ON c.customer = h.customer ;
1309 ORDER BY d.fkey, c.customer, c.division ;
1310 WHERE !EMPTY(d.division) AND EMPTY(h.cust_group) INTO CURSOR tmpCurs
1311
1312 SELECT DISTINCT d.fkey, d.division, h.customer, h.edi_store ;
1313 FROM (pceipoTH) h ;
1314 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1315 WHERE !EMPTY(d.division) AND EMPTY(h.cust_group) INTO CURSOR tmpCurs
1316
1317 this.cSQLTempTable=""
1318 if recc('tmpCurs') > 0 and this.GenerateSQLTempTable('tmpCurs') and this.PopulateSQLTempTable('tmpCurs') and !Empty(this.cSQLTempTable)
1319
1320 use in select('tmpCurs')
1321 *--- If costomer is available, will take control of that customer from zzeipocr_expl table. If customer is empty then will take customer
1322 *--- from edi store provided in flat file. Else customer may not match with store.
1323 lcSql = "SELECT DISTINCT t.fkey, c.customer, t.division, c.division AS ctrl_division, c.pkey as control_pkey, t.customer, " +;
1324 IIF(This.lValidateDivision, " 'Y' AS validate_division ", " case when c.validate_division = 'Y' then 'Y' else 'N' end as validate_division ") +;
1325 " FROM " + this.cSQLTempTable + " t " +;
1326 " JOIN zzeipocr_expl c " +;
1327 " on c.customer = case when t.customer > '' then t.customer else c.customer end " +;
1328 " join zzxstorr r " +;
1329 " on r.customer = c.customer and r.edi_store = case when t.edi_store > '' then t.edi_store else r.edi_store end " +;
1330 " ORDER BY t.fkey, c.customer, c.division"
1331
1332 llRetVal = llRetVal and v_sqlexec(lcSql, 'tmpCurs')
1333 endif
1334 *=== TR 1105078 1-Jul-2017 Goutam
1335
1336 *=== TR 1101199 9-Feb-2017 Goutam
1337
1338 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1339 if llRetVal &&*--- TR 1105078 1-Jul-2017 Goutam
1340
1341 Select tmpCurs
1342 If This.lUserInterface
1343 * Init Thermometer
1344 * TAN 31891 - JAZ - 5/20/02
1345 * This.InitThermo(RECC('tmpCurs'))
1346 This.InitThermo(Reccount('tmpCurs'))
1347 * End TAN 31891 - JAZ - 5/20/02
1348 l_nThermoCnt = 0
1349 Endif
1350 Scan
1351 If This.lUserInterface
1352 * Advance progress bar, if we're using one.
1353 l_nThermoCnt = l_nThermoCnt + 1
1354 This.AdvanceThermo(l_nThermoCnt)
1355 Endif
1356 Select (pceipoTH)
1357
1358 * --- TR 1022896 NSD 05-10-07
1359 * Convert LOCATE to SEEK
1360 *LOCATE FOR pkey = tmpCurs.fkey
1361 *IF FOUND()
1362 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1363
1364 *--- TR 1101199 9-Feb-2017 Goutam
1365 SELECT tmpCurs
1366 lnFkey = fkey
1367 lcCustomer = customer
1368 LOCATE FOR ctrl_division = division WHILE fkey = lnFkey AND customer = lcCustomer
1369 llDivfound = FOUND()
1370 IF !llDivfound
1371 skip-1
1372 ENDIF
1373 Select (pceipoTH)
1374 *=== TR 1101199 9-Feb-2017 Goutam
1375
1376 * === TR 1022896 NSD 05-10-07
1377 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1378 *--- TR 1101199 9-Feb-2017 Goutam. Added !llDivfound AND in the following condition
1379 IF !llDivfound AND tmpCurs.validate_division = "Y" AND tmpCurs.ctrl_division <> tmpCurs.division
1380 REPLACE errs_msg_h WITH errs_msg_h + ;
1381 "Mismatch between division(" + ALLTRIM(tmpCurs.ctrl_division) + ;
1382 ") and resolved UPC/SKU division(" + ALLTRIM(tmpCurs.division) + ")." + CRLF,;
1383 errs_flg_h WITH "Y" IN (pceipoTH)
1384 ELSE
1385 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1386 *--- TR 1101199 9-Feb-2017 Goutam. added control_pkey update
1387 Replace division With tmpCurs.division, control_pkey WITH tmpCurs.control_pkey In (pceipoTH)
1388
1389 *--- TR 1105078 1-Jul-2017 Goutam
1390 llEmptyCustomer = iif(empty(&pceipoTH..customer), true, llEmptyCustomer)
1391 Replace customer With iif(empty(customer), tmpCurs.customer, customer) In (pceipoTH)
1392 *=== TR 1105078 1-Jul-2017 Goutam
1393
1394 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1395 ENDIF
1396 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1397
1398 *--- TR 1101199 9-Feb-2017 Goutam
1399 IF llDivfound
1400 SELECT tmpCurs
1401 LOCATE FOR customer <> lcCustomer WHILE fkey = lnFkey
1402 IF !FOUND()
1403 skip-1
1404 ENDIF
1405 ENDIF
1406 *=== TR 1101199 9-Feb-2017 Goutam
1407 Endif
1408 Endscan
1409 endif &&*--- TR 1105078 1-Jul-2017 Goutam
1410
1411 *--- TR 1105078 1-Jul-2017 Goutam
1412 *Use In tmpCurs
1413 use in select('tmpCurs')
1414 *=== TR 1105078 1-Jul-2017 Goutam
1415
1416 *--- TR 1105078 1-Jul-2017 Goutam
1417 If llRetVal and llEmptyCustomer
1418 update d set d.customer = h.customer from (pceipoTH) h join (pceipoTD) d on d.fkey = h.pkey where d.customer = ''
1419 replace all errs_msg_h with strtran(errs_msg_h, "Invalid Customer code." + CRLF, "") In (pceipoTH)
1420 replace all errs_msg_h with strtran(errs_msg_h, "Invalid EDI Store code." + CRLF, "") In (pceipoTH)
1421 replace all errs_msg_h with strtran(errs_msg_h, "Invalid Store code." + CRLF, "") In (pceipoTH)
1422 replace all errs_flg_h with 'N' for empty(alltrim(errs_msg_h)) In (pceipoTH)
1423 replace all Errs_msg_H with iif(empty(alltrim(Errs_msg_H)), '', Errs_msg_H) in (pceipoTH)
1424
1425 .LogEntry("Validating EDI store once again due to blank customer...")
1426 llRetVal= .CheckStore(pceipoTH, pceipoCR)
1427 If llRetVal
1428 .LogEntry("Validating EDI center once again...")
1429 llRetVal= .CheckDistribution(pceipoTH)
1430 If llRetVal
1431 .LogEntry("Validating Header Notes type once again...")
1432 llRetVal= .CheckNoteType(pceipoTH)
1433 Endif
1434 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR)
1435 Endif
1436 Endif
1437 *=== TR 1105078 1-Jul-2017 Goutam
1438
1439 If This.lUserInterface
1440 * Reset Thermometer
1441 This.ResetThermo()
1442 Endif
1443 Select(lnOldSelect)
1444 Return llRetVal
1445 ENDPROC
1446 *----------------------------------------------------------------------------------------
1447 * TR 1037976 JAN-22-2008 BR
1448 *----------------------------------------------------------------------------------------
1449
1450 *---------------------------------------------------------------------------------
1451
1452 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1453 ************************************************************************************
1454 * Resolve BC SKU from SLN records and create customer style data.
1455 ************************************************************************************
1456 Procedure ResolveStyleFromSLN
1457 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1458 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1459 *--- TR 1035491 4-Nov-2008 Goutam
1460 *--- This entire function splitted into two different part ;
1461 1. ResolveBCSkuFromSLN ;
1462 2. ResolvePPKSkuAndUpdateDetail
1463
1464 Local llRetVal, lnOldSelect
1465 lnOldSelect = Select()
1466 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1467 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1468
1469
1470 Select(lnOldSelect)
1471 Return llRetVal
1472 Endproc
1473
1474 *----------------------------------------------------------------------------------
1475 ************************************************************************************
1476 * Validate UPC for all details
1477 ************************************************************************************
1478 Procedure CheckUpc
1479 Lparameters pceipoTH, pceipoTD,;
1480 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1481
1482 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1483 * Added Parameter pceipocr
1484 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1485
1486 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1487 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1488 lnSize_desc, llSLN
1489
1490 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1491 LOCAL lcIs_upcsku
1492 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1493
1494 llRetVal = .T.
1495 lcErrs_Msg= ""
1496 lnOldSelect = Select()
1497
1498 * cannot check for UPC if customer is empty
1499 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1500 * on Cust SKU or UPC.
1501 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1502
1503 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1504 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1505 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1506
1507 *--- TechRec 1005163 17-May-2004 GS ---
1508 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1509 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1510 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1511 *Order by h.customer, d.upc Into Cursor tmpCurs
1512
1513 *---- TR 1024667 NSD 5/31/07
1514 * If sizebucket = 0 then re-resolve.
1515
1516 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1517 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1518*!* If This.lHaveSLN
1519*!* Select h.customer,;
1520*!* d.upc,;
1521*!* d.pkey,;
1522*!* (pceipoTD) As Src;
1523*!* FROM (pceipoTH) h ;
1524*!* JOIN (pceipoTD) d ;
1525*!* ON h.pkey = d.fkey ;
1526*!* WHERE !Empty(d.upc) ;
1527*!* AND !Empty(h.customer) ;
1528*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1529*!* UNION All ;
1530*!* SELECT h.customer,;
1531*!* s.SLN_UPC As upc,;
1532*!* s.pkey,;
1533*!* (pceipoTS) As Src ;
1534*!* FROM (pceipoTH) h ;
1535*!* JOIN (pceipoTD) d ;
1536*!* ON d.fkey = h.pkey ;
1537*!* JOIN (pceipoTS) s ;
1538*!* ON s.fkey = d.pkey ;
1539*!* WHERE !Empty(s.SLN_UPC) ;
1540*!* AND !Empty(h.customer) ;
1541*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1542*!* ORDER By 1, 2 ;
1543*!* INTO Cursor tmpCurs
1544*!* Else
1545*!* Select h.Customer,;
1546*!* d.UPC,;
1547*!* d.PKey,;
1548*!* (pceipoTD) As Src;
1549*!* FROM (pceipoTH) h ;
1550*!* JOIN (pceipoTD) d ;
1551*!* ON h.pkey = d.fkey ;
1552*!* WHERE !Empty(d.upc) ;
1553*!* AND !Empty(h.customer) ;
1554*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1555*!* ORDER By 1, 2;
1556*!* INTO Cursor tmpCurs
1557*!* Endif
1558 *=== TechRec 1005163 17-May-2004 GS ===
1559
1560 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1561 *--- TR 1101199 6-Mar-2017 Goutam. Added cust_group
1562 SELECT customer, cust_group, MAX(ResvCustSKU) as ResvCustSKU ;
1563 FROM (pceipocr) ;
1564 GROUP BY customer ;
1565 INTO CURSOR __ResvCustSKU
1566 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1567
1568 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1569*!* select h.Customer;
1570*!* , d.UPC;
1571*!* , d.PKey;
1572*!* from (pceipoTH) h;
1573*!* join (pceipoTD) d;
1574*!* on h.PKey = d.FKey;
1575*!* where !Empty(d.UPC);
1576*!* and !Empty(h.Customer);
1577*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1578*!* order by 1, 2;
1579*!* into Cursor tmpCurs ReadWrite
1580
1581 *- 1035314 08/28/08 YIK
1582 *- Added r.ResvCustSKU to the list of fields
1583 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1584
1585 .oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1586
1587 *--- TR 1101199 6-Mar-2017 Goutam. Added distinct and cust_group in join
1588 Select distinct h.customer;
1589 , d.upc;
1590 , d.pkey;
1591 ,(pceipoTD) AS Src;
1592 ,r.ResvCustSKU ;
1593 from (pceipoTH) h;
1594 join (pceipoTD) d;
1595 on h.pkey = d.fkey;
1596 JOIN __ResvCustSKU r ;
1597 ON ((r.Customer = H.Customer) or (r.cust_group = h.cust_group)) ;
1598 where !Empty(d.upc);
1599 and !Empty(h.customer);
1600 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1601 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1602 order By 1, 2;
1603 into Cursor tmpCurs Readwrite
1604 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1605 *= 08/12/08 YIK TR 1035314
1606*=== TechRec 1024522 25-Sep-2007 GSternik ===
1607
1608*-1040686
1609 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1610 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1611 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1612 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1613 IF llRetVal
1614 .PopulateSQLTempTable("tcCustUpc")
1615 ENDIF
1616
1617 llRetVal = llRetVal AND v_sqlexec(;
1618 "SELECT x.upc,d.* "+;
1619 " FROM zzxcstdr d"+ ;
1620 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1621 " JOIN " + this.cSQLTempTable + " x " + ;
1622 " ON d.customer = x.customer " +;
1623 " AND d.cust_style = x.upc " + ;
1624 " WHERE h.IB_resolv = 'Y'" + ;
1625 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1626 SELECT tmpCstdr_upc
1627 INDEX on customer + upc TAG cust_upc
1628
1629
1630 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1631 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1632 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1633 IF llRetVal
1634 .PopulateSQLTempTable("tcDistUpc")
1635 ENDIF
1636
1637 llRetVal = llRetVal AND v_sqlexec(;
1638 "SELECT x.upc,d.* "+;
1639 " FROM zzeupcnr d"+ ;
1640 " JOIN " + this.cSQLTempTable + " x " + ;
1641 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1642 SELECT tmpUpcnr
1643 INDEX on upc TAG upc
1644 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1645*-1040686
1646
1647 lcOldCust = ""
1648 lcOldItem = ""
1649 Select tmpCurs
1650 If This.lUserInterface
1651 * Init Thermometer
1652 This.UpdateThermoCaption("Validating UPC(s)...")
1653 * TAN 31891 - JAZ - 5/20/02
1654 * This.InitThermo(RECC('tmpCurs'))
1655 This.InitThermo(RecCount('tmpCurs'))
1656 * End TAN 31891 - JAZ - 5/20/02
1657 l_nThermoCnt = 0
1658 EndIf
1659
1660 Scan
1661 If This.lUserInterface
1662 * Advance progress bar, if we're using one.
1663 l_nThermoCnt = l_nThermoCnt + 1
1664 This.AdvanceThermo(l_nThermoCnt)
1665 Endif
1666 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1667 lcErrs_Msg = ""
1668 lcOldCust = tmpCurs.customer
1669 lcOldItem = tmpCurs.upc
1670 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1671 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1672
1673 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1674 lcIs_upcsku = ' '
1675 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1676
1677 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1678 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1679
1680 *- 1040686 - tmpCstdr_upc...
1681 lcDivision = tmpCstdr_upc.division
1682 lcStyle = tmpCstdr_upc.Style
1683 lcColor_code = tmpCstdr_upc.color_code
1684 lcLbl_code = tmpCstdr_upc.lbl_code
1685 lcDimension = tmpCstdr_upc.Dimension
1686 lnSizeBucket = tmpCstdr_upc.size_bk
1687 lnSize_desc = tmpCstdr_upc.size_desc
1688 *- 1040686 - tmpCstdr_upc...
1689
1690 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1691 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1692 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1693
1694 ELSE
1695 *- 08/12/08 YIK TR 1035314
1696 IF ResvCustSKU <> 'Y'
1697 lcErrs_Msg = ""
1698 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1699 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1700 lcDivision = tmpUpcnr.division
1701 lcStyle = tmpUpcnr.Style
1702 lcColor_code = tmpUpcnr.color_code
1703 lcLbl_code = tmpUpcnr.lbl_code
1704 lcDimension = tmpUpcnr.Dimension
1705 lnSizeBucket = tmpUpcnr.sizebucket
1706 lnSize_desc = tmpUpcnr.size_desc
1707 Else
1708 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1709 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1710 Store 0 To lnSizeBucket
1711 Endif
1712 *- 08/12/08 YIK TR 1035314
1713 ELSE
1714 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1715 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1716 STORE 0 TO lnSizeBucket
1717 ENDIF
1718 *= 08/12/08 YIK TR 1035314
1719 Endif
1720 Endif && level break
1721
1722 *--- TechRec 1005163 17-May-2004 GS ---
1723 *Select (pceipoTD)
1724*!* llSLN = (tmpCurs.Src = pceipoTS)
1725*!* If llSLN
1726*!* Select (pceipoTS)
1727*!* Else
1728 Select (pceipoTD)
1729*!* Endif
1730 *=== TechRec 1005163 17-May-2004 GS ===
1731 *- 1010682 04/25/05 YIK
1732 *- Locate For pkey = tmpCurs.pkey
1733 lnWorkArea = Select()
1734 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1735 Scatter Name loEiPOtd Memo
1736 If !Empty(lcErrs_Msg)
1737*!* *--- TechRec 1005163 17-May-2004 GS ---
1738*!* If llSLN
1739*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1740*!* loEiPOtd.Errs_Flg_S = "Y"
1741*!* Else
1742*!* *=== TechRec 1005163 17-May-2004 GS ===
1743 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1744 loEiPOtd.Errs_Flg_D = "Y"
1745*!* Endif
1746 Endif
1747 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1748 loEiPOtd.Division = lcDivision
1749 loEiPOtd.Style = lcStyle
1750 loEiPOtd.Color_Code = lcColor_code
1751 loEiPOtd.Lbl_Code = lcLbl_code
1752 loEiPOtd.Dimension = lcDimension
1753 loEiPOtd.SizeBucket = lnSizeBucket
1754 loEiPOtd.Size_Desc = lnSize_desc
1755
1756 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1757 IF !EMPTY(lcIs_upcsku)
1758 loEiPOtd.Is_upcsku = lcIs_upcsku
1759 ENDIF
1760 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1761
1762 *--- TR 1019697 NH : clear rang style when bc style is set
1763 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1764 loEiPOtd.rng_style = ''
1765 loEiPOtd.rng_color = ''
1766 loEiPOtd.rng_lbl = ''
1767 loEiPOtd.rng_pack = ''
1768 Endif
1769 *=== TR 1019697 NH
1770 Endif
1771
1772 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1773 * only replace our SKU when no range style explosion happen
1774 *--- TechRec 1005163 17-May-2004 GS ---
1775 *If empty(&pceipoTD..rng_style)
1776 * Replace division With loEiPOtd.division, ;
1777 * style With loEiPOtd.style, ;
1778 * color_code With loEiPOtd.color_code, ;
1779 * lbl_code With loEiPOtd.lbl_code, ;
1780 * dimension With loEiPOtd.dimension, ;
1781 * sizebucket With loEiPOtd.sizebucket, ;
1782 * size_desc With loEiPOtd.size_desc, ;
1783 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1784 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1785 * In (pceipoTD)
1786 *Endif
1787 *- 1009508 3/16/05 YIK
1788 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1789 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1790 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1791 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1792 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1793
1794 Gather Name loEiPOtd Memo
1795 Endif
1796 *=== TechRec 1005163 17-May-2004 GS ===
1797
1798 Endscan
1799 Use In tmpCurs
1800
1801 If This.lUserInterface
1802 * Reset Thermometer
1803 This.ResetThermo()
1804 Endif
1805
1806 If Used("tmpCstdr")
1807 Use In tmpCstdr
1808 Endif
1809 If Used("tmpUpcnr")
1810 Use In tmpUpcnr
1811 ENDIF
1812
1813 *- 1040686
1814 USE IN SELECT("tcCustUpc")
1815 USE IN SELECT("tmpCstdr_upc")
1816 USE IN SELECT("tcDistUpc")
1817 USE IN SELECT("tmpUpcnr")
1818 *- 1040686
1819
1820 Select(lnOldSelect)
1821 Return llRetVal
1822 Endproc
1823
1824 *----------------------------------------------------------------------------------
1825
1826 *--- TR 1035223 NH
1827 PROCEDURE ClearErrorsForSkipSlnCheck
1828 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1829
1830 LOCAL llRetVal, lnOldSelect
1831 lnOldSelect = SELECT()
1832 llRetVal = .t.
1833
1834 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1835 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1836
1837 *--- TR 1038353 NH
1838 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'
1839 *=== TR 1038353 NH
1840
1841 Select(lnOldSelect)
1842 Return llRetVal
1843 Endproc
1844
1845 *----------------------------------------------------------------------------------
1846
1847 PROCEDURE SetupSkipSLNCheck
1848 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1849
1850 LOCAL lnOldSelect, llRetVal
1851 lnOldSelect = SELECT()
1852 llRetVal = .t.
1853 *--- take division from trans detail
1854 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
1855 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1856 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1857 inner join (pceipoCR) r on r.pkey = th.control_pkey ;
1858 WHERE th.customer > '' AND td.division > ''
1859
1860 *--- Setup in pceipoTS
1861 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1862 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1863
1864 Select(lnOldSelect)
1865 Return llRetVal
1866
1867 Endproc
1868 *=== TR 1035223 NH
1869
1870 *----------------------------------------------------------------------------------
1871
1872 *--- TR 1023892 NH
1873 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1874 PROCEDURE Populate_Cust_lbl
1875 LPARAMETERS pcTransHeader, pcTransDetail
1876 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1877 llRetVal = .t.
1878 lnOldSelect = SELECT()
1879 lcSQLString = ""
1880 lcFkeySku = ""
1881 lcCust_lbl = ""
1882
1883 *--- TR 1101199 16-Feb-2017 Goutam. added h.control_pkey
1884 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl, h.control_pkey ;
1885 FROM (pcTransHeader) h, (pcTransDetail) d ;
1886 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1887 and d.lbl_code = '' ;
1888 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1889
1890 IF RECCOUNT("__TmpCursor") = 0
1891 *-- no valid style to process
1892 this.LogEntry("No detail record found to populate customer label.")
1893 SELECT(lnOldSelect)
1894 RETURN llRetVal
1895 ENDIF
1896
1897 WITH this
1898 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1899 .cSQLTempTable = ""
1900 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1901 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1902 lcCustSku = "#CustSku" + SYS(2015)
1903
1904 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1905 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1906 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1907 *--- Used sc.Division instead of c.Division.
1908 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join anded add control_pkey in zzeipocr
1909 TEXT TO lcSQLString NOSHOW
1910 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1911 case when d.orig_lbl <> '' then d.orig_lbl
1912 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1913 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1914 else d.lbl_code end as cust_lbl
1915 FROM #Temp d INNER JOIN zzeipocr_expl c on d.control_pkey = c.pkey
1916 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1917 AND sc.style = d.style AND sc.color_code = d.color_code
1918 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1919 ENDTEXT
1920
1921 lcCustLbl = SYS(2015)
1922 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1923 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1924 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1925 IF llRetVal
1926 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1927 SELECT(pcTransDetail)
1928 lcZzeipotd_order = ORDER()
1929 SET ORDER TO fkeySku
1930 SELECT (lcCustLbl)
1931 SCAN
1932 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1933 lcCust_lbl = Cust_lbl
1934 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1935 SELECT(pcTransDetail)
1936 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1937 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1938 ENDSCAN
1939 ENDIF
1940 ENDSCAN
1941 SELECT(pcTransDetail)
1942 SET ORDER TO (lcZzeipotd_order)
1943 ENDIF
1944 ENDWITH
1945 SELECT(lnOldSelect)
1946 RETURN llRetVal
1947 ENDPROC
1948
1949 *-----------------------------------------------------------------------------------
1950 *=== TR 1023892 NH
1951
1952 ************************************************************************************
1953 * Validate EAN for all details
1954 * Created on 03/24/04 - BD- TR 1003801
1955 ************************************************************************************
1956 Procedure CheckEAN
1957 Lparameters pceipoTH, pceipoTD,;
1958 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1959 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1960
1961 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1962 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1963 lnSize_desc, llSLN
1964 llRetVal = .T.
1965 lcErrs_Msg= ""
1966 lnOldSelect = Select()
1967
1968 *--- TR 1061652 05/18/12 ATHIRUNAVU
1969 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1970 FROM (pceipocr) ;
1971 GROUP BY customer ;
1972 INTO CURSOR __ResvCustSKU
1973 *=== TR 1061652 05/18/12 ATHIRUNAVU
1974
1975 *- Check EAN only if customer is empty
1976 *--- TechRec 1005163 17-May-2004 GS ---
1977 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1978 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1979 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1980 *Order by h.customer, d.ean Into Cursor tmpCurs
1981
1982 *---- TR 1024667 NSD 5/31/07
1983 * If sizebucket = 0 then re-resolve.
1984
1985 If This.oHostProcess.lHaveSLN
1986 *--- TR 1061652 05/18/12 ATHIRUNAVU
1987 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1988 Select h.customer,;
1989 d.ean,;
1990 d.pkey, ;
1991 r.ResvCustSKU, ;
1992 (pceipoTD) As Src;
1993 FROM (pceipoTD) d ;
1994 JOIN (pceipoTH) h ;
1995 ON h.pkey = d.fkey ;
1996 JOIN __ResvCustSKU r ;
1997 ON r.Customer = H.Customer ;
1998 WHERE !Empty(d.ean) ;
1999 AND !Empty(h.customer) ;
2000 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
2001 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
2002 Union All ;
2003 SELECT h.customer,;
2004 s.SLN_EAN As ean,;
2005 s.pkey, ;
2006 r.ResvCustSKU, ;
2007 (pceipoTS) As Src;
2008 FROM (pceipoTD) d ;
2009 JOIN (pceipoTH) h ;
2010 ON h.pkey = d.fkey ;
2011 JOIN (pceipoTS) s ;
2012 ON s.fkey = d.pkey ;
2013 JOIN __ResvCustSKU r ;
2014 ON r.Customer = H.Customer ;
2015 WHERE !Empty(s.SLN_EAN) ;
2016 AND !Empty(h.customer) ;
2017 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
2018 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
2019 ORDER By 1, 2 ;
2020 INTO Cursor tmpCurs
2021 Else
2022 *--- TR 1061652 05/18/12 ATHIRUNAVU
2023 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
2024 Select h.customer,;
2025 d.ean,;
2026 d.pkey, ;
2027 r.ResvCustSKU, ;
2028 (pceipoTD) As Src;
2029 FROM (pceipoTD) d ;
2030 JOIN (pceipoTH) h ;
2031 ON h.pkey = d.fkey ;
2032 JOIN __ResvCustSKU r ;
2033 ON r.Customer = H.Customer ;
2034 WHERE !Empty(d.ean) ;
2035 AND !Empty(h.customer) ;
2036 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
2037 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
2038 Order By h.customer, d.ean ;
2039 INTO Cursor tmpCurs
2040 Endif
2041 *=== TechRec 1005163 17-May-2004 GS ===
2042
2043 lcOldCust = ""
2044 lcOldItem = ""
2045 Select tmpCurs
2046 If This.lUserInterface
2047 * Init Thermometer
2048 This.UpdateThermoCaption("Validating EAN(s)...")
2049 This.InitThermo(RecCount('tmpCurs'))
2050 l_nThermoCnt = 0
2051 Endif
2052 Scan
2053 If This.lUserInterface
2054 * Advance progress bar, if we're using one.
2055 l_nThermoCnt = l_nThermoCnt + 1
2056 This.AdvanceThermo(l_nThermoCnt)
2057 Endif
2058 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
2059 lcErrs_Msg = ""
2060 lcOldCust = tmpCurs.customer
2061 lcOldItem = tmpCurs.ean
2062 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
2063 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
2064
2065 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
2066 lcDivision = tmpCstdr.division
2067 lcStyle = tmpCstdr.Style
2068 lcColor_code = tmpCstdr.color_code
2069 lcLbl_code = tmpCstdr.lbl_code
2070 lcDimension = tmpCstdr.Dimension
2071 lnSizeBucket = tmpCstdr.size_bk
2072 lnSize_desc = tmpCstdr.size_desc
2073 Else
2074
2075 *--- TR 1061652 05/18/12 ATHIRUNAVU
2076 IF ResvCustSKU <> 'Y'
2077 *=== TR 1061652 05/18/12 ATHIRUNAVU
2078
2079 lcErrs_Msg = ""
2080 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
2081 lcDivision = tmpUpcnr.division
2082 lcStyle = tmpUpcnr.Style
2083 lcColor_code = tmpUpcnr.color_code
2084 lcLbl_code = tmpUpcnr.lbl_code
2085 lcDimension = tmpUpcnr.Dimension
2086 lnSizeBucket = tmpUpcnr.sizebucket
2087 lnSize_desc = tmpUpcnr.size_desc
2088 Else
2089 lcErrs_Msg = lcErrs_Msg + CRLF
2090 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
2091 Store 0 To lnSizeBucket
2092 Endif
2093
2094 *--- TR 1061652 05/18/12 ATHIRUNAVU
2095 ELSE
2096 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
2097 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
2098 STORE 0 TO lnSizeBucket
2099 ENDIF
2100 *=== TR 1061652 05/18/12 ATHIRUNAVU
2101
2102 Endif
2103 Endif && level break
2104
2105 *--- TechRec 1005163 17-May-2004 GS ---
2106 *Select (pceipoTD)
2107 llSLN = (tmpCurs.Src = pceipoTS)
2108 If llSLN
2109 Select (pceipoTS)
2110 Else
2111 Select (pceipoTD)
2112 Endif
2113 *=== TechRec 1005163 17-May-2004 GS ===
2114
2115 *- 1010682 04/25/05 YIK
2116 *- Locate For pkey = tmpCurs.pkey
2117 lnWorkArea = Select()
2118 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
2119 Scatter Name loEiPOtd Memo
2120 If !Empty(lcErrs_Msg)
2121 *--- TechRec 1005163 17-May-2004 GS ---
2122 If llSLN
2123 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
2124 loEiPOtd.Errs_Flg_S = "Y"
2125 Else
2126 *=== TechRec 1005163 17-May-2004 GS ===
2127 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
2128 loEiPOtd.Errs_Flg_D = "Y"
2129 Endif &&--- TechRec 1005163 17-May-2004 GS ===
2130 Endif
2131 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
2132 loEiPOtd.division = lcDivision
2133 loEiPOtd.Style = lcStyle
2134 loEiPOtd.color_code = lcColor_code
2135 loEiPOtd.lbl_code = lcLbl_code
2136 loEiPOtd.Dimension = lcDimension
2137 loEiPOtd.sizebucket = lnSizeBucket
2138 loEiPOtd.size_desc = lnSize_desc
2139 Endif
2140
2141 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
2142 * only replace our SKU when no range style explosion happen
2143 *--- TechRec 1005163 17-May-2004 GS ---
2144 *If empty(&pceipoTD..rng_style)
2145 * Replace division With loEiPOtd.division, ;
2146 * style With loEiPOtd.style, ;
2147 * color_code With loEiPOtd.color_code, ;
2148 * lbl_code With loEiPOtd.lbl_code, ;
2149 * dimension With loEiPOtd.dimension, ;
2150 * sizebucket With loEiPOtd.sizebucket, ;
2151 * size_desc With loEiPOtd.size_desc, ;
2152 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
2153 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
2154 * In (pceipoTD)
2155 *- 1009508 3/16/05 YIK
2156 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
2157 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
2158
2159 Gather Name loEiPOtd Memo
2160 *=== TechRec 1005163 17-May-2004 GS ===
2161 Endif
2162 Endscan
2163 Use In tmpCurs
2164
2165 If This.lUserInterface
2166 * Reset Thermometer
2167 This.ResetThermo()
2168 Endif
2169
2170 If Used("tmpCstdr")
2171 Use In tmpCstdr
2172 Endif
2173 If Used("tmpUpcnr")
2174 Use In tmpUpcnr
2175 Endif
2176
2177 Select(lnOldSelect)
2178 Return llRetVal
2179 Endproc
2180
2181 *-----------------------------------------------------------------------------------
2182
2183 *--- 39222 5/1/03 YIK
2184 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
2185 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
2186 *- matches the sku sent in transmission.
2187
2188 *--- TechRec 1005163 17-May-2004 GS:
2189 *- Combined ConfirmUPC and ConfirmEAN
2190
2191 Procedure ConfirmSku
2192 Lparameters pceipoTH, pceipoTD, pceipoCR,;
2193 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
2194
2195 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
2196 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
2197 lcSku, lcErrs_Msg, llSLN
2198
2199 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
2200 LOCAL lcCust_Size &&*--- TR 1101545 17-Jan-2017 Anupam ===*
2201 llRetVal = .T.
2202 lcErrs_Msg= ""
2203
2204 *--- TR 1085322 24-Sep-2015 Goutam
2205 LOCAL llCustStyleDupeCheck, llCustStyleFound,lcStyle, lcColor, lcLabel
2206 *=== TR 1085322 24-Sep-2015 Goutam
2207
2208 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2209 lcWarnMsg = ""
2210 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2211
2212 lnOldSelect = Select()
2213
2214 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
2215
2216 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
2217 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
2218 *- 1003788 2/25/04 YIK
2219 *- use d.division, not h.division which is still empty
2220
2221 *--- TechRec 1005163 17-May-2004 GS ---
2222 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2223
2224 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2225 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2226 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2227 *--- TR 1078000 16-4-2014 VKK Added cust_size
2228 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2229 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass, cust_size ;
2230 from (pceipoTD) Into Cursor __eipoTD
2231
2232 If This.oHostProcess.lHaveSLN
2233 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2234 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2235 *--- TR 1078000 16-4-2014 VKK Added cust_size
2236 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2237 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass, cust_size From (pceipoTS) Into Cursor __EiPOts
2238 Endif
2239 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2240 *--- NH - 08/10/07
2241 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2242 Select(lnOldSelect)
2243 RETURN llRetVal
2244 ENDIF
2245 *=== TR 1022625
2246
2247 With This
2248 .cSQLTempTable = ""
2249 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2250 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2251 lceipoTD_tmp = .cSQLTempTable
2252 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2253
2254 If This.oHostProcess.lHaveSLN
2255 .cSQLTempTable = ""
2256 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2257 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2258 lceipoTS_tmp = .cSQLTempTable
2259 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2260 Endif
2261 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2262 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2263 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2264 ENDWITH
2265
2266
2267 This.MakeCursorWritable("tmpCursR","tmpCurs")
2268 *=== TR 1019697 NH
2269 *=== TechRec 1005163 17-May-2004 GS ===
2270
2271 *-FH 1103931 - Grab sql from GetConfrimSkuSql, lets make a temp table from it.
2272 LOCAL lcTemptbl
2273 lcTemptbl = SQLTableFromQuery(lcSQL)
2274 *-FH 1103931
2275
2276 *--- TR 1085322 24-Sep-2015 Goutam
2277 * FH 1103931 - Let's use lcTemptbl, instead of lceipoTD_tmp( lceipoTD_tmp is all of DTL, lcTemptbl will only be confirm sku)
2278 *- - also add distinct
2279 IF llRetVal AND !EMPTY(lcTemptbl)
2280 lcSql = "select distinct b.cust_style, b.division, b.style, b.color_code, b.lbl_code, b.dimension, b.size_bk " +;
2281 " from " + lcTemptbl + " a join zzxcstdr b " +;
2282 " on a.sku = b.cust_style"
2283
2284 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpBCSKUCurs")
2285 IF llRetVal
2286 SELECT tmpBCSKUCurs
2287 INDEX on cust_style+division+style+color_code+lbl_code+dimension+STR(size_bk) TAG cust_style
2288 SET ORDER TO
2289 ENDIF
2290 ENDIF
2291 *=== TR 1085322 24-Sep-2015 Goutam
2292
2293 .LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2294 Select tmpCurs
2295 If This.lUserInterface
2296 * Init Thermometer
2297 This.UpdateThermoCaption("Comparing SKU(s)...")
2298 This.InitThermo(RecCount('tmpCurs'))
2299 l_nThermoCnt = 0
2300 Endif
2301 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2302 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2303 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2304 *=== TR 1019697 NH
2305
2306 *-1040686
2307 *=-=-=-=-=-=-=-=-=-=
2308 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2309 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2310 IF llRetVal
2311 .PopulateSQLTempTable("tcDistCustSku")
2312 ENDIF
2313 llRetVal = llRetVal AND v_sqlexec(;
2314 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2315 " , d.aux_sku, d.pkey, d.cust_size " +; &&*--- TR 1101545 19-Jan-2017 Anupam Added d.cust_size ===*
2316 " FROM zzxcstdr d"+ ;
2317 " JOIN " + this.cSQLTempTable + " x " + ;
2318 " ON d.customer = x.customer " +;
2319 " AND d.division = x.division " + ;
2320 " AND d.style = x.style " + ;
2321 " AND d.color_code = x.color_code " + ;
2322 " AND d.lbl_code = x.lbl_code " + ;
2323 " AND d.dimension = x.dimension " + ;
2324 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2325 SELECT tmpCstdr
2326 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2327 INDEX on cust_style TAG custsty && TR 1085322 KISHORE 22-SEP-2015
2328
2329 *=-=-=-=-=-=-=-=-=-=
2330
2331 * TR 1085322 KISHORE 12-MAR-2015
2332 llCustStyleDupeCheck = (goEnv.sv("CUST_STYLE_DUPE_CHECK","N") = "Y")
2333
2334 SELECT tmpCurs
2335 *- 1040686
2336
2337
2338 Local lnSizeBk
2339 lnSizeBk = 0
2340 SCAN
2341 llCustStyleFound = false &&*--- TR 1085322 24-Sep-2015 Goutam
2342
2343 If This.lUserInterface
2344 * Advance progress bar, if we're using one.
2345 l_nThermoCnt = l_nThermoCnt + 1
2346 This.AdvanceThermo(l_nThermoCnt)
2347 Endif
2348 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2349 lcErrs_Msg = ""
2350 *=== TechRec 1005163 17-May-2004 GS, YK ===
2351
2352 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2353 lcWarnMsg = ""
2354 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2355
2356 *-1040686
2357 *=-=-=-=-=-=-=-=-=-
2358 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2359 DIMENSION, sizebucket, "tmpCstdr")
2360 lcSku = ""
2361 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2362 lcSku = tmpCstdr.cust_style
2363 ELSE
2364 lcErrs_Msg = "Missing SKU code."
2365 ENDIF
2366 *=-=-=-=-=-=-=-=-=-
2367 *-1040686
2368
2369 *--- TR 1085322 24-Sep-2015 Goutam.
2370 *Note: Cust_sku must be unique in zzxcstdr if the system parameter CUST_STYLE_DUPE_CHECK = ‘Y’
2371 IF SEEK(tmpCurs.sku, "tmpBCSKUCurs", "cust_style")
2372 lcStyle = ALLTRIM(tmpBCSKUCurs.style)
2373 lcColor = ALLTRIM(tmpBCSKUCurs.color_code)
2374 lcLabel = ALLTRIM(tmpBCSKUCurs.lbl_code)
2375 IF llCustStyleDupeCheck AND !SEEK(tmpCurs.sku+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpBCSKUCurs", "cust_style")
2376 lcErrs_Msg = "Customer Style " + ALLTRIM(tmpCurs.sku) + " already exists for Style " + lcstyle + ", Color " + lcColor + " and label " + lcLabel
2377 llCustStyleFound = true
2378 ENDIF
2379
2380 *--- TR 1095258 04/28/16 ATHIRUNAVU Added tmpcurs.customer
2381 *IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2382 IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2383 *=== TR 1095258 04/28/16 ATHIRUNAVU
2384 Replace AddCustSKU With .T. In (tmpCurs.Src)
2385 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2386 llCustStyleFound = true
2387 *--- TR-1098891 4-Oct-2016 JPaul. lcErrs_Msg should be cleared
2388 lcErrs_Msg= ''
2389 *=== TR-1098891 4-Oct-2016 JPaul.
2390 ENDIF
2391 ENDIF
2392 *=== TR 1085322 24-Sep-2015 Goutam
2393
2394 IF !llCustStyleFound &&*--- TR 1085322 24-Sep-2015 Goutam
2395 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2396 lcCust_Size = tmpCstdr.cust_size &&*--- TR 1101545 17-Jan-2017 Anupam ===*
2397 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2398 If !(lcSku == tmpCurs.sku)
2399 * TR 1085322 KISHORE 12-MAR-2015 added OR Upd_CustSku = 'Y'
2400 If (Empty(lcSku) And GenCustSKU = 'Y') OR Upd_CustSku = 'Y'
2401 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2402
2403 *--- TR 1085322 24-Sep-2015 Goutam
2404 IF Upd_CustSku = 'Y'
2405 IF SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.Style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.DIMENSION+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku") ;
2406 AND (tmpCurs.SKU <> tmpCstdr.cust_style)
2407
2408 lcSQL = "Update zzxcstdr set cust_style = " + SQLFormatChar(tmpCurs.sku) + ;
2409 ", last_mod = " + SQLFormatTs(DATETIME()) + ", user_id = " + SQLFormatChar(EDI_USER) + ;
2410 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2411 llRetVal = llRetVal And v_SqlExec(lcSQL)
2412
2413 ELSE && FH 1103232 - what if I have upd_custsku = Y, but my sku coming in doesn't exists in cust style ref.
2414 && This IF assumes only add to cust style ref if Upd_CustSku is NOT Y.
2415 Replace AddCustSKU With .T. In (tmpCurs.Src)
2416 Replace AddCustSKU With 'Y' In tmpCurs
2417 ENDIF
2418 ELSE
2419 *=== TR 1085322 24-Sep-2015 Goutam
2420 Replace AddCustSKU With .T. In (tmpCurs.Src)
2421 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2422
2423 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2424
2425 lcErrs_Msg = ""
2426 Else
2427 If Confirm_SKU = 'Y'
2428 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2429 Else
2430 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2431 CRLF + "Unable to generate new customer Sku." + CRLF
2432 Endif
2433 ENDIF
2434 *--- TR 1061151 2-MAY-12 Venuk.
2435 Else
2436 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2437 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2438 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2439 v_SqlExec(lcSQL)
2440 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2441 ELSE
2442 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2443 lcWarnMsg = "Aux sku already exist."
2444 ENDIF
2445 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2446 ENDIF
2447 *=== TR 1061151 2-MAY-12 Venuk.
2448
2449 *--- TR 1101545 17-Jan-2017 Anupam ---*
2450 If empty(lcCust_Size) AND !EMPTY(tmpCurs.cust_size)
2451 lcSQL = "Update zzxcstdr set cust_size = " + SQLFormatChar(tmpCurs.cust_size) + ;
2452 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2453 v_SqlExec(lcSQL)
2454 ELSE
2455 IF !empty(lcCust_Size) AND !EMPTY(tmpCurs.cust_size) AND (lcCust_Size <> tmpCurs.cust_size)
2456 lcWarnMsg = "Customer Size already exist."
2457 ENDIF
2458 ENDIF
2459 *=== TR 1101545 17-Jan-2017 Anupam ===*
2460
2461 Endif
2462
2463 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2464
2465 *--- TechRec 1005163 17-May-2004 GS ---
2466 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2467 * Replace ;
2468 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2469 * Errs_Flg_D With "Y" ;
2470 * In (pceipoTD)
2471
2472 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2473 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2474 llSLN = (tmpCurs.Src = pceipoTS)
2475 If llSLN
2476 Select (pceipoTS)
2477 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2478 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2479 IF !EMPTY(lcErrs_Msg)
2480 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2481 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2482 Replace ;
2483 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2484 Errs_Flg_S With "Y"
2485 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2486 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2487 Errs_Flg_D With 'Y' In (pceipoTD)
2488 Endif
2489 ENDIF
2490 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2491 ELSE
2492 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2493 Warn_Flg_D With "Y" In (pceipoTD)
2494 ENDIF
2495 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2496 Else
2497 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2498 Select (pceipoTD)
2499 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2500 IF !EMPTY(lcErrs_Msg)
2501 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2502 Replace ;
2503 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2504 Errs_Flg_D With "Y"
2505 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2506 ELSE
2507 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2508 Warn_Flg_D With "Y"
2509 ENDIF
2510 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2511 Endif
2512 *=== TechRec 1005163 17-May-2004 GS ===
2513 Endif
2514 ENDSCAN
2515 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2516 *--- TR 1019697 NH :
2517 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2518 *=== TR 1019697 NH
2519 Use In tmpCurs
2520
2521 If This.lUserInterface
2522 * Reset Thermometer
2523 This.ResetThermo()
2524 Endif
2525
2526 If Used("tmpCstdr")
2527 Use In tmpCstdr
2528 ENDIF
2529
2530 *--- TR 1085322 24-Sep-2015 Goutam
2531 USE IN SELECT("tmpBCSKUCurs")
2532 *=== TR 1085322 24-Sep-2015 Goutam
2533
2534 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2535
2536 Select(lnOldSelect)
2537 Return llRetVal
2538 Endproc
2539
2540 *-----------------------------------------------------------------------------------
2541
2542 *--- TR 1019697 NH
2543 **************************************************************************************
2544 Procedure GetConfrimSkuSql
2545 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2546 Local lcSQL, lcSqlSln, lnOldSelect
2547 lnOldSelect = Select()
2548
2549 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2550 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2551
2552 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2553 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2554 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2555 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2556 *--- TR 1078000 16-4-2014 VKK Added cust_size
2557 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2558 lcSQL = ;
2559 "select d.customer"+;
2560 " , d.division"+;
2561 " , d.sku"+;
2562 " , d.STYLE"+;
2563 " , d.color_code"+;
2564 " , case"+;
2565 " when r.rng_style is null"+;
2566 " and d.lbl_code = ''"+;
2567 " and c.resv_label = 'Y' then c.lbl_code"+;
2568 " when r.rng_style is null"+;
2569 " and d.lbl_code = ''"+;
2570 " and c.resv_label = 'V'"+;
2571 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2572 " else d.lbl_code"+;
2573 " end as lbl_code"+;
2574 " , d.lbl_code as lbl_codeOrig"+;
2575 " , c.resv_label"+;
2576 " , d.DIMENSION"+;
2577 " , d.Sizebucket"+;
2578 " , d.upc"+;
2579 " , d.pkey"+;
2580 " , C.GenCustSKU"+;
2581 " , C.Confirm_SKU"+;
2582 " , C.upd_custsku " + ;
2583 " , 'N' as AddCustSKU"+;
2584 " , d.size_desc"+;
2585 " , '" + Trim(pceipoTD) + "' as Src"+;
2586 " , d.aux_sku " + ;
2587 " , d.subclass " + ;
2588 " , d.cust_size " + ;
2589 " from " + pceipoTD_tmp + " d"+;
2590 " join " + This.c850Control + " C"+;
2591 " on d.customer = C.customer"+;
2592 " and d.division = C.division"+;
2593 " left join zzxrangh r"+;
2594 " on r.division = d.division"+;
2595 " and r.rng_style = d.style"+;
2596 " and r.rng_color = d.color_code"+;
2597 " and r.rng_lbl = d.lbl_code"+;
2598 " and r.rng_pack = d.dimension"+;
2599 " left join zzxscolr sc"+;
2600 " on sc.division = d.division"+;
2601 " and sc.style = d.style"+;
2602 " and sc.color_code = d.color_code"+;
2603 " and sc.lbl_code = c.lbl_code"+;
2604 " and sc.dimension = d.dimension"+;
2605 " where d.customer > ''"+;
2606 " and d.SKU > ''"+;
2607 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2608 " and d.Division > ''"+;
2609 " and d.Style > ''"+;
2610 " and d.Color_Code > ''"+;
2611 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2612 " and d.Rng_Style = '' "
2613
2614 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2615 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2616 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2617 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2618 *--- Used sc.Division instead of c.Division.
2619 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2620 *--- TR 1078000 16-4-2014 VKK Added cust_size
2621 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2622 *- TR 1098656 FH - change to s.Division
2623 lcSqlSln = ;
2624 "select d.Customer"+;
2625 " , s.Division"+;
2626 " , s.SLN_SKU as sku"+;
2627 " , s.STYLE"+;
2628 " , s.Color_Code"+;
2629 " , case when s.Lbl_Code = ''"+;
2630 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2631 " when s.Lbl_Code = ''"+;
2632 " and c.Resv_Label = 'V'"+;
2633 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2634 " else s.lbl_code"+;
2635 " end as lbl_code"+;
2636 " , s.lbl_code as lbl_codeOrig"+;
2637 " , c.resv_label"+;
2638 " , s.DIMENSION"+;
2639 " , s.Sizebucket"+;
2640 " , s.SLN_UPC as upc"+;
2641 " , s.pkey"+;
2642 " , C.GenCustSKU"+;
2643 " , C.Confirm_SKU"+;
2644 " , C.upd_custsku " + ;
2645 " , 'N' as AddCustSKU"+;
2646 " , s.size_desc"+;
2647 " , '" + Trim(pceipoTS) + "' as Src"+;
2648 " , s.aux_sku " + ;
2649 " , s.subclass " + ;
2650 " , s.cust_size " + ;
2651 " from " + pceipoTD_tmp + " d"+;
2652 " join " + pceipoTS_tmp + " s"+;
2653 " on s.fkey = d.pkey"+;
2654 " join " + This.c850Control + " C"+;
2655 " on d.customer = C.customer"+;
2656 " and d.division = C.division"+;
2657 " left join zzxscolr sc"+;
2658 " on sc.division = d.division"+;
2659 " and sc.style = s.style"+;
2660 " and sc.color_code = s.color_code"+;
2661 " and sc.lbl_code = c.lbl_code"+;
2662 " and sc.dimension = s.dimension"+;
2663 " where d.Customer > ''"+;
2664 " and s.SLN_SKU > ''"+;
2665 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2666 " and d.Division > ''"+;
2667 " and s.Style > ''"+;
2668 " and s.Color_Code > ''"+;
2669 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2670 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2671 Endif
2672
2673 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2674 Select(lnOldSelect)
2675 Return lcSQL
2676 Endproc
2677
2678 *-----------------------------------------------------------------------------------
2679
2680 Procedure CreateOurSkuFromTmpCurs
2681 If Not Used("TmpCurs")
2682 Return .F.
2683 Endif
2684 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2685 llRetVal = .T.
2686 lnOldSelect = Select()
2687 With This
2688 Select tmpCurs
2689 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2690
2691 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2692 lcDistSku = Getuniquefilename()
2693 lcExistingSku = Getuniquefilename()
2694 lcCustLbl = Getuniquefilename()
2695
2696 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2697 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2698 *- We need this because cursor lcCustLbl has customer field.
2699 *- 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
2700 *- with auto_style = 'Y', we will add both auto_style twice.
2701
2702 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2703 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2704 *- because style exists in zzxscolr (we just addeded)
2705 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2706 *- so we will add it twice by accident.
2707
2708 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2709 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2710 *-FH 1066967
2711
2712
2713 *-FH 1066967 - added customer
2714 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2715 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2716 IF llRetVal
2717 .PopulateSQLTempTable(lcDistSku)
2718 ENDIF
2719
2720 llRetVal = llRetVal AND v_sqlexec(;
2721 "SELECT x.* "+;
2722 " FROM zzxscolr d"+ ;
2723 " JOIN " + this.cSQLTempTable + " x " + ;
2724 " ON d.division = x.division " +;
2725 " AND d.style = x.style " + ;
2726 " AND d.color_code = x.color_code " + ;
2727 " AND d.lbl_code = x.lbl_code " + ;
2728 " AND d.dimension = x.dimension " ,lcExistingSku )
2729 SELECT (lcExistingSku)
2730 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2731
2732 IF llRetVal
2733 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2734 ENDIF
2735
2736 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2737 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2738 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2739 SELECT(lcCustLbl)
2740 INDEX on customer + lbl_code TAG cust_lbl
2741
2742 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2743 SELECT (lcDistSku) && FH 1066967
2744 Scan
2745 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2746 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2747 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2748*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2749*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2750*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2751*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2752*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2753*!* Else
2754*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2755*!* Endif
2756*!* ENDIF
2757
2758 IF NOT EMPTY(&lcDistSku..lbl_code)
2759 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2760 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2761 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2762 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2763
2764 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2765 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2766 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2767 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2768
2769 .oLog.LogEntry("Created style: " + lcOurSKU )
2770 Else
2771 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2772 ENDIF
2773 ENDIF
2774 Endif
2775 ENDIF
2776
2777 ENDSCAN
2778 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2779
2780 USE IN SELECT(lcDistSku)
2781 USE IN SELECT(lcExistingSku)
2782 USE IN SELECT(lcCustLbl)
2783
2784 USE IN SELECT('lcStyleAdded') && FH 1066967
2785
2786 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2787 Endwith
2788 Select (lnOldSelect)
2789 Return llRetVal
2790 Endproc
2791
2792 *-----------------------------------------------------------------------------------
2793
2794 Procedure GenerateCustomerSkuFromCursor
2795 Parameters tcSkuCursor
2796 Local lnOldSelect, llRetVal
2797 llRetVal = .T.
2798 lnOldSelect = Select()
2799
2800 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2801 lcPrevSkuIpotd = ""
2802 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2803 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2804 *--- TR 1078000 16-4-2014 VKK Added cust_size
2805 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2806 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2807 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2808 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2809
2810 With This
2811 lnCount = Reccount("tmpCurs1")
2812
2813 If lnCount = 0
2814 Select (lnOldSelect)
2815 Return
2816 Endif
2817
2818 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2819 Select (lnOldSelect)
2820 Return
2821 Endif
2822
2823 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2824 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2825 lnCount = lnCount - 1
2826 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2827 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2828
2829 Select VZZXCSTHR
2830 Scatter Memvar Blank
2831 Select VZZXCSTDR
2832 Scatter Memvar Blank
2833
2834 m.Last_mod = Datetime()
2835 m.User_id = 'CGSADMIN'
2836 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2837
2838 * --- TR 1039603 4/6/09 CM
2839 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2840 m.active_ok = 'Y'
2841 m.anti_theft = 'N'
2842 * === TR 1039603 4/6/09 CM
2843
2844 m.notes = ''
2845
2846 lcPrevSKU = ' '
2847
2848 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2849 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2850 Select("tmpCursSrc")
2851 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2852 Scan
2853 Select (Alltrim(tmpCursSrc.Src))
2854 lcOldOrder = Order()
2855 Set Order To CstBcSku
2856 Replace oldOrder With lcOldOrder In tmpCursSrc
2857 ENDSCAN
2858 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2859
2860 Select tmpCurs1
2861 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2862 Scan
2863 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2864 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2865 *--- TR 1078000 16-4-2014 VKK Added cust_size
2866 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2867 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2868 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2869 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2870 If lcPrevSKU # lcSku
2871 lcPrevSKU = lcSku
2872 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2873 If Empty(lnHDRpKey)
2874 lnHDRpKey = lnCstHrPkey
2875 Insert Into VZZXCSTHR From Memvar
2876 Replace pkey With lnHDRpKey In VZZXCSTHR
2877 Endif
2878 Endif
2879 *--- clear AddCustSKU for all matching rows in zzeipotd
2880 Select (tmpCurs1.Src)
2881 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2882 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2883 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2884 Endscan
2885 lcPrevSkuIpotd = lcSkuIpotd
2886
2887 *-TR 1059834 FH -moved in IF statement
2888 Select tmpCurs1
2889 Insert Into VZZXCSTDR From Memvar
2890 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2891 lnCstDrPkey = lnCstDrPkey +1
2892 lnCstHrPkey = lnCstHrPkey +1
2893 *-TR 1059834 FH -moved in IF statement
2894
2895 Endif
2896 ENDSCAN
2897 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2898 Select("tmpCursSrc")
2899 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2900 Scan
2901 Select (Alltrim(tmpCursSrc.Src))
2902 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2903* If Not Empty(lcOldOrder)
2904 Set Order To (lcOldOrder)
2905* Endif
2906 ENDSCAN
2907 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2908 Use In tmpCursSrc
2909
2910 Dimension laTables[2]
2911 laTables[1]= "VZZXCSTHR"
2912 laTables[2]= "VZZXCSTDR"
2913
2914 llBeganTransaction = .BeginTransaction()
2915 llRetVal = .Tableupdate(@laTables)
2916
2917 If llRetVal
2918 If llBeganTransaction
2919 This.EndTransaction()
2920 Endif
2921 Else
2922 If llBeganTransaction
2923 This.RollbackTransaction()
2924 Endif
2925 Endif
2926 Endwith
2927 If Used("tmpCurs1")
2928 Use In tmpCurs1
2929 Endif
2930 Select(lnOldSelect)
2931 Return llRetVal
2932 Endproc
2933
2934 *-----------------------------------------------------------------------------------
2935 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2936
2937 Function GenerateRBACustSKU
2938 Lparameters pceipoTH,pceipoTD
2939
2940 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2941 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2942
2943
2944 llRetVal = True
2945 lnSelect = Select()
2946 lcRBADivision = 'TFG'
2947 With This
2948
2949 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2950
2951 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2952 *- 12/12/06 YIK
2953 *- No distinct since includes pkey. Change order.
2954 *-- SELECT DISTINCT ;
2955 *-- h.customer,;
2956 *-- lcRBADivision as division,;
2957 *-- d.pkey as dtlpkey ,;
2958 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2959 *-- d.color_code,;
2960 *-- .GetCustLabel(h.customer) as lbl_code,;
2961 *-- "" as DIMENSION,;
2962 *-- h.store as cust_store ,;
2963 *-- d.sku as cust_style ,;
2964 *-- d.price as cust_price , ;
2965 *-- d.size_desc, ;
2966 *-- 0 as size_bk ;
2967 *-- FROM (pceipoTH) h ;
2968 *-- JOIN (pceipoTD) d ;
2969 *-- ON d.fkey = h.pkey ;
2970 *-- INTO CURSOR __tmpCur ;
2971 *-- ORDER BY 1,2,3,4,5,6
2972
2973 *** Size_BK needs to be 00 and NOT 0
2974 Select ;
2975 h.customer,;
2976 lcRBADivision As division,;
2977 d.pkey As dtlpkey ,;
2978 d.Style As Style, ;
2979 d.color_code,;
2980 .GetCustLabel(h.customer) As lbl_code,;
2981 "" As Dimension,;
2982 h.Store As cust_store ,;
2983 d.sku As Cust_style ,;
2984 d.price As cust_price , ;
2985 d.size_desc, ;
2986 00 As size_bk ;
2987 FROM (pceipoTH) h ;
2988 JOIN (pceipoTD) d ;
2989 ON d.fkey = h.pkey ;
2990 WHERE h.Errs_flg_h < 'Y' And ;
2991 d.Errs_Flg_D < 'Y' ;
2992 INTO Cursor __tmpCur ;
2993 ORDER By 1,2,4,5,6,7, 11
2994 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2995
2996 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2997
2998 lnCount = Reccount("tmpCurs")
2999
3000 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
3001
3002 If lnCount = 0
3003 If Used("tmpCurs")
3004 Use In tmpCurs
3005 Endif
3006 Select (lnSelect)
3007 Return
3008 Endif
3009
3010 Select tmpCurs
3011 *
3012 * Make it a loop for safety
3013 *
3014 Scan
3015 *** .LogEntry("Original Style " + style)
3016 lcStyle = .GetBCStyle(lcRBADivision,Style)
3017 *** .LogEntry("Resolved Style " + lcStyle)
3018 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
3019 Replace Style With lcStyle , size_bk With lnSize_BK
3020 Endscan
3021 .LogEntry("Resolved Styles/Size_BK")
3022
3023 *- 12/12/06 YIK
3024 *- Index just in case somebody changes the SELECT above
3025 Select tmpCurs
3026 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
3027 TAG sku
3028
3029 .LogEntry("Load Customer Style.")
3030
3031 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
3032 If Used("tmpCurs")
3033 Use In tmpCurs
3034 Endif
3035 Select (lnSelect)
3036 Return
3037 Endif
3038
3039 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
3040 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
3041 lnCount = lnCount - 1
3042 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
3043 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
3044
3045 Select VZZXCSTHR
3046 Scatter Memvar Blank
3047 Select VZZXCSTDR
3048 Scatter Memvar Blank
3049
3050 m.Last_mod = Datetime()
3051 m.User_id = 'CGSADMIN'
3052 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
3053 m.notes = ''
3054
3055 lcPrevSKU = ' '
3056 lcPrevSkuSize = ''
3057
3058 *- 12/12/06 YIK
3059 *- inserted details counter
3060 Local lnInsertCount
3061 lnInsertCount = 0
3062
3063 Select tmpCurs
3064
3065 Scan
3066 .LogEntry("Loading Customer Style...")
3067 .LogEntry("Style :" + Style )
3068 .LogEntry("Color_code :" + color_code )
3069
3070 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
3071 .LogEntry("Invalid Style or Color_code or Size_bk " )
3072 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
3073 FOR pkey = dtlpkey In (pceipoTD)
3074 Loop
3075 Endif
3076
3077 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
3078 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
3079 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
3080 If lcPrevSKU # lcSku
3081 lcPrevSKU = lcSku
3082 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
3083 .LogEntry("Customer :" + m.customer )
3084 .LogEntry("Division : " + m.division)
3085 .LogEntry("Style :" + Style )
3086 .LogEntry("Color_code :" + m.color_code )
3087 .LogEntry("Label code :" + m.lbl_code )
3088 .LogEntry("dimension : " + m.dimension)
3089 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
3090 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
3091 If Empty(lnHDRpKey)
3092 lnHDRpKey = lnCstHrPkey
3093 .LogEntry("Inserting into header..")
3094 Insert Into VZZXCSTHR From Memvar
3095 Replace pkey With lnHDRpKey In VZZXCSTHR
3096 Endif
3097 Endif
3098 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
3099 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
3100 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
3101 If Empty(lnDtlKey)
3102 lnDtlpKey = lnCstDrPkey
3103 .LogEntry("Inserting into detail..")
3104 Insert Into VZZXCSTDR From Memvar
3105 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
3106 *- 12/12/06 YIK
3107 lnInsertCount = lnInsertCount + 1
3108 Endif
3109 Endif
3110 lnCstDrPkey = lnCstDrPkey +1
3111 lnCstHrPkey = lnCstHrPkey +1
3112
3113 Endscan
3114
3115 Dimension laTables[2]
3116 laTables[1]= "VZZXCSTHR"
3117 laTables[2]= "VZZXCSTDR"
3118
3119 llBeganTransaction = .BeginTransaction()
3120 llRetVal = .Tableupdate(@laTables)
3121
3122 If llRetVal
3123 If llBeganTransaction
3124 This.EndTransaction()
3125 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
3126 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
3127 Endif
3128 Else
3129 If llBeganTransaction
3130 This.RollbackTransaction()
3131 .LogEntry("Table Update failed - Roll back Transaction " )
3132 Endif
3133 Endif
3134
3135 Endwith
3136
3137 If Used("tmpCurs")
3138 Use In tmpCurs
3139 Endif
3140
3141 Select (lnSelect)
3142 Return llRetVal
3143 Endfunc
3144
3145 *-----------------------------------------------------------------------------------
3146
3147 Function GetBCStyle
3148 Lparameters tcDivision, tcUDFStyle
3149 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
3150
3151 llRetVal = True
3152 lnSelect = Select()
3153 l_vRetVal = ''
3154
3155 lcCursor = GetUniqueFileName()
3156 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
3157 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
3158
3159 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
3160
3161 If llRetVal
3162 Select(lcCursor)
3163 l_vRetVal = Alltrim(Style)
3164 Use In (lcCursor)
3165 Endif
3166
3167 Select (lnSelect)
3168 Return l_vRetVal
3169 Endfunc
3170
3171 *-----------------------------------------------------------------------------------
3172
3173 Function GetSizeBkt
3174 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
3175 p_cKeyField4, p_cKeyField5, p_cKeyField6
3176 Local l_cSQLString, l_vRetVal
3177
3178 l_nOldSele = Select()
3179 pnSizeBucket = 0
3180
3181 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
3182 l_vRetVal = 0
3183 Return l_vRetVal
3184 Endif
3185
3186 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
3187 p_cKeyField2)
3188 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
3189 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
3190 p_cKeyField3, p_cKeyField4, p_cKeyField5)
3191 Select TmpSavlr
3192 For l_n=1 To 24
3193 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
3194 If l_lAlwSz
3195 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
3196 If l_cSize_Desc = p_cKeyField6
3197 ***l_vRetVal = .T.
3198 pnSizeBucket = l_n
3199 Endif
3200 Endif
3201 Endfor
3202 Use In TmpSavlr
3203 Use In TmpSizer
3204 Endif
3205 Endif
3206
3207 l_vRetVal = pnSizeBucket
3208
3209 Select (l_nOldSele)
3210 Return l_vRetVal
3211
3212 Endfunc
3213
3214 *-----------------------------------------------------------------------------------
3215 * Validate SKU for all details
3216 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
3217
3218 Procedure CheckSku
3219 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
3220 Lparameters pceipoTH, pceipoTD,;
3221 pceipoTS, pceipoCR
3222 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
3223 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
3224 lnSize_desc, llSLN
3225
3226 *--- TR 1013117 NH
3227 Local lcSku_resolv
3228 Dimension lasku_resolv[1]
3229 lcSku_resolv = ""
3230 lasku_resolv[1] = ""
3231 *=== TR 1013117 NH
3232
3233 * --- TR 1045305 2/3/10 CM
3234 LOCAL lnSkuPkey
3235 lnSkuPkey = 0
3236 * === TR 1045305 2/3/10 CM
3237
3238
3239 llRetVal = .T.
3240 lcErrs_Msg= ""
3241 lnOldSelect = Select()
3242
3243 * cannot check for SKU if customer is empty
3244 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
3245 * on Cust SKU or UPC.
3246 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
3247
3248 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
3249 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
3250 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
3251
3252 *--- TechRec 1005163 17-May-2004 GS ---
3253 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
3254 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
3255 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
3256 *Order by h.customer, d.sku Into Cursor tmpCurs
3257
3258 *---- TR 1024667 NSD 5/31/07
3259 * If sizebucket = 0 then re-resolve.
3260
3261 If This.oHostProcess.lHaveSLN
3262 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3263 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3264 *!* SELECT h.customer,;
3265 *!* c.sku_resolv, ;
3266 *!* JOIN (pceipoCR) C;
3267 *!* ON d.division= C.division ;
3268 *!* AND h.customer= C.customer ;
3269
3270 *!* c.sku_resolv, ; && after union
3271 *!* JOIN (pceipoCR) C;
3272 *!* ON d.division= C.division ;
3273 *!* AND h.customer= C.customer ;
3274
3275 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3276 Select h.customer,;
3277 h.department, ;
3278 h.Store, ;
3279 d.sku,;
3280 d.upc, ;
3281 d.pkey, ;
3282 (pceipoTD) As Src ;
3283 FROM (pceipoTD) d ;
3284 JOIN (pceipoTH) h ;
3285 ON h.pkey = d.fkey ;
3286 WHERE !Empty(h.customer) ;
3287 AND !Empty(d.sku) ;
3288 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
3289 UNION All ;
3290 SELECT h.customer,;
3291 h.department, ;
3292 h.Store, ;
3293 s.SLN_SKU As sku,;
3294 s.SLN_UPC As upc,;
3295 s.pkey, ;
3296 (pceipoTS) As Src ;
3297 FROM (pceipoTS) s ;
3298 JOIN (pceipoTD) d ;
3299 ON d.pkey = s.fkey ;
3300 JOIN (pceipoTH) h ;
3301 ON h.pkey = d.fkey ;
3302 WHERE !Empty(h.customer) ;
3303 AND !Empty(s.SLN_SKU) ;
3304 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
3305 ORDER By 1, 2 ;
3306 INTO Cursor tmpCurs
3307 *=== TR 1010097 07/27/05 TK
3308 Else
3309 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3310 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3311 *!* SELECT h.customer,;
3312 *!* c.sku_resolv, ;
3313 *!* JOIN (pceipoCR) C;
3314 *!* ON d.division= C.division ;
3315 *!* AND h.customer= C.customer ;
3316 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3317 Select h.customer,;
3318 h.department, ;
3319 h.Store, ;
3320 d.sku,;
3321 d.upc, ;
3322 d.pkey, ;
3323 (pceipoTD) As Src ;
3324 FROM (pceipoTD) d ;
3325 JOIN (pceipoTH) h ;
3326 ON h.pkey = d.fkey ;
3327 WHERE !Empty(h.customer) ;
3328 AND !Empty(d.sku) ;
3329 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3330 Order By h.customer, d.sku ;
3331 INTO Cursor tmpCurs
3332 *=== TR 1010097 07/27/05 TK
3333 Endif
3334 *=== TechRec 1005163 17-May-2004 GS ===
3335
3336*- 1040686
3337 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3338 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3339 IF llRetVal
3340 .PopulateSQLTempTable("tcDistCustSku")
3341 ENDIF
3342 llRetVal = llRetVal AND v_sqlexec(;
3343 "SELECT x.sku,d.* "+;
3344 " FROM zzxcstdr d"+ ;
3345 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3346 " JOIN " + this.cSQLTempTable + " x " + ;
3347 " ON d.customer = x.customer " +;
3348 " AND d.cust_style = x.sku " + ;
3349 " WHERE h.IB_resolv = 'Y'" + ;
3350 " AND d.Size_Desc>'' " + ;
3351 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3352 SELECT tmpCstdr_sku
3353 INDEX ON customer + cust_style TAG cust_sku
3354
3355 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3356 UNION ;
3357 SELECT customer,sku FROM tmpCstdr_sku ;
3358 GROUP BY customer,sku ;
3359 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3360 INDEX ON customer+sku TAG cust_sku
3361 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3362*- 1040686
3363
3364
3365 lcOldCust = ""
3366 lcOldItem = ""
3367 lcOldSku_resolv = ""
3368 Select tmpCurs
3369 If This.lUserInterface
3370 * Init Thermometer
3371 This.UpdateThermoCaption("Validating SKU(s)...")
3372 * TAN 31891 - JAZ - 5/20/02
3373 * This.InitThermo(RECC('tmpCurs'))
3374 This.InitThermo(RecCount('tmpCurs'))
3375 * End TAN 31891 - JAZ - 5/20/02
3376 l_nThermoCnt = 0
3377 Endif
3378 SCAN
3379 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3380 *-- Skip sku resolution
3381 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3382 LOOP
3383 ENDIF
3384 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3385
3386 If This.lUserInterface
3387 * Advance progress bar, if we're using one.
3388 l_nThermoCnt = l_nThermoCnt + 1
3389 This.AdvanceThermo(l_nThermoCnt)
3390 Endif
3391
3392 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3393 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3394 *--- TR 1013117 NH 20050908
3395 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3396 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3397 *=== TR 1013117 NH 20050908
3398 *=== TR 1010097 07/27/05 TK
3399
3400 *---TR 1037976 JAN-07-08 BR
3401 IF !(tmpCurs.customer == lcOldCust)
3402 lcCustomer = tmpCurs.customer
3403 IF SEEK(lcCustomer,pceipocr,"customer")
3404 lcSku_resolv = &pceipocr..sku_resolv
3405 ENDIF
3406 ENDIF
3407 *===TR 1037976 JAN-07-08 BR
3408
3409 lcErrs_Msg = ""
3410 lcOldCust = tmpCurs.customer
3411 lcOldItem = tmpCurs.sku
3412 *--- TR 1013117 NH
3413 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3414 *=== TR 1013117 NH
3415
3416 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3417
3418
3419
3420 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3421 *--- TR 1013117 NH 20050908
3422 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3423 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3424
3425 *- 1040686 - COMMENT
3426*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3427*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3428*!* *=== TR 1013117 NH 20050908
3429*!* *--- TR 1010097 07/27/05 TK
3430
3431*!* lcDivision = tmpCstdr.division
3432*!* lcStyle = tmpCstdr.Style
3433*!* lcColor_code = tmpCstdr.color_code
3434*!* lcLbl_code = tmpCstdr.lbl_code
3435*!* lcDimension = tmpCstdr.Dimension
3436*!* lnSizeBucket = tmpCstdr.size_bk
3437*!* lnSize_desc = tmpCstdr.size_desc
3438*!*
3439*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3440*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3441*!* If tmpCstdr.fkey > 0
3442*!* lnSkuPkey = tmpCstdr.fkey
3443*!* Endif
3444*!* * === TR 1045305 2/3/10 CM
3445*!*
3446*!*
3447*!* Else
3448*!* lcErrs_Msg = lcErrs_Msg + CRLF
3449*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3450*!* Store 0 To lnSizeBucket
3451*!* Endif
3452
3453 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3454 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3455 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3456 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3457 Store 0 To lnSizeBucket
3458 ELSE
3459 *- TR 1074276 FH - adding UPPER()
3460 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3461 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3462 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3463 Store 0 To lnSizeBucket
3464 ELSE
3465 lcDivision = tmpCstdr_sku.division
3466 lcStyle = tmpCstdr_sku.Style
3467 lcColor_code = tmpCstdr_sku.color_code
3468 lcLbl_code = tmpCstdr_sku.lbl_code
3469 lcDimension = tmpCstdr_sku.Dimension
3470 lnSizeBucket = tmpCstdr_sku.size_bk
3471 lnSize_desc = tmpCstdr_sku.size_desc
3472
3473 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3474 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3475 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3476 If tmpCstdr_sku.fkey > 0
3477 lnSkuPkey = tmpCstdr_sku.fkey
3478 Endif
3479 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3480 *!* * === TR 1045305 2/3/10 CM
3481
3482 ENDIF
3483 ENDIF
3484*- 1040686 - COMMENT
3485
3486 Endif && level break
3487
3488 *--- TechRec 1005163 17-May-2004 GS ---
3489 *Select (pceipoTD)
3490 llSLN = (tmpCurs.Src = pceipoTS)
3491 If llSLN
3492 Select (pceipoTS)
3493 Else
3494 Select (pceipoTD)
3495 Endif
3496 *!* Locate For pkey = tmpCurs.pkey
3497 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3498 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3499 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3500 *=== TechRec 1005163 17-May-2004 GS ===
3501 Scatter Name loEiPOtd Memo
3502 If !Empty(lcErrs_Msg)
3503 *--- TechRec 1005163 17-May-2004 GS ---
3504 If llSLN
3505 *- 1008827 04/22/05 YIK
3506 *- correct a typo
3507 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3508
3509 loEiPOtd.Errs_Flg_S = "Y"
3510 Else
3511 *=== TechRec 1005163 17-May-2004 GS ===
3512 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3513 loEiPOtd.Errs_Flg_D = "Y"
3514 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3515 Endif
3516 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3517 loEiPOtd.division = lcDivision
3518 loEiPOtd.Style = lcStyle
3519 loEiPOtd.color_code = lcColor_code
3520 loEiPOtd.lbl_code = lcLbl_code
3521 loEiPOtd.Dimension = lcDimension
3522 loEiPOtd.sizebucket = lnSizeBucket
3523 loEiPOtd.size_desc = lnSize_desc
3524
3525 * --- TR 1045305 2/3/10 CM
3526 loEiPOtd.sku_pkey = lnSkuPkey
3527 * === TR 1045305 2/3/10 CM
3528
3529 Endif
3530
3531 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3532 * only replace our SKU when no range style explosion happen
3533 *--- TechRec 1005163 17-May-2004 GS ---
3534 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3535 * Replace division With loEiPOtd.division, ;
3536 * style With loEiPOtd.style, ;
3537 * color_code With loEiPOtd.color_code, ;
3538 * lbl_code With loEiPOtd.lbl_code, ;
3539 * dimension With loEiPOtd.dimension, ;
3540 * sizebucket With loEiPOtd.sizebucket, ;
3541 * size_desc With loEiPOtd.size_desc, ;
3542 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3543 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3544 * In (pceipoTD)
3545 *- 1009508 3/16/05 YIK
3546 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3547 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3548 Gather Name loEiPOtd Memo
3549 *=== TechRec 1005163 17-May-2004 GS ===
3550 Endif
3551
3552 *=== TechRec 1005163 17-May-2004 GS ===
3553 Endif
3554 Endscan
3555 Use In tmpCurs
3556
3557 If This.lUserInterface
3558 * Reset Thermometer
3559 This.ResetThermo()
3560 Endif
3561
3562 If Used("tmpCstdr")
3563 Use In tmpCstdr
3564 ENDIF
3565
3566 *-1040686
3567 USE IN SELECT("tcDistCustSku")
3568 USE IN SELECT("tmpCstdr_sku")
3569 USE IN SELECT("tcAmbigSku")
3570 *-1040686
3571
3572 Select(lnOldSelect)
3573 Return llRetVal
3574 Endproc
3575
3576 *-----------------------------------------------------------------------------------
3577 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3578 PROCEDURE PopulateOrigLabel
3579 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3580 LOCAL llRetVal, lnOldSelect
3581 lnOldSelect = SELECT()
3582
3583 SELECT (pceipoTD)
3584 *-TR FH 1093621 - Push then pop
3585 .PushRecordSet()
3586
3587 SELECT d.pkey ;
3588 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3589 WHERE c.accept_lbl = 'Y' and ;
3590 c.customer = h.customer and ;
3591 c.division = d.division and ;
3592 h.pkey = d.fkey and ;
3593 h.errs_flg_h <> 'Y' and ;
3594 d.errs_flg_d <> 'Y' ;
3595 ORDER BY d.pkey ;
3596 INTO CURSOR 'cursTmpTD'
3597
3598 Index On pkey Tag pkey
3599
3600 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3601
3602 goto top in "cursTmpTD"
3603
3604 If llRetVal AND !EOF('cursTmpTD')
3605 SELECT (pceipoTD)
3606 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3607 In (pceipoTD)
3608 Endif
3609
3610 *-TR FH 1093621 - Push then pop
3611 .PopRecordSet()
3612
3613 Set Relation to
3614 USE IN 'cursTmpTD'
3615 SELECT (lnOldSelect)
3616 RETURN llRetVal
3617 ENDPROC
3618 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3619 *-----------------------------------------------------------------------------------
3620
3621 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3622 Procedure ConfirmUPC
3623 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3624
3625 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3626 lcUPC, lcErrs_Msg, llSLN
3627
3628 llRetVal = .T.
3629 lcErrs_Msg= ""
3630 lnOldSelect = Select()
3631
3632 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3633
3634 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3635
3636 *--- TR 1101199 16-Feb-2017 Goutam. Deleted following sql and Added pceipoth and h.control_pkey in next sql
3637 *Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3638 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3639 from (pceipoTD) Into Cursor __eipoTD
3640
3641 Select d.customer, d.division, d.sku, d.Style, d.color_code, d.lbl_code, d.Dimension, ;
3642 d.sizebucket, d.upc, d.ean, d.pkey, d.size_desc, d.rng_style, h.control_pkey ;
3643 from (pceipoTD) d JOIN (pceipoTH) h ON h.pkey = d.fkey Into Cursor __eipoTD
3644 *=== TR 1101199 16-Feb-2017 Goutam
3645
3646 If This.oHostProcess.lHaveSLN
3647 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3648 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3649 Endif
3650
3651 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3652 Select(lnOldSelect)
3653 Return llRetVal
3654 Endif
3655
3656 With This
3657 .cSQLTempTable = ""
3658 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3659 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3660 lceipoTD_tmp = .cSQLTempTable
3661 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3662
3663 If This.oHostProcess.lHaveSLN
3664 .cSQLTempTable = ""
3665 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3666 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3667 lceipoTS_tmp = .cSQLTempTable
3668 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3669 Endif
3670 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3671 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3672 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3673 Endwith
3674
3675
3676 This.MakeCursorWritable("tmpCursR","tmpCurs")
3677
3678 Select tmpCurs
3679 If This.lUserInterface
3680 * Init Thermometer
3681 This.UpdateThermoCaption("Comparing UPC(s)...")
3682 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3683 l_nThermoCnt = 0
3684 Endif
3685
3686
3687*- 1040686
3688 *=-=-=-=-=-=-=-=-=-=
3689 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3690 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3691 IF llRetVal
3692 .PopulateSQLTempTable("tcDistUpc")
3693 ENDIF
3694 llRetVal = llRetVal AND v_sqlexec(;
3695 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3696 " FROM zveupcnr d"+ ;
3697 " JOIN " + this.cSQLTempTable + " x " + ;
3698 " ON d.division = x.division " + ;
3699 " AND d.style = x.style " + ;
3700 " AND d.color_code = x.roll_color " + ;
3701 " AND d.lbl_code = x.lbl_code " + ;
3702 " AND d.dimension = x.dimension " + ;
3703 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3704 SELECT tmpCstdr
3705 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3706 *=-=-=-=-=-=-=-=-=-=
3707 SELECT tmpCurs
3708
3709*- 1040686
3710 Local lnSizeBk
3711 lnSizeBk = 0
3712 Scan
3713 If This.lUserInterface
3714 * Advance progress bar, if we're using one.
3715 l_nThermoCnt = l_nThermoCnt + 1
3716 This.AdvanceThermo(l_nThermoCnt)
3717 Endif
3718
3719 lcErrs_Msg = ""
3720
3721 *- 1040686
3722 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3723 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3724 DIMENSION, sizebucket, "tmpCstdr")
3725 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3726 DIMENSION, sizebucket, "tmpCstdr")
3727
3728 lcUPC = ""
3729 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3730 lcErrs_Msg = "Missing UPC number."
3731 ELSE
3732 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3733 ENDIF
3734
3735 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3736 *-1040686
3737
3738 If !(lcUPC == tmpCurs.UPC)
3739 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3740 Endif
3741
3742 If !Empty(lcErrs_Msg)
3743 llSLN = (tmpCurs.Src = pceipoTS)
3744 If llSLN
3745 Select (pceipoTS)
3746 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3747 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3748 Replace ;
3749 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3750 Errs_Flg_S With "Y"
3751 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3752 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3753 Errs_Flg_D With 'Y' In (pceipoTD)
3754 Endif
3755 ENDIF &&--- TR 1035223 NH
3756 Else
3757 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3758 Select (pceipoTD)
3759 Replace ;
3760 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3761 Errs_Flg_D With "Y"
3762 Endif
3763 Endif
3764 Endscan
3765
3766 Use In tmpCurs
3767
3768 If This.lUserInterface
3769 * Reset Thermometer
3770 This.ResetThermo()
3771 Endif
3772
3773 If Used("tmpCstdr")
3774 Use In tmpCstdr
3775 ENDIF
3776
3777 USE IN SELECT("tcDistUpc") &&1040686
3778
3779 Select(lnOldSelect)
3780 Return llRetVal
3781 ENDPROC
3782
3783 *-----------------------------------------------------------------------------------
3784
3785 Procedure GetConfrimUPCSql
3786 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3787 Local lcSql, lcSqlSln, lnOldSelect
3788 lnOldSelect = Select()
3789
3790 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3791 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3792 * this is a straight join and not a date resolution.
3793 lcSql = ;
3794 "select d.customer"+;
3795 " , d.division"+;
3796 " , d.sku"+;
3797 " , d.STYLE"+;
3798 " , d.color_code"+;
3799 " , case"+;
3800 " when r.rng_style is null"+;
3801 " and d.lbl_code = ''"+;
3802 " and c.resv_label = 'Y' then c.lbl_code"+;
3803 " when r.rng_style is null"+;
3804 " and d.lbl_code = ''"+;
3805 " and c.resv_label = 'V'"+;
3806 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3807 " else d.lbl_code"+;
3808 " end as lbl_code"+;
3809 " , d.lbl_code as lbl_codeOrig"+;
3810 " , c.resv_label"+;
3811 " , d.DIMENSION"+;
3812 " , d.Sizebucket"+;
3813 " , d.upc"+;
3814 " , d.pkey"+;
3815 " , C.Confirm_UPC"+;
3816 " , d.size_desc"+;
3817 " , '" + Trim(pceipoTD) + "' as Src"+;
3818 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3819 " from " + pceipoTD_tmp + " d"+;
3820 " join zzeipocr C"+;
3821 " /*on d.customer = C.customer"+; &&*--- TR 1101199 16-Feb-2017 Goutam. Deleted
3822 " and d.division = C.division*/ "+; &&*--- TR 1101199 16-Feb-2017 Goutam. Deleted
3823 " on d.control_pkey = C.pkey"+; &&*--- TR 1101199 16-Feb-2017 Goutam. Added h.control_pkey
3824 " left join zzxrangh r"+;
3825 " on r.division = d.division"+;
3826 " and r.rng_style = d.style"+;
3827 " and r.rng_color = d.color_code"+;
3828 " and r.rng_lbl = d.lbl_code"+;
3829 " and r.rng_pack = d.dimension"+;
3830 " left join zzxscolr sc"+;
3831 " on sc.division = d.division"+;
3832 " and sc.style = d.style"+;
3833 " and sc.color_code = d.color_code"+;
3834 " and sc.lbl_code = c.lbl_code"+;
3835 " and sc.dimension = d.dimension"+;
3836 " left join zzxrupcd rc " + ;
3837 " on rc.division = d.division"+;
3838 " and rc.style = d.style"+;
3839 " and rc.new_color = d.color_code"+;
3840 " and rc.lbl_code = d.lbl_code"+;
3841 " and rc.dimension = d.dimension"+;
3842 " where d.customer > ''"+;
3843 " and d.SKU > ''"+;
3844 " and (d.UPC > '' or d.EAN > '' )"+;
3845 " and d.Division > ''"+;
3846 " and d.Style > ''"+;
3847 " and d.Color_Code > ''"+;
3848 " and C.Confirm_UPC = 'Y' "+;
3849 " and d.Rng_Style = '' "
3850
3851 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3852 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3853 *--- Used sc.Division instead of c.Division.
3854 lcSqlSln = ;
3855 "select d.Customer"+;
3856 " , d.Division"+;
3857 " , s.SLN_SKU as sku"+;
3858 " , s.STYLE"+;
3859 " , s.Color_Code"+;
3860 " , case when s.Lbl_Code = ''"+;
3861 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3862 " when s.Lbl_Code = ''"+;
3863 " and c.Resv_Label = 'V'"+;
3864 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3865 " else s.lbl_code"+;
3866 " end as lbl_code"+;
3867 " , s.lbl_code as lbl_codeOrig"+;
3868 " , c.resv_label"+;
3869 " , s.DIMENSION"+;
3870 " , s.Sizebucket"+;
3871 " , s.SLN_UPC as upc"+;
3872 " , s.pkey"+;
3873 " , C.Confirm_UPC"+;
3874 " , s.size_desc"+;
3875 " , '" + Trim(pceipoTS) + "' as Src"+;
3876 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3877 " from " + pceipoTD_tmp + " d"+;
3878 " join " + pceipoTS_tmp + " s"+;
3879 " on s.fkey = d.pkey"+;
3880 " join zzeipocr C"+;
3881 " /*on d.customer = C.customer"+; &&*--- TR 1101199 16-Feb-2017 Goutam. Deleted
3882 " and d.division = C.division*/ "+; &&*--- TR 1101199 16-Feb-2017 Goutam. Deleted
3883 " on d.control_pkey = C.pkey"+; &&*--- TR 1101199 16-Feb-2017 Goutam. Added h.control_pkey
3884 " left join zzxscolr sc"+;
3885 " on sc.division = d.division"+;
3886 " and sc.style = s.style"+;
3887 " and sc.color_code = s.color_code"+;
3888 " and sc.lbl_code = c.lbl_code"+;
3889 " and sc.dimension = s.dimension"+;
3890 " left join zzxrupcd rc " + ;
3891 " on rc.division = d.division"+;
3892 " and rc.style = s.style"+;
3893 " and rc.new_color = s.color_code"+;
3894 " and rc.lbl_code = c.lbl_code"+;
3895 " and rc.dimension = s.dimension"+;
3896 " where d.Customer > ''"+;
3897 " and s.SLN_SKU > ''"+;
3898 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3899 " and d.Division > ''"+;
3900 " and s.Style > ''"+;
3901 " and s.Color_Code > ''"+;
3902 " and c.Confirm_UPC = 'Y'"+;
3903 " and d.Rng_Style > ''"
3904 Endif
3905
3906 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3907 Select(lnOldSelect)
3908 Return lcSql
3909 Endproc
3910 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3911
3912 *-----------------------------------------------------------------------------------
3913
3914 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3915 PROCEDURE MarkHeaderwithDetailOrSLNInError
3916 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3917 * This is customized method from clsEDI
3918
3919 LOCAL llRetVal, lnOldSelect
3920 LOCAL lnBadOrderCount
3921 llRetVal = .T.
3922 lnOldSelect = SELECT()
3923
3924 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3925 pcEW = "E"
3926 ENDIF
3927 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3928 LOCAL lcErrorMsg, lcErrorMsgSLN
3929 lnBadOrderCount = 0
3930 IF pcEW = 'W'
3931 lcErrorMsg = "Has Warnings in Details."
3932 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3933 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3934 ELSE
3935 lcErrorMsg = "Has Errors in Details."
3936 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3937 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3938
3939 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3940 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3941 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3942 ENDIF
3943
3944 SELECT tcBadOrders
3945 IF THIS.lUserInterface
3946 * Init Thermometer
3947 THIS.InitThermo(lnBadOrderCount)
3948 l_nThermoCnt = 0
3949 ENDIF
3950 SCAN
3951 IF THIS.lUserInterface
3952 * Advance progress bar, if we're using one.
3953 l_nThermoCnt = l_nThermoCnt + 1
3954 THIS.AdvanceThermo(l_nThermoCnt)
3955 ENDIF
3956 SELECT (pceipoTH)
3957 IF pcEW = 'W'
3958 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3959 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3960 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3961 IN (pceipoTH)
3962 ENDIF
3963 ENDIF
3964 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3965 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3966 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3967 IN (pceipoTH)
3968 ENDIF
3969 ENDIF
3970 ELSE
3971 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3972 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3973
3974 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3975 IN (pceipoTH)
3976 ENDIF
3977 ENDIF
3978 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3979 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3980
3981 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3982 IN (pceipoTH)
3983 ENDIF
3984 ENDIF
3985 ENDIF
3986 ENDSCAN
3987 USE IN tcBadOrders
3988 USE IN tcBadOrdersSLN
3989
3990 IF THIS.lUserInterface
3991 THIS.ResetThermo()
3992 ENDIF
3993 SELECT(lnOldSelect)
3994 RETURN llRetVal
3995 ENDPROC
3996 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3997
3998 *-----------------------------------------------------------------------------------
3999
4000 *--- TR 1013007 NH
4001 *--- checks if pceipoTH.req_855 is 'R'
4002 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
4003 *--- if default status value is not empty then set Send855 flag to true and return true
4004 *--- if default status value is empty then set Send855 flag to true and return false and
4005 *--- set error message 'Missing 855 status code'
4006 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
4007 *--- then set Send855 flag to true and return false and
4008 *--- set error message 'Missing 855 status code'
4009
4010 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
4011 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
4012 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
4013 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
4014 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
4015
4016
4017 Procedure Check855Required
4018 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
4019
4020 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
4021 llRetVal = .T.
4022 lnOldSelect = Select()
4023 lcOldPO_num = ""
4024 lcPO_Status_855 = ""
4025 This.LogEntry("Starting procedure" + Program())
4026 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
4027
4028 *--- prepare detail zzeipotd for cascading status_855 code
4029 Select(pceipoTD)
4030 lnOldOrder_TD = Val(Sys(21)) && getting the current order
4031 Set Order To Tagno('FKEY') && settting order by 'fkey'
4032
4033 Select(pceipoTH)
4034 Scan For req_855 = 'R'
4035 Scatter Name loEiPOth Memo
4036 *--- when this.lSend855 flag is true then data will be sent to server
4037 This.lSend855 = .T.
4038
4039 *--- TR 1040432 MAY-20-2009 BR
4040 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
4041
4042 *--- TR 1101199 16-Feb-2017 Goutam
4043 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
4044 If Empty(loEiPOth.status_855) And Seek(loEiPOth.control_pkey, pceipoCR, 'pkey')
4045 *=== TR 1101199 16-Feb-2017 Goutam
4046
4047 *=== TR 1040432 MAY-20-2009 BR
4048 Select(pceipoCR)
4049 If Auto_855 = 'Y'
4050 If Not Empty(def_855)
4051 *--- set default value
4052 loEiPOth.status_855 = def_855
4053 *--- TR 1080293 KISHORE 26-AUG-2014
4054 IF NOT EMPTY(def_855dtl)
4055 lcDetail855Code = EVALUATE(pceipoCR + ".def_855dtl")
4056 REPLACE ALL status_855 WITH lcDetail855Code ;
4057 IN (pceipoTD) ;
4058 FOR fkey = loeipoTH.pkey AND EMPTY(EVALUATE(pceipoTD + ".status_855"))
4059 ELSE
4060 *=== TR 1080293 KISHORE 26-AUG-2014
4061 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
4062 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
4063*!* llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
4064 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
4065 ENDIF && TR 1080293 KISHORE 26-AUG-2014
4066 Else
4067 loEiPOth.Errs_flg_h = 'Y'
4068 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
4069 Endif
4070 Endif
4071 Endif
4072
4073 *--- status_855 code is still empty
4074 If Empty(loEiPOth.status_855)
4075 loEiPOth.Errs_flg_h = 'Y'
4076 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
4077 Endif
4078
4079 *--- check if defferent status_855 code exists in orders with same po number
4080 If lcOldPO_num <> loEiPOth.po_num
4081 lcOldPO_num = loEiPOth.po_num
4082 lcPO_Status_855 = loEiPOth.status_855
4083 Else
4084 If lcPO_Status_855 <> loEiPOth.status_855
4085 loEiPOth.Errs_flg_h = 'Y'
4086 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
4087 Endif
4088 Endif
4089
4090 *--- all records will only be get updated. No insert is need here.
4091 Select(pceipoTH)
4092 Gather Name loEiPOth Memo
4093
4094 If Not llRetVal
4095 Exit
4096 Endif
4097 Endscan
4098 *--- set back to old order by
4099 Select(pceipoTD)
4100 Set Order To (lnOldOrder_TD)
4101 *-- when one order is flaged error then all order of PO will be make
4102 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
4103 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
4104 Select(lnOldSelect)
4105 Return llRetVal
4106
4107 ENDPROC
4108
4109 *-----------------------------------------------------------------------------------
4110
4111 *--- must set order by 'FKey' in pceipoTD
4112 Procedure Cascade855AckCode
4113 Lparameters poeipoTH, pceipoTD
4114
4115 Local llRetVal, lnOldSelect
4116 lnOldSelect = Select()
4117 llRetVal = .T.
4118
4119 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
4120 Return .F.
4121 Endif
4122 *- 1034481 10/06/08 YIK
4123 *- Cascade ALL status codes to details.
4124 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
4125 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
4126 Select(pceipoTD)
4127 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
4128 Scan While fkey = poeipoTH.pkey
4129 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
4130 Endscan
4131 ENDIF
4132 *- 1034481
4133 *- Endif
4134
4135 Select(lnOldSelect)
4136 Return llRetVal
4137 Endproc
4138
4139 *----------------------------------------------------------------------------------------
4140 *--- TR 1034481 NH
4141 PROCEDURE MarkHeaderForMissing855ControlRef
4142 LPARAMETERS pceipoTH
4143
4144 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
4145
4146 llRetVal = .t.
4147 lnOldSelect = SELECT()
4148 lcZzeoprcr = "Oprcr" + SYS(2015)
4149 lcZzxlookp = "LOOKP" + SYS(2015) && TR 1083402 20-Jan-2015 Partha
4150
4151 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
4152
4153 *--- TR 1083402 20-Jan-2015 Partha ---
4154*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
4155
4156 llRetVal = llRetVal and v_sqlexec("select customer, division, ack29_req from zzeoprcr", lcZzeoprcr)
4157 llRetVal = llRetVal and v_sqlexec("SELECT p.lk_code FROM zzxlookp p WHERE p.Lk_Type ='ACK29 Codes' ", lcZzxlookp)
4158 *=== TR 1083402 20-Jan-2015 Partha ===
4159
4160 IF USED(lcZzeoprcr)
4161
4162 SELECT (lcZzeoprcr) && TR 1083402 20-Jan-2015 Partha
4163
4164 INDEX on customer TAG customer
4165 INDEX on division TAG division
4166
4167 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
4168 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
4169 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
4170
4171 *--- TR 1083402 20-Jan-2015 Partha ---
4172 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Valid ACK29 Code required.' + CRLF ;
4173 from (pceipoTH) th ;
4174 JOIN (pceipoTD) td ON th.pkey=td.fkey ;
4175 WHERE th.req_855 ='R' ;
4176 AND EXISTS ( select c.customer from (lcZzeoprcr) c ;
4177 WHERE c.customer = th.customer AND c.division = th.division AND c.ack29_req='Y') ;
4178 AND ( EMPTY(td.ack29) ;
4179 OR NOT EXISTS (SELECT 1 FROM (lcZzxlookp) p WHERE p.LK_CODE = td.ack29 ))
4180 *=== TR 1083402 20-Jan-2015 Partha ===
4181
4182 USE IN (lcZzeoprcr)
4183 USE IN (lcZzxlookp) && TR 1083402 20-Jan-2015 Partha
4184 ENDIF
4185
4186 SELECT(lnOldSelect)
4187 RETURN llRetVal
4188
4189 ENDPROC
4190 *=== TR 1034481 NH
4191 *----------------------------------------------------------------------------------------
4192
4193 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
4194
4195 Local laTables[4]
4196 laTables[1] = "VzzeiPOth_iPOproc"
4197 laTables[2] = "VzzeiPOtd_iPOproc"
4198 laTables[3] = "VzzeiPOts_iPOproc"
4199 * --- TR 1018184 RLN 1018184
4200 laTables[4] = "VzzeiPOtsac_iPOproc"
4201
4202 Local llRetVal, llBeganTransaction, loEiPOth
4203 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
4204 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
4205
4206 llRetVal = .T.
4207
4208 With This
4209 .LogEntry("Starting Program : " + Program())
4210 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
4211
4212 Select(pceipoTH)
4213 Scan
4214 Scatter Name loEiPOth Memo
4215 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
4216 Select('VzzeiPOth_iPOproc')
4217 Gather Name loEiPOth Memo
4218 Endif
4219 Endscan
4220
4221 Select(pceipoTD)
4222 Scan
4223 Scatter Name loEiPOtd Memo
4224 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
4225 Select('VzzeiPOtd_iPOproc')
4226 Gather Name loEiPOtd Memo
4227 Endif
4228 Endscan
4229
4230 Select(pceipoTS)
4231 Scan
4232 Scatter Name loeipoTS Memo
4233 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
4234 Select('VzzeiPOts_iPOproc')
4235 Gather Name loeipoTS Memo
4236 Endif
4237 Endscan
4238
4239 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
4240 If This.BeginTransaction()
4241 llRetVal = This.Tableupdate(@laTables)
4242 If llRetVal
4243 This.EndTransaction()
4244 Else
4245 This.RollbackTransaction()
4246 Endif
4247 Endif
4248 *--- close views.
4249 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
4250 Endwith
4251
4252 Return llRetVal
4253
4254 Endfunc
4255
4256 *----------------------------------------------------------------------------------------
4257
4258 Procedure Run855Process
4259 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4260 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
4261 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4262
4263 Local lnOldSelect, llRetVal, loStatusCur
4264 lnOldSelect = Select()
4265 llRetVal = .T.
4266 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4267 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4268 Local lcStatusCur, loStatus
4269 lcStatusCur = Sys(2015)
4270 With This
4271
4272 *--- TR 1044017 07-JAN-2010 HNISAR
4273*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
4274 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
4275 *=== TR 1044017 07-JAN-2010 HNISAR
4276
4277 .LogEntry("Starting program " + Program())
4278
4279 * --- TR 1048571 9/9/10 CM
4280 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
4281 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
4282 * === TR 1048571 9/9/10 CM
4283
4284 If llRetVal
4285 Select (lcStatusCur )
4286 Scatter Name loStatus
4287 Use In (lcStatusCur)
4288 ENDIF
4289 *- 1034481 10/03/08 YIK
4290 *- Check if there are no 855(o) to process
4291 llHas855ToSend = .T.
4292
4293 *--- req_855 must be more the status missing count
4294 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
4295 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
4296 *-- move 850 data to 855 transaction
4297 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
4298
4299 *- 1034481 10/03/08 YIK
4300 *- Added parameter pceipoTH and llHas855ToSend
4301 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4302 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
4303 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
4304
4305 *--- TR 1044017 07-JAN-2010 HNISAR
4306*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4307 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4308 *===TR 1044017 07-JAN-2010 HNISAR
4309
4310 *- 1034481 10/03/08 YIK
4311 *- Check if there are no 855(o) to process
4312 IF llHas855ToSend
4313 *-- create flat files
4314 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4315 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
4316 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
4317 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
4318
4319 *--- update 855 flag of 850 tran header
4320 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
4321
4322 *--- TR 1044017 07-JAN-2010 HNISAR
4323*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
4324 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
4325 *=== TR 1044017 07-JAN-2010 HNISAR
4326
4327 *--- drop temp tables
4328 *- 1030497 02/29/08 TT
4329 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
4330 *!* .dropTempTable(lceoprth,.T.)
4331 *!* .dropTempTable(lceoprtd,.T.)
4332 *!* .dropTempTable(lceoprtc,.T.)
4333 *!* .dropTempTable(lceoprta,.T.)
4334 *!* .dropTempTable(lceoprth_notes,.T.)
4335 *!* .dropTempTable(lceoprtd_notes,.T.)
4336 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
4337 .oCopyUtil.dropTempTable(lceoprth,.T.)
4338 .oCopyUtil.dropTempTable(lceoprtd,.T.)
4339 .oCopyUtil.dropTempTable(lceoprtc,.T.)
4340 .oCopyUtil.dropTempTable(lceoprta,.T.)
4341 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
4342 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
4343
4344 *- 1034481 10/03/08 YIK
4345 ELSE
4346 .LogEntry("No 855(o) transaction data to send.")
4347 ENDIF
4348 *= 1034481 *- 1030497 02/29/08 TT
4349 Endif
4350
4351 *- 1034481 10/03/08 YIK
4352 *- Added ..AND loStatus.STATUS_855_MISSING > 0
4353 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
4354 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
4355 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
4356 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
4357 .oHostProcess.c855Msg
4358 Endif
4359 Release loStatus
4360 Endwith
4361
4362 Select(lnOldSelect)
4363 Return llRetVal
4364
4365 Endfunc
4366
4367 *----------------------------------------------------------------------------------------
4368
4369 Procedure get855Status
4370 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4371 Lparameters tcCursor, pceipoTH
4372
4373 * --- TR 1048571 9/9/10 CM
4374 *Local lcSQL, lnOldSelect,llRetVal
4375 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4376
4377 lceipoth = "#Ipoth" + SYS(2015)
4378 * === TR 1048571 9/9/10 CM
4379
4380 lnOldSelect = Select()
4381 llRetVal = .T.
4382
4383 * --- TR 1048571 9/9/10 CM
4384 With This
4385 .cSQLTempTable=""
4386 IF .GenerateSQLTempTable(pceipoTH)
4387 IF .PopulateSQLTempTable(pceipoTH)
4388 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4389 llRetVal = llRetVal And v_SqlExec(lcSQL)
4390 ENDIF
4391 ENDIF
4392 Endwith
4393 * === TR 1048571 9/9/10 CM
4394
4395 *- TR 1100974 FH - taking out This.cFilterCriteria
4396 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4397 lcSQL = " select sum(1) rec_count, " + ;
4398 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4399 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4400 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4401 " from " + lceipoth + " h "
4402
4403 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4404 Select(lnOldSelect)
4405 Return llRetVal
4406 Endproc
4407
4408 *----------------------------------------------------------------------------------------
4409
4410 Procedure MoveTo855TempTransaction
4411 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4412 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4413 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4414
4415 Local llRetVal, lnOldSelect
4416 lnOldSelect = Select()
4417 llRetVal = .T.
4418 With This
4419 *--- create temporary 855 transaction tables at server
4420 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4421 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4422
4423 *--- copy data from 850 trans table to 855 temp trans tables
4424 *- 1034481 10/03/08 YIK
4425 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4426 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4427 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4428
4429 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4430 IF plHas855ToSend
4431 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4432 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4433
4434 *--- update header division from detail
4435 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4436 ENDIF
4437 *= 1034481
4438 Endwith
4439
4440 Select(lnOldSelect)
4441 Return llRetVal
4442
4443 Endproc
4444
4445 *----------------------------------------------------------------------------------------
4446
4447 Procedure CreateOPRTempTables
4448 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4449
4450 Local llRetVal, lnOldSelect, lcUnique
4451 lnOldSelect = Select()
4452 llRetVal = .T.
4453 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4454 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4455 AND Vartype(pcRefeoprtd_notes) == "C" )
4456
4457 lcUnique = Sys(2015)
4458 With This
4459 .LogEntry("Starting " + Program())
4460 .LogEntry("Creating OPR Temp Tables.")
4461
4462 *--- zzeipoth
4463 pcRefeoprth = "#zzeoprth" + lcUnique
4464 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4465 llRetVal = llRetVal And v_SqlExec(lcSQL)
4466
4467 *--- TR 1044208
4468 .oHostProcess.AddToTempTables(pcRefeoprth)
4469 *=== TR 1044208
4470
4471 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4472 *--- zzeipotd
4473 pcRefeoprtd = "#zzeoprtd" + lcUnique
4474 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4475 llRetVal = llRetVal And v_SqlExec(lcSQL)
4476 *--- TR 1044208
4477 .oHostProcess.AddToTempTables(pcRefeoprtd)
4478 *=== TR 1044208
4479 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4480
4481 *--- zzeipotc
4482 pcRefeoprtc = "#zzeoprtc" + lcUnique
4483 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4484 llRetVal = llRetVal And v_SqlExec(lcSQL)
4485 *--- TR 1044208
4486 .oHostProcess.AddToTempTables(pcRefeoprtc )
4487 *=== TR 1044208
4488 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4489
4490 *--- zzeipota
4491 pcRefeoprta = "#zzeoprta" + lcUnique
4492 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4493 llRetVal = llRetVal And v_SqlExec(lcSQL)
4494 *--- TR 1044208
4495 .oHostProcess.AddToTempTables(pcRefeoprta )
4496 *=== TR 1044208
4497 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4498
4499 *---- sysnotes_oprth
4500 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4501 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4502 llRetVal = llRetVal And v_SqlExec(lcSQL)
4503 *--- TR 1044208
4504 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4505 *=== TR 1044208
4506 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4507
4508 *---- sysnotes_oprtd
4509 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4510 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4511 llRetVal = llRetVal And v_SqlExec(lcSQL)
4512 *--- TR 1044208
4513 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4514 *=== TR 1044208
4515 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4516
4517 Endwith
4518
4519 Select(lnOldSelect)
4520 Return llRetVal
4521
4522 Endproc
4523
4524 *----------------------------------------------------------------------------------------
4525
4526 Procedure IPODataToOPRTmpTable
4527 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4528 pceipoTD
4529 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4530 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4531 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4532
4533 lcOPR_TMP = ""
4534 lnOldSelect = Select()
4535 llRetVal = .T.
4536 lcCommonFields = ""
4537 *-TR 1100974 FH - filter for all
4538 *lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4539 lcFilter = " where 1 = 1 "
4540 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4541 lcLeftOnlyDefaults = ""
4542 lcLeftOnlyFields = ""
4543 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4544
4545 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4546
4547 * --- TR 1048571 9/9/10 CM
4548 lcipotd = "#Zzeipotd" + SYS(2015)
4549 * === TR 1048571 9/9/10 CM
4550
4551 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4552
4553 With This
4554 *-- TR 1044604 DEC-29-2009 BR
4555 .cSQLTempTable=""
4556 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4557*!* IF .GenerateSQLTempTable(pceipoTH)
4558*!* IF .PopulateSQLTempTable(pceipoTH)
4559 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4560 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4561 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4562
4563 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4564 &lcCmnd
4565
4566*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4567 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4568 IF .GenerateSQLTempTable(lcTempIPOTH)
4569
4570 IF .PopulateSQLTempTable(lcTempIPOTH)
4571 Use In Select(lcTempIPOTH)
4572 *=== TR 1043191 23-Oct-2009 JK ===
4573 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4574 llRetVal = llRetVal And v_SqlExec(lcSQL)
4575 ENDIF
4576 ENDIF
4577 *== TR 1044604 DEC-29-2009 BR
4578
4579 * --- TR 1048571 9/9/10 CM
4580 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4581 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4582 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4583 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4584 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4585 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4586 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4587 *.ScatterGather(pceipoTD, "tcIpoDtls")
4588 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4589 .ScatterGather("__tceipoTD", "tcIpoDtls")
4590 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4591
4592 SELECT tcIpoDtls
4593 LOCATE
4594 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4595 .cSQLTempTable=""
4596 IF .GenerateSQLTempTable("tcFinalDtls")
4597 IF .PopulateSQLTempTable("tcFinalDtls")
4598 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4599 llRetVal = llRetVal And v_SqlExec(lcSQL)
4600 ENDIF
4601 ENDIF
4602 * === TR 1048571 9/9/10 CM
4603
4604 *--- IPOTH -> OPRTH
4605 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4606 *--- lcCalFldsOPR : fields need calculation or map or constant values
4607 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4608
4609 *--- for example if term_type field data will go to terms_type field and blank term_type
4610 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4611 *!* lcCalFldsOPR = "term_type, terms_type"
4612 *!* lcCalFldsOPR_val = "' ',term_type"
4613 lcCalFldsOPR_SQL = "'PROC_855'"
4614 lcCalFldsOPR = "PROC_855"
4615 lcCalFldsOPR_val = "' '"
4616 lcFlds = ""
4617 lcValues = ""
4618
4619 lcOPR_TMP = pceoprth
4620 *- 1030497 02/29/08 TT
4621 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4622 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4623
4624 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4625 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4626 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4627 *- 1030497 02/29/08 TT
4628 *--- 1034481 set correct flag value 'P' for Proc_855
4629 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4630 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4631 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4632 llRetVal = llRetVal And v_SqlExec(lcSQL)
4633
4634 *--- IPOTD -> OPRTD
4635 lcCalFldsOPR_SQL = ""
4636 lcCalFldsOPR = ""
4637 lcCalFldsOPR_val = ""
4638 lcFlds = ""
4639 lcValues = ""
4640
4641 lcOPR_TMP = pceoprtd
4642 *- 1030497 02/29/08 TT
4643 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4644 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4645 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4646 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4647 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4648 *- 1030497 02/29/08 TT
4649 *- 1034481 10/03/08 YIK
4650 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4651 DECLARE la855Cnt[1]
4652 la855Cnt[1] = 0
4653 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4654 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4655 " INTO ARRAY la855Cnt"
4656 &lcSQL
4657
4658 plHas855ToSend = (la855Cnt[1] > 0)
4659
4660 IF plHas855ToSend
4661 *--- 1034481 set correct flag value 'P' for Proc_855
4662 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4663 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4664 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4665 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4666 " ( select * from " + lcipoth + " h " + lcFilter + ;
4667 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4668
4669 llRetVal = llRetVal And v_SqlExec(lcSQL)
4670
4671 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4672 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4673 " on d.fkey = h.pkey "
4674 llRetVal = llRetVal And v_SqlExec(lcSQL)
4675
4676 *--- IPOTC -> OPRTC
4677 lcOPR_TMP = pceoprtc
4678 lcCalFldsOPR_SQL = ""
4679 lcCalFldsOPR = ""
4680 lcCalFldsOPR_val = ""
4681 lcFlds = ""
4682 lcValues = ""
4683
4684 *- 1030497 02/29/08 TT
4685 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4686 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4687 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4688 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4689 *- 1030497 02/29/08 TT
4690 *--- 1034481 set correct flag value 'P' for Proc_855
4691 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4692 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4693 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4694 " (select * from " + lcipoth + " h " + lcFilter + ;
4695 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4696
4697 llRetVal = llRetVal And v_SqlExec(lcSQL)
4698
4699 *--- IPOTA -> OPRTA
4700 lcOPR_TMP = pceoprta
4701 lcCalFldsOPR_SQL = ""
4702 lcCalFldsOPR = ""
4703 lcCalFldsOPR_val = ""
4704 lcFlds = ""
4705 lcValues = ""
4706
4707 *- 1030497 02/29/08 TT
4708 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4709 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4710 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4711 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4712 *- 1030497 02/29/08 TT
4713 *--- 1034481 set correct flag value 'P' for Proc_855
4714
4715 *--- 1042063 10/12/09 CM
4716 *--- We're unconditionally going to remove characters greater than 25,
4717 * for 855 address1,address2 fields since max field size is 25.
4718 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4719 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4720 *=== 1042063 10/12/09 CM
4721
4722 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4723 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4724 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4725 " (select * from " + lcipoth + " h " + lcFilter + ;
4726 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4727
4728 llRetVal = llRetVal And v_SqlExec(lcSQL)
4729
4730 *--- sysnotes - zzeoprth
4731 lcOPR_TMP = pceoprth_notes
4732 *--- 1034481 set correct flag value 'P' for Proc_855
4733 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4734 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4735 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4736 " (select * from " + lcipoth + " h " + lcFilter + ;
4737 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4738
4739 llRetVal = llRetVal And v_SqlExec(lcSQL)
4740
4741 *--- sysnotes - zzeoprtd
4742 lcOPR_TMP = pceoprtd_notes
4743 *--- 1034481 set correct flag value 'P' for Proc_855
4744 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4745 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4746 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4747 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4748 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4749 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4750 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4751
4752 llRetVal = llRetVal And v_SqlExec(lcSQL)
4753 *- 1034481 10/03/08 YIK
4754 ENDIF &&plHas855ToSend
4755
4756 *-- TR 1044604 DEC-29-2009 BR
4757 lcSQL = "DROP TABLE " + lcipoth
4758 v_SqlExec(lcSQL)
4759 *== TR 1044604 DEC-29-2009 BR
4760 Endwith
4761
4762 * --- TR 1048571 9/9/10 CM
4763 USE IN SELECT("tcIpoDtls")
4764 USE IN SELECT("tcFinalDtls")
4765 USE IN SELECT("tcTmpDtls")
4766 * === TR 1048571 9/9/10 CM
4767
4768 Select(lnOldSelect)
4769 Return llRetVal
4770 Endproc
4771
4772
4773 *----------------------------------------------------------------------------------------
4774
4775 Procedure ResetPkey_OPRTmpTable
4776 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4777
4778 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4779 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4780
4781 lnOldSelect = Select()
4782 llRetVal = .T.
4783 lcOPR_TMP = pceoprth
4784 lnRecCount = 0
4785 lnMaxPkey = 0
4786 lcUnique = Sys(2015)
4787
4788 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4789 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4790 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4791 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4792 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4793 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4794 lcNewPkeyCol_TH = "PKEY_OPRTH"
4795 lcNewPkeyCol_TD = "PKEY_OPRTD"
4796 With This
4797 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4798 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4799 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4800 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4801 *- 1030497 02/29/08 TT
4802 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4803 *- TR 1092952 - FH typo, change sysnotes -> zzeoprth
4804 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "zzeoprth", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4805 *- 1030497 02/29/08 TT
4806
4807 *--- fkey updates for all chield tables
4808 *--- ipotd -> oprtd : fkey
4809 lcOPR_TMP = pceoprtd
4810 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4811 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4812 llRetVal = llRetVal And v_SqlExec(lcSQL)
4813
4814 *--- ipota -> oprta : fkey
4815 lcOPR_TMP = pceoprta
4816 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4817 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4818
4819 llRetVal = llRetVal And v_SqlExec(lcSQL)
4820
4821 *--- ipotc -> oprtc : fkey
4822 lcOPR_TMP = pceoprtc
4823 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4824 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4825 llRetVal = llRetVal And v_SqlExec(lcSQL)
4826
4827 *-- sysnotes :
4828 *-- table_name
4829 lcOPR_TMP = pceoprth_notes
4830 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4831 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4832 llRetVal = llRetVal And v_SqlExec(lcSQL)
4833
4834 *-- update detail pkey
4835 *- 1030497 02/29/08 TT
4836 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4837 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4838 *- 1030497 02/29/08 TT
4839
4840 *-- sysnotes : update table_name, fkey
4841 lcOPR_TMP = pceoprtd_notes
4842 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4843 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4844 llRetVal = llRetVal And v_SqlExec(lcSQL)
4845
4846 *--- update header notes pkey
4847 *- 1030497 02/29/08 TT
4848 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4849 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4850 *- 1030497 02/29/08 TT
4851 *--- update detail notes pkey
4852 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4853 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4854
4855 *-- update pkey
4856 *- 1030497 02/29/08 TT
4857 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4858 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4859
4860 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4861 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4862 *- 1030497 02/29/08 TT
4863
4864 *--- drop all temp tables
4865 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4866 *- 1030497 02/29/08 TT
4867 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4868 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4869 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4870 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4871 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4872
4873 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4874 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4875 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4876 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4877 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4878 *- 1030497 02/29/08 TT
4879
4880 Endwith
4881
4882 Select(lnOldSelect)
4883 Return llRetVal
4884 Endproc
4885
4886 *----------------------------------------------------------------------------------------
4887
4888 Procedure UpdateOPRTempHDRDivisionFromDtl
4889 Lparameters pcRefeoprth,pcRefeoprtd
4890
4891 Local llRetVal, lnOldSelect
4892 llRetVal = .T.
4893 lnOldSelect = Select()
4894 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4895 llRetVal = llRetVal And v_SqlExec(lcSQL)
4896 Select(lnOldSelect)
4897 Return llRetVal
4898
4899 Endproc
4900
4901 *----------------------------------------------------------------------------------------
4902
4903 Procedure Launch855Process
4904 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4905 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4906 Local llRetVal, lnOldSelect
4907 lnOldSelect = Select()
4908 llRetVal = .T.
4909
4910 Local lo855
4911 Local lc855DataTbls, lc855Msg
4912 lcFilterCriteria = ""
4913 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4914 llRetVal = (Vartype(lo855) = 'O')
4915 lc855Msg = ""
4916
4917 If llRetVal
4918 *--- TR 1037976 JAN-22-2008 BR
4919 *lo855 = This
4920 lo855.oLog = THIS.oLog
4921 *=== TR 1037976 JAN-22-2008 BR
4922 lo855.oFrmProgressBar = This.oFrmProgressBar
4923 Endif
4924 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4925 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4926 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4927 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4928 This.oHostProcess.c855Msg = lc855Msg
4929 Select(lnOldSelect)
4930 Return llRetVal
4931
4932 Endproc
4933
4934 *----------------------------------------------------------------------------------------
4935
4936 Procedure Update855ProcFlag
4937 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4938
4939 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4940 lnOldSelect = Select()
4941 llRetVal = .T.
4942 lcCursor = Sys(2015)
4943 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4944 *--- 1034481 set correct flag value 'P' for Proc_855
4945 *- 1034481 10/03/08 YIK
4946 *- Also populate error flag and error message from zzeoprth to the 850(i)
4947 *- otherwise 850(i) goes through while the 855(o) errors out.
4948 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4949 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4950 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4951 " t on o.pkey = t.pkey_oprth" + ;
4952 " LEFT JOIN zzeoprth th " + ;
4953 " on th.pkey = t.pkey_oprth"
4954
4955 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4956 If llRetVal
4957 Select (lcCursor)
4958 SCAN
4959 Scatter Name loCursor Memo
4960 DO CASE
4961 CASE proc_855 = 'P'
4962 *- 1014298 12/02/05 YIK, NH
4963 *- it was ..proc_855 WITH 'Y'
4964 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4965 CASE errs_flg_h = 'Y'
4966 REPLACE errs_flg_h WITH 'Y', ;
4967 errs_msg_h WITH errs_msg_h + ;
4968 " ---- 855(o) process ----" + CRLF + ;
4969 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4970 For pkey = loCursor.pkey In (pceipoTH)
4971 OTHERWISE
4972 ENDCASE
4973 Endscan
4974 Endif
4975 *= 1034481
4976 Select(lnOldSelect)
4977 Return llRetVal
4978
4979 Endproc
4980
4981 *----------------------------------------------------------------------------------------
4982
4983 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4984
4985 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4986 *!* In this case label must be with empty.
4987
4988 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4989
4990 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4991 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4992 *!* style '9040' color 'RED' label 'WM'.
4993
4994 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4995 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4996 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4997
4998 Procedure CheckMultiUPC
4999 Lparameters tcEiPOth, tcEiPOtd
5000
5001 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
5002
5003 llRetVal = True
5004 lnSelect = Select()
5005
5006 With This
5007
5008 lcWorkAlias = GetUniqueFileName()
5009
5010 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
5011 *-- Change h.division to d.division
5012 SELECT d.pkey, ;
5013 h.customer, ;
5014 d.division, ;
5015 d.upc ;
5016 ,h.control_pkey ; && *--- TR 1101199 16-Feb-2017 Goutam.
5017 FROM tceipoth h ;
5018 JOIN tceipotd d ;
5019 ON h.pkey = d.fkey ;
5020 INTO ;
5021 CURSOR (lcworkAlias)
5022
5023 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
5024 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
5025 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
5026 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
5027
5028 If llRetVal
5029
5030 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
5031 *-- Included 'V' in the condition of pocr.resv_label
5032 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
5033 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
5034
5035 lcSql = " SELECT upcd.lbl_code, t.* " + ;
5036 " FROM " + lcTempTbl + " t " + ;
5037 " JOIN zzemupch upch " + ;
5038 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
5039 " JOIN zzemupcd upcd " + ;
5040 " ON upch.pkey = upcd.fkey " + ;
5041 " AND upcd.active_ok = 'Y' " + ;
5042 " JOIN " + This.c850Control + " pocr " + ;
5043 " /*ON pocr.customer = t.customer " + ; && *--- TR 1101199 16-Feb-2017 Goutam.
5044 " AND pocr.division = t.division*/ " + ; && *--- TR 1101199 16-Feb-2017 Goutam.
5045 " ON pocr.pkey = t.control_pkey " + ; && *--- TR 1101199 16-Feb-2017 Goutam.
5046 " AND pocr.lbl_code = upcd.lbl_code " + ;
5047 " AND pocr.resv_label IN ('Y','V') "
5048
5049 lcWorkAlias = GetUniqueFileName()
5050
5051 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
5052
5053 If Reccount(lcWorkAlias) > 0
5054 Select (tcEiPOtd)
5055 Scan
5056 lnPKey = pkey
5057
5058 Select(lcWorkAlias)
5059 Locat For pkey = lnPKey
5060
5061 If Found()
5062 lcLbl_code = lbl_code
5063 Select (tcEiPOtd)
5064 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
5065 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
5066 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
5067 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
5068 Endif
5069
5070 Select (tcEiPOtd)
5071 Endscan
5072 Endif
5073
5074 Endif
5075
5076 .TableClose(lcWorkAlias)
5077
5078 Endwith
5079
5080 Select (lnSelect)
5081 Return llRetVal
5082 Endproc
5083 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
5084
5085 *----------------------------------------------------------------------------------------
5086
5087 Procedure RangeStyle
5088 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
5089 Local llRetVal, lnOldSelect, lcErrs_Msg
5090 llRetVal = .T.
5091 lnOldSelect = Select()
5092
5093 *****************************************************************************
5094 * 1st Getting all range style (hdr/dtl) that relate to the
5095 * passing order line for this run
5096
5097 *--- TR 1038376 05-May-2009 Goutam
5098 LOCAL lctmpCursor
5099 lctmpCursor = GetUniqueFileName()
5100
5101 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
5102 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
5103
5104 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
5105 * TR 1059142 FH - adding h.ord_type to the group by clause
5106 *--- TR 1088126 2-JUL-2015 Venuk -- Added 'as price_code' else MAX(h.price_code) will be max_price_Code ===
5107 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) as price_code, h.ord_type FROM (pcTransHeader) h ;
5108 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
5109 WHERE d.errs_flg_d <> 'Y' ;
5110 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
5111 INTO CURSOR __TmpCursor
5112
5113 .cSQLTempTable=""
5114 If .GenerateSQLTempTable('__TmpCursor')
5115 If .PopulateSQLTempTable('__TmpCursor')
5116 If !Empty(.cSQLTempTable)
5117 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
5118 lcSqlString = "Update " + .cSQLTempTable + ;
5119 " Set price_code = coalesce((Select Top 1 price_code " + ;
5120 " From zzxcslsr " + ;
5121 " Where Customer = h.customer " + ;
5122 " and (Store = h.store or Store = '') " + ;
5123 " and (Division = h.division or Division = '') " + ;
5124 " and (Department = h.department or Department = '') " + ;
5125 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
5126 " and price_code <> '' " + ;
5127 " order by rank_seq),'') " + ;
5128 " From " + .cSQLTempTable + " h"
5129
5130 llRetVal = v_sqlExec(lcSqlString)
5131
5132 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
5133 lcSqlString = "UPDATE " + .cSQLTempTable + ;
5134 " Set price_code = c.price_code "+;
5135 " From " + .cSQLTempTable + " h "+;
5136 " , zzocntrc c "+;
5137 " Where h.division = c.division " +;
5138 " and h.price_code = '' "
5139 llRetVal = v_sqlExec(lcSqlString)
5140 *- TR 1056061 FH 08/17/11
5141
5142
5143 IF llRetVal
5144 lcSqlString = "Select * from " + .cSQLTempTable
5145 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
5146
5147 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
5148 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
5149*!* lcSqlString = "UPDATE h " + ;
5150*!* " SET price_code = c.price_code " + ;
5151*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
5152*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
5153*!* " on d.division = c.division " + ;
5154*!* " And d.customer = c.customer " + ;
5155*!* " And h.Store = c.Store " + ;
5156*!* " And h.department = c.department " + ;
5157*!* " And h.ord_type = c.ord_type " + ;
5158*!* "Where d.errs_flg_d <> 'Y' "
5159
5160 lcSqlString = "UPDATE h " + ;
5161 " SET price_code = c.price_code " + ;
5162 " From " + pcTransheader + " h " + ;
5163 " join " + lcTmpCursor + " c " + ;
5164 " on h.division = c.division " + ;
5165 " And h.customer = c.customer " + ;
5166 " And h.Store = c.Store " + ;
5167 " And h.department = c.department " + ;
5168 " And h.ord_type = c.ord_type " + ;
5169 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
5170
5171 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
5172
5173 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
5174 ENDIF
5175
5176 IF llRetVal
5177 *-1061331 FH - simpilifed update query
5178 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
5179 *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 ;
5180 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
5181 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
5182 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
5183
5184 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 ;
5185 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
5186
5187 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
5188 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
5189 *- TR 1054873 FH - changed error message
5190 &&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 ;
5191 &&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 ;
5192 *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 ;
5193 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
5194 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
5195 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
5196 ENDIF
5197
5198 endif
5199 endif
5200 endif
5201
5202 *--- TR 1088126 2-JUL-2015 Venuk
5203 IF This.oBPOSalesOrder.lRslv_pricecode_cssld
5204 SELECT CRS_pkey, d.pkey as dtlpkey, d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type, ;
5205 d.style, d.color_code, d.lbl_code, d.dimension ;
5206 FROM (pcTransHeader) h ;
5207 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
5208 WHERE d.errs_flg_d <> 'Y' ;
5209 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type, d.pkey ;
5210 INTO CURSOR __TmpCursor
5211
5212 .cSQLTempTable=""
5213 If .GenerateSQLTempTable('__TmpCursor')
5214 If .PopulateSQLTempTable('__TmpCursor')
5215 If !Empty(.cSQLTempTable)
5216
5217 lcSqlString = "Update " + .cSQLTempTable + ;
5218 " Set CRS_pkey = coalesce((Select Top 1 pkey " + ;
5219 " From zzxcslsr " + ;
5220 " Where Customer = h.customer " + ;
5221 " and (Store = h.store or Store = '') " + ;
5222 " and (Division = h.division or Division = '') " + ;
5223 " and (Department = h.department or Department = '') " + ;
5224 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
5225 " and price_code <> '' " + ;
5226 " order by rank_seq),'') " + ;
5227 " From " + .cSQLTempTable + " h"
5228 llRetVal = v_sqlExec(lcSqlString)
5229
5230 lcSqlString = ;
5231 " Select r.dtlpkey as dtlpkey, " + ;
5232 " case when Coalesce(d.price_code,'')='' then h.price_code else d.price_code end as price_Code " + ;
5233 " from zzxcslsr h " + ;
5234 " join "+ .cSQLTempTable + " r" + ;
5235 " on h.pkey = r.CRS_pkey " + ;
5236 " join zzxscolr c " + ;
5237 " on c.division = h.division " + ;
5238 " and c.style = r.style" + ;
5239 " and c.color_Code = r.color_Code " + ;
5240 " and c.lbl_Code = r.lbl_code " + ;
5241 " and c.dimension = r.dimension " + ;
5242 " join zzxcslsd d " + ;
5243 " on h.pkey = d.fkey " + ;
5244 " and h.group_Type = d.group_type " + ;
5245 " and d.group_code = " + ;
5246 " case when d.Group_type='A' then c.Group_Code1 " + ;
5247 " when h.Group_type='B' then c.Group_Code2 " + ;
5248 " when h.Group_type='C' then c.Group_Code3 " + ;
5249 " when h.Group_type='D' then c.Group_Code4 " + ;
5250 " when h.Group_type='E' then c.Group_Code5 " + ;
5251 " when h.Group_type='F' then c.Group_Code6 " + ;
5252 " when h.Group_type='G' then c.Group_Code7 " + ;
5253 " when h.Group_type='H' then c.Group_Code8 " + ;
5254 " when h.Group_type='I' then c.Group_Code9 " + ;
5255 " when h.Group_type='J' then c.Group_Code10 " + ;
5256 " when h.Group_type='K' then c.Group_Code11 " + ;
5257 " when h.Group_type='L' then c.Group_Code12 " + ;
5258 " when h.Group_type='M' then c.Group_Code13 end "
5259
5260 llRetVal = v_sqlExec(lcSqlString, "tcPriceCode")
5261
5262 If(USED("tcPriceCode"))
5263 SELECT tcPriceCode
5264 INDEX on dtlpkey TAG dtlpkey
5265 llRetval = .SetRelation("tcPriceCode", "dtlpkey", pcTransDetail,"pkey")
5266
5267 REPLACE ALL PRICE_CODE WITH tcPriceCode.price_Code IN (pcTransDetail)
5268
5269 Set Relation To
5270 USE IN tcPriceCode
5271 ENDIF
5272 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 ;
5273 from (pcTransDetail) d WHERE EMPTY(d.price_code) AND d.errs_flg_d <> 'Y'
5274
5275 ENDIF
5276 ENDIF
5277 ENDIF
5278 USE IN __TmpCursor
5279 ELSE
5280 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey where d.price_code=''
5281 Endif
5282 *=== TR 1088126 2-JUL-2015 Venuk
5283
5284 .cSQLTempTable=""
5285 *=== TR 1038376 05-May-2009 Goutam
5286 * additional past for range style verification/explotion
5287 *-- TR 1023892 5-3-07 BR
5288 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5289 IF .lALLOW_RANGE_HDR_LABEL
5290 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5291 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5292 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 ;
5293 FROM (pcTransHeader) h, (pcTransDetail) d ;
5294 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5295 AND d.Errs_Flg_D= 'N' AND ;
5296 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5297 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5298 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5299 ELSE
5300 *=== TR 1023892 NH
5301 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5302 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5303 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
5304 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5305 FROM (pcTransHeader) h, (pcTransDetail) d ;
5306 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5307 And d.Errs_Flg_D= "N" And ;
5308 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5309 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5310 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5311 ENDIF && TR 1023892 NH
5312 With This
5313 .cSQLTempTable=""
5314 If .GenerateSQLTempTable('__TmpCursor')
5315 If .PopulateSQLTempTable('__TmpCursor')
5316 If !Empty(.cSQLTempTable)
5317
5318 .LogEntry("Exploding range style.")
5319 * Get range style header
5320 *- 1000984 9/11/03 YIK
5321 *- do not explode range styles type 'P'rint
5322 *- Added ..and h.rng_type <> 'P'
5323 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
5324 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
5325 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
5326 IF .lALLOW_RANGE_HDR_LABEL
5327 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5328 "Where h.division= t.division and h.rng_style = t.style and "+;
5329 "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 "+; &&TR 1109145 FH - switched lbl_code and cust_lbl
5330 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5331 ELSE
5332 *=== TR 1023892 NH
5333 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5334 "Where h.division= t.division and h.rng_style = t.style and "+;
5335 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5336 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5337 *= 1000984
5338 ENDIF && TR 1023892 NH
5339 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
5340
5341 * TAN 31891 - JAZ - 5/20/02
5342 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5343 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5344 * End TAN 31891 - JAZ - 5/20/02
5345
5346 If llHaveRangeStyleToExplode
5347 * Get range style detail
5348 *- 1000984 9/11/03 YIK
5349 *- do not explode range styles type 'P'rint
5350 *- Added ..and h.rng_type <> 'P'
5351
5352 *--- TR 1038376 05-May-2009 Goutam
5353 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5354
5355 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
5356 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
5357*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
5358*!* " case t.price_code when 'A' then h.a_price " + ;
5359*!* " when 'B' then h.b_price " + ;
5360*!* " when 'C' then h.c_price " + ;
5361*!* " when 'D' then h.d_price " + ;
5362*!* " when 'E' then h.e_price " + ;
5363*!* " else h.a_price end rnghdr_Price " + ;
5364*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5365*!* "join " + .cSQLTempTable + " t " +;
5366*!* "on h.division= t.division and h.rng_style = t.style and "+;
5367*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5368*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5369*!* " (case t.price_code when 'A' then h.a_price " + ;
5370*!* " when 'B' then h.b_price " + ;
5371*!* " when 'C' then h.c_price " + ;
5372*!* " when 'D' then h.d_price " + ;
5373*!* " when 'E' then h.e_price " + ;
5374*!* " else h.a_price end " + ;
5375*!* " <> t.org_price)" +;
5376*!* " AND t.sizebucket = h.rng_bk"
5377
5378 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5379 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
5380 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
5381 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
5382 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
5383 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
5384 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
5385 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
5386 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
5387 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5388
5389 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
5390 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5391 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
5392 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
5393 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
5394 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
5395 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
5396 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5397 " Left join zzxcsrgh cs "+ ;
5398 " on cs.hdrpkey = h.pkey "+ ;
5399 " and cs.dtlpkey = 0 " +;
5400 "join " + .cSQLTempTable + " t " +;
5401 "on h.division= t.division and h.rng_style = t.style and "+;
5402 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5403 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5404 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5405 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
5406 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
5407 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
5408 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
5409 " else coalesce(cs.a_price,h.a_price) end " + ;
5410 " <> t.org_price)" +;
5411 " AND t.sizebucket = h.rng_bk"+ ;
5412 " Where cs.customer = t.customer "
5413 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
5414 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
5415
5416 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5417 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
5418 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
5419 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) " + ;
5420 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
5421 " on d.division= r.division and d.style = r.rng_style and " + ;
5422 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
5423 " d.dimension= r.Rng_Pack " + ;
5424 " join zzeipocr c on c.pkey = h.control_pkey " + ; && *--- TR 1101199 16-Feb-2017 Goutam.
5425 " where d.rng_type <> 'P' AND 'Y' = IIF(EMPTY(h.price_err),c.price_err,h.price_err) AND r.sizebucket = d.sizebucket" &&--- TechRec 1102112 08-Feb-2017 dkadam === removed sql case statement and used vfp IIF statement
5426*!* " 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
5427
5428 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
5429
5430 *- TR 1048790 FH 10/04/10
5431 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
5432 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
5433 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5434
5435 IF .lALLOW_RANGE_HDR_LABEL
5436 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 ;
5437 FROM (pcTransHeader) h, (pcTransDetail) d ;
5438 WHERE h.pkey = d.fkey ;
5439 AND d.Errs_Flg_D= 'N' AND ;
5440 Not EMPTY(h.price_code) AND ;
5441 d.rng_style= '' ;
5442 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5443 ELSE
5444 *--- TechRec 1084745 14-May-2015 jjanand === Added h.customer
5445 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5446 FROM (pcTransHeader) h, (pcTransDetail) d ;
5447 WHERE h.pkey = d.fkey ;
5448 And d.Errs_Flg_D= "N" And ;
5449 Not EMPTY(h.price_code) AND ;
5450 d.rng_style= '' ;
5451 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5452 ENDIF
5453
5454 .cSQLTempTable=""
5455 If .GenerateSQLTempTable('__TmpCursor')
5456 If .PopulateSQLTempTable('__TmpCursor')
5457 *- TR 1048790 FH 10/04/10
5458
5459 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5460 *-- TR 1040759 JUN-29-2009 BR
5461 IF .lALLOW_RANGE_HDR_LABEL
5462 *- TR 1048790 FH 10/04/10 - removed price check
5463 *- TR 1050589 12/13/10 FH
5464 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5465*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5466*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5467*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5468*!* "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 "+;
5469*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5470 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5471*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5472*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5473*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5474*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5475*!* "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 "+;
5476*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5477
5478 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5479 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5480 "join " + .cSQLTempTable + " t " +;
5481 "on h.division= t.division and h.rng_style = t.style and "+;
5482 "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 "+;
5483 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5484 " t.sizebucket = h.rng_bk"+ ;
5485 " Left join zzxcsrgh cs "+ ;
5486 " on cs.hdrpkey = h.pkey "+ ;
5487 " and cs.dtlpkey = d.pkey " +;
5488 " and cs.customer = t.customer " + ;
5489 " where d.fkey in " +;
5490 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5491 "Where h.division= t.division and h.rng_style = t.style and "+;
5492 "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 "+;
5493 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5494 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5495 *- TR 1050589 12/13/10 FH
5496 ELSE
5497 *== TR 1040759 JUN-29-2009 BR
5498 *- TR 1048790 FH 10/04/10 - removed price check
5499 *- TR 1050589 12/13/10 FH
5500 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5501
5502*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5503*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5504*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5505*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5506*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5507*!*
5508 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5509*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5510*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5511*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5512*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5513*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5514*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5515
5516 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5517 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5518 "join " + .cSQLTempTable + " t " +;
5519 "on h.division= t.division and h.rng_style = t.style and "+;
5520 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5521 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5522 " t.sizebucket = h.rng_bk"+ ;
5523 " Left join zzxcsrgh cs "+ ;
5524 " on cs.hdrpkey = h.pkey "+ ;
5525 " and cs.dtlpkey = d.pkey " +;
5526 " and cs.customer = t.customer " + ;
5527 " where fkey in " +;
5528 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5529 "Where h.division= t.division and h.rng_style = t.style and "+;
5530 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5531 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5532 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5533 *- TR 1050589 12/13/10 FH
5534 ENDIF && TR 1040759 JUN-29-2009 BR
5535 *=== TR 1038376 05-May-2009 Goutam
5536 endif &&- TR 1048790 FH 10/04/10
5537 ENDIF &&- TR 1048790 FH 10/04/10
5538
5539 *= 1000984
5540 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5541
5542 * turn Range detail to vertical (with sizebucket,size_desc)
5543 * have to explode in vertical format
5544 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5545 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5546 WHERE 0=1 Into Cursor __Range2
5547 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5548 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5549 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5550 If Used("__Range1")
5551 Use In __Range1
5552 Endif
5553 If Used("__Range2")
5554 Use In __Range2
5555 Endif
5556
5557 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5558 Select __RangH
5559 Index On pkey Tag pkey
5560 Select __RangD
5561 Index On division+Style Tag DivStyle
5562 Select tcRangeVer
5563 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5564 Set Order To RangeSKU
5565 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5566
5567 *****************************************************************************
5568 * 2). Validate "Run"- type of range style. divisible by range header qty
5569 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5570
5571 *****************************************************************************
5572 * 3). Explode range style only once good tran detail that have
5573 * matching range style. Vertical range style explosion
5574 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5575 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5576 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5577 Select Distinct d.pkey ;
5578 FROM __RangD r, (pcTransDetail) d ;
5579 WHERE d.Errs_Flg_D= "N" And ; &&no error
5580 d.rng_style= '' And ; &&never explode before
5581 r.division= d.division And r.rng_style = d.Style And ; && matching range
5582 r.rng_color= d.color_code And ;
5583 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
5584 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5585 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5586 INTO Cursor __DtlExpl
5587 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5588 Endif
5589 Endif
5590 Endif
5591 Endif
5592 Endif
5593 Endwith
5594
5595 If Used("__RangH")
5596 Use In __RangH
5597 Endif
5598 If Used("__RangD")
5599 Use In __RangD
5600 Endif
5601 If Used("tcRangeVer")
5602 Use In tcRangeVer
5603 Endif
5604 If Used("__DtlExpl")
5605 Use In __DtlExpl
5606 Endif
5607 If Used("__TmpCursor")
5608 Use In __TmpCursor
5609 Endif
5610
5611 *--- TR 1038376 05-May-2009 Goutam
5612 If Used("__RangTmpD")
5613 Use In __RangTmpD
5614 ENDIF
5615 this.TableClose(lcTmpCursor)
5616 *=== TR 1038376 05-May-2009 Goutam
5617
5618 Select(lnOldSelect)
5619 Return llRetVal
5620 Endproc
5621 *----------------------------------------------------------------------------------------
5622
5623 Procedure ExplodeRangeRef
5624 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5625 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5626 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5627
5628 lnOldSele= Select()
5629 lcDivStyle= ""
5630 * TAN 31891 - JAZ - 5/20/02
5631 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5632 lnSourceCnt= RecCount(pcRangeDetail)
5633 * End TAN 31891 - JAZ - 5/20/02
5634 llRetVal= .T.
5635 lnCurDtlFkey= 0
5636
5637 Select (pcRangeDetail)
5638 Set Order To DivStyle
5639 Scan
5640 *- 1009508 03/16/05 YIK
5641 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5642 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5643 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5644 *-- m.rng_type= &pcRangeHeader..rng_type
5645 *-- m.rng_qty= &pcRangeHeader..rng_qty
5646
5647 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5648 *-- m.coord_code= &pcRangeHeader..coord_code
5649 *-- m.rng_type= &pcRangeHeader..rng_type
5650 If lnCurDtlFkey<> fkey
5651 lnCurDtlFkey= fkey
5652 If Seek(fkey, pcRangeHeader , "PKEY")
5653 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5654 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5655 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5656 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5657 *= 1009508 YIK
5658 Else
5659 llRetVal = .F.
5660 Exit
5661 Endif
5662 Endif
5663
5664 * only run once per Div + Style
5665 If !(lcDivStyle == division + Style)
5666 lcDivStyle = division + Style
5667 * Insert a record for each size bucket with a caption *
5668 If !v_GetSizeHeadings(division, Style, "__xSizer")
5669 llRetVal = .F.
5670 Exit
5671 Endif
5672 Endif
5673
5674 Select (pcRangeDetail)
5675 Scatter Memvar Memo
5676 For lnSizePosition = 1 To goEnv.MaxBuckets
5677 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5678 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5679 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5680 m.sizebucket = lnSizePosition
5681 m.size_desc = lcSizeName
5682 m.total_qty = lnSizeQty
5683 If lnSizeQty > 0 && Only want buckets with activity!
5684 Insert Into (pcRangeDetailTarget) From Memvar
5685 Endif
5686 Endfor
5687
5688 Endscan
5689 This.TableClose("__xSizer")
5690 Select (pcRangeDetail)
5691 Select (lnOldSele)
5692 Return llRetVal
5693 Endproc
5694
5695 *----------------------------------------------------------------------------------------
5696
5697 Procedure ValidateRangeStyle
5698 Lparameters pcRangeStyle, pcTransDetail
5699 Local llRetVal, lnOldSelect, lcErrs_Msg
5700 llRetVal = .T.
5701 lnOldSelect = Select()
5702 lcErrs_Msg= "Total Units must be divisible by "
5703
5704 Select (pcRangeStyle)
5705 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5706 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5707 "division+style+color_code+lbl_code+dimension")
5708
5709 If llRetVal
5710 .LogEntry("Validating range style.")
5711 * Verify range style "R"un order in min multiple of rng_qty
5712 * no need for "S"et verification of range type --just explode to
5713 * range detail
5714 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5715 *- 1023438 04/06/07 YIK
5716 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5717 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5718 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5719 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5720 Errs_Flg_D With "Y" ;
5721 IN (pcTransDetail)
5722 Endif
5723 Endscan
5724 Endif
5725
5726 Set Relation To
5727 Select(lnOldSelect)
5728 Return llRetVal
5729 Endproc
5730
5731 *----------------------------------------------------------------------------------------
5732
5733 Procedure ExplodeRangeStyleVertical
5734 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5735 Local llRetVal, lnOldSelect, lcErrs_Msg
5736 llRetVal = .T.
5737 lnOldSelect = Select()
5738
5739 * --- TR 1034963 12/15/08 CM
5740 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5741 * === TR 1034963 12/15/08 CM
5742
5743 Select (pcDetailtoExplode)
5744 Scan
5745 * Find detail line that need range style exploding using PKEY
5746 If Seek(pkey, pcTransDetail, "Pkey")
5747 * Current working trans detail
5748 Select (pcTransDetail)
5749
5750
5751 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5752 *-- TR 1040759 JUN-29-2009 BR
5753*!* IF !EMPTY(lbl_code)
5754*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5755*!* ELSE
5756*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5757*!* ENDIF
5758 *== TR 1040759 JUN-29-2009 BR
5759 IF .lALLOW_RANGE_HDR_LABEL
5760
5761 IF !EMPTY(lbl_code)
5762 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5763
5764 else
5765 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5766 ENDIF
5767 else
5768
5769 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5770
5771 endIF
5772 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5773
5774 lnCurDtlTotal_qty= total_qty
5775
5776 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5777 *- 1009508 3/16/05 YIK
5778 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5779 lnRangeBucket = sizebucket
5780
5781 Scatter Name loTransDetail Memo
5782
5783 *--- TR 1038376 16-Feb-2009 Goutam
5784 loTransDetail.Rng_Price = loTransDetail.org_price
5785 *--- TR 1038376 16-Feb-2009 Goutam
5786
5787 * delete current working trans detail already have image
5788 * in loTransDetail
5789 Delete In (pcTransDetail)
5790
5791 * --- TR 1034963 12/15/08 CM
5792 lnDetailPkey = loTransDetail.pkey
5793 * === TR 1034963 12/15/08 CM
5794
5795 * --- TR 1018184 RLN 01/10/07
5796 lnDetailPkey = loTransDetail.pkey
5797 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5798 * === TR 1018184
5799
5800 Select (pcRangeDetailVert)
5801 * Find 1st match of OURSKU
5802 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5803 * calculate lnMultiplier regardless of rng_type
5804 * --"R"un only divisible by rng_qty will get to this point
5805 * --otherwise will stay in errs_dtl_F/msg
5806
5807 *- 1009508 3/16/05 YIK
5808 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5809 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5810 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5811 lnCurDtlTotal_qty/rng_qty)
5812
5813 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5814 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5815 * Exploding detail line
5816 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5817 If !Empty(loTransDetail.pkey)
5818
5819 * --- TR 1034963 12/15/08 CM
5820 lcDetailNotes = GetUniqueFileName()
5821 *-TR 1109914 FH - added and table_Name = 'ZZEIPOTD'
5822 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey) + " and table_Name = 'ZZEIPOTD'"
5823 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5824 * === TR 1034963 12/15/08 CM
5825
5826 *- 1009508 3/16/05 YIK
5827 Select (pcRangeDetailVert)
5828 Scatter Name loVert Memo
5829 *= 1009508
5830
5831 Select (pcTransDetail)
5832 Append Blank
5833 Gather Name loTransDetail Memo
5834
5835 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5836 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5837 * only recording a..e_price to zzeipoth and resetting org_price
5838 *org_price with &pcRangeDetailVert..a_price,
5839
5840 *- 1009508 3/16/05 YIK
5841 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5842 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5843 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5844 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5845 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5846 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5847 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5848 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5849 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5850 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5851 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5852 *-- division WITH &pcRangeDetailVert..division, ;
5853 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5854 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5855 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5856 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5857 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5858 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5859 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5860 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5861 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5862 *-- e_price WITH &pcRangeDetailVert..e_price ;
5863 *-- IN (pcTransDetail)
5864
5865 *- 1022149 03/06/07 YIK
5866 *- do not zero out org_price for MultiUPC
5867 Replace rng_style With loVert.rng_style, ;
5868 rng_color With loVert.rng_color, ;
5869 rng_lbl With loVert.rng_lbl, ;
5870 rng_pack With loVert.rng_pack, ;
5871 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5872 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5873 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5874 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5875 total_qty With lnMultiplier * loVert.total_qty, ;
5876 sizebucket With loVert.sizebucket, ;
5877 size_desc With loVert.size_desc, ;
5878 division With loVert.division, ;
5879 STYLE With loVert.Style, ;
5880 color_code With loVert.color_code, ;
5881 lbl_code With loVert.lbl_code, ;
5882 DIMENSION With loVert.Dimension, ;
5883 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5884 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5885 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5886 a_price With loVert.a_price,; && 4186- store a..e_price
5887 b_price With loVert.b_price,; && from range style detail
5888 c_price With loVert.c_price,; && to use latter when have
5889 d_price With loVert.d_price,; && price_code
5890 e_price With loVert.e_price ;
5891 IN (pcTransDetail)
5892 *= 1009508 03/16/05 YIK
5893 * --- TR 1018184 RLN 01/10/07
5894 Select tmpRngSacs
5895 Scan
5896 Scatter Name loTmpSACs Memo
5897 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5898 loTmpSACs.dfkey = loTransDetail.pkey
5899 Insert Into (tcTransSAC) From Name loTmpSACs
5900 Endscan
5901 * === TR 1018184
5902
5903 * --- TR 1034963 12/15/08 CM
5904 If llDtlRangeNotes
5905 Select (lcDetailNotes)
5906 Scan
5907 Scatter Name loTmpDetNotes Memo
5908
5909 * --- TR 1045865 3/8/10 CM
5910 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5911 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5912 * === TR 1045865 3/8/10 CM
5913
5914 loTmpDetNotes.fkey = loTransDetail.pkey
5915 SELECT('Vzzeipotd_notes_iPOproc')
5916 Append Blank
5917 Gather Name loTmpDetNotes Memo
5918 Endscan
5919 Endif
5920
5921 IF USED(lcDetailNotes)
5922 USE IN (lcDetailNotes)
5923 ENDIF
5924 * === TR 1034963 12/15/08 CM
5925
5926 Else
5927 llRetVal= .F. && Cannot get Pkey from bcsysnum
5928 Exit
5929 Endif
5930
5931 Select (pcRangeDetailVert)
5932 Endscan
5933 Else
5934 llRetVal= .F. && Should be in pcrangdetailvert
5935 Exit
5936 Endif
5937 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5938 Endif
5939
5940 If !llRetVal &&Get out of scan when have some problem
5941 Exit
5942 Endif
5943 Endscan
5944
5945 * --- TR 1034963 12/15/08 CM
5946 If llDtlRangeNotes
5947 *- TR 1109914 FH
5948 *This.UpdateSysNotes()
5949 llRetVal = llRetVal AND this.UpdateSysNotesServerSide()
5950 this.LogResult(llRetVal, "Updating Sysnote Server side")
5951 *- TR 1109914 FH
5952 Endif
5953 * === TR 1034963 12/15/08 CM
5954
5955 Select(lnOldSelect)
5956 Return llRetVal
5957 Endproc
5958
5959 *----------------------------------------------------------------------------------------
5960
5961 Procedure PrepackConversion
5962 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5963 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5964 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5965 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5966 llRetVal = .T.
5967 lnOldSelect = Select()
5968
5969 * --- TR 1046519 7/26/10 CM
5970 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5971 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5972
5973 STORE "" To lcSumSln, lcError, lcPPKAction
5974 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5975 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5976 * === TR 1046519 7/26/10 CM
5977
5978 *****************************************************************************
5979 * 1st Getting all prepack headers
5980 *--- 1001112 9/26/03 YIK
5981 *- process all.
5982 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5983 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5984 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5985 *!* and d.rng_style= '' ; && none exploded range style
5986 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5987 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5988
5989 *- 1013522 10/10/05 12/02/05 YIK
5990 *- Exclude range style P from the consideration
5991 *- Do not close this cursor. It is needed in CheckSLN()
5992 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5993 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5994
5995 *- 1025153 10/22/07 YIK - comment out
5996 * --- TR 1022896 NSD 05-10-07
5997*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5998 * === TR 1022896 NSD 05-10-07
5999
6000 *- 1005499 07/06/04 YIK
6001 *- Change d.rng_style = '' to EMPTY(d.rng_style)
6002
6003 *- 1023438 04/05/07 YIK
6004 *- Allow to check Range Style type 'R'.
6005 *- Needed for MultiUPC and a good idea anyway.
6006 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
6007
6008 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
6009
6010*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
6011*!* FROM (pcTransDetail) d ;
6012*!* WHERE Empty(d.rng_style) ; && none exploded range style
6013*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
6014*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
6015*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
6016*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
6017
6018 *--- TechRec 1044487 18-Mar-2010 JK ---
6019*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
6020*!* FROM (pcTransDetail) d ;
6021*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
6022*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
6023*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
6024*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
6025*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
6026
6027 * --- TR 1046519 7/26/10 CM
6028 IF RECCOUNT(pcSLN) > 0
6029 *--- TR 1101199 16-Feb-2017 Goutam. Added JOIN (pcTransHeader) h ON h.pkey = d.fkey
6030 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
6031 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
6032 JOIN (pcTransDetail) d ;
6033 ON s.fkey = d.pkey ;
6034 JOIN (pcTransHeader) h ON h.pkey = d.fkey ;
6035 JOIN (pceipoCR) c ;
6036 ON h.control_pkey = c.pkey ;
6037 WHERE s.sln_qty > 0 ;
6038 GROUP BY s.fkey ;
6039 INTO CURSOR __SumSlnQty
6040
6041 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
6042
6043 WITH THIS
6044 .cSQLTempTable=""
6045 IF .GenerateSQLTempTable('__SumSlnQty')
6046 IF .PopulateSQLTempTable('__SumSlnQty')
6047 lcSumSln = .cSQLTempTable
6048 IF !EMPTY(lcSumSln)
6049 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
6050 ENDIF
6051 ENDIF
6052 ENDIF
6053 ENDWITH
6054 ENDIF
6055 * === TR 1046519 7/26/10 CM
6056
6057 *--- TechRec 1089737 21-Dec-2015 jisingh ---
6058 IF !EMPTY(This.cOverridePpkAction)
6059 REPLACE ALL ppk_action WITH This.cOverridePpkAction ;
6060 FOR EMPTY(ppk_action) OR ppk_action $ 'QPBO' IN (pcTransDetail)
6061 ENDIF
6062 *=== TechRec 1089737 21-Dec-2015 jisingh ===
6063
6064 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
6065 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
6066 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
6067 *--- TR 1101199 16-Feb-2017 Goutam. Added JOIN (pcTransHeader) h ON h.pkey = d.fkey
6068 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
6069 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
6070 FROM (pcTransDetail) d ;
6071 JOIN (pcTransHeader) h ON h.pkey = d.fkey ;
6072 JOIN (pceipoCR) c ON c.pkey = h.control_pkey ;
6073 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
6074 AND (c.rngp_conv = 'P' ;
6075 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
6076 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
6077 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
6078 AND c.ppk_conv <> 'N' ;
6079 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
6080 *=== TechRec 1044487 18-Mar-2010 JK ===
6081
6082 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
6083 *== 1023438
6084
6085 *=== 1013522
6086 *=== 1001112
6087 With This
6088 .cSQLTempTable=""
6089 If .GenerateSQLTempTable('__TmpCursor')
6090 If .PopulateSQLTempTable('__TmpCursor')
6091 If !Empty(.cSQLTempTable)
6092 *- TR 1025153 06/14/07 YIK
6093 *- Use the OUTER JOIN, then we have all details needed
6094 *- and can simply scan for !EOF() later on.
6095*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
6096*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
6097*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
6098*-- "s.style= t.style and s.color_code= t.color_code and " +;
6099*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
6100*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
6101*-- "s.dimension= ph.ppk_code"
6102 *--- TR 1026025 NH - use size_code from zzxstylr
6103 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
6104 * using sln_qty instead of ppk_qty
6105
6106 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
6107 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
6108 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
6109 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
6110 " ,st.size_code " +; && 1026025
6111 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
6112 " from " + .cSQLTempTable + " t " +;
6113 " JOIN zzxscolr s " + ;
6114 " ON s.division= t.division and " +;
6115 " s.style= t.style and s.color_code= t.color_code and " +;
6116 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
6117 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
6118 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
6119 " LEFT OUTER JOIN zzxppakh ph " + ;
6120 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
6121 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
6122 " Where s.ppack_ok= 'Y' "
6123
6124 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
6125 If Used("_PPK_Qty")
6126 Select ("_PPK_Qty")
6127 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
6128 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
6129 "division+style+color_code+lbl_code+dimension")
6130 SELECT ("__TmpCursor")
6131
6132 If llRetVal
6133 .LogEntry("Validating prepack style.")
6134 lcErrs_Msg = "No valid prepack code found"
6135 Select (pcTransDetail)
6136 *- 1005499 07/06/04 YIK
6137 *- Replace ..Errs_Flg_D= "N") and rng_style=''
6138 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
6139 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
6140*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
6141 *- TR 1025153 06/14/07 YIK
6142 *- Since we use the OUTER JOIN, can simply scan for !EOF()
6143 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
6144 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
6145
6146 If Empty(_PPK_Qty.pack_qty)
6147 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
6148 Errs_Flg_D With "Y" ;
6149 IN (pcTransDetail)
6150 Else
6151 Do Case
6152
6153 * --- TR 1040838 6/11/09 CM
6154 * --- Check prepack action based on Transaction detail
6155 * Removed _PPK_Qty Alias
6156 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
6157 Case ppk_action = 'Q' && multiply qty
6158 * === TR 1040838 6/11/09 CM
6159
6160 * --- TR 1046519 7/26/10 CM
6161 * At this point we know we have some slns to use for our alternate
6162 * conversion, lets just make sure that the conversion type is 'E'
6163 IF llConvertBySln
6164 lcPPKAction = ppk_action
6165 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6166 lnOrigQty = total_qty
6167 lnPpkQty = ppk_qty
6168 ENDIF
6169 * === TR 1046519 7/26/10 CM
6170
6171 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6172 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6173 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6174 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6175 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
6176 In (pcTransDetail)
6177
6178 * --- TR 1046519 7/26/10 CM
6179 IF llSlnConvert
6180 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6181 IF llRemain
6182 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6183 Errs_Flg_D WITH "Y" , ;
6184 ppk_action WITH lcPPKAction , ;
6185 total_qty WITH lnOrigQty ;
6186 In (pcTransDetail)
6187 ENDIF
6188 ENDIF
6189 * ==== TR 1046519 7/26/10 CM
6190
6191 * --- TR 1040838 6/11/09 CM
6192 * Removed _PPK_Qty Alias
6193 *Case _PPK_Qty.ppk_action = 'P' && divide price
6194 Case ppk_action = 'P' && divide price
6195 * === TR 1040838 6/11/09 CM
6196
6197 * --- TR 1046519 7/26/10 CM
6198 * At this point we know we have some slns to use for our alternate
6199 * conversion, lets just make sure that the conversion type is 'E'
6200 IF llConvertBySln
6201 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6202 ENDIF
6203 * === TR 1046519 7/26/10 CM
6204
6205 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6206 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6207 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6208 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6209 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6210 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6211 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6212 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
6213 In (pcTransDetail)
6214 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6215 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6216 *- Range style price will be populated later from a_price..e_price
6217 *- not from org_price. Need to updated these prices here.
6218 IF rng_type = 'R'
6219 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6220 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6221 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6222 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6223 e_price WITH e_price/_PPK_Qty.pack_qty ;
6224 In (pcTransDetail)
6225 ENDIF
6226 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6227
6228 * --- TR 1040838 6/11/09 CM
6229 * Removed _PPK_Qty Alias
6230 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
6231 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
6232 * === TR 1040838 6/11/09 CM
6233
6234 * --- TR 1046519 7/26/10 CM
6235 IF llConvertBySln
6236 lcPPKAction = ppk_action
6237 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6238 lnOrigQty = total_qty
6239 lnPrice = org_price
6240 lnretail1 = retail1
6241 lnretail2 = retail2
6242 lnPpkQty = ppk_qty
6243 ENDIF
6244 * === TR 1046519 7/26/10 CM
6245
6246 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6247 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6248 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6249 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6250 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6251 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6252 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6253 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6254 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
6255 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
6256 In (pcTransDetail)
6257
6258 * --- TR 1046519 7/26/10 CM
6259 IF llSlnConvert
6260 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6261 IF llRemain
6262 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6263 Errs_Flg_D WITH "Y", ;
6264 ppk_action WITH lcPPKAction , ;
6265 total_qty WITH lnOrigQty , ;
6266 org_price WITH lnPrice , ;
6267 retail1 WITH lnretail1 , ;
6268 retail2 WITH lnretail2 , ;
6269 ppk_qty WITH lnPpkQty ;
6270 In (pcTransDetail)
6271 ENDIF
6272 ENDIF
6273 * ==== TR 1046519 7/26/10 CM
6274
6275 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6276 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6277 IF rng_type = 'R'
6278 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6279 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6280 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6281 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6282 e_price WITH e_price/_PPK_Qty.pack_qty ;
6283 In (pcTransDetail)
6284 ENDIF
6285 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6286
6287 Otherwise
6288 Endcase
6289 Endif
6290 Endscan
6291 Endif
6292 Set Relation To
6293 Endif
6294 Endif
6295 Endif
6296 Endif
6297 Endwith
6298 If Used("__TmpCursor")
6299 Use In __TmpCursor
6300 Endif
6301 If Used("_PPK_Qty")
6302 Use In _PPK_Qty
6303 Endif
6304
6305 * --- TR 1046519 7/26/10 CM
6306 IF USED("__SumSlnQty")
6307 USE IN __SumSlnQty
6308 ENDIF
6309 * === TR 1046519 7/26/10 CM
6310
6311 Select(lnOldSelect)
6312 Return llRetVal
6313
6314 *----------------------------------------------------------------------------------------
6315 *- 1006607 09/02/04 YIK
6316 Function ResolveRangeP
6317 Lparameters pceipoTH, pceipoTD, pceipoCR
6318
6319 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
6320 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
6321 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
6322 llRetVal = .T.
6323 lnOldSelect = Select()
6324 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6325 lcRngp_conv = ""
6326 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6327
6328 With This
6329 .oLog.LogMajorStage("Range Style Implosion.")
6330 *- do we have any range styles 'P' in BC
6331 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
6332 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
6333 If !llRetVal Or Recc("tcTemp") = 0
6334 .oLog.LogEntry("No range styles for implosion")
6335 Return llRetVal
6336 Endif
6337
6338 *- 1007637 11/17/04 YIK
6339 *- Allow open stock: Rng_impl = 'O'
6340 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
6341 *- implode only orders that have not been range imploded (empty range style)
6342 *- and were not prepack imploded (implosion <> "Y")
6343 *!* select distinct fkey ;
6344 *!* from (pceipoTd) d ;
6345 *!* join (pceipoCR) c ;
6346 *!* on d.division = c.division and d.customer = c.customer ;
6347 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
6348 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
6349 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
6350 *!* into cursor rng_det
6351
6352*- 1047842/1048069 07/01/10 YIK
6353*- Implode only orders with no detail errors
6354*-- Select Distinct fkey, C.Rng_impl ;
6355*-- FROM (pceipoTD) d ;
6356*-- JOIN (pceipoCR) C ;
6357*-- ON d.division = C.division And d.customer = C.customer ;
6358*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6359*-- AND !Empty(d.division) And !Empty(d.customer) ;
6360*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
6361*-- INTO Cursor rng_det
6362
6363 *- TR 1058336 FH - added division to select, and group by
6364 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
6365 *--- TR 1101199 16-Feb-2017 Goutam. Added JOIN (pcTransHeader) h ON h.pkey = d.fkey
6366 *--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
6367 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6368 FROM (pceipoTD) d ;
6369 JOIN (pceipoTH) h ON h.pkey = d.fkey ;
6370 JOIN (pceipoCR) C ;
6371 ON h.control_pkey = C.pkey ;
6372 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6373 AND !Empty(d.division) And !Empty(d.customer) ;
6374 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6375 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6376 HAVING MAX(errs_flg_d) = 'N' ;
6377 INTO Cursor rng_det
6378*===
6379
6380 *==
6381 *--- TR 1023892 NH
6382 IF .lALLOW_RANGE_HDR_LABEL
6383 &&- TR 1058336 FH - added qualifier for division
6384 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
6385 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6386 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 ;
6387 FROM (pceipoTD) d ;
6388 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6389 WHERE !EMPTY(d.STYLE) ;
6390 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
6391 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
6392 INTO CURSOR __TmpCurs
6393 ELSE
6394 &&- TR 1058336 FH - added qualifier for division
6395 *=== TR 1023892 NH
6396 *- 1047842/1048069 07/01/10 YIK
6397 *- Added d.pkey
6398 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6399 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
6400 FROM (pceipoTD) d ;
6401 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6402 WHERE !Empty(d.Style) ;
6403 AND !Empty(d.division) And !Empty(d.customer) ;
6404 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6405 INTO Cursor __tmpCurs
6406 ENDIF && TR 1023892 NH
6407 .cSQLTempTable=""
6408 If .GenerateSQLTempTable('__TmpCurs')
6409 If .PopulateSQLTempTable('__TmpCurs')
6410 If !Empty(.cSQLTempTable)
6411 Select rng_det
6412 Scan
6413 lnFKey = rng_det.fkey
6414 *- 1007637 11/17/04 YIK
6415 lcRng_Impl = rng_det.Rng_impl
6416
6417 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6418 lcRngp_conv = rng_det.Rngp_conv
6419 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6420
6421 lcDivision = rng_det.division &&- TR 1058336 FH
6422
6423 *- one order at a time. Select on the server side.
6424 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
6425 dtl = SQLTableFromQuery(lcSQLStr )
6426 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
6427
6428 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
6429 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
6430
6431 Select (pceipoTD)
6432 Do Case
6433 Case lnResult = 0 && match not found
6434 *- 1007637 11/17/04 YIK
6435 If lcRng_Impl = 'Y'
6436
6437 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
6438 Errs_Flg_D With "Y" ;
6439 FOR fkey = lnFKey And !Empty(Style) ;
6440 AND !Empty(division) And !Empty(customer) ;
6441 AND Empty(rng_style) And implosion <> "Y"
6442 Endif
6443 Case lnResult > 1 && ambiguous
6444 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
6445 *- 1049007 08/24/10 YIK
6446 *- List all ambiguous Range Styles
6447 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
6448 Errs_Flg_D With "Y" ;
6449 FOR fkey = lnFKey And !Empty(Style) ;
6450 AND !Empty(division) And !Empty(customer) ;
6451 AND Empty(rng_style) And implosion <> "Y"
6452*!* lcErrorMsg = " Ambiguous range styles "
6453*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
6454*!* lcErrorMsg = lcErrorMsg + ": "
6455*!* SELECT __tmp
6456*!* SCAN
6457*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
6458*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
6459*!* EndScan
6460*!* SELECT(pceipoTD)
6461*!* ENDIF
6462*!*
6463*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
6464*!* Errs_Flg_D With "Y" ;
6465*!* FOR fkey = lnFKey And !Empty(Style) ;
6466*!* AND !Empty(division) And !Empty(customer) ;
6467*!* AND Empty(rng_style) And implosion <> "Y"
6468 *=== 1049007
6469 Endcase
6470 Endscan
6471 Endif
6472 Endif
6473 Endif
6474
6475 Endwith
6476 Select (lnOldSelect)
6477 Return llRetVal
6478 Endfunc
6479
6480 Function RangeImplosion
6481 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6482 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6483 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6484
6485 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6486 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6487 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6488
6489 llRetVal = .T.
6490 lnOldSelect = Select()
6491 With This
6492
6493 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6494 *- turn them vertical into SQL-side temp table var. RangD
6495 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6496 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6497*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6498*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6499*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6500*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6501*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6502*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6503
6504*!* Added following join
6505*!* " join " + dtl + " td1 " +;
6506*!* " on d.style = td1.style " +;
6507*!* " and d.color_code = td1.color_code " +;
6508*!* " and d.lbl_code = td1.lbl_code " +;
6509*!* " and d.dimension = td1.dimension "
6510
6511 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6512
6513 *--- TR 1084825 20-Feb-2015 BNarayanan adding the join on division, sizebucket for the dtl table join ---
6514 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6515 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6516 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6517 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6518 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6519 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6520 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6521 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6522 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6523 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6524 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6525 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6526 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6527 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6528 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6529 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6530 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6531 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6532 "coalesce(cs.e_price,d.e_price) as e_price "+;
6533 "from ( " +;
6534 " select dd.* from zzxrangd dd " +;
6535 " where fkey in ( " +;
6536 " select distinct ph.pkey " +;
6537 " from zzxrangh ph " +;
6538 " join zzxrangd pd " +;
6539 " on ph.Pkey = Pd.Fkey " +;
6540 " join " + dtl + " td1 " +;
6541 " on pd.division = td1.division " + ; && TR 1084825 03-Mar-2015 BNarayanan
6542 " and pd.style = td1.style " +;
6543 " and pd.color_code = td1.color_code " +;
6544 " and pd.lbl_code = td1.lbl_code " +;
6545 " and pd.dimension = td1.dimension " +;
6546 " where ph.rng_type = 'P' " +;
6547 " and not exists( " +;
6548 " select * " +;
6549 " from zzxrangd da " +;
6550 " left join " + dtl + " det " +;
6551 " on det.division= da.division" +; && TR 1084825 03-Mar-2015 BNarayanan
6552 " and det.style = da.style " +;
6553 " and det.color_code = da.color_code " +;
6554 " and det.lbl_code = da.lbl_code " +;
6555 " and det.dimension = da.dimension " +;
6556 " where da.Fkey = ph.pkey " +;
6557 " and (det.Pkey is null " +;
6558 " or case det.SizeBucket " +;
6559 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6560 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6561 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6562 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6563 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6564 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6565 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6566 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6567 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6568 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6569 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6570 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6571 " ) ) d " +;
6572 " join zzxbuckt b " +;
6573 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6574 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6575 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6576 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6577 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6578 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6579 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6580 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6581 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6582 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6583 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6584 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 " + ;
6585 " join " + dtl + " td1 " +;
6586 " on d.division = td1.division " +; && TR 1084825 20-Feb-2015 BNarayanan
6587 " and d.style = td1.style " +;
6588 " and d.color_code = td1.color_code " +;
6589 " and d.lbl_code = td1.lbl_code " +;
6590 " and d.dimension = td1.dimension "+;
6591 " and size_num = td1.sizebucket " +; && TR 1084825 20-Feb-2015 BNarayanan
6592 " Left join zzxcsrgh cs "+ ;
6593 " on cs.dtlpkey = d.pkey "+ ;
6594 " and cs.customer = td1.customer "
6595
6596 RangD = SQLTableFromQuery(lcSQLString)
6597
6598 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6599 *- possible combinations of RangD that cover them.
6600 *- Result is SQL-side temp table var. RangeSet
6601 *- 1047842/1048069 07/01/10 YIK
6602 *- Added td.pkey
6603 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6604 *--- 1049007 08/24/10 YIK
6605 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6606 *- to check for components divisibility
6607 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6608 *--- TR 1084825 03-Mar-2015 BNarayanan added td.division in the select ---
6609 lcSQLString = ;
6610 'select td.division,td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6611 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6612 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6613 ',td.pkey as dtl_pkey ' + ;
6614 ' from ' + dtl + ' td ' + ;
6615 ' cross join ( ' + ;
6616 ' select * ' + ;
6617 ' from zzxrangh H ' + ;
6618 ' where exists ( ' + ;
6619 ' select * ' + ;
6620 ' from ' + RangD + ' dd ' + ;
6621 ' join ' + dtl + ' td1 ' + ;
6622 ' on dd.Division = td1.Division ' + ;
6623 ' and dd.style = td1.style ' + ;
6624 ' and dd.color_code = td1.color_code ' + ;
6625 ' and dd.lbl_code = td1.lbl_code ' + ;
6626 ' and dd.dimension = td1.dimension ' + ;
6627 ' and dd.size_bk = td1.sizebucket ' + ;
6628 ' where dd.FKey = H.PKey )) mtch ' + ;
6629 ' left join ' + RangD + ' D ' + ;
6630 ' on d.FKey = mtch.PKey ' + ;
6631 ' and d.Division = td.Division ' + ;
6632 ' and d.style = td.style ' + ;
6633 ' and d.color_code = td.color_code ' + ;
6634 ' and d.lbl_code = td.lbl_code ' + ;
6635 ' and d.dimension = td.dimension ' + ;
6636 ' and d.size_bk = td.sizebucket ' + ;
6637 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6638 *==104900708/24/10YIK
6639 RangeSet = SQLTableFromQuery(lcSQLString)
6640
6641 * --- TR 1048126 8/23/10 CM
6642 v_SqlExec(lcSQLString, "tcRangeSet")
6643
6644 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6645*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6646*!*
6647*!* UPDATE d ;
6648*!* SET ppk_qty = -1 ;
6649*!* FROM (pceipoTD) d ;
6650*!* JOIN tcRangeSet r ;
6651*!* ON d.pkey = r.dtl_pkey ;
6652*!* WHERE d.ppk_action $ 'XM'
6653*!*
6654*!* ENDIF
6655 *=== TR 1051390 23-Dec-2010 Goutam
6656
6657 * === TR 1048126 8/23/10 CM
6658
6659 *- how many different range styles were found for this order
6660 *--- 1049007 08/24/10 YIK
6661 *- Modify logic to determine ambiguos Range Styles
6662*-- lcSQLString = ;
6663*-- ' select count(*) PPKCnt ' + ;
6664*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6665
6666 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6667 *= 1049007
6668
6669 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6670 lnPPKCnt = tmp_cnt.PPKCnt
6671
6672 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6673 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6674 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6675
6676 *--- the result (Query #2):
6677 *- See if any single range style in the RangeSet fully matches DTL
6678 *- 1047842/1048069 07/01/10 YIK
6679 *- added t1dtl_pkey
6680 lcSQLString = ;
6681 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6682 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6683 ' from ' + dtl + ' dtl ' + ;
6684 ' join ' + RangeSet + ' t1 ' + ;
6685 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6686 ' and dtl.style = t1.style ' + ;
6687 ' and dtl.color_code = t1.color_code ' + ;
6688 ' and dtl.lbl_code = t1.lbl_code ' + ;
6689 ' and dtl.dimension = t1.dimension ' + ;
6690 ' and dtl.sizebucket = t1.sizebucket ' + ;
6691 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6692 ' having count(*) = (select count(*) from ' + dtl + ') '
6693 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6694 lnCnt = Reccount()
6695
6696 *- 1049007 08/24/10 YIK
6697 *- Exclude Range styles that are not divisible
6698 IF (lnCnt > 0)
6699 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6700 lnCnt = _TALLY
6701 ENDIF
6702 *=
6703
6704 llSingleMatch = .F.
6705 llAmbig = .F.
6706 *- 1047842/1048069 07/01/10 YIK
6707 *- Added ValidDetail
6708 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6709 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6710 Do Case
6711 Case lnCnt > 1
6712 *- 1049007 08/24/10 YIK
6713 USE IN SELECT("__tmp")
6714 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6715 *=
6716 llAmbig = .T. && ambiguos, give error message and do not continue
6717 Case lnCnt = 1
6718 llSingleMatch = .T.
6719 *- 1047842/1048069 07/01/10 YIK
6720 *- Added ValidDetail
6721 *- 1049007 08/26/10 YIK
6722 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6723* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6724 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6725 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6726
6727 Otherwise
6728 Endcase
6729 *- 1049007 08/24/10 YIK
6730 *- commented out. This method is not called with this parameter = .T.
6731*--- IF tlNoConsol
6732*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6733*--- ENDIF
6734
6735 lnResult = lnCnt
6736
6737 If !llAmbig
6738 *- If none single range style in the RangeSet fully matches DTL,
6739 *- or even if a match was found
6740 *- start going through combinations of 2,3... - may be ambiguous
6741
6742 *- 1047842/1048069 07/01/10 YIK
6743 *- added t1dtl_pkey
6744 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6745
6746 lcTopStr = ;
6747 ' from ' + dtl + ' dtl ' + ;
6748 ' join ' + RangeSet + ' t1 ' + ;
6749 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6750 ' and dtl.style = t1.style ' + ;
6751 ' and dtl.color_code = t1.color_code ' + ;
6752 ' and dtl.lbl_code = t1.lbl_code ' + ;
6753 ' and dtl.dimension = t1.dimension ' + ;
6754 ' and dtl.sizebucket = t1.sizebucket '
6755
6756 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6757 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6758 lcMiddleStr = ''
6759 lcCoalStr_pkey = 't1.pkey'
6760 lcCoalRevStr_pkey = 't1.pkey'
6761 lcCoalStr_ratio = 't1.ratio'
6762 lcCoalRevStr_ratio = 't1.ratio'
6763 lcGroupFkeyStr = ' t1.FKey'
6764 lcGroupStr = ''
6765
6766 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6767 *lnPrepacks = Min(lnPPKCnt, 6)
6768 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6769 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6770 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6771
6772 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6773
6774 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6775 llFoundNext = .F.
6776
6777 lcnum = Trans(j, "9")
6778 lcPrevNum = Trans(j - 1, "9")
6779 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6780 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6781
6782 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6783
6784 *-- TR 1049817 Oct-12-2010 BR
6785 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6786 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6787 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6788 *== TR 1049817 Oct-12-2010 BR
6789
6790 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6791
6792 *--- TR 1049817 Oct-12-2010 BR
6793 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6794 lcGroupStr = lcGroupFkeyStr
6795 *=== TR 1049817 Oct-12-2010 BR
6796
6797 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6798 *- 06/30/10 YIK LOCAL ONLY
6799 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6800 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6801 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6802 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6803
6804 lcMiddleStr = lcMiddleStr + ;
6805 "join " + RangeSet + " t" + lcnum + ;
6806 ' on dtl.division = t' + lcnum + '.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6807 ' and dtl.style = t' + lcnum + '.style ' + ;
6808 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6809 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6810 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6811 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6812 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6813
6814 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6815 ' Group by ' + lcGroupStr
6816
6817 *--- TR 1049817 Oct-12-2010 BR
6818 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6819 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6820 *=== TR 1049817 Oct-12-2010 BR
6821
6822 *--- TR 1050754 NOV-15-2010 BR
6823 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6824 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6825 *=== TR 1050754 NOV-15-2010 BR
6826
6827 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6828 lnCnt = Reccount()
6829 llFoundNext = (lnCnt = 1)
6830 *- ambig when either prev or this SQL returned more than 1 row or
6831 *- one match was found before AND one is found now - making it two.
6832 If lnCnt > 0
6833 Scan
6834 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6835 *- divisible by the number of items in the range style!!!
6836
6837 *---TR 1049817 Oct-12-2010 BR
6838 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6839 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6840 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6841 *===TR 1049817 Oct-12-2010 BR
6842 Else
6843 lcInsertStr = Trans(fkey)
6844 *- 1047842 06/17/10 YIK
6845 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6846
6847 For lnCounter = 2 To j
6848
6849 *- TR 1055009 FH - added If statement
6850 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6851
6852 else
6853 *- 1047842 06/17/10 YIK
6854 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6855 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6856 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6857 *- Added ValidDetail
6858 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6859 ENDIF
6860 *- TR 1055009 FH
6861
6862 Endfor
6863
6864 *---TR 1049817 Oct-12-2010 BR
6865 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6866 lcInsertRatioStr = Trans(t1_ratio)
6867
6868 For lnCounter = 2 To j
6869 *- TR 1055009 FH - added If statement
6870 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6871
6872 ELSE
6873 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6874 ENDIF
6875 *- TR 1055009 FH - added If statement
6876 ENDFOR
6877 *== =TR 1049817 Oct-12-2010 BR
6878
6879 *- 1047842/1048069 07/01/10 YIK
6880 *- Added ValidDetail
6881 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6882 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6883
6884 Endif
6885 Endscan
6886 Endif
6887 lnResultCnt = Recc("q_Result")
6888 llAmbig = (lnResultCnt > 1)
6889 llSingleMatch = (lnResultCnt = 1)
6890 If llAmbig
6891 lnResult = lnResultCnt
6892 Exit
6893 Endif
6894 Endfor
6895 If llSingleMatch
6896 lnResult = 1
6897 IF NOT tlNoConsol
6898 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6899
6900 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6901 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6902 ENDIF
6903 Endif
6904 Else && ambiguous
6905 lnResult = lnCnt
6906 Endif
6907
6908 *--- TR 1051390 23-Dec-2010 Goutam
6909 *--- 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
6910 *IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6911 IF VARTYPE(pceipoTD) <> 'L' AND lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6912 *=== TR 1092774 27-Jan-2016 BNarayanan ===
6913 UPDATE d ;
6914 SET ppk_qty = -1 ;
6915 FROM (pceipoTD) d ;
6916 JOIN tcRangeSet r ;
6917 ON d.pkey = r.dtl_pkey ;
6918 WHERE d.ppk_action $ 'XM'
6919 ENDIF
6920 *=== TR 1051390 23-Dec-2010 Goutam
6921
6922 Endwith
6923 Return lnResult
6924
6925 Procedure ConsolidateRangeP
6926 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6927 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6928 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6929
6930 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6931
6932 LOCAL lcDvision && 1058336 FH
6933
6934 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6935 LOCAL lnOrgPrice
6936 IF EMPTY(pcRngp_conv )
6937 pcRngp_conv = "N"
6938 ENDIF
6939 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6940
6941 llRetVal = .T.
6942 lnOldSelect = Select()
6943
6944 *- insert range styles that match zzxrangd.fkey from q_result
6945 *- into pceipotd.
6946 *- parse the string from cursor q_result to get the list of fkeys
6947 *- 1047842/1048069 07/01/10 YIK
6948 *- Moved Locate down
6949*-- Select (pceipoTD)
6950*-- Locate For fkey = pnFkey
6951*-- Scatter Name oDtl Memo
6952
6953 Declare aRange[1]
6954 aRange = ''
6955 Select q_Result
6956 Scatter Memvar Memo
6957 *- 1030497 02/29/08 TT
6958 *--StringToArray(m.ValidRange, @aRange, ",")
6959
6960 *--TR 1040854 Jun-11-09 BR
6961 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6962 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6963 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6964 *==TR 1040854 Jun-11-09 BR
6965
6966 *- 1030497 02/29/08 TT
6967 *-- TR 1049817 Oct-12-2010 BR
6968 *lnLen = Alen(aRange) - 1 && the last element is ratio
6969 lnLen = Alen(aRange)
6970 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6971 *== TR 1049817 Oct-12-2010 BR
6972
6973 *- 1047842/1048069 07/01/10 YIK
6974 Declare aDetail[1]
6975 aDetail = ''
6976 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6977 *= 1047842/1048069
6978
6979 *-- TR 1049817 Oct-12-2010 BR
6980 DECLARE aRatios[1]
6981 aRatios = ''
6982 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6983 *== TR 1049817 Oct-12-2010 BR
6984
6985 For j = 1 To lnLen
6986 lcFkey = aRange[j]
6987 *- 1047842/1048069 07/01/10 YIK
6988 lnDtl_Pkey = EVALUATE(aDetail[j])
6989 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6990
6991 Select (pceipoTD)
6992 Locate For pkey = lnDtl_Pkey
6993 Scatter Name oDtl Memo
6994 *= 1047842/1048069
6995 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6996*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6997 *--- TR 1084825 20-Feb-2015 BNarayanan removed the column h.RNG_PACK_001, which is not available in zzxrangh table and where clause ---
6998 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6999 " coalesce(cs.a_price,h.a_price) as a_price, "+;
7000 " coalesce(cs.b_price,h.b_price) as b_price, "+;
7001 " coalesce(cs.c_price,h.c_price) as c_price, "+;
7002 " coalesce(cs.d_price,h.d_price) as d_price, "+;
7003 " coalesce(cs.e_price,h.e_price) as e_price, "+;
7004 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
7005 " h.SOURCETYPE,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
7006 " From zzxrangh h " + ;
7007 " Left Join zzxcsrgh cs "+ ;
7008 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
7009 " and cs.customer = "+ SQLFormatChar(oDtl.Customer) + ;
7010 " where h.pkey = " + lcFkey && 1084825
7011 v_SqlExec(lcSQL ,"__RangH")
7012 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
7013 lcDvision = __RangH.division && 1058336 FH
7014
7015 oDtl.Style = __RangH.rng_style
7016 oDtl.color_code = __RangH.rng_color
7017 oDtl.lbl_code = __RangH.rng_lbl
7018 oDtl.Dimension = __RangH.rng_pack
7019 oDtl.rng_style = __RangH.rng_style
7020 oDtl.rng_color = __RangH.rng_color
7021 oDtl.rng_lbl = __RangH.rng_lbl
7022 oDtl.rng_pack = __RangH.rng_pack
7023 oDtl.rng_qty = __RangH.rng_qty
7024 oDtl.rng_type = __RangH.rng_type
7025 *- don't have to have upc or sku for the imploded range style
7026 oDtl.upc = ''
7027 oDtl.sku = ''
7028 oDtl.coord_code = __RangH.coord_code
7029 oDtl.a_price = __RangH.a_price
7030 oDtl.b_price = __RangH.b_price
7031 oDtl.c_price = __RangH.c_price
7032 oDtl.d_price = __RangH.d_price
7033 oDtl.e_price = __RangH.e_price
7034 *- clear err msg and err flag which may have error after unsuccessful implosion
7035 oDtl.Errs_Msg_D = ""
7036
7037 *- 1009211 03/09/05 YIK
7038 *- Initializ3e errs_flg_d to N, not blank
7039 *- oDtl.Errs_Flg_D = " "
7040 oDtl.Errs_Flg_D = "N"
7041 *- org_price is based on zzocntrc (cust sales) price_code
7042 *- we'll get the proper price_code in ValidOrderControl()
7043 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
7044
7045 *- 1009211 02/24/05 YIK
7046 *- Keep quantity in cases and use price per case.
7047 *- and zero out orig price which will be resolved.
7048 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
7049
7050 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
7051 lnOrgPrice = oDtl.org_price
7052 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
7053
7054 oDtl.total_qty = lnRatio
7055 oDtl.org_price = 0
7056
7057 *--- TR 1060800 24-May-2012 Goutam.
7058 oDtl.Rng_Impl = pcRng_Impl
7059 oDtl.Rngp_conv = pcRngp_conv
7060 *=== TR 1060800 24-May-2012 Goutam.
7061
7062 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
7063 IF pcRngp_conv = "R"
7064 *--- TechRec 1057383 15-Dec-2011 jisingh ---
7065*!* oDtl.ppk_qty = __RangH.rng_qty
7066*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
7067*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
7068*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
7069*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
7070*!* oDtl.ppk_action = 'X'
7071
7072 IF EMPTY(oDtl.ppk_action)
7073 oDtl.org_price = lnOrgPrice
7074 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
7075 ENDIF
7076
7077 IF oDtl.ppk_action = "B"
7078 oDtl.org_price = lnOrgPrice
7079 oDtl.ppk_qty = __RangH.rng_qty
7080 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
7081 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
7082 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
7083 oDtl.ppk_action = 'X'
7084 ENDIF
7085
7086 IF oDtl.ppk_action = "Q" && Qty conversion only
7087 oDtl.org_price = lnOrgPrice
7088 oDtl.ppk_qty = __RangH.rng_qty
7089 oDtl.retail1 = oDtl.retail1
7090 oDtl.retail2 = oDtl.retail2
7091 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
7092 oDtl.ppk_action = 'M'
7093 ENDIF
7094
7095 IF oDtl.ppk_action = "P" && Price conversion only
7096 oDtl.org_price = lnOrgPrice
7097 oDtl.ppk_qty = __RangH.rng_qty
7098 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
7099 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
7100 oDtl.total_qty = oDtl.total_qty
7101 oDtl.ppk_action = 'D'
7102 ENDIF
7103 *=== TechRec 1057383 15-Dec-2011 jisingh ===
7104 ENDIF
7105 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
7106
7107 *= 1009211
7108 *- 1047842/1048069 07/01/10 YIK
7109 *- Clear po1_upc and po1_sku as they get populated on the way out
7110 oDtl.po1_upc = ''
7111 oDtl.po1_sku = ''
7112
7113
7114 *- Per JR, put into the 1st available size bucket
7115 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
7116 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
7117 If !llRetVal
7118 Exit
7119 Else
7120 *-- TR 1049817 Oct-12-2010 BR
7121 *oDtl.sizebucket = At("Y", __tmp.sizes)
7122 oDtl.sizebucket = __RangH.rng_bk
7123 oDtl.rng_bk = oDtl.sizebucket
7124 lcSzStr = __tmp.sizes
7125 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
7126 *== TR 1049817 Oct-12-2010 BR
7127 Endif
7128 *-- TR 1049817 Oct-12-2010 BR
7129 IF !llValidRngBk
7130 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
7131 oDtl.errs_flg_d = 'Y'
7132 ENDIF &&TR 1106469 FH - Update size_desc unconditionally, even if rng_bk is invalid. - read Dev note
7133 *== TR 1049817 Oct-12-2010 BR
7134
7135 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
7136 llRetVal = .F.
7137 Exit
7138 Endif
7139 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
7140 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
7141
7142 oDtl.pkey = v_nextPkey("ZZEIPOID")
7143 *=== TR 1059965 6-Mar-12 Venuk
7144
7145 Select (pceipoTD)
7146 Append Blank
7147
7148 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
7149 *Gather Name oDtl
7150 Gather Name oDtl memo
7151 *=== TR 1065271 11-Jan-2013 BNarayanan ===
7152
7153 Endfor
7154 If llRetVal
7155 *- delete components
7156 Delete For fkey = pnFkey And !Empty(Style) ;
7157 AND !Empty(division) And !Empty(customer) ;
7158 AND Empty(rng_style) And implosion <> "Y" ;
7159 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
7160 IN (pceipoTD)
7161 Endif
7162 Select (lnOldSelect)
7163 Return llRetVal
7164 *========== 1006607 09/02/04 YIK
7165
7166 *----------------------------------------------------------------------------------------
7167
7168 *--- TechRec 1005163 17-May-2004 GS ---
7169 *-- Validating SLN vs. Prepack
7170 Procedure CheckSLN
7171 Parameters pceipoTH, pceipoTD, pceipoTS
7172 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
7173 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
7174 lcDtl_lbl_code && *-TR 1075660 SK
7175
7176 lnOldDtlPKey = -1
7177 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
7178 *--- TR 1023892 NH
7179 lnOldSelect = SELECT()
7180 llRetVal = .t.
7181 *=== TR 1023892 NH
7182 Select (pceipoTS)
7183 Set Order To Tag fkey
7184
7185 SCAN
7186 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
7187 IF SkipSlnChk = "Y"
7188 LOOP
7189 ENDIF
7190 *=== TR 1035223 NH
7191
7192 If lnOldDtlPKey != fkey
7193 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
7194 *-- this checks that there is no more records left in BC PrePack info
7195 *-- after all matching to SLNs deleted. Made as a separate routine
7196 *-- because it must be called when detail key changed and when scan is finished.
7197 *-- Error info applied to Detail.
7198 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7199 Endif
7200 lnOldDtlPKey = fkey
7201 lcPPackError = ""
7202 lcDtlError = ""
7203 Select (pceipoTD)
7204 *- 1008909 01/18/05 YIK
7205 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
7206 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
7207 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
7208 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
7209 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
7210 *- TR 1097936 FH - added check if detail lbl is empty, then lets use cust_lbl
7211 lcDtl_lbl_code = IIF(llRangeStyle, NULL, IIF(EMPTY(lbl_code), cust_lbl, lbl_code)) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
7212
7213 *- 1013522 10/17/05 12/02/05 YIK
7214 *- Check for the range style type P. For it there's no explosion to components and the range
7215 *- style info is not written into detail table, but it is still a range style and we should skip it.
7216 Local Array laRangP[1]
7217 laRangP[1] = 0
7218 *--- TR 1023892 NH
7219 IF .lALLOW_RANGE_HDR_LABEL
7220 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
7221 SELECT COUNT(*) ;
7222 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7223 ON d.division = r.division ;
7224 AND d.STYLE = r.rng_style ;
7225 AND d.color_code = r.rng_color ;
7226 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
7227 AND d.DIMENSION = r.rng_pack ;
7228 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
7229 INTO ARRAY laRangP
7230 ELSE
7231 *=== TR 1023892 NH
7232 Select Count(*) ;
7233 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7234 On d.division = r.division ;
7235 AND d.Style = r.rng_style ;
7236 AND d.color_code = r.rng_color ;
7237 AND d.lbl_code = r.rng_lbl ;
7238 AND d.Dimension = r.rng_pack ;
7239 WHERE d.pkey = lnOldDtlPKey ; && TR 1090099 FH
7240 INTO Array laRangP
7241 ENDIF && TR 1023892 NH
7242 llRangeStyle = llRangeStyle Or laRangP[1] > 0
7243 *= 1013522 YIK
7244
7245 llDtlHasError = (Errs_Flg_D = 'Y')
7246 *- 1008909 01/18/05 YIK
7247 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7248 If llDtlHasError Or llRangeStyle
7249 *= 1008909
7250 Loop && For unresolved Details do not even bother...
7251 Endif
7252
7253 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
7254 *-- set to NULL if any C and/or L can be used for the PrePack:
7255 *- 08/25/04 YIK
7256 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
7257 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
7258 lcSQL = ;
7259 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
7260 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
7261 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
7262 " d.Dimension, Pack_Total," +;
7263 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7264 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7265 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7266 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7267 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7268 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
7269 " Size_Num as Sizebucket" +;
7270 " from zzxscolr c" +;
7271 " join zzxstylr st"+;
7272 " on st.pkey = c.fkey "+;
7273 " join zzxppakh h" +;
7274 " on h.Division = c.Division" +;
7275 " and h.PPK_CODE = c.Dimension" +;
7276 " and h.Size_Code = st.Size_Code" +; && TR 1026025
7277 " join zzxppakd d" +;
7278 " on d.Fkey = h.PKey" +;
7279 " cross join zzxbuckt" +;
7280 " where c.Division = " + SQLFormatChar(division ) + ;
7281 " and c.Style = " + SQLFormatChar(Style ) + ;
7282 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
7283 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
7284 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
7285 " and c.PPack_Ok = 'Y'" +;
7286 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7287 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7288 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7289 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7290 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7291 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
7292 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
7293
7294 v_SqlExec(lcSQL, "tcPPK")
7295 If Reccount("tcPPK") > 0
7296 lnPPK_SLN_Diff = pack_qty
7297 Else
7298 lnPPK_SLN_Diff = 0
7299 Endif
7300 Endif
7301 *- 1008909 01/18/05 YIK
7302 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7303 If llDtlHasError Or llRangeStyle
7304 Loop && For unresolved Details do not even bother...
7305 Endif
7306
7307 Select (pceipoTS)
7308
7309 If Reccount("tcPPK") = 0
7310 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
7311 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7312 Loop
7313 Endif
7314
7315 If tcPPK.active_ok = 'N'
7316 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
7317 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7318 Loop
7319 Endif
7320
7321 If Errs_Flg_S = 'Y'
7322 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
7323 Loop && UPC/EAN/SKU is unesolved.
7324 Endif
7325
7326 lcStyle = style && *- TR 1064758 FH
7327 lcColor_code = color_code
7328 lcLbl_code = lbl_code
7329 lcDimension = Dimension
7330 lnSLN_Qty = SLN_Qty
7331 lnSizeBucket = sizebucket
7332
7333 *- TR 1106856 FH - comment this, updating the screen with the same message every loop
7334 *.AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
7335
7336 Select tcPPK
7337
7338 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
7339 *FH 1084440 - added EMPTY(lcLbl_code) - if sln lbl is '', don't need to compare between DTL lbl and SLN lbl.
7340 * If DTL grabbed cust label from 850 control, second time running process will fail validation (lbl no longer matches)
7341
7342 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
7343 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
7344 AND ((Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code) OR (NVL(lbl_Code,'') = ALLTRIM(lcLbl_code))) && TR 1084440
7345
7346 If Found()
7347 Delete && in PrePack info leave only unresolved ones.
7348 Else
7349 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
7350 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
7351 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
7352 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
7353 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
7354 If !"Has errors in SLNs."$lcDtlError
7355 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
7356 Endif
7357 Endif
7358
7359 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
7360 *if lnPPK_SLN_Diff < 0
7361 *endif
7362 Endscan
7363 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
7364
7365 *- 1008909 01/18/05 YIK
7366 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
7367 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
7368 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7369 Endif
7370 *- 1013522 10/17/05 12/02/05 YIK
7371 If Used("__RangeP")
7372 Use In __RangeP
7373 Endif
7374 *=
7375 *--- TR 1023892 NH
7376 SELECT(lnOldSelect)
7377 RETURN llRetVal
7378 *== TR 1023892 NH
7379
7380 Endproc
7381
7382 *----------------------------------------------------------------------------------------
7383 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
7384 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
7385 Procedure CheckSlnSet
7386 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
7387
7388 Local lnOldSelect
7389
7390 lnOldSelect = Select()
7391
7392 If !Empty(tcPPKError)
7393 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7394 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7395 Return
7396 Endif
7397
7398 Select tcPPK
7399 Scan
7400 tcDtlError = tcDtlError +;
7401 "Missing Prepack Component" + ;
7402 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
7403 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
7404 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
7405 "; Qty:"+Transform(Qty) + CRLF
7406 Endscan
7407
7408 If !Empty(tcDtlError)
7409 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7410 Local lcErr
7411 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
7412 If !Empty(lcErr)
7413 tcDtlError = CRLF + tcDtlError
7414 Endif
7415 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7416 Endif
7417
7418 Select (lnOldSelect)
7419
7420 Endproc
7421
7422 *----------------------------------------------------------------------------------------
7423
7424 ************************************************************************************
7425 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7426 * 1. Try to substitute lbl_code with customer label when have the following conditions:
7427 * Header: customer
7428 * Detail: division,style,color_code
7429 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
7430 * resolve all detail division into header )
7431 ************************************************************************************
7432 Procedure ResolveCustomerLabel
7433 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7434 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
7435 Local llRetVal, lnOldSelect
7436 llRetVal = .T.
7437 lnOldSelect = Select()
7438 With This
7439 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
7440 *--- TechRec 1048667 03-May-2011 GSternik ---
7441 *-- Not needed, already done in the calling CheckDetail
7442 *.LogEntry("Cascading Customer To Detail.")
7443 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
7444 *=== TechRec 1048667 03-May-2011 GSternik ===
7445 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
7446 .LogEntry("Substituding customer label.")
7447 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7448 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
7449 .LogEntry("Auto creating style.")
7450 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7451 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
7452 * PL 08/22/01 27847 Auto-create Customer SKU
7453 .LogEntry("Auto creating customer style.")
7454 *--- TechRec 1005163 18-May-2004 GS ---
7455 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7456 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
7457 *=== TechRec 1005163 18-May-2004 GS ===
7458
7459 Endwith
7460 Select(lnOldSelect)
7461 Return llRetVal
7462 Endproc
7463
7464
7465 *----------------------------------------------------------------------------------------
7466 ************************************************************************************
7467 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7468 ************************************************************************************
7469 Procedure CascadingCustomerToDetail
7470 Lparameters pceipoTH, pceipoTD
7471 Local llRetVal, lnOldSelect
7472 llRetVal = .T.
7473 lnOldSelect = Select()
7474 With This
7475 * set header/detail Relation
7476 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
7477 * --- TR 1019358 RLN 10/30/06
7478 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
7479 Replace All customer With &pceipoTH..customer, ;
7480 department With &pceipoTH..department ;
7481 IN (pceipoTD)
7482 * === TR 1019358
7483 Set Relation To
7484 Endwith
7485 Select(lnOldSelect)
7486 Return llRetVal
7487 Endproc
7488
7489 *----------------------------------------------------------------------------------------
7490 *---- TR 1019697 NH
7491 Procedure CascadingCustomerToSLN
7492 Lparameters pceipoTD, pceipoTS
7493 Local llRetVal, lnOldSelect
7494 llRetVal = .T.
7495 lnOldSelect = Select()
7496 With This
7497 * set detail/SLN Relation
7498 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7499 Replace All customer With &pceipoTD..customer In (pceipoTS)
7500 Set Relation To
7501 Endwith
7502 Select(lnOldSelect)
7503 Return llRetVal
7504 Endproc
7505 *==== TR 1019697 NH
7506
7507 *----------------------------------------------------------------------------------------
7508 ************************************************************************************
7509 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7510 ************************************************************************************
7511 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7512 * regardless of auto_create of style flag set in Customer Label Ref.
7513 Procedure SubstitudeValidLabel
7514 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7515 Local llRetVal, lnOldSelect
7516 llRetVal = .T.
7517 lnOldSelect = Select()
7518 With This
7519 *- 1010285 05/18/05 YIK
7520 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7521 *- if the SKU with the label is valid and active in the style master.
7522 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7523 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7524 *-- WHERE h.pkey= d.fkey AND ;
7525 *-- d.division= C.division AND h.customer= C.customer AND ;
7526 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7527 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7528 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7529 *-- INTO CURSOR tmpCurs
7530
7531 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7532 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7533 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7534 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7535 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7536 WHERE h.pkey= d.fkey And ;
7537 h.control_pkey = C.pkey And ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
7538 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7539 Not (MultiUPC = 'Y') And ;
7540 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7541 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7542 INTO Cursor tmpCurs
7543 *==
7544
7545 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7546 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7547 "customer+division+style+color_code+dimension")
7548 If llRetVal
7549 *- 1010285 05/18/05 YIK
7550 *- 1004785 05/04/04 YIK
7551 *- Added .. AND Empty(Errs_Msg_D)
7552 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7553 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7554 Select (pceipoTD)
7555 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7556 If tmpCurs.resv_label = "Y" Or ;
7557 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7558 AND tmpscolr.active_ok = "Y" )
7559 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7560 Endif
7561 Endscan
7562 *= 1010285
7563 Set Relation To
7564 Endif
7565 .TableClose('tmpCurs')
7566 Endwith
7567 Select(lnOldSelect)
7568 Return llRetVal
7569 Endproc
7570
7571 *----------------------------------------------------------------------------------------
7572 ************************************************************************************
7573 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7574 ************************************************************************************
7575 * encounter for both set up in customer label ref:
7576 * 1. empty label apply to all customer
7577 * 2. none empty customer will be specificly create only for that customer
7578 * either 1 or 2 exists but never both
7579 *
7580 * Get a list of distinct ourSKU to server side to join zzxcolr
7581 Procedure CreateOurSKU
7582 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7583 Local llRetVal, lnOldSelect
7584 llRetVal = .T.
7585 lnOldSelect = Select()
7586 With This
7587 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7588 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7589 WHERE h.pkey= d.fkey And ;
7590 h.control_pkey = C.pkey And ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
7591 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7592 l.auto_style= 'Y' And ;
7593 C.resv_label= 'Y' And ;
7594 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7595 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7596 INTO Cursor tmpCurs
7597 *--- TR 1019697 NH
7598 *!* SCAN
7599 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7600 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7601 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7602 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7603 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7604 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7605 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7606 *!* .LogEntry("Created style: " + lcOurSKU )
7607 *!* ELSE
7608 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7609 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7610 *!* ENDIF
7611 *!* ENDIF
7612 *!* ENDSCAN
7613 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7614 *=== TR 1019697 NH
7615 Endwith
7616 Select(lnOldSelect)
7617 Return llRetVal
7618 Endproc
7619
7620 *----------------------------------------------------------------------------------------
7621
7622 Procedure CreateCustomerStyle
7623 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7624 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7625 Local llRetVal, lnOldSelect
7626 llRetVal = .T.
7627 lnOldSelect = Select()
7628 With This
7629 *--- TechRec 1005164 18-May-2004 GS ---
7630 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7631 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7632 * Where h.pkey= d.fkey and ;
7633 * d.division= C.division and h.customer= C.customer and ;
7634 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7635 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7636 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7637 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7638 * Into Cursor tmpCurs
7639 If This.oHostProcess.lHaveSLN
7640 Select Distinct C.customer,;
7641 d.division,;
7642 d.Style,;
7643 d.color_code,;
7644 C.lbl_code,;
7645 d.Dimension ;
7646 FROM (pceipoTD) d ;
7647 JOIN (pceipoTH) h ;
7648 ON h.pkey = d.fkey ;
7649 JOIN (pceipoCR) C;
7650 ON h.control_pkey = C.pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
7651 JOIN (pcxclblr) l ;
7652 ON C.lbl_code= l.lbl_code ;
7653 WHERE l.auto_style= 'Y' ;
7654 AND C.resv_label= 'Y' ;
7655 AND C.AutoCustSKU= 'Y' ;
7656 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7657 And h.customer > ' ' ;
7658 AND d.division > ' ' ;
7659 AND d.Style > ' ' ;
7660 AND d.color_code > ' ';
7661 UNION ;
7662 SELECT Distinct C.customer,;
7663 d.division,;
7664 d.Style,;
7665 s.color_code,;
7666 C.lbl_code,;
7667 s.Dimension ;
7668 FROM (pceipoTS) s ;
7669 JOIN (pceipoTD) d ;
7670 ON d.pkey = s.fkey ;
7671 JOIN (pceipoTH) h ;
7672 ON h.pkey = d.fkey ;
7673 JOIN (pceipoCR) C ;
7674 ON h.control_pkey = C.pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
7675 JOIN (pcxclblr) l ;
7676 ON C.lbl_code= l.lbl_code ;
7677 WHERE l.auto_style= 'Y' ;
7678 AND C.resv_label= 'Y' ;
7679 AND C.AutoCustSKU= 'Y' ;
7680 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7681 And h.customer > ' ' ;
7682 AND d.division > ' ' ;
7683 AND d.Style > ' ' ;
7684 AND s.color_code > ' ';
7685 INTO Cursor tmpCurs
7686
7687 Else
7688
7689 Select Distinct C.customer,;
7690 d.division,;
7691 d.Style,;
7692 d.color_code,;
7693 C.lbl_code,;
7694 d.Dimension ;
7695 FROM (pceipoTD) d ;
7696 JOIN (pceipoTH) h ;
7697 ON h.pkey = d.fkey ;
7698 JOIN (pceipoCR) C ;
7699 ON h.control_pkey = C.pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
7700 JOIN (pcxclblr) l ;
7701 ON C.lbl_code= l.lbl_code ;
7702 WHERE l.auto_style= 'Y' ;
7703 AND C.resv_label= 'Y' ;
7704 AND C.AutoCustSKU= 'Y' ;
7705 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7706 And h.customer > ' ' ;
7707 AND d.division > ' ' ;
7708 AND d.Style > ' ' ;
7709 AND d.color_code > ' ';
7710 INTO Cursor tmpCurs
7711
7712 Endif
7713 *=== TechRec 1005164 18-May-2004 GS ===
7714 Scan
7715 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7716 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7717 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7718 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7719 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7720 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7721 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7722 .LogEntry("Created customer style: " + lcCustSKU )
7723 Else
7724 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7725 .LogWarning("Unable to create customer style: " + lcCustSKU )
7726 Endif
7727 Endif
7728 Endscan
7729 Endwith
7730 Select(lnOldSelect)
7731 Return llRetVal
7732 Endproc
7733
7734 *----------------------------------------------------------------------------------------
7735 ************************************************************************************
7736 * Validate UPC for all details
7737 ************************************************************************************
7738 *--- TR 1088986 31-Jul-2015 BNarayanan Method name changed to avoid duplication. This method is obsolete ---
7739 *Procedure CheckUpc
7740 Procedure CheckUpc_obsolete
7741 *=== TR 1088986 31-Jul-2015 BNarayanan ===
7742 Lparameters pceipoTH, pceipoTD,;
7743 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7744
7745 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7746 * Added Parameter pceipocr
7747 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7748
7749 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7750 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7751 lnSize_desc, llSLN
7752
7753 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7754 LOCAL lcIs_upcsku
7755 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7756
7757 llRetVal = .T.
7758 lcErrs_Msg= ""
7759 lnOldSelect = Select()
7760
7761 * cannot check for UPC if customer is empty
7762 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7763 * on Cust SKU or UPC.
7764 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7765
7766 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7767 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7768 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7769
7770 *--- TechRec 1005163 17-May-2004 GS ---
7771 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7772 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7773 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7774 *Order by h.customer, d.upc Into Cursor tmpCurs
7775
7776 *---- TR 1024667 NSD 5/31/07
7777 * If sizebucket = 0 then re-resolve.
7778
7779 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7780 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7781*!* If This.lHaveSLN
7782*!* Select h.customer,;
7783*!* d.upc,;
7784*!* d.pkey,;
7785*!* (pceipoTD) As Src;
7786*!* FROM (pceipoTH) h ;
7787*!* JOIN (pceipoTD) d ;
7788*!* ON h.pkey = d.fkey ;
7789*!* WHERE !Empty(d.upc) ;
7790*!* AND !Empty(h.customer) ;
7791*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7792*!* UNION All ;
7793*!* SELECT h.customer,;
7794*!* s.SLN_UPC As upc,;
7795*!* s.pkey,;
7796*!* (pceipoTS) As Src ;
7797*!* FROM (pceipoTH) h ;
7798*!* JOIN (pceipoTD) d ;
7799*!* ON d.fkey = h.pkey ;
7800*!* JOIN (pceipoTS) s ;
7801*!* ON s.fkey = d.pkey ;
7802*!* WHERE !Empty(s.SLN_UPC) ;
7803*!* AND !Empty(h.customer) ;
7804*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7805*!* ORDER By 1, 2 ;
7806*!* INTO Cursor tmpCurs
7807*!* Else
7808*!* Select h.Customer,;
7809*!* d.UPC,;
7810*!* d.PKey,;
7811*!* (pceipoTD) As Src;
7812*!* FROM (pceipoTH) h ;
7813*!* JOIN (pceipoTD) d ;
7814*!* ON h.pkey = d.fkey ;
7815*!* WHERE !Empty(d.upc) ;
7816*!* AND !Empty(h.customer) ;
7817*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7818*!* ORDER By 1, 2;
7819*!* INTO Cursor tmpCurs
7820*!* Endif
7821 *=== TechRec 1005163 17-May-2004 GS ===
7822
7823 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7824 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7825 FROM (pceipocr) ;
7826 GROUP BY customer ;
7827 INTO CURSOR __ResvCustSKU
7828 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7829
7830 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7831*!* select h.Customer;
7832*!* , d.UPC;
7833*!* , d.PKey;
7834*!* from (pceipoTH) h;
7835*!* join (pceipoTD) d;
7836*!* on h.PKey = d.FKey;
7837*!* where !Empty(d.UPC);
7838*!* and !Empty(h.Customer);
7839*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7840*!* order by 1, 2;
7841*!* into Cursor tmpCurs ReadWrite
7842
7843 Select h.customer;
7844 , d.upc;
7845 , d.pkey,;
7846 (pceipoTD) AS Src;
7847 from (pceipoTH) h;
7848 join (pceipoTD) d;
7849 on h.pkey = d.fkey;
7850 JOIN __ResvCustSKU r ;
7851 ON r.Customer = H.Customer ;
7852 where !Empty(d.upc);
7853 and !Empty(h.customer);
7854 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7855 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7856 order By 1, 2;
7857 into Cursor tmpCurs Readwrite
7858 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7859
7860*=== TechRec 1024522 25-Sep-2007 GSternik ===
7861
7862 lcOldCust = ""
7863 lcOldItem = ""
7864 Select tmpCurs
7865 If This.lUserInterface
7866 * Init Thermometer
7867 This.UpdateThermoCaption("Validating UPC(s)...")
7868 * TAN 31891 - JAZ - 5/20/02
7869 * This.InitThermo(RECC('tmpCurs'))
7870 This.InitThermo(RecCount('tmpCurs'))
7871 * End TAN 31891 - JAZ - 5/20/02
7872 l_nThermoCnt = 0
7873 EndIf
7874
7875 Scan
7876 If This.lUserInterface
7877 * Advance progress bar, if we're using one.
7878 l_nThermoCnt = l_nThermoCnt + 1
7879 This.AdvanceThermo(l_nThermoCnt)
7880 Endif
7881 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7882 lcErrs_Msg = ""
7883 lcOldCust = tmpCurs.customer
7884 lcOldItem = tmpCurs.upc
7885 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7886 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7887
7888 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7889 lcIs_upcsku = ' '
7890 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7891
7892 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7893 lcDivision = tmpCstdr.division
7894 lcStyle = tmpCstdr.Style
7895 lcColor_code = tmpCstdr.color_code
7896 lcLbl_code = tmpCstdr.lbl_code
7897 lcDimension = tmpCstdr.Dimension
7898 lnSizeBucket = tmpCstdr.size_bk
7899 lnSize_desc = tmpCstdr.size_desc
7900
7901 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7902 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7903 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7904
7905 Else
7906 lcErrs_Msg = ""
7907 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7908 lcDivision = tmpUpcnr.division
7909 lcStyle = tmpUpcnr.Style
7910 lcColor_code = tmpUpcnr.color_code
7911 lcLbl_code = tmpUpcnr.lbl_code
7912 lcDimension = tmpUpcnr.Dimension
7913 lnSizeBucket = tmpUpcnr.sizebucket
7914 lnSize_desc = tmpUpcnr.size_desc
7915 Else
7916 lcErrs_Msg = lcErrs_Msg + CRLF
7917 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7918 Store 0 To lnSizeBucket
7919 Endif
7920 Endif
7921 Endif && level break
7922
7923 *--- TechRec 1005163 17-May-2004 GS ---
7924 *Select (pceipoTD)
7925*!* llSLN = (tmpCurs.Src = pceipoTS)
7926*!* If llSLN
7927*!* Select (pceipoTS)
7928*!* Else
7929 Select (pceipoTD)
7930*!* Endif
7931 *=== TechRec 1005163 17-May-2004 GS ===
7932 *- 1010682 04/25/05 YIK
7933 *- Locate For pkey = tmpCurs.pkey
7934 lnWorkArea = Select()
7935 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7936 Scatter Name loEiPOtd Memo
7937 If !Empty(lcErrs_Msg)
7938*!* *--- TechRec 1005163 17-May-2004 GS ---
7939*!* If llSLN
7940*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7941*!* loEiPOtd.Errs_Flg_S = "Y"
7942*!* Else
7943*!* *=== TechRec 1005163 17-May-2004 GS ===
7944 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7945 loEiPOtd.Errs_Flg_D = "Y"
7946*!* Endif
7947 Endif
7948 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7949 loEiPOtd.Division = lcDivision
7950 loEiPOtd.Style = lcStyle
7951 loEiPOtd.Color_Code = lcColor_code
7952 loEiPOtd.Lbl_Code = lcLbl_code
7953 loEiPOtd.Dimension = lcDimension
7954 loEiPOtd.SizeBucket = lnSizeBucket
7955 loEiPOtd.Size_Desc = lnSize_desc
7956
7957 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7958 IF !EMPTY(lcIs_upcsku)
7959 loEiPOtd.Is_upcsku = lcIs_upcsku
7960 ENDIF
7961 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7962
7963 *--- TR 1019697 NH : clear rang style when bc style is set
7964 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7965 loEiPOtd.rng_style = ''
7966 loEiPOtd.rng_color = ''
7967 loEiPOtd.rng_lbl = ''
7968 loEiPOtd.rng_pack = ''
7969 Endif
7970 *=== TR 1019697 NH
7971 Endif
7972
7973 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7974 * only replace our SKU when no range style explosion happen
7975 *--- TechRec 1005163 17-May-2004 GS ---
7976 *If empty(&pceipoTD..rng_style)
7977 * Replace division With loEiPOtd.division, ;
7978 * style With loEiPOtd.style, ;
7979 * color_code With loEiPOtd.color_code, ;
7980 * lbl_code With loEiPOtd.lbl_code, ;
7981 * dimension With loEiPOtd.dimension, ;
7982 * sizebucket With loEiPOtd.sizebucket, ;
7983 * size_desc With loEiPOtd.size_desc, ;
7984 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7985 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7986 * In (pceipoTD)
7987 *Endif
7988 *- 1009508 3/16/05 YIK
7989 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7990 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7991 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7992 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7993 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7994
7995 Gather Name loEiPOtd Memo
7996 Endif
7997 *=== TechRec 1005163 17-May-2004 GS ===
7998 Endscan
7999 Use In tmpCurs
8000
8001 If This.lUserInterface
8002 * Reset Thermometer
8003 This.ResetThermo()
8004 Endif
8005
8006 If Used("tmpCstdr")
8007 Use In tmpCstdr
8008 Endif
8009 If Used("tmpUpcnr")
8010 Use In tmpUpcnr
8011 Endif
8012
8013 Select(lnOldSelect)
8014 Return llRetVal
8015 Endproc
8016
8017 *----------------------------------------------------------------------------------------
8018 ************************************************************************************
8019 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
8020 ************************************************************************************
8021 Procedure ValidateOurSKU
8022 Lparameters pceipoTH, pceipoTD, pceipoTS
8023 Local llRetVal, lnOldSelect, lcScolrSQL
8024 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
8025
8026 *--- TechRec 1022705 21-Jun-2007 jjanand ---
8027 LOCAL llActiveCheck
8028 *=== TechRec 1022705 21-Jun-2007 jjanand ===
8029
8030 *--- TR 1017598 14-Sep-2006 SS
8031 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
8032
8033 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
8034
8035 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
8036
8037 *--- TR 1018193 18-NOV-2006 VKK
8038 lcErrs_Allowed_Msg = ""
8039 *=== TR 1018193 18-NOV-2006 VKK
8040
8041 *=== TR 1017598 14-Sep-2006 SS
8042
8043 * --- TR 1039400 3/31/09 CM
8044 LOCAL lcCurrentSku
8045 lcCurrentSku = ""
8046 * === TR 1039400 3/31/09 CM
8047
8048 llRetVal = .T.
8049 lnOldSelect = Select()
8050
8051 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
8052 *--- See VSS for Changes.
8053
8054 * for anything that resove to None blank h.customer, d.div/sty/col-
8055 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
8056 *- TAN 27166
8057 *- 1010682 04/25/05 YIK
8058 *- Added .. WHERE d.rng_style = ' '
8059
8060 *- 1017363 06/02/06 YIK
8061 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
8062
8063 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
8064 Select h.customer;
8065 , d.division;
8066 , d.Style;
8067 , d.color_code;
8068 , d.lbl_code;
8069 , d.Dimension;
8070 , d.sizebucket;
8071 , d.size_desc; && TR 1058045 11-29-2011 RKI
8072 , d.upc; && TR 1058045 11-29-2011 RKI
8073 , d.sku; && TR 1058045 11-29-2011 RKI
8074 , d.ean; && TR 1058045 11-29-2011 RKI
8075 , d.pkey;
8076 , (pceipoTD) As Src ;
8077 from (pceipoTH) h;
8078 join (pceipoTD) d ;
8079 on h.pkey = d.fkey ;
8080 where h.customer >' ' ;
8081 and d.division >' ' ;
8082 and d.Style >' ' ;
8083 and d.color_code >' ' ;
8084 UNION All;
8085 select h.customer;
8086 , s.division;
8087 , s.Style;
8088 , s.color_code;
8089 , s.lbl_code;
8090 , s.Dimension;
8091 , s.sizebucket;
8092 , s.size_desc; && TR 1058045 11-29-2011 RKI
8093 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
8094 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
8095 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
8096 , s.pkey;
8097 , (pceipoTS) As Src ;
8098 from (pceipoTS) s;
8099 join (pceipoTD) d ;
8100 on d.pkey = s.fkey;
8101 join (pceipoTH) h ;
8102 on h.pkey = d.fkey ;
8103 and h.customer > ' ' ;
8104 and s.division > ' ' ;
8105 and s.Style > ' ' ;
8106 and s.color_code > ' ' ;
8107 where d.rng_style = ' ' ;
8108 order By 2, 3, 4, 5, 6, 7, 1 ;
8109 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
8110
8111 *-- Order by SKU + Bucket + Customer !!!
8112 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
8113
8114 lcCnt = Reccount("tmpCurs")
8115 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
8116
8117 *--- This cursor will be used to cache Customer-Label Validations:
8118 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
8119 Index On customer + lbl_code Tag CustLbl
8120
8121 lcErrs_Msg = ''
8122 Select tmpCurs
8123 Scatter Memo Name oTmpCurs Blank
8124 * --- TR 1014834 RLN 08/10/06
8125
8126 *--- TR 1017598 14-Sep-2006 SS
8127 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
8128
8129 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
8130 llBookUnavail = (lcbk_unavl_sku = 'Y')
8131 llErrUnavail = (lcbk_unavl_sku = 'E')
8132 *=== TR 1017598 14-Sep-2006 SS
8133
8134 With oTmpCurs
8135 llSize_OK = .T.
8136 Scan
8137 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
8138 * --- TR 1027498 NSD 10/3/07
8139 * Clear error message after every line, not just every sku.
8140 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
8141 * === TR 1027498 NSD 10/3/07
8142
8143 * --- TR 1014834 RLN 08/10/06
8144 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
8145 *llSize_OK = .T. FH 1090559 - absolutely have to comment this. IT should only be set when we change sizes
8146 If division # .division ;
8147 or Style # .Style ;
8148 or color_code # .color_code ;
8149 or lbl_code # .lbl_code ;
8150 or Dimension # .Dimension
8151 *-- SKU Changed... Let's make sure it is valid:
8152
8153 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
8154 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8155
8156 * --- TR 1039400 3/31/09 CM
8157 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
8158 * === TR 1039400 3/31/09 CM
8159
8160 * --- TR 1014834 RLN 08/10/06
8161 If division <> .division
8162 *--- TR 1017598 14-Sep-2006 SS
8163 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
8164
8165 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
8166 llBookUnavail = (lcbk_unavl_sku = 'Y')
8167 llErrUnavail = (lcbk_unavl_sku = 'E')
8168 *=== TR 1017598 14-Sep-2006 SS
8169 Endif
8170 * === TR 1014834
8171 lcErrs_Msg = ""
8172 .division = division
8173 .Style = Style
8174 .color_code = color_code
8175 .Dimension = Dimension
8176 .lbl_code = lbl_code && TR 1057867 FH
8177 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
8178 * --- TR 1014834 RLN 08/09/06
8179 lnSelect = Select()
8180 * Available sizes stored in Scolr
8181 *--- TR: 1021620 BR/NH
8182 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
8183 Lbl_Code, .Dimension)
8184
8185
8186*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
8187*!* "division = " + SQLFormatChar(division) + " AND " + ;
8188*!* "style = " + SQLFormatChar(Style) + " AND " + ;
8189*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
8190*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
8191*!* "dimension = " + SQLFormatChar(Dimension)
8192
8193*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
8194*!* Select (lnSelect)
8195*!* * === TR 1014834
8196*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
8197*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
8198
8199 *--- TechRec 1022705 20-Jun-2007 jjanand ---
8200 *!* IF tcTmpScolr.active_ok = 'N'
8201 llActiveCheck = This.lAllowInactiveStyleColors
8202 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
8203 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
8204 IF llActiveCheck
8205 *=== TechRec 1022705 20-Jun-2007 jjanand ===
8206
8207 lcErrs_Msg = "Inactive Style/Color"
8208 llStyle_OK = .F.
8209 ELSE
8210 lcErrs_Msg = ""
8211 llStyle_OK = .T.
8212 ENDIF
8213
8214 *--- TR 1040614 MAY-29-2009 BR
8215 llUnAvlBkCheck = .T.
8216 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
8217 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
8218
8219 *- 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
8220 IF llStyle_OK
8221 IF llUnAvlBkCheck
8222 lcErrs_Msg = "Style/Color combination is unavailable"
8223 llStyle_OK = .F.
8224 ELSE
8225 lcErrs_Msg = ""
8226 llStyle_OK = .T.
8227 ENDIF
8228 ENDIF
8229 *- TR 1062018 FH 06/08/12
8230 *=== TR 1040614 MAY-29-2009 BR
8231 ELSE
8232 *=== TR 1021620
8233 llStyle_OK = .F.
8234 This.GetStyleError(@lcErrs_Msg)
8235 Endif
8236 Endif && SKU Changed
8237
8238 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
8239 *- took out (customer # .customer Or .lbl_code # lbl_code)
8240 If llStyle_OK AND llSKU_changed
8241*!* If llStyle_OK And (;
8242*!* customer # .customer Or .lbl_code # lbl_code)
8243 .lbl_code = lbl_code
8244 .customer = customer
8245 llLabel_OK = .T.
8246 If !Empty(.lbl_code)
8247 If !Seek(.customer+.lbl_code, "curCustLbl")
8248 *- populate cursor of cached Customer/Lbl
8249 *- vl_clblr2() returns .F. if lbl is invalid for the customer
8250 Insert Into curCustLbl Values(;
8251 .customer, .lbl_code,;
8252 vl_clblr2(.lbl_code, "", , .customer))
8253 Endif
8254
8255 If !curCustLbl.is_Valid && always check from the cached table.
8256 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
8257 llLabel_OK = .F.
8258 Endif
8259 Endif
8260 Endif && Style OK
8261
8262 *--- TR 1058045 11-29-2011 RKI ---*
8263 lnPkey = Pkey
8264 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
8265 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
8266 replace sizebucket WITH lnSize_BK
8267 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
8268 DO CASE
8269 CASE tmpCurs.Src = (pceipoTD)
8270 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8271 CASE tmpCurs.Src = (pceipoTS) && TR 1090066 FH - typo
8272 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8273 Endcase
8274 ENDIF
8275 ENDIF
8276 SELECT tmpCurs
8277 *=== TR 1058045 11-29-2011 RKI ===*
8278
8279 * --- TR 1018184
8280 *llAllowedSize_OK = .T. FH 1090559 - what if 2 records have same sku and size, first record finds llAllowedSize_OK to be .F.
8281 * Second record will set llAllowedSize_OK to .T. here, and it won't go in the below to revaluate llAllowedSize_OK because same sizebucket
8282 If llStyle_OK And llLabel_OK
8283 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
8284 .sizebucket = sizebucket
8285 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8286
8287 llAllowedSize_OK = .T. && FH 1090559
8288 llSize_OK = .T. && FH 1090559
8289
8290 *- that's why we used Savlr
8291 * --- TR 1014834 RLN 08/09/06
8292 * I guess we really do not need Savlr...
8293 *llSize_OK = Evaluate("__Savlr.allow"
8294 *--- TR 1058045 11-29-2011 RKI ---*
8295 IF BETWEEN(.sizebucket,1,24)
8296 *=== TR 1058045 11-29-2011 RKI ===*
8297 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
8298 Transform(.sizebucket, "@L 99")) = 'Y'
8299
8300 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
8301 *if !llSize_OK
8302 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
8303 Transform(.sizebucket, "@L 99")) = 'Y'
8304 *--- TR 1058045 11-29-2011 RKI ---*
8305 ELSE
8306 llAllowedSize_OK = .F.
8307 ENDIF
8308 *=== TR 1058045 11-29-2011 RKI ===*
8309
8310 If !llAllowedSize_OK
8311 *--TR 1034769 JUL-21-2008 BR
8312 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
8313 lcErrs_Msg = "Invalid Available Sizes."
8314 *==TR 1034769 JUL-21-2008 BR
8315 Else
8316 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
8317 lcErrs_Msg = "Invalid Available Sizes."
8318 Endif
8319 Endif
8320
8321 *=== TR 1017598 14-Sep-2006 SS
8322 ENDIF
8323 && 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
8324 * is valid or not. So let's set variable llAllowedSize_OK = .T. and llSize_OK = .T.
8325 * because it will force error (TR 1067995, DEV NOTE TECHNICAL, explains scenario where style is invalid but still won't
8326 * error out because of these size variables that was from previous records),
8327 * if any of the 2 variables is .F., it will try to add error message base on size variables
8328 * which doesn't make sense.
8329 ELSE
8330 llAllowedSize_OK = .T.
8331 llSize_OK = .T.
8332
8333 Endif
8334 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
8335
8336 * for each detail line replace detail error msg if have one
8337 *--- TechRec 1005163 21-Jun-2004 GS ---
8338 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
8339 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
8340 * Errs_Flg_D with 'Y' in (pceipoTD)
8341 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
8342 If tmpCurs.Src = (pceipoTD)
8343 *--- TR 1017598 14-Sep-2006 SS
8344 If Not llAllowedSize_OK && if size is not allowed - error out always
8345 *--- TR 1018193 18-NOV-2006 VKK
8346 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
8347 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
8348 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
8349 Errs_Flg_D With 'Y' In (pceipoTD)
8350 *=== TR 1018193 18-NOV-2006 VKK
8351 Else
8352 *=== TR 1017598 14-Sep-2006 SS
8353
8354 * --- TR 1014834 RLN 08/08/06
8355 If !llSize_OK
8356 If llBookUnavail
8357 Replace UnAvailSize With .T. In (pceipoTD)
8358 Else
8359 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
8360 If llErrUnavail && error as invalid available sizes.
8361 * === TR 1014834
8362 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
8363 Errs_Flg_D With 'Y' In (pceipoTD)
8364 Endif
8365 *=== TR 1017598 14-Sep-2006 SS
8366 ENDIF
8367 *--- TR 1021620 NH 04/12/07
8368 ELSE
8369
8370
8371 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
8372 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
8373 IF llSKU_changed
8374 * --- TR 1039400 3/31/09 CM
8375 * Commented out and added seek/scan while to determine how many particular style/color
8376 * combinations should be flagged as inactive
8377 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8378 Select(pceipoTD)
8379 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
8380 If Seek(lcCurrentSku)
8381 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
8382 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8383 Endscan
8384 Endif
8385 * === TR 1039400 3/31/09 CM
8386 endif
8387 *--TR 1057867 FH
8388
8389 *=== TR 1021620 NH 04/12/07
8390 Endif && TR 1014834
8391 Endif && TR 1017598
8392 ELSE
8393 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
8394 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
8395 Errs_Flg_S With 'Y' In (pceipoTS)
8396
8397 *- 1010682 04/25/05 YIK
8398 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
8399 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
8400 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
8401 Select(pceipoTS)
8402 lnFKey = fkey
8403 Select(pceipoTD)
8404 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
8405 *=== TechRec 1016817 04-May-2006 GS ===
8406 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
8407 Errs_Flg_D With 'Y' In (pceipoTD)
8408 ENDIF
8409 ENDIF
8410 Endif
8411 *=== TechRec 1005163 21-Jun-2004 GS ===
8412 Endif
8413 Endscan
8414 Endwith
8415
8416 Use In Select("curCustLbl")
8417
8418 Select(lnOldSelect)
8419 Return llRetVal
8420 Endproc
8421
8422 *----------------------------------------------------------------------------------------
8423
8424 Function GetCustLabel
8425 Lparameters pcCust
8426 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
8427
8428 llRetVal = True
8429 lnSelect = Select()
8430 l_vRetVal = ''
8431 lcCursor = GetUniqueFileName()
8432
8433 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
8434
8435 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
8436
8437 If llRetVal
8438 Select(lcCursor)
8439 l_vRetVal = Alltrim(lbl_code )
8440
8441 Use In (lcCursor)
8442 Endif
8443
8444 Select (lnSelect)
8445 Return l_vRetVal
8446 Endfunc
8447
8448 *----------------------------------------------------------------------------------------
8449 Function ResolveMultiPrepacks
8450 Lparameters pcTransHeader, pcTransDetail, pcMppk
8451 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
8452
8453 llRetVal = True
8454 lnOldSelect = Select()
8455
8456
8457
8458 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8459 FROM (pcTransHeader) h, (pcTransDetail) d ;
8460 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
8461 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
8462 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8463
8464 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
8465 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
8466 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
8467 *!* d.rng_style= '' ;
8468 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
8469
8470 With This
8471 .cSQLTempTable=""
8472
8473 If .GenerateSQLTempTable('__TmpCursor')
8474 If .PopulateSQLTempTable('__TmpCursor')
8475 If !Empty(.cSQLTempTable)
8476
8477 .LogEntry("Exploding MultiPack.")
8478
8479 *AND h.mpack_code = t.dimension
8480 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
8481 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8482
8483 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
8484
8485 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
8486
8487 If llMultPpkToExplode
8488
8489 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
8490 "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
8491
8492 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
8493
8494
8495 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
8496
8497 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
8498 WHERE 0=1 Into Cursor __ppk2
8499
8500
8501 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
8502 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
8503
8504
8505 If Used("__ppk1")
8506 Use In __ppk1
8507 Endif
8508
8509 If Used("__ppk2")
8510 Use In __ppk2
8511 Endif
8512
8513 Select __MppkH
8514 Index On pkey Tag pkey
8515 Select __MppkD
8516 Index On division+Style Tag DivStyle
8517 Select tcMppkVer
8518 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8519 Set Order To MpackRef
8520 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8521
8522 *****************************************************************************
8523 *!* SELECT DISTINCT pkey FROM __MppkD ;
8524 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8525 *!* INTO CURSOR __DtlExpl
8526
8527
8528 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8529 *!* FROM __MppkD m, (pcTransDetail) d ;
8530 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8531 *!* INTO CURSOR __DtlExpl
8532
8533 && TR 1011644 VSS 27-09-2005
8534
8535 Select Distinct d.pkey ;
8536 FROM __MppkD mp, (pcTransDetail) d ;
8537 WHERE d.Errs_Flg_D= "N" ; &&no error
8538 And mp.Style = d.Style ;
8539 AND mp.color_code = d.color_code ;
8540 AND mp.lbl_code = d.lbl_code ;
8541 AND mp.Dimension = d.Dimension;
8542 AND d.implosion = 'Y';
8543 INTO Cursor __DtlExpl
8544
8545 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8546
8547 Endif
8548 Endif
8549 Endif
8550 Endif
8551 Endwith
8552
8553 If Used("__MppkH")
8554 Use In __MppkH
8555 Endif
8556 If Used("__MppkD")
8557 Use In __MppkD
8558 Endif
8559 If Used("tcMppkVer")
8560 Use In tcMppkVer
8561 Endif
8562 If Used("__DtlExpl")
8563 Use In __DtlExpl
8564 Endif
8565 If Used("__TmpCursor")
8566 Use In __TmpCursor
8567 Endif
8568
8569 Select(lnOldSelect)
8570 Return llRetVal
8571
8572 Endfunc
8573
8574 *----------------------------------------------------------------------------------------
8575 Procedure ExplodeMultiPackVertical
8576 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8577 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8578 llRetVal = .T.
8579 lnOldSelect = Select()
8580
8581 .LogEntry("Exploding multi pack details into vertical cursor.")
8582 Select (pcDetailtoExplode)
8583
8584 Scan
8585
8586 If Seek(pkey, pcTransDetail, "Pkey")
8587
8588 * Current working trans detail
8589 Select (pcTransDetail)
8590 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8591 lnCurDtlTotal_qty= total_qty
8592
8593
8594 Scatter Name loTransDetail Memo
8595 * delete current working trans detail already have image
8596 * in loTransDetail
8597 Delete In (pcTransDetail)
8598
8599
8600 Select (pcMultDetailVert)
8601 * Find 1st match of OURSKU
8602 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8603 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8604
8605
8606 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8607 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8608 * Exploding detail line
8609 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8610 If !Empty(loTransDetail.pkey)
8611
8612 Select (pcMultDetailVert)
8613 Scatter Name loVert Memo
8614
8615 Select (pcTransDetail)
8616 Append Blank
8617 Gather Name loTransDetail Memo
8618
8619 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8620 sizebucket With loVert.sizebucket, ;
8621 size_desc With loVert.size_desc, ;
8622 division With loVert.division, ;
8623 STYLE With loVert.Style, ;
8624 color_code With loVert.color_code, ;
8625 lbl_code With loVert.lbl_code, ;
8626 DIMENSION With loVert.ppk_code In (pcTransDetail)
8627 Else
8628 .LogEntry("Pkey cannot be empty.")
8629 llRetVal= .F. && Cannot get Pkey from bcsysnum
8630 Exit
8631 Endif
8632
8633 Select (pcMultDetailVert)
8634 Endscan
8635 Else
8636 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8637 llRetVal= .F. && Should be in pcMultDetailVert
8638 Exit
8639 Endif
8640 Endif
8641
8642 If !llRetVal &&Get out of scan when have some problem
8643 Exit
8644 Endif
8645 Endscan
8646
8647 Select(lnOldSelect)
8648 Return llRetVal
8649 Endproc
8650 *=== TR 1011644 23-AUG-2005 KA
8651
8652 *----------------------------------------------------------------------------------------
8653 Procedure ExplodeMultPackRef
8654 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8655 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8656 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8657
8658 lnOldSele = Select()
8659 lcDivStyle = ""
8660 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8661
8662 llRetVal= .T.
8663 lnCurDtlFkey= 0
8664 lnMultiplyQty = 0
8665
8666 .LogEntry("Exploding multi pack details.")
8667
8668 Select (pcMultPackDetail)
8669 Set Order To DivStyle
8670 Scan
8671
8672 If lnCurDtlFkey<> fkey
8673 lnCurDtlFkey = fkey
8674 If Seek(fkey, pcMultPackHeader , "PKEY")
8675 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8676 Else
8677 llRetVal = .F.
8678 Exit
8679 Endif
8680 Endif
8681
8682
8683 * only run once per Div + Style
8684 If !(lcDivStyle == division + Style)
8685 lcDivStyle = division + Style
8686 * Insert a record for each size bucket with a caption *
8687 If !v_GetSizeHeadings(division, Style, "__xSizer")
8688 llRetVal = .F.
8689 Exit
8690 Endif
8691 Endif
8692
8693
8694 lnSizeQty = 1
8695 Select (pcMultPackDetail)
8696 Scatter Memvar Memo
8697
8698 lnSizePosition = 1
8699 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8700 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8701 lnSizeQty = ppk_qty
8702
8703 m.sizebucket = lnSizePosition
8704 m.size_desc = lcSizeName
8705 m.total_qty = lnSizeQty
8706 m.multQty = lnMultiplyQty
8707
8708 If lnSizeQty > 0 && Only want buckets with activity!
8709 Insert Into (pcMultPackTarget) From Memvar
8710 Endif
8711 Select (pcMultPackDetail)
8712
8713 Endscan
8714
8715 This.TableClose("__xSizer")
8716 Select (pcMultPackDetail)
8717 Select (lnOldSele)
8718 Return llRetVal
8719 Endproc
8720
8721 *----------------------------------------------------------------------------------------
8722 *--- TechRec 1016817 04-May-2006 GS ---
8723 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8724 Procedure GetStyleError
8725
8726 Lparameter tcErrorMsg, toTmpCurs
8727
8728 Do Case
8729 Case vl_scolr(division,,, Style, color_code, lbl_code)
8730 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8731
8732 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8733 tcErrorMsg = "Invalid Label code." + CRLF
8734
8735 Case !Empty(Style) And vl_Stylr(division,,, Style)
8736 tcErrorMsg = "Invalid Color code." + CRLF
8737
8738 Otherwise
8739 tcErrorMsg = "Invalid Style." + CRLF
8740 Endcase
8741 Endproc
8742
8743 *----------------------------------------------------------------------------------------
8744
8745 **********************************************************************************
8746 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8747 **********************************************************************************
8748 Procedure PopulateInboundUOM
8749 Lparameters pceipoTH, pceipoTD, pceipoCR
8750 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8751 llRetVal = .T.
8752 lnOldSelect = Select()
8753
8754 With This
8755
8756 *****************************************************************************
8757 * unconditionally reset all base_uom and uom_factor
8758 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8759
8760 *****************************************************************************
8761 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8762 * Server-side join previous list to get cursor of scolr to populate base_uom
8763 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8764 FROM (pceipoTH) h, (pceipoTD) d ;
8765 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8766 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8767 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8768 * TAN 31891 - JAZ - 5/20/02 @@@
8769 * If Recc("__TmpCursor")> 0
8770 If Reccount("__TmpCursor")> 0
8771 * End TAN 31891 - JAZ - 5/20/02
8772 .cSQLTempTable=""
8773 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8774 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8775 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8776 "Where s.division= t.division and s.style= t.style and "+;
8777 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8778 "s.dimension= t.dimension"
8779 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8780 * Populate style UOM
8781 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8782 Endif
8783 .TableClose("tcUOM")
8784 .TableClose("__TmpCursor")
8785
8786 *****************************************************************************
8787 * Get distinct list of Inbound UOM and style UOM
8788 * Server-side join previous list to populate UOM conversion factor
8789 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8790 WHERE ib_uom<>'' And base_uom<>'' ;
8791 INTO Cursor __TmpCursor
8792 * TAN 31891 - JAZ - 5/20/02
8793 * If Recc("__TmpCursor")> 0
8794 If Reccount("__TmpCursor")> 0
8795 * End TAN 31891 - JAZ - 5/20/02
8796 .cSQLTempTable=""
8797 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8798 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8799 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8800 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8801 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8802 * Populate style UOM
8803 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8804 Endif
8805 .TableClose("tcUOMFactor")
8806 .TableClose("__TmpCursor")
8807
8808 Endwith
8809 Select(lnOldSelect)
8810 Return llRetVal
8811 Endproc
8812
8813 *----------------------------------------------------------------------------------------
8814
8815 Procedure PopulateBaseUOM
8816 Lparameters pceipoTD, pcUOM
8817 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8818 llRetVal = .T.
8819 lnOldSelect = Select()
8820
8821 With This
8822 Select (pcUOM)
8823 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8824 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8825 "division+style+color_code+lbl_code+dimension")
8826 Select (pceipoTD)
8827 If llRetVal
8828 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8829 FOR !Empty(&pcUOM..uom)
8830 Endif
8831 Set Relation To
8832 Endwith
8833 Select(lnOldSelect)
8834 Return llRetVal
8835 Endproc
8836
8837 *----------------------------------------------------------------------------------------
8838
8839 Procedure PopulateUOMFactor
8840 Lparameters pceipoTD, pcUOMFactor
8841 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8842 llRetVal = .T.
8843 lnOldSelect = Select()
8844
8845 With This
8846 Select (pcUOMFactor)
8847 Index On uom+uom_convert Tag IB_BaseUOM
8848 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8849 "ib_uom+base_uom")
8850 Select (pceipoTD)
8851 If llRetVal
8852 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8853 FOR !Empty(&pcUOMFactor..uom_factor)
8854 Endif
8855 Set Relation To
8856 Endwith
8857 Select(lnOldSelect)
8858 Return llRetVal
8859 Endproc
8860
8861 *----------------------------------------------------------------------------------------
8862
8863 Procedure ResolvePrepack
8864 *--- TR 1097960 10-Feb-2017 Partha : Added Added pceipoTSAC(tceipoTSAC), pcEiPOtWHSE(tcEiPOtWHSE) ===
8865 Lparameters pceipoTH, pceipoTD, pceipoCR, pceipoTSAC, pcEiPOtWHSE
8866
8867 LOCAL llRetVal
8868 llRetVal = .t.
8869 IF VARTYPE(This.oResolvePrepack) <> "O"
8870 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8871 ENDIF
8872
8873 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8874
8875 IF NOT llRetVal
8876 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8877 RETURN llRetVal
8878 ENDIF
8879
8880 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8881 this.oResolvePrepack.cLogName = this.cLogName
8882
8883 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8884 This.oResolvePrepack.c850Control = This.c850Control
8885 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8886
8887 *--- TR 1097960 10-Feb-2017 Partha : Added Added pceipoTSAC(tceipoTSAC), pcEiPOtWHSE(tcEiPOtWHSE) ===
8888 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR, pceipoTSAC, pcEiPOtWHSE)
8889
8890 RETURN llRetVal
8891
8892 ENDPROC
8893
8894 *------------------------------------------------------------------------
8895
8896 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8897 Procedure ValidateCharges
8898 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8899
8900 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8901 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8902 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8903 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8904 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8905 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8906 lcDtlError = "Has errors in Charges." + CRLF
8907 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8908 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8909 SELECT (tcEipoTH)
8910 lntcEipoTHrec = RECNO()
8911 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8912
8913 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8914 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8915 v_sqlExec(;
8916 "select d.FKey"+;
8917 " , d.Chrg_Type"+;
8918 " , d.Chrg_Flag"+;
8919 " , d.Active_Ok"+;
8920 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8921 " from zzxChrgD d"+;
8922 " join zzxChrTR t"+;
8923 " on t.Chrg_Type = d.Chrg_Type"+;
8924 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8925 Select qChrgD
8926 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8927 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8928 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8929 v_sqlExec(;
8930 "select Customer"+;
8931 " , Division"+;
8932 " , Store"+;
8933 " , Center_Code"+;
8934 " , Season"+;
8935 " , PKey"+;
8936 " , Rank_Seq"+;
8937 " from zzxchrgh", "qChrgH")
8938 Select qChrgH
8939 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8940 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8941 Index On division+customer+Store+Center_Code+Season Tag divcust
8942 If division = ' ' And customer = ' '
8943 lnDefaultKey = pkey
8944 Endif
8945
8946 Select (tcEiPOTR)
8947 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8948 SCAN FOR charge_tag <> 'CHGH' && *--- TR 1103895 25-Jul-2017 Goutam. Added for clause
8949 lcChrg_Type = Chrg_Type
8950 Select (tcEiPOtd)
8951 lcDivision = division
8952 lcCustomer = customer
8953 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8954 lnFkeyEipoTD = fkey
8955 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8956 lcCenter_Code = &tcEipoTH..center_Code
8957 lcStore = &tcEipoTH..Store
8958 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8959 lcSeason = &tcEipoTH..Season
8960 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8961 ELSE
8962 lcCenter_Code = ""
8963 lcStore = ""
8964 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8965 lcSeason = ""
8966 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8967 ENDIF
8968 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8969
8970 Select qChrgH
8971 Do Case
8972 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8973*!* Case Seek(lcDivision+lcCustomer)
8974*!* lnFKey = pkey
8975*!* Case Seek(' '+lcCustomer, "qChrgH")
8976*!* lnFKey = pkey
8977*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8978*!* Case Seek(lcDivision+' ')
8979*!* lnFKey = pkey
8980*!* Otherwise
8981*!* lnFKey = lnDefaultKey
8982 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8983*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8984*!* lnFKey = pkey
8985*!*
8986*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8987*!* lnFKey = pkey
8988*!*
8989*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8990*!* lnFKey = pkey
8991*!*
8992*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8993*!* lnFKey = pkey
8994
8995*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8996*!* lnFKey = pkey
8997*!*
8998*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8999*!* lnFKey = pkey
9000
9001 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
9002 lnFKey = pkey
9003
9004 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
9005 lnFKey = pkey
9006
9007 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
9008 lnFKey = pkey
9009
9010 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
9011 lnFKey = pkey
9012
9013 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
9014 lnFKey = pkey
9015
9016 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
9017 lnFKey = pkey
9018
9019 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
9020 lnFKey = pkey
9021
9022 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
9023 lnFKey = pkey
9024
9025 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
9026 lnFKey = pkey
9027
9028 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
9029 lnFKey = pkey
9030 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
9031
9032 Otherwise
9033 lnFKey = lnDefaultKey
9034 * === TR 1041118 14-Aug-2009 Surinder Singh ===
9035 Endcase
9036 Select (tcEiPOTR)
9037 If Empty(lnFKey)
9038 Replace Errs_Flg_R With "Y",;
9039 Errs_Msg_R With "No Charges set up for "+;
9040 Trim(lcDivision)+'/'+Trim(lcCustomer)
9041 Else
9042 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
9043 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
9044
9045 *--- Check if the Charge still active:
9046 If qChrgD.Active_Ok # 'Y'
9047 Replace Errs_Flg_R With "Y",;
9048 Errs_Msg_R With lcErrorMsg3
9049 Endif
9050
9051 If Empty(Chrg_Flag)
9052 *-- Set Charge Type from Resolution if success
9053 If Errs_Flg_R # "Y"
9054 Replace Chrg_Flag With lcResolved_Chrg_Flag
9055 Endif
9056 Else
9057 If Chrg_Flag # lcResolved_Chrg_Flag
9058 Replace Errs_Flg_R With "Y",;
9059 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
9060 Endif
9061 Endif
9062 Else
9063 Replace Errs_Flg_R With "Y",;
9064 Errs_Msg_R With lcErrorMsg1
9065 lnFKey = fkey
9066 lcResolved_Chrg_Flag = ""
9067 Endif
9068 Endif
9069
9070 If Errs_Flg_R = "Y"
9071 Select(tcEiPOtd)
9072 If !lcDtlError$Errs_Msg_D
9073 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
9074 Errs_Flg_D With 'Y'
9075 Endif
9076 ELSE
9077 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
9078* Replace Chrg_Cost With qChrgD.Chrg_Cost
9079 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
9080 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
9081 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
9082 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
9083 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
9084 Endif
9085 Endscan
9086
9087 Set Relation To
9088 Use In Select("qChrgH")
9089 Use In Select("qChrgD")
9090 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
9091 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
9092 GO lntcEipoTHrec IN (tcEipoTH)
9093 ENDIF
9094 * === TR 1041118 14-Aug-2009 Surinder Singh ===
9095
9096 Endproc
9097 *=== TechRec 1028745 05-Feb-2008 GSternik ===
9098
9099 *------------------------------------------------------------------------
9100
9101 *--- TR 1083402 20-Jan-2015 Partha ---
9102 * ROFL - This proc is duplicate :)
9103*!* *----------------------------------------------------------------------------------------
9104*!* *--- TR 1034481 NH
9105*!* PROCEDURE MarkHeaderForMissing855ControlRef
9106*!* LPARAMETERS pceipoTH
9107*!*
9108*!* LOCAL llRetVal, lnOldSelect,lcZzeoprcr
9109*!*
9110*!* llRetVal = .t.
9111*!* lnOldSelect = SELECT()
9112*!* lcZzeoprcr = "Oprcr" + SYS(2015)
9113*!* *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
9114*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
9115*!*
9116*!* IF USED(lcZzeoprcr)
9117*!* INDEX on customer TAG customer
9118*!* INDEX on division TAG division
9119*!*
9120*!* UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
9121*!* from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
9122*!* AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
9123
9124*!* USE IN (lcZzeoprcr)
9125*!* ENDIF
9126*!*
9127*!* SELECT(lnOldSelect)
9128*!* RETURN llRetVal
9129*!*
9130*!* ENDPROC
9131*!* *=== TR 1034481 NH
9132
9133 *=== TR 1083402 20-Jan-2015 Partha ===
9134
9135 *----------------------------------------------------------------------------------------
9136
9137 *--- TR 1035491 4-Nov-2008 Goutam
9138 ************************************************************************************
9139 * Move SLN to Detail.
9140 ************************************************************************************
9141 Procedure MoveSLNToDTLs
9142 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9143 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9144 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
9145 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
9146
9147 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
9148 lnLine_Seq
9149
9150 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9151 LOCAL lcSQL ,loIPOtdn
9152 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9153
9154 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
9155
9156 llRetVal = true
9157 lnOldSelect = Select()
9158 lnDetailPrice = 0
9159
9160 *--- TR 1036614 8-Jun-2009 Goutam
9161 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
9162
9163*!* select t.Customer ;
9164*!* , t.FKey ;
9165*!* , t.PKey ;
9166*!* , c.price_flg ;
9167*!* from (pcTmpCursor) t ;
9168*!* join zzeipocr c ;
9169*!* on c.division = t.division ;
9170*!* and c.customer = t.customer ;
9171*!* join (pceipoTD) d ;
9172*!* on d.pkey = t.dtlPkey ;
9173*!* where c.slntodtl = 'Y' ;
9174*!* and d.slntodtl <> 'Y' ;
9175*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
9176*!* into Cursor __tmpipots ;
9177*!* order by t.fkey, t.Customer, t.PKey
9178
9179 *=== TR 1036614 8-Jun-2009 Goutam
9180
9181 *-- #1 Create detail record from pceipoTS
9182 SELECT __tmpipots
9183 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
9184 GO top
9185 lnSkipedPSFkey = 0
9186 lnPSFkey = 0
9187 lnCoor_Code = 1
9188 lnLine_Seq = 0
9189 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
9190
9191 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9192 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9193 ENDIF
9194 DO WHILE NOT EOF()
9195 lnPSFkey = Fkey
9196
9197 *--- TR 1049029 24-Aug-2010 Partha ---
9198 IF lnPSFkey <> lnSkipedPSFkey
9199 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
9200 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
9201 ENDIF
9202 *=== TR 1049029 24-Aug-2010 Partha ===
9203
9204 lnStartPkey = lnStartPkey + 1
9205 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9206 lnLine_Seq = lnLine_Seq + 1
9207 SELECT (pceipoTD)
9208 SCATTER NAME loIPOtd MEMO
9209 loIPOtd.pkey = lnStartPkey
9210 loIPOtd.Line_Seq = lnLine_Seq
9211
9212 *-FH 1077588 - detail's header pkey
9213 lnHfkey = fkey
9214
9215 *--- TechRec 1056973 06-Dec-2011 jisingh ---
9216 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
9217 *- 1060291 04/02/2012 YIK/FH
9218*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9219*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
9220 SELECT (pczzeiPOtWhse)
9221 lnDocNum = doc_num
9222 lnEdiLine = edi_line
9223 lnSlnLine = sln_line
9224
9225 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9226 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
9227 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
9228
9229 SELECT (pceipoTD)
9230 *= 1060291
9231 ENDIF
9232 *=== TechRec 1056973 06-Dec-2011 jisingh ===
9233
9234 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
9235*!* loIPOtd.slntodtl = 'Y'
9236
9237 *--- TR 1045922 05-MAR-2010 HNISAR
9238 *- 1060291 03/30/2012 YIK
9239 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
9240*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9241*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
9242 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9243 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
9244 *=== TechRec 1056973 09-Nov-2011 jisingh ===
9245 *=== TR 1045922 05-MAR-2010 HNISAR
9246
9247
9248
9249 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
9250 *--- TechRec 1063327 16-Aug-2012 jjanand ---
9251 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
9252*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
9253*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
9254*!* loIPOtd.assort_qty = loIPOtd.total_qty
9255*!* ENDIF
9256 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
9257*!* IF EMPTY(loIPOtd.Assortment)
9258*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9259*!* IF loIPOtd.assort_qty = 0
9260*!* loIPOtd.assort_qty = loIPOtd.total_qty
9261*!* ENDIF
9262*!* ENDIF
9263
9264 IF EMPTY(loIPOtd.Assortment)
9265 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9266 ENDIF
9267 IF EMPTY(loIPOtd.assort_qty)
9268 loIPOtd.assort_qty = loIPOtd.total_qty
9269 ENDIF
9270 *=== TechRec 1063327 16-Aug-2012 jjanand ===
9271 *- TR 1062810 FH
9272
9273 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
9274 loIPOtd.PO1_UPC = loIPOtd.UPC
9275 loIPOtd.PO1_SKU = loIPOtd.SKU
9276 loIPOtd.po1_price = loIPOtd.org_price
9277 loIPOtd.Division = &pceipoTS..Division
9278 loIPOtd.Style = &pceipoTS..Style
9279 loIPOtd.Color_code = &pceipoTS..Color_code
9280 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
9281 loIPOtd.Dimension = &pceipoTS..Dimension
9282 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
9283 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
9284 loIPOtd.UPC = &pceipoTS..SLN_UPC
9285 *- 03/19/09 1038539, 1039344 YIK
9286 loIPOtd.SKU = &pceipoTS..SLN_SKU
9287 *- TR 1051757 FH 04/19/11
9288 loIPOtd.aux_sku = &pceipoTS..aux_sku
9289
9290 *--- TechRec 1056973 07-Dec-2011 jisingh ---
9291 loIPOtd.sln01 = &pceipoTS..sln01
9292 *=== TechRec 1056973 07-Dec-2011 jisingh ===
9293
9294 *--- TR 1049029 30-Aug-2010 Partha ---
9295
9296*!* *--- TR 1047912 23-Jun-2010 Partha ---
9297*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
9298*!* *=== TR 1047912 23-Jun-2010 Partha ===
9299*!*
9300*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9301*!*
9302*!* *=== TR 1047912 23-Jun-2010 Partha ===
9303*!* ENDIF
9304*!* *=== TR 1047912 23-Jun-2010 Partha ===
9305*!*
9306*!* *--- TR 1047912 23-Jun-2010 Partha ---
9307*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
9308*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9309*!* ELSE
9310*!* lnDetailPrice = &pceipoTD..Org_Price
9311*!* ENDIF
9312*!* *=== TR 1047912 23-Jun-2010 Partha ===
9313
9314 DO CASE
9315 CASE loIPOtd.ppk_action = 'B'
9316 *- 02/18/11 1052584 YIK
9317 *- Moved calculation of ppk_qty here
9318 loIPOtd.ppk_qty = lnTotSLNQty
9319
9320 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9321
9322 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
9323 *loIPOtd.ppk_action = 'X'
9324 loIPOtd.ppk_action = 'S'
9325 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
9326 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9327 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9328 *- 02/18/11 YIK 1052584
9329 *- moved calculation of ppk_qty higher
9330 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9331
9332 *-TR 1094622 FH - need to update org_price
9333 loIPOtd.org_price = lnDetailPrice
9334
9335 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
9336 *- 02/18/11 YIK 1052584
9337 *- Moved calculation of ppk_qty here
9338 loIPOtd.ppk_qty = lnTotSLNQty
9339
9340 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9341
9342 IF loIPOtd.ppk_action = 'Q'
9343 loIPOtd.ppk_action = 'M'
9344 ENDIF
9345
9346 *- 02/18/11 YIK 1052584
9347 *- moved calculation of ppk_qty higher
9348 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9349
9350 lnDetailPrice = &pceipoTD..Org_Price
9351
9352 CASE loIPOtd.ppk_action = 'P'
9353 *-TR 1062018/1064343 FH - moved up
9354 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9355 *- TR 1062018/1064343 FH - moved up
9356 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9357 loIPOtd.ppk_action = 'D'
9358 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty && TR 1094622 FH - why is there a space here
9359 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9360 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9361
9362 *-TR 1094622 FH - need to update org_price
9363 loIPOtd.org_price = lnDetailPrice
9364
9365 OTHERWISE
9366 *-TR 1062018/1064343 FH - moved up
9367 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9368 *- TR 1062018/1064343 FH - moved up
9369 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9370 lnDetailPrice = &pceipoTD..Org_Price
9371 loIPOtd.ppk_qty = lnTotSLNQty
9372
9373 ENDCASE
9374 *=== TR 1049029 30-Aug-2010 Partha ===
9375
9376 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
9377 IF __tmpipots.price_flg = "E"
9378 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9379 ELSE
9380 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9381 ENDIF
9382
9383 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
9384 loIPOtd.Errs_flg_d = "N"
9385 loIPOtd.Errs_msg_d = ""
9386 *=== TR 1038353 NH
9387
9388 APPEND BLANK
9389 GATHER NAME loIPOtd MEMO
9390
9391 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9392
9393 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
9394 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
9395 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
9396
9397 &lcSQL
9398 SELECT _tmpipodnt
9399 SCAN
9400 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
9401 SELECT "Vzzeipotd_notes_iPOproc"
9402 SCATTER NAME loIPOtdn MEMO
9403
9404 APPEND BLANK
9405 loIPOtdn.Fkey = lnStartPkey
9406 loIPOtdn.Pkey = v_nextPkey("SysNotes")
9407
9408 GATHER NAME loIPOtdn MEMO
9409 ENDIF
9410
9411 ENDSCAN
9412 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
9413
9414 ENDIF && TR 1043037 OCT-06-2009 BR
9415 ENDIF
9416 SELECT __tmpipots
9417 SKIP IN __tmpipots
9418 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
9419
9420 *- TR 1062018/1064343 FH
9421 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9422 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9423 *- TR 1062018/1064343 FH
9424 DELETE IN (pceipoTD)
9425
9426 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9427
9428 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
9429 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
9430 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
9431
9432 ENDIF && TR 1043037 OCT-06-2009 BR
9433
9434 lnCoor_Code = lnCoor_Code + 1
9435 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9436 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9437 ENDIF
9438 lnLine_Seq = 0
9439 ENDIF
9440 ENDDO
9441 USE IN __tmpipots
9442
9443 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9444
9445 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9446 This.Tableupdate("Vzzeipotd_notes_iPOproc")
9447 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9448
9449 ENDIF && TR 1043037 OCT-06-2009 BR
9450
9451 SELECT (lnOldSelect)
9452 RETURN llRetVal
9453 ENDPROC
9454
9455*=======================================================================
9456
9457 *---- get total sln qty for a detail line
9458 FUNCTION getPriceFromIPOts
9459 LPARAMETERS pceipoTS, pnPrice
9460 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
9461 lnUnitPrice = 0
9462 IF pnPrice > 0
9463 lnOldSelect = SELECT()
9464
9465 SELECT (pceipoTS)
9466 lnFkey = Fkey
9467 lnSLNQty = SLN_Qty
9468 .PushRecordSet()
9469 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
9470 lnUnitPrice = pnPrice/lnSLNTotalQty
9471 .PopRecordSet()
9472
9473 SELECT (lnOldSelect)
9474 ENDIF
9475
9476 RETURN lnUnitPrice
9477 ENDFUNC
9478
9479 ************************************************************************************
9480 * Resolve BC SKU from SLN records and create customer style data.
9481 *--- This is splitted 1st part from function ResolveStyleFromSLN
9482 ************************************************************************************
9483 Procedure ResolveBCSkuFromSLN
9484 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9485 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9486 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
9487 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9488 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
9489 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
9490
9491 lnOldSelect = Select()
9492 llRetVal = .T. && 1040686
9493 *--- TR 1036614 3-Mar-2010 Goutam
9494 lcErrs_Msg = ""
9495 lcDivision = ""
9496 *=== TR 1036614 3-Mar-2010 Goutam
9497
9498 *-- #1 Resolve SLN SKUs
9499 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
9500 *- 03/19/09 TR ? Retrofit TR1038539 YIK
9501 *- added SLN_SKU
9502 *- Removed WHERE ...and !Empty(s.SLN_UPC)
9503
9504 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
9505 * Added , s.sln_qty
9506 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
9507
9508 select h.Customer;
9509 , s.FKey;
9510 , s.SLN_UPC as UPC;
9511 , s.SLN_SKU as SKU ;
9512 , h.department ;
9513 , h.store ;
9514 , s.PKey;
9515 , .F. as SLN_Error;
9516 , Empty(d.SizeBucket) as Unresolved;
9517 , s.Division;
9518 , s.Style;
9519 , s.Color_Code;
9520 , s.SizeBucket;
9521 , d.Pkey as dtlPkey;
9522 , 'N' as IsPPK;
9523 , SPACE(5) as ppk_code;
9524 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9525 , s.sln_qty ;
9526 , h.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added h.control_pkey
9527 from (pceipoTH) h;
9528 join (pceipoTD) d ;
9529 on d.FKey = h.PKey;
9530 join (pceipoTS) s ;
9531 on s.FKey = d.PKey ;
9532 where !Empty(h.Customer) ;
9533 order by 1, 2;
9534 into Cursor tmpCurs ReadWrite
9535
9536* , s.Lbl_Code;
9537* , s.Dimension;
9538
9539*- 1040686
9540
9541 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9542 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9543 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9544 IF llRetVal
9545 .PopulateSQLTempTable("tcCustUpc")
9546 ENDIF
9547
9548 llRetVal = llRetVal AND v_sqlexec(;
9549 "SELECT x.upc,d.* "+;
9550 " FROM zzxcstdr d"+ ;
9551 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9552 " JOIN " + this.cSQLTempTable + " x " + ;
9553 " ON d.customer = x.customer " +;
9554 " AND d.cust_style = x.upc " + ;
9555 " WHERE h.IB_resolv = 'Y'" + ;
9556 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9557 SELECT tmpCstdr_upc
9558 INDEX on customer + upc TAG cust_upc
9559
9560
9561 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9562 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9563 IF llRetVal
9564 .PopulateSQLTempTable("tcDistUpc")
9565 ENDIF
9566
9567 llRetVal = llRetVal AND v_sqlexec(;
9568 "SELECT x.upc,d.* "+;
9569 " FROM zzeupcnr d"+ ;
9570 " JOIN " + this.cSQLTempTable + " x " + ;
9571 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9572 SELECT tmpUpcnr
9573 INDEX on upc TAG upc
9574
9575
9576 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9577 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9578 IF llRetVal
9579 .PopulateSQLTempTable("tcDistCustSku")
9580 ENDIF
9581 llRetVal = llRetVal AND v_sqlexec(;
9582 "SELECT x.sku,d.* "+;
9583 " FROM zzxcstdr d"+ ;
9584 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9585 " JOIN " + this.cSQLTempTable + " x " + ;
9586 " ON d.customer = x.customer " +;
9587 " AND d.cust_style = x.sku " + ;
9588 " WHERE h.IB_resolv = 'Y'" + ;
9589 " AND d.Size_Desc>'' " + ;
9590 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9591 SELECT tmpCstdr_sku
9592 INDEX ON customer + cust_style TAG cust_sku
9593
9594 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9595 UNION ;
9596 SELECT customer,sku FROM tmpCstdr_sku ;
9597 GROUP BY customer,sku ;
9598 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9599 INDEX ON customer+sku TAG cust_sku
9600 *=-===-=-=-=-=-=-=-
9601
9602*- 1040686
9603
9604 Select tmpCurs
9605 If This.lUserInterface
9606 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9607 This.InitThermo(RecCount())
9608 EndIf
9609
9610 lcOldCust = ""
9611 lcOldUPC = ""
9612 *- 03/19/09 1038539 YIK
9613 lcOldItem = ''
9614 Local lcSku_resolv, lcOldSku_resolv
9615 lcSku_resolv = ""
9616 *=
9617
9618 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9619 If This.lUserInterface
9620 * Advance progress bar, if we're using one.
9621 This.AdvanceThermo(RecNo())
9622 EndIf
9623 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9624 IF !EMPTY(tmpCurs.UPC)
9625
9626 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9627 lcErrs_Msg = ""
9628 lcOldCust = tmpCurs.Customer
9629 lcOldUPC = tmpCurs.UPC
9630
9631 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9632 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9633*- 1040686
9634*!* lcDivision = tmpCstdr.division
9635*!* lcStyle = tmpCstdr.Style
9636*!* lcColor_Code = tmpCstdr.Color_Code
9637*!* lcLbl_Code = tmpCstdr.Lbl_Code
9638*!* lcDimension = tmpCstdr.Dimension
9639*!* lnSizeBucket = tmpCstdr.Size_Bk
9640*!* lnSize_Desc = tmpCstdr.Size_Desc
9641 lcDivision = tmpCstdr_upc.division
9642 lcStyle = tmpCstdr_upc.Style
9643 lcColor_Code = tmpCstdr_upc.Color_Code
9644 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9645 lcDimension = tmpCstdr_upc.Dimension
9646 lnSizeBucket = tmpCstdr_upc.Size_Bk
9647 lnSize_Desc = tmpCstdr_upc.Size_Desc
9648*- 1040686
9649 Else
9650 lcErrs_Msg = ""
9651 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9652 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9653 lcDivision = tmpUpcnr.Division
9654 lcStyle = tmpUpcnr.Style
9655 lcColor_Code = tmpUpcnr.Color_Code
9656 lcLbl_Code = tmpUpcnr.Lbl_Code
9657 lcDimension = tmpUpcnr.Dimension
9658 lnSizeBucket = tmpUpcnr.SizeBucket
9659 lnSize_Desc = tmpUpcnr.Size_Desc
9660 ELSE
9661 *-&&1040686
9662 *lcErrs_Msg = lcErrs_Msg + CRLF
9663 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9664 *-&&1040686
9665 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9666 lnSizeBucket = 0
9667 Endif
9668 Endif
9669 Endif && level break
9670 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9671 *- Added resolution on SKU
9672 ENDIF && TmpCurs.UPC
9673 *- 03/17/09 TR 1038539 YIK
9674 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9675 *- but UPC resolution failed.
9676 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9677 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9678
9679 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9680 lcErrs_Msg = ""
9681 lcOldCust = tmpCurs.customer
9682 lcOldItem = tmpCurs.sku
9683
9684 *- 1040686
9685 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9686 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9687 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9688 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9689 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9690 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9691 Store 0 To lnSizeBucket
9692 ELSE
9693 *- TR 1074276 FH - adding UPPER()
9694 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9695 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9696 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9697 Store 0 To lnSizeBucket
9698 ELSE
9699*!* lcDivision = tmpCstdr.division
9700*!* lcStyle = tmpCstdr.Style
9701*!* lcColor_code = tmpCstdr.color_code
9702*!* lcLbl_code = tmpCstdr.lbl_code
9703*!* lcDimension = tmpCstdr.Dimension
9704*!* lnSizeBucket = tmpCstdr.size_bk
9705*!* lnSize_desc = tmpCstdr.size_desc
9706 lcDivision = tmpCstdr_sku.division
9707 lcStyle = tmpCstdr_sku.Style
9708 lcColor_code = tmpCstdr_sku.color_code
9709 lcLbl_code = tmpCstdr_sku.lbl_code
9710 lcDimension = tmpCstdr_sku.Dimension
9711 lnSizeBucket = tmpCstdr_sku.size_bk
9712 lnSize_desc = tmpCstdr_sku.size_desc
9713 ENDIF
9714 ENDIF
9715 *- 1040686
9716 ENDIF
9717 ENDIF
9718 *== 1038539 Resolution on SKU
9719
9720 Select (pceipoTS)
9721 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9722
9723 Scatter Name loEiPOTS Memo
9724 If !Empty(lcErrs_Msg)
9725 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9726 loEiPOTS.Errs_Flg_S = "Y"
9727 replace Sln_Error with .T. in tmpCurs
9728 Else
9729 replace Division with lcDivision in tmpCurs
9730 Endif
9731
9732 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9733 loEiPOTS.Division = lcDivision
9734 loEiPOTS.Style = lcStyle
9735 loEiPOTS.Color_Code = lcColor_code
9736 loEiPOTS.Lbl_Code = lcLbl_code
9737 loEiPOTS.Dimension = lcDimension
9738 loEiPOTS.SizeBucket = lnSizeBucket
9739 loEiPOTS.Size_Desc = lnSize_Desc
9740 Endif
9741
9742 Gather Name loEiPOTS Memo
9743
9744 EndScan
9745
9746*- 1060291 07/02/12 YIK
9747*- The code below makes no sense. It takes the first prepack found for the SLN.
9748*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9749 *--- TR 1036614 17-Mar-2010 Goutam
9750*-- SELECT tmpCurs
9751*-- SCAN FOR IsPPK = 'N'
9752*-- Select (pceipoTS)
9753*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9754*-- Scatter Name loEiPOTS Memo
9755*--
9756*-- IF NOT EMPTY(loEiPOTS.Dimension)
9757*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9758*-- IF !EMPTY(lcppk_code)
9759*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9760*-- ENDIF
9761*-- ENDIF
9762*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9763*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9764*-- 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')
9765*-- SELECT __tmpDimCurs
9766*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9767*-- lcppk_code = dimension
9768*-- USE IN SELECT('__tmpDimCurs')
9769*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9770*-- 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)
9771*-- SELECT __tmpDimCurs
9772*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9773*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9774*-- ENDIF
9775*-- USE IN SELECT('__tmpDimCurs')
9776*-- ENDIF
9777*-- ENDIF
9778*-- ENDSCAN
9779 *--- TR 1036614 17-Mar-2010 Goutam
9780
9781 *--- TR 1038353 NH - error out dtl line for SLN error
9782 UPDATE td SET Style_SLN_OK = 'N' ;
9783 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9784 WHERE ts.errs_flg_s ='Y'
9785 *=== TR 1038353 NH
9786
9787 If This.lUserInterface
9788 * Reset Thermometer
9789 This.ResetThermo()
9790 EndIf
9791
9792 *--- TR 1036614 8-Jun-2009 Goutam
9793 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9794 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9795
9796 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9797 lnSelect = SELECT()
9798
9799 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9800 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9801
9802 Select tmpErrSlnLines
9803 Scan
9804 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9805 Endscan
9806
9807 This.TableClose("tmpErrSlnLines")
9808
9809 Select (lnSelect )
9810 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9811
9812 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9813 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9814 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9815 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9816 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9817 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9818 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9819 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9820
9821 This.TableClose("tmpCurs")
9822
9823 *=== TR 1036614 8-Jun-2009 Goutam
9824
9825 *-1040686
9826 USE IN SELECT("tcCustUpc")
9827 USE IN SELECT("tmpCstdr_upc")
9828 USE IN SELECT("tcDistUpc")
9829 USE IN SELECT("tmpUpcnr")
9830 USE IN SELECT("tcDistCustSku")
9831 USE IN SELECT("tmpCstdr_sku")
9832 USE IN SELECT("tcAmbigSku")
9833 *-1040686
9834
9835 Select(lnOldSelect)
9836 Return llRetVal
9837 Endproc
9838
9839
9840 *--------------------------------------------
9841 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9842 *--------------------------------------------
9843 Procedure GetImplodeSQL
9844 *-- Populates cImplodeSQL
9845 SET TextMerge OFF NoShow
9846*-- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9847*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9848 Text to this.cImplodeSQL flags 1
9849declare @Division char(3), @Style varChar(50), @Customer char(7),
9850 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9851
9852set @Customer = ?cCustomer
9853set @Division = ?cDivision
9854set @Style = ?cStyle
9855
9856-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9857select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9858 from zzeipocr_expl
9859 where Customer = @Customer
9860 and Division = @Division
9861
9862select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9863
9864--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9865
9866-- Output Values:
9867--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9868declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9869
9870-- first SQL:
9871if @CR_Lbl > ''
9872select top 1 @Color_Code = c.Color_Code
9873 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9874 , @Dimension = c.Dimension
9875 , @Size = Min(z.Size01)
9876-- , c.Lbl_Code as SColR_Lbl
9877 from zzxSColR c
9878 join zzxStylR st
9879 on st.PKey = c.FKey
9880 join zzxPPakH ph
9881 on ph.Division = c.Division
9882 and ph.Size_Code = st.Size_Code
9883 and ph.Ppk_Code = c.Dimension
9884 and c.Color_Code = case
9885 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9886 else c.Color_Code end
9887 join zzxPPakD pd
9888 on pd.FKey = ph.PKey
9889 join zzxSizer z
9890 on z.Division = c.Division
9891 and z.Size_Code = st.Size_Code
9892 cross join zzxBuckt b
9893 left join #ImplodeSLN i
9894 on i.Color_Code = case
9895 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9896 else pd.Color_Code end
9897 and (i.Lbl_Code = case
9898 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9899 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9900 and i.Dimension = pd.Dimension
9901 and i.SizeBucket = b.Size_Num
9902 where c.Style = @Style
9903 and c.Division = @Division
9904 and c.PPack_OK = 'Y'
9905 and c.Active_OK = 'Y'
9906 and ph.Active_OK = 'Y'
9907 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9908 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9909 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9910 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9911 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9912 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9913 and (c.Lbl_Code = case
9914 when @SLN_Lbl > ''
9915 then @SLN_Lbl
9916 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9917 group by c.PKey, ph.Pack_qty
9918 , c.Color_code, c.Lbl_Code, c.Dimension
9919having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9920 and sum(i.Qty) = ph.Pack_qty
9921 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9922 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9923
9924IF @CR_Lbl > '' and @@ROWCOUNT > 0
9925 select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9926ELSE BEGIN
9927
9928select top 1 @Color_Code = c.Color_Code
9929 , @Lbl_Code = c.Lbl_Code
9930 , @Dimension = c.Dimension
9931 , @Size = Min(z.Size01)
9932 from zzxSColR c
9933 join zzxStylR st
9934 on st.PKey = c.FKey
9935 join zzxPPakH ph
9936 on ph.Division = c.Division
9937 and ph.Size_Code = st.Size_Code
9938 and ph.Ppk_Code = c.Dimension
9939 and c.Color_Code = case
9940 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9941 else c.Color_Code end
9942 join zzxPPakD pd
9943 on pd.FKey = ph.PKey
9944 join zzxSizer z
9945 on z.Division = c.Division
9946 and z.Size_Code = st.Size_Code
9947 cross join zzxBuckt b
9948 left join #ImplodeSLN i
9949 on i.Color_Code = case
9950 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9951 else pd.Color_Code end
9952 and (i.Lbl_Code = case
9953 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9954 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9955 and i.Dimension = pd.Dimension
9956 and i.SizeBucket = b.Size_Num
9957 where c.Style = @Style
9958 and c.Division = @Division
9959 and c.PPack_OK = 'Y'
9960 and c.Active_OK = 'Y'
9961 and ph.Active_OK = 'Y'
9962 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9963 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9964 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9965 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9966 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9967 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9968 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9969 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9970 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9971 group by c.PKey, ph.Pack_qty
9972 , c.Color_code, c.Lbl_Code, c.Dimension
9973having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9974 and sum(i.Qty) = ph.Pack_qty
9975 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9976 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9977 , c.Lbl_code -- blank one goes first if there is no match
9978
9979select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9980 where @Color_Code is not null
9981END
9982EndText
9983
9984*--- TechRec 1073664 20-Sep-2013 GSternik ---
9985 Text to this.cImplodeRangeSQL flags 1
9986declare @Division char(3)
9987set @Division = ?cDivision
9988
9989-- Output Values:
9990declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9991
9992select @Style = rh.Rng_Style
9993 , @Color_Code = rh.Rng_Color
9994 , @Lbl_Code = rh.Rng_Lbl
9995 , @Dimension = rh.Rng_Pack
9996 , @SizeBucket = rng_bk
9997 from zzxRangH rh with (NoLock)
9998 join zzxRangD rd with (NoLock)
9999 on rd.FKey = rh.PKey
10000 --join zzxSColR c
10001 -- on c.Division = rh.Division
10002 -- and c.Style = rh.Rng_Style
10003 -- and c.Color_Code = rh.Rng_Color
10004 -- and c.Lbl_Code = rh.Rng_Lbl
10005 -- and c.Dimension = rh.Rng_Pack
10006 join zzxBuckt b with (NoLock)
10007 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
10008 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
10009 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
10010 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
10011 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
10012 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
10013 left join #ImplodeSLN i
10014 on i.Style = rd.Style
10015 and i.Color_Code = rd.Color_Code
10016 and i.Lbl_Code = rd.Lbl_Code
10017 and i.Dimension = rd.Dimension
10018 and i.SizeBucket = b.Size_Num
10019 and i.Division = rd.Division
10020 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
10021 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
10022 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
10023 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
10024 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
10025 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
10026 where rh.Rng_Type = 'P'
10027 and rh.Division = @Division
10028-- and c.Active_OK = 'Y'
10029 group by rh.Rng_Style
10030 , rh.Rng_Color
10031 , rh.Rng_Lbl
10032 , rh.Rng_Pack
10033 , rng_bk
10034having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
10035 and sum(i.Qty) = Max(rh.Rng_Qty)
10036
10037if @Style is not null -- @@RowCount > 0
10038select @Size = case @SizeBucket
10039 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
10040 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
10041 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
10042 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
10043 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
10044 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
10045 from zzxStylR s with (NoLock)
10046 join zzxSizeR z with (NoLock)
10047 on z.Division = s.Division
10048 and z.Size_Code = s.Size_Code
10049 where s.Division = @Division
10050 and s.Style = @Style
10051
10052select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
10053 where @Style is not null
10054EndText
10055*=== TechRec 1073664 20-Sep-2013 GSternik ===
10056
10057 EndProc
10058
10059 *---------------------------------
10060 *--- This function will generate PPK SKU and updates detail with it.
10061 *--- This is splitted 2nd part from function ResolveStyleFromSLN
10062 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
10063 *---------------------------------
10064 Procedure ResolvePPKSkuAndUpdateDetail
10065 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
10066 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
10067 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
10068 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
10069 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
10070 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
10071
10072 llRetVal = .T.
10073 lnOldSelect = Select()
10074
10075 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
10076 Dimension laBuckets(goEnv.MaxBuckets)
10077
10078 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
10079 Select tmpCurs
10080 lnFKey = 0
10081
10082 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
10083
10084 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
10085 Scan
10086 If FKey # lnFKey
10087 lnFKey = FKey
10088
10089 If SLN_Error or !Unresolved
10090 llDeleteSLN = .T.
10091 ELSE
10092 *--- TR 1101199 16-Feb-2017 Goutam
10093 *llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
10094 llDeleteSLN = !Seek(control_pkey, pceipoCR, "pkey")
10095 *=== TR 1101199 16-Feb-2017 Goutam
10096
10097 If !llDeleteSLN
10098 Select (pceipoCR)
10099 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
10100
10101 *--- TR 1036614 10-Jun-2009 Goutam
10102 *llDeleteSLN = StyleFromSLN < "Y"
10103 llDeleteSLN = StyleFromSLN < "O"
10104 *=== TR 1036614 10-Jun-2009 Goutam
10105
10106 Select tmpCurs
10107 EndIf
10108 EndIf
10109
10110 If !llDeleteSLN
10111 lnRecNo = RecNo()
10112
10113 Scan while FKey = lnFKey
10114 If SLN_Error
10115 *-- One SLN with error exists.
10116 llDeleteSLN = .T.
10117 Exit
10118 EndIf
10119 EndScan
10120
10121 Go lnRecNo
10122 EndIf
10123 EndIf
10124
10125 If llDeleteSLN
10126 Delete
10127 EndIf
10128 EndScan
10129
10130
10131 *-- #3 -- Updating Details with PPK BC SKU:
10132 lcOldCust = ""
10133 lcOldSKU = ""
10134 lnFKey = 0
10135 lnRecNo = This.CountTotalRecs('tmpCurs')
10136
10137 If lnRecNo > 0
10138 *-- Need for optimization:
10139
10140 If This.lUserInterface
10141 This.UpdateThermoCaption("Resolving Style From SLN...")
10142 This.InitThermo(lnRecNo + 1)
10143 lnRecNo = 1
10144 Endif
10145 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
10146
10147 *- 1041704 07/30/09 YIK
10148 *--- TechRec 1073664 20-Sep-2013 GSternik ---
10149 *-- Let's rely on the field types in the UPC table:
10150 *v_SQLExec("create table #ImplodeSLN " + ;
10151 * "( 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)
10152 * " Size_Desc Char(10), Qty Int, PKey Int)")
10153 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
10154 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
10155 *=== TechRec 1073664 20-Sep-2013 GSternik ===
10156
10157 Select (pceipoTD)
10158 lcOldOrder = Order()
10159
10160 *- 03/23/09 YIK
10161 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
10162 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
10163 Index on Customer+SKU+UPC+Assortment tag CustSKU
10164 lcOldUPC = ''
10165 *==
10166
10167 If This.lUserInterface
10168 This.AdvanceThermo(lnRecNo)
10169 EndIf
10170
10171 Select tmpCurs
10172 Locate
10173 cCustomer = Customer
10174
10175 Do while .T. && Scan replacement
10176 if FKey # lnFKey && Will trigger @ EOF :o)
10177 If llProcess
10178 If llImplodeOK
10179 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
10180
10181 *--- TechRec 1073664 20-Sep-2013 GSternik ---
10182 *-- Let's check if they belong to the Range Style 'P'
10183 If Reccount("qPPK") = 0 && Prepack not found
10184 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
10185 EndIf
10186 *=== TechRec 1073664 20-Sep-2013 GSternik ===
10187
10188 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
10189 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
10190 Select (pceipoTS)
10191 *- insert into #implodeSLN
10192 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
10193 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
10194 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
10195 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
10196 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
10197 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10198 Endif
10199 EndIf && llImplodeOK
10200 *========= 1041704 07/30/09 YIK
10201
10202 select (pceipoTD)
10203 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
10204 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
10205 lcOldCust = Customer
10206 lcOldSKU = SKU
10207
10208 *- 03/23/09 YIK
10209 *-- Update all records with the same CustSKU
10210 *- =Seek(lcOldCust+lcOldSKU) && First matching record
10211 lcOldUPC = UPC
10212 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
10213
10214 *==
10215 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
10216 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10217 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
10218 replace Division with cDivision, ;
10219 Style with qPPK.Style, ;
10220 Color_Code with qPPK.Color_Code, ;
10221 Lbl_Code with qPPK.Lbl_Code, ;
10222 Dimension with qPPK.Dimension,;
10223 SizeBucket with qPPK.SizeBucket;
10224 Size_Desc with qPPk.Size01;
10225 Style_SLN_OK with 'Y' ;
10226 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10227 Else
10228
10229 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
10230 *--- TR 1036614 12-Jun-2009 Goutam
10231
10232 *--- TR 1101199 16-Feb-2017 Goutam
10233 *IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
10234 =SEEK(fkey, 'pceipoTH', 'pkey')
10235 IF Seek(&pceipoTH..control_pkey, pceipoCR, "pkey") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
10236 *=== TR 1101199 16-Feb-2017 Goutam
10237
10238 *=== TR 1036614 12-Jun-2009 Goutam
10239 *--- TR 1056329 02-Nov-11 SK
10240 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10241 replace Style_SLN_OK with 'N' ;
10242 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10243 *--- TR 1036614 12-Jun-2009 Goutam
10244 ENDIF
10245 *=== TR 1036614 12-Jun-2009 Goutam
10246
10247 ENDIF
10248 Else && llProcess flag is not set
10249 v_SQLExec("TRUNCATE TABLE #ImplodeSLN") && FH 1105469
10250 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
10251 Select (pceipoTS)
10252 *- insert into #implodeSLN
10253 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10254 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
10255 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
10256 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
10257 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
10258 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
10259 *=== 1041704
10260 EndIf
10261 EndIf && Process Detail
10262
10263 Select tmpCurs
10264 if Eof()
10265 Exit
10266 EndIf
10267
10268 lnFKey = FKey
10269 cCustomer = Customer
10270 Select (pceipoTD)
10271 =Seek(lnFKey, pceipoTD, "PKey")
10272
10273 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
10274
10275 llImplodeOK = llProcess
10276
10277 If llImplodeOK
10278 store 0 to laBuckets
10279 lnPackTotal = 0
10280
10281 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
10282 Select (pceipoTS)
10283 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
10284
10285 cDivision = Division
10286 cStyle = Style
10287 lcColor_Code = Color_Code
10288 lcLbl_Code = Lbl_Code
10289 lcDimension = Dimension
10290 EndIf
10291
10292 Else && The same FKey
10293 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
10294 Select (pceipoTS)
10295 if Division # cDivision;
10296 or Style # cStyle
10297 *- 1041704 YIK 07/29/09
10298 *- Allow multicolor prepacks
10299 *-- or Color_Code # lcColor_Code;
10300 *-- or Lbl_Code # lcLbl_Code;
10301 *-- or Dimension # lcDimension
10302
10303 llImplodeOK = .F.
10304 ELSE
10305 *- insert into #implodeSLN
10306 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10307 v_SQLExec("insert into #ImplodeSLN values ('"+;
10308 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
10309 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
10310 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10311 *=== 1041704
10312 EndIf
10313 EndIf
10314 EndIf && FKey Changed
10315
10316 if llImplodeOK
10317 *-- (pceipoTS) is selected!
10318 laBuckets[SizeBucket] = Sln_Qty
10319 lnPackTotal = lnPackTotal + Sln_Qty
10320 EndIf
10321
10322 Select tmpCurs
10323 Skip
10324
10325 If This.lUserInterface
10326 lnRecNo = lnRecNo + 1
10327 This.AdvanceThermo(lnRecNo)
10328 Endif
10329 EndDo && Endscan
10330
10331 Select (pceipoTD)
10332 Set Order to (lcOldOrder)
10333 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
10334 *v_SQLExec("DROP table #ImplodeSLN ")
10335 EndIf && Have data to Implode
10336
10337 *--- TR 1036614 11-Jun-2009 Goutam
10338 *Use In tmpCurs
10339 *=== TR 1036614 11-Jun-2009 Goutam
10340
10341 If This.lUserInterface
10342 * Reset Thermometer
10343 This.ResetThermo()
10344 Endif
10345
10346 Select(lnOldSelect)
10347 Return llRetVal
10348 Endproc
10349 *=== TR 1035491 4-Nov-2008 Goutam
10350
10351*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
10352*!*
10353* TR 1037925 - As per Krishna/Shenba
10354* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
10355* This is getting moved in TR 1037925
10356
10357*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
10358*!* *===========================================================================================
10359*!* Function ResolveCustShipper
10360*!* Lparameters pceipoTH, pceipoCR
10361*!* LOCAL lnSelect, llRetVal
10362
10363*!* lnSelect = SELECT()
10364
10365*!* WITH This
10366*!*
10367*!* SELECT distinct h.customer, h.division, ;
10368*!* h.cust_shipper ;
10369*!* FROM (pceipoTH) h, (pceipoCR) r ;
10370*!* WHERE r.resv_cust_ship = 'Y' and ;
10371*!* h.customer = r.customer and ;
10372*!* h.division = r.division ;
10373*!* INTO CURSOR '_tmpCustShipper'
10374*!*
10375*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10376*!*
10377*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10378*!*
10379*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
10380*!* REPLACE ALL shipper WITH '' In (pceipoTH)
10381*!* SET RELATION TO
10382*!* ENDIF
10383*!*
10384*!* SELECT '_tmpCustShipper'
10385
10386*!* .cSQLTempTable = ""
10387*!*
10388*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10389*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10390*!* IF !EMPTY(.cSQLTempTable)
10391*!*
10392*!* *---- Matching with customer, cust_shipper, division
10393*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10394*!* "s.shipper " + ;
10395*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10396*!* "Where s.customer = t.customer and " + ;
10397*!* "s.division = t.division and " + ;
10398*!* "s.cust_shipper = t.cust_shipper "
10399*!*
10400*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10401*!*
10402*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10403*!* SELECT _custShipper
10404*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10405*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10406*!* IF llRetVal
10407*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10408*!* SET RELATION TO
10409*!* ENDIF
10410*!* ENDIF
10411*!* ENDIF
10412*!* ENDIF
10413*!* ENDIF
10414*!*
10415*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10416*!* FROM (pceipoTH) h, (pceipoCR) r ;
10417*!* WHERE r.resv_cust_ship = 'Y' and ;
10418*!* h.customer = r.customer and ;
10419*!* h.division = r.division and ;
10420*!* EMPTY(h.shipper) ;
10421*!* INTO CURSOR '_tmpCustShipper'
10422*!*
10423*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10424*!*
10425*!* SELECT '_tmpCustShipper'
10426
10427*!* .cSQLTempTable = ""
10428*!*
10429*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10430*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10431*!* IF !EMPTY(.cSQLTempTable)
10432*!*
10433*!* *---- Matching with customer, cust shipper, and division = ''
10434*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10435*!* "s.shipper " + ;
10436*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10437*!* "Where s.customer = t.customer and " + ;
10438*!* "s.division = '' and " + ;
10439*!* "s.cust_shipper = t.cust_shipper "
10440*!*
10441*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10442*!*
10443*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10444*!* SELECT _custShipper
10445*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10446*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10447*!*
10448*!* IF llRetVal
10449*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10450*!* SET RELATION TO
10451*!* ENDIF
10452*!*
10453*!* ENDIF
10454*!* ENDIF
10455*!* ENDIF
10456*!* ENDIF
10457
10458*!* USE in '_tmpCustShipper'
10459*!*
10460*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10461*!* FROM (pceipoTH) h, (pceipoCR) r ;
10462*!* WHERE r.resv_cust_ship = 'Y' and ;
10463*!* h.customer = r.customer and ;
10464*!* h.division = r.division and ;
10465*!* EMPTY(h.shipper) ;
10466*!* INTO CURSOR '_tmpCustShipper'
10467*!*
10468*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10469*!*
10470*!* IF RECCOUNT('_tmpCustShipper') > 0
10471*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10472*!*
10473*!* IF llRetVal
10474*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
10475*!* Errs_flg_h WITH "Y" ;
10476*!* FOR customer = _tmpCustShipper.customer and ;
10477*!* division = _tmpCustShipper.division and ;
10478*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
10479*!*
10480*!* SET RELATION TO
10481*!* ENDIF
10482*!*
10483*!* ENDIF
10484*!*
10485*!* ENDWITH
10486*!*
10487*!* USE in '_tmpCustShipper'
10488*!* USE in '_custShipper'
10489*!* SELECT(lnSelect)
10490*!*
10491*!* RETURN llRetVal
10492*!* ENDFUNC
10493*!* *===========================================================================================
10494*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
10495*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
10496
10497*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
10498*============================================================
10499 FUNCTION CalculateSLNs
10500 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10501 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10502 lnTotal_qty
10503
10504 llRetVal = true
10505 lnSelect = SELECT()
10506
10507 lcCursor = GetUniqueFileName()
10508 WITH This
10509
10510 *--- TR 1047450 28-May-2010 Partha ---
10511 * removed c.Template = 'GAP'
10512 * from where clause of following qry
10513
10514*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10515*!* " FROM (pceipoTD) d " + ;
10516*!* " JOIN (pceipoTH) H " + ;
10517*!* " ON H.pkey = d.fkey " + ;
10518*!* " JOIN (pceipoCR) C " + ;
10519*!* " ON D.division = C.Division " + ;
10520*!* " AND H.Customer = C.Customer " + ;
10521*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
10522
10523 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10524 " FROM (pceipoTD) d " + ;
10525 " JOIN (pceipoTH) H " + ;
10526 " ON H.pkey = d.fkey " + ;
10527 " JOIN (pceipoCR) C " + ;
10528 " ON h.control_pkey = C.pkey " + ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
10529 " WHERE NOT (d.Gap_ok = 'Y') "
10530 *=== TR 1047450 28-May-2010 Partha ===
10531
10532 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10533
10534 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10535 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10536 lcDeatil = .cSQLTempTable
10537
10538 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10539 " FROM " + lcDeatil + " t " + ;
10540 " JOIN zzxscolr s " + ;
10541 " ON s.division= t.division and " +;
10542 " s.style= t.style and s.color_code= t.color_code and " +;
10543 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10544 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10545 " LEFT OUTER JOIN zzxppakh ph " + ;
10546 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10547 " s.dimension= ph.ppk_code " + ;
10548 " Where s.ppack_ok= 'Y' "
10549
10550 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10551
10552 IF llRetVal
10553 *--- TR 1038394 YIK 01/29/09
10554 *- Select(lcCursor)
10555 *--INDEX on Pkey TAG Pkey
10556 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10557 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10558
10559 lnPrePack = 0
10560 SELECT(lcCursor)
10561 SCAN
10562 lnPkey = Pkey
10563 lnpack_qty = pack_qty
10564
10565 lnTotal_qty = &pceipoTD..Total_qty
10566
10567 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10568 lcErrs_Msg = " Can not Calculate number of prepacks. "
10569
10570 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10571 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10572 Errs_Flg_D With "Y" ;
10573 IN (pceipoTD)
10574 LOOP
10575 ELSE
10576 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10577 IF lnpack_qty >0
10578 lnTotal_qty = lnTotal_qty /lnpack_qty
10579 ENDIF
10580 ENDIF
10581 Endif
10582
10583 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10584 lnPrePack = (lnTotal_qty/lnpack_qty)
10585 SELECT(pceipoTS)
10586 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10587
10588 IF lnSlnqty >0
10589 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10590 SELECT(pceipoTS)
10591 SCAN FOR Fkey = lnPkey
10592 IF MOD(sln_qty,lnPrePack) >0
10593 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10594 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10595 Errs_Flg_S With "Y"
10596 ENDIF
10597 ENDSCAN
10598 LOOP
10599 ELSE
10600 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10601*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10602 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10603 ENDIF
10604
10605 ENDIF
10606 ENDSCAN
10607
10608 ENDIF
10609 ENDIF
10610 .TableClose(lcCursor)
10611 ENDWITH
10612
10613 SELECT (lnSelect)
10614 RETURN llRetVal
10615 ENDFUNC
10616*============================================================
10617
10618*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10619
10620
10621*--- TR 1036917 04-Feb-2009 Partha ---
10622
10623*============================================================
10624 FUNCTION ChangeColor
10625 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10626 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10627 lnTotal_qty
10628
10629 llRetVal = true
10630 lnSelect = SELECT()
10631
10632 WITH This
10633 *--- TR 1039262 NSD - Use current system date, not PO date.
10634 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10635 If This.oHostProcess.lHaveSLN
10636 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.
10637 " 'D' AS Source " + ;
10638 " FROM (pceipoTD) d " + ;
10639 " JOIN (pceipoTH) H " + ;
10640 " ON H.pkey = d.fkey " + ;
10641 " WHERE d.Errs_flg_d <> 'Y' " + ;
10642 " AND d.org_color = ' ' " +;
10643 " UNION ALL " + ;
10644 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10645 " 'S' AS Source " + ;
10646 " FROM (pceipoTD) d " + ;
10647 " JOIN (pceipoTH) H " + ;
10648 " ON H.pkey = d.fkey " + ;
10649 " JOIN (pceipoTS) S " + ;
10650 " ON D.pkey = s.fkey " + ;
10651 " WHERE s.Errs_flg_s <> 'Y' " + ;
10652 " AND s.org_color = ' ' "
10653 ELSE
10654 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10655 " 'D' AS Source " + ;
10656 " FROM (pceipoTD) d " + ;
10657 " JOIN (pceipoTH) H " + ;
10658 " ON H.pkey = d.fkey " + ;
10659 " WHERE d.Errs_flg_d <> 'Y' " + ;
10660 " AND d.org_color = ' ' "
10661 ENDIF
10662
10663 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10664
10665 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10666 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10667 lcDeatil = .cSQLTempTable
10668 *--- 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)
10669 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10670 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10671 " FROM " + lcDeatil + " t " + ;
10672 " JOIN zzxrupch h " + ;
10673 " ON h.division= t.division " + ;
10674 " and h.style= t.style " + ;
10675 " and h.color_code= t.color_code " + ;
10676 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10677 " and h.dimension = t.dimension " + ;
10678 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10679 " WHERE h.active_ok = 'Y' " + ;
10680 " AND d.active_color = 'Y' " + ;
10681 " AND d.effect_Date = " + ;
10682 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10683 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10684 " ORDER BY d1.effect_date DESC ) "
10685
10686 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10687
10688 IF llRetVal
10689 Select("__RollingUpc")
10690 INDEX on Pkey TAG Pkey
10691 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10692
10693 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10694 org_Color WITH __RollingUpc.TempColr ;
10695 FOR NOT EOF("__RollingUpc") ;
10696 AND __RollingUpc.Source = "D" IN (pceipoTD)
10697
10698 Set Relation To
10699
10700 If This.oHostProcess.lHaveSLN
10701 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10702 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10703 org_Color WITH __RollingUpc.TempColr ;
10704 FOR NOT EOF("__RollingUpc") ;
10705 AND __RollingUpc.Source = "S" IN (pceipoTS)
10706 Set Relation To
10707 ENDIF
10708
10709 ENDIF
10710
10711 .TableClose("__RollingUpc")
10712
10713 ENDIF
10714 ENDWITH
10715
10716 SELECT (lnSelect)
10717 RETURN true
10718 ENDFUNC
10719*============================================================
10720
10721*=== TR 1036917 04-Feb-2009 Partha ===
10722
10723**************************************************************************************
10724
10725*- TR 1109914 FH - server side insert to notes.
10726 Procedure UpdateSysNotesServerSide
10727 LOCAL tmpTbl, llRetVal, lcSql, llBeganTransaction
10728
10729 lcSql = ""
10730 llRetVal = .T.
10731
10732 If This.BeginTransaction()
10733 SELECT * FROM Vzzeipotd_notes_iPOproc WITH (BUFFERING = .T.) INTO CURSOR lctmpNt READWRITE
10734 THIS.BulkInsert_CorrectDateFields('lctmpNt')
10735
10736 llRetVal = llRetVal AND .GenerateSQLTempTable('lctmpNt')
10737 llRetVal = llRetVal AND .PopulateSQLTempTable('lctmpNt')
10738 If !Empty(.cSQLTempTable)
10739 llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cSQLTempTable,'sysnotes')
10740 llRetVal = llRetVal and v_sqlexec(lcSQL)
10741
10742 ENDIF
10743 v_sqlexecnoerror("DROP TABLE " + .cSQLTempTable)
10744 USE IN SELECT("lctmpNt")
10745
10746 If llRetVal
10747 This.EndTransaction()
10748 Else
10749 This.RollbackTransaction()
10750 Endif
10751 ENDIF
10752
10753 RETURN llRetVal
10754 ENDPROC
10755*- TR 1109914 FH -
10756
10757
10758
10759 * --- TR 1034963 12/15/08 CM
10760 * This procedure will write back to sysnotes exploded components of Range Styles
10761
10762 Procedure UpdateSysNotes
10763
10764 Local laTables[1]
10765 laTables[1] = "Vzzeipotd_notes_iPOproc"
10766
10767 Local llRetVal, llBeganTransaction
10768
10769 llRetVal = .T.
10770
10771 If This.BeginTransaction()
10772 llRetVal = This.Tableupdate(@laTables)
10773 If llRetVal
10774 This.EndTransaction()
10775 Else
10776 This.RollbackTransaction()
10777 Endif
10778 Endif
10779
10780 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10781
10782 Endproc
10783 * --- TR 1034963 12/15/08 CM
10784
10785**************************************************************************************
10786
10787 *--------------------------------------------------
10788 *--- TR 1041542 NSD 7/22/09
10789 * Register Number can be assigned by a sort now.
10790 PROCEDURE ResolveRegisterNumber
10791 LPARAMETERS pceipoTH
10792
10793 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10794 llRetVal = .T.
10795 lnSelect = SELECT()
10796
10797 WITH THIS
10798
10799 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10800 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10801 lcColList = "pkey,customer,reg_num"
10802 SELECT tcAllCols
10803 SCAN
10804 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10805 ENDSCAN
10806
10807 * Retrieve just the columns we need
10808 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10809 &lcSQL
10810
10811 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10812 * Push records to server to work with.
10813 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10814 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10815 lcAllTmp = .cSQLTempTable
10816
10817 * Find distinct customer
10818 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10819 SELECT tcRegNum_cust
10820 SCAN
10821 * Process 1 customer
10822
10823 * Get the grouping
10824 lcCustTmp = "#" + GetUniqueFileName()
10825 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10826 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10827 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10828 IF llRetVal
10829 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10830 lcGrouping = "CUSTOMER,PO_NUM"
10831 ELSE
10832 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10833 ENDIF
10834
10835 * Need to have a SQL Filter for the groupings
10836 STRINGTOARRAY(lcGrouping,@laGroupFields)
10837 lcGroupFieldsFilter = ""
10838 FOR x = 1 TO ALEN(laGroupFields,1)
10839 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10840 ENDFOR
10841 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10842
10843 * Create temp table of unique reg nums
10844 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10845 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10846 " GROUP BY " + lcGrouping
10847 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10848
10849 * Count distinct records and generate enough reg_nums
10850 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10851 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10852
10853 * Calculate New reg_nums
10854 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10855
10856 * Write back to table
10857 llRetVal = llRetVal AND v_sqlexec(;
10858 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10859 lcGroupFieldsFilter )
10860
10861 ENDIF
10862
10863 USE IN SELECT("tcRegNum_Sort")
10864 USE IN SELECT("tcRegNum_cnt")
10865 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10866 ENDSCAN
10867
10868 * Get all records back from Temp table. Loop through and apply to main cursor
10869 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10870 IF llRetVal
10871 SELECT tcRegNum_res
10872 SCAN
10873 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10874 SELECT (pceipoTH)
10875 REPLACE reg_num WITH tcRegNum_res.reg_num
10876 ENDIF
10877 ENDSCAN
10878
10879 ENDIF
10880
10881 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10882 ENDIF
10883
10884
10885 USE IN SELECT("tcRegNum_res")
10886 USE IN SELECT("tcAllCols")
10887 USE IN SELECT("tcRegNum_All")
10888 USE IN SELECT("tcRegNum_cust")
10889
10890 ENDWITH
10891
10892 SELECT(lnSelect)
10893 RETURN llRetVal
10894 ENDPROC
10895 *=== TR 1041542 NSD 7/22/09
10896
10897*===============================================================
10898
10899 *--- TR 1036614 8-Jun-2009 Goutam
10900 Procedure CreateSingleSLNCursor
10901 Lparameters pcTmpCursor
10902
10903 Local llRetVal, lnOldSelect, lcSQLString
10904
10905 llRetVal = true
10906 lnOldSelect = Select()
10907
10908 *---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.
10909
10910 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10911
10912 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10913*!* select t.Customer ;
10914*!* , t.FKey ;
10915*!* , t.PKey ;
10916*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10917*!* , c.template ; && TR 1050793
10918*!* , c.slntodtl ; && TR 1050793
10919*!* from (pcTmpCursor) t ;
10920*!* join zzeipocr c ;
10921*!* on c.division = t.division ;
10922*!* and c.customer = t.customer ;
10923*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10924*!* on s.division = t.division ;
10925*!* and s.customer = t.customer ;
10926*!* and s.store = t.store ;
10927*!* where c.slntodtl = 'N' ;
10928*!* and (c.stylefromsln = 'O' ;
10929*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10930*!* into Cursor __tmpipots ;
10931*!* order by t.fkey, t.Customer, t.PKey
10932
10933 select t.Customer ;
10934 , t.FKey ;
10935 , t.PKey ;
10936 , NVL(s.price_flg, c.price_flg) as price_flg ;
10937 , c.template ; && TR 1050793
10938 , c.slntodtl ; && TR 1050793
10939 from (pcTmpCursor) t ;
10940 join zzeipocr c ;
10941 on c.pkey = t.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
10942 left join (this.oHostProcess.cCustomerStoreTable) s ;
10943 on s.division = t.division ;
10944 and s.customer = t.customer ;
10945 and s.store = t.store ;
10946 where c.slntodtl = 'N' ;
10947 and (c.stylefromsln = 'O' ;
10948 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10949 JOIN zzeipocr c ;
10950 on c.pkey = t.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
10951 group by t.fkey having (count(t.pkey)=1) and ;
10952 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10953 into Cursor __tmpipots ;
10954 order by t.fkey, t.Customer, t.PKey
10955 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10956
10957 Select(lnOldSelect)
10958 Return llRetVal
10959 Endproc
10960 *=== TR 1036614 8-Jun-2009 Goutam
10961
10962 *--- TR 1036614 8-Jun-2009 Goutam
10963 *--- This is the splited function from MoveSLNToDTLs
10964 PROCEDURE CreateCursorSLNToDtl
10965 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10966
10967 LOCAL llRetVal, lnOldSelect
10968 lnOldSelect = SELECT()
10969 llRetVal = true
10970
10971 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10972*!* select t.Customer ;
10973*!* , t.FKey ;
10974*!* , t.PKey ;
10975*!* , c.price_flg ;
10976*!* from (pcTmpCursor) t ;
10977*!* join zzeipocr c ;
10978*!* on c.division = t.division ;
10979*!* and c.customer = t.customer ;
10980*!* join (pceipoTD) d ;
10981*!* on d.pkey = t.dtlPkey ;
10982*!* where c.slntodtl = 'Y' ;
10983*!* and d.slntodtl <> 'Y' ;
10984*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10985*!* into Cursor __tmpipots ;
10986*!* order by t.fkey, t.Customer, t.PKey
10987
10988 *--- TR 1045922 05-MAR-2010 HNISAR
10989 * Added 'I' to Inlis in below statements
10990*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10991*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10992 *=== TR 1045922 05-MAR-2010 HNISAR
10993
10994 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10995 select t.Customer ;
10996 , t.FKey ;
10997 , t.PKey ;
10998 , NVL(s.price_flg, c.price_flg) as price_flg ;
10999 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
11000 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
11001 from (pcTmpCursor) t ;
11002 join zzeipocr c ;
11003 on c.pkey = t.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
11004 left join (this.oHostProcess.cCustomerStoreTable) s ;
11005 on s.division = t.division ;
11006 and s.customer = t.customer ;
11007 and s.store = t.store ;
11008 join (pceipoTD) d ;
11009 on d.pkey = t.dtlPkey ;
11010 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
11011 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
11012 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
11013 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
11014 into Cursor __tmpipots ;
11015 order by t.fkey, t.Customer, t.PKey
11016 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
11017
11018 SELECT(lnOldSelect)
11019 RETURN llRetVal
11020
11021 ENDPROC
11022
11023 Procedure ResolveSingleSLNDetail
11024 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
11025
11026 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
11027
11028 llRetVal = true
11029 lnOldSelect = Select()
11030
11031 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
11032 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
11033 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
11034 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
11035
11036 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
11037*!* select t.Customer ;
11038*!* , t.FKey ;
11039*!* , t.PKey ;
11040*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
11041*!* , t.ppk_code ;
11042*!* from (pcTmpCursor) t ;
11043*!* join zzeipocr c ;
11044*!* on c.division = t.division ;
11045*!* and c.customer = t.customer ;
11046*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
11047*!* on s.division = t.division ;
11048*!* and s.customer = t.customer ;
11049*!* and s.store = t.store ;
11050*!* where c.slntodtl = 'N' ;
11051*!* AND ((c.stylefromsln in ('Y','O') ;
11052*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
11053*!* into Cursor __tmpipots ;
11054*!* order by t.fkey, t.Customer, t.PKey
11055
11056 select t.Customer ;
11057 , t.FKey ;
11058 , t.PKey ;
11059 , NVL(s.price_flg, c.price_flg) as price_flg ;
11060 , t.ppk_code ;
11061 from (pcTmpCursor) t ;
11062 join zzeipocr c ;
11063 on c.pkey = t.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
11064 left join (this.oHostProcess.cCustomerStoreTable) s ;
11065 on s.division = t.division ;
11066 and s.customer = t.customer ;
11067 and s.store = t.store ;
11068 where c.slntodtl = 'N' ;
11069 AND ((c.stylefromsln in ('Y','O') ;
11070 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
11071 JOIN zzeipocr c ;
11072 on c.pkey = t.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
11073 group by t.fkey having (count(t.pkey)=1) and ;
11074 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
11075 into Cursor __tmpipots ;
11076 order by t.fkey, t.Customer, t.PKey
11077 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
11078
11079 SELECT __tmpipots
11080 SCAN
11081 lnFKey = Fkey
11082
11083 Select (pceipoTS)
11084 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
11085
11086 lcDivision = Division
11087 lcStyle = Style
11088 lcColor_Code = Color_Code
11089 lcLbl_Code = Lbl_Code
11090 lcDimension = __tmpipots.PPK_Code
11091 lcSize_Desc = Size_Desc
11092
11093 select (pceipoTD)
11094 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
11095
11096 replace Division with lcDivision, ;
11097 Style with lcStyle, ;
11098 Color_Code with lcColor_Code, ;
11099 Lbl_Code with lcLbl_Code, ;
11100 Dimension with lcDimension,;
11101 SizeBucket with 1;
11102 Size_Desc with lcSize_Desc;
11103 Style_SLN_OK with 'Y' ;
11104 IN (pceipoTD)
11105 ENDIF
11106 ENDIF
11107 ENDSCAN
11108
11109 IF USED("__tmpipots")
11110 USE IN __tmpipots
11111 ENDIF
11112
11113 Select(lnOldSelect)
11114 Return llRetVal
11115 Endproc
11116
11117 *=== TR 1036614 8-Jun-2009 Goutam
11118
11119 *- 1044723 05/20/10 YIK
11120 *- Moved this method from postvalidation()
11121 PROCEDURE ResolveNewStoreOrd_type
11122 LPARAMETERS pcEipoTH
11123 LOCAL llRetVal, lnOldSelect
11124 llRetVal = .t.
11125 lnOldSelect = SELECT()
11126 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
11127 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
11128
11129 LOCAL lcSql, lcEipoTh, lcSQLTempTable
11130 lcEipoTh = SYS(2015)
11131 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
11132
11133 IF RECCOUNT(lcEipoTh) = 0
11134 USE IN (lcEipoTh)
11135 SELECT(lnOldSelect)
11136 RETURN llRetVal
11137 ENDIF
11138
11139 LOCAL lcOrd_typeResult
11140 lcOrd_typeResult = SYS(2015)
11141 WITH this
11142 .cSQLTempTable=""
11143 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
11144 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
11145 lcSQLTempTable = .cSQLTempTable
11146
11147 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
11148 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
11149 " inner join zzotyper r on r.ns_ord_type = 'Y'"
11150 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
11151 IF llRetVal
11152 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
11153 ENDIF
11154 ENDWITH
11155
11156 IF USED(lcEipoTh)
11157 USE IN (lcEipoTh)
11158 ENDIF
11159 IF USED(lcOrd_typeResult)
11160 USE IN (lcOrd_typeResult)
11161 ENDIF
11162
11163 Select(lnOldSelect)
11164 Return llRetVal
11165 Endproc
11166 *=== TR 1035678 NH
11167
11168 *--- TR 1049029 24-Aug-2010 Partha ---
11169 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
11170 FUNCTION GetTotSLNQty
11171 LPARAMETERS tnPSFkey, pceipoTS
11172
11173 LOCAL lnTotSlnQty, lnOldSelect
11174 LOCAL ARRAY laTotSlnQty[1]
11175
11176 lnOldSelect = SELECT()
11177 lnTotSlnQty = 0
11178
11179 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
11180 lnTotSlnQty = laTotSlnQty[1]
11181
11182 Select(lnOldSelect)
11183 Return lnTotSlnQty
11184 ENDFUNC
11185
11186 *=== TR 1049029 24-Aug-2010 Partha ===
11187
11188 *--- TechRec 1048792 17-Dec-2010 jisingh ---
11189 FUNCTION ClearSkus
11190 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
11191 LOCAL llRetVal, lnSelect, lcSqlString
11192
11193 llRetVal = true
11194 lnSelect = SELECT()
11195
11196 *-- Populate new flag from Control in Transaction Maintenance
11197 lcSqlString = " UPDATE h SET " + ;
11198 " ReResvStyle = c.ReResvStyle " + ;
11199 " FROM (pcEipoTH) h " + ;
11200 " JOIN (pcEipoCR) c " + ;
11201 " ON h.control_pkey = c.pkey " + ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
11202 " WHERE h.ReResvStyle = '' "
11203
11204 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11205
11206 *-- Make SKUs blank in Transaction Maintenance detail
11207 lcSqlString = " UPDATE d SET " + ;
11208 " Style = '', " + ;
11209 " Color_Code = '', " + ;
11210 " Lbl_Code = '', " + ;
11211 " Dimension = '', " + ;
11212 " SizeBucket = 0, " + ;
11213 " Size_Desc = '' " + ;
11214 " FROM (pcEipoTD) d " + ;
11215 " JOIN (pcEipoTH) h " + ;
11216 " ON h.pkey = d.fkey " + ;
11217 " WHERE h.ReResvStyle = 'Y' " + ;
11218 " AND (d.upc > '' OR d.sku > '') "
11219
11220 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11221
11222 *-- Make SKUs blank in SLN
11223 lcSqlString = " UPDATE s SET " + ;
11224 " Style = '', " + ;
11225 " Color_Code = '', " + ;
11226 " Lbl_Code = '', " + ;
11227 " Dimension = '', " + ;
11228 " SizeBucket = 0, " + ;
11229 " Size_Desc = '' " + ;
11230 " FROM (pcEipoTD) d " + ;
11231 " JOIN (pcEipoTH) h " + ;
11232 " ON h.pkey = d.fkey " + ;
11233 " JOIN (pcEipoTS) s " + ;
11234 " ON s.fkey = d.pkey " + ;
11235 " WHERE h.ReResvStyle = 'Y' " + ;
11236 " AND (s.sln_upc > '' OR s.sln_sku > '') "
11237
11238 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11239
11240 SELECT (lnSelect)
11241 RETURN llRetVal
11242 ENDFUNC
11243 *=== TechRec 1048792 17-Dec-2010 jisingh ===
11244
11245 *--- TR 1053820 25-May-2011 Goutam
11246 Function GenerateCustomerSKU_Style_ColorSize
11247 Lparameters pceipoTH,pceipoTD
11248
11249 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
11250 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
11251
11252 llRetVal = True
11253 lnSelect = Select()
11254 With This
11255
11256 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
11257
11258 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
11259
11260 *** Size_BK needs to be 00 and NOT 0
11261 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
11262 Select ;
11263 h.customer,;
11264 d.division,;
11265 d.pkey As dtlpkey ,;
11266 d.Style As Style, ;
11267 d.color_code,;
11268 d.lbl_code,;
11269 d.Dimension,;
11270 h.Store As cust_store ,;
11271 d.price As cust_price , ;
11272 d.size_desc, ;
11273 d.sizebucket as size_bk, ;
11274 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
11275 d.aux_sku ;
11276 from (pceipoTH) h ;
11277 join (pceipoTD) d ;
11278 on d.fkey = h.pkey ;
11279 join zzeipocr c ;
11280 on c.pkey = h.control_pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added control_pkey join and removed division/customer join
11281 where c.GenCustSKU = 'Y' ;
11282 and d.sku = '' ;
11283 and h.Errs_flg_h < 'Y' ;
11284 and d.Errs_Flg_D < 'Y' ;
11285 into cursor tmpCurs ;
11286 order by 1,2,4,5,6,7, 11
11287 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
11288
11289 lnCount = Reccount("tmpCurs")
11290
11291 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
11292
11293 If lnCount = 0
11294 If Used("tmpCurs")
11295 Use In tmpCurs
11296 Endif
11297 Select (lnSelect)
11298 Return
11299 Endif
11300
11301 *- Index just in case somebody changes the SELECT above
11302 Select tmpCurs
11303 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
11304 TAG sku
11305
11306 .LogEntry("Load Customer Style.")
11307
11308 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
11309 If Used("tmpCurs")
11310 Use In tmpCurs
11311 Endif
11312 Select (lnSelect)
11313 Return
11314 Endif
11315
11316 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
11317 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
11318 lnCount = lnCount - 1
11319 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
11320 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
11321
11322 Select VZZXCSTHR
11323 Scatter Memvar Blank
11324 Select VZZXCSTDR
11325 Scatter Memvar Blank
11326
11327 m.Last_mod = Datetime()
11328 m.User_id = 'CGSADMIN'
11329 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
11330 m.notes = ''
11331
11332 *--- TR 1057011 7-10-2011 VKK
11333 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
11334 m.active_ok = 'Y'
11335 m.anti_theft = 'N'
11336 *=== TR 1057011 7-10-2011 VKK
11337
11338 lcPrevSKU = ' '
11339 lcPrevSkuSize = ''
11340
11341 *- inserted details counter
11342 Local lnInsertCount
11343 lnInsertCount = 0
11344
11345 Select tmpCurs
11346
11347 Scan
11348 .LogEntry("Loading Customer Style...")
11349 .LogEntry("Style :" + Style )
11350 .LogEntry("Color_code :" + color_code )
11351
11352 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
11353 .LogEntry("Invalid Style or Color_code or Size_bk " )
11354 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
11355 FOR pkey = dtlpkey In (pceipoTD)
11356 Loop
11357 Endif
11358
11359 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
11360 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
11361 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
11362
11363 *--- Client Soffe wants to display size description in dimension's place if it is empty
11364 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
11365 If lcPrevSKU # lcSku
11366 lcPrevSKU = lcSku
11367 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
11368 .LogEntry("Customer :" + m.customer )
11369 .LogEntry("Division : " + m.division)
11370 .LogEntry("Style :" + Style )
11371 .LogEntry("Color_code :" + m.color_code )
11372 .LogEntry("Label code :" + m.lbl_code )
11373 .LogEntry("dimension : " + m.dimension)
11374 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
11375 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))
11376 If Empty(lnHDRpKey)
11377 lnHDRpKey = lnCstHrPkey
11378 .LogEntry("Inserting into header..")
11379 Insert Into VZZXCSTHR From Memvar
11380 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
11381 In VZZXCSTHR
11382 Endif
11383 Endif
11384 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
11385 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
11386 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
11387 *- 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)
11388 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
11389 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)
11390
11391 If Empty(lnDtlKey)
11392 lnDtlpKey = lnCstDrPkey
11393 .LogEntry("Inserting into detail..")
11394 Insert Into VZZXCSTDR From Memvar
11395 *- TR 1071542 FH- need to add replace for dimension here as well
11396 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
11397 lnInsertCount = lnInsertCount + 1
11398 Endif
11399 Endif
11400 lnCstDrPkey = lnCstDrPkey +1
11401 lnCstHrPkey = lnCstHrPkey +1
11402
11403 Endscan
11404
11405 Dimension laTables[2]
11406 laTables[1]= "VZZXCSTHR"
11407 laTables[2]= "VZZXCSTDR"
11408
11409 llBeganTransaction = .BeginTransaction()
11410 llRetVal = .Tableupdate(@laTables)
11411
11412 If llRetVal
11413 If llBeganTransaction
11414 This.EndTransaction()
11415 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
11416 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
11417 Endif
11418 Else
11419 If llBeganTransaction
11420 This.RollbackTransaction()
11421 .LogEntry("Table Update failed - Roll back Transaction " )
11422 Endif
11423 Endif
11424
11425 Endwith
11426
11427 If Used("tmpCurs")
11428 Use In tmpCurs
11429 Endif
11430
11431 Select (lnSelect)
11432 Return llRetVal
11433 Endfunc
11434
11435 *=== TR 1053820 25-May-2011 Goutam
11436
11437*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
11438 *============================================================
11439 Procedure RangePConversion
11440 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
11441 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
11442 llRetVal = .T.
11443 lnOldSelect = Select()
11444
11445 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11446
11447 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11448 * 1st Getting all range headers
11449 *- process all.
11450 *- Exclude range style P from the consideration
11451 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
11452 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
11453
11454 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
11455 FROM (pcTransDetail) d ;
11456 JOIN (pcTransHeader) h ON h.pkey = d.fkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Added JOIN (pcTransHeader) h ON h.pkey = d.fkey
11457 JOIN (pceipoCR) c ;
11458 ON h.control_pkey = C.pkey ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
11459 WHERE ((d.rng_type = 'P' OR ;
11460 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
11461 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
11462 )AND c.rngp_conv = 'R') ; && requires Range P conversion
11463 AND d.ppk_action $ 'QPBO' ;
11464 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
11465
11466 With This
11467 .cSQLTempTable=""
11468 If .GenerateSQLTempTable('__TmpCursor')
11469 If .PopulateSQLTempTable('__TmpCursor')
11470 If !Empty(.cSQLTempTable)
11471
11472 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
11473 " st.size_code " +;
11474 " FROM " + .cSQLTempTable + " t " +;
11475 " JOIN zzxscolr s " + ;
11476 " ON s.division = t.division " +;
11477 " AND s.style = t.style " + ;
11478 " AND s.color_code = t.color_code " + ;
11479 " AND s.lbl_code = t.lbl_code " + ;
11480 " AND s.dimension = t.dimension " + ;
11481 " INNER JOIN zzxstylr st " + ;
11482 " ON st.pkey = s.fkey " + ;
11483 " JOIN zzxrangh rh " + ;
11484 " ON rh.division = t.division " + ;
11485 " AND rh.rng_Style = t.style " + ;
11486 " AND rh.rng_color = t.color_Code " + ;
11487 " AND rh.rng_lbl = t.lbl_Code " + ;
11488 " AND rh.rng_pack = t.dimension "
11489
11490 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
11491
11492 If Used("_PPK_Qty")
11493 Select ("_PPK_Qty")
11494 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
11495 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
11496 "division+style+color_code+lbl_code+dimension")
11497 SELECT ("__TmpCursor")
11498
11499 If llRetVal
11500 .LogEntry("Validating Range style.")
11501 lcErrs_Msg = "No valid Range Style found"
11502 Select (pcTransDetail)
11503 SCAN FOR !EOF("_PPK_Qty")
11504
11505 If Empty(_PPK_Qty.pack_qty)
11506 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
11507 Errs_Flg_D With "Y" ;
11508 IN (pcTransDetail)
11509 Else
11510 Do Case
11511
11512 Case ppk_action = 'Q' && multiply qty
11513
11514 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11515 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11516 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
11517 In (pcTransDetail)
11518
11519 Case ppk_action = 'P' && divide price
11520
11521 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11522 org_price With org_price/_PPK_Qty.pack_qty, ;
11523 retail1 With retail1/_PPK_Qty.pack_qty, ;
11524 retail2 With retail2/_PPK_Qty.pack_qty, ;
11525 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
11526 In (pcTransDetail)
11527
11528 *- Range style price will be populated later from a_price..e_price
11529 *- not from org_price. Need to updated these prices here.
11530 IF rng_type = 'R'
11531 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11532 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11533 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11534 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11535 e_price WITH e_price/_PPK_Qty.pack_qty ;
11536 In (pcTransDetail)
11537 ENDIF
11538
11539 Case ppk_action = 'B' OR ppk_action = 'O'
11540
11541 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11542 org_price With org_price/_PPK_Qty.pack_qty, ;
11543 retail1 With retail1/_PPK_Qty.pack_qty, ;
11544 retail2 With retail2/_PPK_Qty.pack_qty, ;
11545 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11546 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
11547 In (pcTransDetail)
11548
11549 IF rng_type = 'R'
11550 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11551 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11552 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11553 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11554 e_price WITH e_price/_PPK_Qty.pack_qty ;
11555 In (pcTransDetail)
11556 ENDIF
11557
11558 Otherwise
11559 Endcase
11560 Endif
11561 Endscan
11562 Endif
11563 Set Relation To
11564 Endif
11565 Endif
11566 Endif
11567 Endif
11568
11569 Endwith
11570
11571 If Used("__TmpCursor")
11572 Use In __TmpCursor
11573 Endif
11574
11575 If Used("_PPK_Qty")
11576 Use In _PPK_Qty
11577 Endif
11578
11579 If Used("__RangeP")
11580 Use In __RangeP
11581 Endif
11582
11583 Select(lnOldSelect)
11584 Return llRetVal
11585 *============================================================
11586 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11587
11588 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11589 PROCEDURE PopulateIs860
11590 LPARAMETERS pceipoTH, pceipoCR
11591 LOCAL llRetVal, lnSelect, lcUpdate
11592
11593 llRetVal = true
11594 lnSelect = SELECT()
11595
11596 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11597
11598 *--- TR 1070268 26-Jun-2013 Goutam
11599 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11600 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11601 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11602
11603 *--- TechRec 1088575 14-Jul-2015 TSV ===
11604*!* lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11605*!* " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11606*!* " 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')))"
11607
11608 * TR 1088961 KISHORE 31-JUL-2015 Added OR (th.po_purp='01' AND (cr.template = 'BELK 4030'))
11609 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11610 " JOIN (pceipoCR) cr ON cr.pkey = th.control_pkey " + ; &&*--- TR 1101199 16-Feb-2017 Goutam. Removed Division/Style join and added control_pkey in zzeipocr
11611 " 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')) " + ;
11612 " OR (th.po_purp='01' AND (cr.template = 'BELKS 4030')))"
11613 *=== TR 1070268 26-Jun-2013 Goutam
11614
11615 &lcUpdate
11616
11617 SELECT (lnSelect)
11618 RETURN llRetVal
11619 ENDPROC
11620
11621 *============================================================
11622
11623 PROCEDURE Create860TM
11624 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
11625 LPARAMETERS pceipoTH, pceipoTD
11626 *--- TechRec 1082601 15-Dec-2014 jisingh Added loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp ===
11627 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql, loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp
11628
11629 llRetVal = true
11630 lnSelect = SELECT()
11631 lcAlias = GetUniqueFileName()
11632 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11633 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11634 lcInsertDtl = BuildInsertString("zzeipctd", "voEiPctd")
11635 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11636
11637 WITH This
11638 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11639 *IF !EMPTY(lcInsert)
11640 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11641 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11642 ORDER By h.division, h.customer INTO CURSOR tcOrders
11643
11644 .cSQLTempTable = ""
11645 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11646 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11647 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11648
11649 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11650 " FROM zzoordrh rh " + ;
11651 " JOIN " + .cSQLTempTable + " t " + ;
11652 " ON t.customer = rh.customer " + ;
11653 " AND t.division = rh.division " + ;
11654 " AND t.po_num = rh.po_num " + ;
11655 " AND t.store = rh.store " + ;
11656 " WHERE t.is860 = 'Y' "
11657
11658 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11659
11660 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11661 SELECT tcOrders
11662 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11663 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11664 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11665 SELECT (lcAlias)
11666 SCATTER NAME voEiPcth MEMO
11667
11668 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11669 .vSqlExec("SELECT * FROM zzeipctd WHERE 1 = 2", lcAlias)
11670 SELECT (lcAlias)
11671 SCATTER NAME voEiPctd MEMO
11672 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11673
11674 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11675 SELECT tcCRPkey
11676 INDEX ON customer+division TAG cudiv
11677
11678 SELECT (pceipoTH)
11679 COUNT TO lnRecNo FOR Is860 = 'Y'
11680
11681 IF .lUserInterface
11682 .AdvanceThermo(lnRecNo)
11683 ENDIF
11684
11685 SELECT (pceipoTH)
11686 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11687 *SCAN FOR Is860 = 'Y'
11688 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11689 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11690 SCATTER NAME loEiPOth MEMO
11691
11692 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11693 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11694
11695 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11696
11697 IF RECCOUNT("__tcipcth") > 0
11698 REPLACE Is860 WITH 'X' IN (pceipoTH)
11699 USE IN SELECT("__tcipcth")
11700 LOOP
11701 ENDIF
11702
11703 *--- TechRec 1082601 08-Jan-2015 jisingh ---
11704 lcPocPurp = "01"
11705 SELECT (pceipoTD)
11706 IF SEEK(loEiPOth.pkey, pceipoTD, "fkey")
11707 SCAN WHILE fkey = loEiPOth.pkey
11708 IF !EMPTY(qual_860)
11709 lcPocPurp = "04"
11710 EXIT
11711 ENDIF
11712 ENDSCAN
11713 ENDIF
11714 SELECT (pceipoTH)
11715 *=== TechRec 1082601 08-Jan-2015 jisingh ===
11716
11717 WITH voEiPcth
11718 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11719 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11720 *--- TechRec 1082601 25-Dec-2014 jisingh ---
11721 *voEiPcth.poc_purp = "01"
11722 voEiPcth.poc_purp = lcPocPurp
11723 *=== TechRec 1082601 25-Dec-2014 jisingh ===
11724 voEiPcth.customer = loEiPOth.customer
11725 voEiPcth.division = loEiPOth.division
11726 voEiPcth.doc_num = loEiPOth.doc_num
11727 voEiPcth.edi_store = loEiPOth.edi_store
11728 voEiPcth.store = loEiPOth.store
11729 voEiPcth.isa_num = loEiPOth.isa_num
11730 voEiPcth.our_id = loEiPOth.our_id
11731 voEiPcth.our_qual = loEiPOth.our_qual
11732 voEiPcth.po_num = loEiPOth.po_num
11733 voEiPcth.vnd_id = loEiPOth.vnd_id
11734 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11735 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11736 voEiPcth.po_type = loEiPOth.po_type
11737 voEiPcth.vnd_key = loEiPOth.vnd_key
11738 ENDWITH
11739
11740 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11741
11742 REPLACE Is860 WITH 'X' IN (pceipoTH)
11743
11744 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11745 IF llRetVal AND !EMPTY(lcInsertDtl) AND voEiPcth.pkey > 0
11746 lnLineSeq = 1
11747
11748 SELECT (pceipoTD)
11749 SCAN FOR fkey = loEiPOth.pkey AND !EMPTY(qual_860)
11750 SCATTER NAME loEiPOtd MEMO
11751
11752 WITH voEiPctd
11753 voEiPctd.pkey = v_NextPkey("zzeipctd")
11754 voEiPctd.line_seq = lnLineSeq
11755 voEiPctd.fkey = voEiPcth.pkey
11756 voEiPctd.qualifier = loEiPOtd.qual_860
11757 voEiPctd.upc = loEiPOtd.upc
11758 voEiPctd.sku = loEiPOtd.sku
11759 voEiPctd.aux_sku = loEiPOtd.aux_sku
11760 voEiPctd.division = loEiPOtd.division
11761 voEiPctd.style = loEiPOtd.style
11762 voEiPctd.color_code = loEiPOtd.color_code
11763 voEiPctd.lbl_code = loEiPOtd.lbl_code
11764 voEiPctd.dimension = loEiPOtd.dimension
11765 voEiPctd.size_desc = loEiPOtd.size_desc
11766 voEiPctd.sizebucket = loEiPOtd.sizebucket
11767 voEiPctd.ean = loEiPOtd.ean
11768 voEiPctd.udfoordd1c = loEiPOtd.udfoordd1c
11769 voEiPctd.udfoordd2c = loEiPOtd.udfoordd2c
11770 voEiPctd.start_date = loEiPOtd.start_date
11771 voEiPctd.end_date = loEiPOtd.end_date
11772 voEiPctd.delv_code = loEiPOtd.delv_code
11773 voEiPctd.qty_change = loEiPOtd.total_qty
11774 voEiPctd.total_qty = loEiPOtd.total_qty
11775 voEiPctd.poc_cost = loEiPOtd.price
11776 voEiPctd.poc_price = loEiPOtd.retail1
11777 voEiPctd.poc_retail2 = loEiPOtd.retail2
11778 ENDWITH
11779
11780 llRetVal = llRetVal AND .vSqlExec(lcInsertDtl)
11781 lnLineSeq = lnLineSeq + 1
11782 ENDSCAN
11783 ENDIF
11784 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11785
11786 IF .lUserInterface
11787 lnRecNo = lnRecNo + 1
11788 .AdvanceThermo(lnRecNo)
11789 ENDIF
11790 USE IN SELECT("__tcipcth")
11791 ENDSCAN
11792 ENDIF
11793 .TableClose(lcAlias)
11794 .TableClose("tcCRPkey")
11795 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11796 .TableClose("tcOrders")
11797 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11798 ENDWITH
11799
11800 RELEASE voEiPcth
11801 SELECT (lnSelect)
11802 RETURN llRetVal
11803 ENDPROC
11804 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11805
11806 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11807 PROCEDURE ValidateLocation
11808 LPARAMETERS pcHeader
11809
11810 LOCAL llRetVal, lnOldSelect
11811
11812 llRetVal= true
11813 lnOldSelect= Select()
11814
11815 SELECT Distinct Location FROM (pcHeader) ;
11816 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11817
11818 SELECT __tmpLocation
11819 WITH This
11820 .cSQLTempTable=""
11821 IF .GenerateSQLTempTable('__tmpLocation')
11822 IF .PopulateSQLTempTable('__tmpLocation')
11823 IF !EMPTY(.cSQLTempTable)
11824 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11825 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11826 llRetVal = v_SqlExec(lcSQLString, "_Location")
11827 IF llRetVal
11828 SELECT _Location
11829 INDEX On Location TAG Location
11830 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11831 IF llRetVal
11832 SELECT (pcHeader)
11833 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11834 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11835 SET RELATION TO
11836 ENDIF
11837 ENDIF
11838 ENDIF
11839 ENDIF
11840 ENDIF
11841 ENDWITH
11842
11843 IF USED("__tmpLocation")
11844 USE IN __tmpLocation
11845 ENDIF
11846 IF USED("_Location")
11847 USE IN _Location
11848 ENDIF
11849
11850 Select(lnOldSelect)
11851 Return llRetVal
11852 ENDPROC
11853 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11854
11855 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11856 PROCEDURE GetFldsList
11857 LPARAMETERS lcpceipoTH, lczzeoprth
11858
11859 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11860
11861 lnOldSelect= Select()
11862
11863 *- get common fields from both aliases
11864 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11865
11866 *- get fields from source table to validate 850 filter bros
11867 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11868
11869 *- Retrieve all 850 filter bros
11870 lcSQLString = "Select OBJID from zzxsfxrf " +;
11871 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11872
11873 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11874
11875 SELECT _Filter
11876
11877 SCAN
11878 lcFld = UPPER(TRIM(objid))
11879 *- Check filter bros and add them in required fields list if valid
11880 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11881 lcFldsList = lcFldsList + ", " + lcFld
11882 ENDIF
11883 ENDSCAN
11884
11885 *- Adding additional fields used in 850 filter string and insert sql in calling method
11886 IF NOT "IS940I" $ UPPER(lcFldsList)
11887 lcFldsList = lcFldsList + ", IS940I"
11888 ENDIF
11889
11890 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11891 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11892 ENDIF
11893
11894 IF NOT "REQ_855" $ UPPER(lcFldsList)
11895 lcFldsList = lcFldsList + ", REQ_855"
11896 ENDIF
11897
11898 IF NOT "PROC_855" $ UPPER(lcFldsList)
11899 lcFldsList = lcFldsList + ", PROC_855"
11900 ENDIF
11901
11902 IF USED("_Filter")
11903 USE IN _Filter
11904 ENDIF
11905
11906 Select(lnOldSelect)
11907
11908 Return lcFldsList
11909
11910 ENDPROC
11911 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11912
11913 *============================================================
11914
11915 *--- TechRec 1082601 24-Dec-2014 jisingh ---
11916 PROCEDURE Validate860Qual
11917 LPARAMETERS pcHeader, pcDetail
11918 LOCAL llRetVal, lnSelect
11919
11920 lnSelect = SELECT()
11921 llRetVal = .SetRelation(pcHeader, "pkey", pcDetail, "fkey")
11922
11923 REPLACE ALL errs_msg_d WITH errs_msg_d + "Item has 860 change code (" + ALLTRIM(qual_860) + ")" + CRLF, ;
11924 errs_flg_d WITH "Y" FOR !EMPTY(qual_860) AND &pcHeader..po_purp = "05" IN (pcDetail)
11925 SET RELATION TO
11926
11927 SELECT (lnSelect)
11928 RETURN llRetVal
11929 ENDPROC
11930 *=== TechRec 1082601 24-Dec-2014 jisingh ===
11931
11932 *- TR 1089110 FH
11933 PROCEDURE ValidateZeroQty
11934 LPARAMETERS pceipoTD
11935
11936 LOCAL llRetVal, lnOldSelect
11937 lnOldSelect = SELECT()
11938 llRetVal = .t.
11939
11940 UPDATE td SET Errs_flg_d = 'Y', Errs_msg_d = Errs_msg_d + 'Item has 0 Quantity' + CRLF ;
11941 FROM (pceipoTD) td WHERE total_qty = 0
11942
11943 Select(lnOldSelect)
11944 Return llRetVal
11945 ENDPROC
11946 *- TR 1089110 FH
11947
11948*============================================================
11949 *--- TR 1090280 3-Oct-2015 Goutam
11950 FUNCTION ValidateImplosionType
11951 LPARAMETERS tceipoTH, tceipoTD, tceipoCR
11952 LOCAL llRetVal, lnSelect
11953
11954 llRetVal = true
11955 lnSelect = SELECT()
11956
11957 WITH This
11958
11959 *--- TR 1101199 16-Feb-2017 Goutam
11960 *llRetVal= llRetVal And .SetRelation(tceipoCR, "divcust", tceipoTH, "division + customer")
11961 llRetVal= llRetVal And .SetRelation(tceipoCR, "pkey", tceipoTH, "control_pkey")
11962 *=== TR 1101199 16-Feb-2017 Goutam
11963
11964 IF llRetVal
11965 Replace Errs_msg_H With Errs_msg_H + "Empty implosion bulk for implosion flag B." +CRLF ,;
11966 Errs_flg_h With "Y" FOR &pceipoCR..impl_ok = 'B' AND EMPTY(impl_bulk) In (pceipoTH)
11967 Set Relation To
11968 ENDIF
11969
11970 llRetVal = llRetVal And .SetRelation(tceipoTH, "pkey", tceipoTD, "fkey")
11971 IF llRetVal
11972 Replace Errs_msg_D With Errs_msg_D + "Empty implosion bulk in header for implosion flag B." +CRLF ,;
11973 Errs_flg_d With "Y" FOR 'Empty implosion bulk for implosion flag B' $ &tceipoTH..Errs_msg_H In (pceipoTD)
11974 Set Relation To
11975 ENDIF
11976
11977 ENDWITH
11978
11979 SELECT (lnSelect)
11980 RETURN llRetVal
11981 ENDFUNC
11982 *=== TR 1090280 3-Oct-2015 Goutam
11983
11984 *--- TR 1098918 26-Sep-2016 HGORE ---
11985 PROCEDURE UpdateReq_855ForAllocation
11986 LPARAMETERS pcHeader
11987
11988 LOCAL llRetVal, lnOldSelect
11989
11990 llRetVal= true
11991 lnOldSelect= Select()
11992
11993 SELECT DISTINCT Customer, Division FROM (pcHeader) ;
11994 WHERE NOT EMPTY(Customer) AND NOT EMPTY(Division) INTO CURSOR __tmpCustDivn
11995
11996 SELECT __tmpCustDivn
11997 WITH This
11998 .cSQLTempTable=""
11999 IF .GenerateSQLTempTable('__tmpCustDivn')
12000 IF .PopulateSQLTempTable('__tmpCustDivn')
12001 IF !EMPTY(.cSQLTempTable)
12002 lcSQLString= "SELECT c.Customer, c.Division FROM zzeoprcr c, " + .cSQLTempTable + " t " +;
12003 "WHERE c.Customer = t.Customer AND c.Division = t.Division "+;
12004 " AND c.Use_Allocation = 'Y' "
12005 llRetVal = v_SqlExec(lcSQLString, "_CustDivn")
12006 IF llRetVal
12007 SELECT _CustDivn
12008 INDEX On Customer + Division TAG CustDivn
12009 llRetVal= .SetRelation("_CustDivn", "CustDivn", pcHeader, "Customer+Division")
12010 IF llRetVal
12011 SELECT (pcHeader)
12012 REPLACE req_855 WITH 'A' FOR req_855 = 'R' AND customer = _CustDivn.Customer AND Division = _CustDivn.Division
12013 SET RELATION TO
12014 ENDIF
12015 ENDIF
12016 ENDIF
12017 ENDIF
12018 ENDIF
12019 ENDWITH
12020
12021 .TableClose("__tmpCustDivn")
12022 .TableClose("_CustDivn")
12023
12024 Select(lnOldSelect)
12025 Return llRetVal
12026
12027 ENDPROC
12028 *
12029 *--------------------------------------------------------------
12030 * 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.
12031 PROCEDURE ResetReq_855
12032 LPARAMETERS pcHeader
12033
12034 LOCAL llRetVal, lnOldSelect
12035
12036 llRetVal= true
12037 lnOldSelect= Select()
12038
12039 SELECT (pcHeader)
12040 REPLACE req_855 WITH 'R' FOR req_855 = 'A' IN (pcHeader)
12041
12042 Select(lnOldSelect)
12043 Return llRetVal
12044
12045 ENDPROC
12046 *=== TR 1098918 26-Sep-2016 HGORE ===
12047 *
12048
12049*============================================================
12050 *--- TR 1101199 6-Feb-2017 Goutam
12051 FUNCTION CheckCustGroup
12052 LPARAMETERS pcHeader, pceipoCR
12053 LOCAL llRetVal, lnSelect
12054
12055 llRetVal = true
12056 lnSelect = SELECT()
12057
12058 WITH This
12059
12060 llRetVal = llRetVal And .ValidateCustGroup(pcHeader, pceipoCR)
12061 llRetVal = llRetVal And .PopulateCustGroup(pcHeader)
12062
12063 ENDWITH
12064
12065 SELECT (lnSelect)
12066 RETURN llRetVal
12067 ENDFUNC
12068
12069*============================================================
12070 FUNCTION ValidateCustGroup
12071 LPARAMETERS pcHeader, pceipoCR
12072 LOCAL llRetVal, lnSelect, lcErrs_Msg, lcSql
12073
12074 llRetVal = true
12075 lnSelect = SELECT()
12076
12077
12078 WITH This
12079
12080 *If cust_group is populated that reference should be available in 850 control table.
12081 UPDATE h SET h.Errs_msg_H = h.Errs_msg_H + 'Customer group ' + ALLTRIM(h.cust_group) + ' not found in 850 control table' + CRLF ;
12082 ,h.Errs_flg_h = "Y" from (pcHeader) h left join (pceipoCR) c on c.cust_group = h.cust_group ;
12083 WHERE h.cust_group > '' AND NVL(c.pkey, 0) = 0
12084
12085 *If CUST_GROUP is populated, then field CUSTOMER must be populated.
12086 Replace Errs_msg_H With Errs_msg_H + 'Missing customer code for Customer Group ' + ALLTRIM(cust_group) + CRLF, Errs_flg_h With "Y" ;
12087 FOR EMPTY(customer) AND !EMPTY(cust_group) IN (pcHeader)
12088
12089 *If the Customer is already a part of another Customer Group - error out the order with the message
12090 SELECT customer, cust_group FROM (pcHeader) WHERE Errs_flg_h <> 'Y' AND customer > '' and cust_group > '' GROUP BY customer, cust_group INTO CURSOR __tmpcustgroup
12091 SELECT customer FROM __tmpcustgroup GROUP BY customer HAVING COUNT(customer) > 1 INTO CURSOR __tmpcustomer
12092
12093 IF RECCOUNT('__tmpcustomer') > 0
12094 SELECT __tmpcustomer
12095 INDEX on customer TAG customer
12096 llRetVal = llRetVal And .SetRelation("__tmpcustomer", "customer", pcHeader, "customer")
12097 IF llRetVal
12098 SELECT (pcHeader)
12099 Replace Errs_msg_H With Errs_msg_H + 'Cannot add Customer ' + ALLTRIM(customer) + ' to Customer Group ' + ALLTRIM(cust_group) +;
12100 '. He already exists in Customer Group ' + ALLTRIM(cust_group) + CRLF, Errs_flg_h With "Y" FOR !EOF('__tmpcustomer') IN (pcHeader)
12101 SET RELATION TO
12102 ENDIF
12103 ENDIF
12104
12105 USE IN SELECT("__tmpcustgroup")
12106
12107 SELECT customer, cust_group FROM (pcHeader) WHERE Errs_flg_h <> 'Y' AND customer > '' and cust_group > '' GROUP BY customer, cust_group INTO CURSOR __tmpcustgroup
12108 .cSQLTempTable=""
12109 IF .GenerateSQLTempTable('__tmpcustgroup') AND .PopulateSQLTempTable('__tmpcustgroup') AND !Empty(.cSQLTempTable)
12110 USE IN SELECT("__tmpcustgroup")
12111 lcSql = "Select distinct tmp.customer, tmp.cust_group TH_cust_group, gd.cust_group " + ;
12112 " From " + .cSQLTempTable + " tmp join zzxcstgd gd on gd.customer = tmp.customer"
12113 llRetVal = llRetVal And v_SqlExec(lcSql, "__tmpcustgroup")
12114
12115 SELECT __tmpcustgroup
12116 INDEX on customer + th_cust_group TAG cust_group
12117 llRetVal = llRetVal And .SetRelation("__tmpcustgroup", "cust_group", pcHeader, "customer + cust_group")
12118 IF llRetVal
12119 SELECT (pcHeader)
12120 Replace Errs_msg_H With Errs_msg_H + 'Cannot add Customer ' + ALLTRIM(customer) + ' to Customer Group ' + ALLTRIM(cust_group) +;
12121 '. He already exists in Customer Group ' + ALLTRIM(__tmpcustgroup.cust_group) + CHR(10)+CHR(14), Errs_flg_h With "Y" ;
12122 FOR (__tmpcustgroup.th_cust_group <> __tmpcustgroup.cust_group) AND !EOF('__tmpcustgroup') IN (pcHeader)
12123 SET RELATION TO
12124 ENDIF
12125
12126 ENDIF
12127 USE IN SELECT("__tmpcustgroup")
12128 USE IN SELECT("__tmpcustomer")
12129 ENDWITH
12130
12131 SELECT (lnSelect)
12132 RETURN llRetVal
12133 ENDFUNC
12134
12135*============================================================
12136
12137 FUNCTION PopulateCustGroup
12138 LPARAMETERS pcHeader
12139 LOCAL llRetVal, lnSelect, lcCustgrpcurs, lcCustcurs, lcSql, lcCustGroupHSql, lcCustGroupDSql, llBeganTransaction
12140
12141 llRetVal = true
12142 lnSelect = SELECT()
12143
12144 lcCustgrpcurs = "#CusGroup" + SYS(2015)
12145 lcCustcurs = "#Customer" + SYS(2015)
12146
12147 WITH This
12148 *If the field CUSTOMER contains a valid BlueCherry customer code, and the customer group reference with customer group CUST_GROUP
12149 *does not exist, then create new customer group reference. Then add the customer code from field CUSTOMER to the new customer group reference.
12150
12151 *If the field CUSTOMER contains a valid BlueCherry customer code, and the customer group reference with customer group code from the
12152 *CUST_GROUP already exists, then check to see if the customer group reference has the customer code already added to the customer group.
12153 *If not, then add the customer code to the customer group.
12154
12155 SELECT customer, cust_group FROM (pcHeader) WHERE Errs_flg_h <> 'Y' AND customer > '' and cust_group > '' GROUP BY customer, cust_group INTO CURSOR __tmpcustgroup
12156 .cSQLTempTable=""
12157 IF (RECCOUNT('__tmpcustgroup') > 0) AND .GenerateSQLTempTable('__tmpcustgroup') AND .PopulateSQLTempTable('__tmpcustgroup') AND !Empty(.cSQLTempTable)
12158 USE IN SELECT("__tmpcustgroup")
12159
12160 lcSql = "Select distinct tmp.cust_group into " + lcCustgrpcurs + ;
12161 " From " + .cSQLTempTable + " tmp where not exists(select 1 from zzxcstgh where cust_group = tmp.cust_group)"
12162 llRetVal = llRetVal And v_SqlExec(lcSql)
12163
12164 lcCustGroupHSql = .CreateCustGroupH(lcCustgrpcurs)
12165
12166 llRetVal = llRetVal And !EMPTY(lcCustGroupHSql)
12167
12168 lcSql = "Select tmp.customer, tmp.cust_group into " + lcCustcurs + ;
12169 " From " + .cSQLTempTable + " tmp where not exists(select 1 from zzxcstgd where customer = tmp.customer and cust_group = tmp.cust_group)"
12170 llRetVal = llRetVal And v_SqlExec(lcSql)
12171
12172 lcCustGroupDSql = .CreateCustGroupD(lcCustcurs)
12173
12174 llRetVal = llRetVal And !EMPTY(lcCustGroupDSql)
12175
12176 IF llRetVal
12177 *-- Transaction start
12178 llBeganTransaction = llRetval AND .BeginTransaction()
12179
12180 llRetVal = llRetVal And v_SqlExec(lcCustGroupHSql)
12181 llRetVal = llRetVal And v_SqlExec(lcCustGroupDSql)
12182
12183 IF llBeganTransaction
12184 IF llRetval
12185 .EndTransaction()
12186 ELSE
12187 .RollBackTransaction()
12188 ENDIF
12189 ENDIF
12190 ENDIF
12191
12192 ENDIF
12193
12194 .DropSQLTempTable(lcCustgrpcurs)
12195 .DropSQLTempTable(lcCustcurs)
12196 ENDWITH
12197
12198 SELECT (lnSelect)
12199 RETURN llRetVal
12200 ENDFUNC
12201
12202*============================================================
12203
12204 FUNCTION CreateCustGroupD
12205 LPARAMETERS tcCustcurs
12206 LOCAL llRetVal, lnSelect, lcRetVal
12207
12208 llRetVal = true
12209 lnSelect = SELECT()
12210 lcRetVal = ""
12211
12212 WITH This.oGenStr
12213 this.oLog.LogEntry(" - Generate SQL query to post data to zzxcstgd.")
12214 .SB_Reset()
12215 .cSB_Target = "zzxcstgd"
12216 .cSB_Source = tcCustcurs
12217 .cSB_SourceAlias = "t"
12218 .cSB_WhereString = " NOT EXISTS(SELECT 1 FROM zzxcstgd WHERE customer = t.customer and cust_group = t.cust_group)"
12219 .cSB_FROMExpandedString = "JOIN zzxcstgh gh on gh.cust_group = t.cust_group"
12220
12221 .SB_SetLiteralFieldValue("last_mod",SQLFormatTS(DATETIME()))
12222 .SB_SetLiteralFieldValue("user_id",SQLFormatChar(goEnv.envLogin.cUserName))
12223 .SB_SetLiteralFieldValue("fkey", "gh.pkey")
12224
12225 .SB_KeySetAddKeySpec("pkey","Char(14)","t.cust_group+t.customer")
12226
12227 llRetVal = llRetVal AND .SB_GenerateSQLInsertString()
12228 IF llRetVal
12229 lcRetVal = .cSQLString
12230 ENDIF
12231 ENDWITH
12232
12233 SELECT (lnSelect)
12234 RETURN lcRetVal
12235 ENDFUNC
12236
12237*============================================================
12238
12239 FUNCTION CreateCustGroupH
12240 LPARAMETERS tcCustgrpcurs
12241 LOCAL llRetVal, lnSelect, lcRetVal
12242
12243 llRetVal = true
12244 lnSelect = SELECT()
12245 lcRetVal = ""
12246
12247 WITH This.oGenStr
12248 this.oLog.LogEntry(" - Generate SQL query to post data to zzxcstgh.")
12249 .SB_Reset()
12250 .cSB_Target = "zzxcstgh"
12251 .cSB_Source = tcCustgrpcurs
12252 .cSB_SourceAlias = "t"
12253 .cSB_WhereString = " NOT EXISTS(SELECT 1 FROM zzxcstgh WHERE cust_group = t.cust_group)"
12254
12255 .SB_SetLiteralFieldValue("group_desc", "t.cust_group")
12256 .SB_SetLiteralFieldValue("last_mod",SQLFormatTS(DATETIME()))
12257 .SB_SetLiteralFieldValue("user_id",SQLFormatChar(goEnv.envLogin.cUserName))
12258
12259 .SB_KeySetAddKeySpec("pkey","Char(7)","t.cust_group")
12260
12261 llRetVal = llRetVal AND .SB_GenerateSQLInsertString()
12262 IF llRetVal
12263 lcRetVal = .cSQLString
12264 ENDIF
12265 ENDWITH
12266
12267 SELECT (lnSelect)
12268 RETURN lcRetVal
12269 ENDFUNC
12270
12271*============================================================
12272
12273 FUNCTION PopulateControlpkey
12274 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
12275 LOCAL llRetVal, lnSelect
12276
12277 llRetVal = true
12278 lnSelect = SELECT()
12279
12280 WITH This
12281 .LogEntry("Resolving header division based on customer group.")
12282
12283 SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, c.pkey as control_pkey, h.cust_group, ;
12284 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
12285 FROM (pceipoTH) h ;
12286 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
12287 JOIN (pceipoCR) c ON c.cust_group = h.cust_group ;
12288 ORDER BY d.fkey, c.cust_group, c.division ;
12289 WHERE !EMPTY(d.division) AND !EMPTY(h.cust_group) INTO CURSOR tmpCurs
12290
12291 Select tmpCurs
12292 If This.lUserInterface
12293 * Init Thermometer
12294 This.InitThermo(Reccount('tmpCurs'))
12295 l_nThermoCnt = 0
12296 ENDIF
12297
12298 Scan
12299 If This.lUserInterface
12300 * Advance progress bar, if we're using one.
12301 l_nThermoCnt = l_nThermoCnt + 1
12302 This.AdvanceThermo(l_nThermoCnt)
12303 Endif
12304 Select (pceipoTH)
12305
12306 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
12307
12308 SELECT tmpCurs
12309 lnFkey = fkey
12310 lccust_group = cust_group
12311 LOCATE FOR ctrl_division = division WHILE fkey = lnFkey AND cust_group = lccust_group
12312 llDivfound = FOUND()
12313 IF !llDivfound
12314 skip-1
12315 ENDIF
12316 Select (pceipoTH)
12317
12318 IF !llDivfound AND tmpCurs.validate_division = "Y" AND tmpCurs.ctrl_division <> tmpCurs.division
12319 REPLACE errs_msg_h WITH errs_msg_h + ;
12320 "Mismatch between division(" + ALLTRIM(tmpCurs.ctrl_division) + ;
12321 ") and resolved UPC/SKU division(" + ALLTRIM(tmpCurs.division) + ")." + CRLF,;
12322 errs_flg_h WITH "Y" IN (pceipoTH)
12323 ELSE
12324 Replace division With tmpCurs.division, control_pkey WITH tmpCurs.control_pkey In (pceipoTH)
12325 ENDIF
12326
12327 IF llDivfound
12328 SELECT tmpCurs
12329 LOCATE FOR cust_group <> lccust_group WHILE fkey = lnFkey
12330 IF !FOUND()
12331 skip-1
12332 ENDIF
12333 ENDIF
12334 Endif
12335 Endscan
12336 Use In tmpCurs
12337
12338 ENDWITH
12339
12340 SELECT (lnSelect)
12341 RETURN llRetVal
12342 ENDFUNC
12343
12344 *=== TR 1101199 6-Feb-2017 Goutam
12345
12346*============================================================
12347 *--- TR 1103895 13-JUN-2017 HGORE ---
12348 FUNCTION ValidateCustomerSpecificCharges
12349 PARAMETERS tcEipoTH, tcEiPOTR, tcEiPOCR
12350
12351 Local lnSelect, lcChrg_Type, lnFKey, lcErrorMsgType, lcErrorMsgFlag, lcErrorMsgInactive, lcDtlError, lcHdrError, ;
12352 lcDivision, lcCustomer, lnxFKey, lnDefaultKey, lcSeason, lcSql, llRetVal, Cust_chrg_type, lnzzxchrgd_pkey
12353
12354 lnSelect = SELECT()
12355
12356 llRetVal = true
12357 lcErrorMsgType = "Invalid Header Charge Type."
12358 lcErrorMsgFlag = "Invalid Header Charge Flag."
12359 lcErrorMsgInactive = "Inactive Charge Used in Header."
12360 lcDtlError = "Has errors in Header Charges."
12361 lcHdrError = ""
12362
12363 LOCAL lntcEipoTHrec, lcStore, lcCenter_Code
12364 SELECT (tcEipoTH)
12365 lntcEipoTHrec = RECNO()
12366
12367 * Existing BC Charge cursor(s)
12368 *
12369 lcSql = ;
12370 "select t.chrg_type"+;
12371 " , t.chrg_flag"+;
12372 " , r.chrg_hdrdtl "+;
12373 " from zzeipotr t"+;
12374 " join zzxchrtr r "+;
12375 " on r.chrg_type = t.chrg_type "+;
12376 " where t.charge_tag = 'CHGH'"
12377 llRetVal = llRetVal and v_sqlExec(lcSql, "__ChrgType")
12378
12379 SELECT __ChrgType
12380 INDEX on chrg_type TAG chrg_type
12381
12382 lcSql = ;
12383 "select d.pkey, d.FKey"+;
12384 " , d.Chrg_Type"+;
12385 " , d.Chrg_Flag"+;
12386 " , d.Active_Ok"+;
12387 " , d.excl_misc_inv"+;
12388 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.chrg_amt, d.percentage,d.round_to"+;
12389 " from zzxChrgD d"+;
12390 " join zzxChrTR t"+;
12391 " on t.Chrg_Type = d.Chrg_Type"+;
12392 " where t.Chrg_HdrDtl = 'H' and exists(select 1 from zzeipotr where chrg_type = t.chrg_type and charge_tag = 'CHGH')"
12393
12394 llRetVal = llRetVal and v_sqlExec(lcSql, "qChrgD")
12395
12396 Select qChrgD
12397 Index On Str(fkey) + Chrg_Type Tag FKey_Chrg
12398
12399 lcSql = ;
12400 "select Customer"+;
12401 " , Division"+;
12402 " , Store"+;
12403 " , Center_Code"+;
12404 " , Season"+;
12405 " , PKey"+;
12406 " , Rank_Seq"+;
12407 " from zzxchrgh"
12408
12409 llRetVal = llRetVal and v_sqlExec(lcSql, "qChrgH")
12410 Select qChrgH
12411 Index On division+customer+Store+Center_Code+Season Tag divcust
12412 If division = ' ' And customer = ' '
12413 lnDefaultKey = pkey
12414 ENDIF
12415
12416 * X-Ref cursor(s)
12417 *
12418 lcSql = ;
12419 "select distinct xD.FKey"+;
12420 " , xD.Chrg_Type"+;
12421 " , coalesce(d.chrg_type, '') as chrg_type_ref"+;
12422 " , coalesce(d.Chrg_Flag, '') as Chrg_Flag"+;
12423 " , coalesce(d.Active_Ok, 'Y') as Active_Ok"+;
12424 " , coalesce(d.Chrg_Cost, 0) as Chrg_Cost"+;
12425 " , xD.cust_chrg_formula as chrg_formula"+;
12426 " , cast(coalesce(d.chrg_expr, '') as varchar(1000)) as chrg_expr"+;
12427 " , coalesce(d.percentage, 0) as percentage"+;
12428 " , coalesce(d.round_to, 0) as round_to"+;
12429 " , xd.Cust_chrg_type "+;
12430 " from zzxchgxD xD"+;
12431 " join zzxChrTR t "+;
12432 " on t.Chrg_Type = xD.Chrg_Type"+;
12433 " join zzxchgxH xH "+;
12434 " on xD.fkey = xH.pkey "+;
12435 " left join zzxChrgD d "+;
12436 " on d.chrg_type = t.chrg_type "+;
12437 " and d.customer = xh.customer and (d.division = xh.division or xh.division = '') "+;
12438 " where t.Chrg_HdrDtl = 'H' "+;
12439 " and exists( "+;
12440 " select 1 "+;
12441 " from zzeipotr "+;
12442 " where chrg_type = t.chrg_type "+;
12443 " and charge_tag = 'CHGH')"
12444
12445 llRetVal = llRetVal and v_sqlExec(lcSql, "xChrgD")
12446 SELECT xChrgD
12447 INDEX ON Str(fkey) + Chrg_Type Tag xChrgD
12448 INDEX ON Str(fkey) + Chrg_Type + Cust_chrg_type Tag xCstChrg
12449
12450 lcSql = ;
12451 " SELECT Customer"+;
12452 " , Division"+;
12453 " , PKey"+;
12454 " from zzxchgxH"
12455
12456 llRetVal = llRetVal and v_sqlExec(lcSql, "xChrgH")
12457 SELECT xChrgH
12458 INDEX ON division+customer TAG xChrgH
12459
12460 * Filtering records applicable for CHGH template where chrg_code will not empty & it will import from ff.
12461 *
12462
12463 SELECT (tcEiPOTR)
12464 GO TOP
12465 IF NOT EOF()
12466 .SetRelation(tcEiPOtH, "PKey", tcEiPOTR, "FKey")
12467 SCAN FOR charge_tag = 'CHGH'
12468 lcChrg_Type = Chrg_type
12469 lcCust_chrg_type = ext_chrg_code
12470 lnzzxchrgd_pkey = 0
12471
12472 * Initializing values from Control cursor
12473 SELECT (tcEiPOCR)
12474 lcProcess_Charges = 'N'
12475 IF Seek(&tcEiPOtH..Control_Pkey, tceIPOcr, "pkey")
12476 lcProcess_Charges = &tcEiPOCR..Process_Charges
12477 ENDIF
12478 IF lcProcess_Charges = 'N'
12479 Replace Errs_Flg_R With "X" IN (tcEiPOTR)
12480 LOOP
12481 ENDIF
12482
12483 IF !SEEK(lcChrg_Type, "__ChrgType", "Chrg_type")
12484 lcHdrError = "Invalid Charge Type [" + ALLTRIM(lcChrg_Type) + "] in header"
12485 IF EMPTY(lcChrg_Type)
12486 lcHdrError = "Empty Charge Type in header"
12487 ENDIF
12488 Replace Errs_Msg_H With Errs_Msg_H + lcHdrError + CRLF, ;
12489 Errs_Flg_H With 'Y' IN (tcEiPOTH)
12490 LOOP
12491 ENDIF
12492
12493 lnFKey = 0
12494 lnxFKey = 0
12495 * Initializing values from Header cursor.
12496 SELECT (tcEiPOtH)
12497 lcDivision = division
12498 lcCustomer = customer
12499
12500 lcCenter_Code = center_Code
12501 lcStore = Store
12502 lcSeason = Season
12503
12504 * BC existing validations for Control Setup = 'R' - Restricted
12505 *
12506 SELECT (tcEiPOTR)
12507 IF INLIST(lcProcess_Charges, 'Y', 'R')
12508 Select qChrgH
12509 Do Case
12510 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
12511 lnFKey = pkey
12512
12513 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
12514 lnFKey = pkey
12515
12516 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
12517 lnFKey = pkey
12518
12519 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
12520 lnFKey = pkey
12521
12522 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
12523 lnFKey = pkey
12524
12525 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
12526 lnFKey = pkey
12527
12528 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
12529 lnFKey = pkey
12530
12531 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
12532 lnFKey = pkey
12533
12534 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
12535 lnFKey = pkey
12536
12537 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
12538 lnFKey = pkey
12539
12540 Otherwise
12541 lnFKey = lnDefaultKey
12542 ENDCASE
12543 SELECT tceipotr
12544
12545 IF lnFKey = 0
12546 lcHdrError = "No Charges set up for " + Trim(lcDivision)+'/'+Trim(lcCustomer)
12547 Replace Errs_Flg_R With "Y", Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12548 ELSE
12549 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD", "FKey_Chrg")
12550 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
12551 lnzzxchrgd_pkey = qChrgD.pkey
12552 IF lcProcess_Charges = 'R'
12553 *--- Check if the Charge still active:
12554 If qChrgD.Active_Ok # 'Y'
12555 lcHdrError = lcErrorMsgInactive
12556 Replace Errs_Flg_R With "Y",;
12557 Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12558 Endif
12559
12560 If Empty(Chrg_Flag)
12561 *-- Set Charge Type from Resolution if success
12562 If Errs_Flg_R # "Y"
12563 Replace Chrg_Flag With lcResolved_Chrg_Flag
12564 Endif
12565 Else
12566 If Chrg_Flag # lcResolved_Chrg_Flag
12567 lcHdrError = lcErrorMsgFlag
12568 Replace Errs_Flg_R With "Y",;
12569 Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12570 Endif
12571 ENDIF
12572 ENDIF
12573 ELSE
12574 IF lcProcess_Charges = 'R'
12575 lcHdrError = lcErrorMsgType
12576 Replace Errs_Flg_R With "Y", Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12577 lnFKey = fkey
12578 lcResolved_Chrg_Flag = ""
12579 ENDIF
12580 ENDIF
12581 ENDIF
12582 ENDIF
12583
12584 * X-Ref table validation
12585
12586 SELECT (tcEiPOTR)
12587 IF INLIST(lcProcess_Charges,'Y','R') AND Errs_Flg_R <> "Y"
12588 SELECT xChrgH
12589 DO CASE
12590 CASE SEEK(lcDivision+lcCustomer)
12591 lnxFKey = pkey
12592 CASE SEEK(' '+lcCustomer)
12593 lnxFKey = pkey
12594 OTHERWISE
12595 lnxFKey = 0
12596 ENDCASE
12597
12598 SELECT (tcEiPOTR)
12599 IF lnxFKey = 0
12600 lcHdrError = "No Charges set up in X-Ref for Division/Customer - " + Trim(lcDivision)+'/'+Trim(lcCustomer)
12601 Replace Errs_Flg_R With "Y", Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12602 ELSE
12603 llRefCharge = Seek(Str(lnxFKey) + lcChrg_Type, "xChrgD", "xChrgD")
12604 *llXRefCharge = Seek(Str(lnxFKey) + lcChrg_Type + lcCust_chrg_type, "xChrgD")
12605 llXRefCharge = llRefCharge and !EMPTY(lcCust_chrg_type)
12606
12607 IF llXRefCharge &&AND (lcProcess_Charges = 'Y' OR (lcProcess_Charges = 'R' AND llRefCharge))
12608
12609 lcResolved_Chrg_Flag = xChrgD.Chrg_Flag
12610
12611 *--- Check if the Charge still active:
12612 lcHdrError = lcErrorMsgInactive
12613 If xChrgD.Active_Ok # 'Y'
12614 Replace Errs_Flg_R With "Y",;
12615 Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12616 Endif
12617
12618 If Empty(Chrg_Flag)
12619 *-- Set Charge Type from Resolution if success
12620 If Errs_Flg_R # "Y"
12621 Replace Chrg_Flag With lcResolved_Chrg_Flag
12622 Endif
12623 Else
12624 If Chrg_Flag # lcResolved_Chrg_Flag AND !(lcProcess_Charges = 'Y')
12625 lcHdrError = lcErrorMsgFlag + " '" + Chrg_Flag + "'"
12626 Replace Errs_Flg_R With "Y",;
12627 Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12628 Endif
12629 Endif
12630
12631 *--- Check amount or percentage with setup based on Chrg_Flag.
12632 If lcProcess_Charges = 'R' AND IIF(Chrg_Flag = 'P', percentage <> qChrgD.percentage, chrg_amt <> qChrgD.chrg_amt )
12633 lcHdrError = "The header inbound Charge amount/percentage is not matching with setup where control setup set as 'Restricted'."
12634 Replace Errs_Flg_R With "Y",;
12635 Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12636 ENDIF
12637 ELSE
12638 lcHdrError = "The header inbound charge code ("+ ALLTRIM(lcChrg_Type) +") is not setup in the customer x-ref for that customer ("+ALLTRIM(lcCustomer)+")"
12639 Replace Errs_Flg_R With "Y", Errs_Msg_R With Errs_Msg_R + lcHdrError + CRLF
12640 lnxFKey = fkey
12641 lcResolved_Chrg_Flag = ""
12642 ENDIF
12643 ENDIF
12644 ENDIF
12645
12646 IF lcProcess_Charges = 'N' && Ignoring, if N (No). Replacing 'X' to remove those records after endscan in this procedure.
12647 Replace Errs_Flg_R With "X"
12648 ENDIF
12649
12650 SELECT (tcEiPOTR)
12651 DO CASE
12652 CASE Errs_Flg_R = "Y"
12653 Select(tcEiPOtH)
12654 If !lcHdrError$Errs_Msg_H
12655 Replace Errs_Msg_H With Errs_Msg_H + lcHdrError + CRLF, ;
12656 Errs_Flg_H With 'Y'
12657 Endif
12658
12659 CASE Errs_Flg_R = "X"
12660 * Nothing to do here. Replaced 'X' to remove those records after endscan in this procedure.
12661
12662 OTHERWISE
12663
12664 Replace Chrg_Cost With qChrgD.Chrg_Cost ;
12665 , chrg_formula WITH IIF((lcProcess_Charges = 'Y') AND (chrg_flag = 'P'), xChrgD.chrg_formula, qChrgD.chrg_formula) ;
12666 , round_to WITH IIF((lcProcess_Charges = 'Y'), 0, qChrgD.round_to) ;
12667 , percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt, percentage)) ;
12668 , chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt) ;
12669 , zzxchrgd_pkey WITH lnzzxchrgd_pkey IN tceipotr
12670
12671 ENDCASE
12672 ENDSCAN
12673
12674 SELECT (tcEiPOTR)
12675 DELETE FOR Errs_Flg_R = "X"
12676 GO TOP
12677 ENDIF
12678
12679 SET FILTER TO
12680 Set Relation To
12681 Use In Select("__ChrgType")
12682 Use In Select("qChrgH")
12683 Use In Select("qChrgD")
12684 Use In Select("xChrgH")
12685 Use In Select("xChrgD")
12686 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
12687 GO lntcEipoTHrec IN (tcEipoTH)
12688 ENDIF
12689
12690 SELECT (lnSelect)
12691 RETURN llRetVal
12692 ENDFUNC
12693 *=== TR 1103895 13-JUN-2017 HGORE ===
12694
12695*============================================================
12696
12697 *-FH 1110216
12698 *- For Details with is_upcsku = 'C' which was set in checkupc because we found upc in customer style.
12699 *- What if SKU and UPC is the same value, in this case we don't want to do is_upcsku, lets clear it out if UPC mathces SKU and UPC was found in customer style.
12700 FUNCTION ResolveIsUpcSku
12701 LPARAMETERS pceipoTD
12702 LOCAL llRetVal, lnSelect
12703
12704 llRetVal = true
12705 lnSelect = SELECT()
12706
12707 Replace ALL is_upcsku with '' FOR is_upcsku = 'C' AND ALLTRIM(UPC) = ALLTRIM(SKU) In (pceipoTD)
12708
12709 SELECT (lnSelect)
12710 RETURN llRetVal
12711 ENDFUNC
12712
12713
12714Enddefine