· 7 years ago · Oct 01, 2018, 07:58 PM
1**********************************************************************************************
2* Program....: clsIpopr_PreValidation.PRG
3* Author.....: Nasim Huq
4* Date.......: Nov, 2008
5* Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
6* Techreq....: 1032800
7* Abstract...: EDI 850 inbound Pre-Validation
8* Changes....:
9***********************************************************************************************
10
11#include edi.h
12#include system.h
13
14#Define LARGEST_DATE {^2999-01-01}
15#Define EDI_NOT_PROCESSORIGINAL_MSG "Control Flag set to Not Process Original EDI orders into Live Table."
16#Define EDI_NOT_PROCESSCONFIRM_MSG "Control Flag set to Not Process Confirm EDI orders into Live Table."
17#Define EDI_NOT_PROCESSDUPLICATE_MSG "Control Flag set to Not Process Duplicate EDI orders into Live Table."
18#Define NOT_YET_PROCESS "Not yet process."
19#Define NO_UOM_CONVERSION_REF "Require Style UOM."
20#Define UOM_NOT_DIVISIBLE "Total Units must be divisible by "
21#Define NO_UOM_CONVERSION_FACTOR "No conversion factor."
22#Define NO_PREPACK "Unable to determine Prepack code." && 30854 3/25/02
23
24#Define EDI_BULK_ORDER "BK"
25#Define EDI_BLANKET_ORDER "BL"
26*- 1002007 11/13/03 YIK
27#Define EDI_DISCOUNT_CODE "EDI"
28
29
30Define Class clsIpopr_PreValidation As clsIpopr_delegatebase
31
32 oResolvePrepack = Null
33
34 *--- TR 1045965 09-MAR-2010 HNISAR
35 lFrom940i = False
36 *=== TR 1045965 09-MAR-2010 HNISAR
37
38 *--- TechRec 1030517 25-Aug-2010 jisingh ---
39 c850Control = ""
40 *=== TechRec 1030517 25-Aug-2010 jisingh ===
41
42 cImplodeSQL = ""
43 cImplodeRangeSQL = "" &&--- TechRec 1073664 20-Sep-2013 GSternik ===
44
45 *--- TR 1065217 27-Nov-2012 BNarayanan ---
46 nMaxStylesImplode = 0
47 *=== TR 1065217 27-Nov-2012 BNarayanan ===
48
49 *--- TechRec 1089737 20-Nov-2015 jisingh ---
50 cOverridePpkAction = ""
51 *=== TechRec 1089737 20-Nov-2015 jisingh ===
52
53 *--- TechRec 1090303 08-Jan-2016 jisingh ---
54 lValidateDivision = false
55 *=== TechRec 1090303 08-Jan-2016 jisingh ===
56
57 *--------------------------------------------------------------------------
58
59 Procedure Init
60 Lparameters toHostProcess
61 LOCAL llRetVal
62 llRetVal = .t.
63 llRetVal = llRetVal and DODEFAULT(toHostProcess)
64
65 *--- TR 1052729 10-Mar-11 SK
66 This.oPopulateSqlTempTable = Null
67
68 *--- TR 1065271 27-Nov-2012 BNarayanan ---
69 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
70 *=== TR 1065271 27-Nov-2012 BNarayanan ===
71
72 this.GetImplodeSQL()
73
74 RETURN llRetVal
75 Endproc
76
77 *--------------------------------------------------------------------------
78
79 *-- [Main procedure]
80 Procedure PreValidation
81 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
82 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
83 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
84 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
85 Local llRetVal, lcSQLSelect, lcSQLOrder
86 llRetVal = .T.
87 PRIVATE vcLogName
88 vcLogName = this.cLogName
89 With This
90 .LogEntry("Resetting all error messages in transaction tables.")
91 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
92 vcLogName)
93 *--- TechRec 1005163 17-May-2004 GS ---
94 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
95 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
96 *=== TechRec 1005163 17-May-2004 GS ===
97
98 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
99 vcLogName)
100
101 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
102 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
103 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
104 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
105
106 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
107 vcLogName)
108 *--- TechRec 1005163 17-May-2004 GS ---
109 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
110 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
111 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
112 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
113 *=== TechRec 1005163 17-May-2004 GS ===
114 Endwith
115 Return llRetVal
116 Endproc
117
118 *--------------------------------------------------------------------------
119
120 * Clear all previous errors
121 Procedure ClearErrors
122 Lparameters pceipoTH, pceipoTD,;
123 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
124 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
125 Local llRetVal, lnOldSelect, laTables[2]
126 llRetVal = .T.
127 lnOldSelect = Select()
128 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
129 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
130 * we don't allow explosion happen again therefore cannot clearout division)
131 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
132 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
133 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
134 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
135 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
136 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
137 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
138 *=== 1010206 11/10/2005 Ilya.
139
140 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
141
142 *--- TR 1064141 3-Oct-2012 Goutam
143 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
144 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
145
146 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
147 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
148 *=== TR 1064141 3-Oct-2012 Goutam
149
150 *=== TR 1003801 - BD
151 *--- TechRec 1005163 17-May-2004 GS ---
152 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
153 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
154 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
155 *=== TechRec 1005163 17-May-2004 GS ===
156
157 *--- TechRec 1028745 05-Feb-2008 GSternik ---
158 If .oHostProcess.lHaveChrgs
159 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
160 Endif
161 *=== TechRec 1028745 05-Feb-2008 GSternik ===
162
163 *---TR 1008342 10-JAN-2005 RG
164 Replace All Pending_Flg With 'N' In (pceipoTH)
165 *===TR 1008342 10-JAN-2005 RG
166
167 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
168 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
169 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
170 IN (pceipoTH)
171 *=== TR 1073346 05-Sep-13 SK
172
173 *- 1041285 07/10/09 YIK
174 *- Populate force errors into error fields
175 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
176 FOR Errs_flg_fh = 'Y' ;
177 IN (pceipoTH)
178
179 *--- TR 1043191 23-Oct-2009 JK ---
180 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
181 *=== TR 1043191 23-Oct-2009 JK ===
182
183 Select(lnOldSelect)
184 Return llRetVal
185 Endproc
186
187 *--------------------------------------------------------------------------
188
189 ************************************************************************************
190 * Error check EDI headers
191 ************************************************************************************
192 Procedure CheckHeader
193 Lparameters pceipoTH, pceipoCR, pceipoTD
194 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
195
196 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
197 llRetVal = .T.
198 lnOldSelect = Select()
199 With This
200
201 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
202 *--- LOCAL MOD
203 *If llRetVal And .lRBACustSku
204 If llRetVal And .oHostProcess.lRBACustSku
205 .LogEntry("Resolve RBA Customer")
206 llRetVal= .ResolveBCCustomer(pceipoTH)
207 Else
208 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
209
210 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
211
212 *--- TR 1045965 09-MAR-2010 HNISAR
213*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
214 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
215 *=== TR 1045965 09-MAR-2010 HNISAR
216
217 If llRetVal
218 .LogEntry("Validating customer.")
219 llRetVal= .CheckCustomer(pceipoTH)
220 *- 01/29/02 YIK TAN 29056
221 If llRetVal
222 .LogEntry("Verifying Multiple customer.")
223 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
224 *= TAN 29056
225 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
226 Endif
227 Endif
228 Endif
229 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
230
231 *--- TR 1041542 NSD 7/22/09
232 IF llRetVal
233 .LogEntry("Resolving Register Number")
234 llRetVal = .ResolveRegisterNumber(pceipoTH)
235 ENDIF
236 *=== TR 1041542 NSD 7/22/09
237
238 If llRetVal
239 .LogEntry("Validating EDI store.")
240 llRetVal= .CheckStore(pceipoTH, pceipoCR)
241 If llRetVal
242 .LogEntry("Validating EDI center.")
243 llRetVal= .CheckDistribution(pceipoTH)
244 *- 1007452 10/22/04 YIK
245 *- Checking notes type
246 If llRetVal
247 .LogEntry("Validating Header Notes type.")
248 llRetVal= .CheckNoteType(pceipoTH)
249 Endif
250 *= 1007452
251 Endif
252 Endif
253
254 *--- TR 1022625 4-Mar-2007 TT
255 If llRetVal
256 .LogEntry("Checking for Terminations in PO_TYPE")
257 llRetVal= .CheckTerminationInPoType(pceipoTH)
258 Endif
259
260 *--- TR 1022625 4-Mar-2007 TT
261 *!* ENDIF
262 *!* ENDIF
263
264 *--- TR 1030441 17-Apr-2008 Goutam
265 If llRetVal
266 .LogEntry("Validating shipper code.")
267 llRetVal= .CheckShipper(pceipoTH)
268 Endif
269 *=== TR 1030441 17-Apr-2008 Goutam
270
271 *--- TechRec 1066487 05-Feb-2013 MANI. ---
272 IF llRetVal
273 .LogEntry("Validating Location.")
274 llRetVal= .ValidateLocation(pceipoTH)
275 Endif
276 *=== TechRec 1066487 05-Feb-2013 MANI. ===
277
278 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
279 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
280*!* If llRetVal
281*!* .LogEntry("Validating 855 Header status code.")
282*!* llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
283*!* ENDIF
284 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
285 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
286
287 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
288 * TR 1037925 - As per Krishna/Shenba
289 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
290 * This is getting moved in TR 1037925
291*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
292*!* IF llRetVal
293*!* .LogEntry("Resolving Customer Shipper.")
294*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
295*!* ENDIF
296*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
297 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
298
299 *- TR 1111325 FH
300 llRetVal = llRetVal AND .ResolveControlPkey(pceipoTH)
301 Endwith
302 Select(lnOldSelect)
303 Return llRetVal
304 Endproc
305
306 *--------------------------------------------------------------------------------------
307
308 Function ResolveBCCustomer
309
310 Lparameters pceipoTH
311 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
312
313 llRetVal = True
314 lnSelect = Select()
315 With This
316 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
317 lcSQLString = " Select * From ZZXCSTCR "
318 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
319
320 If llRetVal
321 lcCursor = GetUniqueFileName()
322
323 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
324
325 Select lcCursor
326 lcErrs_Msg = " No matching record in Customer Store cross reference "
327
328 lnCnt = Recc()
329 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
330
331 Scan
332 lccustomer = Alltrim(rtl_cust)
333 lcDepartment = Alltrim(rtl_dept)
334 lcOrd_type = Alltrim(rtl_ord_type)
335
336 .LogEntry("Retail Customer: " + lccustomer )
337 .LogEntry("Retail Dept: " + lcDepartment)
338 .LogEntry("Retail order type: " + lcOrd_type)
339
340 Select tcCustcr
341 .LogEntry("Select: tcCustcr")
342
343 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
344 If Not Found()
345 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
346 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
347 IN (pceipoTH)
348 .LogEntry(lcErrs_Msg)
349 Else
350 lcBCCustomer = tcCustcr.customer
351 lcBCEDIStore = tcCustcr.Store
352
353 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
354
355 * TR 1019260 Added- , ord_type WITH '' ;
356
357 Replace customer With lcBCCustomer ;
358 EDI_STORE With lcBCEDIStore , ord_type With '' ;
359 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
360 IN (pceipoTH)
361
362 Endif
363 Endscan
364 .TableClose(lcCursor)
365 .TableClose("tcCustcr")
366
367 Endif
368 Endwith
369
370 Select (lnSelect)
371 Return llRetVal
372 Endfunc
373
374 *-----------------------------------------------------------------------------------
375
376 * TAN 29056 YIK
377 Procedure CheckForMultiCust
378 Lparameter pceipoTH, pceipoCR
379 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
380 llRetVal, llMultiCust
381 Private pcCustomer
382
383 lnSelect = Select()
384 Select (pceipoCR)
385 Scan For mult_cust = 'Y'
386
387 *--- TR 1031442 25-Jun-2008 Goutam
388 *llMultiCust = .T.
389 *--- TR 1031442 25-Jun-2008 Goutam
390
391 pcCustomer = customer
392 lcDiv = division
393 lcCursor = GetUniqueFileName()
394 *- YIK 01/30/02
395 *- We may have multiple POs/regions per customer in one tceipoth file
396 Select Distinct Region From (pceipoTH) ;
397 WHERE customer = pcCustomer ;
398 AND !Empty(Region) ;
399 INTO Cursor &lcCursor
400 Select (lcCursor)
401 Scan
402
403 *--- TR 1031442 25-Jun-2008 Goutam
404 llMultiCust = .T.
405 *--- TR 1031442 25-Jun-2008 Goutam
406
407 pcRegion = Region
408 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
409 Replace &pceipoTH..customer With lcNewCustID ;
410 FOR customer = pcCustomer And Region = pcRegion;
411 IN (pceipoTH)
412 Endscan
413 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
414 Select (pceipoCR)
415 Endscan
416 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
417 Select (lnSelect)
418 Return llRetVal
419 Endproc
420
421 *-----------------------------------------------------------------------------------
422
423 Procedure CheckStore
424 Lparameters pcHeader, pcControl
425 Local llRetVal, lnOldSelect
426 llRetVal= .T.
427 lnOldSelect= Select()
428
429 * 1st - group get store using cust,edi_store but not overwrite existing store
430 * users could change store in Trans Maint.
431 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
432 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
433 Select __TmpCursor
434 With This
435 .cSQLTempTable=""
436 If .GenerateSQLTempTable('__TmpCursor')
437 If .PopulateSQLTempTable('__TmpCursor')
438 If !Empty(.cSQLTempTable)
439 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
440 * also, populate center_code, consol_code if empty
441 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
442 " from zzxstorr s, " + .cSQLTempTable + " t " +;
443 "Where s.customer= t.customer and s.edi_store= t.edi_store"
444 llRetVal = v_SqlExec(lcSQLString, "_Storr")
445 If llRetVal
446 Select _Storr
447 Index On customer+EDI_STORE Tag CustStore
448 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
449 "customer+edi_store")
450 If llRetVal
451 Select (pcHeader)
452
453
454 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
455 * Otherwise we will not be able to resolve currency later and that will
456
457
458 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
459 * Confirm order(with store) for the same customer
460 * the Bulk order will have "Invalid Store" message.
461 * Only Scan for !Empty(edi_store)
462 Scan For !Empty(EDI_STORE)
463 Do Case
464 Case Empty(_Storr.customer)
465 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
466 Errs_flg_h With "Y" In (pcHeader)
467 Case _Storr.active_ok <> 'Y'
468 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
469 Errs_flg_h With "Y" In (pcHeader)
470 Otherwise
471 If Empty(Store) && don't want to overwrite previous data
472 Replace Store With _Storr.Store
473 Endif
474 *- YIK 1017307 07/18/06
475 *- Added AND EMPTY(edi_center)
476 *--- TR 1042564 14-Sep-2008 JK ---
477 * if the dts flag on the order is not Y, then populate.
478 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
479 *=== TR 1042564 14-Sep-2008 JK ===
480 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
481 Replace center_code With _Storr.center_code
482 Endif
483 If Empty(consol_code) And !Empty(_Storr.consol_code)
484 Replace consol_code With _Storr.consol_code
485 Endif
486 *--- TR 1042564 14-Sep-2008 JK ---
487 ENDIF
488 *=== TR 1042564 14-Sep-2008 JK ===
489 *== 1009508
490 Endcase
491
492 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
493
494 Endscan
495 Set Relation To
496 Use In _Storr
497 Endif
498 Endif
499 Endif
500 Endif
501 Endif
502 Endwith
503 If Used("__TmpCursor")
504 Use In __TmpCursor
505 Endif
506
507 * 2nd - validate store by cust,store
508 * Notes: cannot reuse the above server side cursor because have
509 * to resolve it to tran header local 1st before validate happen
510 Select Distinct customer, Store From (pcHeader) ;
511 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
512 Select __TmpCursor
513 With This
514 .cSQLTempTable=""
515 If .GenerateSQLTempTable('__TmpCursor')
516 If .PopulateSQLTempTable('__TmpCursor')
517 If !Empty(.cSQLTempTable)
518 lcSQLString= "Select s.customer, s.store " +;
519 " from zzxstorr s, " + .cSQLTempTable + " t " +;
520 "Where s.customer= t.customer and s.store= t.store"
521 llRetVal = v_SqlExec(lcSQLString, "_Storr")
522 If llRetVal
523 Select _Storr
524 Index On customer+Store Tag CustStore
525 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
526 "customer+store")
527 If llRetVal
528 Select (pcHeader)
529 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
530 * Confirm order(with store) for the same customer
531 * the Bulk order will have "Invalid Store" message.
532 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
533 * Don't have conf_type as "A" or "B" yet
534 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
535 *- assortment orders with no store.
536
537 *--- TR1055827 NSD/FGCjr
538 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
539 SCAN FOR (NOT (po_type= EDI_BLANKET_ORDER OR po_type= EDI_BULK_ORDER OR EMPTY(EDI_STORE))) OR (conf_type = 'A' AND NOT EMPTY(store) AND EMPTY(edi_store))
540 *=== TR1055827
541 If Empty(_Storr.customer)
542 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
543 Errs_flg_h With "Y" In (pcHeader)
544 Endif
545 Endscan
546 Set Relation To
547 Use In _Storr
548 Endif
549 Endif
550 Endif
551 Endif
552 Endif
553 Endwith
554 If Used("__TmpCursor")
555 Use In __TmpCursor
556 Endif
557
558 If Used("_Storr")
559 Use In _Storr
560 Endif
561
562 Select(lnOldSelect)
563 Return llRetVal
564 Endproc
565
566 *------------------------------------------------------------------------------------------
567
568 ************************************************************************************
569 * Validate EDI Distribution Center
570 * ATS# 2757 PL 06/09/99- validate against edi_center
571 * use edi_center in tran header for validation, when found
572 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
573 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
574 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
575 ************************************************************************************
576 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
577 * 1. Select Distinct customer, distribution center from work header.
578 * 2. Check for valid distribution center. If faile the check update all headers for
579 * the same customer, distribution center with "Invalid Store code." and
580 * Errs_Flg with "Y"
581 * Return: True= All pass validation
582 * False= If one of them fail the check
583 ************************************************************************************
584 Procedure CheckDistribution
585 Lparameters pceipoTH
586 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
587 llRetVal = .T.
588 lnOldSelect = Select()
589
590 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
591 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
592 Into Cursor CntrList
593 Select CntrList
594 If This.lUserInterface
595 * Init Thermometer
596 This.UpdateThermoCaption("Validating Distribution Center(s)...")
597 * TAN 31891 - JAZ - 5/20/02
598 * This.InitThermo(RECC('CntrList'))
599 This.InitThermo(Reccount('CntrList'))
600 * End TAN 31891 - JAZ - 5/20/02
601 l_nThermoCnt = 0
602 Endif
603 Scan
604 If This.lUserInterface
605 * Advance progress bar, if we're using one.
606 l_nThermoCnt = l_nThermoCnt + 1
607 This.AdvanceThermo(l_nThermoCnt)
608 Endif
609 * Empty(center_code) resolve using edi_center
610 If Empty(center_code)
611 lcErrs_Msg= ""
612 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
613 lcErrs_Msg= lcErrs_Msg + CRLF
614 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
615 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
616 IN (pceipoTH)
617 Else
618 * replace center_code with shipthru.center_code when found edi_center
619 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
620 * COMMENT OUT replace ship_dc with "D" also.
621 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
622 * Do not update center code unless dts_flag <> Y
623 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
624 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
625 IN (pceipoTH)
626
627 Endif
628 Else
629 * user may overwrite with wrong center_code, validate distribution center
630 lcErrs_Msg= ""
631 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
632 lcErrs_Msg= lcErrs_Msg + CRLF
633 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
634 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
635 IN (pceipoTH)
636 Endif
637 Endif
638
639 Endscan
640 Use In CntrList
641
642 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
643 * also, populate center_code, consol_code if empty
644 * populate Ship_dc base on center/consol_code
645 Select (pceipoTH)
646 Scan
647 lcShip_dc = ""
648 *- 1009508 03/16/05
649 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
650 *-- DO CASE
651 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
652 *-- lcShip_dc = "B"
653 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
654 *-- lcShip_dc = "D"
655 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
656 *-- lcShip_dc = "C"
657 *-- ENDCASE
658
659 If !Empty(center_code) Or !Empty(consol_code)
660 Do Case
661 Case !Empty(center_code) And !Empty(consol_code)
662 lcShip_dc = "B"
663 Case !Empty(center_code) And Empty(consol_code)
664 lcShip_dc = "D"
665 Case Empty(center_code) And !Empty(consol_code)
666 lcShip_dc = "C"
667 Endcase
668 *= 1009508 YIK
669 If !Empty(lcShip_dc)
670 Replace ship_dc With lcShip_dc In (pceipoTH)
671 Endif
672 Endif
673 Endscan
674
675 If This.lUserInterface
676 * Reset Thermometer
677 This.ResetThermo()
678 Endif
679
680 If Used("CntrList")
681 Use In CntrList
682 Endif
683 If Used("tcDistr")
684 Use In tcDistr
685 Endif
686 Select(lnOldSelect)
687 Return llRetVal
688 Endproc
689
690 *---------------------------------------------------------------------------------
691
692 Procedure CheckNoteType
693 Lparameters tcEiPOth
694 Local llRetVal, lcNotes, laNotes
695 llRetVal = .T.
696 Select (tcEiPOth)
697 Scan For !Empty(notes)
698 lcNotes = notes
699 Declare laNotes[2]
700 laNotes = ""
701 If At("|", lcNotes) > 0 && has note_type
702 *- 1030497 02/29/08 TT
703 *--StringToArray(lcNotes, @laNotes, "|")
704 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
705 *- 1030497 02/29/08 TT
706 lnNotes = Alen(laNotes)/2
707 For lnCnt = 1 To lnNotes
708 If !vl_notyp(laNotes[2*lnCnt - 1])
709 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
710 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
711 Endif
712 Endfor
713 Endif
714 Endscan
715 Return llRetVal
716 Endproc
717 *---------------------------------------------------------------------------------
718
719 *--- TR 1022625 4-Mar-2007 TT
720 Function CheckTerminationInPoType
721 Lparameters pceipoTH
722 LOCAL llRetVal, lnOldSelect
723 lnOldSelect = SELECT()
724 llRetVal = .t.
725 Local lnLastOrder
726 Select (pceipoTH)
727 lnLastOrder = Order()
728 Set Order To Tag po_type
729 If Seek("TR", pceipoTH, "po_type")
730 Scan While po_type = 'TR'
731 Replace Errs_msg_H With Errs_msg_H + ;
732 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
733 Errs_flg_h With "Y" In (pceipoTH)
734 Endscan
735 Endif
736 Set Order To lnLastOrder
737 SELECT(lnOldSelect)
738 RETURN llRetVal
739 Endfunc
740 *--- TR 1022625 4-Mar-2007 TT
741
742 *---------------------------------------------------------------------------------
743
744 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
745 PROCEDURE Validate855Status
746 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
747
748 Local llRetVal, lnOldSelect, lcSourceFilter
749 llRetVal= true
750 lnOldSelect= Select()
751
752 IF pcHeaderDetail = 'H'
753 SELECT Distinct status_855 FROM (pcHeader) ;
754 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
755 lcSourceFilter = " s.source = 'BAK02'"
756 ELSE
757 SELECT DISTINCT d.status_855 ;
758 FROM (pcDetail) d ;
759 JOIN (pcHeader) h ;
760 ON h.pkey = d.fkey ;
761 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
762 INTO CURSOR __tmp855Status
763 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
764 ENDIF
765
766 SELECT __tmp855Status
767 WITH This
768 .cSQLTempTable=""
769 IF .GenerateSQLTempTable('__tmp855Status')
770 IF .PopulateSQLTempTable('__tmp855Status')
771 IF !EMPTY(.cSQLTempTable)
772
773 lcSQLString= "Select s.status_855 from " +;
774 " zzeopakr s, " + .cSQLTempTable + " t " +;
775 "Where s.status_855 = t.status_855 and " + lcSourceFilter
776
777 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
778 IF llRetVal
779 SELECT _Ststus855
780 INDEX On status_855 TAG status_855
781 IF pcHeaderDetail = 'H'
782 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
783 ELSE
784 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
785 ENDIF
786
787 IF llRetVal
788 IF pcHeaderDetail = 'H'
789 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
790 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
791 ELSE
792 *- TR 1083937 FH - added INLIST(status_855,'AK','RJ'
793 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
794 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) ;
795 AND NOT INLIST(status_855,'AK','RJ') In (pcDetail)
796
797 * mark headers errors here as the Run855Process which runs next will rely on header errors.
798 SELECT (pcDetail)
799 SCAN FOR errs_flg_d = 'Y'
800 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
801 AND EVALUATE(pcHeader+'.req_855') = 'R'
802 ENDSCAN
803 ENDIF
804
805 SET RELATION TO
806 ENDIF
807 ENDIF
808 ENDIF
809 ENDIF
810 ENDIF
811 ENDWITH
812
813 IF USED("__tmp855Status")
814 USE IN __tmp855Status
815 ENDIF
816 IF USED("_Ststus855")
817 USE IN _Ststus855
818 ENDIF
819
820 Select(lnOldSelect)
821 Return llRetVal
822 ENDPROC
823 *=== TR 1074251 03-Jan-2014 Goutam
824
825 *---------------------------------------------------------------------------------
826
827 *--- TR 1030441 17-Apr-2008 Goutam
828 Procedure CheckShipper
829 LPARAMETERS pcHeader
830 Local llRetVal, lnOldSelect
831 llRetVal= true
832 lnOldSelect= Select()
833
834 SELECT Distinct shipper FROM (pcHeader) ;
835 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
836
837 SELECT __tmpShipper
838 WITH This
839 .cSQLTempTable=""
840 IF .GenerateSQLTempTable('__tmpShipper')
841 IF .PopulateSQLTempTable('__tmpShipper')
842 IF !EMPTY(.cSQLTempTable)
843 lcSQLString= "Select s.shipper from " +;
844 " zzxshipr s, " + .cSQLTempTable + " t " +;
845 "Where s.shipper= t.shipper"
846 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
847 IF llRetVal
848 SELECT _Shiper
849 INDEX On shipper TAG Shipper
850 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
851 IF llRetVal
852 SELECT (pcHeader)
853 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
854 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
855 SET RELATION TO
856 ENDIF
857 ENDIF
858 ENDIF
859 ENDIF
860 ENDIF
861 ENDWITH
862
863 IF USED("__tmpShipper")
864 USE IN __tmpShipper
865 ENDIF
866 IF USED("_Shiper")
867 USE IN _Shiper
868 ENDIF
869
870 Select(lnOldSelect)
871 Return llRetVal
872 Endproc
873 *=== TR 1030441 17-Apr-2008 Goutam
874
875 *---------------------------------------------------------------------------------
876
877 ************************************************************************************
878 * Error check all raw EDI details
879 ************************************************************************************
880 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
881 * Move codes to CheckUPC() and CheckSKU()
882 * Add:ResolveCustomerLabel()
883 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
884 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
885 * [div,sty,col,lbl,dim,size] allow or not
886 *
887 Procedure CheckDetail
888 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
889 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
890 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
891 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
892 Local llRetVal, lnOldSelect
893 llRetVal = .T.
894 lnOldSelect = Select()
895 With This
896 *--- TechRec 1048792 17-Dec-2010 jisingh ---
897 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
898 *=== TechRec 1048792 17-Dec-2010 jisingh ===
899
900 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
901 *--- TR 1019697 NH
902 .LogEntry("Cascading Customer To Detail.")
903 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
904 .LogEntry("Cascading Customer To SLN.")
905 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
906 *=== TR 1019697 NH
907 *=== TechRec 1048667 03-May-2011 GSternik ===
908
909
910 *--- TechRec 1024522 18-Sep-2007 GSternik ---
911 *--- LOCAL MOD
912 *If This.lHaveSLN
913 If This.oHostProcess.lHaveSLN
914 .LogEntry("Resolving SLNs/Prepack Style.")
915 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
916 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
917 EndIf
918 *=== TechRec 1024522 18-Sep-2007 GSternik ===
919
920 .LogEntry("Resolving style using UPC.")
921 *--- TechRec 1005163 17-May-2004 GS ---
922 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
923 *--- TR 1019697 NH
924 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
925 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
926*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
927 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
928 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
929
930 *--- TR 1036917 04-Feb-2009 Partha ---
931 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
932 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
933
934 *=== TR 1036917 04-Feb-2009 Partha ===
935
936 *=== TR 1019697 NH
937 *=== TechRec 1005163 17-May-2004 GS ===
938 *--- TR 1023892 NH
939 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
940 *=== TR 1023892 NH
941
942 *--- TR 1044885 13-JAN-2010 BR Moved from above
943 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
944
945 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
946 *--- TechRec 1005163 17-May-2004 GS ---
947 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
948 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
949 *=== TechRec 1005163 17-May-2004 GS ===
950 *= 39222
951
952 *- TR 1003801 - 03/25/04 BD - Resolve EAN
953 .LogEntry("Resolving style using EAN.")
954
955 *--- TechRec 1005163 17-May-2004 GS ---
956 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
957 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
958 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
959 *=== TR 1061652 05/18/12 ATHIRUNAVU
960
961 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
962 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
963 *--- TR 1035223 NH
964 .LogEntry("Setting Skip SLN Check flag.")
965 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
966 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
967 *=== TR 1035223 NH
968
969 *--- TR 1053820 26-May-2011 Goutam
970 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
971 .LogEntry("Generate Customer SKU (Style_ColorSize).")
972 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
973 ENDIF
974 *=== TR 1053820 26-May-2011 Goutam
975
976 .LogEntry("Confirming SKU for UPC/EAN.")
977 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
978 *=== TechRec 1005163 17-May-2004 GS ===
979 *=== TR 1003801
980
981 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
982 If llRetVal And .oHostProcess.lRBACustSku
983 .LogEntry("Verifying Customer SKU.")
984 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
985 Endif
986 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
987
988 .LogEntry("Resolving style using SKU.")
989 *--- TechRec 1005163 17-May-2004 GS ---
990 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
991
992 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
993 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
994 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
995 *=== TR 1010097 07/27/05 TK
996 *=== TechRec 1005163 17-May-2004 GS ===
997
998 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
999 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
1000 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
1001
1002 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1003 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1004 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1005
1006 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1007 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
1008 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1009
1010 *--- TR 1101199 10-Feb-2017 Goutam
1011 llRetVal = llRetVal And .PopulateControlpkey(pceipoTH, pceipoTD, pceipoCR)
1012 *=== TR 1101199 10-Feb-2017 Goutam
1013
1014 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
1015 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1016 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD, pceipoCR)
1017 *=== TR 1040432 MAY-20-2009 BR
1018
1019 *--- TR 1090280 30-Sep-2015 Goutam
1020 .LogEntry("Validating Implosion Type.")
1021 llRetVal= llRetVal And .ValidateImplosionType(pceipoTH, pceipoTD, pceipoCR)
1022 *=== TR 1090280 30-Sep-2015 Goutam
1023
1024 *--- TR 1098918 26-Sep-2016 HGORE ---
1025 llRetVal = llRetVal And .UpdateReq_855ForAllocation(pceipoTH)
1026 *=== TR 1098918 26-Sep-2016 HGORE ===
1027
1028 *--- TR 1013007 NH
1029 *--- check if req_855 if 'R' and status flag is empty then set error flag
1030 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1031 *=== TR 1013007 NH
1032
1033 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1034 If llRetVal
1035 .LogEntry("Validating detail 855 status code.")
1036 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1037 Endif
1038 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1039
1040 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1041 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1042 vcLogName)
1043
1044 *--- TR 1013007 NH 2005-10-11
1045 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1046 If .lSend855
1047 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1048
1049 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1050 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1051 *=== TR 1040432 MAY-20-2009 BR
1052
1053 *--- Error out IPO records which has no corresponding OPRCR control ref
1054 *--- IPO and OPRCR link is customer, division, oVnd_Key
1055 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1056 *=== TR 1034481 NH
1057 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1058 *--- If req_855 = 'R'
1059 *--- then run process 855
1060 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1061 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1062 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1063 Endif
1064 *=== TR 1013007 NH
1065
1066 *--- TR 1098918 26-Sep-2016 HGORE ---
1067 llRetVal = llRetVal And .ResetReq_855(pceipoTH)
1068 *=== TR 1098918 26-Sep-2016 HGORE ===
1069
1070 *-1089110 FH - error out 0 total_qty
1071 llRetVal= llRetVal And .ValidateZeroQty(pceipoTD)
1072
1073 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1074 .LogEntry("Resolving Is 860.")
1075 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1076
1077 .LogEntry("Creating 860 Transaction records.")
1078 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
1079 llRetVal = llRetVal And .Create860TM(pceipoTH, pceipoTD)
1080 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1081
1082 *--- TechRec 1082601 24-Dec-2014 jisingh ---
1083 .LogEntry("Validating detail 860 qual.")
1084 llRetVal = llRetVal And .Validate860Qual(pceipoTH, pceipoTD)
1085 *=== TechRec 1082601 24-Dec-2014 jisingh ===
1086
1087 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1088 .LogEntry("Resolving Multi-UPCs.")
1089 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1090 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1091
1092 .LogEntry("Resolving range style.")
1093 *--- TR 1023892 NH -
1094 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1095 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1096 *=== TR 1023892 NH
1097
1098 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1099 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1100 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1101 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1102
1103 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1104 vcLogName)
1105 *- 36262 6/11/03 YIK
1106 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1107 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1108 vcLogName)
1109 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1110 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1111 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1112 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1113 * === TR 1046519 7/26/10 CM
1114
1115 *=
1116
1117 *- 1044723 01/06/10 YIK
1118 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1119 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1120
1121 *- TR 1042748 09/23/09 YIK
1122 *- Call it here to populate Impl_ok flag (3d parameter).
1123 *- MOved it to clsipopr, so need to call with .oHostProcess
1124 *- This method will be called again after implosion. Ok per JRoth
1125 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1126
1127
1128 * 3/25/02 30854 - Implosion single prepack
1129 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1130 vcLogName)
1131 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
1132
1133 *- 1006607 09/01/04 YIK
1134 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1135 vcLogName)
1136 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1137 *=========
1138
1139 *--- TechRec 1005163 17-May-2004 GS ---
1140 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1141 If .oHostProcess.lHaveSLN
1142 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1143
1144 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1145*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1146*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1147 *=== TR 1049029 27-Aug-2010 Partha ===
1148
1149 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1150
1151 .LogEntry("Validating SLN vs. Prepack.")
1152 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1153 Endif
1154 *=== TechRec 1005163 17-May-2004 GS ===
1155
1156 *--- TR 1011644 23-AUG-2005 KA
1157 *If this.oResolvePrepack.lMultipack
1158 If this.lMultipack
1159 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1160 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1161 Endif
1162 *=== TR 1011644 23-AUG-2005 KA
1163
1164 .LogMajorStage("Resolving and getting default fields.")
1165 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1166 .LogEntry("Resolving customer label.")
1167 *--- TechRec 1005163 18-May-2004 GS ---
1168 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1169 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1170 *=== TechRec 1005163 18-May-2004 GS ===
1171
1172 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1173 vcLogName)
1174
1175 .LogEntry("Validating style.")
1176 *--- TechRec 1005163 21-Jun-2004 GS ---
1177 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1178 *--- TechRec 1016817 04-May-2006 GS ---
1179 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1180 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1181 *=== TechRec 1016817 04-May-2006 GS ===
1182 *=== TechRec 1005163 21-Jun-2004 GS ===
1183
1184 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1185 If This.oHostProcess.lHaveChrgs
1186 .LogEntry("Validating Charges.")
1187 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1188 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1189 EndIf
1190 *-- This is not needed anymore:
1191 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1192 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1193 * vcLogName)
1194 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1195
1196 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1197 *!* .LogEntry("Validating MinMultiple.")
1198 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1199 *===TR 1012978 VK 23/11/05
1200
1201 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1202 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1203 vcLogName)
1204 .LogEntry("Converting inbound UOM.")
1205 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1206
1207 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1208 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1209 lcSqlString = " UPDATE h SET " + ;
1210 " ReResvStyle = c.ReResvStyle " + ;
1211 " FROM (pcEipoTH) h " + ;
1212 " JOIN (pcEipoCR) c " + ;
1213 " ON h.division = c.division " + ;
1214 " AND h.customer = c.customer " + ;
1215 " WHERE h.ReResvStyle = '' "
1216
1217 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1218 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1219 EndWith
1220
1221 Select(lnOldSelect)
1222 Return llRetVal
1223 ENDPROC
1224
1225 *----------------------------------------------------------------------------------------
1226 * TR 1037976 JAN-22-2008 BR
1227 *----------------------------------------------------------------------------------------
1228 Procedure UpdtHeaderDivs
1229 *--- TechRec 1090303 08-Jan-2016 jisingh Added pceipoCR ===
1230 Lparameters pceipoTH, pceipoTD, pceipoCR
1231 Local llRetVal, lnOldSelect, llUpdate
1232 llRetVal = .T.
1233 lnOldSelect = Select()
1234
1235 .LogEntry("Resolving header division.")
1236 *- 1005164 07/12/04 YIK
1237 *- Removed ..And Empty(Errs_Msg_D)
1238 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1239*!* Select Distinct fkey, division From (pceipoTD) ;
1240*!* WHERE !Empty(division) Into Cursor tmpCurs
1241
1242 SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, ;
1243 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
1244 FROM (pceipoTH) h ;
1245 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
1246 JOIN (pceipoCR) c ON c.pkey = h.control_pkey ;
1247 WHERE !EMPTY(d.division) INTO CURSOR tmpCurs
1248 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1249 Select tmpCurs
1250 If This.lUserInterface
1251 * Init Thermometer
1252 * TAN 31891 - JAZ - 5/20/02
1253 * This.InitThermo(RECC('tmpCurs'))
1254 This.InitThermo(Reccount('tmpCurs'))
1255 * End TAN 31891 - JAZ - 5/20/02
1256 l_nThermoCnt = 0
1257 Endif
1258 Scan
1259 If This.lUserInterface
1260 * Advance progress bar, if we're using one.
1261 l_nThermoCnt = l_nThermoCnt + 1
1262 This.AdvanceThermo(l_nThermoCnt)
1263 Endif
1264 Select (pceipoTH)
1265
1266 * --- TR 1022896 NSD 05-10-07
1267 * Convert LOCATE to SEEK
1268 *LOCATE FOR pkey = tmpCurs.fkey
1269 *IF FOUND()
1270 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1271 * === TR 1022896 NSD 05-10-07
1272 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1273 IF tmpCurs.validate_division = "Y" AND tmpCurs.ctrl_division <> tmpCurs.division
1274 REPLACE errs_msg_h WITH errs_msg_h + ;
1275 "Mismatch between division(" + ALLTRIM(tmpCurs.ctrl_division) + ;
1276 ") and resolved UPC/SKU division(" + ALLTRIM(tmpCurs.division) + ")." + CRLF,;
1277 errs_flg_h WITH "Y" IN (pceipoTH)
1278 ELSE
1279 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1280 Replace division With tmpCurs.division In (pceipoTH)
1281 *--- TechRec 1090303 08-Jan-2016 jisingh ---
1282 ENDIF
1283 *=== TechRec 1090303 08-Jan-2016 jisingh ===
1284 Endif
1285 Endscan
1286 Use In tmpCurs
1287
1288 If This.lUserInterface
1289 * Reset Thermometer
1290 This.ResetThermo()
1291 Endif
1292 Select(lnOldSelect)
1293 Return llRetVal
1294 ENDPROC
1295 *----------------------------------------------------------------------------------------
1296 * TR 1037976 JAN-22-2008 BR
1297 *----------------------------------------------------------------------------------------
1298
1299 *---------------------------------------------------------------------------------
1300
1301 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1302 ************************************************************************************
1303 * Resolve BC SKU from SLN records and create customer style data.
1304 ************************************************************************************
1305 Procedure ResolveStyleFromSLN
1306 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1307 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1308 *--- TR 1035491 4-Nov-2008 Goutam
1309 *--- This entire function splitted into two different part ;
1310 1. ResolveBCSkuFromSLN ;
1311 2. ResolvePPKSkuAndUpdateDetail
1312
1313 Local llRetVal, lnOldSelect
1314 lnOldSelect = Select()
1315 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1316 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1317
1318
1319 Select(lnOldSelect)
1320 Return llRetVal
1321 Endproc
1322
1323 *----------------------------------------------------------------------------------
1324 ************************************************************************************
1325 * Validate UPC for all details
1326 ************************************************************************************
1327 Procedure CheckUpc
1328 Lparameters pceipoTH, pceipoTD,;
1329 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1330
1331 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1332 * Added Parameter pceipocr
1333 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1334
1335 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1336 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1337 lnSize_desc, llSLN
1338
1339 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1340 LOCAL lcIs_upcsku
1341 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1342
1343 llRetVal = .T.
1344 lcErrs_Msg= ""
1345 lnOldSelect = Select()
1346
1347 * cannot check for UPC if customer is empty
1348 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1349 * on Cust SKU or UPC.
1350 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1351
1352 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1353 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1354 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1355
1356 *--- TechRec 1005163 17-May-2004 GS ---
1357 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1358 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1359 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1360 *Order by h.customer, d.upc Into Cursor tmpCurs
1361
1362 *---- TR 1024667 NSD 5/31/07
1363 * If sizebucket = 0 then re-resolve.
1364
1365 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1366 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1367*!* If This.lHaveSLN
1368*!* Select h.customer,;
1369*!* d.upc,;
1370*!* d.pkey,;
1371*!* (pceipoTD) As Src;
1372*!* FROM (pceipoTH) h ;
1373*!* JOIN (pceipoTD) d ;
1374*!* ON h.pkey = d.fkey ;
1375*!* WHERE !Empty(d.upc) ;
1376*!* AND !Empty(h.customer) ;
1377*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1378*!* UNION All ;
1379*!* SELECT h.customer,;
1380*!* s.SLN_UPC As upc,;
1381*!* s.pkey,;
1382*!* (pceipoTS) As Src ;
1383*!* FROM (pceipoTH) h ;
1384*!* JOIN (pceipoTD) d ;
1385*!* ON d.fkey = h.pkey ;
1386*!* JOIN (pceipoTS) s ;
1387*!* ON s.fkey = d.pkey ;
1388*!* WHERE !Empty(s.SLN_UPC) ;
1389*!* AND !Empty(h.customer) ;
1390*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1391*!* ORDER By 1, 2 ;
1392*!* INTO Cursor tmpCurs
1393*!* Else
1394*!* Select h.Customer,;
1395*!* d.UPC,;
1396*!* d.PKey,;
1397*!* (pceipoTD) As Src;
1398*!* FROM (pceipoTH) h ;
1399*!* JOIN (pceipoTD) d ;
1400*!* ON h.pkey = d.fkey ;
1401*!* WHERE !Empty(d.upc) ;
1402*!* AND !Empty(h.customer) ;
1403*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1404*!* ORDER By 1, 2;
1405*!* INTO Cursor tmpCurs
1406*!* Endif
1407 *=== TechRec 1005163 17-May-2004 GS ===
1408
1409 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1410 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1411 FROM (pceipocr) ;
1412 GROUP BY customer ;
1413 INTO CURSOR __ResvCustSKU
1414 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1415
1416 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1417*!* select h.Customer;
1418*!* , d.UPC;
1419*!* , d.PKey;
1420*!* from (pceipoTH) h;
1421*!* join (pceipoTD) d;
1422*!* on h.PKey = d.FKey;
1423*!* where !Empty(d.UPC);
1424*!* and !Empty(h.Customer);
1425*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1426*!* order by 1, 2;
1427*!* into Cursor tmpCurs ReadWrite
1428
1429 *- 1035314 08/28/08 YIK
1430 *- Added r.ResvCustSKU to the list of fields
1431 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1432
1433.oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1434
1435 Select h.customer;
1436 , d.upc;
1437 , d.pkey;
1438 ,(pceipoTD) AS Src;
1439 ,r.ResvCustSKU ;
1440 from (pceipoTH) h;
1441 join (pceipoTD) d;
1442 on h.pkey = d.fkey;
1443 JOIN __ResvCustSKU r ;
1444 ON r.Customer = H.Customer ;
1445 where !Empty(d.upc);
1446 and !Empty(h.customer);
1447 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1448 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1449 order By 1, 2;
1450 into Cursor tmpCurs Readwrite
1451 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1452 *= 08/12/08 YIK TR 1035314
1453*=== TechRec 1024522 25-Sep-2007 GSternik ===
1454
1455*-1040686
1456 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1457 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1458 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1459 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1460 IF llRetVal
1461 .PopulateSQLTempTable("tcCustUpc")
1462 ENDIF
1463
1464 llRetVal = llRetVal AND v_sqlexec(;
1465 "SELECT x.upc,d.* "+;
1466 " FROM zzxcstdr d"+ ;
1467 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1468 " JOIN " + this.cSQLTempTable + " x " + ;
1469 " ON d.customer = x.customer " +;
1470 " AND d.cust_style = x.upc " + ;
1471 " WHERE h.IB_resolv = 'Y'" + ;
1472 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1473 SELECT tmpCstdr_upc
1474 INDEX on customer + upc TAG cust_upc
1475
1476
1477 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1478 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1479 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1480 IF llRetVal
1481 .PopulateSQLTempTable("tcDistUpc")
1482 ENDIF
1483
1484 llRetVal = llRetVal AND v_sqlexec(;
1485 "SELECT x.upc,d.* "+;
1486 " FROM zzeupcnr d"+ ;
1487 " JOIN " + this.cSQLTempTable + " x " + ;
1488 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1489 SELECT tmpUpcnr
1490 INDEX on upc TAG upc
1491 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1492*-1040686
1493
1494 lcOldCust = ""
1495 lcOldItem = ""
1496 Select tmpCurs
1497 If This.lUserInterface
1498 * Init Thermometer
1499 This.UpdateThermoCaption("Validating UPC(s)...")
1500 * TAN 31891 - JAZ - 5/20/02
1501 * This.InitThermo(RECC('tmpCurs'))
1502 This.InitThermo(RecCount('tmpCurs'))
1503 * End TAN 31891 - JAZ - 5/20/02
1504 l_nThermoCnt = 0
1505 EndIf
1506
1507 Scan
1508 If This.lUserInterface
1509 * Advance progress bar, if we're using one.
1510 l_nThermoCnt = l_nThermoCnt + 1
1511 This.AdvanceThermo(l_nThermoCnt)
1512 Endif
1513 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1514 lcErrs_Msg = ""
1515 lcOldCust = tmpCurs.customer
1516 lcOldItem = tmpCurs.upc
1517 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1518 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1519
1520 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1521 lcIs_upcsku = ' '
1522 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1523
1524 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1525 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1526
1527 *- 1040686 - tmpCstdr_upc...
1528 lcDivision = tmpCstdr_upc.division
1529 lcStyle = tmpCstdr_upc.Style
1530 lcColor_code = tmpCstdr_upc.color_code
1531 lcLbl_code = tmpCstdr_upc.lbl_code
1532 lcDimension = tmpCstdr_upc.Dimension
1533 lnSizeBucket = tmpCstdr_upc.size_bk
1534 lnSize_desc = tmpCstdr_upc.size_desc
1535 *- 1040686 - tmpCstdr_upc...
1536
1537 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1538 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1539 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1540
1541 ELSE
1542 *- 08/12/08 YIK TR 1035314
1543 IF ResvCustSKU <> 'Y'
1544 lcErrs_Msg = ""
1545 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1546 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1547 lcDivision = tmpUpcnr.division
1548 lcStyle = tmpUpcnr.Style
1549 lcColor_code = tmpUpcnr.color_code
1550 lcLbl_code = tmpUpcnr.lbl_code
1551 lcDimension = tmpUpcnr.Dimension
1552 lnSizeBucket = tmpUpcnr.sizebucket
1553 lnSize_desc = tmpUpcnr.size_desc
1554 Else
1555 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1556 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1557 Store 0 To lnSizeBucket
1558 Endif
1559 *- 08/12/08 YIK TR 1035314
1560 ELSE
1561 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1562 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1563 STORE 0 TO lnSizeBucket
1564 ENDIF
1565 *= 08/12/08 YIK TR 1035314
1566 Endif
1567 Endif && level break
1568
1569 *--- TechRec 1005163 17-May-2004 GS ---
1570 *Select (pceipoTD)
1571*!* llSLN = (tmpCurs.Src = pceipoTS)
1572*!* If llSLN
1573*!* Select (pceipoTS)
1574*!* Else
1575 Select (pceipoTD)
1576*!* Endif
1577 *=== TechRec 1005163 17-May-2004 GS ===
1578 *- 1010682 04/25/05 YIK
1579 *- Locate For pkey = tmpCurs.pkey
1580 lnWorkArea = Select()
1581 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1582 Scatter Name loEiPOtd Memo
1583 If !Empty(lcErrs_Msg)
1584*!* *--- TechRec 1005163 17-May-2004 GS ---
1585*!* If llSLN
1586*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1587*!* loEiPOtd.Errs_Flg_S = "Y"
1588*!* Else
1589*!* *=== TechRec 1005163 17-May-2004 GS ===
1590 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1591 loEiPOtd.Errs_Flg_D = "Y"
1592*!* Endif
1593 Endif
1594 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1595 loEiPOtd.Division = lcDivision
1596 loEiPOtd.Style = lcStyle
1597 loEiPOtd.Color_Code = lcColor_code
1598 loEiPOtd.Lbl_Code = lcLbl_code
1599 loEiPOtd.Dimension = lcDimension
1600 loEiPOtd.SizeBucket = lnSizeBucket
1601 loEiPOtd.Size_Desc = lnSize_desc
1602
1603 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1604 IF !EMPTY(lcIs_upcsku)
1605 loEiPOtd.Is_upcsku = lcIs_upcsku
1606 ENDIF
1607 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1608
1609 *--- TR 1019697 NH : clear rang style when bc style is set
1610 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1611 loEiPOtd.rng_style = ''
1612 loEiPOtd.rng_color = ''
1613 loEiPOtd.rng_lbl = ''
1614 loEiPOtd.rng_pack = ''
1615 Endif
1616 *=== TR 1019697 NH
1617 Endif
1618
1619 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1620 * only replace our SKU when no range style explosion happen
1621 *--- TechRec 1005163 17-May-2004 GS ---
1622 *If empty(&pceipoTD..rng_style)
1623 * Replace division With loEiPOtd.division, ;
1624 * style With loEiPOtd.style, ;
1625 * color_code With loEiPOtd.color_code, ;
1626 * lbl_code With loEiPOtd.lbl_code, ;
1627 * dimension With loEiPOtd.dimension, ;
1628 * sizebucket With loEiPOtd.sizebucket, ;
1629 * size_desc With loEiPOtd.size_desc, ;
1630 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1631 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1632 * In (pceipoTD)
1633 *Endif
1634 *- 1009508 3/16/05 YIK
1635 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1636 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1637 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1638 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1639 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1640
1641 Gather Name loEiPOtd Memo
1642 Endif
1643 *=== TechRec 1005163 17-May-2004 GS ===
1644
1645 Endscan
1646 Use In tmpCurs
1647
1648 If This.lUserInterface
1649 * Reset Thermometer
1650 This.ResetThermo()
1651 Endif
1652
1653 If Used("tmpCstdr")
1654 Use In tmpCstdr
1655 Endif
1656 If Used("tmpUpcnr")
1657 Use In tmpUpcnr
1658 ENDIF
1659
1660 *- 1040686
1661 USE IN SELECT("tcCustUpc")
1662 USE IN SELECT("tmpCstdr_upc")
1663 USE IN SELECT("tcDistUpc")
1664 USE IN SELECT("tmpUpcnr")
1665 *- 1040686
1666
1667 Select(lnOldSelect)
1668 Return llRetVal
1669 Endproc
1670
1671 *----------------------------------------------------------------------------------
1672
1673 *--- TR 1035223 NH
1674 PROCEDURE ClearErrorsForSkipSlnCheck
1675 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1676
1677 LOCAL llRetVal, lnOldSelect
1678 lnOldSelect = SELECT()
1679 llRetVal = .t.
1680
1681 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1682 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1683
1684 *--- TR 1038353 NH
1685 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'
1686 *=== TR 1038353 NH
1687
1688 Select(lnOldSelect)
1689 Return llRetVal
1690 Endproc
1691
1692 *----------------------------------------------------------------------------------
1693
1694 PROCEDURE SetupSkipSLNCheck
1695 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1696
1697 LOCAL lnOldSelect, llRetVal
1698 lnOldSelect = SELECT()
1699 llRetVal = .t.
1700 *--- take division from trans detail
1701 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1702 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1703 inner join (pceipoCR) r on r.customer = th.customer AND r.division = td.division ;
1704 WHERE th.customer > '' AND td.division > ''
1705
1706 *--- Setup in pceipoTS
1707 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1708 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1709
1710 Select(lnOldSelect)
1711 Return llRetVal
1712
1713 Endproc
1714 *=== TR 1035223 NH
1715
1716 *----------------------------------------------------------------------------------
1717
1718 *--- TR 1023892 NH
1719 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1720 PROCEDURE Populate_Cust_lbl
1721 LPARAMETERS pcTransHeader, pcTransDetail
1722 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1723 llRetVal = .t.
1724 lnOldSelect = SELECT()
1725 lcSQLString = ""
1726 lcFkeySku = ""
1727 lcCust_lbl = ""
1728
1729
1730 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl ;
1731 FROM (pcTransHeader) h, (pcTransDetail) d ;
1732 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1733 and d.lbl_code = '' ;
1734 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1735
1736 IF RECCOUNT("__TmpCursor") = 0
1737 *-- no valid style to process
1738 this.LogEntry("No detail record found to populate customer label.")
1739 SELECT(lnOldSelect)
1740 RETURN llRetVal
1741 ENDIF
1742
1743 WITH this
1744 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1745 .cSQLTempTable = ""
1746 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1747 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1748 lcCustSku = "#CustSku" + SYS(2015)
1749
1750 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1751 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1752 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1753 *--- Used sc.Division instead of c.Division.
1754 TEXT TO lcSQLString NOSHOW
1755 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1756 case when d.orig_lbl <> '' then d.orig_lbl
1757 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1758 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1759 else d.lbl_code end as cust_lbl
1760 FROM #Temp d INNER JOIN zzeipocr_expl c on d.customer = c.customer and d.division = c.division
1761 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1762 AND sc.style = d.style AND sc.color_code = d.color_code
1763 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1764 ENDTEXT
1765
1766 lcCustLbl = SYS(2015)
1767 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1768 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1769 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1770 IF llRetVal
1771 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1772 SELECT(pcTransDetail)
1773 lcZzeipotd_order = ORDER()
1774 SET ORDER TO fkeySku
1775 SELECT (lcCustLbl)
1776 SCAN
1777 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1778 lcCust_lbl = Cust_lbl
1779 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1780 SELECT(pcTransDetail)
1781 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1782 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1783 ENDSCAN
1784 ENDIF
1785 ENDSCAN
1786 SELECT(pcTransDetail)
1787 SET ORDER TO (lcZzeipotd_order)
1788 ENDIF
1789 ENDWITH
1790 SELECT(lnOldSelect)
1791 RETURN llRetVal
1792 ENDPROC
1793
1794 *-----------------------------------------------------------------------------------
1795 *=== TR 1023892 NH
1796
1797 ************************************************************************************
1798 * Validate EAN for all details
1799 * Created on 03/24/04 - BD- TR 1003801
1800 ************************************************************************************
1801 Procedure CheckEAN
1802 Lparameters pceipoTH, pceipoTD,;
1803 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1804 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1805
1806 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1807 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1808 lnSize_desc, llSLN
1809 llRetVal = .T.
1810 lcErrs_Msg= ""
1811 lnOldSelect = Select()
1812
1813 *--- TR 1061652 05/18/12 ATHIRUNAVU
1814 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1815 FROM (pceipocr) ;
1816 GROUP BY customer ;
1817 INTO CURSOR __ResvCustSKU
1818 *=== TR 1061652 05/18/12 ATHIRUNAVU
1819
1820 *- Check EAN only if customer is empty
1821 *--- TechRec 1005163 17-May-2004 GS ---
1822 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1823 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1824 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1825 *Order by h.customer, d.ean Into Cursor tmpCurs
1826
1827 *---- TR 1024667 NSD 5/31/07
1828 * If sizebucket = 0 then re-resolve.
1829
1830 If This.oHostProcess.lHaveSLN
1831 *--- TR 1061652 05/18/12 ATHIRUNAVU
1832 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1833 Select h.customer,;
1834 d.ean,;
1835 d.pkey, ;
1836 r.ResvCustSKU, ;
1837 (pceipoTD) As Src;
1838 FROM (pceipoTD) d ;
1839 JOIN (pceipoTH) h ;
1840 ON h.pkey = d.fkey ;
1841 JOIN __ResvCustSKU r ;
1842 ON r.Customer = H.Customer ;
1843 WHERE !Empty(d.ean) ;
1844 AND !Empty(h.customer) ;
1845 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1846 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1847 Union All ;
1848 SELECT h.customer,;
1849 s.SLN_EAN As ean,;
1850 s.pkey, ;
1851 r.ResvCustSKU, ;
1852 (pceipoTS) As Src;
1853 FROM (pceipoTD) d ;
1854 JOIN (pceipoTH) h ;
1855 ON h.pkey = d.fkey ;
1856 JOIN (pceipoTS) s ;
1857 ON s.fkey = d.pkey ;
1858 JOIN __ResvCustSKU r ;
1859 ON r.Customer = H.Customer ;
1860 WHERE !Empty(s.SLN_EAN) ;
1861 AND !Empty(h.customer) ;
1862 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1863 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1864 ORDER By 1, 2 ;
1865 INTO Cursor tmpCurs
1866 Else
1867 *--- TR 1061652 05/18/12 ATHIRUNAVU
1868 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1869 Select h.customer,;
1870 d.ean,;
1871 d.pkey, ;
1872 r.ResvCustSKU, ;
1873 (pceipoTD) As Src;
1874 FROM (pceipoTD) d ;
1875 JOIN (pceipoTH) h ;
1876 ON h.pkey = d.fkey ;
1877 JOIN __ResvCustSKU r ;
1878 ON r.Customer = H.Customer ;
1879 WHERE !Empty(d.ean) ;
1880 AND !Empty(h.customer) ;
1881 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1882 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1883 Order By h.customer, d.ean ;
1884 INTO Cursor tmpCurs
1885 Endif
1886 *=== TechRec 1005163 17-May-2004 GS ===
1887
1888 lcOldCust = ""
1889 lcOldItem = ""
1890 Select tmpCurs
1891 If This.lUserInterface
1892 * Init Thermometer
1893 This.UpdateThermoCaption("Validating EAN(s)...")
1894 This.InitThermo(RecCount('tmpCurs'))
1895 l_nThermoCnt = 0
1896 Endif
1897 Scan
1898 If This.lUserInterface
1899 * Advance progress bar, if we're using one.
1900 l_nThermoCnt = l_nThermoCnt + 1
1901 This.AdvanceThermo(l_nThermoCnt)
1902 Endif
1903 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
1904 lcErrs_Msg = ""
1905 lcOldCust = tmpCurs.customer
1906 lcOldItem = tmpCurs.ean
1907 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1908 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1909
1910 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
1911 lcDivision = tmpCstdr.division
1912 lcStyle = tmpCstdr.Style
1913 lcColor_code = tmpCstdr.color_code
1914 lcLbl_code = tmpCstdr.lbl_code
1915 lcDimension = tmpCstdr.Dimension
1916 lnSizeBucket = tmpCstdr.size_bk
1917 lnSize_desc = tmpCstdr.size_desc
1918 Else
1919
1920 *--- TR 1061652 05/18/12 ATHIRUNAVU
1921 IF ResvCustSKU <> 'Y'
1922 *=== TR 1061652 05/18/12 ATHIRUNAVU
1923
1924 lcErrs_Msg = ""
1925 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
1926 lcDivision = tmpUpcnr.division
1927 lcStyle = tmpUpcnr.Style
1928 lcColor_code = tmpUpcnr.color_code
1929 lcLbl_code = tmpUpcnr.lbl_code
1930 lcDimension = tmpUpcnr.Dimension
1931 lnSizeBucket = tmpUpcnr.sizebucket
1932 lnSize_desc = tmpUpcnr.size_desc
1933 Else
1934 lcErrs_Msg = lcErrs_Msg + CRLF
1935 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1936 Store 0 To lnSizeBucket
1937 Endif
1938
1939 *--- TR 1061652 05/18/12 ATHIRUNAVU
1940 ELSE
1941 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
1942 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1943 STORE 0 TO lnSizeBucket
1944 ENDIF
1945 *=== TR 1061652 05/18/12 ATHIRUNAVU
1946
1947 Endif
1948 Endif && level break
1949
1950 *--- TechRec 1005163 17-May-2004 GS ---
1951 *Select (pceipoTD)
1952 llSLN = (tmpCurs.Src = pceipoTS)
1953 If llSLN
1954 Select (pceipoTS)
1955 Else
1956 Select (pceipoTD)
1957 Endif
1958 *=== TechRec 1005163 17-May-2004 GS ===
1959
1960 *- 1010682 04/25/05 YIK
1961 *- Locate For pkey = tmpCurs.pkey
1962 lnWorkArea = Select()
1963 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1964 Scatter Name loEiPOtd Memo
1965 If !Empty(lcErrs_Msg)
1966 *--- TechRec 1005163 17-May-2004 GS ---
1967 If llSLN
1968 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1969 loEiPOtd.Errs_Flg_S = "Y"
1970 Else
1971 *=== TechRec 1005163 17-May-2004 GS ===
1972 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1973 loEiPOtd.Errs_Flg_D = "Y"
1974 Endif &&--- TechRec 1005163 17-May-2004 GS ===
1975 Endif
1976 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1977 loEiPOtd.division = lcDivision
1978 loEiPOtd.Style = lcStyle
1979 loEiPOtd.color_code = lcColor_code
1980 loEiPOtd.lbl_code = lcLbl_code
1981 loEiPOtd.Dimension = lcDimension
1982 loEiPOtd.sizebucket = lnSizeBucket
1983 loEiPOtd.size_desc = lnSize_desc
1984 Endif
1985
1986 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1987 * only replace our SKU when no range style explosion happen
1988 *--- TechRec 1005163 17-May-2004 GS ---
1989 *If empty(&pceipoTD..rng_style)
1990 * Replace division With loEiPOtd.division, ;
1991 * style With loEiPOtd.style, ;
1992 * color_code With loEiPOtd.color_code, ;
1993 * lbl_code With loEiPOtd.lbl_code, ;
1994 * dimension With loEiPOtd.dimension, ;
1995 * sizebucket With loEiPOtd.sizebucket, ;
1996 * size_desc With loEiPOtd.size_desc, ;
1997 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1998 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1999 * In (pceipoTD)
2000 *- 1009508 3/16/05 YIK
2001 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
2002 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
2003
2004 Gather Name loEiPOtd Memo
2005 *=== TechRec 1005163 17-May-2004 GS ===
2006 Endif
2007 Endscan
2008 Use In tmpCurs
2009
2010 If This.lUserInterface
2011 * Reset Thermometer
2012 This.ResetThermo()
2013 Endif
2014
2015 If Used("tmpCstdr")
2016 Use In tmpCstdr
2017 Endif
2018 If Used("tmpUpcnr")
2019 Use In tmpUpcnr
2020 Endif
2021
2022 Select(lnOldSelect)
2023 Return llRetVal
2024 Endproc
2025
2026 *-----------------------------------------------------------------------------------
2027
2028 *--- 39222 5/1/03 YIK
2029 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
2030 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
2031 *- matches the sku sent in transmission.
2032
2033 *--- TechRec 1005163 17-May-2004 GS:
2034 *- Combined ConfirmUPC and ConfirmEAN
2035
2036 Procedure ConfirmSku
2037 Lparameters pceipoTH, pceipoTD, pceipoCR,;
2038 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
2039
2040 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
2041 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
2042 lcSku, lcErrs_Msg, llSLN
2043
2044 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
2045 llRetVal = .T.
2046 lcErrs_Msg= ""
2047
2048 *--- TR 1085322 24-Sep-2015 Goutam
2049 LOCAL llCustStyleDupeCheck, llCustStyleFound,lcStyle, lcColor, lcLabel
2050 *=== TR 1085322 24-Sep-2015 Goutam
2051
2052 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2053 lcWarnMsg = ""
2054 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2055
2056 lnOldSelect = Select()
2057
2058 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
2059
2060 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
2061 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
2062 *- 1003788 2/25/04 YIK
2063 *- use d.division, not h.division which is still empty
2064
2065 *--- TechRec 1005163 17-May-2004 GS ---
2066 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2067
2068 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2069 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2070 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2071 *--- TR 1078000 16-4-2014 VKK Added cust_size
2072 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2073 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass, cust_size ;
2074 from (pceipoTD) Into Cursor __eipoTD
2075
2076 If This.oHostProcess.lHaveSLN
2077 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2078 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2079 *--- TR 1078000 16-4-2014 VKK Added cust_size
2080 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2081 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass, cust_size From (pceipoTS) Into Cursor __EiPOts
2082 Endif
2083 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2084 *--- NH - 08/10/07
2085 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2086 Select(lnOldSelect)
2087 RETURN llRetVal
2088 ENDIF
2089 *=== TR 1022625
2090
2091 With This
2092 .cSQLTempTable = ""
2093 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2094 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2095 lceipoTD_tmp = .cSQLTempTable
2096 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2097
2098 If This.oHostProcess.lHaveSLN
2099 .cSQLTempTable = ""
2100 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2101 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2102 lceipoTS_tmp = .cSQLTempTable
2103 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2104 Endif
2105 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2106 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2107 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2108 ENDWITH
2109
2110
2111 This.MakeCursorWritable("tmpCursR","tmpCurs")
2112 *=== TR 1019697 NH
2113 *=== TechRec 1005163 17-May-2004 GS ===
2114
2115 *-FH 1103931 - Grab sql from GetConfrimSkuSql, lets make a temp table from it.
2116 LOCAL lcTemptbl
2117 lcTemptbl = SQLTableFromQuery(lcSQL)
2118 *-FH 1103931
2119
2120 *--- TR 1085322 24-Sep-2015 Goutam
2121 * FH 1103931 - Let's use lcTemptbl, instead of lceipoTD_tmp( lceipoTD_tmp is all of DTL, lcTemptbl will only be confirm sku)
2122 *- - also add distinct
2123 IF llRetVal AND !EMPTY(lcTemptbl)
2124 lcSql = "select distinct b.cust_style, b.division, b.style, b.color_code, b.lbl_code, b.dimension, b.size_bk " +;
2125 " from " + lcTemptbl + " a join zzxcstdr b " +;
2126 " on a.sku = b.cust_style"
2127
2128 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpBCSKUCurs")
2129 IF llRetVal
2130 SELECT tmpBCSKUCurs
2131 INDEX on cust_style+division+style+color_code+lbl_code+dimension+STR(size_bk) TAG cust_style
2132 SET ORDER TO
2133 ENDIF
2134 ENDIF
2135 *=== TR 1085322 24-Sep-2015 Goutam
2136
2137 .LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2138 Select tmpCurs
2139 If This.lUserInterface
2140 * Init Thermometer
2141 This.UpdateThermoCaption("Comparing SKU(s)...")
2142 This.InitThermo(RecCount('tmpCurs'))
2143 l_nThermoCnt = 0
2144 Endif
2145 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2146 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2147 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2148 *=== TR 1019697 NH
2149
2150 *-1040686
2151 *=-=-=-=-=-=-=-=-=-=
2152 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2153 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2154 IF llRetVal
2155 .PopulateSQLTempTable("tcDistCustSku")
2156 ENDIF
2157 llRetVal = llRetVal AND v_sqlexec(;
2158 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2159 " , d.aux_sku, d.pkey " +;
2160 " FROM zzxcstdr d"+ ;
2161 " JOIN " + this.cSQLTempTable + " x " + ;
2162 " ON d.customer = x.customer " +;
2163 " AND d.division = x.division " + ;
2164 " AND d.style = x.style " + ;
2165 " AND d.color_code = x.color_code " + ;
2166 " AND d.lbl_code = x.lbl_code " + ;
2167 " AND d.dimension = x.dimension " + ;
2168 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2169 SELECT tmpCstdr
2170 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2171 INDEX on cust_style TAG custsty && TR 1085322 KISHORE 22-SEP-2015
2172
2173 *=-=-=-=-=-=-=-=-=-=
2174
2175 * TR 1085322 KISHORE 12-MAR-2015
2176 llCustStyleDupeCheck = (goEnv.sv("CUST_STYLE_DUPE_CHECK","N") = "Y")
2177
2178 SELECT tmpCurs
2179 *- 1040686
2180
2181
2182 Local lnSizeBk
2183 lnSizeBk = 0
2184 SCAN
2185 llCustStyleFound = false &&*--- TR 1085322 24-Sep-2015 Goutam
2186
2187 If This.lUserInterface
2188 * Advance progress bar, if we're using one.
2189 l_nThermoCnt = l_nThermoCnt + 1
2190 This.AdvanceThermo(l_nThermoCnt)
2191 Endif
2192 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2193 lcErrs_Msg = ""
2194 *=== TechRec 1005163 17-May-2004 GS, YK ===
2195
2196 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2197 lcWarnMsg = ""
2198 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2199
2200 *-1040686
2201 *=-=-=-=-=-=-=-=-=-
2202 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2203 DIMENSION, sizebucket, "tmpCstdr")
2204 lcSku = ""
2205 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2206 lcSku = tmpCstdr.cust_style
2207 ELSE
2208 lcErrs_Msg = "Missing SKU code."
2209 ENDIF
2210 *=-=-=-=-=-=-=-=-=-
2211 *-1040686
2212
2213 *--- TR 1085322 24-Sep-2015 Goutam.
2214 *Note: Cust_sku must be unique in zzxcstdr if the system parameter CUST_STYLE_DUPE_CHECK = ‘Y’
2215 IF SEEK(tmpCurs.sku, "tmpBCSKUCurs", "cust_style")
2216 lcStyle = ALLTRIM(tmpBCSKUCurs.style)
2217 lcColor = ALLTRIM(tmpBCSKUCurs.color_code)
2218 lcLabel = ALLTRIM(tmpBCSKUCurs.lbl_code)
2219 IF llCustStyleDupeCheck AND !SEEK(tmpCurs.sku+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpBCSKUCurs", "cust_style")
2220 lcErrs_Msg = "Customer Style " + ALLTRIM(tmpCurs.sku) + " already exists for Style " + lcstyle + ", Color " + lcColor + " and label " + lcLabel
2221 llCustStyleFound = true
2222 ENDIF
2223
2224 *--- TR 1095258 04/28/16 ATHIRUNAVU Added tmpcurs.customer
2225 *IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2226 IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2227 *=== TR 1095258 04/28/16 ATHIRUNAVU
2228 Replace AddCustSKU With .T. In (tmpCurs.Src)
2229 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2230 llCustStyleFound = true
2231 *--- TR-1098891 4-Oct-2016 JPaul. lcErrs_Msg should be cleared
2232 lcErrs_Msg= ''
2233 *=== TR-1098891 4-Oct-2016 JPaul.
2234 ENDIF
2235 ENDIF
2236 *=== TR 1085322 24-Sep-2015 Goutam
2237
2238 IF !llCustStyleFound &&*--- TR 1085322 24-Sep-2015 Goutam
2239 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2240 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2241 If !(lcSku == tmpCurs.sku)
2242 * TR 1085322 KISHORE 12-MAR-2015 added OR Upd_CustSku = 'Y'
2243 If (Empty(lcSku) And GenCustSKU = 'Y') OR Upd_CustSku = 'Y'
2244 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2245
2246 *--- TR 1085322 24-Sep-2015 Goutam
2247 IF Upd_CustSku = 'Y'
2248 IF SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.Style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.DIMENSION+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku") ;
2249 AND (tmpCurs.SKU <> tmpCstdr.cust_style)
2250
2251 lcSQL = "Update zzxcstdr set cust_style = " + SQLFormatChar(tmpCurs.sku) + ;
2252 ", last_mod = " + SQLFormatTs(DATETIME()) + ", user_id = " + SQLFormatChar(EDI_USER) + ;
2253 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2254 llRetVal = llRetVal And v_SqlExec(lcSQL)
2255 ENDIF
2256 ELSE
2257 *=== TR 1085322 24-Sep-2015 Goutam
2258 Replace AddCustSKU With .T. In (tmpCurs.Src)
2259 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2260
2261 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2262
2263 lcErrs_Msg = ""
2264 Else
2265 If Confirm_SKU = 'Y'
2266 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2267 Else
2268 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2269 CRLF + "Unable to generate new customer Sku." + CRLF
2270 Endif
2271 ENDIF
2272 *--- TR 1061151 2-MAY-12 Venuk.
2273 Else
2274 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2275 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2276 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2277 v_SqlExec(lcSQL)
2278 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2279 ELSE
2280 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2281 lcWarnMsg = "Aux sku already exist."
2282 ENDIF
2283 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2284 ENDIF
2285 *=== TR 1061151 2-MAY-12 Venuk.
2286 Endif
2287
2288 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2289
2290 *--- TechRec 1005163 17-May-2004 GS ---
2291 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2292 * Replace ;
2293 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2294 * Errs_Flg_D With "Y" ;
2295 * In (pceipoTD)
2296
2297 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2298 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2299 llSLN = (tmpCurs.Src = pceipoTS)
2300 If llSLN
2301 Select (pceipoTS)
2302 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2303 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2304 IF !EMPTY(lcErrs_Msg)
2305 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2306 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2307 Replace ;
2308 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2309 Errs_Flg_S With "Y"
2310 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2311 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2312 Errs_Flg_D With 'Y' In (pceipoTD)
2313 Endif
2314 ENDIF
2315 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2316 ELSE
2317 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2318 Warn_Flg_D With "Y" In (pceipoTD)
2319 ENDIF
2320 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2321 Else
2322 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2323 Select (pceipoTD)
2324 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2325 IF !EMPTY(lcErrs_Msg)
2326 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2327 Replace ;
2328 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2329 Errs_Flg_D With "Y"
2330 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2331 ELSE
2332 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2333 Warn_Flg_D With "Y"
2334 ENDIF
2335 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2336 Endif
2337 *=== TechRec 1005163 17-May-2004 GS ===
2338 Endif
2339 ENDSCAN
2340 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2341 *--- TR 1019697 NH :
2342 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2343 *=== TR 1019697 NH
2344 Use In tmpCurs
2345
2346 If This.lUserInterface
2347 * Reset Thermometer
2348 This.ResetThermo()
2349 Endif
2350
2351 If Used("tmpCstdr")
2352 Use In tmpCstdr
2353 ENDIF
2354
2355 *--- TR 1085322 24-Sep-2015 Goutam
2356 USE IN SELECT("tmpBCSKUCurs")
2357 *=== TR 1085322 24-Sep-2015 Goutam
2358
2359 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2360
2361 Select(lnOldSelect)
2362 Return llRetVal
2363 Endproc
2364
2365 *-----------------------------------------------------------------------------------
2366
2367 *--- TR 1019697 NH
2368 **************************************************************************************
2369 Procedure GetConfrimSkuSql
2370 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2371 Local lcSQL, lcSqlSln, lnOldSelect
2372 lnOldSelect = Select()
2373
2374 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2375 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2376
2377 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2378 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2379 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2380 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2381 *--- TR 1078000 16-4-2014 VKK Added cust_size
2382 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2383 lcSQL = ;
2384 "select d.customer"+;
2385 " , d.division"+;
2386 " , d.sku"+;
2387 " , d.STYLE"+;
2388 " , d.color_code"+;
2389 " , case"+;
2390 " when r.rng_style is null"+;
2391 " and d.lbl_code = ''"+;
2392 " and c.resv_label = 'Y' then c.lbl_code"+;
2393 " when r.rng_style is null"+;
2394 " and d.lbl_code = ''"+;
2395 " and c.resv_label = 'V'"+;
2396 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2397 " else d.lbl_code"+;
2398 " end as lbl_code"+;
2399 " , d.lbl_code as lbl_codeOrig"+;
2400 " , c.resv_label"+;
2401 " , d.DIMENSION"+;
2402 " , d.Sizebucket"+;
2403 " , d.upc"+;
2404 " , d.pkey"+;
2405 " , C.GenCustSKU"+;
2406 " , C.Confirm_SKU"+;
2407 " , C.upd_custsku " + ;
2408 " , 'N' as AddCustSKU"+;
2409 " , d.size_desc"+;
2410 " , '" + Trim(pceipoTD) + "' as Src"+;
2411 " , d.aux_sku " + ;
2412 " , d.subclass " + ;
2413 " , d.cust_size " + ;
2414 " from " + pceipoTD_tmp + " d"+;
2415 " join " + This.c850Control + " C"+;
2416 " on d.customer = C.customer"+;
2417 " and d.division = C.division"+;
2418 " left join zzxrangh r"+;
2419 " on r.division = d.division"+;
2420 " and r.rng_style = d.style"+;
2421 " and r.rng_color = d.color_code"+;
2422 " and r.rng_lbl = d.lbl_code"+;
2423 " and r.rng_pack = d.dimension"+;
2424 " left join zzxscolr sc"+;
2425 " on sc.division = d.division"+;
2426 " and sc.style = d.style"+;
2427 " and sc.color_code = d.color_code"+;
2428 " and sc.lbl_code = c.lbl_code"+;
2429 " and sc.dimension = d.dimension"+;
2430 " where d.customer > ''"+;
2431 " and d.SKU > ''"+;
2432 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2433 " and d.Division > ''"+;
2434 " and d.Style > ''"+;
2435 " and d.Color_Code > ''"+;
2436 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2437 " and d.Rng_Style = '' "
2438
2439 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2440 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2441 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2442 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2443 *--- Used sc.Division instead of c.Division.
2444 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2445 *--- TR 1078000 16-4-2014 VKK Added cust_size
2446 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2447 *- TR 1098656 FH - change to s.Division
2448 lcSqlSln = ;
2449 "select d.Customer"+;
2450 " , s.Division"+;
2451 " , s.SLN_SKU as sku"+;
2452 " , s.STYLE"+;
2453 " , s.Color_Code"+;
2454 " , case when s.Lbl_Code = ''"+;
2455 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2456 " when s.Lbl_Code = ''"+;
2457 " and c.Resv_Label = 'V'"+;
2458 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2459 " else s.lbl_code"+;
2460 " end as lbl_code"+;
2461 " , s.lbl_code as lbl_codeOrig"+;
2462 " , c.resv_label"+;
2463 " , s.DIMENSION"+;
2464 " , s.Sizebucket"+;
2465 " , s.SLN_UPC as upc"+;
2466 " , s.pkey"+;
2467 " , C.GenCustSKU"+;
2468 " , C.Confirm_SKU"+;
2469 " , C.upd_custsku " + ;
2470 " , 'N' as AddCustSKU"+;
2471 " , s.size_desc"+;
2472 " , '" + Trim(pceipoTS) + "' as Src"+;
2473 " , s.aux_sku " + ;
2474 " , s.subclass " + ;
2475 " , s.cust_size " + ;
2476 " from " + pceipoTD_tmp + " d"+;
2477 " join " + pceipoTS_tmp + " s"+;
2478 " on s.fkey = d.pkey"+;
2479 " join " + This.c850Control + " C"+;
2480 " on d.customer = C.customer"+;
2481 " and d.division = C.division"+;
2482 " left join zzxscolr sc"+;
2483 " on sc.division = d.division"+;
2484 " and sc.style = s.style"+;
2485 " and sc.color_code = s.color_code"+;
2486 " and sc.lbl_code = c.lbl_code"+;
2487 " and sc.dimension = s.dimension"+;
2488 " where d.Customer > ''"+;
2489 " and s.SLN_SKU > ''"+;
2490 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2491 " and d.Division > ''"+;
2492 " and s.Style > ''"+;
2493 " and s.Color_Code > ''"+;
2494 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2495 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2496 Endif
2497
2498 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2499 Select(lnOldSelect)
2500 Return lcSQL
2501 Endproc
2502
2503 *-----------------------------------------------------------------------------------
2504
2505 Procedure CreateOurSkuFromTmpCurs
2506 If Not Used("TmpCurs")
2507 Return .F.
2508 Endif
2509 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2510 llRetVal = .T.
2511 lnOldSelect = Select()
2512 With This
2513 Select tmpCurs
2514 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2515
2516 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2517 lcDistSku = Getuniquefilename()
2518 lcExistingSku = Getuniquefilename()
2519 lcCustLbl = Getuniquefilename()
2520
2521 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2522 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2523 *- We need this because cursor lcCustLbl has customer field.
2524 *- 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
2525 *- with auto_style = 'Y', we will add both auto_style twice.
2526
2527 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2528 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2529 *- because style exists in zzxscolr (we just addeded)
2530 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2531 *- so we will add it twice by accident.
2532
2533 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2534 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2535 *-FH 1066967
2536
2537
2538 *-FH 1066967 - added customer
2539 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2540 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2541 IF llRetVal
2542 .PopulateSQLTempTable(lcDistSku)
2543 ENDIF
2544
2545 llRetVal = llRetVal AND v_sqlexec(;
2546 "SELECT x.* "+;
2547 " FROM zzxscolr d"+ ;
2548 " JOIN " + this.cSQLTempTable + " x " + ;
2549 " ON d.division = x.division " +;
2550 " AND d.style = x.style " + ;
2551 " AND d.color_code = x.color_code " + ;
2552 " AND d.lbl_code = x.lbl_code " + ;
2553 " AND d.dimension = x.dimension " ,lcExistingSku )
2554 SELECT (lcExistingSku)
2555 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2556
2557 IF llRetVal
2558 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2559 ENDIF
2560
2561 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2562 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2563 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2564 SELECT(lcCustLbl)
2565 INDEX on customer + lbl_code TAG cust_lbl
2566
2567 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2568 SELECT (lcDistSku) && FH 1066967
2569 Scan
2570 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2571 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2572 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2573*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2574*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2575*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2576*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2577*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2578*!* Else
2579*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2580*!* Endif
2581*!* ENDIF
2582
2583 IF NOT EMPTY(&lcDistSku..lbl_code)
2584 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2585 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2586 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2587 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2588
2589 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2590 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2591 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2592 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2593
2594 .oLog.LogEntry("Created style: " + lcOurSKU )
2595 Else
2596 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2597 ENDIF
2598 ENDIF
2599 Endif
2600 ENDIF
2601
2602 ENDSCAN
2603 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2604
2605 USE IN SELECT(lcDistSku)
2606 USE IN SELECT(lcExistingSku)
2607 USE IN SELECT(lcCustLbl)
2608
2609 USE IN SELECT('lcStyleAdded') && FH 1066967
2610
2611 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2612 Endwith
2613 Select (lnOldSelect)
2614 Return llRetVal
2615 Endproc
2616
2617 *-----------------------------------------------------------------------------------
2618
2619 Procedure GenerateCustomerSkuFromCursor
2620 Parameters tcSkuCursor
2621 Local lnOldSelect, llRetVal
2622 llRetVal = .T.
2623 lnOldSelect = Select()
2624
2625 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2626 lcPrevSkuIpotd = ""
2627 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2628 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2629 *--- TR 1078000 16-4-2014 VKK Added cust_size
2630 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2631 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2632 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2633 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2634
2635 With This
2636 lnCount = Reccount("tmpCurs1")
2637
2638 If lnCount = 0
2639 Select (lnOldSelect)
2640 Return
2641 Endif
2642
2643 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2644 Select (lnOldSelect)
2645 Return
2646 Endif
2647
2648 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2649 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2650 lnCount = lnCount - 1
2651 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2652 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2653
2654 Select VZZXCSTHR
2655 Scatter Memvar Blank
2656 Select VZZXCSTDR
2657 Scatter Memvar Blank
2658
2659 m.Last_mod = Datetime()
2660 m.User_id = 'CGSADMIN'
2661 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2662
2663 * --- TR 1039603 4/6/09 CM
2664 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2665 m.active_ok = 'Y'
2666 m.anti_theft = 'N'
2667 * === TR 1039603 4/6/09 CM
2668
2669 m.notes = ''
2670
2671 lcPrevSKU = ' '
2672
2673 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2674 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2675 Select("tmpCursSrc")
2676 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2677 Scan
2678 Select (Alltrim(tmpCursSrc.Src))
2679 lcOldOrder = Order()
2680 Set Order To CstBcSku
2681 Replace oldOrder With lcOldOrder In tmpCursSrc
2682 ENDSCAN
2683 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2684
2685 Select tmpCurs1
2686 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2687 Scan
2688 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2689 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2690 *--- TR 1078000 16-4-2014 VKK Added cust_size
2691 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2692 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2693 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2694 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2695 If lcPrevSKU # lcSku
2696 lcPrevSKU = lcSku
2697 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2698 If Empty(lnHDRpKey)
2699 lnHDRpKey = lnCstHrPkey
2700 Insert Into VZZXCSTHR From Memvar
2701 Replace pkey With lnHDRpKey In VZZXCSTHR
2702 Endif
2703 Endif
2704 *--- clear AddCustSKU for all matching rows in zzeipotd
2705 Select (tmpCurs1.Src)
2706 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2707 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2708 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2709 Endscan
2710 lcPrevSkuIpotd = lcSkuIpotd
2711
2712 *-TR 1059834 FH -moved in IF statement
2713 Select tmpCurs1
2714 Insert Into VZZXCSTDR From Memvar
2715 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2716 lnCstDrPkey = lnCstDrPkey +1
2717 lnCstHrPkey = lnCstHrPkey +1
2718 *-TR 1059834 FH -moved in IF statement
2719
2720 Endif
2721 ENDSCAN
2722 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2723 Select("tmpCursSrc")
2724 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2725 Scan
2726 Select (Alltrim(tmpCursSrc.Src))
2727 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2728* If Not Empty(lcOldOrder)
2729 Set Order To (lcOldOrder)
2730* Endif
2731 ENDSCAN
2732 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2733 Use In tmpCursSrc
2734
2735 Dimension laTables[2]
2736 laTables[1]= "VZZXCSTHR"
2737 laTables[2]= "VZZXCSTDR"
2738
2739 llBeganTransaction = .BeginTransaction()
2740 llRetVal = .Tableupdate(@laTables)
2741
2742 If llRetVal
2743 If llBeganTransaction
2744 This.EndTransaction()
2745 Endif
2746 Else
2747 If llBeganTransaction
2748 This.RollbackTransaction()
2749 Endif
2750 Endif
2751 Endwith
2752 If Used("tmpCurs1")
2753 Use In tmpCurs1
2754 Endif
2755 Select(lnOldSelect)
2756 Return llRetVal
2757 Endproc
2758
2759 *-----------------------------------------------------------------------------------
2760 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2761
2762 Function GenerateRBACustSKU
2763 Lparameters pceipoTH,pceipoTD
2764
2765 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2766 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2767
2768
2769 llRetVal = True
2770 lnSelect = Select()
2771 lcRBADivision = 'TFG'
2772 With This
2773
2774 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2775
2776 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2777 *- 12/12/06 YIK
2778 *- No distinct since includes pkey. Change order.
2779 *-- SELECT DISTINCT ;
2780 *-- h.customer,;
2781 *-- lcRBADivision as division,;
2782 *-- d.pkey as dtlpkey ,;
2783 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2784 *-- d.color_code,;
2785 *-- .GetCustLabel(h.customer) as lbl_code,;
2786 *-- "" as DIMENSION,;
2787 *-- h.store as cust_store ,;
2788 *-- d.sku as cust_style ,;
2789 *-- d.price as cust_price , ;
2790 *-- d.size_desc, ;
2791 *-- 0 as size_bk ;
2792 *-- FROM (pceipoTH) h ;
2793 *-- JOIN (pceipoTD) d ;
2794 *-- ON d.fkey = h.pkey ;
2795 *-- INTO CURSOR __tmpCur ;
2796 *-- ORDER BY 1,2,3,4,5,6
2797
2798 *** Size_BK needs to be 00 and NOT 0
2799 Select ;
2800 h.customer,;
2801 lcRBADivision As division,;
2802 d.pkey As dtlpkey ,;
2803 d.Style As Style, ;
2804 d.color_code,;
2805 .GetCustLabel(h.customer) As lbl_code,;
2806 "" As Dimension,;
2807 h.Store As cust_store ,;
2808 d.sku As Cust_style ,;
2809 d.price As cust_price , ;
2810 d.size_desc, ;
2811 00 As size_bk ;
2812 FROM (pceipoTH) h ;
2813 JOIN (pceipoTD) d ;
2814 ON d.fkey = h.pkey ;
2815 WHERE h.Errs_flg_h < 'Y' And ;
2816 d.Errs_Flg_D < 'Y' ;
2817 INTO Cursor __tmpCur ;
2818 ORDER By 1,2,4,5,6,7, 11
2819 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2820
2821 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2822
2823 lnCount = Reccount("tmpCurs")
2824
2825 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
2826
2827 If lnCount = 0
2828 If Used("tmpCurs")
2829 Use In tmpCurs
2830 Endif
2831 Select (lnSelect)
2832 Return
2833 Endif
2834
2835 Select tmpCurs
2836 *
2837 * Make it a loop for safety
2838 *
2839 Scan
2840 *** .LogEntry("Original Style " + style)
2841 lcStyle = .GetBCStyle(lcRBADivision,Style)
2842 *** .LogEntry("Resolved Style " + lcStyle)
2843 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
2844 Replace Style With lcStyle , size_bk With lnSize_BK
2845 Endscan
2846 .LogEntry("Resolved Styles/Size_BK")
2847
2848 *- 12/12/06 YIK
2849 *- Index just in case somebody changes the SELECT above
2850 Select tmpCurs
2851 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
2852 TAG sku
2853
2854 .LogEntry("Load Customer Style.")
2855
2856 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2857 If Used("tmpCurs")
2858 Use In tmpCurs
2859 Endif
2860 Select (lnSelect)
2861 Return
2862 Endif
2863
2864 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2865 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2866 lnCount = lnCount - 1
2867 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2868 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2869
2870 Select VZZXCSTHR
2871 Scatter Memvar Blank
2872 Select VZZXCSTDR
2873 Scatter Memvar Blank
2874
2875 m.Last_mod = Datetime()
2876 m.User_id = 'CGSADMIN'
2877 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2878 m.notes = ''
2879
2880 lcPrevSKU = ' '
2881 lcPrevSkuSize = ''
2882
2883 *- 12/12/06 YIK
2884 *- inserted details counter
2885 Local lnInsertCount
2886 lnInsertCount = 0
2887
2888 Select tmpCurs
2889
2890 Scan
2891 .LogEntry("Loading Customer Style...")
2892 .LogEntry("Style :" + Style )
2893 .LogEntry("Color_code :" + color_code )
2894
2895 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
2896 .LogEntry("Invalid Style or Color_code or Size_bk " )
2897 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
2898 FOR pkey = dtlpkey In (pceipoTD)
2899 Loop
2900 Endif
2901
2902 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2903 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
2904 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2905 If lcPrevSKU # lcSku
2906 lcPrevSKU = lcSku
2907 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
2908 .LogEntry("Customer :" + m.customer )
2909 .LogEntry("Division : " + m.division)
2910 .LogEntry("Style :" + Style )
2911 .LogEntry("Color_code :" + m.color_code )
2912 .LogEntry("Label code :" + m.lbl_code )
2913 .LogEntry("dimension : " + m.dimension)
2914 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
2915 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2916 If Empty(lnHDRpKey)
2917 lnHDRpKey = lnCstHrPkey
2918 .LogEntry("Inserting into header..")
2919 Insert Into VZZXCSTHR From Memvar
2920 Replace pkey With lnHDRpKey In VZZXCSTHR
2921 Endif
2922 Endif
2923 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
2924 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
2925 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
2926 If Empty(lnDtlKey)
2927 lnDtlpKey = lnCstDrPkey
2928 .LogEntry("Inserting into detail..")
2929 Insert Into VZZXCSTDR From Memvar
2930 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
2931 *- 12/12/06 YIK
2932 lnInsertCount = lnInsertCount + 1
2933 Endif
2934 Endif
2935 lnCstDrPkey = lnCstDrPkey +1
2936 lnCstHrPkey = lnCstHrPkey +1
2937
2938 Endscan
2939
2940 Dimension laTables[2]
2941 laTables[1]= "VZZXCSTHR"
2942 laTables[2]= "VZZXCSTDR"
2943
2944 llBeganTransaction = .BeginTransaction()
2945 llRetVal = .Tableupdate(@laTables)
2946
2947 If llRetVal
2948 If llBeganTransaction
2949 This.EndTransaction()
2950 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
2951 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
2952 Endif
2953 Else
2954 If llBeganTransaction
2955 This.RollbackTransaction()
2956 .LogEntry("Table Update failed - Roll back Transaction " )
2957 Endif
2958 Endif
2959
2960 Endwith
2961
2962 If Used("tmpCurs")
2963 Use In tmpCurs
2964 Endif
2965
2966 Select (lnSelect)
2967 Return llRetVal
2968 Endfunc
2969
2970 *-----------------------------------------------------------------------------------
2971
2972 Function GetBCStyle
2973 Lparameters tcDivision, tcUDFStyle
2974 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
2975
2976 llRetVal = True
2977 lnSelect = Select()
2978 l_vRetVal = ''
2979
2980 lcCursor = GetUniqueFileName()
2981 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
2982 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
2983
2984 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
2985
2986 If llRetVal
2987 Select(lcCursor)
2988 l_vRetVal = Alltrim(Style)
2989 Use In (lcCursor)
2990 Endif
2991
2992 Select (lnSelect)
2993 Return l_vRetVal
2994 Endfunc
2995
2996 *-----------------------------------------------------------------------------------
2997
2998 Function GetSizeBkt
2999 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
3000 p_cKeyField4, p_cKeyField5, p_cKeyField6
3001 Local l_cSQLString, l_vRetVal
3002
3003 l_nOldSele = Select()
3004 pnSizeBucket = 0
3005
3006 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
3007 l_vRetVal = 0
3008 Return l_vRetVal
3009 Endif
3010
3011 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
3012 p_cKeyField2)
3013 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
3014 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
3015 p_cKeyField3, p_cKeyField4, p_cKeyField5)
3016 Select TmpSavlr
3017 For l_n=1 To 24
3018 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
3019 If l_lAlwSz
3020 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
3021 If l_cSize_Desc = p_cKeyField6
3022 ***l_vRetVal = .T.
3023 pnSizeBucket = l_n
3024 Endif
3025 Endif
3026 Endfor
3027 Use In TmpSavlr
3028 Use In TmpSizer
3029 Endif
3030 Endif
3031
3032 l_vRetVal = pnSizeBucket
3033
3034 Select (l_nOldSele)
3035 Return l_vRetVal
3036
3037 Endfunc
3038
3039 *-----------------------------------------------------------------------------------
3040 * Validate SKU for all details
3041 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
3042
3043 Procedure CheckSku
3044 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
3045 Lparameters pceipoTH, pceipoTD,;
3046 pceipoTS, pceipoCR
3047 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
3048 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
3049 lnSize_desc, llSLN
3050
3051 *--- TR 1013117 NH
3052 Local lcSku_resolv
3053 Dimension lasku_resolv[1]
3054 lcSku_resolv = ""
3055 lasku_resolv[1] = ""
3056 *=== TR 1013117 NH
3057
3058 * --- TR 1045305 2/3/10 CM
3059 LOCAL lnSkuPkey
3060 lnSkuPkey = 0
3061 * === TR 1045305 2/3/10 CM
3062
3063
3064 llRetVal = .T.
3065 lcErrs_Msg= ""
3066 lnOldSelect = Select()
3067
3068 * cannot check for SKU if customer is empty
3069 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
3070 * on Cust SKU or UPC.
3071 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
3072
3073 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
3074 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
3075 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
3076
3077 *--- TechRec 1005163 17-May-2004 GS ---
3078 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
3079 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
3080 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
3081 *Order by h.customer, d.sku Into Cursor tmpCurs
3082
3083 *---- TR 1024667 NSD 5/31/07
3084 * If sizebucket = 0 then re-resolve.
3085
3086 If This.oHostProcess.lHaveSLN
3087 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3088 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3089 *!* SELECT h.customer,;
3090 *!* c.sku_resolv, ;
3091 *!* JOIN (pceipoCR) C;
3092 *!* ON d.division= C.division ;
3093 *!* AND h.customer= C.customer ;
3094
3095 *!* c.sku_resolv, ; && after union
3096 *!* JOIN (pceipoCR) C;
3097 *!* ON d.division= C.division ;
3098 *!* AND h.customer= C.customer ;
3099
3100 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3101 Select h.customer,;
3102 h.department, ;
3103 h.Store, ;
3104 d.sku,;
3105 d.upc, ;
3106 d.pkey, ;
3107 (pceipoTD) As Src ;
3108 FROM (pceipoTD) d ;
3109 JOIN (pceipoTH) h ;
3110 ON h.pkey = d.fkey ;
3111 WHERE !Empty(h.customer) ;
3112 AND !Empty(d.sku) ;
3113 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
3114 UNION All ;
3115 SELECT h.customer,;
3116 h.department, ;
3117 h.Store, ;
3118 s.SLN_SKU As sku,;
3119 s.SLN_UPC As upc,;
3120 s.pkey, ;
3121 (pceipoTS) As Src ;
3122 FROM (pceipoTS) s ;
3123 JOIN (pceipoTD) d ;
3124 ON d.pkey = s.fkey ;
3125 JOIN (pceipoTH) h ;
3126 ON h.pkey = d.fkey ;
3127 WHERE !Empty(h.customer) ;
3128 AND !Empty(s.SLN_SKU) ;
3129 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
3130 ORDER By 1, 2 ;
3131 INTO Cursor tmpCurs
3132 *=== TR 1010097 07/27/05 TK
3133 Else
3134 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3135 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3136 *!* SELECT h.customer,;
3137 *!* c.sku_resolv, ;
3138 *!* JOIN (pceipoCR) C;
3139 *!* ON d.division= C.division ;
3140 *!* AND h.customer= C.customer ;
3141 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3142 Select h.customer,;
3143 h.department, ;
3144 h.Store, ;
3145 d.sku,;
3146 d.upc, ;
3147 d.pkey, ;
3148 (pceipoTD) As Src ;
3149 FROM (pceipoTD) d ;
3150 JOIN (pceipoTH) h ;
3151 ON h.pkey = d.fkey ;
3152 WHERE !Empty(h.customer) ;
3153 AND !Empty(d.sku) ;
3154 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3155 Order By h.customer, d.sku ;
3156 INTO Cursor tmpCurs
3157 *=== TR 1010097 07/27/05 TK
3158 Endif
3159 *=== TechRec 1005163 17-May-2004 GS ===
3160
3161*- 1040686
3162 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3163 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3164 IF llRetVal
3165 .PopulateSQLTempTable("tcDistCustSku")
3166 ENDIF
3167 llRetVal = llRetVal AND v_sqlexec(;
3168 "SELECT x.sku,d.* "+;
3169 " FROM zzxcstdr d"+ ;
3170 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3171 " JOIN " + this.cSQLTempTable + " x " + ;
3172 " ON d.customer = x.customer " +;
3173 " AND d.cust_style = x.sku " + ;
3174 " WHERE h.IB_resolv = 'Y'" + ;
3175 " AND d.Size_Desc>'' " + ;
3176 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3177 SELECT tmpCstdr_sku
3178 INDEX ON customer + cust_style TAG cust_sku
3179
3180 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3181 UNION ;
3182 SELECT customer,sku FROM tmpCstdr_sku ;
3183 GROUP BY customer,sku ;
3184 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3185 INDEX ON customer+sku TAG cust_sku
3186 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3187*- 1040686
3188
3189
3190 lcOldCust = ""
3191 lcOldItem = ""
3192 lcOldSku_resolv = ""
3193 Select tmpCurs
3194 If This.lUserInterface
3195 * Init Thermometer
3196 This.UpdateThermoCaption("Validating SKU(s)...")
3197 * TAN 31891 - JAZ - 5/20/02
3198 * This.InitThermo(RECC('tmpCurs'))
3199 This.InitThermo(RecCount('tmpCurs'))
3200 * End TAN 31891 - JAZ - 5/20/02
3201 l_nThermoCnt = 0
3202 Endif
3203 SCAN
3204 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3205 *-- Skip sku resolution
3206 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3207 LOOP
3208 ENDIF
3209 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3210
3211 If This.lUserInterface
3212 * Advance progress bar, if we're using one.
3213 l_nThermoCnt = l_nThermoCnt + 1
3214 This.AdvanceThermo(l_nThermoCnt)
3215 Endif
3216
3217 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3218 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3219 *--- TR 1013117 NH 20050908
3220 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3221 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3222 *=== TR 1013117 NH 20050908
3223 *=== TR 1010097 07/27/05 TK
3224
3225 *---TR 1037976 JAN-07-08 BR
3226 IF !(tmpCurs.customer == lcOldCust)
3227 lcCustomer = tmpCurs.customer
3228 IF SEEK(lcCustomer,pceipocr,"customer")
3229 lcSku_resolv = &pceipocr..sku_resolv
3230 ENDIF
3231 ENDIF
3232 *===TR 1037976 JAN-07-08 BR
3233
3234 lcErrs_Msg = ""
3235 lcOldCust = tmpCurs.customer
3236 lcOldItem = tmpCurs.sku
3237 *--- TR 1013117 NH
3238 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3239 *=== TR 1013117 NH
3240
3241 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3242
3243
3244
3245 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3246 *--- TR 1013117 NH 20050908
3247 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3248 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3249
3250 *- 1040686 - COMMENT
3251*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3252*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3253*!* *=== TR 1013117 NH 20050908
3254*!* *--- TR 1010097 07/27/05 TK
3255
3256*!* lcDivision = tmpCstdr.division
3257*!* lcStyle = tmpCstdr.Style
3258*!* lcColor_code = tmpCstdr.color_code
3259*!* lcLbl_code = tmpCstdr.lbl_code
3260*!* lcDimension = tmpCstdr.Dimension
3261*!* lnSizeBucket = tmpCstdr.size_bk
3262*!* lnSize_desc = tmpCstdr.size_desc
3263*!*
3264*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3265*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3266*!* If tmpCstdr.fkey > 0
3267*!* lnSkuPkey = tmpCstdr.fkey
3268*!* Endif
3269*!* * === TR 1045305 2/3/10 CM
3270*!*
3271*!*
3272*!* Else
3273*!* lcErrs_Msg = lcErrs_Msg + CRLF
3274*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3275*!* Store 0 To lnSizeBucket
3276*!* Endif
3277
3278 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3279 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3280 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3281 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3282 Store 0 To lnSizeBucket
3283 ELSE
3284 *- TR 1074276 FH - adding UPPER()
3285 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3286 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3287 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3288 Store 0 To lnSizeBucket
3289 ELSE
3290 lcDivision = tmpCstdr_sku.division
3291 lcStyle = tmpCstdr_sku.Style
3292 lcColor_code = tmpCstdr_sku.color_code
3293 lcLbl_code = tmpCstdr_sku.lbl_code
3294 lcDimension = tmpCstdr_sku.Dimension
3295 lnSizeBucket = tmpCstdr_sku.size_bk
3296 lnSize_desc = tmpCstdr_sku.size_desc
3297
3298 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3299 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3300 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3301 If tmpCstdr_sku.fkey > 0
3302 lnSkuPkey = tmpCstdr_sku.fkey
3303 Endif
3304 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3305 *!* * === TR 1045305 2/3/10 CM
3306
3307 ENDIF
3308 ENDIF
3309*- 1040686 - COMMENT
3310
3311 Endif && level break
3312
3313 *--- TechRec 1005163 17-May-2004 GS ---
3314 *Select (pceipoTD)
3315 llSLN = (tmpCurs.Src = pceipoTS)
3316 If llSLN
3317 Select (pceipoTS)
3318 Else
3319 Select (pceipoTD)
3320 Endif
3321 *!* Locate For pkey = tmpCurs.pkey
3322 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3323 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3324 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3325 *=== TechRec 1005163 17-May-2004 GS ===
3326 Scatter Name loEiPOtd Memo
3327 If !Empty(lcErrs_Msg)
3328 *--- TechRec 1005163 17-May-2004 GS ---
3329 If llSLN
3330 *- 1008827 04/22/05 YIK
3331 *- correct a typo
3332 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3333
3334 loEiPOtd.Errs_Flg_S = "Y"
3335 Else
3336 *=== TechRec 1005163 17-May-2004 GS ===
3337 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3338 loEiPOtd.Errs_Flg_D = "Y"
3339 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3340 Endif
3341 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3342 loEiPOtd.division = lcDivision
3343 loEiPOtd.Style = lcStyle
3344 loEiPOtd.color_code = lcColor_code
3345 loEiPOtd.lbl_code = lcLbl_code
3346 loEiPOtd.Dimension = lcDimension
3347 loEiPOtd.sizebucket = lnSizeBucket
3348 loEiPOtd.size_desc = lnSize_desc
3349
3350 * --- TR 1045305 2/3/10 CM
3351 loEiPOtd.sku_pkey = lnSkuPkey
3352 * === TR 1045305 2/3/10 CM
3353
3354 Endif
3355
3356 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3357 * only replace our SKU when no range style explosion happen
3358 *--- TechRec 1005163 17-May-2004 GS ---
3359 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3360 * Replace division With loEiPOtd.division, ;
3361 * style With loEiPOtd.style, ;
3362 * color_code With loEiPOtd.color_code, ;
3363 * lbl_code With loEiPOtd.lbl_code, ;
3364 * dimension With loEiPOtd.dimension, ;
3365 * sizebucket With loEiPOtd.sizebucket, ;
3366 * size_desc With loEiPOtd.size_desc, ;
3367 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3368 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3369 * In (pceipoTD)
3370 *- 1009508 3/16/05 YIK
3371 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3372 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3373 Gather Name loEiPOtd Memo
3374 *=== TechRec 1005163 17-May-2004 GS ===
3375 Endif
3376
3377 *=== TechRec 1005163 17-May-2004 GS ===
3378 Endif
3379 Endscan
3380 Use In tmpCurs
3381
3382 If This.lUserInterface
3383 * Reset Thermometer
3384 This.ResetThermo()
3385 Endif
3386
3387 If Used("tmpCstdr")
3388 Use In tmpCstdr
3389 ENDIF
3390
3391 *-1040686
3392 USE IN SELECT("tcDistCustSku")
3393 USE IN SELECT("tmpCstdr_sku")
3394 USE IN SELECT("tcAmbigSku")
3395 *-1040686
3396
3397 Select(lnOldSelect)
3398 Return llRetVal
3399 Endproc
3400
3401 *-----------------------------------------------------------------------------------
3402 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3403 PROCEDURE PopulateOrigLabel
3404 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3405 LOCAL llRetVal, lnOldSelect
3406 lnOldSelect = SELECT()
3407
3408 SELECT (pceipoTD)
3409 *-TR FH 1093621 - Push then pop
3410 .PushRecordSet()
3411
3412 SELECT d.pkey ;
3413 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3414 WHERE c.accept_lbl = 'Y' and ;
3415 c.customer = h.customer and ;
3416 c.division = d.division and ;
3417 h.pkey = d.fkey and ;
3418 h.errs_flg_h <> 'Y' and ;
3419 d.errs_flg_d <> 'Y' ;
3420 ORDER BY d.pkey ;
3421 INTO CURSOR 'cursTmpTD'
3422
3423 Index On pkey Tag pkey
3424
3425 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3426
3427 goto top in "cursTmpTD"
3428
3429 If llRetVal AND !EOF('cursTmpTD')
3430 SELECT (pceipoTD)
3431 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3432 In (pceipoTD)
3433 Endif
3434
3435 *-TR FH 1093621 - Push then pop
3436 .PopRecordSet()
3437
3438 Set Relation to
3439 USE IN 'cursTmpTD'
3440 SELECT (lnOldSelect)
3441 RETURN llRetVal
3442 ENDPROC
3443 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3444 *-----------------------------------------------------------------------------------
3445
3446 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3447 Procedure ConfirmUPC
3448 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3449
3450 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3451 lcUPC, lcErrs_Msg, llSLN
3452
3453 llRetVal = .T.
3454 lcErrs_Msg= ""
3455 lnOldSelect = Select()
3456
3457 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3458
3459 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3460
3461 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3462 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3463 from (pceipoTD) Into Cursor __eipoTD
3464
3465 If This.oHostProcess.lHaveSLN
3466 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3467 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3468 Endif
3469
3470 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3471 Select(lnOldSelect)
3472 Return llRetVal
3473 Endif
3474
3475 With This
3476 .cSQLTempTable = ""
3477 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3478 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3479 lceipoTD_tmp = .cSQLTempTable
3480 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3481
3482 If This.oHostProcess.lHaveSLN
3483 .cSQLTempTable = ""
3484 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3485 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3486 lceipoTS_tmp = .cSQLTempTable
3487 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3488 Endif
3489 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3490 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3491 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3492 Endwith
3493
3494
3495 This.MakeCursorWritable("tmpCursR","tmpCurs")
3496
3497 Select tmpCurs
3498 If This.lUserInterface
3499 * Init Thermometer
3500 This.UpdateThermoCaption("Comparing UPC(s)...")
3501 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3502 l_nThermoCnt = 0
3503 Endif
3504
3505
3506*- 1040686
3507 *=-=-=-=-=-=-=-=-=-=
3508 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3509 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3510 IF llRetVal
3511 .PopulateSQLTempTable("tcDistUpc")
3512 ENDIF
3513 llRetVal = llRetVal AND v_sqlexec(;
3514 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3515 " FROM zveupcnr d"+ ;
3516 " JOIN " + this.cSQLTempTable + " x " + ;
3517 " ON d.division = x.division " + ;
3518 " AND d.style = x.style " + ;
3519 " AND d.color_code = x.roll_color " + ;
3520 " AND d.lbl_code = x.lbl_code " + ;
3521 " AND d.dimension = x.dimension " + ;
3522 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3523 SELECT tmpCstdr
3524 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3525 *=-=-=-=-=-=-=-=-=-=
3526 SELECT tmpCurs
3527
3528*- 1040686
3529 Local lnSizeBk
3530 lnSizeBk = 0
3531 Scan
3532 If This.lUserInterface
3533 * Advance progress bar, if we're using one.
3534 l_nThermoCnt = l_nThermoCnt + 1
3535 This.AdvanceThermo(l_nThermoCnt)
3536 Endif
3537
3538 lcErrs_Msg = ""
3539
3540 *- 1040686
3541 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3542 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3543 DIMENSION, sizebucket, "tmpCstdr")
3544 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3545 DIMENSION, sizebucket, "tmpCstdr")
3546
3547 lcUPC = ""
3548 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3549 lcErrs_Msg = "Missing UPC number."
3550 ELSE
3551 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3552 ENDIF
3553
3554 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3555 *-1040686
3556
3557 If !(lcUPC == tmpCurs.UPC)
3558 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3559 Endif
3560
3561 If !Empty(lcErrs_Msg)
3562 llSLN = (tmpCurs.Src = pceipoTS)
3563 If llSLN
3564 Select (pceipoTS)
3565 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3566 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3567 Replace ;
3568 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3569 Errs_Flg_S With "Y"
3570 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3571 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3572 Errs_Flg_D With 'Y' In (pceipoTD)
3573 Endif
3574 ENDIF &&--- TR 1035223 NH
3575 Else
3576 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3577 Select (pceipoTD)
3578 Replace ;
3579 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3580 Errs_Flg_D With "Y"
3581 Endif
3582 Endif
3583 Endscan
3584
3585 Use In tmpCurs
3586
3587 If This.lUserInterface
3588 * Reset Thermometer
3589 This.ResetThermo()
3590 Endif
3591
3592 If Used("tmpCstdr")
3593 Use In tmpCstdr
3594 ENDIF
3595
3596 USE IN SELECT("tcDistUpc") &&1040686
3597
3598 Select(lnOldSelect)
3599 Return llRetVal
3600 ENDPROC
3601
3602 *-----------------------------------------------------------------------------------
3603
3604 Procedure GetConfrimUPCSql
3605 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3606 Local lcSql, lcSqlSln, lnOldSelect
3607 lnOldSelect = Select()
3608
3609 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3610 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3611 * this is a straight join and not a date resolution.
3612 lcSql = ;
3613 "select d.customer"+;
3614 " , d.division"+;
3615 " , d.sku"+;
3616 " , d.STYLE"+;
3617 " , d.color_code"+;
3618 " , case"+;
3619 " when r.rng_style is null"+;
3620 " and d.lbl_code = ''"+;
3621 " and c.resv_label = 'Y' then c.lbl_code"+;
3622 " when r.rng_style is null"+;
3623 " and d.lbl_code = ''"+;
3624 " and c.resv_label = 'V'"+;
3625 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3626 " else d.lbl_code"+;
3627 " end as lbl_code"+;
3628 " , d.lbl_code as lbl_codeOrig"+;
3629 " , c.resv_label"+;
3630 " , d.DIMENSION"+;
3631 " , d.Sizebucket"+;
3632 " , d.upc"+;
3633 " , d.pkey"+;
3634 " , C.Confirm_UPC"+;
3635 " , d.size_desc"+;
3636 " , '" + Trim(pceipoTD) + "' as Src"+;
3637 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3638 " from " + pceipoTD_tmp + " d"+;
3639 " join zzeipocr C"+;
3640 " on d.customer = C.customer"+;
3641 " and d.division = C.division"+;
3642 " left join zzxrangh r"+;
3643 " on r.division = d.division"+;
3644 " and r.rng_style = d.style"+;
3645 " and r.rng_color = d.color_code"+;
3646 " and r.rng_lbl = d.lbl_code"+;
3647 " and r.rng_pack = d.dimension"+;
3648 " left join zzxscolr sc"+;
3649 " on sc.division = d.division"+;
3650 " and sc.style = d.style"+;
3651 " and sc.color_code = d.color_code"+;
3652 " and sc.lbl_code = c.lbl_code"+;
3653 " and sc.dimension = d.dimension"+;
3654 " left join zzxrupcd rc " + ;
3655 " on rc.division = d.division"+;
3656 " and rc.style = d.style"+;
3657 " and rc.new_color = d.color_code"+;
3658 " and rc.lbl_code = d.lbl_code"+;
3659 " and rc.dimension = d.dimension"+;
3660 " where d.customer > ''"+;
3661 " and d.SKU > ''"+;
3662 " and (d.UPC > '' or d.EAN > '' )"+;
3663 " and d.Division > ''"+;
3664 " and d.Style > ''"+;
3665 " and d.Color_Code > ''"+;
3666 " and C.Confirm_UPC = 'Y' "+;
3667 " and d.Rng_Style = '' "
3668
3669 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3670 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3671 *--- Used sc.Division instead of c.Division.
3672 lcSqlSln = ;
3673 "select d.Customer"+;
3674 " , d.Division"+;
3675 " , s.SLN_SKU as sku"+;
3676 " , s.STYLE"+;
3677 " , s.Color_Code"+;
3678 " , case when s.Lbl_Code = ''"+;
3679 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3680 " when s.Lbl_Code = ''"+;
3681 " and c.Resv_Label = 'V'"+;
3682 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3683 " else s.lbl_code"+;
3684 " end as lbl_code"+;
3685 " , s.lbl_code as lbl_codeOrig"+;
3686 " , c.resv_label"+;
3687 " , s.DIMENSION"+;
3688 " , s.Sizebucket"+;
3689 " , s.SLN_UPC as upc"+;
3690 " , s.pkey"+;
3691 " , C.Confirm_UPC"+;
3692 " , s.size_desc"+;
3693 " , '" + Trim(pceipoTS) + "' as Src"+;
3694 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3695 " from " + pceipoTD_tmp + " d"+;
3696 " join " + pceipoTS_tmp + " s"+;
3697 " on s.fkey = d.pkey"+;
3698 " join zzeipocr C"+;
3699 " on d.customer = C.customer"+;
3700 " and d.division = C.division"+;
3701 " left join zzxscolr sc"+;
3702 " on sc.division = d.division"+;
3703 " and sc.style = s.style"+;
3704 " and sc.color_code = s.color_code"+;
3705 " and sc.lbl_code = c.lbl_code"+;
3706 " and sc.dimension = s.dimension"+;
3707 " left join zzxrupcd rc " + ;
3708 " on rc.division = d.division"+;
3709 " and rc.style = s.style"+;
3710 " and rc.new_color = s.color_code"+;
3711 " and rc.lbl_code = c.lbl_code"+;
3712 " and rc.dimension = s.dimension"+;
3713 " where d.Customer > ''"+;
3714 " and s.SLN_SKU > ''"+;
3715 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3716 " and d.Division > ''"+;
3717 " and s.Style > ''"+;
3718 " and s.Color_Code > ''"+;
3719 " and c.Confirm_UPC = 'Y'"+;
3720 " and d.Rng_Style > ''"
3721 Endif
3722
3723 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3724 Select(lnOldSelect)
3725 Return lcSql
3726 Endproc
3727 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3728
3729 *-----------------------------------------------------------------------------------
3730
3731 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3732 PROCEDURE MarkHeaderwithDetailOrSLNInError
3733 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3734 * This is customized method from clsEDI
3735
3736 LOCAL llRetVal, lnOldSelect
3737 LOCAL lnBadOrderCount
3738 llRetVal = .T.
3739 lnOldSelect = SELECT()
3740
3741 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3742 pcEW = "E"
3743 ENDIF
3744 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3745 LOCAL lcErrorMsg, lcErrorMsgSLN
3746 lnBadOrderCount = 0
3747 IF pcEW = 'W'
3748 lcErrorMsg = "Has Warnings in Details."
3749 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3750 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3751 ELSE
3752 lcErrorMsg = "Has Errors in Details."
3753 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3754 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3755
3756 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3757 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3758 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3759 ENDIF
3760
3761 SELECT tcBadOrders
3762 IF THIS.lUserInterface
3763 * Init Thermometer
3764 THIS.InitThermo(lnBadOrderCount)
3765 l_nThermoCnt = 0
3766 ENDIF
3767 SCAN
3768 IF THIS.lUserInterface
3769 * Advance progress bar, if we're using one.
3770 l_nThermoCnt = l_nThermoCnt + 1
3771 THIS.AdvanceThermo(l_nThermoCnt)
3772 ENDIF
3773 SELECT (pceipoTH)
3774 IF pcEW = 'W'
3775 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3776 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3777 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3778 IN (pceipoTH)
3779 ENDIF
3780 ENDIF
3781 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3782 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3783 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3784 IN (pceipoTH)
3785 ENDIF
3786 ENDIF
3787 ELSE
3788 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3789 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3790
3791 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3792 IN (pceipoTH)
3793 ENDIF
3794 ENDIF
3795 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3796 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3797
3798 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3799 IN (pceipoTH)
3800 ENDIF
3801 ENDIF
3802 ENDIF
3803 ENDSCAN
3804 USE IN tcBadOrders
3805 USE IN tcBadOrdersSLN
3806
3807 IF THIS.lUserInterface
3808 THIS.ResetThermo()
3809 ENDIF
3810 SELECT(lnOldSelect)
3811 RETURN llRetVal
3812 ENDPROC
3813 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3814
3815 *-----------------------------------------------------------------------------------
3816
3817 *--- TR 1013007 NH
3818 *--- checks if pceipoTH.req_855 is 'R'
3819 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
3820 *--- if default status value is not empty then set Send855 flag to true and return true
3821 *--- if default status value is empty then set Send855 flag to true and return false and
3822 *--- set error message 'Missing 855 status code'
3823 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
3824 *--- then set Send855 flag to true and return false and
3825 *--- set error message 'Missing 855 status code'
3826
3827 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
3828 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
3829 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
3830 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
3831 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
3832
3833
3834 Procedure Check855Required
3835 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
3836
3837 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
3838 llRetVal = .T.
3839 lnOldSelect = Select()
3840 lcOldPO_num = ""
3841 lcPO_Status_855 = ""
3842 This.LogEntry("Starting procedure" + Program())
3843 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
3844
3845 *--- prepare detail zzeipotd for cascading status_855 code
3846 Select(pceipoTD)
3847 lnOldOrder_TD = Val(Sys(21)) && getting the current order
3848 Set Order To Tagno('FKEY') && settting order by 'fkey'
3849
3850 Select(pceipoTH)
3851 Scan For req_855 = 'R'
3852 Scatter Name loEiPOth Memo
3853 *--- when this.lSend855 flag is true then data will be sent to server
3854 This.lSend855 = .T.
3855
3856 *--- TR 1040432 MAY-20-2009 BR
3857 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
3858 If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
3859 *=== TR 1040432 MAY-20-2009 BR
3860 Select(pceipoCR)
3861 If Auto_855 = 'Y'
3862 If Not Empty(def_855)
3863 *--- set default value
3864 loEiPOth.status_855 = def_855
3865 *--- TR 1080293 KISHORE 26-AUG-2014
3866 IF NOT EMPTY(def_855dtl)
3867 lcDetail855Code = EVALUATE(pceipoCR + ".def_855dtl")
3868 REPLACE ALL status_855 WITH lcDetail855Code ;
3869 IN (pceipoTD) ;
3870 FOR fkey = loeipoTH.pkey AND EMPTY(EVALUATE(pceipoTD + ".status_855"))
3871 ELSE
3872 *=== TR 1080293 KISHORE 26-AUG-2014
3873 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
3874 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
3875*!* llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
3876 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
3877 ENDIF && TR 1080293 KISHORE 26-AUG-2014
3878 Else
3879 loEiPOth.Errs_flg_h = 'Y'
3880 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
3881 Endif
3882 Endif
3883 Endif
3884
3885 *--- status_855 code is still empty
3886 If Empty(loEiPOth.status_855)
3887 loEiPOth.Errs_flg_h = 'Y'
3888 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
3889 Endif
3890
3891 *--- check if defferent status_855 code exists in orders with same po number
3892 If lcOldPO_num <> loEiPOth.po_num
3893 lcOldPO_num = loEiPOth.po_num
3894 lcPO_Status_855 = loEiPOth.status_855
3895 Else
3896 If lcPO_Status_855 <> loEiPOth.status_855
3897 loEiPOth.Errs_flg_h = 'Y'
3898 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
3899 Endif
3900 Endif
3901
3902 *--- all records will only be get updated. No insert is need here.
3903 Select(pceipoTH)
3904 Gather Name loEiPOth Memo
3905
3906 If Not llRetVal
3907 Exit
3908 Endif
3909 Endscan
3910 *--- set back to old order by
3911 Select(pceipoTD)
3912 Set Order To (lnOldOrder_TD)
3913 *-- when one order is flaged error then all order of PO will be make
3914 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
3915 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
3916 Select(lnOldSelect)
3917 Return llRetVal
3918
3919 ENDPROC
3920
3921 *-----------------------------------------------------------------------------------
3922
3923 *--- must set order by 'FKey' in pceipoTD
3924 Procedure Cascade855AckCode
3925 Lparameters poeipoTH, pceipoTD
3926
3927 Local llRetVal, lnOldSelect
3928 lnOldSelect = Select()
3929 llRetVal = .T.
3930
3931 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
3932 Return .F.
3933 Endif
3934 *- 1034481 10/06/08 YIK
3935 *- Cascade ALL status codes to details.
3936 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
3937 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
3938 Select(pceipoTD)
3939 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
3940 Scan While fkey = poeipoTH.pkey
3941 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
3942 Endscan
3943 ENDIF
3944 *- 1034481
3945 *- Endif
3946
3947 Select(lnOldSelect)
3948 Return llRetVal
3949 Endproc
3950
3951 *----------------------------------------------------------------------------------------
3952 *--- TR 1034481 NH
3953 PROCEDURE MarkHeaderForMissing855ControlRef
3954 LPARAMETERS pceipoTH
3955
3956 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
3957
3958 llRetVal = .t.
3959 lnOldSelect = SELECT()
3960 lcZzeoprcr = "Oprcr" + SYS(2015)
3961 lcZzxlookp = "LOOKP" + SYS(2015) && TR 1083402 20-Jan-2015 Partha
3962
3963 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
3964
3965 *--- TR 1083402 20-Jan-2015 Partha ---
3966*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
3967
3968 llRetVal = llRetVal and v_sqlexec("select customer, division, ack29_req from zzeoprcr", lcZzeoprcr)
3969 llRetVal = llRetVal and v_sqlexec("SELECT p.lk_code FROM zzxlookp p WHERE p.Lk_Type ='ACK29 Codes' ", lcZzxlookp)
3970 *=== TR 1083402 20-Jan-2015 Partha ===
3971
3972 IF USED(lcZzeoprcr)
3973
3974 SELECT (lcZzeoprcr) && TR 1083402 20-Jan-2015 Partha
3975
3976 INDEX on customer TAG customer
3977 INDEX on division TAG division
3978
3979 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
3980 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
3981 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
3982
3983 *--- TR 1083402 20-Jan-2015 Partha ---
3984 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Valid ACK29 Code required.' + CRLF ;
3985 from (pceipoTH) th ;
3986 JOIN (pceipoTD) td ON th.pkey=td.fkey ;
3987 WHERE th.req_855 ='R' ;
3988 AND EXISTS ( select c.customer from (lcZzeoprcr) c ;
3989 WHERE c.customer = th.customer AND c.division = th.division AND c.ack29_req='Y') ;
3990 AND ( EMPTY(td.ack29) ;
3991 OR NOT EXISTS (SELECT 1 FROM (lcZzxlookp) p WHERE p.LK_CODE = td.ack29 ))
3992 *=== TR 1083402 20-Jan-2015 Partha ===
3993
3994 USE IN (lcZzeoprcr)
3995 USE IN (lcZzxlookp) && TR 1083402 20-Jan-2015 Partha
3996 ENDIF
3997
3998 SELECT(lnOldSelect)
3999 RETURN llRetVal
4000
4001 ENDPROC
4002 *=== TR 1034481 NH
4003 *----------------------------------------------------------------------------------------
4004
4005 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
4006
4007 Local laTables[4]
4008 laTables[1] = "VzzeiPOth_iPOproc"
4009 laTables[2] = "VzzeiPOtd_iPOproc"
4010 laTables[3] = "VzzeiPOts_iPOproc"
4011 * --- TR 1018184 RLN 1018184
4012 laTables[4] = "VzzeiPOtsac_iPOproc"
4013
4014 Local llRetVal, llBeganTransaction, loEiPOth
4015 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
4016 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
4017
4018 llRetVal = .T.
4019
4020 With This
4021 .LogEntry("Starting Program : " + Program())
4022 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
4023
4024 Select(pceipoTH)
4025 Scan
4026 Scatter Name loEiPOth Memo
4027 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
4028 Select('VzzeiPOth_iPOproc')
4029 Gather Name loEiPOth Memo
4030 Endif
4031 Endscan
4032
4033 Select(pceipoTD)
4034 Scan
4035 Scatter Name loEiPOtd Memo
4036 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
4037 Select('VzzeiPOtd_iPOproc')
4038 Gather Name loEiPOtd Memo
4039 Endif
4040 Endscan
4041
4042 Select(pceipoTS)
4043 Scan
4044 Scatter Name loeipoTS Memo
4045 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
4046 Select('VzzeiPOts_iPOproc')
4047 Gather Name loeipoTS Memo
4048 Endif
4049 Endscan
4050
4051 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
4052 If This.BeginTransaction()
4053 llRetVal = This.Tableupdate(@laTables)
4054 If llRetVal
4055 This.EndTransaction()
4056 Else
4057 This.RollbackTransaction()
4058 Endif
4059 Endif
4060 *--- close views.
4061 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
4062 Endwith
4063
4064 Return llRetVal
4065
4066 Endfunc
4067
4068 *----------------------------------------------------------------------------------------
4069
4070 Procedure Run855Process
4071 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4072 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
4073 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4074
4075 Local lnOldSelect, llRetVal, loStatusCur
4076 lnOldSelect = Select()
4077 llRetVal = .T.
4078 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4079 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4080 Local lcStatusCur, loStatus
4081 lcStatusCur = Sys(2015)
4082 With This
4083
4084 *--- TR 1044017 07-JAN-2010 HNISAR
4085*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
4086 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
4087 *=== TR 1044017 07-JAN-2010 HNISAR
4088
4089 .LogEntry("Starting program " + Program())
4090
4091 * --- TR 1048571 9/9/10 CM
4092 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
4093 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
4094 * === TR 1048571 9/9/10 CM
4095
4096 If llRetVal
4097 Select (lcStatusCur )
4098 Scatter Name loStatus
4099 Use In (lcStatusCur)
4100 ENDIF
4101 *- 1034481 10/03/08 YIK
4102 *- Check if there are no 855(o) to process
4103 llHas855ToSend = .T.
4104
4105 *--- req_855 must be more the status missing count
4106 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
4107 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
4108 *-- move 850 data to 855 transaction
4109 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
4110
4111 *- 1034481 10/03/08 YIK
4112 *- Added parameter pceipoTH and llHas855ToSend
4113 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4114 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
4115 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
4116
4117 *--- TR 1044017 07-JAN-2010 HNISAR
4118*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4119 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4120 *===TR 1044017 07-JAN-2010 HNISAR
4121
4122 *- 1034481 10/03/08 YIK
4123 *- Check if there are no 855(o) to process
4124 IF llHas855ToSend
4125 *-- create flat files
4126 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4127 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
4128 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
4129 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
4130
4131 *--- update 855 flag of 850 tran header
4132 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
4133
4134 *--- TR 1044017 07-JAN-2010 HNISAR
4135*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
4136 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
4137 *=== TR 1044017 07-JAN-2010 HNISAR
4138
4139 *--- drop temp tables
4140 *- 1030497 02/29/08 TT
4141 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
4142 *!* .dropTempTable(lceoprth,.T.)
4143 *!* .dropTempTable(lceoprtd,.T.)
4144 *!* .dropTempTable(lceoprtc,.T.)
4145 *!* .dropTempTable(lceoprta,.T.)
4146 *!* .dropTempTable(lceoprth_notes,.T.)
4147 *!* .dropTempTable(lceoprtd_notes,.T.)
4148 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
4149 .oCopyUtil.dropTempTable(lceoprth,.T.)
4150 .oCopyUtil.dropTempTable(lceoprtd,.T.)
4151 .oCopyUtil.dropTempTable(lceoprtc,.T.)
4152 .oCopyUtil.dropTempTable(lceoprta,.T.)
4153 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
4154 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
4155
4156 *- 1034481 10/03/08 YIK
4157 ELSE
4158 .LogEntry("No 855(o) transaction data to send.")
4159 ENDIF
4160 *= 1034481 *- 1030497 02/29/08 TT
4161 Endif
4162
4163 *- 1034481 10/03/08 YIK
4164 *- Added ..AND loStatus.STATUS_855_MISSING > 0
4165 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
4166 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
4167 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
4168 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
4169 .oHostProcess.c855Msg
4170 Endif
4171 Release loStatus
4172 Endwith
4173
4174 Select(lnOldSelect)
4175 Return llRetVal
4176
4177 Endfunc
4178
4179 *----------------------------------------------------------------------------------------
4180
4181 Procedure get855Status
4182 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4183 Lparameters tcCursor, pceipoTH
4184
4185 * --- TR 1048571 9/9/10 CM
4186 *Local lcSQL, lnOldSelect,llRetVal
4187 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4188
4189 lceipoth = "#Ipoth" + SYS(2015)
4190 * === TR 1048571 9/9/10 CM
4191
4192 lnOldSelect = Select()
4193 llRetVal = .T.
4194
4195 * --- TR 1048571 9/9/10 CM
4196 With This
4197 .cSQLTempTable=""
4198 IF .GenerateSQLTempTable(pceipoTH)
4199 IF .PopulateSQLTempTable(pceipoTH)
4200 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4201 llRetVal = llRetVal And v_SqlExec(lcSQL)
4202 ENDIF
4203 ENDIF
4204 Endwith
4205 * === TR 1048571 9/9/10 CM
4206
4207 *- TR 1100974 FH - taking out This.cFilterCriteria
4208 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4209 lcSQL = " select sum(1) rec_count, " + ;
4210 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4211 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4212 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4213 " from " + lceipoth + " h "
4214
4215 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4216 Select(lnOldSelect)
4217 Return llRetVal
4218 Endproc
4219
4220 *----------------------------------------------------------------------------------------
4221
4222 Procedure MoveTo855TempTransaction
4223 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4224 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4225 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4226
4227 Local llRetVal, lnOldSelect
4228 lnOldSelect = Select()
4229 llRetVal = .T.
4230 With This
4231 *--- create temporary 855 transaction tables at server
4232 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4233 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4234
4235 *--- copy data from 850 trans table to 855 temp trans tables
4236 *- 1034481 10/03/08 YIK
4237 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4238 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4239 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4240
4241 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4242 IF plHas855ToSend
4243 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4244 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4245
4246 *--- update header division from detail
4247 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4248 ENDIF
4249 *= 1034481
4250 Endwith
4251
4252 Select(lnOldSelect)
4253 Return llRetVal
4254
4255 Endproc
4256
4257 *----------------------------------------------------------------------------------------
4258
4259 Procedure CreateOPRTempTables
4260 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4261
4262 Local llRetVal, lnOldSelect, lcUnique
4263 lnOldSelect = Select()
4264 llRetVal = .T.
4265 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4266 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4267 AND Vartype(pcRefeoprtd_notes) == "C" )
4268
4269 lcUnique = Sys(2015)
4270 With This
4271 .LogEntry("Starting " + Program())
4272 .LogEntry("Creating OPR Temp Tables.")
4273
4274 *--- zzeipoth
4275 pcRefeoprth = "#zzeoprth" + lcUnique
4276 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4277 llRetVal = llRetVal And v_SqlExec(lcSQL)
4278
4279 *--- TR 1044208
4280 .oHostProcess.AddToTempTables(pcRefeoprth)
4281 *=== TR 1044208
4282
4283 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4284 *--- zzeipotd
4285 pcRefeoprtd = "#zzeoprtd" + lcUnique
4286 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4287 llRetVal = llRetVal And v_SqlExec(lcSQL)
4288 *--- TR 1044208
4289 .oHostProcess.AddToTempTables(pcRefeoprtd)
4290 *=== TR 1044208
4291 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4292
4293 *--- zzeipotc
4294 pcRefeoprtc = "#zzeoprtc" + lcUnique
4295 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4296 llRetVal = llRetVal And v_SqlExec(lcSQL)
4297 *--- TR 1044208
4298 .oHostProcess.AddToTempTables(pcRefeoprtc )
4299 *=== TR 1044208
4300 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4301
4302 *--- zzeipota
4303 pcRefeoprta = "#zzeoprta" + lcUnique
4304 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4305 llRetVal = llRetVal And v_SqlExec(lcSQL)
4306 *--- TR 1044208
4307 .oHostProcess.AddToTempTables(pcRefeoprta )
4308 *=== TR 1044208
4309 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4310
4311 *---- sysnotes_oprth
4312 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4313 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4314 llRetVal = llRetVal And v_SqlExec(lcSQL)
4315 *--- TR 1044208
4316 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4317 *=== TR 1044208
4318 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4319
4320 *---- sysnotes_oprtd
4321 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4322 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4323 llRetVal = llRetVal And v_SqlExec(lcSQL)
4324 *--- TR 1044208
4325 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4326 *=== TR 1044208
4327 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4328
4329 Endwith
4330
4331 Select(lnOldSelect)
4332 Return llRetVal
4333
4334 Endproc
4335
4336 *----------------------------------------------------------------------------------------
4337
4338 Procedure IPODataToOPRTmpTable
4339 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4340 pceipoTD
4341 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4342 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4343 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4344
4345 lcOPR_TMP = ""
4346 lnOldSelect = Select()
4347 llRetVal = .T.
4348 lcCommonFields = ""
4349 *-TR 1100974 FH - filter for all
4350 *lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4351 lcFilter = " where 1 = 1 "
4352 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4353 lcLeftOnlyDefaults = ""
4354 lcLeftOnlyFields = ""
4355 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4356
4357 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4358
4359 * --- TR 1048571 9/9/10 CM
4360 lcipotd = "#Zzeipotd" + SYS(2015)
4361 * === TR 1048571 9/9/10 CM
4362
4363 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4364
4365 With This
4366 *-- TR 1044604 DEC-29-2009 BR
4367 .cSQLTempTable=""
4368 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4369*!* IF .GenerateSQLTempTable(pceipoTH)
4370*!* IF .PopulateSQLTempTable(pceipoTH)
4371 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4372 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4373 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4374
4375 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4376 &lcCmnd
4377
4378*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4379 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4380 IF .GenerateSQLTempTable(lcTempIPOTH)
4381
4382 IF .PopulateSQLTempTable(lcTempIPOTH)
4383 Use In Select(lcTempIPOTH)
4384 *=== TR 1043191 23-Oct-2009 JK ===
4385 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4386 llRetVal = llRetVal And v_SqlExec(lcSQL)
4387 ENDIF
4388 ENDIF
4389 *== TR 1044604 DEC-29-2009 BR
4390
4391 * --- TR 1048571 9/9/10 CM
4392 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4393 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4394 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4395 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4396 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4397 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4398 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4399 *.ScatterGather(pceipoTD, "tcIpoDtls")
4400 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4401 .ScatterGather("__tceipoTD", "tcIpoDtls")
4402 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4403
4404 SELECT tcIpoDtls
4405 LOCATE
4406 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4407 .cSQLTempTable=""
4408 IF .GenerateSQLTempTable("tcFinalDtls")
4409 IF .PopulateSQLTempTable("tcFinalDtls")
4410 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4411 llRetVal = llRetVal And v_SqlExec(lcSQL)
4412 ENDIF
4413 ENDIF
4414 * === TR 1048571 9/9/10 CM
4415
4416 *--- IPOTH -> OPRTH
4417 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4418 *--- lcCalFldsOPR : fields need calculation or map or constant values
4419 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4420
4421 *--- for example if term_type field data will go to terms_type field and blank term_type
4422 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4423 *!* lcCalFldsOPR = "term_type, terms_type"
4424 *!* lcCalFldsOPR_val = "' ',term_type"
4425 lcCalFldsOPR_SQL = "'PROC_855'"
4426 lcCalFldsOPR = "PROC_855"
4427 lcCalFldsOPR_val = "' '"
4428 lcFlds = ""
4429 lcValues = ""
4430
4431 lcOPR_TMP = pceoprth
4432 *- 1030497 02/29/08 TT
4433 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4434 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4435
4436 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4437 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4438 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4439 *- 1030497 02/29/08 TT
4440 *--- 1034481 set correct flag value 'P' for Proc_855
4441 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4442 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4443 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4444 llRetVal = llRetVal And v_SqlExec(lcSQL)
4445
4446 *--- IPOTD -> OPRTD
4447 lcCalFldsOPR_SQL = ""
4448 lcCalFldsOPR = ""
4449 lcCalFldsOPR_val = ""
4450 lcFlds = ""
4451 lcValues = ""
4452
4453 lcOPR_TMP = pceoprtd
4454 *- 1030497 02/29/08 TT
4455 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4456 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4457 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4458 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4459 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4460 *- 1030497 02/29/08 TT
4461 *- 1034481 10/03/08 YIK
4462 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4463 DECLARE la855Cnt[1]
4464 la855Cnt[1] = 0
4465 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4466 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4467 " INTO ARRAY la855Cnt"
4468 &lcSQL
4469
4470 plHas855ToSend = (la855Cnt[1] > 0)
4471
4472 IF plHas855ToSend
4473 *--- 1034481 set correct flag value 'P' for Proc_855
4474 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4475 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4476 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4477 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4478 " ( select * from " + lcipoth + " h " + lcFilter + ;
4479 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4480
4481 llRetVal = llRetVal And v_SqlExec(lcSQL)
4482
4483 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4484 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4485 " on d.fkey = h.pkey "
4486 llRetVal = llRetVal And v_SqlExec(lcSQL)
4487
4488 *--- IPOTC -> OPRTC
4489 lcOPR_TMP = pceoprtc
4490 lcCalFldsOPR_SQL = ""
4491 lcCalFldsOPR = ""
4492 lcCalFldsOPR_val = ""
4493 lcFlds = ""
4494 lcValues = ""
4495
4496 *- 1030497 02/29/08 TT
4497 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4498 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4499 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4500 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4501 *- 1030497 02/29/08 TT
4502 *--- 1034481 set correct flag value 'P' for Proc_855
4503 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4504 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4505 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4506 " (select * from " + lcipoth + " h " + lcFilter + ;
4507 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4508
4509 llRetVal = llRetVal And v_SqlExec(lcSQL)
4510
4511 *--- IPOTA -> OPRTA
4512 lcOPR_TMP = pceoprta
4513 lcCalFldsOPR_SQL = ""
4514 lcCalFldsOPR = ""
4515 lcCalFldsOPR_val = ""
4516 lcFlds = ""
4517 lcValues = ""
4518
4519 *- 1030497 02/29/08 TT
4520 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4521 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4522 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4523 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4524 *- 1030497 02/29/08 TT
4525 *--- 1034481 set correct flag value 'P' for Proc_855
4526
4527 *--- 1042063 10/12/09 CM
4528 *--- We're unconditionally going to remove characters greater than 25,
4529 * for 855 address1,address2 fields since max field size is 25.
4530 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4531 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4532 *=== 1042063 10/12/09 CM
4533
4534 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4535 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4536 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4537 " (select * from " + lcipoth + " h " + lcFilter + ;
4538 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4539
4540 llRetVal = llRetVal And v_SqlExec(lcSQL)
4541
4542 *--- sysnotes - zzeoprth
4543 lcOPR_TMP = pceoprth_notes
4544 *--- 1034481 set correct flag value 'P' for Proc_855
4545 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4546 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4547 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4548 " (select * from " + lcipoth + " h " + lcFilter + ;
4549 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4550
4551 llRetVal = llRetVal And v_SqlExec(lcSQL)
4552
4553 *--- sysnotes - zzeoprtd
4554 lcOPR_TMP = pceoprtd_notes
4555 *--- 1034481 set correct flag value 'P' for Proc_855
4556 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4557 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4558 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4559 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4560 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4561 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4562 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4563
4564 llRetVal = llRetVal And v_SqlExec(lcSQL)
4565 *- 1034481 10/03/08 YIK
4566 ENDIF &&plHas855ToSend
4567
4568 *-- TR 1044604 DEC-29-2009 BR
4569 lcSQL = "DROP TABLE " + lcipoth
4570 v_SqlExec(lcSQL)
4571 *== TR 1044604 DEC-29-2009 BR
4572 Endwith
4573
4574 * --- TR 1048571 9/9/10 CM
4575 USE IN SELECT("tcIpoDtls")
4576 USE IN SELECT("tcFinalDtls")
4577 USE IN SELECT("tcTmpDtls")
4578 * === TR 1048571 9/9/10 CM
4579
4580 Select(lnOldSelect)
4581 Return llRetVal
4582 Endproc
4583
4584
4585 *----------------------------------------------------------------------------------------
4586
4587 Procedure ResetPkey_OPRTmpTable
4588 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4589
4590 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4591 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4592
4593 lnOldSelect = Select()
4594 llRetVal = .T.
4595 lcOPR_TMP = pceoprth
4596 lnRecCount = 0
4597 lnMaxPkey = 0
4598 lcUnique = Sys(2015)
4599
4600 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4601 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4602 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4603 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4604 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4605 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4606 lcNewPkeyCol_TH = "PKEY_OPRTH"
4607 lcNewPkeyCol_TD = "PKEY_OPRTD"
4608 With This
4609 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4610 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4611 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4612 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4613 *- 1030497 02/29/08 TT
4614 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4615 *- TR 1092952 - FH typo, change sysnotes -> zzeoprth
4616 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "zzeoprth", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4617 *- 1030497 02/29/08 TT
4618
4619 *--- fkey updates for all chield tables
4620 *--- ipotd -> oprtd : fkey
4621 lcOPR_TMP = pceoprtd
4622 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4623 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4624 llRetVal = llRetVal And v_SqlExec(lcSQL)
4625
4626 *--- ipota -> oprta : fkey
4627 lcOPR_TMP = pceoprta
4628 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4629 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4630
4631 llRetVal = llRetVal And v_SqlExec(lcSQL)
4632
4633 *--- ipotc -> oprtc : fkey
4634 lcOPR_TMP = pceoprtc
4635 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4636 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4637 llRetVal = llRetVal And v_SqlExec(lcSQL)
4638
4639 *-- sysnotes :
4640 *-- table_name
4641 lcOPR_TMP = pceoprth_notes
4642 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4643 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4644 llRetVal = llRetVal And v_SqlExec(lcSQL)
4645
4646 *-- update detail pkey
4647 *- 1030497 02/29/08 TT
4648 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4649 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4650 *- 1030497 02/29/08 TT
4651
4652 *-- sysnotes : update table_name, fkey
4653 lcOPR_TMP = pceoprtd_notes
4654 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4655 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4656 llRetVal = llRetVal And v_SqlExec(lcSQL)
4657
4658 *--- update header notes pkey
4659 *- 1030497 02/29/08 TT
4660 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4661 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4662 *- 1030497 02/29/08 TT
4663 *--- update detail notes pkey
4664 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4665 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4666
4667 *-- update pkey
4668 *- 1030497 02/29/08 TT
4669 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4670 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4671
4672 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4673 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4674 *- 1030497 02/29/08 TT
4675
4676 *--- drop all temp tables
4677 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4678 *- 1030497 02/29/08 TT
4679 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4680 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4681 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4682 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4683 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4684
4685 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4686 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4687 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4688 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4689 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4690 *- 1030497 02/29/08 TT
4691
4692 Endwith
4693
4694 Select(lnOldSelect)
4695 Return llRetVal
4696 Endproc
4697
4698 *----------------------------------------------------------------------------------------
4699
4700 Procedure UpdateOPRTempHDRDivisionFromDtl
4701 Lparameters pcRefeoprth,pcRefeoprtd
4702
4703 Local llRetVal, lnOldSelect
4704 llRetVal = .T.
4705 lnOldSelect = Select()
4706 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4707 llRetVal = llRetVal And v_SqlExec(lcSQL)
4708 Select(lnOldSelect)
4709 Return llRetVal
4710
4711 Endproc
4712
4713 *----------------------------------------------------------------------------------------
4714
4715 Procedure Launch855Process
4716 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4717 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4718 Local llRetVal, lnOldSelect
4719 lnOldSelect = Select()
4720 llRetVal = .T.
4721
4722 Local lo855
4723 Local lc855DataTbls, lc855Msg
4724 lcFilterCriteria = ""
4725 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4726 llRetVal = (Vartype(lo855) = 'O')
4727 lc855Msg = ""
4728
4729 If llRetVal
4730 *--- TR 1037976 JAN-22-2008 BR
4731 *lo855 = This
4732 lo855.oLog = THIS.oLog
4733 *=== TR 1037976 JAN-22-2008 BR
4734 lo855.oFrmProgressBar = This.oFrmProgressBar
4735 Endif
4736 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4737 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4738 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4739 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4740 This.oHostProcess.c855Msg = lc855Msg
4741 Select(lnOldSelect)
4742 Return llRetVal
4743
4744 Endproc
4745
4746 *----------------------------------------------------------------------------------------
4747
4748 Procedure Update855ProcFlag
4749 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4750
4751 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4752 lnOldSelect = Select()
4753 llRetVal = .T.
4754 lcCursor = Sys(2015)
4755 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4756 *--- 1034481 set correct flag value 'P' for Proc_855
4757 *- 1034481 10/03/08 YIK
4758 *- Also populate error flag and error message from zzeoprth to the 850(i)
4759 *- otherwise 850(i) goes through while the 855(o) errors out.
4760 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4761 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4762 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4763 " t on o.pkey = t.pkey_oprth" + ;
4764 " LEFT JOIN zzeoprth th " + ;
4765 " on th.pkey = t.pkey_oprth"
4766
4767 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4768 If llRetVal
4769 Select (lcCursor)
4770 SCAN
4771 Scatter Name loCursor Memo
4772 DO CASE
4773 CASE proc_855 = 'P'
4774 *- 1014298 12/02/05 YIK, NH
4775 *- it was ..proc_855 WITH 'Y'
4776 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4777 CASE errs_flg_h = 'Y'
4778 REPLACE errs_flg_h WITH 'Y', ;
4779 errs_msg_h WITH errs_msg_h + ;
4780 " ---- 855(o) process ----" + CRLF + ;
4781 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4782 For pkey = loCursor.pkey In (pceipoTH)
4783 OTHERWISE
4784 ENDCASE
4785 Endscan
4786 Endif
4787 *= 1034481
4788 Select(lnOldSelect)
4789 Return llRetVal
4790
4791 Endproc
4792
4793 *----------------------------------------------------------------------------------------
4794
4795 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4796
4797 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4798 *!* In this case label must be with empty.
4799
4800 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4801
4802 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4803 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4804 *!* style '9040' color 'RED' label 'WM'.
4805
4806 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4807 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4808 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4809
4810 Procedure CheckMultiUPC
4811 Lparameters tcEiPOth, tcEiPOtd
4812
4813 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
4814
4815 llRetVal = True
4816 lnSelect = Select()
4817
4818 With This
4819
4820 lcWorkAlias = GetUniqueFileName()
4821
4822 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4823 *-- Change h.division to d.division
4824 SELECT d.pkey, ;
4825 h.customer, ;
4826 d.division, ;
4827 d.upc ;
4828 FROM tceipoth h ;
4829 JOIN tceipotd d ;
4830 ON h.pkey = d.fkey ;
4831 INTO ;
4832 CURSOR (lcworkAlias)
4833
4834 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
4835 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
4836 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
4837 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
4838
4839 If llRetVal
4840
4841 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4842 *-- Included 'V' in the condition of pocr.resv_label
4843 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
4844 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
4845
4846 lcSql = " SELECT upcd.lbl_code, t.* " + ;
4847 " FROM " + lcTempTbl + " t " + ;
4848 " JOIN zzemupch upch " + ;
4849 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
4850 " JOIN zzemupcd upcd " + ;
4851 " ON upch.pkey = upcd.fkey " + ;
4852 " AND upcd.active_ok = 'Y' " + ;
4853 " JOIN " + This.c850Control + " pocr " + ;
4854 " ON pocr.customer = t.customer " + ;
4855 " AND pocr.division = t.division " + ;
4856 " AND pocr.lbl_code = upcd.lbl_code " + ;
4857 " AND pocr.resv_label IN ('Y','V') "
4858
4859 lcWorkAlias = GetUniqueFileName()
4860
4861 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
4862
4863 If Reccount(lcWorkAlias) > 0
4864 Select (tcEiPOtd)
4865 Scan
4866 lnPKey = pkey
4867
4868 Select(lcWorkAlias)
4869 Locat For pkey = lnPKey
4870
4871 If Found()
4872 lcLbl_code = lbl_code
4873 Select (tcEiPOtd)
4874 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
4875 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
4876 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
4877 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
4878 Endif
4879
4880 Select (tcEiPOtd)
4881 Endscan
4882 Endif
4883
4884 Endif
4885
4886 .TableClose(lcWorkAlias)
4887
4888 Endwith
4889
4890 Select (lnSelect)
4891 Return llRetVal
4892 Endproc
4893 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
4894
4895 *----------------------------------------------------------------------------------------
4896
4897 Procedure RangeStyle
4898 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
4899 Local llRetVal, lnOldSelect, lcErrs_Msg
4900 llRetVal = .T.
4901 lnOldSelect = Select()
4902
4903 *****************************************************************************
4904 * 1st Getting all range style (hdr/dtl) that relate to the
4905 * passing order line for this run
4906
4907 *--- TR 1038376 05-May-2009 Goutam
4908 LOCAL lctmpCursor
4909 lctmpCursor = GetUniqueFileName()
4910
4911 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
4912 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
4913
4914 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
4915 * TR 1059142 FH - adding h.ord_type to the group by clause
4916 *--- TR 1088126 2-JUL-2015 Venuk -- Added 'as price_code' else MAX(h.price_code) will be max_price_Code ===
4917 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) as price_code, h.ord_type FROM (pcTransHeader) h ;
4918 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4919 WHERE d.errs_flg_d <> 'Y' ;
4920 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
4921 INTO CURSOR __TmpCursor
4922
4923SET ASSERTS ON
4924ASSERT .f.
4925 .cSQLTempTable=""
4926 If .GenerateSQLTempTable('__TmpCursor')
4927 If .PopulateSQLTempTable('__TmpCursor')
4928 If !Empty(.cSQLTempTable)
4929 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4930 lcSqlString = "Update " + .cSQLTempTable + ;
4931 " Set price_code = coalesce((Select Top 1 price_code " + ;
4932 " From zzxcslsr " + ;
4933 " Where Customer = h.customer " + ;
4934 " and (Store = h.store or Store = '') " + ;
4935 " and (Division = h.division or Division = '') " + ;
4936 " and (Department = h.department or Department = '') " + ;
4937 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4938 " and price_code <> '' " + ;
4939 " order by rank_seq),'') " + ;
4940 " From " + .cSQLTempTable + " h"
4941
4942 llRetVal = v_sqlExec(lcSqlString)
4943
4944 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
4945 lcSqlString = "UPDATE " + .cSQLTempTable + ;
4946 " Set price_code = c.price_code "+;
4947 " From " + .cSQLTempTable + " h "+;
4948 " , zzocntrc c "+;
4949 " Where h.division = c.division " +;
4950 " and h.price_code = '' "
4951 llRetVal = v_sqlExec(lcSqlString)
4952 *- TR 1056061 FH 08/17/11
4953
4954
4955 IF llRetVal
4956 lcSqlString = "Select * from " + .cSQLTempTable
4957 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
4958
4959 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
4960 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4961*!* lcSqlString = "UPDATE h " + ;
4962*!* " SET price_code = c.price_code " + ;
4963*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
4964*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
4965*!* " on d.division = c.division " + ;
4966*!* " And d.customer = c.customer " + ;
4967*!* " And h.Store = c.Store " + ;
4968*!* " And h.department = c.department " + ;
4969*!* " And h.ord_type = c.ord_type " + ;
4970*!* "Where d.errs_flg_d <> 'Y' "
4971
4972 lcSqlString = "UPDATE h " + ;
4973 " SET price_code = c.price_code " + ;
4974 " From " + pcTransheader + " h " + ;
4975 " join " + lcTmpCursor + " c " + ;
4976 " on h.division = c.division " + ;
4977 " And h.customer = c.customer " + ;
4978 " And h.Store = c.Store " + ;
4979 " And h.department = c.department " + ;
4980 " And h.ord_type = c.ord_type " + ;
4981 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
4982
4983 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
4984
4985 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
4986 ENDIF
4987
4988 IF llRetVal
4989 *-1061331 FH - simpilifed update query
4990 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
4991 *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 ;
4992 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4993 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4994 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4995
4996 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 ;
4997 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
4998
4999 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
5000 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
5001 *- TR 1054873 FH - changed error message
5002 &&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 ;
5003 &&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 ;
5004 *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 ;
5005 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
5006 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
5007 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
5008 ENDIF
5009
5010 endif
5011 endif
5012 endif
5013
5014 *--- TR 1088126 2-JUL-2015 Venuk
5015 IF This.oBPOSalesOrder.lRslv_pricecode_cssld
5016 SELECT CRS_pkey, d.pkey as dtlpkey, d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type, ;
5017 d.style, d.color_code, d.lbl_code, d.dimension ;
5018 FROM (pcTransHeader) h ;
5019 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
5020 WHERE d.errs_flg_d <> 'Y' ;
5021 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type, d.pkey ;
5022 INTO CURSOR __TmpCursor
5023
5024 .cSQLTempTable=""
5025 If .GenerateSQLTempTable('__TmpCursor')
5026 If .PopulateSQLTempTable('__TmpCursor')
5027 If !Empty(.cSQLTempTable)
5028
5029 lcSqlString = "Update " + .cSQLTempTable + ;
5030 " Set CRS_pkey = coalesce((Select Top 1 pkey " + ;
5031 " From zzxcslsr " + ;
5032 " Where Customer = h.customer " + ;
5033 " and (Store = h.store or Store = '') " + ;
5034 " and (Division = h.division or Division = '') " + ;
5035 " and (Department = h.department or Department = '') " + ;
5036 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
5037 " and price_code <> '' " + ;
5038 " order by rank_seq),'') " + ;
5039 " From " + .cSQLTempTable + " h"
5040 llRetVal = v_sqlExec(lcSqlString)
5041
5042 lcSqlString = ;
5043 " Select r.dtlpkey as dtlpkey, " + ;
5044 " case when Coalesce(d.price_code,'')='' then h.price_code else d.price_code end as price_Code " + ;
5045 " from zzxcslsr h " + ;
5046 " join "+ .cSQLTempTable + " r" + ;
5047 " on h.pkey = r.CRS_pkey " + ;
5048 " join zzxscolr c " + ;
5049 " on c.division = h.division " + ;
5050 " and c.style = r.style" + ;
5051 " and c.color_Code = r.color_Code " + ;
5052 " and c.lbl_Code = r.lbl_code " + ;
5053 " and c.dimension = r.dimension " + ;
5054 " join zzxcslsd d " + ;
5055 " on h.pkey = d.fkey " + ;
5056 " and h.group_Type = d.group_type " + ;
5057 " and d.group_code = " + ;
5058 " case when d.Group_type='A' then c.Group_Code1 " + ;
5059 " when h.Group_type='B' then c.Group_Code2 " + ;
5060 " when h.Group_type='C' then c.Group_Code3 " + ;
5061 " when h.Group_type='D' then c.Group_Code4 " + ;
5062 " when h.Group_type='E' then c.Group_Code5 " + ;
5063 " when h.Group_type='F' then c.Group_Code6 " + ;
5064 " when h.Group_type='G' then c.Group_Code7 " + ;
5065 " when h.Group_type='H' then c.Group_Code8 " + ;
5066 " when h.Group_type='I' then c.Group_Code9 " + ;
5067 " when h.Group_type='J' then c.Group_Code10 " + ;
5068 " when h.Group_type='K' then c.Group_Code11 " + ;
5069 " when h.Group_type='L' then c.Group_Code12 " + ;
5070 " when h.Group_type='M' then c.Group_Code13 end "
5071
5072 llRetVal = v_sqlExec(lcSqlString, "tcPriceCode")
5073
5074 If(USED("tcPriceCode"))
5075 SELECT tcPriceCode
5076 INDEX on dtlpkey TAG dtlpkey
5077 llRetval = .SetRelation("tcPriceCode", "dtlpkey", pcTransDetail,"pkey")
5078
5079 REPLACE ALL PRICE_CODE WITH tcPriceCode.price_Code IN (pcTransDetail)
5080
5081 Set Relation To
5082 USE IN tcPriceCode
5083 ENDIF
5084 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 ;
5085 from (pcTransDetail) d WHERE EMPTY(d.price_code) AND d.errs_flg_d <> 'Y'
5086
5087 ENDIF
5088 ENDIF
5089 ENDIF
5090 USE IN __TmpCursor
5091 ELSE
5092 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey where d.price_code=''
5093 Endif
5094 *=== TR 1088126 2-JUL-2015 Venuk
5095
5096 .cSQLTempTable=""
5097 *=== TR 1038376 05-May-2009 Goutam
5098 * additional past for range style verification/explotion
5099 *-- TR 1023892 5-3-07 BR
5100 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5101 IF .lALLOW_RANGE_HDR_LABEL
5102 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5103 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5104 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 ;
5105 FROM (pcTransHeader) h, (pcTransDetail) d ;
5106 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5107 AND d.Errs_Flg_D= 'N' AND ;
5108 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5109 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5110 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5111 ELSE
5112 *=== TR 1023892 NH
5113 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5114 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5115 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
5116 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5117 FROM (pcTransHeader) h, (pcTransDetail) d ;
5118 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5119 And d.Errs_Flg_D= "N" And ;
5120 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5121 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5122 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5123 ENDIF && TR 1023892 NH
5124 With This
5125 .cSQLTempTable=""
5126 If .GenerateSQLTempTable('__TmpCursor')
5127 If .PopulateSQLTempTable('__TmpCursor')
5128 If !Empty(.cSQLTempTable)
5129
5130 .LogEntry("Exploding range style.")
5131 * Get range style header
5132 *- 1000984 9/11/03 YIK
5133 *- do not explode range styles type 'P'rint
5134 *- Added ..and h.rng_type <> 'P'
5135 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
5136 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
5137 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
5138 IF .lALLOW_RANGE_HDR_LABEL
5139 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5140 "Where h.division= t.division and h.rng_style = t.style and "+;
5141 "h.rng_color= t.color_code and h.rng_lbl= (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) and "+;
5142 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5143 ELSE
5144 *=== TR 1023892 NH
5145 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5146 "Where h.division= t.division and h.rng_style = t.style and "+;
5147 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5148 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5149 *= 1000984
5150 ENDIF && TR 1023892 NH
5151 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
5152
5153 * TAN 31891 - JAZ - 5/20/02
5154 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5155 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5156 * End TAN 31891 - JAZ - 5/20/02
5157
5158 If llHaveRangeStyleToExplode
5159 * Get range style detail
5160 *- 1000984 9/11/03 YIK
5161 *- do not explode range styles type 'P'rint
5162 *- Added ..and h.rng_type <> 'P'
5163
5164 *--- TR 1038376 05-May-2009 Goutam
5165 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5166
5167 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
5168 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
5169*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
5170*!* " case t.price_code when 'A' then h.a_price " + ;
5171*!* " when 'B' then h.b_price " + ;
5172*!* " when 'C' then h.c_price " + ;
5173*!* " when 'D' then h.d_price " + ;
5174*!* " when 'E' then h.e_price " + ;
5175*!* " else h.a_price end rnghdr_Price " + ;
5176*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5177*!* "join " + .cSQLTempTable + " t " +;
5178*!* "on h.division= t.division and h.rng_style = t.style and "+;
5179*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5180*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5181*!* " (case t.price_code when 'A' then h.a_price " + ;
5182*!* " when 'B' then h.b_price " + ;
5183*!* " when 'C' then h.c_price " + ;
5184*!* " when 'D' then h.d_price " + ;
5185*!* " when 'E' then h.e_price " + ;
5186*!* " else h.a_price end " + ;
5187*!* " <> t.org_price)" +;
5188*!* " AND t.sizebucket = h.rng_bk"
5189
5190 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5191 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
5192 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
5193 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
5194 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
5195 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
5196 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
5197 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
5198 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
5199 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5200
5201 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
5202 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5203 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
5204 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
5205 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
5206 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
5207 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
5208 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5209 " Left join zzxcsrgh cs "+ ;
5210 " on cs.hdrpkey = h.pkey "+ ;
5211 " and cs.dtlpkey = 0 " +;
5212 "join " + .cSQLTempTable + " t " +;
5213 "on h.division= t.division and h.rng_style = t.style and "+;
5214 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5215 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5216 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5217 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
5218 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
5219 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
5220 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
5221 " else coalesce(cs.a_price,h.a_price) end " + ;
5222 " <> t.org_price)" +;
5223 " AND t.sizebucket = h.rng_bk"+ ;
5224 " Where cs.customer = t.customer "
5225 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
5226 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
5227
5228 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5229 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
5230 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) " + ;
5231 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
5232 " on d.division= r.division and d.style = r.rng_style and " + ;
5233 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
5234 " d.dimension= r.Rng_Pack " + ;
5235 " join zzeipocr c on c.division = d.division and h.customer = c.customer " + ;
5236 " 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
5237
5238 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
5239
5240 *- TR 1048790 FH 10/04/10
5241 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
5242 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
5243 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5244
5245 IF .lALLOW_RANGE_HDR_LABEL
5246 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 ;
5247 FROM (pcTransHeader) h, (pcTransDetail) d ;
5248 WHERE h.pkey = d.fkey ;
5249 AND d.Errs_Flg_D= 'N' AND ;
5250 Not EMPTY(h.price_code) AND ;
5251 d.rng_style= '' ;
5252 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5253 ELSE
5254 *--- TechRec 1084745 14-May-2015 jjanand === Added h.customer
5255 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5256 FROM (pcTransHeader) h, (pcTransDetail) d ;
5257 WHERE h.pkey = d.fkey ;
5258 And d.Errs_Flg_D= "N" And ;
5259 Not EMPTY(h.price_code) AND ;
5260 d.rng_style= '' ;
5261 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5262 ENDIF
5263
5264 .cSQLTempTable=""
5265 If .GenerateSQLTempTable('__TmpCursor')
5266 If .PopulateSQLTempTable('__TmpCursor')
5267 *- TR 1048790 FH 10/04/10
5268
5269 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5270 *-- TR 1040759 JUN-29-2009 BR
5271 IF .lALLOW_RANGE_HDR_LABEL
5272 *- TR 1048790 FH 10/04/10 - removed price check
5273 *- TR 1050589 12/13/10 FH
5274 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5275*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5276*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5277*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5278*!* "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 "+;
5279*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5280 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5281*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5282*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5283*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5284*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5285*!* "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 "+;
5286*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5287
5288 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5289 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5290 "join " + .cSQLTempTable + " t " +;
5291 "on h.division= t.division and h.rng_style = t.style and "+;
5292 "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 "+;
5293 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5294 " t.sizebucket = h.rng_bk"+ ;
5295 " Left join zzxcsrgh cs "+ ;
5296 " on cs.hdrpkey = h.pkey "+ ;
5297 " and cs.dtlpkey = d.pkey " +;
5298 " and cs.customer = t.customer " + ;
5299 " where d.fkey in " +;
5300 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5301 "Where h.division= t.division and h.rng_style = t.style and "+;
5302 "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 "+;
5303 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5304 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5305 *- TR 1050589 12/13/10 FH
5306 ELSE
5307 *== TR 1040759 JUN-29-2009 BR
5308 *- TR 1048790 FH 10/04/10 - removed price check
5309 *- TR 1050589 12/13/10 FH
5310 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5311
5312*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5313*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5314*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5315*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5316*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5317*!*
5318 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5319*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5320*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5321*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5322*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5323*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5324*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5325
5326 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5327 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5328 "join " + .cSQLTempTable + " t " +;
5329 "on h.division= t.division and h.rng_style = t.style and "+;
5330 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5331 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5332 " t.sizebucket = h.rng_bk"+ ;
5333 " Left join zzxcsrgh cs "+ ;
5334 " on cs.hdrpkey = h.pkey "+ ;
5335 " and cs.dtlpkey = d.pkey " +;
5336 " and cs.customer = t.customer " + ;
5337 " where fkey in " +;
5338 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5339 "Where h.division= t.division and h.rng_style = t.style and "+;
5340 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5341 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5342 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5343 *- TR 1050589 12/13/10 FH
5344 ENDIF && TR 1040759 JUN-29-2009 BR
5345 *=== TR 1038376 05-May-2009 Goutam
5346 endif &&- TR 1048790 FH 10/04/10
5347 ENDIF &&- TR 1048790 FH 10/04/10
5348
5349 *= 1000984
5350 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5351
5352 * turn Range detail to vertical (with sizebucket,size_desc)
5353 * have to explode in vertical format
5354 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5355 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5356 WHERE 0=1 Into Cursor __Range2
5357 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5358 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5359 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5360 If Used("__Range1")
5361 Use In __Range1
5362 Endif
5363 If Used("__Range2")
5364 Use In __Range2
5365 Endif
5366
5367 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5368 Select __RangH
5369 Index On pkey Tag pkey
5370 Select __RangD
5371 Index On division+Style Tag DivStyle
5372 Select tcRangeVer
5373 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5374 Set Order To RangeSKU
5375 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5376
5377 *****************************************************************************
5378 * 2). Validate "Run"- type of range style. divisible by range header qty
5379 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5380
5381 *****************************************************************************
5382 * 3). Explode range style only once good tran detail that have
5383 * matching range style. Vertical range style explosion
5384 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5385 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5386 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5387 Select Distinct d.pkey ;
5388 FROM __RangD r, (pcTransDetail) d ;
5389 WHERE d.Errs_Flg_D= "N" And ; &&no error
5390 d.rng_style= '' And ; &&never explode before
5391 r.division= d.division And r.rng_style = d.Style And ; && matching range
5392 r.rng_color= d.color_code And ;
5393 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
5394 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5395 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5396 INTO Cursor __DtlExpl
5397 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5398 Endif
5399 Endif
5400 Endif
5401 Endif
5402 Endif
5403 Endwith
5404
5405 If Used("__RangH")
5406 Use In __RangH
5407 Endif
5408 If Used("__RangD")
5409 Use In __RangD
5410 Endif
5411 If Used("tcRangeVer")
5412 Use In tcRangeVer
5413 Endif
5414 If Used("__DtlExpl")
5415 Use In __DtlExpl
5416 Endif
5417 If Used("__TmpCursor")
5418 Use In __TmpCursor
5419 Endif
5420
5421 *--- TR 1038376 05-May-2009 Goutam
5422 If Used("__RangTmpD")
5423 Use In __RangTmpD
5424 ENDIF
5425 this.TableClose(lcTmpCursor)
5426 *=== TR 1038376 05-May-2009 Goutam
5427
5428 Select(lnOldSelect)
5429 Return llRetVal
5430 Endproc
5431 *----------------------------------------------------------------------------------------
5432
5433 Procedure ExplodeRangeRef
5434 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5435 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5436 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5437
5438 lnOldSele= Select()
5439 lcDivStyle= ""
5440 * TAN 31891 - JAZ - 5/20/02
5441 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5442 lnSourceCnt= RecCount(pcRangeDetail)
5443 * End TAN 31891 - JAZ - 5/20/02
5444 llRetVal= .T.
5445 lnCurDtlFkey= 0
5446
5447 Select (pcRangeDetail)
5448 Set Order To DivStyle
5449 Scan
5450 *- 1009508 03/16/05 YIK
5451 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5452 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5453 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5454 *-- m.rng_type= &pcRangeHeader..rng_type
5455 *-- m.rng_qty= &pcRangeHeader..rng_qty
5456
5457 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5458 *-- m.coord_code= &pcRangeHeader..coord_code
5459 *-- m.rng_type= &pcRangeHeader..rng_type
5460 If lnCurDtlFkey<> fkey
5461 lnCurDtlFkey= fkey
5462 If Seek(fkey, pcRangeHeader , "PKEY")
5463 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5464 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5465 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5466 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5467 *= 1009508 YIK
5468 Else
5469 llRetVal = .F.
5470 Exit
5471 Endif
5472 Endif
5473
5474 * only run once per Div + Style
5475 If !(lcDivStyle == division + Style)
5476 lcDivStyle = division + Style
5477 * Insert a record for each size bucket with a caption *
5478 If !v_GetSizeHeadings(division, Style, "__xSizer")
5479 llRetVal = .F.
5480 Exit
5481 Endif
5482 Endif
5483
5484 Select (pcRangeDetail)
5485 Scatter Memvar Memo
5486 For lnSizePosition = 1 To goEnv.MaxBuckets
5487 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5488 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5489 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5490 m.sizebucket = lnSizePosition
5491 m.size_desc = lcSizeName
5492 m.total_qty = lnSizeQty
5493 If lnSizeQty > 0 && Only want buckets with activity!
5494 Insert Into (pcRangeDetailTarget) From Memvar
5495 Endif
5496 Endfor
5497
5498 Endscan
5499 This.TableClose("__xSizer")
5500 Select (pcRangeDetail)
5501 Select (lnOldSele)
5502 Return llRetVal
5503 Endproc
5504
5505 *----------------------------------------------------------------------------------------
5506
5507 Procedure ValidateRangeStyle
5508 Lparameters pcRangeStyle, pcTransDetail
5509 Local llRetVal, lnOldSelect, lcErrs_Msg
5510 llRetVal = .T.
5511 lnOldSelect = Select()
5512 lcErrs_Msg= "Total Units must be divisible by "
5513
5514 Select (pcRangeStyle)
5515 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5516 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5517 "division+style+color_code+lbl_code+dimension")
5518
5519 If llRetVal
5520 .LogEntry("Validating range style.")
5521 * Verify range style "R"un order in min multiple of rng_qty
5522 * no need for "S"et verification of range type --just explode to
5523 * range detail
5524 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5525 *- 1023438 04/06/07 YIK
5526 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5527 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5528 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5529 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5530 Errs_Flg_D With "Y" ;
5531 IN (pcTransDetail)
5532 Endif
5533 Endscan
5534 Endif
5535
5536 Set Relation To
5537 Select(lnOldSelect)
5538 Return llRetVal
5539 Endproc
5540
5541 *----------------------------------------------------------------------------------------
5542
5543 Procedure ExplodeRangeStyleVertical
5544 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5545 Local llRetVal, lnOldSelect, lcErrs_Msg
5546 llRetVal = .T.
5547 lnOldSelect = Select()
5548
5549 * --- TR 1034963 12/15/08 CM
5550 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5551 * === TR 1034963 12/15/08 CM
5552
5553 Select (pcDetailtoExplode)
5554 Scan
5555 * Find detail line that need range style exploding using PKEY
5556 If Seek(pkey, pcTransDetail, "Pkey")
5557 * Current working trans detail
5558 Select (pcTransDetail)
5559
5560
5561 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5562 *-- TR 1040759 JUN-29-2009 BR
5563*!* IF !EMPTY(lbl_code)
5564*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5565*!* ELSE
5566*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5567*!* ENDIF
5568 *== TR 1040759 JUN-29-2009 BR
5569 IF .lALLOW_RANGE_HDR_LABEL
5570
5571 IF !EMPTY(lbl_code)
5572 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5573
5574 else
5575 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5576 ENDIF
5577 else
5578
5579 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5580
5581 endIF
5582 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5583
5584 lnCurDtlTotal_qty= total_qty
5585
5586 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5587 *- 1009508 3/16/05 YIK
5588 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5589 lnRangeBucket = sizebucket
5590
5591 Scatter Name loTransDetail Memo
5592
5593 *--- TR 1038376 16-Feb-2009 Goutam
5594 loTransDetail.Rng_Price = loTransDetail.org_price
5595 *--- TR 1038376 16-Feb-2009 Goutam
5596
5597 * delete current working trans detail already have image
5598 * in loTransDetail
5599 Delete In (pcTransDetail)
5600
5601 * --- TR 1034963 12/15/08 CM
5602 lnDetailPkey = loTransDetail.pkey
5603 * === TR 1034963 12/15/08 CM
5604
5605 * --- TR 1018184 RLN 01/10/07
5606 lnDetailPkey = loTransDetail.pkey
5607 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5608 * === TR 1018184
5609
5610 Select (pcRangeDetailVert)
5611 * Find 1st match of OURSKU
5612 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5613 * calculate lnMultiplier regardless of rng_type
5614 * --"R"un only divisible by rng_qty will get to this point
5615 * --otherwise will stay in errs_dtl_F/msg
5616
5617 *- 1009508 3/16/05 YIK
5618 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5619 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5620 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5621 lnCurDtlTotal_qty/rng_qty)
5622
5623 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5624 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5625 * Exploding detail line
5626 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5627 If !Empty(loTransDetail.pkey)
5628
5629 * --- TR 1034963 12/15/08 CM
5630 lcDetailNotes = GetUniqueFileName()
5631 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey)
5632 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5633 * === TR 1034963 12/15/08 CM
5634
5635 *- 1009508 3/16/05 YIK
5636 Select (pcRangeDetailVert)
5637 Scatter Name loVert Memo
5638 *= 1009508
5639
5640 Select (pcTransDetail)
5641 Append Blank
5642 Gather Name loTransDetail Memo
5643
5644 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5645 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5646 * only recording a..e_price to zzeipoth and resetting org_price
5647 *org_price with &pcRangeDetailVert..a_price,
5648
5649 *- 1009508 3/16/05 YIK
5650 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5651 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5652 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5653 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5654 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5655 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5656 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5657 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5658 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5659 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5660 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5661 *-- division WITH &pcRangeDetailVert..division, ;
5662 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5663 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5664 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5665 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5666 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5667 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5668 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5669 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5670 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5671 *-- e_price WITH &pcRangeDetailVert..e_price ;
5672 *-- IN (pcTransDetail)
5673
5674 *- 1022149 03/06/07 YIK
5675 *- do not zero out org_price for MultiUPC
5676 Replace rng_style With loVert.rng_style, ;
5677 rng_color With loVert.rng_color, ;
5678 rng_lbl With loVert.rng_lbl, ;
5679 rng_pack With loVert.rng_pack, ;
5680 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5681 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5682 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5683 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5684 total_qty With lnMultiplier * loVert.total_qty, ;
5685 sizebucket With loVert.sizebucket, ;
5686 size_desc With loVert.size_desc, ;
5687 division With loVert.division, ;
5688 STYLE With loVert.Style, ;
5689 color_code With loVert.color_code, ;
5690 lbl_code With loVert.lbl_code, ;
5691 DIMENSION With loVert.Dimension, ;
5692 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5693 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5694 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5695 a_price With loVert.a_price,; && 4186- store a..e_price
5696 b_price With loVert.b_price,; && from range style detail
5697 c_price With loVert.c_price,; && to use latter when have
5698 d_price With loVert.d_price,; && price_code
5699 e_price With loVert.e_price ;
5700 IN (pcTransDetail)
5701 *= 1009508 03/16/05 YIK
5702 * --- TR 1018184 RLN 01/10/07
5703 Select tmpRngSacs
5704 Scan
5705 Scatter Name loTmpSACs Memo
5706 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5707 loTmpSACs.dfkey = loTransDetail.pkey
5708 Insert Into (tcTransSAC) From Name loTmpSACs
5709 Endscan
5710 * === TR 1018184
5711
5712 * --- TR 1034963 12/15/08 CM
5713 If llDtlRangeNotes
5714 Select (lcDetailNotes)
5715 Scan
5716 Scatter Name loTmpDetNotes Memo
5717
5718 * --- TR 1045865 3/8/10 CM
5719 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5720 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5721 * === TR 1045865 3/8/10 CM
5722
5723 loTmpDetNotes.fkey = loTransDetail.pkey
5724 SELECT('Vzzeipotd_notes_iPOproc')
5725 Append Blank
5726 Gather Name loTmpDetNotes Memo
5727 Endscan
5728 Endif
5729
5730 IF USED(lcDetailNotes)
5731 USE IN (lcDetailNotes)
5732 ENDIF
5733 * === TR 1034963 12/15/08 CM
5734
5735 Else
5736 llRetVal= .F. && Cannot get Pkey from bcsysnum
5737 Exit
5738 Endif
5739
5740 Select (pcRangeDetailVert)
5741 Endscan
5742 Else
5743 llRetVal= .F. && Should be in pcrangdetailvert
5744 Exit
5745 Endif
5746 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5747 Endif
5748
5749 If !llRetVal &&Get out of scan when have some problem
5750 Exit
5751 Endif
5752 Endscan
5753
5754 * --- TR 1034963 12/15/08 CM
5755 If llDtlRangeNotes
5756 This.UpdateSysNotes()
5757 Endif
5758 * === TR 1034963 12/15/08 CM
5759
5760 Select(lnOldSelect)
5761 Return llRetVal
5762 Endproc
5763
5764 *----------------------------------------------------------------------------------------
5765
5766 Procedure PrepackConversion
5767 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5768 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5769 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5770 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5771 llRetVal = .T.
5772 lnOldSelect = Select()
5773
5774 * --- TR 1046519 7/26/10 CM
5775 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5776 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5777
5778 STORE "" To lcSumSln, lcError, lcPPKAction
5779 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5780 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5781 * === TR 1046519 7/26/10 CM
5782
5783 *****************************************************************************
5784 * 1st Getting all prepack headers
5785 *--- 1001112 9/26/03 YIK
5786 *- process all.
5787 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5788 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5789 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5790 *!* and d.rng_style= '' ; && none exploded range style
5791 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5792 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5793
5794 *- 1013522 10/10/05 12/02/05 YIK
5795 *- Exclude range style P from the consideration
5796 *- Do not close this cursor. It is needed in CheckSLN()
5797 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5798 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5799
5800 *- 1025153 10/22/07 YIK - comment out
5801 * --- TR 1022896 NSD 05-10-07
5802*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5803 * === TR 1022896 NSD 05-10-07
5804
5805 *- 1005499 07/06/04 YIK
5806 *- Change d.rng_style = '' to EMPTY(d.rng_style)
5807
5808 *- 1023438 04/05/07 YIK
5809 *- Allow to check Range Style type 'R'.
5810 *- Needed for MultiUPC and a good idea anyway.
5811 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
5812
5813 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
5814
5815*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5816*!* FROM (pcTransDetail) d ;
5817*!* WHERE Empty(d.rng_style) ; && none exploded range style
5818*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5819*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5820*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5821*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5822
5823 *--- TechRec 1044487 18-Mar-2010 JK ---
5824*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5825*!* FROM (pcTransDetail) d ;
5826*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
5827*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5828*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5829*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5830*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5831
5832 * --- TR 1046519 7/26/10 CM
5833 IF RECCOUNT(pcSLN) > 0
5834 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
5835 JOIN (pcTransDetail) d ;
5836 ON s.fkey = d.pkey ;
5837 JOIN (pceipoCR) c ;
5838 ON d.division = c.division ;
5839 AND d.customer = c.customer ;
5840 WHERE s.sln_qty > 0 ;
5841 GROUP BY s.fkey ;
5842 INTO CURSOR __SumSlnQty
5843
5844 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
5845
5846 WITH THIS
5847 .cSQLTempTable=""
5848 IF .GenerateSQLTempTable('__SumSlnQty')
5849 IF .PopulateSQLTempTable('__SumSlnQty')
5850 lcSumSln = .cSQLTempTable
5851 IF !EMPTY(lcSumSln)
5852 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
5853 ENDIF
5854 ENDIF
5855 ENDIF
5856 ENDWITH
5857 ENDIF
5858 * === TR 1046519 7/26/10 CM
5859
5860 *--- TechRec 1089737 21-Dec-2015 jisingh ---
5861 IF !EMPTY(This.cOverridePpkAction)
5862 REPLACE ALL ppk_action WITH This.cOverridePpkAction ;
5863 FOR EMPTY(ppk_action) OR ppk_action $ 'QPBO' IN (pcTransDetail)
5864 ENDIF
5865 *=== TechRec 1089737 21-Dec-2015 jisingh ===
5866
5867 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
5868 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
5869 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
5870 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
5871 FROM (pcTransDetail) d ;
5872 JOIN (pceipoCR) c ON c.customer = d.customer ;
5873 AND c.division = d.division ;
5874 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
5875 AND (c.rngp_conv = 'P' ;
5876 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
5877 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
5878 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5879 AND c.ppk_conv <> 'N' ;
5880 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5881 *=== TechRec 1044487 18-Mar-2010 JK ===
5882
5883 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
5884 *== 1023438
5885
5886 *=== 1013522
5887 *=== 1001112
5888 With This
5889 .cSQLTempTable=""
5890 If .GenerateSQLTempTable('__TmpCursor')
5891 If .PopulateSQLTempTable('__TmpCursor')
5892 If !Empty(.cSQLTempTable)
5893 *- TR 1025153 06/14/07 YIK
5894 *- Use the OUTER JOIN, then we have all details needed
5895 *- and can simply scan for !EOF() later on.
5896*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
5897*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
5898*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
5899*-- "s.style= t.style and s.color_code= t.color_code and " +;
5900*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
5901*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
5902*-- "s.dimension= ph.ppk_code"
5903 *--- TR 1026025 NH - use size_code from zzxstylr
5904 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
5905 * using sln_qty instead of ppk_qty
5906
5907 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
5908 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
5909 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
5910 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
5911 " ,st.size_code " +; && 1026025
5912 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
5913 " from " + .cSQLTempTable + " t " +;
5914 " JOIN zzxscolr s " + ;
5915 " ON s.division= t.division and " +;
5916 " s.style= t.style and s.color_code= t.color_code and " +;
5917 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
5918 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
5919 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
5920 " LEFT OUTER JOIN zzxppakh ph " + ;
5921 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
5922 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
5923 " Where s.ppack_ok= 'Y' "
5924
5925 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
5926 If Used("_PPK_Qty")
5927 Select ("_PPK_Qty")
5928 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
5929 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
5930 "division+style+color_code+lbl_code+dimension")
5931 SELECT ("__TmpCursor")
5932
5933 If llRetVal
5934 .LogEntry("Validating prepack style.")
5935 lcErrs_Msg = "No valid prepack code found"
5936 Select (pcTransDetail)
5937 *- 1005499 07/06/04 YIK
5938 *- Replace ..Errs_Flg_D= "N") and rng_style=''
5939 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
5940 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
5941*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
5942 *- TR 1025153 06/14/07 YIK
5943 *- Since we use the OUTER JOIN, can simply scan for !EOF()
5944 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
5945 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
5946
5947 If Empty(_PPK_Qty.pack_qty)
5948 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
5949 Errs_Flg_D With "Y" ;
5950 IN (pcTransDetail)
5951 Else
5952 Do Case
5953
5954 * --- TR 1040838 6/11/09 CM
5955 * --- Check prepack action based on Transaction detail
5956 * Removed _PPK_Qty Alias
5957 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
5958 Case ppk_action = 'Q' && multiply qty
5959 * === TR 1040838 6/11/09 CM
5960
5961 * --- TR 1046519 7/26/10 CM
5962 * At this point we know we have some slns to use for our alternate
5963 * conversion, lets just make sure that the conversion type is 'E'
5964 IF llConvertBySln
5965 lcPPKAction = ppk_action
5966 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5967 lnOrigQty = total_qty
5968 lnPpkQty = ppk_qty
5969 ENDIF
5970 * === TR 1046519 7/26/10 CM
5971
5972 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5973 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5974 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5975 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5976 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
5977 In (pcTransDetail)
5978
5979 * --- TR 1046519 7/26/10 CM
5980 IF llSlnConvert
5981 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5982 IF llRemain
5983 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5984 Errs_Flg_D WITH "Y" , ;
5985 ppk_action WITH lcPPKAction , ;
5986 total_qty WITH lnOrigQty ;
5987 In (pcTransDetail)
5988 ENDIF
5989 ENDIF
5990 * ==== TR 1046519 7/26/10 CM
5991
5992 * --- TR 1040838 6/11/09 CM
5993 * Removed _PPK_Qty Alias
5994 *Case _PPK_Qty.ppk_action = 'P' && divide price
5995 Case ppk_action = 'P' && divide price
5996 * === TR 1040838 6/11/09 CM
5997
5998 * --- TR 1046519 7/26/10 CM
5999 * At this point we know we have some slns to use for our alternate
6000 * conversion, lets just make sure that the conversion type is 'E'
6001 IF llConvertBySln
6002 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6003 ENDIF
6004 * === TR 1046519 7/26/10 CM
6005
6006 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6007 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6008 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6009 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6010 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6011 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6012 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6013 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
6014 In (pcTransDetail)
6015 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6016 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6017 *- Range style price will be populated later from a_price..e_price
6018 *- not from org_price. Need to updated these prices here.
6019 IF rng_type = 'R'
6020 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6021 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6022 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6023 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6024 e_price WITH e_price/_PPK_Qty.pack_qty ;
6025 In (pcTransDetail)
6026 ENDIF
6027 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6028
6029 * --- TR 1040838 6/11/09 CM
6030 * Removed _PPK_Qty Alias
6031 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
6032 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
6033 * === TR 1040838 6/11/09 CM
6034
6035 * --- TR 1046519 7/26/10 CM
6036 IF llConvertBySln
6037 lcPPKAction = ppk_action
6038 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
6039 lnOrigQty = total_qty
6040 lnPrice = org_price
6041 lnretail1 = retail1
6042 lnretail2 = retail2
6043 lnPpkQty = ppk_qty
6044 ENDIF
6045 * === TR 1046519 7/26/10 CM
6046
6047 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
6048 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
6049 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
6050 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6051 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
6052 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
6053 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
6054 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
6055 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
6056 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
6057 In (pcTransDetail)
6058
6059 * --- TR 1046519 7/26/10 CM
6060 IF llSlnConvert
6061 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6062 IF llRemain
6063 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6064 Errs_Flg_D WITH "Y", ;
6065 ppk_action WITH lcPPKAction , ;
6066 total_qty WITH lnOrigQty , ;
6067 org_price WITH lnPrice , ;
6068 retail1 WITH lnretail1 , ;
6069 retail2 WITH lnretail2 , ;
6070 ppk_qty WITH lnPpkQty ;
6071 In (pcTransDetail)
6072 ENDIF
6073 ENDIF
6074 * ==== TR 1046519 7/26/10 CM
6075
6076 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6077 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6078 IF rng_type = 'R'
6079 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6080 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6081 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6082 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6083 e_price WITH e_price/_PPK_Qty.pack_qty ;
6084 In (pcTransDetail)
6085 ENDIF
6086 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6087
6088 Otherwise
6089 Endcase
6090 Endif
6091 Endscan
6092 Endif
6093 Set Relation To
6094 Endif
6095 Endif
6096 Endif
6097 Endif
6098 Endwith
6099 If Used("__TmpCursor")
6100 Use In __TmpCursor
6101 Endif
6102 If Used("_PPK_Qty")
6103 Use In _PPK_Qty
6104 Endif
6105
6106 * --- TR 1046519 7/26/10 CM
6107 IF USED("__SumSlnQty")
6108 USE IN __SumSlnQty
6109 ENDIF
6110 * === TR 1046519 7/26/10 CM
6111
6112 Select(lnOldSelect)
6113 Return llRetVal
6114
6115 *----------------------------------------------------------------------------------------
6116 *- 1006607 09/02/04 YIK
6117 Function ResolveRangeP
6118 Lparameters pceipoTH, pceipoTD, pceipoCR
6119
6120 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
6121 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
6122 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
6123 llRetVal = .T.
6124 lnOldSelect = Select()
6125 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6126 lcRngp_conv = ""
6127 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6128
6129 With This
6130 .oLog.LogMajorStage("Range Style Implosion.")
6131 *- do we have any range styles 'P' in BC
6132 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
6133 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
6134 If !llRetVal Or Recc("tcTemp") = 0
6135 .oLog.LogEntry("No range styles for implosion")
6136 Return llRetVal
6137 Endif
6138
6139 *- 1007637 11/17/04 YIK
6140 *- Allow open stock: Rng_impl = 'O'
6141 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
6142 *- implode only orders that have not been range imploded (empty range style)
6143 *- and were not prepack imploded (implosion <> "Y")
6144 *!* select distinct fkey ;
6145 *!* from (pceipoTd) d ;
6146 *!* join (pceipoCR) c ;
6147 *!* on d.division = c.division and d.customer = c.customer ;
6148 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
6149 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
6150 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
6151 *!* into cursor rng_det
6152
6153*- 1047842/1048069 07/01/10 YIK
6154*- Implode only orders with no detail errors
6155*-- Select Distinct fkey, C.Rng_impl ;
6156*-- FROM (pceipoTD) d ;
6157*-- JOIN (pceipoCR) C ;
6158*-- ON d.division = C.division And d.customer = C.customer ;
6159*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6160*-- AND !Empty(d.division) And !Empty(d.customer) ;
6161*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
6162*-- INTO Cursor rng_det
6163
6164 *- TR 1058336 FH - added division to select, and group by
6165 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
6166 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6167 FROM (pceipoTD) d ;
6168 JOIN (pceipoCR) C ;
6169 ON d.division = C.division And d.customer = C.customer ;
6170 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6171 AND !Empty(d.division) And !Empty(d.customer) ;
6172 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6173 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6174 HAVING MAX(errs_flg_d) = 'N' ;
6175 INTO Cursor rng_det
6176*===
6177
6178 *==
6179 *--- TR 1023892 NH
6180 IF .lALLOW_RANGE_HDR_LABEL
6181 &&- TR 1058336 FH - added qualifier for division
6182 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
6183 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6184 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 ;
6185 FROM (pceipoTD) d ;
6186 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6187 WHERE !EMPTY(d.STYLE) ;
6188 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
6189 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
6190 INTO CURSOR __TmpCurs
6191 ELSE
6192 &&- TR 1058336 FH - added qualifier for division
6193 *=== TR 1023892 NH
6194 *- 1047842/1048069 07/01/10 YIK
6195 *- Added d.pkey
6196 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6197 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
6198 FROM (pceipoTD) d ;
6199 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6200 WHERE !Empty(d.Style) ;
6201 AND !Empty(d.division) And !Empty(d.customer) ;
6202 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6203 INTO Cursor __tmpCurs
6204 ENDIF && TR 1023892 NH
6205 .cSQLTempTable=""
6206 If .GenerateSQLTempTable('__TmpCurs')
6207 If .PopulateSQLTempTable('__TmpCurs')
6208 If !Empty(.cSQLTempTable)
6209 Select rng_det
6210 Scan
6211 lnFKey = rng_det.fkey
6212 *- 1007637 11/17/04 YIK
6213 lcRng_Impl = rng_det.Rng_impl
6214
6215 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6216 lcRngp_conv = rng_det.Rngp_conv
6217 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6218
6219 lcDivision = rng_det.division &&- TR 1058336 FH
6220
6221 *- one order at a time. Select on the server side.
6222 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
6223 dtl = SQLTableFromQuery(lcSQLStr )
6224 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
6225
6226 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
6227 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
6228
6229 Select (pceipoTD)
6230 Do Case
6231 Case lnResult = 0 && match not found
6232 *- 1007637 11/17/04 YIK
6233 If lcRng_Impl = 'Y'
6234
6235 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
6236 Errs_Flg_D With "Y" ;
6237 FOR fkey = lnFKey And !Empty(Style) ;
6238 AND !Empty(division) And !Empty(customer) ;
6239 AND Empty(rng_style) And implosion <> "Y"
6240 Endif
6241 Case lnResult > 1 && ambiguous
6242 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
6243 *- 1049007 08/24/10 YIK
6244 *- List all ambiguous Range Styles
6245 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
6246 Errs_Flg_D With "Y" ;
6247 FOR fkey = lnFKey And !Empty(Style) ;
6248 AND !Empty(division) And !Empty(customer) ;
6249 AND Empty(rng_style) And implosion <> "Y"
6250*!* lcErrorMsg = " Ambiguous range styles "
6251*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
6252*!* lcErrorMsg = lcErrorMsg + ": "
6253*!* SELECT __tmp
6254*!* SCAN
6255*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
6256*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
6257*!* EndScan
6258*!* SELECT(pceipoTD)
6259*!* ENDIF
6260*!*
6261*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
6262*!* Errs_Flg_D With "Y" ;
6263*!* FOR fkey = lnFKey And !Empty(Style) ;
6264*!* AND !Empty(division) And !Empty(customer) ;
6265*!* AND Empty(rng_style) And implosion <> "Y"
6266 *=== 1049007
6267 Endcase
6268 Endscan
6269 Endif
6270 Endif
6271 Endif
6272
6273 Endwith
6274 Select (lnOldSelect)
6275 Return llRetVal
6276 Endfunc
6277
6278 Function RangeImplosion
6279 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6280 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6281 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6282
6283 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6284 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6285 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6286
6287 llRetVal = .T.
6288 lnOldSelect = Select()
6289 With This
6290
6291 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6292 *- turn them vertical into SQL-side temp table var. RangD
6293 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6294 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6295*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6296*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6297*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6298*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6299*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6300*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6301
6302*!* Added following join
6303*!* " join " + dtl + " td1 " +;
6304*!* " on d.style = td1.style " +;
6305*!* " and d.color_code = td1.color_code " +;
6306*!* " and d.lbl_code = td1.lbl_code " +;
6307*!* " and d.dimension = td1.dimension "
6308
6309 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6310
6311 *--- TR 1084825 20-Feb-2015 BNarayanan adding the join on division, sizebucket for the dtl table join ---
6312 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6313 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6314 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6315 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6316 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6317 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6318 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6319 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6320 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6321 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6322 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6323 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6324 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6325 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6326 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6327 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6328 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6329 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6330 "coalesce(cs.e_price,d.e_price) as e_price "+;
6331 "from ( " +;
6332 " select dd.* from zzxrangd dd " +;
6333 " where fkey in ( " +;
6334 " select distinct ph.pkey " +;
6335 " from zzxrangh ph " +;
6336 " join zzxrangd pd " +;
6337 " on ph.Pkey = Pd.Fkey " +;
6338 " join " + dtl + " td1 " +;
6339 " on pd.division = td1.division " + ; && TR 1084825 03-Mar-2015 BNarayanan
6340 " and pd.style = td1.style " +;
6341 " and pd.color_code = td1.color_code " +;
6342 " and pd.lbl_code = td1.lbl_code " +;
6343 " and pd.dimension = td1.dimension " +;
6344 " where ph.rng_type = 'P' " +;
6345 " and not exists( " +;
6346 " select * " +;
6347 " from zzxrangd da " +;
6348 " left join " + dtl + " det " +;
6349 " on det.division= da.division" +; && TR 1084825 03-Mar-2015 BNarayanan
6350 " and det.style = da.style " +;
6351 " and det.color_code = da.color_code " +;
6352 " and det.lbl_code = da.lbl_code " +;
6353 " and det.dimension = da.dimension " +;
6354 " where da.Fkey = ph.pkey " +;
6355 " and (det.Pkey is null " +;
6356 " or case det.SizeBucket " +;
6357 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6358 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6359 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6360 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6361 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6362 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6363 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6364 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6365 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6366 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6367 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6368 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6369 " ) ) d " +;
6370 " join zzxbuckt b " +;
6371 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6372 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6373 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6374 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6375 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6376 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6377 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6378 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6379 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6380 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6381 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6382 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 " + ;
6383 " join " + dtl + " td1 " +;
6384 " on d.division = td1.division " +; && TR 1084825 20-Feb-2015 BNarayanan
6385 " and d.style = td1.style " +;
6386 " and d.color_code = td1.color_code " +;
6387 " and d.lbl_code = td1.lbl_code " +;
6388 " and d.dimension = td1.dimension "+;
6389 " and size_num = td1.sizebucket " +; && TR 1084825 20-Feb-2015 BNarayanan
6390 " Left join zzxcsrgh cs "+ ;
6391 " on cs.dtlpkey = d.pkey "+ ;
6392 " and cs.customer = td1.customer "
6393
6394 RangD = SQLTableFromQuery(lcSQLString)
6395
6396 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6397 *- possible combinations of RangD that cover them.
6398 *- Result is SQL-side temp table var. RangeSet
6399 *- 1047842/1048069 07/01/10 YIK
6400 *- Added td.pkey
6401 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6402 *--- 1049007 08/24/10 YIK
6403 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6404 *- to check for components divisibility
6405 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6406 *--- TR 1084825 03-Mar-2015 BNarayanan added td.division in the select ---
6407 lcSQLString = ;
6408 'select td.division,td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6409 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6410 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6411 ',td.pkey as dtl_pkey ' + ;
6412 ' from ' + dtl + ' td ' + ;
6413 ' cross join ( ' + ;
6414 ' select * ' + ;
6415 ' from zzxrangh H ' + ;
6416 ' where exists ( ' + ;
6417 ' select * ' + ;
6418 ' from ' + RangD + ' dd ' + ;
6419 ' join ' + dtl + ' td1 ' + ;
6420 ' on dd.Division = td1.Division ' + ;
6421 ' and dd.style = td1.style ' + ;
6422 ' and dd.color_code = td1.color_code ' + ;
6423 ' and dd.lbl_code = td1.lbl_code ' + ;
6424 ' and dd.dimension = td1.dimension ' + ;
6425 ' and dd.size_bk = td1.sizebucket ' + ;
6426 ' where dd.FKey = H.PKey )) mtch ' + ;
6427 ' left join ' + RangD + ' D ' + ;
6428 ' on d.FKey = mtch.PKey ' + ;
6429 ' and d.Division = td.Division ' + ;
6430 ' and d.style = td.style ' + ;
6431 ' and d.color_code = td.color_code ' + ;
6432 ' and d.lbl_code = td.lbl_code ' + ;
6433 ' and d.dimension = td.dimension ' + ;
6434 ' and d.size_bk = td.sizebucket ' + ;
6435 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6436 *==104900708/24/10YIK
6437 RangeSet = SQLTableFromQuery(lcSQLString)
6438
6439 * --- TR 1048126 8/23/10 CM
6440 v_SqlExec(lcSQLString, "tcRangeSet")
6441
6442 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6443*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6444*!*
6445*!* UPDATE d ;
6446*!* SET ppk_qty = -1 ;
6447*!* FROM (pceipoTD) d ;
6448*!* JOIN tcRangeSet r ;
6449*!* ON d.pkey = r.dtl_pkey ;
6450*!* WHERE d.ppk_action $ 'XM'
6451*!*
6452*!* ENDIF
6453 *=== TR 1051390 23-Dec-2010 Goutam
6454
6455 * === TR 1048126 8/23/10 CM
6456
6457 *- how many different range styles were found for this order
6458 *--- 1049007 08/24/10 YIK
6459 *- Modify logic to determine ambiguos Range Styles
6460*-- lcSQLString = ;
6461*-- ' select count(*) PPKCnt ' + ;
6462*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6463
6464 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6465 *= 1049007
6466
6467 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6468 lnPPKCnt = tmp_cnt.PPKCnt
6469
6470 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6471 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6472 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6473
6474 *--- the result (Query #2):
6475 *- See if any single range style in the RangeSet fully matches DTL
6476 *- 1047842/1048069 07/01/10 YIK
6477 *- added t1dtl_pkey
6478 lcSQLString = ;
6479 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6480 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6481 ' from ' + dtl + ' dtl ' + ;
6482 ' join ' + RangeSet + ' t1 ' + ;
6483 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6484 ' and dtl.style = t1.style ' + ;
6485 ' and dtl.color_code = t1.color_code ' + ;
6486 ' and dtl.lbl_code = t1.lbl_code ' + ;
6487 ' and dtl.dimension = t1.dimension ' + ;
6488 ' and dtl.sizebucket = t1.sizebucket ' + ;
6489 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6490 ' having count(*) = (select count(*) from ' + dtl + ') '
6491 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6492 lnCnt = Reccount()
6493
6494 *- 1049007 08/24/10 YIK
6495 *- Exclude Range styles that are not divisible
6496 IF (lnCnt > 0)
6497 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6498 lnCnt = _TALLY
6499 ENDIF
6500 *=
6501
6502 llSingleMatch = .F.
6503 llAmbig = .F.
6504 *- 1047842/1048069 07/01/10 YIK
6505 *- Added ValidDetail
6506 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6507 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6508 Do Case
6509 Case lnCnt > 1
6510 *- 1049007 08/24/10 YIK
6511 USE IN SELECT("__tmp")
6512 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6513 *=
6514 llAmbig = .T. && ambiguos, give error message and do not continue
6515 Case lnCnt = 1
6516 llSingleMatch = .T.
6517 *- 1047842/1048069 07/01/10 YIK
6518 *- Added ValidDetail
6519 *- 1049007 08/26/10 YIK
6520 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6521* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6522 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6523 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6524
6525 Otherwise
6526 Endcase
6527 *- 1049007 08/24/10 YIK
6528 *- commented out. This method is not called with this parameter = .T.
6529*--- IF tlNoConsol
6530*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6531*--- ENDIF
6532
6533 lnResult = lnCnt
6534
6535 If !llAmbig
6536 *- If none single range style in the RangeSet fully matches DTL,
6537 *- or even if a match was found
6538 *- start going through combinations of 2,3... - may be ambiguous
6539
6540 *- 1047842/1048069 07/01/10 YIK
6541 *- added t1dtl_pkey
6542 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6543
6544 lcTopStr = ;
6545 ' from ' + dtl + ' dtl ' + ;
6546 ' join ' + RangeSet + ' t1 ' + ;
6547 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6548 ' and dtl.style = t1.style ' + ;
6549 ' and dtl.color_code = t1.color_code ' + ;
6550 ' and dtl.lbl_code = t1.lbl_code ' + ;
6551 ' and dtl.dimension = t1.dimension ' + ;
6552 ' and dtl.sizebucket = t1.sizebucket '
6553
6554 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6555 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6556 lcMiddleStr = ''
6557 lcCoalStr_pkey = 't1.pkey'
6558 lcCoalRevStr_pkey = 't1.pkey'
6559 lcCoalStr_ratio = 't1.ratio'
6560 lcCoalRevStr_ratio = 't1.ratio'
6561 lcGroupFkeyStr = ' t1.FKey'
6562 lcGroupStr = ''
6563
6564 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6565 *lnPrepacks = Min(lnPPKCnt, 6)
6566 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6567 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6568 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6569
6570 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6571
6572 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6573 llFoundNext = .F.
6574
6575 lcnum = Trans(j, "9")
6576 lcPrevNum = Trans(j - 1, "9")
6577 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6578 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6579
6580 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6581
6582 *-- TR 1049817 Oct-12-2010 BR
6583 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6584 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6585 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6586 *== TR 1049817 Oct-12-2010 BR
6587
6588 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6589
6590 *--- TR 1049817 Oct-12-2010 BR
6591 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6592 lcGroupStr = lcGroupFkeyStr
6593 *=== TR 1049817 Oct-12-2010 BR
6594
6595 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6596 *- 06/30/10 YIK LOCAL ONLY
6597 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6598 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6599 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6600 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6601
6602 lcMiddleStr = lcMiddleStr + ;
6603 "join " + RangeSet + " t" + lcnum + ;
6604 ' on dtl.division = t' + lcnum + '.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6605 ' and dtl.style = t' + lcnum + '.style ' + ;
6606 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6607 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6608 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6609 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6610 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6611
6612 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6613 ' Group by ' + lcGroupStr
6614
6615 *--- TR 1049817 Oct-12-2010 BR
6616 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6617 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6618 *=== TR 1049817 Oct-12-2010 BR
6619
6620 *--- TR 1050754 NOV-15-2010 BR
6621 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6622 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6623 *=== TR 1050754 NOV-15-2010 BR
6624
6625 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6626 lnCnt = Reccount()
6627 llFoundNext = (lnCnt = 1)
6628 *- ambig when either prev or this SQL returned more than 1 row or
6629 *- one match was found before AND one is found now - making it two.
6630 If lnCnt > 0
6631 Scan
6632 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6633 *- divisible by the number of items in the range style!!!
6634
6635 *---TR 1049817 Oct-12-2010 BR
6636 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6637 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6638 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6639 *===TR 1049817 Oct-12-2010 BR
6640 Else
6641 lcInsertStr = Trans(fkey)
6642 *- 1047842 06/17/10 YIK
6643 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6644
6645 For lnCounter = 2 To j
6646
6647 *- TR 1055009 FH - added If statement
6648 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6649
6650 else
6651 *- 1047842 06/17/10 YIK
6652 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6653 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6654 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6655 *- Added ValidDetail
6656 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6657 ENDIF
6658 *- TR 1055009 FH
6659
6660 Endfor
6661
6662 *---TR 1049817 Oct-12-2010 BR
6663 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6664 lcInsertRatioStr = Trans(t1_ratio)
6665
6666 For lnCounter = 2 To j
6667 *- TR 1055009 FH - added If statement
6668 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6669
6670 ELSE
6671 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6672 ENDIF
6673 *- TR 1055009 FH - added If statement
6674 ENDFOR
6675 *== =TR 1049817 Oct-12-2010 BR
6676
6677 *- 1047842/1048069 07/01/10 YIK
6678 *- Added ValidDetail
6679 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6680 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6681
6682 Endif
6683 Endscan
6684 Endif
6685 lnResultCnt = Recc("q_Result")
6686 llAmbig = (lnResultCnt > 1)
6687 llSingleMatch = (lnResultCnt = 1)
6688 If llAmbig
6689 lnResult = lnResultCnt
6690 Exit
6691 Endif
6692 Endfor
6693 If llSingleMatch
6694 lnResult = 1
6695 IF NOT tlNoConsol
6696 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6697
6698 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6699 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6700 ENDIF
6701 Endif
6702 Else && ambiguous
6703 lnResult = lnCnt
6704 Endif
6705
6706 *--- TR 1051390 23-Dec-2010 Goutam
6707 *--- 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
6708 *IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6709 IF VARTYPE(pceipoTD) <> 'L' AND lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6710 *=== TR 1092774 27-Jan-2016 BNarayanan ===
6711 UPDATE d ;
6712 SET ppk_qty = -1 ;
6713 FROM (pceipoTD) d ;
6714 JOIN tcRangeSet r ;
6715 ON d.pkey = r.dtl_pkey ;
6716 WHERE d.ppk_action $ 'XM'
6717 ENDIF
6718 *=== TR 1051390 23-Dec-2010 Goutam
6719
6720 Endwith
6721 Return lnResult
6722
6723 Procedure ConsolidateRangeP
6724 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6725 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6726 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6727
6728 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6729
6730 LOCAL lcDvision && 1058336 FH
6731
6732 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6733 LOCAL lnOrgPrice
6734 IF EMPTY(pcRngp_conv )
6735 pcRngp_conv = "N"
6736 ENDIF
6737 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6738
6739 llRetVal = .T.
6740 lnOldSelect = Select()
6741
6742 *- insert range styles that match zzxrangd.fkey from q_result
6743 *- into pceipotd.
6744 *- parse the string from cursor q_result to get the list of fkeys
6745 *- 1047842/1048069 07/01/10 YIK
6746 *- Moved Locate down
6747*-- Select (pceipoTD)
6748*-- Locate For fkey = pnFkey
6749*-- Scatter Name oDtl Memo
6750
6751 Declare aRange[1]
6752 aRange = ''
6753 Select q_Result
6754 Scatter Memvar Memo
6755 *- 1030497 02/29/08 TT
6756 *--StringToArray(m.ValidRange, @aRange, ",")
6757
6758 *--TR 1040854 Jun-11-09 BR
6759 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6760 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6761 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6762 *==TR 1040854 Jun-11-09 BR
6763
6764 *- 1030497 02/29/08 TT
6765 *-- TR 1049817 Oct-12-2010 BR
6766 *lnLen = Alen(aRange) - 1 && the last element is ratio
6767 lnLen = Alen(aRange)
6768 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6769 *== TR 1049817 Oct-12-2010 BR
6770
6771 *- 1047842/1048069 07/01/10 YIK
6772 Declare aDetail[1]
6773 aDetail = ''
6774 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6775 *= 1047842/1048069
6776
6777 *-- TR 1049817 Oct-12-2010 BR
6778 DECLARE aRatios[1]
6779 aRatios = ''
6780 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6781 *== TR 1049817 Oct-12-2010 BR
6782
6783 For j = 1 To lnLen
6784 lcFkey = aRange[j]
6785 *- 1047842/1048069 07/01/10 YIK
6786 lnDtl_Pkey = EVALUATE(aDetail[j])
6787 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6788
6789 Select (pceipoTD)
6790 Locate For pkey = lnDtl_Pkey
6791 Scatter Name oDtl Memo
6792 *= 1047842/1048069
6793 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6794*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6795 *--- TR 1084825 20-Feb-2015 BNarayanan removed the column h.RNG_PACK_001, which is not available in zzxrangh table and where clause ---
6796 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6797 " coalesce(cs.a_price,h.a_price) as a_price, "+;
6798 " coalesce(cs.b_price,h.b_price) as b_price, "+;
6799 " coalesce(cs.c_price,h.c_price) as c_price, "+;
6800 " coalesce(cs.d_price,h.d_price) as d_price, "+;
6801 " coalesce(cs.e_price,h.e_price) as e_price, "+;
6802 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
6803 " h.SOURCETYPE,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
6804 " From zzxrangh h " + ;
6805 " Left Join zzxcsrgh cs "+ ;
6806 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
6807 " and cs.customer = "+ SQLFormatChar(oDtl.Customer) + ;
6808 " where h.pkey = " + lcFkey && 1084825
6809 v_SqlExec(lcSQL ,"__RangH")
6810 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
6811 lcDvision = __RangH.division && 1058336 FH
6812
6813 oDtl.Style = __RangH.rng_style
6814 oDtl.color_code = __RangH.rng_color
6815 oDtl.lbl_code = __RangH.rng_lbl
6816 oDtl.Dimension = __RangH.rng_pack
6817 oDtl.rng_style = __RangH.rng_style
6818 oDtl.rng_color = __RangH.rng_color
6819 oDtl.rng_lbl = __RangH.rng_lbl
6820 oDtl.rng_pack = __RangH.rng_pack
6821 oDtl.rng_qty = __RangH.rng_qty
6822 oDtl.rng_type = __RangH.rng_type
6823 *- don't have to have upc or sku for the imploded range style
6824 oDtl.upc = ''
6825 oDtl.sku = ''
6826 oDtl.coord_code = __RangH.coord_code
6827 oDtl.a_price = __RangH.a_price
6828 oDtl.b_price = __RangH.b_price
6829 oDtl.c_price = __RangH.c_price
6830 oDtl.d_price = __RangH.d_price
6831 oDtl.e_price = __RangH.e_price
6832 *- clear err msg and err flag which may have error after unsuccessful implosion
6833 oDtl.Errs_Msg_D = ""
6834
6835 *- 1009211 03/09/05 YIK
6836 *- Initializ3e errs_flg_d to N, not blank
6837 *- oDtl.Errs_Flg_D = " "
6838 oDtl.Errs_Flg_D = "N"
6839 *- org_price is based on zzocntrc (cust sales) price_code
6840 *- we'll get the proper price_code in ValidOrderControl()
6841 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
6842
6843 *- 1009211 02/24/05 YIK
6844 *- Keep quantity in cases and use price per case.
6845 *- and zero out orig price which will be resolved.
6846 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
6847
6848 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6849 lnOrgPrice = oDtl.org_price
6850 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6851
6852 oDtl.total_qty = lnRatio
6853 oDtl.org_price = 0
6854
6855 *--- TR 1060800 24-May-2012 Goutam.
6856 oDtl.Rng_Impl = pcRng_Impl
6857 oDtl.Rngp_conv = pcRngp_conv
6858 *=== TR 1060800 24-May-2012 Goutam.
6859
6860 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6861 IF pcRngp_conv = "R"
6862 *--- TechRec 1057383 15-Dec-2011 jisingh ---
6863*!* oDtl.ppk_qty = __RangH.rng_qty
6864*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
6865*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6866*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6867*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
6868*!* oDtl.ppk_action = 'X'
6869
6870 IF EMPTY(oDtl.ppk_action)
6871 oDtl.org_price = lnOrgPrice
6872 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
6873 ENDIF
6874
6875 IF oDtl.ppk_action = "B"
6876 oDtl.org_price = lnOrgPrice
6877 oDtl.ppk_qty = __RangH.rng_qty
6878 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6879 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6880 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6881 oDtl.ppk_action = 'X'
6882 ENDIF
6883
6884 IF oDtl.ppk_action = "Q" && Qty conversion only
6885 oDtl.org_price = lnOrgPrice
6886 oDtl.ppk_qty = __RangH.rng_qty
6887 oDtl.retail1 = oDtl.retail1
6888 oDtl.retail2 = oDtl.retail2
6889 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6890 oDtl.ppk_action = 'M'
6891 ENDIF
6892
6893 IF oDtl.ppk_action = "P" && Price conversion only
6894 oDtl.org_price = lnOrgPrice
6895 oDtl.ppk_qty = __RangH.rng_qty
6896 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6897 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6898 oDtl.total_qty = oDtl.total_qty
6899 oDtl.ppk_action = 'D'
6900 ENDIF
6901 *=== TechRec 1057383 15-Dec-2011 jisingh ===
6902 ENDIF
6903 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6904
6905 *= 1009211
6906 *- 1047842/1048069 07/01/10 YIK
6907 *- Clear po1_upc and po1_sku as they get populated on the way out
6908 oDtl.po1_upc = ''
6909 oDtl.po1_sku = ''
6910
6911
6912 *- Per JR, put into the 1st available size bucket
6913 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
6914 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
6915 If !llRetVal
6916 Exit
6917 Else
6918 *-- TR 1049817 Oct-12-2010 BR
6919 *oDtl.sizebucket = At("Y", __tmp.sizes)
6920 oDtl.sizebucket = __RangH.rng_bk
6921 oDtl.rng_bk = oDtl.sizebucket
6922 lcSzStr = __tmp.sizes
6923 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
6924 *== TR 1049817 Oct-12-2010 BR
6925 Endif
6926 *-- TR 1049817 Oct-12-2010 BR
6927 IF !llValidRngBk
6928 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
6929 oDtl.errs_flg_d = 'Y'
6930 ELSE
6931 *== TR 1049817 Oct-12-2010 BR
6932 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
6933 llRetVal = .F.
6934 Exit
6935 Endif
6936 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
6937 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
6938
6939 *--- TR 1059965 6-Mar-12 Venuk
6940 *oDtl.pkey = v_nextPkey("ZZEIPOID")
6941 * ENDIF
6942 ENDIF
6943 oDtl.pkey = v_nextPkey("ZZEIPOID")
6944 *=== TR 1059965 6-Mar-12 Venuk
6945
6946 Select (pceipoTD)
6947 Append Blank
6948
6949 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
6950 *Gather Name oDtl
6951 Gather Name oDtl memo
6952 *=== TR 1065271 11-Jan-2013 BNarayanan ===
6953
6954 Endfor
6955 If llRetVal
6956 *- delete components
6957 Delete For fkey = pnFkey And !Empty(Style) ;
6958 AND !Empty(division) And !Empty(customer) ;
6959 AND Empty(rng_style) And implosion <> "Y" ;
6960 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
6961 IN (pceipoTD)
6962 Endif
6963 Select (lnOldSelect)
6964 Return llRetVal
6965 *========== 1006607 09/02/04 YIK
6966
6967 *----------------------------------------------------------------------------------------
6968
6969 *--- TechRec 1005163 17-May-2004 GS ---
6970 *-- Validating SLN vs. Prepack
6971 Procedure CheckSLN
6972 Parameters pceipoTH, pceipoTD, pceipoTS
6973 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
6974 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
6975 lcDtl_lbl_code && *-TR 1075660 SK
6976
6977 lnOldDtlPKey = -1
6978 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
6979 *--- TR 1023892 NH
6980 lnOldSelect = SELECT()
6981 llRetVal = .t.
6982 *=== TR 1023892 NH
6983 Select (pceipoTS)
6984 Set Order To Tag fkey
6985
6986 SCAN
6987 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
6988 IF SkipSlnChk = "Y"
6989 LOOP
6990 ENDIF
6991 *=== TR 1035223 NH
6992
6993 If lnOldDtlPKey != fkey
6994 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
6995 *-- this checks that there is no more records left in BC PrePack info
6996 *-- after all matching to SLNs deleted. Made as a separate routine
6997 *-- because it must be called when detail key changed and when scan is finished.
6998 *-- Error info applied to Detail.
6999 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7000 Endif
7001 lnOldDtlPKey = fkey
7002 lcPPackError = ""
7003 lcDtlError = ""
7004 Select (pceipoTD)
7005 *- 1008909 01/18/05 YIK
7006 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
7007 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
7008 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
7009 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
7010 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
7011 *- TR 1097936 FH - added check if detail lbl is empty, then lets use cust_lbl
7012 lcDtl_lbl_code = IIF(llRangeStyle, NULL, IIF(EMPTY(lbl_code), cust_lbl, lbl_code)) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
7013
7014 *- 1013522 10/17/05 12/02/05 YIK
7015 *- Check for the range style type P. For it there's no explosion to components and the range
7016 *- style info is not written into detail table, but it is still a range style and we should skip it.
7017 Local Array laRangP[1]
7018 laRangP[1] = 0
7019 *--- TR 1023892 NH
7020 IF .lALLOW_RANGE_HDR_LABEL
7021 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
7022 SELECT COUNT(*) ;
7023 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7024 ON d.division = r.division ;
7025 AND d.STYLE = r.rng_style ;
7026 AND d.color_code = r.rng_color ;
7027 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
7028 AND d.DIMENSION = r.rng_pack ;
7029 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
7030 INTO ARRAY laRangP
7031 ELSE
7032 *=== TR 1023892 NH
7033 Select Count(*) ;
7034 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
7035 On d.division = r.division ;
7036 AND d.Style = r.rng_style ;
7037 AND d.color_code = r.rng_color ;
7038 AND d.lbl_code = r.rng_lbl ;
7039 AND d.Dimension = r.rng_pack ;
7040 WHERE d.pkey = lnOldDtlPKey ; && TR 1090099 FH
7041 INTO Array laRangP
7042 ENDIF && TR 1023892 NH
7043 llRangeStyle = llRangeStyle Or laRangP[1] > 0
7044 *= 1013522 YIK
7045
7046 llDtlHasError = (Errs_Flg_D = 'Y')
7047 *- 1008909 01/18/05 YIK
7048 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7049 If llDtlHasError Or llRangeStyle
7050 *= 1008909
7051 Loop && For unresolved Details do not even bother...
7052 Endif
7053
7054 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
7055 *-- set to NULL if any C and/or L can be used for the PrePack:
7056 *- 08/25/04 YIK
7057 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
7058 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
7059 lcSQL = ;
7060 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
7061 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
7062 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
7063 " d.Dimension, Pack_Total," +;
7064 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7065 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7066 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7067 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7068 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7069 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
7070 " Size_Num as Sizebucket" +;
7071 " from zzxscolr c" +;
7072 " join zzxstylr st"+;
7073 " on st.pkey = c.fkey "+;
7074 " join zzxppakh h" +;
7075 " on h.Division = c.Division" +;
7076 " and h.PPK_CODE = c.Dimension" +;
7077 " and h.Size_Code = st.Size_Code" +; && TR 1026025
7078 " join zzxppakd d" +;
7079 " on d.Fkey = h.PKey" +;
7080 " cross join zzxbuckt" +;
7081 " where c.Division = " + SQLFormatChar(division ) + ;
7082 " and c.Style = " + SQLFormatChar(Style ) + ;
7083 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
7084 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
7085 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
7086 " and c.PPack_Ok = 'Y'" +;
7087 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7088 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7089 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7090 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7091 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7092 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
7093 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
7094
7095 v_SqlExec(lcSQL, "tcPPK")
7096 If Reccount("tcPPK") > 0
7097 lnPPK_SLN_Diff = pack_qty
7098 Else
7099 lnPPK_SLN_Diff = 0
7100 Endif
7101 Endif
7102 *- 1008909 01/18/05 YIK
7103 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7104 If llDtlHasError Or llRangeStyle
7105 Loop && For unresolved Details do not even bother...
7106 Endif
7107
7108 Select (pceipoTS)
7109
7110 If Reccount("tcPPK") = 0
7111 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
7112 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7113 Loop
7114 Endif
7115
7116 If tcPPK.active_ok = 'N'
7117 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
7118 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7119 Loop
7120 Endif
7121
7122 If Errs_Flg_S = 'Y'
7123 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
7124 Loop && UPC/EAN/SKU is unesolved.
7125 Endif
7126
7127 lcStyle = style && *- TR 1064758 FH
7128 lcColor_code = color_code
7129 lcLbl_code = lbl_code
7130 lcDimension = Dimension
7131 lnSLN_Qty = SLN_Qty
7132 lnSizeBucket = sizebucket
7133
7134 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
7135 Select tcPPK
7136
7137 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
7138 *FH 1084440 - added EMPTY(lcLbl_code) - if sln lbl is '', don't need to compare between DTL lbl and SLN lbl.
7139 * If DTL grabbed cust label from 850 control, second time running process will fail validation (lbl no longer matches)
7140
7141 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
7142 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
7143 AND ((Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code) OR (NVL(lbl_Code,'') = ALLTRIM(lcLbl_code))) && TR 1084440
7144
7145 If Found()
7146 Delete && in PrePack info leave only unresolved ones.
7147 Else
7148 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
7149 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
7150 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
7151 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
7152 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
7153 If !"Has errors in SLNs."$lcDtlError
7154 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
7155 Endif
7156 Endif
7157
7158 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
7159 *if lnPPK_SLN_Diff < 0
7160 *endif
7161 Endscan
7162 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
7163
7164 *- 1008909 01/18/05 YIK
7165 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
7166 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
7167 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7168 Endif
7169 *- 1013522 10/17/05 12/02/05 YIK
7170 If Used("__RangeP")
7171 Use In __RangeP
7172 Endif
7173 *=
7174 *--- TR 1023892 NH
7175 SELECT(lnOldSelect)
7176 RETURN llRetVal
7177 *== TR 1023892 NH
7178
7179 Endproc
7180
7181 *----------------------------------------------------------------------------------------
7182 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
7183 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
7184 Procedure CheckSlnSet
7185 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
7186
7187 Local lnOldSelect
7188
7189 lnOldSelect = Select()
7190
7191 If !Empty(tcPPKError)
7192 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7193 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7194 Return
7195 Endif
7196
7197 Select tcPPK
7198 Scan
7199 tcDtlError = tcDtlError +;
7200 "Missing Prepack Component" + ;
7201 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
7202 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
7203 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
7204 "; Qty:"+Transform(Qty) + CRLF
7205 Endscan
7206
7207 If !Empty(tcDtlError)
7208 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7209 Local lcErr
7210 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
7211 If !Empty(lcErr)
7212 tcDtlError = CRLF + tcDtlError
7213 Endif
7214 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7215 Endif
7216
7217 Select (lnOldSelect)
7218
7219 Endproc
7220
7221 *----------------------------------------------------------------------------------------
7222
7223 ************************************************************************************
7224 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7225 * 1. Try to substitute lbl_code with customer label when have the following conditions:
7226 * Header: customer
7227 * Detail: division,style,color_code
7228 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
7229 * resolve all detail division into header )
7230 ************************************************************************************
7231 Procedure ResolveCustomerLabel
7232 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7233 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
7234 Local llRetVal, lnOldSelect
7235 llRetVal = .T.
7236 lnOldSelect = Select()
7237 With This
7238 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
7239 *--- TechRec 1048667 03-May-2011 GSternik ---
7240 *-- Not needed, already done in the calling CheckDetail
7241 *.LogEntry("Cascading Customer To Detail.")
7242 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
7243 *=== TechRec 1048667 03-May-2011 GSternik ===
7244 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
7245 .LogEntry("Substituding customer label.")
7246 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7247 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
7248 .LogEntry("Auto creating style.")
7249 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7250 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
7251 * PL 08/22/01 27847 Auto-create Customer SKU
7252 .LogEntry("Auto creating customer style.")
7253 *--- TechRec 1005163 18-May-2004 GS ---
7254 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7255 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
7256 *=== TechRec 1005163 18-May-2004 GS ===
7257
7258 Endwith
7259 Select(lnOldSelect)
7260 Return llRetVal
7261 Endproc
7262
7263
7264 *----------------------------------------------------------------------------------------
7265 ************************************************************************************
7266 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7267 ************************************************************************************
7268 Procedure CascadingCustomerToDetail
7269 Lparameters pceipoTH, pceipoTD
7270 Local llRetVal, lnOldSelect
7271 llRetVal = .T.
7272 lnOldSelect = Select()
7273 With This
7274 * set header/detail Relation
7275 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
7276 * --- TR 1019358 RLN 10/30/06
7277 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
7278 Replace All customer With &pceipoTH..customer, ;
7279 department With &pceipoTH..department ;
7280 IN (pceipoTD)
7281 * === TR 1019358
7282 Set Relation To
7283 Endwith
7284 Select(lnOldSelect)
7285 Return llRetVal
7286 Endproc
7287
7288 *----------------------------------------------------------------------------------------
7289 *---- TR 1019697 NH
7290 Procedure CascadingCustomerToSLN
7291 Lparameters pceipoTD, pceipoTS
7292 Local llRetVal, lnOldSelect
7293 llRetVal = .T.
7294 lnOldSelect = Select()
7295 With This
7296 * set detail/SLN Relation
7297 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7298 Replace All customer With &pceipoTD..customer In (pceipoTS)
7299 Set Relation To
7300 Endwith
7301 Select(lnOldSelect)
7302 Return llRetVal
7303 Endproc
7304 *==== TR 1019697 NH
7305
7306 *----------------------------------------------------------------------------------------
7307 ************************************************************************************
7308 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7309 ************************************************************************************
7310 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7311 * regardless of auto_create of style flag set in Customer Label Ref.
7312 Procedure SubstitudeValidLabel
7313 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7314 Local llRetVal, lnOldSelect
7315 llRetVal = .T.
7316 lnOldSelect = Select()
7317 With This
7318 *- 1010285 05/18/05 YIK
7319 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7320 *- if the SKU with the label is valid and active in the style master.
7321 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7322 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7323 *-- WHERE h.pkey= d.fkey AND ;
7324 *-- d.division= C.division AND h.customer= C.customer AND ;
7325 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7326 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7327 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7328 *-- INTO CURSOR tmpCurs
7329
7330 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7331 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7332 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7333 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7334 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7335 WHERE h.pkey= d.fkey And ;
7336 d.division= C.division And h.customer= C.customer And ;
7337 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7338 Not (MultiUPC = 'Y') And ;
7339 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7340 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7341 INTO Cursor tmpCurs
7342 *==
7343
7344 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7345 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7346 "customer+division+style+color_code+dimension")
7347 If llRetVal
7348 *- 1010285 05/18/05 YIK
7349 *- 1004785 05/04/04 YIK
7350 *- Added .. AND Empty(Errs_Msg_D)
7351 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7352 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7353 Select (pceipoTD)
7354 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7355 If tmpCurs.resv_label = "Y" Or ;
7356 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7357 AND tmpscolr.active_ok = "Y" )
7358 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7359 Endif
7360 Endscan
7361 *= 1010285
7362 Set Relation To
7363 Endif
7364 .TableClose('tmpCurs')
7365 Endwith
7366 Select(lnOldSelect)
7367 Return llRetVal
7368 Endproc
7369
7370 *----------------------------------------------------------------------------------------
7371 ************************************************************************************
7372 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7373 ************************************************************************************
7374 * encounter for both set up in customer label ref:
7375 * 1. empty label apply to all customer
7376 * 2. none empty customer will be specificly create only for that customer
7377 * either 1 or 2 exists but never both
7378 *
7379 * Get a list of distinct ourSKU to server side to join zzxcolr
7380 Procedure CreateOurSKU
7381 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7382 Local llRetVal, lnOldSelect
7383 llRetVal = .T.
7384 lnOldSelect = Select()
7385 With This
7386 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7387 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7388 WHERE h.pkey= d.fkey And ;
7389 d.division= C.division And h.customer= C.customer And ;
7390 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7391 l.auto_style= 'Y' And ;
7392 C.resv_label= 'Y' And ;
7393 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7394 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7395 INTO Cursor tmpCurs
7396 *--- TR 1019697 NH
7397 *!* SCAN
7398 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7399 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7400 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7401 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7402 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7403 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7404 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7405 *!* .LogEntry("Created style: " + lcOurSKU )
7406 *!* ELSE
7407 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7408 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7409 *!* ENDIF
7410 *!* ENDIF
7411 *!* ENDSCAN
7412 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7413 *=== TR 1019697 NH
7414 Endwith
7415 Select(lnOldSelect)
7416 Return llRetVal
7417 Endproc
7418
7419 *----------------------------------------------------------------------------------------
7420
7421 Procedure CreateCustomerStyle
7422 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7423 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7424 Local llRetVal, lnOldSelect
7425 llRetVal = .T.
7426 lnOldSelect = Select()
7427 With This
7428 *--- TechRec 1005164 18-May-2004 GS ---
7429 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7430 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7431 * Where h.pkey= d.fkey and ;
7432 * d.division= C.division and h.customer= C.customer and ;
7433 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7434 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7435 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7436 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7437 * Into Cursor tmpCurs
7438 If This.oHostProcess.lHaveSLN
7439 Select Distinct C.customer,;
7440 d.division,;
7441 d.Style,;
7442 d.color_code,;
7443 C.lbl_code,;
7444 d.Dimension ;
7445 FROM (pceipoTD) d ;
7446 JOIN (pceipoTH) h ;
7447 ON h.pkey = d.fkey ;
7448 JOIN (pceipoCR) C;
7449 ON d.division= C.division ;
7450 AND h.customer= C.customer ;
7451 JOIN (pcxclblr) l ;
7452 ON C.lbl_code= l.lbl_code ;
7453 WHERE l.auto_style= 'Y' ;
7454 AND C.resv_label= 'Y' ;
7455 AND C.AutoCustSKU= 'Y' ;
7456 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7457 And h.customer > ' ' ;
7458 AND d.division > ' ' ;
7459 AND d.Style > ' ' ;
7460 AND d.color_code > ' ';
7461 UNION ;
7462 SELECT Distinct C.customer,;
7463 d.division,;
7464 d.Style,;
7465 s.color_code,;
7466 C.lbl_code,;
7467 s.Dimension ;
7468 FROM (pceipoTS) s ;
7469 JOIN (pceipoTD) d ;
7470 ON d.pkey = s.fkey ;
7471 JOIN (pceipoTH) h ;
7472 ON h.pkey = d.fkey ;
7473 JOIN (pceipoCR) C ;
7474 ON d.division= C.division ;
7475 AND h.customer= C.customer ;
7476 JOIN (pcxclblr) l ;
7477 ON C.lbl_code= l.lbl_code ;
7478 WHERE l.auto_style= 'Y' ;
7479 AND C.resv_label= 'Y' ;
7480 AND C.AutoCustSKU= 'Y' ;
7481 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7482 And h.customer > ' ' ;
7483 AND d.division > ' ' ;
7484 AND d.Style > ' ' ;
7485 AND s.color_code > ' ';
7486 INTO Cursor tmpCurs
7487
7488 Else
7489
7490 Select Distinct C.customer,;
7491 d.division,;
7492 d.Style,;
7493 d.color_code,;
7494 C.lbl_code,;
7495 d.Dimension ;
7496 FROM (pceipoTD) d ;
7497 JOIN (pceipoTH) h ;
7498 ON h.pkey = d.fkey ;
7499 JOIN (pceipoCR) C ;
7500 ON d.division= C.division ;
7501 AND h.customer= C.customer ;
7502 JOIN (pcxclblr) l ;
7503 ON C.lbl_code= l.lbl_code ;
7504 WHERE l.auto_style= 'Y' ;
7505 AND C.resv_label= 'Y' ;
7506 AND C.AutoCustSKU= 'Y' ;
7507 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7508 And h.customer > ' ' ;
7509 AND d.division > ' ' ;
7510 AND d.Style > ' ' ;
7511 AND d.color_code > ' ';
7512 INTO Cursor tmpCurs
7513
7514 Endif
7515 *=== TechRec 1005164 18-May-2004 GS ===
7516 Scan
7517 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7518 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7519 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7520 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7521 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7522 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7523 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7524 .LogEntry("Created customer style: " + lcCustSKU )
7525 Else
7526 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7527 .LogWarning("Unable to create customer style: " + lcCustSKU )
7528 Endif
7529 Endif
7530 Endscan
7531 Endwith
7532 Select(lnOldSelect)
7533 Return llRetVal
7534 Endproc
7535
7536 *----------------------------------------------------------------------------------------
7537 ************************************************************************************
7538 * Validate UPC for all details
7539 ************************************************************************************
7540 *--- TR 1088986 31-Jul-2015 BNarayanan Method name changed to avoid duplication. This method is obsolete ---
7541 *Procedure CheckUpc
7542 Procedure CheckUpc_obsolete
7543 *=== TR 1088986 31-Jul-2015 BNarayanan ===
7544 Lparameters pceipoTH, pceipoTD,;
7545 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7546
7547 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7548 * Added Parameter pceipocr
7549 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7550
7551 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7552 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7553 lnSize_desc, llSLN
7554
7555 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7556 LOCAL lcIs_upcsku
7557 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7558
7559 llRetVal = .T.
7560 lcErrs_Msg= ""
7561 lnOldSelect = Select()
7562
7563 * cannot check for UPC if customer is empty
7564 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7565 * on Cust SKU or UPC.
7566 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7567
7568 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7569 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7570 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7571
7572 *--- TechRec 1005163 17-May-2004 GS ---
7573 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7574 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7575 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7576 *Order by h.customer, d.upc Into Cursor tmpCurs
7577
7578 *---- TR 1024667 NSD 5/31/07
7579 * If sizebucket = 0 then re-resolve.
7580
7581 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7582 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7583*!* If This.lHaveSLN
7584*!* Select h.customer,;
7585*!* d.upc,;
7586*!* d.pkey,;
7587*!* (pceipoTD) As Src;
7588*!* FROM (pceipoTH) h ;
7589*!* JOIN (pceipoTD) d ;
7590*!* ON h.pkey = d.fkey ;
7591*!* WHERE !Empty(d.upc) ;
7592*!* AND !Empty(h.customer) ;
7593*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7594*!* UNION All ;
7595*!* SELECT h.customer,;
7596*!* s.SLN_UPC As upc,;
7597*!* s.pkey,;
7598*!* (pceipoTS) As Src ;
7599*!* FROM (pceipoTH) h ;
7600*!* JOIN (pceipoTD) d ;
7601*!* ON d.fkey = h.pkey ;
7602*!* JOIN (pceipoTS) s ;
7603*!* ON s.fkey = d.pkey ;
7604*!* WHERE !Empty(s.SLN_UPC) ;
7605*!* AND !Empty(h.customer) ;
7606*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7607*!* ORDER By 1, 2 ;
7608*!* INTO Cursor tmpCurs
7609*!* Else
7610*!* Select h.Customer,;
7611*!* d.UPC,;
7612*!* d.PKey,;
7613*!* (pceipoTD) As Src;
7614*!* FROM (pceipoTH) h ;
7615*!* JOIN (pceipoTD) d ;
7616*!* ON h.pkey = d.fkey ;
7617*!* WHERE !Empty(d.upc) ;
7618*!* AND !Empty(h.customer) ;
7619*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7620*!* ORDER By 1, 2;
7621*!* INTO Cursor tmpCurs
7622*!* Endif
7623 *=== TechRec 1005163 17-May-2004 GS ===
7624
7625 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7626 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7627 FROM (pceipocr) ;
7628 GROUP BY customer ;
7629 INTO CURSOR __ResvCustSKU
7630 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7631
7632 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7633*!* select h.Customer;
7634*!* , d.UPC;
7635*!* , d.PKey;
7636*!* from (pceipoTH) h;
7637*!* join (pceipoTD) d;
7638*!* on h.PKey = d.FKey;
7639*!* where !Empty(d.UPC);
7640*!* and !Empty(h.Customer);
7641*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7642*!* order by 1, 2;
7643*!* into Cursor tmpCurs ReadWrite
7644
7645 Select h.customer;
7646 , d.upc;
7647 , d.pkey,;
7648 (pceipoTD) AS Src;
7649 from (pceipoTH) h;
7650 join (pceipoTD) d;
7651 on h.pkey = d.fkey;
7652 JOIN __ResvCustSKU r ;
7653 ON r.Customer = H.Customer ;
7654 where !Empty(d.upc);
7655 and !Empty(h.customer);
7656 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7657 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7658 order By 1, 2;
7659 into Cursor tmpCurs Readwrite
7660 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7661
7662*=== TechRec 1024522 25-Sep-2007 GSternik ===
7663
7664 lcOldCust = ""
7665 lcOldItem = ""
7666 Select tmpCurs
7667 If This.lUserInterface
7668 * Init Thermometer
7669 This.UpdateThermoCaption("Validating UPC(s)...")
7670 * TAN 31891 - JAZ - 5/20/02
7671 * This.InitThermo(RECC('tmpCurs'))
7672 This.InitThermo(RecCount('tmpCurs'))
7673 * End TAN 31891 - JAZ - 5/20/02
7674 l_nThermoCnt = 0
7675 EndIf
7676
7677 Scan
7678 If This.lUserInterface
7679 * Advance progress bar, if we're using one.
7680 l_nThermoCnt = l_nThermoCnt + 1
7681 This.AdvanceThermo(l_nThermoCnt)
7682 Endif
7683 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7684 lcErrs_Msg = ""
7685 lcOldCust = tmpCurs.customer
7686 lcOldItem = tmpCurs.upc
7687 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7688 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7689
7690 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7691 lcIs_upcsku = ' '
7692 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7693
7694 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7695 lcDivision = tmpCstdr.division
7696 lcStyle = tmpCstdr.Style
7697 lcColor_code = tmpCstdr.color_code
7698 lcLbl_code = tmpCstdr.lbl_code
7699 lcDimension = tmpCstdr.Dimension
7700 lnSizeBucket = tmpCstdr.size_bk
7701 lnSize_desc = tmpCstdr.size_desc
7702
7703 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7704 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7705 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7706
7707 Else
7708 lcErrs_Msg = ""
7709 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7710 lcDivision = tmpUpcnr.division
7711 lcStyle = tmpUpcnr.Style
7712 lcColor_code = tmpUpcnr.color_code
7713 lcLbl_code = tmpUpcnr.lbl_code
7714 lcDimension = tmpUpcnr.Dimension
7715 lnSizeBucket = tmpUpcnr.sizebucket
7716 lnSize_desc = tmpUpcnr.size_desc
7717 Else
7718 lcErrs_Msg = lcErrs_Msg + CRLF
7719 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7720 Store 0 To lnSizeBucket
7721 Endif
7722 Endif
7723 Endif && level break
7724
7725 *--- TechRec 1005163 17-May-2004 GS ---
7726 *Select (pceipoTD)
7727*!* llSLN = (tmpCurs.Src = pceipoTS)
7728*!* If llSLN
7729*!* Select (pceipoTS)
7730*!* Else
7731 Select (pceipoTD)
7732*!* Endif
7733 *=== TechRec 1005163 17-May-2004 GS ===
7734 *- 1010682 04/25/05 YIK
7735 *- Locate For pkey = tmpCurs.pkey
7736 lnWorkArea = Select()
7737 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7738 Scatter Name loEiPOtd Memo
7739 If !Empty(lcErrs_Msg)
7740*!* *--- TechRec 1005163 17-May-2004 GS ---
7741*!* If llSLN
7742*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7743*!* loEiPOtd.Errs_Flg_S = "Y"
7744*!* Else
7745*!* *=== TechRec 1005163 17-May-2004 GS ===
7746 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7747 loEiPOtd.Errs_Flg_D = "Y"
7748*!* Endif
7749 Endif
7750 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7751 loEiPOtd.Division = lcDivision
7752 loEiPOtd.Style = lcStyle
7753 loEiPOtd.Color_Code = lcColor_code
7754 loEiPOtd.Lbl_Code = lcLbl_code
7755 loEiPOtd.Dimension = lcDimension
7756 loEiPOtd.SizeBucket = lnSizeBucket
7757 loEiPOtd.Size_Desc = lnSize_desc
7758
7759 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7760 IF !EMPTY(lcIs_upcsku)
7761 loEiPOtd.Is_upcsku = lcIs_upcsku
7762 ENDIF
7763 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7764
7765 *--- TR 1019697 NH : clear rang style when bc style is set
7766 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7767 loEiPOtd.rng_style = ''
7768 loEiPOtd.rng_color = ''
7769 loEiPOtd.rng_lbl = ''
7770 loEiPOtd.rng_pack = ''
7771 Endif
7772 *=== TR 1019697 NH
7773 Endif
7774
7775 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7776 * only replace our SKU when no range style explosion happen
7777 *--- TechRec 1005163 17-May-2004 GS ---
7778 *If empty(&pceipoTD..rng_style)
7779 * Replace division With loEiPOtd.division, ;
7780 * style With loEiPOtd.style, ;
7781 * color_code With loEiPOtd.color_code, ;
7782 * lbl_code With loEiPOtd.lbl_code, ;
7783 * dimension With loEiPOtd.dimension, ;
7784 * sizebucket With loEiPOtd.sizebucket, ;
7785 * size_desc With loEiPOtd.size_desc, ;
7786 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7787 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7788 * In (pceipoTD)
7789 *Endif
7790 *- 1009508 3/16/05 YIK
7791 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7792 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7793 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7794 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7795 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7796
7797 Gather Name loEiPOtd Memo
7798 Endif
7799 *=== TechRec 1005163 17-May-2004 GS ===
7800 Endscan
7801 Use In tmpCurs
7802
7803 If This.lUserInterface
7804 * Reset Thermometer
7805 This.ResetThermo()
7806 Endif
7807
7808 If Used("tmpCstdr")
7809 Use In tmpCstdr
7810 Endif
7811 If Used("tmpUpcnr")
7812 Use In tmpUpcnr
7813 Endif
7814
7815 Select(lnOldSelect)
7816 Return llRetVal
7817 Endproc
7818
7819 *----------------------------------------------------------------------------------------
7820 ************************************************************************************
7821 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7822 ************************************************************************************
7823 Procedure ValidateOurSKU
7824 Lparameters pceipoTH, pceipoTD, pceipoTS
7825 Local llRetVal, lnOldSelect, lcScolrSQL
7826 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
7827
7828 *--- TechRec 1022705 21-Jun-2007 jjanand ---
7829 LOCAL llActiveCheck
7830 *=== TechRec 1022705 21-Jun-2007 jjanand ===
7831
7832 *--- TR 1017598 14-Sep-2006 SS
7833 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
7834
7835 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
7836
7837 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
7838
7839 *--- TR 1018193 18-NOV-2006 VKK
7840 lcErrs_Allowed_Msg = ""
7841 *=== TR 1018193 18-NOV-2006 VKK
7842
7843 *=== TR 1017598 14-Sep-2006 SS
7844
7845 * --- TR 1039400 3/31/09 CM
7846 LOCAL lcCurrentSku
7847 lcCurrentSku = ""
7848 * === TR 1039400 3/31/09 CM
7849
7850 llRetVal = .T.
7851 lnOldSelect = Select()
7852
7853 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
7854 *--- See VSS for Changes.
7855
7856 * for anything that resove to None blank h.customer, d.div/sty/col-
7857 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
7858 *- TAN 27166
7859 *- 1010682 04/25/05 YIK
7860 *- Added .. WHERE d.rng_style = ' '
7861
7862 *- 1017363 06/02/06 YIK
7863 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
7864
7865 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
7866 Select h.customer;
7867 , d.division;
7868 , d.Style;
7869 , d.color_code;
7870 , d.lbl_code;
7871 , d.Dimension;
7872 , d.sizebucket;
7873 , d.size_desc; && TR 1058045 11-29-2011 RKI
7874 , d.upc; && TR 1058045 11-29-2011 RKI
7875 , d.sku; && TR 1058045 11-29-2011 RKI
7876 , d.ean; && TR 1058045 11-29-2011 RKI
7877 , d.pkey;
7878 , (pceipoTD) As Src ;
7879 from (pceipoTH) h;
7880 join (pceipoTD) d ;
7881 on h.pkey = d.fkey ;
7882 where h.customer >' ' ;
7883 and d.division >' ' ;
7884 and d.Style >' ' ;
7885 and d.color_code >' ' ;
7886 UNION All;
7887 select h.customer;
7888 , s.division;
7889 , s.Style;
7890 , s.color_code;
7891 , s.lbl_code;
7892 , s.Dimension;
7893 , s.sizebucket;
7894 , s.size_desc; && TR 1058045 11-29-2011 RKI
7895 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
7896 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
7897 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
7898 , s.pkey;
7899 , (pceipoTS) As Src ;
7900 from (pceipoTS) s;
7901 join (pceipoTD) d ;
7902 on d.pkey = s.fkey;
7903 join (pceipoTH) h ;
7904 on h.pkey = d.fkey ;
7905 and h.customer > ' ' ;
7906 and s.division > ' ' ;
7907 and s.Style > ' ' ;
7908 and s.color_code > ' ' ;
7909 where d.rng_style = ' ' ;
7910 order By 2, 3, 4, 5, 6, 7, 1 ;
7911 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
7912
7913 *-- Order by SKU + Bucket + Customer !!!
7914 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
7915
7916 lcCnt = Reccount("tmpCurs")
7917 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
7918
7919 *--- This cursor will be used to cache Customer-Label Validations:
7920 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
7921 Index On customer + lbl_code Tag CustLbl
7922
7923 lcErrs_Msg = ''
7924 Select tmpCurs
7925 Scatter Memo Name oTmpCurs Blank
7926 * --- TR 1014834 RLN 08/10/06
7927
7928 *--- TR 1017598 14-Sep-2006 SS
7929 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7930
7931 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7932 llBookUnavail = (lcbk_unavl_sku = 'Y')
7933 llErrUnavail = (lcbk_unavl_sku = 'E')
7934 *=== TR 1017598 14-Sep-2006 SS
7935
7936 With oTmpCurs
7937 llSize_OK = .T.
7938 Scan
7939 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
7940 * --- TR 1027498 NSD 10/3/07
7941 * Clear error message after every line, not just every sku.
7942 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
7943 * === TR 1027498 NSD 10/3/07
7944
7945 * --- TR 1014834 RLN 08/10/06
7946 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
7947 *llSize_OK = .T. FH 1090559 - absolutely have to comment this. IT should only be set when we change sizes
7948 If division # .division ;
7949 or Style # .Style ;
7950 or color_code # .color_code ;
7951 or lbl_code # .lbl_code ;
7952 or Dimension # .Dimension
7953 *-- SKU Changed... Let's make sure it is valid:
7954
7955 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
7956 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7957
7958 * --- TR 1039400 3/31/09 CM
7959 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
7960 * === TR 1039400 3/31/09 CM
7961
7962 * --- TR 1014834 RLN 08/10/06
7963 If division <> .division
7964 *--- TR 1017598 14-Sep-2006 SS
7965 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7966
7967 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7968 llBookUnavail = (lcbk_unavl_sku = 'Y')
7969 llErrUnavail = (lcbk_unavl_sku = 'E')
7970 *=== TR 1017598 14-Sep-2006 SS
7971 Endif
7972 * === TR 1014834
7973 lcErrs_Msg = ""
7974 .division = division
7975 .Style = Style
7976 .color_code = color_code
7977 .Dimension = Dimension
7978 .lbl_code = lbl_code && TR 1057867 FH
7979 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
7980 * --- TR 1014834 RLN 08/09/06
7981 lnSelect = Select()
7982 * Available sizes stored in Scolr
7983 *--- TR: 1021620 BR/NH
7984 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
7985 Lbl_Code, .Dimension)
7986
7987
7988*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
7989*!* "division = " + SQLFormatChar(division) + " AND " + ;
7990*!* "style = " + SQLFormatChar(Style) + " AND " + ;
7991*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
7992*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
7993*!* "dimension = " + SQLFormatChar(Dimension)
7994
7995*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
7996*!* Select (lnSelect)
7997*!* * === TR 1014834
7998*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
7999*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
8000
8001 *--- TechRec 1022705 20-Jun-2007 jjanand ---
8002 *!* IF tcTmpScolr.active_ok = 'N'
8003 llActiveCheck = This.lAllowInactiveStyleColors
8004 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
8005 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
8006 IF llActiveCheck
8007 *=== TechRec 1022705 20-Jun-2007 jjanand ===
8008
8009 lcErrs_Msg = "Inactive Style/Color"
8010 llStyle_OK = .F.
8011 ELSE
8012 lcErrs_Msg = ""
8013 llStyle_OK = .T.
8014 ENDIF
8015
8016 *--- TR 1040614 MAY-29-2009 BR
8017 llUnAvlBkCheck = .T.
8018 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
8019 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
8020
8021 *- 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
8022 IF llStyle_OK
8023 IF llUnAvlBkCheck
8024 lcErrs_Msg = "Style/Color combination is unavailable"
8025 llStyle_OK = .F.
8026 ELSE
8027 lcErrs_Msg = ""
8028 llStyle_OK = .T.
8029 ENDIF
8030 ENDIF
8031 *- TR 1062018 FH 06/08/12
8032 *=== TR 1040614 MAY-29-2009 BR
8033 ELSE
8034 *=== TR 1021620
8035 llStyle_OK = .F.
8036 This.GetStyleError(@lcErrs_Msg)
8037 Endif
8038 Endif && SKU Changed
8039
8040 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
8041 *- took out (customer # .customer Or .lbl_code # lbl_code)
8042 If llStyle_OK AND llSKU_changed
8043*!* If llStyle_OK And (;
8044*!* customer # .customer Or .lbl_code # lbl_code)
8045 .lbl_code = lbl_code
8046 .customer = customer
8047 llLabel_OK = .T.
8048 If !Empty(.lbl_code)
8049 If !Seek(.customer+.lbl_code, "curCustLbl")
8050 *- populate cursor of cached Customer/Lbl
8051 *- vl_clblr2() returns .F. if lbl is invalid for the customer
8052 Insert Into curCustLbl Values(;
8053 .customer, .lbl_code,;
8054 vl_clblr2(.lbl_code, "", , .customer))
8055 Endif
8056
8057 If !curCustLbl.is_Valid && always check from the cached table.
8058 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
8059 llLabel_OK = .F.
8060 Endif
8061 Endif
8062 Endif && Style OK
8063
8064 *--- TR 1058045 11-29-2011 RKI ---*
8065 lnPkey = Pkey
8066 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
8067 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
8068 replace sizebucket WITH lnSize_BK
8069 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
8070 DO CASE
8071 CASE tmpCurs.Src = (pceipoTD)
8072 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8073 CASE tmpCurs.Src = (pceipoTS) && TR 1090066 FH - typo
8074 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8075 Endcase
8076 ENDIF
8077 ENDIF
8078 SELECT tmpCurs
8079 *=== TR 1058045 11-29-2011 RKI ===*
8080
8081 * --- TR 1018184
8082 *llAllowedSize_OK = .T. FH 1090559 - what if 2 records have same sku and size, first record finds llAllowedSize_OK to be .F.
8083 * Second record will set llAllowedSize_OK to .T. here, and it won't go in the below to revaluate llAllowedSize_OK because same sizebucket
8084 If llStyle_OK And llLabel_OK
8085 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
8086 .sizebucket = sizebucket
8087 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8088
8089 llAllowedSize_OK = .T. && FH 1090559
8090 llSize_OK = .T. && FH 1090559
8091
8092 *- that's why we used Savlr
8093 * --- TR 1014834 RLN 08/09/06
8094 * I guess we really do not need Savlr...
8095 *llSize_OK = Evaluate("__Savlr.allow"
8096 *--- TR 1058045 11-29-2011 RKI ---*
8097 IF BETWEEN(.sizebucket,1,24)
8098 *=== TR 1058045 11-29-2011 RKI ===*
8099 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
8100 Transform(.sizebucket, "@L 99")) = 'Y'
8101
8102 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
8103 *if !llSize_OK
8104 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
8105 Transform(.sizebucket, "@L 99")) = 'Y'
8106 *--- TR 1058045 11-29-2011 RKI ---*
8107 ELSE
8108 llAllowedSize_OK = .F.
8109 ENDIF
8110 *=== TR 1058045 11-29-2011 RKI ===*
8111
8112 If !llAllowedSize_OK
8113 *--TR 1034769 JUL-21-2008 BR
8114 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
8115 lcErrs_Msg = "Invalid Available Sizes."
8116 *==TR 1034769 JUL-21-2008 BR
8117 Else
8118 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
8119 lcErrs_Msg = "Invalid Available Sizes."
8120 Endif
8121 Endif
8122
8123 *=== TR 1017598 14-Sep-2006 SS
8124 ENDIF
8125 && 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
8126 * is valid or not. So let's set variable llAllowedSize_OK = .T. and llSize_OK = .T.
8127 * because it will force error (TR 1067995, DEV NOTE TECHNICAL, explains scenario where style is invalid but still won't
8128 * error out because of these size variables that was from previous records),
8129 * if any of the 2 variables is .F., it will try to add error message base on size variables
8130 * which doesn't make sense.
8131 ELSE
8132 llAllowedSize_OK = .T.
8133 llSize_OK = .T.
8134
8135 Endif
8136 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
8137
8138 * for each detail line replace detail error msg if have one
8139 *--- TechRec 1005163 21-Jun-2004 GS ---
8140 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
8141 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
8142 * Errs_Flg_D with 'Y' in (pceipoTD)
8143 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
8144 If tmpCurs.Src = (pceipoTD)
8145 *--- TR 1017598 14-Sep-2006 SS
8146 If Not llAllowedSize_OK && if size is not allowed - error out always
8147 *--- TR 1018193 18-NOV-2006 VKK
8148 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
8149 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
8150 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
8151 Errs_Flg_D With 'Y' In (pceipoTD)
8152 *=== TR 1018193 18-NOV-2006 VKK
8153 Else
8154 *=== TR 1017598 14-Sep-2006 SS
8155
8156 * --- TR 1014834 RLN 08/08/06
8157 If !llSize_OK
8158 If llBookUnavail
8159 Replace UnAvailSize With .T. In (pceipoTD)
8160 Else
8161 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
8162 If llErrUnavail && error as invalid available sizes.
8163 * === TR 1014834
8164 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
8165 Errs_Flg_D With 'Y' In (pceipoTD)
8166 Endif
8167 *=== TR 1017598 14-Sep-2006 SS
8168 ENDIF
8169 *--- TR 1021620 NH 04/12/07
8170 ELSE
8171
8172
8173 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
8174 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
8175 IF llSKU_changed
8176 * --- TR 1039400 3/31/09 CM
8177 * Commented out and added seek/scan while to determine how many particular style/color
8178 * combinations should be flagged as inactive
8179 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8180 Select(pceipoTD)
8181 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
8182 If Seek(lcCurrentSku)
8183 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
8184 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8185 Endscan
8186 Endif
8187 * === TR 1039400 3/31/09 CM
8188 endif
8189 *--TR 1057867 FH
8190
8191 *=== TR 1021620 NH 04/12/07
8192 Endif && TR 1014834
8193 Endif && TR 1017598
8194 ELSE
8195 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
8196 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
8197 Errs_Flg_S With 'Y' In (pceipoTS)
8198
8199 *- 1010682 04/25/05 YIK
8200 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
8201 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
8202 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
8203 Select(pceipoTS)
8204 lnFKey = fkey
8205 Select(pceipoTD)
8206 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
8207 *=== TechRec 1016817 04-May-2006 GS ===
8208 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
8209 Errs_Flg_D With 'Y' In (pceipoTD)
8210 ENDIF
8211 ENDIF
8212 Endif
8213 *=== TechRec 1005163 21-Jun-2004 GS ===
8214 Endif
8215 Endscan
8216 Endwith
8217
8218 Use In Select("curCustLbl")
8219
8220 Select(lnOldSelect)
8221 Return llRetVal
8222 Endproc
8223
8224 *----------------------------------------------------------------------------------------
8225
8226 Function GetCustLabel
8227 Lparameters pcCust
8228 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
8229
8230 llRetVal = True
8231 lnSelect = Select()
8232 l_vRetVal = ''
8233 lcCursor = GetUniqueFileName()
8234
8235 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
8236
8237 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
8238
8239 If llRetVal
8240 Select(lcCursor)
8241 l_vRetVal = Alltrim(lbl_code )
8242
8243 Use In (lcCursor)
8244 Endif
8245
8246 Select (lnSelect)
8247 Return l_vRetVal
8248 Endfunc
8249
8250 *----------------------------------------------------------------------------------------
8251 Function ResolveMultiPrepacks
8252 Lparameters pcTransHeader, pcTransDetail, pcMppk
8253 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
8254
8255 llRetVal = True
8256 lnOldSelect = Select()
8257
8258
8259
8260 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8261 FROM (pcTransHeader) h, (pcTransDetail) d ;
8262 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
8263 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
8264 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8265
8266 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
8267 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
8268 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
8269 *!* d.rng_style= '' ;
8270 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
8271
8272 With This
8273 .cSQLTempTable=""
8274
8275 If .GenerateSQLTempTable('__TmpCursor')
8276 If .PopulateSQLTempTable('__TmpCursor')
8277 If !Empty(.cSQLTempTable)
8278
8279 .LogEntry("Exploding MultiPack.")
8280
8281 *AND h.mpack_code = t.dimension
8282 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
8283 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8284
8285 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
8286
8287 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
8288
8289 If llMultPpkToExplode
8290
8291 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
8292 "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
8293
8294 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
8295
8296
8297 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
8298
8299 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
8300 WHERE 0=1 Into Cursor __ppk2
8301
8302
8303 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
8304 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
8305
8306
8307 If Used("__ppk1")
8308 Use In __ppk1
8309 Endif
8310
8311 If Used("__ppk2")
8312 Use In __ppk2
8313 Endif
8314
8315 Select __MppkH
8316 Index On pkey Tag pkey
8317 Select __MppkD
8318 Index On division+Style Tag DivStyle
8319 Select tcMppkVer
8320 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8321 Set Order To MpackRef
8322 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8323
8324 *****************************************************************************
8325 *!* SELECT DISTINCT pkey FROM __MppkD ;
8326 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8327 *!* INTO CURSOR __DtlExpl
8328
8329
8330 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8331 *!* FROM __MppkD m, (pcTransDetail) d ;
8332 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8333 *!* INTO CURSOR __DtlExpl
8334
8335 && TR 1011644 VSS 27-09-2005
8336
8337 Select Distinct d.pkey ;
8338 FROM __MppkD mp, (pcTransDetail) d ;
8339 WHERE d.Errs_Flg_D= "N" ; &&no error
8340 And mp.Style = d.Style ;
8341 AND mp.color_code = d.color_code ;
8342 AND mp.lbl_code = d.lbl_code ;
8343 AND mp.Dimension = d.Dimension;
8344 AND d.implosion = 'Y';
8345 INTO Cursor __DtlExpl
8346
8347 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8348
8349 Endif
8350 Endif
8351 Endif
8352 Endif
8353 Endwith
8354
8355 If Used("__MppkH")
8356 Use In __MppkH
8357 Endif
8358 If Used("__MppkD")
8359 Use In __MppkD
8360 Endif
8361 If Used("tcMppkVer")
8362 Use In tcMppkVer
8363 Endif
8364 If Used("__DtlExpl")
8365 Use In __DtlExpl
8366 Endif
8367 If Used("__TmpCursor")
8368 Use In __TmpCursor
8369 Endif
8370
8371 Select(lnOldSelect)
8372 Return llRetVal
8373
8374 Endfunc
8375
8376 *----------------------------------------------------------------------------------------
8377 Procedure ExplodeMultiPackVertical
8378 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8379 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8380 llRetVal = .T.
8381 lnOldSelect = Select()
8382
8383 .LogEntry("Exploding multi pack details into vertical cursor.")
8384 Select (pcDetailtoExplode)
8385
8386 Scan
8387
8388 If Seek(pkey, pcTransDetail, "Pkey")
8389
8390 * Current working trans detail
8391 Select (pcTransDetail)
8392 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8393 lnCurDtlTotal_qty= total_qty
8394
8395
8396 Scatter Name loTransDetail Memo
8397 * delete current working trans detail already have image
8398 * in loTransDetail
8399 Delete In (pcTransDetail)
8400
8401
8402 Select (pcMultDetailVert)
8403 * Find 1st match of OURSKU
8404 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8405 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8406
8407
8408 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8409 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8410 * Exploding detail line
8411 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8412 If !Empty(loTransDetail.pkey)
8413
8414 Select (pcMultDetailVert)
8415 Scatter Name loVert Memo
8416
8417 Select (pcTransDetail)
8418 Append Blank
8419 Gather Name loTransDetail Memo
8420
8421 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8422 sizebucket With loVert.sizebucket, ;
8423 size_desc With loVert.size_desc, ;
8424 division With loVert.division, ;
8425 STYLE With loVert.Style, ;
8426 color_code With loVert.color_code, ;
8427 lbl_code With loVert.lbl_code, ;
8428 DIMENSION With loVert.ppk_code In (pcTransDetail)
8429 Else
8430 .LogEntry("Pkey cannot be empty.")
8431 llRetVal= .F. && Cannot get Pkey from bcsysnum
8432 Exit
8433 Endif
8434
8435 Select (pcMultDetailVert)
8436 Endscan
8437 Else
8438 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8439 llRetVal= .F. && Should be in pcMultDetailVert
8440 Exit
8441 Endif
8442 Endif
8443
8444 If !llRetVal &&Get out of scan when have some problem
8445 Exit
8446 Endif
8447 Endscan
8448
8449 Select(lnOldSelect)
8450 Return llRetVal
8451 Endproc
8452 *=== TR 1011644 23-AUG-2005 KA
8453
8454 *----------------------------------------------------------------------------------------
8455 Procedure ExplodeMultPackRef
8456 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8457 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8458 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8459
8460 lnOldSele = Select()
8461 lcDivStyle = ""
8462 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8463
8464 llRetVal= .T.
8465 lnCurDtlFkey= 0
8466 lnMultiplyQty = 0
8467
8468 .LogEntry("Exploding multi pack details.")
8469
8470 Select (pcMultPackDetail)
8471 Set Order To DivStyle
8472 Scan
8473
8474 If lnCurDtlFkey<> fkey
8475 lnCurDtlFkey = fkey
8476 If Seek(fkey, pcMultPackHeader , "PKEY")
8477 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8478 Else
8479 llRetVal = .F.
8480 Exit
8481 Endif
8482 Endif
8483
8484
8485 * only run once per Div + Style
8486 If !(lcDivStyle == division + Style)
8487 lcDivStyle = division + Style
8488 * Insert a record for each size bucket with a caption *
8489 If !v_GetSizeHeadings(division, Style, "__xSizer")
8490 llRetVal = .F.
8491 Exit
8492 Endif
8493 Endif
8494
8495
8496 lnSizeQty = 1
8497 Select (pcMultPackDetail)
8498 Scatter Memvar Memo
8499
8500 lnSizePosition = 1
8501 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8502 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8503 lnSizeQty = ppk_qty
8504
8505 m.sizebucket = lnSizePosition
8506 m.size_desc = lcSizeName
8507 m.total_qty = lnSizeQty
8508 m.multQty = lnMultiplyQty
8509
8510 If lnSizeQty > 0 && Only want buckets with activity!
8511 Insert Into (pcMultPackTarget) From Memvar
8512 Endif
8513 Select (pcMultPackDetail)
8514
8515 Endscan
8516
8517 This.TableClose("__xSizer")
8518 Select (pcMultPackDetail)
8519 Select (lnOldSele)
8520 Return llRetVal
8521 Endproc
8522
8523 *----------------------------------------------------------------------------------------
8524 *--- TechRec 1016817 04-May-2006 GS ---
8525 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8526 Procedure GetStyleError
8527
8528 Lparameter tcErrorMsg, toTmpCurs
8529
8530 Do Case
8531 Case vl_scolr(division,,, Style, color_code, lbl_code)
8532 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8533
8534 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8535 tcErrorMsg = "Invalid Label code." + CRLF
8536
8537 Case !Empty(Style) And vl_Stylr(division,,, Style)
8538 tcErrorMsg = "Invalid Color code." + CRLF
8539
8540 Otherwise
8541 tcErrorMsg = "Invalid Style." + CRLF
8542 Endcase
8543 Endproc
8544
8545 *----------------------------------------------------------------------------------------
8546
8547 **********************************************************************************
8548 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8549 **********************************************************************************
8550 Procedure PopulateInboundUOM
8551 Lparameters pceipoTH, pceipoTD, pceipoCR
8552 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8553 llRetVal = .T.
8554 lnOldSelect = Select()
8555
8556 With This
8557
8558 *****************************************************************************
8559 * unconditionally reset all base_uom and uom_factor
8560 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8561
8562 *****************************************************************************
8563 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8564 * Server-side join previous list to get cursor of scolr to populate base_uom
8565 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8566 FROM (pceipoTH) h, (pceipoTD) d ;
8567 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8568 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8569 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8570 * TAN 31891 - JAZ - 5/20/02 @@@
8571 * If Recc("__TmpCursor")> 0
8572 If Reccount("__TmpCursor")> 0
8573 * End TAN 31891 - JAZ - 5/20/02
8574 .cSQLTempTable=""
8575 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8576 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8577 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8578 "Where s.division= t.division and s.style= t.style and "+;
8579 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8580 "s.dimension= t.dimension"
8581 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8582 * Populate style UOM
8583 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8584 Endif
8585 .TableClose("tcUOM")
8586 .TableClose("__TmpCursor")
8587
8588 *****************************************************************************
8589 * Get distinct list of Inbound UOM and style UOM
8590 * Server-side join previous list to populate UOM conversion factor
8591 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8592 WHERE ib_uom<>'' And base_uom<>'' ;
8593 INTO Cursor __TmpCursor
8594 * TAN 31891 - JAZ - 5/20/02
8595 * If Recc("__TmpCursor")> 0
8596 If Reccount("__TmpCursor")> 0
8597 * End TAN 31891 - JAZ - 5/20/02
8598 .cSQLTempTable=""
8599 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8600 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8601 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8602 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8603 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8604 * Populate style UOM
8605 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8606 Endif
8607 .TableClose("tcUOMFactor")
8608 .TableClose("__TmpCursor")
8609
8610 Endwith
8611 Select(lnOldSelect)
8612 Return llRetVal
8613 Endproc
8614
8615 *----------------------------------------------------------------------------------------
8616
8617 Procedure PopulateBaseUOM
8618 Lparameters pceipoTD, pcUOM
8619 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8620 llRetVal = .T.
8621 lnOldSelect = Select()
8622
8623 With This
8624 Select (pcUOM)
8625 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8626 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8627 "division+style+color_code+lbl_code+dimension")
8628 Select (pceipoTD)
8629 If llRetVal
8630 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8631 FOR !Empty(&pcUOM..uom)
8632 Endif
8633 Set Relation To
8634 Endwith
8635 Select(lnOldSelect)
8636 Return llRetVal
8637 Endproc
8638
8639 *----------------------------------------------------------------------------------------
8640
8641 Procedure PopulateUOMFactor
8642 Lparameters pceipoTD, pcUOMFactor
8643 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8644 llRetVal = .T.
8645 lnOldSelect = Select()
8646
8647 With This
8648 Select (pcUOMFactor)
8649 Index On uom+uom_convert Tag IB_BaseUOM
8650 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8651 "ib_uom+base_uom")
8652 Select (pceipoTD)
8653 If llRetVal
8654 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8655 FOR !Empty(&pcUOMFactor..uom_factor)
8656 Endif
8657 Set Relation To
8658 Endwith
8659 Select(lnOldSelect)
8660 Return llRetVal
8661 Endproc
8662
8663 *----------------------------------------------------------------------------------------
8664
8665 Procedure ResolvePrepack
8666 Lparameters pceipoTH, pceipoTD, pceipoCR
8667
8668 LOCAL llRetVal
8669 llRetVal = .t.
8670 IF VARTYPE(This.oResolvePrepack) <> "O"
8671 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8672 ENDIF
8673
8674 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8675
8676 IF NOT llRetVal
8677 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8678 RETURN llRetVal
8679 ENDIF
8680
8681 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8682 this.oResolvePrepack.cLogName = this.cLogName
8683
8684 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8685 This.oResolvePrepack.c850Control = This.c850Control
8686 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8687
8688 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
8689
8690 RETURN llRetVal
8691
8692 ENDPROC
8693
8694 *------------------------------------------------------------------------
8695
8696 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8697 Procedure ValidateCharges
8698 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8699
8700 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8701 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8702 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8703 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8704 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8705 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8706 lcDtlError = "Has errors in Charges." + CRLF
8707 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8708 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8709 SELECT (tcEipoTH)
8710 lntcEipoTHrec = RECNO()
8711 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8712
8713 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8714 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8715 v_sqlExec(;
8716 "select d.FKey"+;
8717 " , d.Chrg_Type"+;
8718 " , d.Chrg_Flag"+;
8719 " , d.Active_Ok"+;
8720 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8721 " from zzxChrgD d"+;
8722 " join zzxChrTR t"+;
8723 " on t.Chrg_Type = d.Chrg_Type"+;
8724 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8725 Select qChrgD
8726 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8727 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8728 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8729 v_sqlExec(;
8730 "select Customer"+;
8731 " , Division"+;
8732 " , Store"+;
8733 " , Center_Code"+;
8734 " , Season"+;
8735 " , PKey"+;
8736 " , Rank_Seq"+;
8737 " from zzxchrgh", "qChrgH")
8738 Select qChrgH
8739 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8740 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8741 Index On division+customer+Store+Center_Code+Season Tag divcust
8742 If division = ' ' And customer = ' '
8743 lnDefaultKey = pkey
8744 Endif
8745
8746 Select (tcEiPOTR)
8747 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8748 Scan
8749 lcChrg_Type = Chrg_Type
8750 Select (tcEiPOtd)
8751 lcDivision = division
8752 lcCustomer = customer
8753 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8754 lnFkeyEipoTD = fkey
8755 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8756 lcCenter_Code = &tcEipoTH..center_Code
8757 lcStore = &tcEipoTH..Store
8758 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8759 lcSeason = &tcEipoTH..Season
8760 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8761 ELSE
8762 lcCenter_Code = ""
8763 lcStore = ""
8764 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8765 lcSeason = ""
8766 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8767 ENDIF
8768 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8769
8770 Select qChrgH
8771 Do Case
8772 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8773*!* Case Seek(lcDivision+lcCustomer)
8774*!* lnFKey = pkey
8775*!* Case Seek(' '+lcCustomer, "qChrgH")
8776*!* lnFKey = pkey
8777*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8778*!* Case Seek(lcDivision+' ')
8779*!* lnFKey = pkey
8780*!* Otherwise
8781*!* lnFKey = lnDefaultKey
8782 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8783*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8784*!* lnFKey = pkey
8785*!*
8786*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8787*!* lnFKey = pkey
8788*!*
8789*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8790*!* lnFKey = pkey
8791*!*
8792*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8793*!* lnFKey = pkey
8794
8795*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8796*!* lnFKey = pkey
8797*!*
8798*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8799*!* lnFKey = pkey
8800
8801 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
8802 lnFKey = pkey
8803
8804 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
8805 lnFKey = pkey
8806
8807 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
8808 lnFKey = pkey
8809
8810 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
8811 lnFKey = pkey
8812
8813 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
8814 lnFKey = pkey
8815
8816 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
8817 lnFKey = pkey
8818
8819 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
8820 lnFKey = pkey
8821
8822 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
8823 lnFKey = pkey
8824
8825 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
8826 lnFKey = pkey
8827
8828 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
8829 lnFKey = pkey
8830 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8831
8832 Otherwise
8833 lnFKey = lnDefaultKey
8834 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8835 Endcase
8836 Select (tcEiPOTR)
8837 If Empty(lnFKey)
8838 Replace Errs_Flg_R With "Y",;
8839 Errs_Msg_R With "No Charges set up for "+;
8840 Trim(lcDivision)+'/'+Trim(lcCustomer)
8841 Else
8842 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
8843 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
8844
8845 *--- Check if the Charge still active:
8846 If qChrgD.Active_Ok # 'Y'
8847 Replace Errs_Flg_R With "Y",;
8848 Errs_Msg_R With lcErrorMsg3
8849 Endif
8850
8851 If Empty(Chrg_Flag)
8852 *-- Set Charge Type from Resolution if success
8853 If Errs_Flg_R # "Y"
8854 Replace Chrg_Flag With lcResolved_Chrg_Flag
8855 Endif
8856 Else
8857 If Chrg_Flag # lcResolved_Chrg_Flag
8858 Replace Errs_Flg_R With "Y",;
8859 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
8860 Endif
8861 Endif
8862 Else
8863 Replace Errs_Flg_R With "Y",;
8864 Errs_Msg_R With lcErrorMsg1
8865 lnFKey = fkey
8866 lcResolved_Chrg_Flag = ""
8867 Endif
8868 Endif
8869
8870 If Errs_Flg_R = "Y"
8871 Select(tcEiPOtd)
8872 If !lcDtlError$Errs_Msg_D
8873 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
8874 Errs_Flg_D With 'Y'
8875 Endif
8876 ELSE
8877 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
8878* Replace Chrg_Cost With qChrgD.Chrg_Cost
8879 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
8880 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
8881 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
8882 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
8883 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
8884 Endif
8885 Endscan
8886
8887 Set Relation To
8888 Use In Select("qChrgH")
8889 Use In Select("qChrgD")
8890 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8891 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
8892 GO lntcEipoTHrec IN (tcEipoTH)
8893 ENDIF
8894 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8895
8896 Endproc
8897 *=== TechRec 1028745 05-Feb-2008 GSternik ===
8898
8899 *------------------------------------------------------------------------
8900
8901 *--- TR 1083402 20-Jan-2015 Partha ---
8902 * ROFL - This proc is duplicate :)
8903*!* *----------------------------------------------------------------------------------------
8904*!* *--- TR 1034481 NH
8905*!* PROCEDURE MarkHeaderForMissing855ControlRef
8906*!* LPARAMETERS pceipoTH
8907*!*
8908*!* LOCAL llRetVal, lnOldSelect,lcZzeoprcr
8909*!*
8910*!* llRetVal = .t.
8911*!* lnOldSelect = SELECT()
8912*!* lcZzeoprcr = "Oprcr" + SYS(2015)
8913*!* *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
8914*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
8915*!*
8916*!* IF USED(lcZzeoprcr)
8917*!* INDEX on customer TAG customer
8918*!* INDEX on division TAG division
8919*!*
8920*!* UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
8921*!* from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
8922*!* AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
8923
8924*!* USE IN (lcZzeoprcr)
8925*!* ENDIF
8926*!*
8927*!* SELECT(lnOldSelect)
8928*!* RETURN llRetVal
8929*!*
8930*!* ENDPROC
8931*!* *=== TR 1034481 NH
8932
8933 *=== TR 1083402 20-Jan-2015 Partha ===
8934
8935 *----------------------------------------------------------------------------------------
8936
8937 *--- TR 1035491 4-Nov-2008 Goutam
8938 ************************************************************************************
8939 * Move SLN to Detail.
8940 ************************************************************************************
8941 Procedure MoveSLNToDTLs
8942 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8943 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8944 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
8945 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
8946
8947 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
8948 lnLine_Seq
8949
8950 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8951 LOCAL lcSQL ,loIPOtdn
8952 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8953
8954 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
8955
8956 llRetVal = true
8957 lnOldSelect = Select()
8958 lnDetailPrice = 0
8959
8960 *--- TR 1036614 8-Jun-2009 Goutam
8961 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
8962
8963*!* select t.Customer ;
8964*!* , t.FKey ;
8965*!* , t.PKey ;
8966*!* , c.price_flg ;
8967*!* from (pcTmpCursor) t ;
8968*!* join zzeipocr c ;
8969*!* on c.division = t.division ;
8970*!* and c.customer = t.customer ;
8971*!* join (pceipoTD) d ;
8972*!* on d.pkey = t.dtlPkey ;
8973*!* where c.slntodtl = 'Y' ;
8974*!* and d.slntodtl <> 'Y' ;
8975*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
8976*!* into Cursor __tmpipots ;
8977*!* order by t.fkey, t.Customer, t.PKey
8978
8979 *=== TR 1036614 8-Jun-2009 Goutam
8980
8981 *-- #1 Create detail record from pceipoTS
8982 SELECT __tmpipots
8983 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
8984 GO top
8985 lnSkipedPSFkey = 0
8986 lnPSFkey = 0
8987 lnCoor_Code = 1
8988 lnLine_Seq = 0
8989 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
8990
8991 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8992 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8993 ENDIF
8994 DO WHILE NOT EOF()
8995 lnPSFkey = Fkey
8996
8997 *--- TR 1049029 24-Aug-2010 Partha ---
8998 IF lnPSFkey <> lnSkipedPSFkey
8999 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
9000 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
9001 ENDIF
9002 *=== TR 1049029 24-Aug-2010 Partha ===
9003
9004 lnStartPkey = lnStartPkey + 1
9005 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9006 lnLine_Seq = lnLine_Seq + 1
9007 SELECT (pceipoTD)
9008 SCATTER NAME loIPOtd MEMO
9009 loIPOtd.pkey = lnStartPkey
9010 loIPOtd.Line_Seq = lnLine_Seq
9011
9012 *-FH 1077588 - detail's header pkey
9013 lnHfkey = fkey
9014
9015 *--- TechRec 1056973 06-Dec-2011 jisingh ---
9016 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
9017 *- 1060291 04/02/2012 YIK/FH
9018*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9019*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
9020 SELECT (pczzeiPOtWhse)
9021 lnDocNum = doc_num
9022 lnEdiLine = edi_line
9023 lnSlnLine = sln_line
9024
9025 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
9026 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
9027 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
9028
9029 SELECT (pceipoTD)
9030 *= 1060291
9031 ENDIF
9032 *=== TechRec 1056973 06-Dec-2011 jisingh ===
9033
9034 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
9035*!* loIPOtd.slntodtl = 'Y'
9036
9037 *--- TR 1045922 05-MAR-2010 HNISAR
9038 *- 1060291 03/30/2012 YIK
9039 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
9040*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9041*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
9042 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
9043 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
9044 *=== TechRec 1056973 09-Nov-2011 jisingh ===
9045 *=== TR 1045922 05-MAR-2010 HNISAR
9046
9047
9048
9049 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
9050 *--- TechRec 1063327 16-Aug-2012 jjanand ---
9051 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
9052*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
9053*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
9054*!* loIPOtd.assort_qty = loIPOtd.total_qty
9055*!* ENDIF
9056 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
9057*!* IF EMPTY(loIPOtd.Assortment)
9058*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9059*!* IF loIPOtd.assort_qty = 0
9060*!* loIPOtd.assort_qty = loIPOtd.total_qty
9061*!* ENDIF
9062*!* ENDIF
9063
9064 IF EMPTY(loIPOtd.Assortment)
9065 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
9066 ENDIF
9067 IF EMPTY(loIPOtd.assort_qty)
9068 loIPOtd.assort_qty = loIPOtd.total_qty
9069 ENDIF
9070 *=== TechRec 1063327 16-Aug-2012 jjanand ===
9071 *- TR 1062810 FH
9072
9073 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
9074 loIPOtd.PO1_UPC = loIPOtd.UPC
9075 loIPOtd.PO1_SKU = loIPOtd.SKU
9076 loIPOtd.po1_price = loIPOtd.org_price
9077 loIPOtd.Division = &pceipoTS..Division
9078 loIPOtd.Style = &pceipoTS..Style
9079 loIPOtd.Color_code = &pceipoTS..Color_code
9080 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
9081 loIPOtd.Dimension = &pceipoTS..Dimension
9082 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
9083 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
9084 loIPOtd.UPC = &pceipoTS..SLN_UPC
9085 *- 03/19/09 1038539, 1039344 YIK
9086 loIPOtd.SKU = &pceipoTS..SLN_SKU
9087 *- TR 1051757 FH 04/19/11
9088 loIPOtd.aux_sku = &pceipoTS..aux_sku
9089
9090 *--- TechRec 1056973 07-Dec-2011 jisingh ---
9091 loIPOtd.sln01 = &pceipoTS..sln01
9092 *=== TechRec 1056973 07-Dec-2011 jisingh ===
9093
9094 *--- TR 1049029 30-Aug-2010 Partha ---
9095
9096*!* *--- TR 1047912 23-Jun-2010 Partha ---
9097*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
9098*!* *=== TR 1047912 23-Jun-2010 Partha ===
9099*!*
9100*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9101*!*
9102*!* *=== TR 1047912 23-Jun-2010 Partha ===
9103*!* ENDIF
9104*!* *=== TR 1047912 23-Jun-2010 Partha ===
9105*!*
9106*!* *--- TR 1047912 23-Jun-2010 Partha ---
9107*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
9108*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9109*!* ELSE
9110*!* lnDetailPrice = &pceipoTD..Org_Price
9111*!* ENDIF
9112*!* *=== TR 1047912 23-Jun-2010 Partha ===
9113
9114 DO CASE
9115 CASE loIPOtd.ppk_action = 'B'
9116 *- 02/18/11 1052584 YIK
9117 *- Moved calculation of ppk_qty here
9118 loIPOtd.ppk_qty = lnTotSLNQty
9119
9120 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9121
9122 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
9123 *loIPOtd.ppk_action = 'X'
9124 loIPOtd.ppk_action = 'S'
9125 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
9126 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9127 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9128 *- 02/18/11 YIK 1052584
9129 *- moved calculation of ppk_qty higher
9130 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9131
9132 *-TR 1094622 FH - need to update org_price
9133 loIPOtd.org_price = lnDetailPrice
9134
9135 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
9136 *- 02/18/11 YIK 1052584
9137 *- Moved calculation of ppk_qty here
9138 loIPOtd.ppk_qty = lnTotSLNQty
9139
9140 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9141
9142 IF loIPOtd.ppk_action = 'Q'
9143 loIPOtd.ppk_action = 'M'
9144 ENDIF
9145
9146 *- 02/18/11 YIK 1052584
9147 *- moved calculation of ppk_qty higher
9148 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9149
9150 lnDetailPrice = &pceipoTD..Org_Price
9151
9152 CASE loIPOtd.ppk_action = 'P'
9153 *-TR 1062018/1064343 FH - moved up
9154 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9155 *- TR 1062018/1064343 FH - moved up
9156 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9157 loIPOtd.ppk_action = 'D'
9158 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty && TR 1094622 FH - why is there a space here
9159 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9160 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9161
9162 *-TR 1094622 FH - need to update org_price
9163 loIPOtd.org_price = lnDetailPrice
9164
9165 OTHERWISE
9166 *-TR 1062018/1064343 FH - moved up
9167 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9168 *- TR 1062018/1064343 FH - moved up
9169 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9170 lnDetailPrice = &pceipoTD..Org_Price
9171 loIPOtd.ppk_qty = lnTotSLNQty
9172
9173 ENDCASE
9174 *=== TR 1049029 30-Aug-2010 Partha ===
9175
9176 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
9177 IF __tmpipots.price_flg = "E"
9178 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9179 ELSE
9180 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9181 ENDIF
9182
9183 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
9184 loIPOtd.Errs_flg_d = "N"
9185 loIPOtd.Errs_msg_d = ""
9186 *=== TR 1038353 NH
9187
9188 APPEND BLANK
9189 GATHER NAME loIPOtd MEMO
9190
9191 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9192
9193 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
9194 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
9195 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
9196
9197 &lcSQL
9198 SELECT _tmpipodnt
9199 SCAN
9200 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
9201 SELECT "Vzzeipotd_notes_iPOproc"
9202 SCATTER NAME loIPOtdn MEMO
9203
9204 APPEND BLANK
9205 loIPOtdn.Fkey = lnStartPkey
9206 loIPOtdn.Pkey = v_nextPkey("SysNotes")
9207
9208 GATHER NAME loIPOtdn MEMO
9209 ENDIF
9210
9211 ENDSCAN
9212 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
9213
9214 ENDIF && TR 1043037 OCT-06-2009 BR
9215 ENDIF
9216 SELECT __tmpipots
9217 SKIP IN __tmpipots
9218 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
9219
9220 *- TR 1062018/1064343 FH
9221 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9222 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9223 *- TR 1062018/1064343 FH
9224 DELETE IN (pceipoTD)
9225
9226 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9227
9228 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
9229 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
9230 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
9231
9232 ENDIF && TR 1043037 OCT-06-2009 BR
9233
9234 lnCoor_Code = lnCoor_Code + 1
9235 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9236 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9237 ENDIF
9238 lnLine_Seq = 0
9239 ENDIF
9240 ENDDO
9241 USE IN __tmpipots
9242
9243 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9244
9245 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9246 This.Tableupdate("Vzzeipotd_notes_iPOproc")
9247 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9248
9249 ENDIF && TR 1043037 OCT-06-2009 BR
9250
9251 SELECT (lnOldSelect)
9252 RETURN llRetVal
9253 ENDPROC
9254
9255*=======================================================================
9256
9257 *---- get total sln qty for a detail line
9258 FUNCTION getPriceFromIPOts
9259 LPARAMETERS pceipoTS, pnPrice
9260 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
9261 lnUnitPrice = 0
9262 IF pnPrice > 0
9263 lnOldSelect = SELECT()
9264
9265 SELECT (pceipoTS)
9266 lnFkey = Fkey
9267 lnSLNQty = SLN_Qty
9268 .PushRecordSet()
9269 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
9270 lnUnitPrice = pnPrice/lnSLNTotalQty
9271 .PopRecordSet()
9272
9273 SELECT (lnOldSelect)
9274 ENDIF
9275
9276 RETURN lnUnitPrice
9277 ENDFUNC
9278
9279 ************************************************************************************
9280 * Resolve BC SKU from SLN records and create customer style data.
9281 *--- This is splitted 1st part from function ResolveStyleFromSLN
9282 ************************************************************************************
9283 Procedure ResolveBCSkuFromSLN
9284 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9285 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9286 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
9287 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9288 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
9289 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
9290
9291 lnOldSelect = Select()
9292 llRetVal = .T. && 1040686
9293 *--- TR 1036614 3-Mar-2010 Goutam
9294 lcErrs_Msg = ""
9295 lcDivision = ""
9296 *=== TR 1036614 3-Mar-2010 Goutam
9297
9298 *-- #1 Resolve SLN SKUs
9299 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
9300 *- 03/19/09 TR ? Retrofit TR1038539 YIK
9301 *- added SLN_SKU
9302 *- Removed WHERE ...and !Empty(s.SLN_UPC)
9303
9304 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
9305 * Added , s.sln_qty
9306 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
9307
9308 select h.Customer;
9309 , s.FKey;
9310 , s.SLN_UPC as UPC;
9311 , s.SLN_SKU as SKU ;
9312 , h.department ;
9313 , h.store ;
9314 , s.PKey;
9315 , .F. as SLN_Error;
9316 , Empty(d.SizeBucket) as Unresolved;
9317 , s.Division;
9318 , s.Style;
9319 , s.Color_Code;
9320 , s.SizeBucket;
9321 , d.Pkey as dtlPkey;
9322 , 'N' as IsPPK;
9323 , SPACE(5) as ppk_code;
9324 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9325 , s.sln_qty ;
9326 from (pceipoTH) h;
9327 join (pceipoTD) d ;
9328 on d.FKey = h.PKey;
9329 join (pceipoTS) s ;
9330 on s.FKey = d.PKey ;
9331 where !Empty(h.Customer) ;
9332 order by 1, 2;
9333 into Cursor tmpCurs ReadWrite
9334
9335* , s.Lbl_Code;
9336* , s.Dimension;
9337
9338*- 1040686
9339
9340 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9341 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9342 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9343 IF llRetVal
9344 .PopulateSQLTempTable("tcCustUpc")
9345 ENDIF
9346
9347 llRetVal = llRetVal AND v_sqlexec(;
9348 "SELECT x.upc,d.* "+;
9349 " FROM zzxcstdr d"+ ;
9350 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9351 " JOIN " + this.cSQLTempTable + " x " + ;
9352 " ON d.customer = x.customer " +;
9353 " AND d.cust_style = x.upc " + ;
9354 " WHERE h.IB_resolv = 'Y'" + ;
9355 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9356 SELECT tmpCstdr_upc
9357 INDEX on customer + upc TAG cust_upc
9358
9359
9360 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9361 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9362 IF llRetVal
9363 .PopulateSQLTempTable("tcDistUpc")
9364 ENDIF
9365
9366 llRetVal = llRetVal AND v_sqlexec(;
9367 "SELECT x.upc,d.* "+;
9368 " FROM zzeupcnr d"+ ;
9369 " JOIN " + this.cSQLTempTable + " x " + ;
9370 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9371 SELECT tmpUpcnr
9372 INDEX on upc TAG upc
9373
9374
9375 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9376 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9377 IF llRetVal
9378 .PopulateSQLTempTable("tcDistCustSku")
9379 ENDIF
9380 llRetVal = llRetVal AND v_sqlexec(;
9381 "SELECT x.sku,d.* "+;
9382 " FROM zzxcstdr d"+ ;
9383 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9384 " JOIN " + this.cSQLTempTable + " x " + ;
9385 " ON d.customer = x.customer " +;
9386 " AND d.cust_style = x.sku " + ;
9387 " WHERE h.IB_resolv = 'Y'" + ;
9388 " AND d.Size_Desc>'' " + ;
9389 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9390 SELECT tmpCstdr_sku
9391 INDEX ON customer + cust_style TAG cust_sku
9392
9393 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9394 UNION ;
9395 SELECT customer,sku FROM tmpCstdr_sku ;
9396 GROUP BY customer,sku ;
9397 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9398 INDEX ON customer+sku TAG cust_sku
9399 *=-===-=-=-=-=-=-=-
9400
9401*- 1040686
9402
9403 Select tmpCurs
9404 If This.lUserInterface
9405 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9406 This.InitThermo(RecCount())
9407 EndIf
9408
9409 lcOldCust = ""
9410 lcOldUPC = ""
9411 *- 03/19/09 1038539 YIK
9412 lcOldItem = ''
9413 Local lcSku_resolv, lcOldSku_resolv
9414 lcSku_resolv = ""
9415 *=
9416
9417 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9418 If This.lUserInterface
9419 * Advance progress bar, if we're using one.
9420 This.AdvanceThermo(RecNo())
9421 EndIf
9422 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9423 IF !EMPTY(tmpCurs.UPC)
9424
9425 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9426 lcErrs_Msg = ""
9427 lcOldCust = tmpCurs.Customer
9428 lcOldUPC = tmpCurs.UPC
9429
9430 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9431 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9432*- 1040686
9433*!* lcDivision = tmpCstdr.division
9434*!* lcStyle = tmpCstdr.Style
9435*!* lcColor_Code = tmpCstdr.Color_Code
9436*!* lcLbl_Code = tmpCstdr.Lbl_Code
9437*!* lcDimension = tmpCstdr.Dimension
9438*!* lnSizeBucket = tmpCstdr.Size_Bk
9439*!* lnSize_Desc = tmpCstdr.Size_Desc
9440 lcDivision = tmpCstdr_upc.division
9441 lcStyle = tmpCstdr_upc.Style
9442 lcColor_Code = tmpCstdr_upc.Color_Code
9443 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9444 lcDimension = tmpCstdr_upc.Dimension
9445 lnSizeBucket = tmpCstdr_upc.Size_Bk
9446 lnSize_Desc = tmpCstdr_upc.Size_Desc
9447*- 1040686
9448 Else
9449 lcErrs_Msg = ""
9450 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9451 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9452 lcDivision = tmpUpcnr.Division
9453 lcStyle = tmpUpcnr.Style
9454 lcColor_Code = tmpUpcnr.Color_Code
9455 lcLbl_Code = tmpUpcnr.Lbl_Code
9456 lcDimension = tmpUpcnr.Dimension
9457 lnSizeBucket = tmpUpcnr.SizeBucket
9458 lnSize_Desc = tmpUpcnr.Size_Desc
9459 ELSE
9460 *-&&1040686
9461 *lcErrs_Msg = lcErrs_Msg + CRLF
9462 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9463 *-&&1040686
9464 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9465 lnSizeBucket = 0
9466 Endif
9467 Endif
9468 Endif && level break
9469 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9470 *- Added resolution on SKU
9471 ENDIF && TmpCurs.UPC
9472 *- 03/17/09 TR 1038539 YIK
9473 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9474 *- but UPC resolution failed.
9475 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9476 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9477
9478 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9479 lcErrs_Msg = ""
9480 lcOldCust = tmpCurs.customer
9481 lcOldItem = tmpCurs.sku
9482
9483 *- 1040686
9484 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9485 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9486 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9487 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9488 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9489 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9490 Store 0 To lnSizeBucket
9491 ELSE
9492 *- TR 1074276 FH - adding UPPER()
9493 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9494 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9495 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9496 Store 0 To lnSizeBucket
9497 ELSE
9498*!* lcDivision = tmpCstdr.division
9499*!* lcStyle = tmpCstdr.Style
9500*!* lcColor_code = tmpCstdr.color_code
9501*!* lcLbl_code = tmpCstdr.lbl_code
9502*!* lcDimension = tmpCstdr.Dimension
9503*!* lnSizeBucket = tmpCstdr.size_bk
9504*!* lnSize_desc = tmpCstdr.size_desc
9505 lcDivision = tmpCstdr_sku.division
9506 lcStyle = tmpCstdr_sku.Style
9507 lcColor_code = tmpCstdr_sku.color_code
9508 lcLbl_code = tmpCstdr_sku.lbl_code
9509 lcDimension = tmpCstdr_sku.Dimension
9510 lnSizeBucket = tmpCstdr_sku.size_bk
9511 lnSize_desc = tmpCstdr_sku.size_desc
9512 ENDIF
9513 ENDIF
9514 *- 1040686
9515 ENDIF
9516 ENDIF
9517 *== 1038539 Resolution on SKU
9518
9519 Select (pceipoTS)
9520 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9521
9522 Scatter Name loEiPOTS Memo
9523 If !Empty(lcErrs_Msg)
9524 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9525 loEiPOTS.Errs_Flg_S = "Y"
9526 replace Sln_Error with .T. in tmpCurs
9527 Else
9528 replace Division with lcDivision in tmpCurs
9529 Endif
9530
9531 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9532 loEiPOTS.Division = lcDivision
9533 loEiPOTS.Style = lcStyle
9534 loEiPOTS.Color_Code = lcColor_code
9535 loEiPOTS.Lbl_Code = lcLbl_code
9536 loEiPOTS.Dimension = lcDimension
9537 loEiPOTS.SizeBucket = lnSizeBucket
9538 loEiPOTS.Size_Desc = lnSize_Desc
9539 Endif
9540
9541 Gather Name loEiPOTS Memo
9542
9543 EndScan
9544
9545*- 1060291 07/02/12 YIK
9546*- The code below makes no sense. It takes the first prepack found for the SLN.
9547*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9548 *--- TR 1036614 17-Mar-2010 Goutam
9549*-- SELECT tmpCurs
9550*-- SCAN FOR IsPPK = 'N'
9551*-- Select (pceipoTS)
9552*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9553*-- Scatter Name loEiPOTS Memo
9554*--
9555*-- IF NOT EMPTY(loEiPOTS.Dimension)
9556*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9557*-- IF !EMPTY(lcppk_code)
9558*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9559*-- ENDIF
9560*-- ENDIF
9561*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9562*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9563*-- 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')
9564*-- SELECT __tmpDimCurs
9565*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9566*-- lcppk_code = dimension
9567*-- USE IN SELECT('__tmpDimCurs')
9568*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9569*-- 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)
9570*-- SELECT __tmpDimCurs
9571*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9572*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9573*-- ENDIF
9574*-- USE IN SELECT('__tmpDimCurs')
9575*-- ENDIF
9576*-- ENDIF
9577*-- ENDSCAN
9578 *--- TR 1036614 17-Mar-2010 Goutam
9579
9580 *--- TR 1038353 NH - error out dtl line for SLN error
9581 UPDATE td SET Style_SLN_OK = 'N' ;
9582 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9583 WHERE ts.errs_flg_s ='Y'
9584 *=== TR 1038353 NH
9585
9586 If This.lUserInterface
9587 * Reset Thermometer
9588 This.ResetThermo()
9589 EndIf
9590
9591 *--- TR 1036614 8-Jun-2009 Goutam
9592 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9593 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9594
9595 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9596 lnSelect = SELECT()
9597
9598 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9599 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9600
9601 Select tmpErrSlnLines
9602 Scan
9603 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9604 Endscan
9605
9606 This.TableClose("tmpErrSlnLines")
9607
9608 Select (lnSelect )
9609 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9610
9611 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9612 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9613 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9614 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9615 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9616 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9617 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9618 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9619
9620 This.TableClose("tmpCurs")
9621
9622 *=== TR 1036614 8-Jun-2009 Goutam
9623
9624 *-1040686
9625 USE IN SELECT("tcCustUpc")
9626 USE IN SELECT("tmpCstdr_upc")
9627 USE IN SELECT("tcDistUpc")
9628 USE IN SELECT("tmpUpcnr")
9629 USE IN SELECT("tcDistCustSku")
9630 USE IN SELECT("tmpCstdr_sku")
9631 USE IN SELECT("tcAmbigSku")
9632 *-1040686
9633
9634 Select(lnOldSelect)
9635 Return llRetVal
9636 Endproc
9637
9638
9639 *--------------------------------------------
9640 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9641 *--------------------------------------------
9642 Procedure GetImplodeSQL
9643 *-- Populates cImplodeSQL
9644 SET TextMerge OFF NoShow
9645*-- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9646*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9647 Text to this.cImplodeSQL flags 1
9648declare @Division char(3), @Style varChar(50), @Customer char(7),
9649 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9650
9651set @Customer = ?cCustomer
9652set @Division = ?cDivision
9653set @Style = ?cStyle
9654
9655-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9656select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9657 from zzeipocr_expl
9658 where Customer = @Customer
9659 and Division = @Division
9660
9661select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9662
9663--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9664
9665-- Output Values:
9666--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9667declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9668
9669-- first SQL:
9670if @CR_Lbl > ''
9671select top 1 @Color_Code = c.Color_Code
9672 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9673 , @Dimension = c.Dimension
9674 , @Size = Min(z.Size01)
9675-- , c.Lbl_Code as SColR_Lbl
9676 from zzxSColR c
9677 join zzxStylR st
9678 on st.PKey = c.FKey
9679 join zzxPPakH ph
9680 on ph.Division = c.Division
9681 and ph.Size_Code = st.Size_Code
9682 and ph.Ppk_Code = c.Dimension
9683 and c.Color_Code = case
9684 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9685 else c.Color_Code end
9686 join zzxPPakD pd
9687 on pd.FKey = ph.PKey
9688 join zzxSizer z
9689 on z.Division = c.Division
9690 and z.Size_Code = st.Size_Code
9691 cross join zzxBuckt b
9692 left join #ImplodeSLN i
9693 on i.Color_Code = case
9694 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9695 else pd.Color_Code end
9696 and (i.Lbl_Code = case
9697 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9698 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9699 and i.Dimension = pd.Dimension
9700 and i.SizeBucket = b.Size_Num
9701 where c.Style = @Style
9702 and c.Division = @Division
9703 and c.PPack_OK = 'Y'
9704 and c.Active_OK = 'Y'
9705 and ph.Active_OK = 'Y'
9706 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9707 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9708 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9709 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9710 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9711 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9712 and (c.Lbl_Code = case
9713 when @SLN_Lbl > ''
9714 then @SLN_Lbl
9715 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9716 group by c.PKey, ph.Pack_qty
9717 , c.Color_code, c.Lbl_Code, c.Dimension
9718having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9719 and sum(i.Qty) = ph.Pack_qty
9720 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9721 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9722
9723IF @CR_Lbl > '' and @@ROWCOUNT > 0
9724 select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9725ELSE BEGIN
9726
9727select top 1 @Color_Code = c.Color_Code
9728 , @Lbl_Code = c.Lbl_Code
9729 , @Dimension = c.Dimension
9730 , @Size = Min(z.Size01)
9731 from zzxSColR c
9732 join zzxStylR st
9733 on st.PKey = c.FKey
9734 join zzxPPakH ph
9735 on ph.Division = c.Division
9736 and ph.Size_Code = st.Size_Code
9737 and ph.Ppk_Code = c.Dimension
9738 and c.Color_Code = case
9739 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9740 else c.Color_Code end
9741 join zzxPPakD pd
9742 on pd.FKey = ph.PKey
9743 join zzxSizer z
9744 on z.Division = c.Division
9745 and z.Size_Code = st.Size_Code
9746 cross join zzxBuckt b
9747 left join #ImplodeSLN i
9748 on i.Color_Code = case
9749 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9750 else pd.Color_Code end
9751 and (i.Lbl_Code = case
9752 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9753 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9754 and i.Dimension = pd.Dimension
9755 and i.SizeBucket = b.Size_Num
9756 where c.Style = @Style
9757 and c.Division = @Division
9758 and c.PPack_OK = 'Y'
9759 and c.Active_OK = 'Y'
9760 and ph.Active_OK = 'Y'
9761 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9762 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9763 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9764 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9765 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9766 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9767 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9768 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9769 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9770 group by c.PKey, ph.Pack_qty
9771 , c.Color_code, c.Lbl_Code, c.Dimension
9772having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9773 and sum(i.Qty) = ph.Pack_qty
9774 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9775 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9776 , c.Lbl_code -- blank one goes first if there is no match
9777
9778select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9779 where @Color_Code is not null
9780END
9781EndText
9782
9783*--- TechRec 1073664 20-Sep-2013 GSternik ---
9784 Text to this.cImplodeRangeSQL flags 1
9785declare @Division char(3)
9786set @Division = ?cDivision
9787
9788-- Output Values:
9789declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9790
9791select @Style = rh.Rng_Style
9792 , @Color_Code = rh.Rng_Color
9793 , @Lbl_Code = rh.Rng_Lbl
9794 , @Dimension = rh.Rng_Pack
9795 , @SizeBucket = rng_bk
9796 from zzxRangH rh with (NoLock)
9797 join zzxRangD rd with (NoLock)
9798 on rd.FKey = rh.PKey
9799 --join zzxSColR c
9800 -- on c.Division = rh.Division
9801 -- and c.Style = rh.Rng_Style
9802 -- and c.Color_Code = rh.Rng_Color
9803 -- and c.Lbl_Code = rh.Rng_Lbl
9804 -- and c.Dimension = rh.Rng_Pack
9805 join zzxBuckt b with (NoLock)
9806 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9807 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9808 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9809 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9810 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9811 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
9812 left join #ImplodeSLN i
9813 on i.Style = rd.Style
9814 and i.Color_Code = rd.Color_Code
9815 and i.Lbl_Code = rd.Lbl_Code
9816 and i.Dimension = rd.Dimension
9817 and i.SizeBucket = b.Size_Num
9818 and i.Division = rd.Division
9819 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9820 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9821 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9822 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9823 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9824 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
9825 where rh.Rng_Type = 'P'
9826 and rh.Division = @Division
9827-- and c.Active_OK = 'Y'
9828 group by rh.Rng_Style
9829 , rh.Rng_Color
9830 , rh.Rng_Lbl
9831 , rh.Rng_Pack
9832 , rng_bk
9833having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9834 and sum(i.Qty) = Max(rh.Rng_Qty)
9835
9836if @Style is not null -- @@RowCount > 0
9837select @Size = case @SizeBucket
9838 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
9839 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
9840 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
9841 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
9842 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
9843 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
9844 from zzxStylR s with (NoLock)
9845 join zzxSizeR z with (NoLock)
9846 on z.Division = s.Division
9847 and z.Size_Code = s.Size_Code
9848 where s.Division = @Division
9849 and s.Style = @Style
9850
9851select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
9852 where @Style is not null
9853EndText
9854*=== TechRec 1073664 20-Sep-2013 GSternik ===
9855
9856 EndProc
9857
9858 *---------------------------------
9859 *--- This function will generate PPK SKU and updates detail with it.
9860 *--- This is splitted 2nd part from function ResolveStyleFromSLN
9861 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
9862 *---------------------------------
9863 Procedure ResolvePPKSkuAndUpdateDetail
9864 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
9865 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9866 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9867 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
9868 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
9869 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
9870
9871 llRetVal = .T.
9872 lnOldSelect = Select()
9873
9874 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
9875 Dimension laBuckets(goEnv.MaxBuckets)
9876
9877 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
9878 Select tmpCurs
9879 lnFKey = 0
9880
9881 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
9882
9883 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
9884 Scan
9885 If FKey # lnFKey
9886 lnFKey = FKey
9887
9888 If SLN_Error or !Unresolved
9889 llDeleteSLN = .T.
9890 Else
9891 llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
9892
9893 If !llDeleteSLN
9894 Select (pceipoCR)
9895 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
9896
9897 *--- TR 1036614 10-Jun-2009 Goutam
9898 *llDeleteSLN = StyleFromSLN < "Y"
9899 llDeleteSLN = StyleFromSLN < "O"
9900 *=== TR 1036614 10-Jun-2009 Goutam
9901
9902 Select tmpCurs
9903 EndIf
9904 EndIf
9905
9906 If !llDeleteSLN
9907 lnRecNo = RecNo()
9908
9909 Scan while FKey = lnFKey
9910 If SLN_Error
9911 *-- One SLN with error exists.
9912 llDeleteSLN = .T.
9913 Exit
9914 EndIf
9915 EndScan
9916
9917 Go lnRecNo
9918 EndIf
9919 EndIf
9920
9921 If llDeleteSLN
9922 Delete
9923 EndIf
9924 EndScan
9925
9926
9927 *-- #3 -- Updating Details with PPK BC SKU:
9928 lcOldCust = ""
9929 lcOldSKU = ""
9930 lnFKey = 0
9931 lnRecNo = This.CountTotalRecs('tmpCurs')
9932
9933 If lnRecNo > 0
9934 *-- Need for optimization:
9935
9936 If This.lUserInterface
9937 This.UpdateThermoCaption("Resolving Style From SLN...")
9938 This.InitThermo(lnRecNo + 1)
9939 lnRecNo = 1
9940 Endif
9941 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
9942
9943 *- 1041704 07/30/09 YIK
9944 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9945 *-- Let's rely on the field types in the UPC table:
9946 *v_SQLExec("create table #ImplodeSLN " + ;
9947 * "( 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)
9948 * " Size_Desc Char(10), Qty Int, PKey Int)")
9949 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
9950 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
9951 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9952
9953 Select (pceipoTD)
9954 lcOldOrder = Order()
9955
9956 *- 03/23/09 YIK
9957 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
9958 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
9959 Index on Customer+SKU+UPC+Assortment tag CustSKU
9960 lcOldUPC = ''
9961 *==
9962
9963 If This.lUserInterface
9964 This.AdvanceThermo(lnRecNo)
9965 EndIf
9966
9967 Select tmpCurs
9968 Locate
9969 cCustomer = Customer
9970
9971 Do while .T. && Scan replacement
9972 if FKey # lnFKey && Will trigger @ EOF :o)
9973 If llProcess
9974 If llImplodeOK
9975 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
9976
9977 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9978 *-- Let's check if they belong to the Range Style 'P'
9979 If Reccount("qPPK") = 0 && Prepack not found
9980 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
9981 EndIf
9982 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9983
9984 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
9985 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9986 Select (pceipoTS)
9987 *- insert into #implodeSLN
9988 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
9989 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9990 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9991 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9992 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9993 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
9994 Endif
9995 EndIf && llImplodeOK
9996 *========= 1041704 07/30/09 YIK
9997
9998 select (pceipoTD)
9999 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
10000 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
10001 lcOldCust = Customer
10002 lcOldSKU = SKU
10003
10004 *- 03/23/09 YIK
10005 *-- Update all records with the same CustSKU
10006 *- =Seek(lcOldCust+lcOldSKU) && First matching record
10007 lcOldUPC = UPC
10008 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
10009
10010 *==
10011 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
10012 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10013 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
10014 replace Division with cDivision, ;
10015 Style with qPPK.Style, ;
10016 Color_Code with qPPK.Color_Code, ;
10017 Lbl_Code with qPPK.Lbl_Code, ;
10018 Dimension with qPPK.Dimension,;
10019 SizeBucket with qPPK.SizeBucket;
10020 Size_Desc with qPPk.Size01;
10021 Style_SLN_OK with 'Y' ;
10022 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10023 Else
10024
10025 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
10026 *--- TR 1036614 12-Jun-2009 Goutam
10027 IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
10028 *=== TR 1036614 12-Jun-2009 Goutam
10029 *--- TR 1056329 02-Nov-11 SK
10030 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
10031 replace Style_SLN_OK with 'N' ;
10032 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
10033 *--- TR 1036614 12-Jun-2009 Goutam
10034 ENDIF
10035 *=== TR 1036614 12-Jun-2009 Goutam
10036
10037 ENDIF
10038 Else && llProcess flag is not set
10039 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
10040 Select (pceipoTS)
10041 *- insert into #implodeSLN
10042 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10043 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
10044 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
10045 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
10046 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
10047 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
10048 *=== 1041704
10049 EndIf
10050 EndIf && Process Detail
10051
10052 Select tmpCurs
10053 if Eof()
10054 Exit
10055 EndIf
10056
10057 lnFKey = FKey
10058 cCustomer = Customer
10059 Select (pceipoTD)
10060 =Seek(lnFKey, pceipoTD, "PKey")
10061
10062 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
10063
10064 llImplodeOK = llProcess
10065
10066 If llImplodeOK
10067 store 0 to laBuckets
10068 lnPackTotal = 0
10069
10070 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
10071 Select (pceipoTS)
10072 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
10073
10074 cDivision = Division
10075 cStyle = Style
10076 lcColor_Code = Color_Code
10077 lcLbl_Code = Lbl_Code
10078 lcDimension = Dimension
10079 EndIf
10080
10081 Else && The same FKey
10082 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
10083 Select (pceipoTS)
10084 if Division # cDivision;
10085 or Style # cStyle
10086 *- 1041704 YIK 07/29/09
10087 *- Allow multicolor prepacks
10088 *-- or Color_Code # lcColor_Code;
10089 *-- or Lbl_Code # lcLbl_Code;
10090 *-- or Dimension # lcDimension
10091
10092 llImplodeOK = .F.
10093 ELSE
10094 *- insert into #implodeSLN
10095 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10096 v_SQLExec("insert into #ImplodeSLN values ('"+;
10097 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
10098 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
10099 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10100 *=== 1041704
10101 EndIf
10102 EndIf
10103 EndIf && FKey Changed
10104
10105 if llImplodeOK
10106 *-- (pceipoTS) is selected!
10107 laBuckets[SizeBucket] = Sln_Qty
10108 lnPackTotal = lnPackTotal + Sln_Qty
10109 EndIf
10110
10111 Select tmpCurs
10112 Skip
10113
10114 If This.lUserInterface
10115 lnRecNo = lnRecNo + 1
10116 This.AdvanceThermo(lnRecNo)
10117 Endif
10118 EndDo && Endscan
10119
10120 Select (pceipoTD)
10121 Set Order to (lcOldOrder)
10122 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
10123 *v_SQLExec("DROP table #ImplodeSLN ")
10124 EndIf && Have data to Implode
10125
10126 *--- TR 1036614 11-Jun-2009 Goutam
10127 *Use In tmpCurs
10128 *=== TR 1036614 11-Jun-2009 Goutam
10129
10130 If This.lUserInterface
10131 * Reset Thermometer
10132 This.ResetThermo()
10133 Endif
10134
10135 Select(lnOldSelect)
10136 Return llRetVal
10137 Endproc
10138 *=== TR 1035491 4-Nov-2008 Goutam
10139
10140*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
10141*!*
10142* TR 1037925 - As per Krishna/Shenba
10143* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
10144* This is getting moved in TR 1037925
10145
10146*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
10147*!* *===========================================================================================
10148*!* Function ResolveCustShipper
10149*!* Lparameters pceipoTH, pceipoCR
10150*!* LOCAL lnSelect, llRetVal
10151
10152*!* lnSelect = SELECT()
10153
10154*!* WITH This
10155*!*
10156*!* SELECT distinct h.customer, h.division, ;
10157*!* h.cust_shipper ;
10158*!* FROM (pceipoTH) h, (pceipoCR) r ;
10159*!* WHERE r.resv_cust_ship = 'Y' and ;
10160*!* h.customer = r.customer and ;
10161*!* h.division = r.division ;
10162*!* INTO CURSOR '_tmpCustShipper'
10163*!*
10164*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10165*!*
10166*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10167*!*
10168*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
10169*!* REPLACE ALL shipper WITH '' In (pceipoTH)
10170*!* SET RELATION TO
10171*!* ENDIF
10172*!*
10173*!* SELECT '_tmpCustShipper'
10174
10175*!* .cSQLTempTable = ""
10176*!*
10177*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10178*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10179*!* IF !EMPTY(.cSQLTempTable)
10180*!*
10181*!* *---- Matching with customer, cust_shipper, division
10182*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10183*!* "s.shipper " + ;
10184*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10185*!* "Where s.customer = t.customer and " + ;
10186*!* "s.division = t.division and " + ;
10187*!* "s.cust_shipper = t.cust_shipper "
10188*!*
10189*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10190*!*
10191*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10192*!* SELECT _custShipper
10193*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10194*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10195*!* IF llRetVal
10196*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10197*!* SET RELATION TO
10198*!* ENDIF
10199*!* ENDIF
10200*!* ENDIF
10201*!* ENDIF
10202*!* ENDIF
10203*!*
10204*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10205*!* FROM (pceipoTH) h, (pceipoCR) r ;
10206*!* WHERE r.resv_cust_ship = 'Y' and ;
10207*!* h.customer = r.customer and ;
10208*!* h.division = r.division and ;
10209*!* EMPTY(h.shipper) ;
10210*!* INTO CURSOR '_tmpCustShipper'
10211*!*
10212*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10213*!*
10214*!* SELECT '_tmpCustShipper'
10215
10216*!* .cSQLTempTable = ""
10217*!*
10218*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10219*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10220*!* IF !EMPTY(.cSQLTempTable)
10221*!*
10222*!* *---- Matching with customer, cust shipper, and division = ''
10223*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10224*!* "s.shipper " + ;
10225*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10226*!* "Where s.customer = t.customer and " + ;
10227*!* "s.division = '' and " + ;
10228*!* "s.cust_shipper = t.cust_shipper "
10229*!*
10230*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10231*!*
10232*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10233*!* SELECT _custShipper
10234*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10235*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10236*!*
10237*!* IF llRetVal
10238*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10239*!* SET RELATION TO
10240*!* ENDIF
10241*!*
10242*!* ENDIF
10243*!* ENDIF
10244*!* ENDIF
10245*!* ENDIF
10246
10247*!* USE in '_tmpCustShipper'
10248*!*
10249*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10250*!* FROM (pceipoTH) h, (pceipoCR) r ;
10251*!* WHERE r.resv_cust_ship = 'Y' and ;
10252*!* h.customer = r.customer and ;
10253*!* h.division = r.division and ;
10254*!* EMPTY(h.shipper) ;
10255*!* INTO CURSOR '_tmpCustShipper'
10256*!*
10257*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10258*!*
10259*!* IF RECCOUNT('_tmpCustShipper') > 0
10260*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10261*!*
10262*!* IF llRetVal
10263*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
10264*!* Errs_flg_h WITH "Y" ;
10265*!* FOR customer = _tmpCustShipper.customer and ;
10266*!* division = _tmpCustShipper.division and ;
10267*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
10268*!*
10269*!* SET RELATION TO
10270*!* ENDIF
10271*!*
10272*!* ENDIF
10273*!*
10274*!* ENDWITH
10275*!*
10276*!* USE in '_tmpCustShipper'
10277*!* USE in '_custShipper'
10278*!* SELECT(lnSelect)
10279*!*
10280*!* RETURN llRetVal
10281*!* ENDFUNC
10282*!* *===========================================================================================
10283*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
10284*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
10285
10286*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
10287*============================================================
10288 FUNCTION CalculateSLNs
10289 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10290 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10291 lnTotal_qty
10292
10293 llRetVal = true
10294 lnSelect = SELECT()
10295
10296 lcCursor = GetUniqueFileName()
10297 WITH This
10298
10299 *--- TR 1047450 28-May-2010 Partha ---
10300 * removed c.Template = 'GAP'
10301 * from where clause of following qry
10302
10303*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10304*!* " FROM (pceipoTD) d " + ;
10305*!* " JOIN (pceipoTH) H " + ;
10306*!* " ON H.pkey = d.fkey " + ;
10307*!* " JOIN (pceipoCR) C " + ;
10308*!* " ON D.division = C.Division " + ;
10309*!* " AND H.Customer = C.Customer " + ;
10310*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
10311
10312 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10313 " FROM (pceipoTD) d " + ;
10314 " JOIN (pceipoTH) H " + ;
10315 " ON H.pkey = d.fkey " + ;
10316 " JOIN (pceipoCR) C " + ;
10317 " ON D.division = C.Division " + ;
10318 " AND H.Customer = C.Customer " + ;
10319 " WHERE NOT (d.Gap_ok = 'Y') "
10320 *=== TR 1047450 28-May-2010 Partha ===
10321
10322 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10323
10324 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10325 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10326 lcDeatil = .cSQLTempTable
10327
10328 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10329 " FROM " + lcDeatil + " t " + ;
10330 " JOIN zzxscolr s " + ;
10331 " ON s.division= t.division and " +;
10332 " s.style= t.style and s.color_code= t.color_code and " +;
10333 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10334 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10335 " LEFT OUTER JOIN zzxppakh ph " + ;
10336 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10337 " s.dimension= ph.ppk_code " + ;
10338 " Where s.ppack_ok= 'Y' "
10339
10340 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10341
10342 IF llRetVal
10343 *--- TR 1038394 YIK 01/29/09
10344 *- Select(lcCursor)
10345 *--INDEX on Pkey TAG Pkey
10346 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10347 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10348
10349 lnPrePack = 0
10350 SELECT(lcCursor)
10351 SCAN
10352 lnPkey = Pkey
10353 lnpack_qty = pack_qty
10354
10355 lnTotal_qty = &pceipoTD..Total_qty
10356
10357 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10358 lcErrs_Msg = " Can not Calculate number of prepacks. "
10359
10360 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10361 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10362 Errs_Flg_D With "Y" ;
10363 IN (pceipoTD)
10364 LOOP
10365 ELSE
10366 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10367 IF lnpack_qty >0
10368 lnTotal_qty = lnTotal_qty /lnpack_qty
10369 ENDIF
10370 ENDIF
10371 Endif
10372
10373 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10374 lnPrePack = (lnTotal_qty/lnpack_qty)
10375 SELECT(pceipoTS)
10376 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10377
10378 IF lnSlnqty >0
10379 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10380 SELECT(pceipoTS)
10381 SCAN FOR Fkey = lnPkey
10382 IF MOD(sln_qty,lnPrePack) >0
10383 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10384 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10385 Errs_Flg_S With "Y"
10386 ENDIF
10387 ENDSCAN
10388 LOOP
10389 ELSE
10390 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10391*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10392 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10393 ENDIF
10394
10395 ENDIF
10396 ENDSCAN
10397
10398 ENDIF
10399 ENDIF
10400 .TableClose(lcCursor)
10401 ENDWITH
10402
10403 SELECT (lnSelect)
10404 RETURN llRetVal
10405 ENDFUNC
10406*============================================================
10407
10408*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10409
10410
10411*--- TR 1036917 04-Feb-2009 Partha ---
10412
10413*============================================================
10414 FUNCTION ChangeColor
10415 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10416 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10417 lnTotal_qty
10418
10419 llRetVal = true
10420 lnSelect = SELECT()
10421
10422 WITH This
10423 *--- TR 1039262 NSD - Use current system date, not PO date.
10424 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10425 If This.oHostProcess.lHaveSLN
10426 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.
10427 " 'D' AS Source " + ;
10428 " FROM (pceipoTD) d " + ;
10429 " JOIN (pceipoTH) H " + ;
10430 " ON H.pkey = d.fkey " + ;
10431 " WHERE d.Errs_flg_d <> 'Y' " + ;
10432 " AND d.org_color = ' ' " +;
10433 " UNION ALL " + ;
10434 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10435 " 'S' AS Source " + ;
10436 " FROM (pceipoTD) d " + ;
10437 " JOIN (pceipoTH) H " + ;
10438 " ON H.pkey = d.fkey " + ;
10439 " JOIN (pceipoTS) S " + ;
10440 " ON D.pkey = s.fkey " + ;
10441 " WHERE s.Errs_flg_s <> 'Y' " + ;
10442 " AND s.org_color = ' ' "
10443 ELSE
10444 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10445 " 'D' AS Source " + ;
10446 " FROM (pceipoTD) d " + ;
10447 " JOIN (pceipoTH) H " + ;
10448 " ON H.pkey = d.fkey " + ;
10449 " WHERE d.Errs_flg_d <> 'Y' " + ;
10450 " AND d.org_color = ' ' "
10451 ENDIF
10452
10453 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10454
10455 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10456 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10457 lcDeatil = .cSQLTempTable
10458 *--- 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)
10459 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10460 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10461 " FROM " + lcDeatil + " t " + ;
10462 " JOIN zzxrupch h " + ;
10463 " ON h.division= t.division " + ;
10464 " and h.style= t.style " + ;
10465 " and h.color_code= t.color_code " + ;
10466 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10467 " and h.dimension = t.dimension " + ;
10468 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10469 " WHERE h.active_ok = 'Y' " + ;
10470 " AND d.active_color = 'Y' " + ;
10471 " AND d.effect_Date = " + ;
10472 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10473 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10474 " ORDER BY d1.effect_date DESC ) "
10475
10476 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10477
10478 IF llRetVal
10479 Select("__RollingUpc")
10480 INDEX on Pkey TAG Pkey
10481 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10482
10483 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10484 org_Color WITH __RollingUpc.TempColr ;
10485 FOR NOT EOF("__RollingUpc") ;
10486 AND __RollingUpc.Source = "D" IN (pceipoTD)
10487
10488 Set Relation To
10489
10490 If This.oHostProcess.lHaveSLN
10491 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10492 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10493 org_Color WITH __RollingUpc.TempColr ;
10494 FOR NOT EOF("__RollingUpc") ;
10495 AND __RollingUpc.Source = "S" IN (pceipoTS)
10496 Set Relation To
10497 ENDIF
10498
10499 ENDIF
10500
10501 .TableClose("__RollingUpc")
10502
10503 ENDIF
10504 ENDWITH
10505
10506 SELECT (lnSelect)
10507 RETURN true
10508 ENDFUNC
10509*============================================================
10510
10511*=== TR 1036917 04-Feb-2009 Partha ===
10512
10513**************************************************************************************
10514
10515 * --- TR 1034963 12/15/08 CM
10516 * This procedure will write back to sysnotes exploded components of Range Styles
10517
10518 Procedure UpdateSysNotes
10519
10520 Local laTables[1]
10521 laTables[1] = "Vzzeipotd_notes_iPOproc"
10522
10523 Local llRetVal, llBeganTransaction
10524
10525 llRetVal = .T.
10526
10527 If This.BeginTransaction()
10528 llRetVal = This.Tableupdate(@laTables)
10529 If llRetVal
10530 This.EndTransaction()
10531 Else
10532 This.RollbackTransaction()
10533 Endif
10534 Endif
10535
10536 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10537
10538 Endproc
10539 * --- TR 1034963 12/15/08 CM
10540
10541**************************************************************************************
10542
10543 *--------------------------------------------------
10544 *--- TR 1041542 NSD 7/22/09
10545 * Register Number can be assigned by a sort now.
10546 PROCEDURE ResolveRegisterNumber
10547 LPARAMETERS pceipoTH
10548
10549 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10550 llRetVal = .T.
10551 lnSelect = SELECT()
10552
10553 WITH THIS
10554
10555 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10556 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10557 lcColList = "pkey,customer,reg_num"
10558 SELECT tcAllCols
10559 SCAN
10560 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10561 ENDSCAN
10562
10563 * Retrieve just the columns we need
10564 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10565 &lcSQL
10566
10567 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10568 * Push records to server to work with.
10569 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10570 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10571 lcAllTmp = .cSQLTempTable
10572
10573 * Find distinct customer
10574 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10575 SELECT tcRegNum_cust
10576 SCAN
10577 * Process 1 customer
10578
10579 * Get the grouping
10580 lcCustTmp = "#" + GetUniqueFileName()
10581 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10582 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10583 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10584 IF llRetVal
10585 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10586 lcGrouping = "CUSTOMER,PO_NUM"
10587 ELSE
10588 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10589 ENDIF
10590
10591 * Need to have a SQL Filter for the groupings
10592 STRINGTOARRAY(lcGrouping,@laGroupFields)
10593 lcGroupFieldsFilter = ""
10594 FOR x = 1 TO ALEN(laGroupFields,1)
10595 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10596 ENDFOR
10597 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10598
10599 * Create temp table of unique reg nums
10600 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10601 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10602 " GROUP BY " + lcGrouping
10603 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10604
10605 * Count distinct records and generate enough reg_nums
10606 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10607 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10608
10609 * Calculate New reg_nums
10610 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10611
10612 * Write back to table
10613 llRetVal = llRetVal AND v_sqlexec(;
10614 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10615 lcGroupFieldsFilter )
10616
10617 ENDIF
10618
10619 USE IN SELECT("tcRegNum_Sort")
10620 USE IN SELECT("tcRegNum_cnt")
10621 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10622 ENDSCAN
10623
10624 * Get all records back from Temp table. Loop through and apply to main cursor
10625 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10626 IF llRetVal
10627 SELECT tcRegNum_res
10628 SCAN
10629 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10630 SELECT (pceipoTH)
10631 REPLACE reg_num WITH tcRegNum_res.reg_num
10632 ENDIF
10633 ENDSCAN
10634
10635 ENDIF
10636
10637 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10638 ENDIF
10639
10640
10641 USE IN SELECT("tcRegNum_res")
10642 USE IN SELECT("tcAllCols")
10643 USE IN SELECT("tcRegNum_All")
10644 USE IN SELECT("tcRegNum_cust")
10645
10646 ENDWITH
10647
10648 SELECT(lnSelect)
10649 RETURN llRetVal
10650 ENDPROC
10651 *=== TR 1041542 NSD 7/22/09
10652
10653*===============================================================
10654
10655 *--- TR 1036614 8-Jun-2009 Goutam
10656 Procedure CreateSingleSLNCursor
10657 Lparameters pcTmpCursor
10658
10659 Local llRetVal, lnOldSelect, lcSQLString
10660
10661 llRetVal = true
10662 lnOldSelect = Select()
10663
10664 *---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.
10665
10666 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10667
10668 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10669*!* select t.Customer ;
10670*!* , t.FKey ;
10671*!* , t.PKey ;
10672*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10673*!* , c.template ; && TR 1050793
10674*!* , c.slntodtl ; && TR 1050793
10675*!* from (pcTmpCursor) t ;
10676*!* join zzeipocr c ;
10677*!* on c.division = t.division ;
10678*!* and c.customer = t.customer ;
10679*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10680*!* on s.division = t.division ;
10681*!* and s.customer = t.customer ;
10682*!* and s.store = t.store ;
10683*!* where c.slntodtl = 'N' ;
10684*!* and (c.stylefromsln = 'O' ;
10685*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10686*!* into Cursor __tmpipots ;
10687*!* order by t.fkey, t.Customer, t.PKey
10688
10689 select t.Customer ;
10690 , t.FKey ;
10691 , t.PKey ;
10692 , NVL(s.price_flg, c.price_flg) as price_flg ;
10693 , c.template ; && TR 1050793
10694 , c.slntodtl ; && TR 1050793
10695 from (pcTmpCursor) t ;
10696 join zzeipocr c ;
10697 on c.division = t.division ;
10698 and c.customer = t.customer ;
10699 left join (this.oHostProcess.cCustomerStoreTable) s ;
10700 on s.division = t.division ;
10701 and s.customer = t.customer ;
10702 and s.store = t.store ;
10703 where c.slntodtl = 'N' ;
10704 and (c.stylefromsln = 'O' ;
10705 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10706 JOIN zzeipocr c ;
10707 on c.division = t.division ;
10708 and c.customer = t.customer ;
10709 group by t.fkey having (count(t.pkey)=1) and ;
10710 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10711 into Cursor __tmpipots ;
10712 order by t.fkey, t.Customer, t.PKey
10713 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10714
10715 Select(lnOldSelect)
10716 Return llRetVal
10717 Endproc
10718 *=== TR 1036614 8-Jun-2009 Goutam
10719
10720 *--- TR 1036614 8-Jun-2009 Goutam
10721 *--- This is the splited function from MoveSLNToDTLs
10722 PROCEDURE CreateCursorSLNToDtl
10723 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10724
10725 LOCAL llRetVal, lnOldSelect
10726 lnOldSelect = SELECT()
10727 llRetVal = true
10728
10729 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10730*!* select t.Customer ;
10731*!* , t.FKey ;
10732*!* , t.PKey ;
10733*!* , c.price_flg ;
10734*!* from (pcTmpCursor) t ;
10735*!* join zzeipocr c ;
10736*!* on c.division = t.division ;
10737*!* and c.customer = t.customer ;
10738*!* join (pceipoTD) d ;
10739*!* on d.pkey = t.dtlPkey ;
10740*!* where c.slntodtl = 'Y' ;
10741*!* and d.slntodtl <> 'Y' ;
10742*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10743*!* into Cursor __tmpipots ;
10744*!* order by t.fkey, t.Customer, t.PKey
10745
10746 *--- TR 1045922 05-MAR-2010 HNISAR
10747 * Added 'I' to Inlis in below statements
10748*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10749*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10750 *=== TR 1045922 05-MAR-2010 HNISAR
10751
10752 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10753 select t.Customer ;
10754 , t.FKey ;
10755 , t.PKey ;
10756 , NVL(s.price_flg, c.price_flg) as price_flg ;
10757 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10758 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
10759 from (pcTmpCursor) t ;
10760 join zzeipocr c ;
10761 on c.division = t.division ;
10762 and c.customer = t.customer ;
10763 left join (this.oHostProcess.cCustomerStoreTable) s ;
10764 on s.division = t.division ;
10765 and s.customer = t.customer ;
10766 and s.store = t.store ;
10767 join (pceipoTD) d ;
10768 on d.pkey = t.dtlPkey ;
10769 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
10770 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10771 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10772 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
10773 into Cursor __tmpipots ;
10774 order by t.fkey, t.Customer, t.PKey
10775 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
10776
10777 SELECT(lnOldSelect)
10778 RETURN llRetVal
10779
10780 ENDPROC
10781
10782 Procedure ResolveSingleSLNDetail
10783 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
10784
10785 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
10786
10787 llRetVal = true
10788 lnOldSelect = Select()
10789
10790 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10791 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
10792 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10793 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10794
10795 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10796*!* select t.Customer ;
10797*!* , t.FKey ;
10798*!* , t.PKey ;
10799*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10800*!* , t.ppk_code ;
10801*!* from (pcTmpCursor) t ;
10802*!* join zzeipocr c ;
10803*!* on c.division = t.division ;
10804*!* and c.customer = t.customer ;
10805*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10806*!* on s.division = t.division ;
10807*!* and s.customer = t.customer ;
10808*!* and s.store = t.store ;
10809*!* where c.slntodtl = 'N' ;
10810*!* AND ((c.stylefromsln in ('Y','O') ;
10811*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10812*!* into Cursor __tmpipots ;
10813*!* order by t.fkey, t.Customer, t.PKey
10814
10815 select t.Customer ;
10816 , t.FKey ;
10817 , t.PKey ;
10818 , NVL(s.price_flg, c.price_flg) as price_flg ;
10819 , t.ppk_code ;
10820 from (pcTmpCursor) t ;
10821 join zzeipocr c ;
10822 on c.division = t.division ;
10823 and c.customer = t.customer ;
10824 left join (this.oHostProcess.cCustomerStoreTable) s ;
10825 on s.division = t.division ;
10826 and s.customer = t.customer ;
10827 and s.store = t.store ;
10828 where c.slntodtl = 'N' ;
10829 AND ((c.stylefromsln in ('Y','O') ;
10830 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10831 JOIN zzeipocr c ;
10832 on c.division = t.division ;
10833 and c.customer = t.customer ;
10834 group by t.fkey having (count(t.pkey)=1) and ;
10835 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10836 into Cursor __tmpipots ;
10837 order by t.fkey, t.Customer, t.PKey
10838 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10839
10840 SELECT __tmpipots
10841 SCAN
10842 lnFKey = Fkey
10843
10844 Select (pceipoTS)
10845 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
10846
10847 lcDivision = Division
10848 lcStyle = Style
10849 lcColor_Code = Color_Code
10850 lcLbl_Code = Lbl_Code
10851 lcDimension = __tmpipots.PPK_Code
10852 lcSize_Desc = Size_Desc
10853
10854 select (pceipoTD)
10855 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
10856
10857 replace Division with lcDivision, ;
10858 Style with lcStyle, ;
10859 Color_Code with lcColor_Code, ;
10860 Lbl_Code with lcLbl_Code, ;
10861 Dimension with lcDimension,;
10862 SizeBucket with 1;
10863 Size_Desc with lcSize_Desc;
10864 Style_SLN_OK with 'Y' ;
10865 IN (pceipoTD)
10866 ENDIF
10867 ENDIF
10868 ENDSCAN
10869
10870 IF USED("__tmpipots")
10871 USE IN __tmpipots
10872 ENDIF
10873
10874 Select(lnOldSelect)
10875 Return llRetVal
10876 Endproc
10877
10878 *=== TR 1036614 8-Jun-2009 Goutam
10879
10880 *- 1044723 05/20/10 YIK
10881 *- Moved this method from postvalidation()
10882 PROCEDURE ResolveNewStoreOrd_type
10883 LPARAMETERS pcEipoTH
10884 LOCAL llRetVal, lnOldSelect
10885 llRetVal = .t.
10886 lnOldSelect = SELECT()
10887 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
10888 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
10889
10890 LOCAL lcSql, lcEipoTh, lcSQLTempTable
10891 lcEipoTh = SYS(2015)
10892 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
10893
10894 IF RECCOUNT(lcEipoTh) = 0
10895 USE IN (lcEipoTh)
10896 SELECT(lnOldSelect)
10897 RETURN llRetVal
10898 ENDIF
10899
10900 LOCAL lcOrd_typeResult
10901 lcOrd_typeResult = SYS(2015)
10902 WITH this
10903 .cSQLTempTable=""
10904 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
10905 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
10906 lcSQLTempTable = .cSQLTempTable
10907
10908 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
10909 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
10910 " inner join zzotyper r on r.ns_ord_type = 'Y'"
10911 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
10912 IF llRetVal
10913 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
10914 ENDIF
10915 ENDWITH
10916
10917 IF USED(lcEipoTh)
10918 USE IN (lcEipoTh)
10919 ENDIF
10920 IF USED(lcOrd_typeResult)
10921 USE IN (lcOrd_typeResult)
10922 ENDIF
10923
10924 Select(lnOldSelect)
10925 Return llRetVal
10926 Endproc
10927 *=== TR 1035678 NH
10928
10929 *--- TR 1049029 24-Aug-2010 Partha ---
10930 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
10931 FUNCTION GetTotSLNQty
10932 LPARAMETERS tnPSFkey, pceipoTS
10933
10934 LOCAL lnTotSlnQty, lnOldSelect
10935 LOCAL ARRAY laTotSlnQty[1]
10936
10937 lnOldSelect = SELECT()
10938 lnTotSlnQty = 0
10939
10940 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
10941 lnTotSlnQty = laTotSlnQty[1]
10942
10943 Select(lnOldSelect)
10944 Return lnTotSlnQty
10945 ENDFUNC
10946
10947 *=== TR 1049029 24-Aug-2010 Partha ===
10948
10949 *--- TechRec 1048792 17-Dec-2010 jisingh ---
10950 FUNCTION ClearSkus
10951 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
10952 LOCAL llRetVal, lnSelect, lcSqlString
10953
10954 llRetVal = true
10955 lnSelect = SELECT()
10956
10957 *-- Populate new flag from Control in Transaction Maintenance
10958 lcSqlString = " UPDATE h SET " + ;
10959 " ReResvStyle = c.ReResvStyle " + ;
10960 " FROM (pcEipoTH) h " + ;
10961 " JOIN (pcEipoCR) c " + ;
10962 " ON h.division = c.division " + ;
10963 " AND h.customer = c.customer " + ;
10964 " WHERE h.ReResvStyle = '' "
10965
10966 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10967
10968 *-- Make SKUs blank in Transaction Maintenance detail
10969 lcSqlString = " UPDATE d SET " + ;
10970 " Style = '', " + ;
10971 " Color_Code = '', " + ;
10972 " Lbl_Code = '', " + ;
10973 " Dimension = '', " + ;
10974 " SizeBucket = 0, " + ;
10975 " Size_Desc = '' " + ;
10976 " FROM (pcEipoTD) d " + ;
10977 " JOIN (pcEipoTH) h " + ;
10978 " ON h.pkey = d.fkey " + ;
10979 " WHERE h.ReResvStyle = 'Y' " + ;
10980 " AND (d.upc > '' OR d.sku > '') "
10981
10982 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10983
10984 *-- Make SKUs blank in SLN
10985 lcSqlString = " UPDATE s SET " + ;
10986 " Style = '', " + ;
10987 " Color_Code = '', " + ;
10988 " Lbl_Code = '', " + ;
10989 " Dimension = '', " + ;
10990 " SizeBucket = 0, " + ;
10991 " Size_Desc = '' " + ;
10992 " FROM (pcEipoTD) d " + ;
10993 " JOIN (pcEipoTH) h " + ;
10994 " ON h.pkey = d.fkey " + ;
10995 " JOIN (pcEipoTS) s " + ;
10996 " ON s.fkey = d.pkey " + ;
10997 " WHERE h.ReResvStyle = 'Y' " + ;
10998 " AND (s.sln_upc > '' OR s.sln_sku > '') "
10999
11000 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
11001
11002 SELECT (lnSelect)
11003 RETURN llRetVal
11004 ENDFUNC
11005 *=== TechRec 1048792 17-Dec-2010 jisingh ===
11006
11007 *--- TR 1053820 25-May-2011 Goutam
11008 Function GenerateCustomerSKU_Style_ColorSize
11009 Lparameters pceipoTH,pceipoTD
11010
11011 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
11012 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
11013
11014 llRetVal = True
11015 lnSelect = Select()
11016 With This
11017
11018 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
11019
11020 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
11021
11022 *** Size_BK needs to be 00 and NOT 0
11023 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
11024 Select ;
11025 h.customer,;
11026 d.division,;
11027 d.pkey As dtlpkey ,;
11028 d.Style As Style, ;
11029 d.color_code,;
11030 d.lbl_code,;
11031 d.Dimension,;
11032 h.Store As cust_store ,;
11033 d.price As cust_price , ;
11034 d.size_desc, ;
11035 d.sizebucket as size_bk, ;
11036 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
11037 d.aux_sku ;
11038 from (pceipoTH) h ;
11039 join (pceipoTD) d ;
11040 on d.fkey = h.pkey ;
11041 join zzeipocr c ;
11042 on c.division = d.division ;
11043 and c.customer = h.customer ;
11044 where c.GenCustSKU = 'Y' ;
11045 and d.sku = '' ;
11046 and h.Errs_flg_h < 'Y' ;
11047 and d.Errs_Flg_D < 'Y' ;
11048 into cursor tmpCurs ;
11049 order by 1,2,4,5,6,7, 11
11050 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
11051
11052 lnCount = Reccount("tmpCurs")
11053
11054 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
11055
11056 If lnCount = 0
11057 If Used("tmpCurs")
11058 Use In tmpCurs
11059 Endif
11060 Select (lnSelect)
11061 Return
11062 Endif
11063
11064 *- Index just in case somebody changes the SELECT above
11065 Select tmpCurs
11066 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
11067 TAG sku
11068
11069 .LogEntry("Load Customer Style.")
11070
11071 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
11072 If Used("tmpCurs")
11073 Use In tmpCurs
11074 Endif
11075 Select (lnSelect)
11076 Return
11077 Endif
11078
11079 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
11080 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
11081 lnCount = lnCount - 1
11082 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
11083 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
11084
11085 Select VZZXCSTHR
11086 Scatter Memvar Blank
11087 Select VZZXCSTDR
11088 Scatter Memvar Blank
11089
11090 m.Last_mod = Datetime()
11091 m.User_id = 'CGSADMIN'
11092 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
11093 m.notes = ''
11094
11095 *--- TR 1057011 7-10-2011 VKK
11096 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
11097 m.active_ok = 'Y'
11098 m.anti_theft = 'N'
11099 *=== TR 1057011 7-10-2011 VKK
11100
11101 lcPrevSKU = ' '
11102 lcPrevSkuSize = ''
11103
11104 *- inserted details counter
11105 Local lnInsertCount
11106 lnInsertCount = 0
11107
11108 Select tmpCurs
11109
11110 Scan
11111 .LogEntry("Loading Customer Style...")
11112 .LogEntry("Style :" + Style )
11113 .LogEntry("Color_code :" + color_code )
11114
11115 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
11116 .LogEntry("Invalid Style or Color_code or Size_bk " )
11117 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
11118 FOR pkey = dtlpkey In (pceipoTD)
11119 Loop
11120 Endif
11121
11122 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
11123 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
11124 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
11125
11126 *--- Client Soffe wants to display size description in dimension's place if it is empty
11127 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
11128 If lcPrevSKU # lcSku
11129 lcPrevSKU = lcSku
11130 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
11131 .LogEntry("Customer :" + m.customer )
11132 .LogEntry("Division : " + m.division)
11133 .LogEntry("Style :" + Style )
11134 .LogEntry("Color_code :" + m.color_code )
11135 .LogEntry("Label code :" + m.lbl_code )
11136 .LogEntry("dimension : " + m.dimension)
11137 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
11138 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))
11139 If Empty(lnHDRpKey)
11140 lnHDRpKey = lnCstHrPkey
11141 .LogEntry("Inserting into header..")
11142 Insert Into VZZXCSTHR From Memvar
11143 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
11144 In VZZXCSTHR
11145 Endif
11146 Endif
11147 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
11148 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
11149 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
11150 *- 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)
11151 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
11152 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)
11153
11154 If Empty(lnDtlKey)
11155 lnDtlpKey = lnCstDrPkey
11156 .LogEntry("Inserting into detail..")
11157 Insert Into VZZXCSTDR From Memvar
11158 *- TR 1071542 FH- need to add replace for dimension here as well
11159 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
11160 lnInsertCount = lnInsertCount + 1
11161 Endif
11162 Endif
11163 lnCstDrPkey = lnCstDrPkey +1
11164 lnCstHrPkey = lnCstHrPkey +1
11165
11166 Endscan
11167
11168 Dimension laTables[2]
11169 laTables[1]= "VZZXCSTHR"
11170 laTables[2]= "VZZXCSTDR"
11171
11172 llBeganTransaction = .BeginTransaction()
11173 llRetVal = .Tableupdate(@laTables)
11174
11175 If llRetVal
11176 If llBeganTransaction
11177 This.EndTransaction()
11178 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
11179 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
11180 Endif
11181 Else
11182 If llBeganTransaction
11183 This.RollbackTransaction()
11184 .LogEntry("Table Update failed - Roll back Transaction " )
11185 Endif
11186 Endif
11187
11188 Endwith
11189
11190 If Used("tmpCurs")
11191 Use In tmpCurs
11192 Endif
11193
11194 Select (lnSelect)
11195 Return llRetVal
11196 Endfunc
11197
11198 *=== TR 1053820 25-May-2011 Goutam
11199
11200*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
11201 *============================================================
11202 Procedure RangePConversion
11203 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
11204 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
11205 llRetVal = .T.
11206 lnOldSelect = Select()
11207
11208 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11209
11210 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11211 * 1st Getting all range headers
11212 *- process all.
11213 *- Exclude range style P from the consideration
11214 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
11215 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
11216
11217 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
11218 FROM (pcTransDetail) d ;
11219 JOIN (pceipoCR) c ON c.customer = d.customer ;
11220 AND c.division = d.division ;
11221 WHERE ((d.rng_type = 'P' OR ;
11222 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
11223 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
11224 )AND c.rngp_conv = 'R') ; && requires Range P conversion
11225 AND d.ppk_action $ 'QPBO' ;
11226 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
11227
11228 With This
11229 .cSQLTempTable=""
11230 If .GenerateSQLTempTable('__TmpCursor')
11231 If .PopulateSQLTempTable('__TmpCursor')
11232 If !Empty(.cSQLTempTable)
11233
11234 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
11235 " st.size_code " +;
11236 " FROM " + .cSQLTempTable + " t " +;
11237 " JOIN zzxscolr s " + ;
11238 " ON s.division = t.division " +;
11239 " AND s.style = t.style " + ;
11240 " AND s.color_code = t.color_code " + ;
11241 " AND s.lbl_code = t.lbl_code " + ;
11242 " AND s.dimension = t.dimension " + ;
11243 " INNER JOIN zzxstylr st " + ;
11244 " ON st.pkey = s.fkey " + ;
11245 " JOIN zzxrangh rh " + ;
11246 " ON rh.division = t.division " + ;
11247 " AND rh.rng_Style = t.style " + ;
11248 " AND rh.rng_color = t.color_Code " + ;
11249 " AND rh.rng_lbl = t.lbl_Code " + ;
11250 " AND rh.rng_pack = t.dimension "
11251
11252 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
11253
11254 If Used("_PPK_Qty")
11255 Select ("_PPK_Qty")
11256 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
11257 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
11258 "division+style+color_code+lbl_code+dimension")
11259 SELECT ("__TmpCursor")
11260
11261 If llRetVal
11262 .LogEntry("Validating Range style.")
11263 lcErrs_Msg = "No valid Range Style found"
11264 Select (pcTransDetail)
11265 SCAN FOR !EOF("_PPK_Qty")
11266
11267 If Empty(_PPK_Qty.pack_qty)
11268 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
11269 Errs_Flg_D With "Y" ;
11270 IN (pcTransDetail)
11271 Else
11272 Do Case
11273
11274 Case ppk_action = 'Q' && multiply qty
11275
11276 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11277 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11278 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
11279 In (pcTransDetail)
11280
11281 Case ppk_action = 'P' && divide price
11282
11283 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11284 org_price With org_price/_PPK_Qty.pack_qty, ;
11285 retail1 With retail1/_PPK_Qty.pack_qty, ;
11286 retail2 With retail2/_PPK_Qty.pack_qty, ;
11287 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
11288 In (pcTransDetail)
11289
11290 *- Range style price will be populated later from a_price..e_price
11291 *- not from org_price. Need to updated these prices here.
11292 IF rng_type = 'R'
11293 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11294 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11295 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11296 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11297 e_price WITH e_price/_PPK_Qty.pack_qty ;
11298 In (pcTransDetail)
11299 ENDIF
11300
11301 Case ppk_action = 'B' OR ppk_action = 'O'
11302
11303 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11304 org_price With org_price/_PPK_Qty.pack_qty, ;
11305 retail1 With retail1/_PPK_Qty.pack_qty, ;
11306 retail2 With retail2/_PPK_Qty.pack_qty, ;
11307 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11308 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
11309 In (pcTransDetail)
11310
11311 IF rng_type = 'R'
11312 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11313 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11314 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11315 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11316 e_price WITH e_price/_PPK_Qty.pack_qty ;
11317 In (pcTransDetail)
11318 ENDIF
11319
11320 Otherwise
11321 Endcase
11322 Endif
11323 Endscan
11324 Endif
11325 Set Relation To
11326 Endif
11327 Endif
11328 Endif
11329 Endif
11330
11331 Endwith
11332
11333 If Used("__TmpCursor")
11334 Use In __TmpCursor
11335 Endif
11336
11337 If Used("_PPK_Qty")
11338 Use In _PPK_Qty
11339 Endif
11340
11341 If Used("__RangeP")
11342 Use In __RangeP
11343 Endif
11344
11345 Select(lnOldSelect)
11346 Return llRetVal
11347 *============================================================
11348 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11349
11350 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11351 PROCEDURE PopulateIs860
11352 LPARAMETERS pceipoTH, pceipoCR
11353 LOCAL llRetVal, lnSelect, lcUpdate
11354
11355 llRetVal = true
11356 lnSelect = SELECT()
11357
11358 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11359
11360 *--- TR 1070268 26-Jun-2013 Goutam
11361 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11362 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11363 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11364
11365 *--- TechRec 1088575 14-Jul-2015 TSV ===
11366*!* lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11367*!* " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11368*!* " 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')))"
11369
11370 * TR 1088961 KISHORE 31-JUL-2015 Added OR (th.po_purp='01' AND (cr.template = 'BELK 4030'))
11371 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11372 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11373 " 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')) " + ;
11374 " OR (th.po_purp='01' AND (cr.template = 'BELKS 4030')))"
11375 *=== TR 1070268 26-Jun-2013 Goutam
11376
11377 &lcUpdate
11378
11379 SELECT (lnSelect)
11380 RETURN llRetVal
11381 ENDPROC
11382
11383 *============================================================
11384
11385 PROCEDURE Create860TM
11386 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
11387 LPARAMETERS pceipoTH, pceipoTD
11388 *--- TechRec 1082601 15-Dec-2014 jisingh Added loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp ===
11389 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql, loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp
11390
11391 llRetVal = true
11392 lnSelect = SELECT()
11393 lcAlias = GetUniqueFileName()
11394 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11395 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11396 lcInsertDtl = BuildInsertString("zzeipctd", "voEiPctd")
11397 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11398
11399 WITH This
11400 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11401 *IF !EMPTY(lcInsert)
11402 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11403 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11404 ORDER By h.division, h.customer INTO CURSOR tcOrders
11405
11406 .cSQLTempTable = ""
11407 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11408 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11409 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11410
11411 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11412 " FROM zzoordrh rh " + ;
11413 " JOIN " + .cSQLTempTable + " t " + ;
11414 " ON t.customer = rh.customer " + ;
11415 " AND t.division = rh.division " + ;
11416 " AND t.po_num = rh.po_num " + ;
11417 " AND t.store = rh.store " + ;
11418 " WHERE t.is860 = 'Y' "
11419
11420 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11421
11422 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11423 SELECT tcOrders
11424 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11425 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11426 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11427 SELECT (lcAlias)
11428 SCATTER NAME voEiPcth MEMO
11429
11430 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11431 .vSqlExec("SELECT * FROM zzeipctd WHERE 1 = 2", lcAlias)
11432 SELECT (lcAlias)
11433 SCATTER NAME voEiPctd MEMO
11434 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11435
11436 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11437 SELECT tcCRPkey
11438 INDEX ON customer+division TAG cudiv
11439
11440 SELECT (pceipoTH)
11441 COUNT TO lnRecNo FOR Is860 = 'Y'
11442
11443 IF .lUserInterface
11444 .AdvanceThermo(lnRecNo)
11445 ENDIF
11446
11447 SELECT (pceipoTH)
11448 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11449 *SCAN FOR Is860 = 'Y'
11450 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11451 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11452 SCATTER NAME loEiPOth MEMO
11453
11454 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11455 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11456
11457 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11458
11459 IF RECCOUNT("__tcipcth") > 0
11460 REPLACE Is860 WITH 'X' IN (pceipoTH)
11461 USE IN SELECT("__tcipcth")
11462 LOOP
11463 ENDIF
11464
11465 *--- TechRec 1082601 08-Jan-2015 jisingh ---
11466 lcPocPurp = "01"
11467 SELECT (pceipoTD)
11468 IF SEEK(loEiPOth.pkey, pceipoTD, "fkey")
11469 SCAN WHILE fkey = loEiPOth.pkey
11470 IF !EMPTY(qual_860)
11471 lcPocPurp = "04"
11472 EXIT
11473 ENDIF
11474 ENDSCAN
11475 ENDIF
11476 SELECT (pceipoTH)
11477 *=== TechRec 1082601 08-Jan-2015 jisingh ===
11478
11479 WITH voEiPcth
11480 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11481 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11482 *--- TechRec 1082601 25-Dec-2014 jisingh ---
11483 *voEiPcth.poc_purp = "01"
11484 voEiPcth.poc_purp = lcPocPurp
11485 *=== TechRec 1082601 25-Dec-2014 jisingh ===
11486 voEiPcth.customer = loEiPOth.customer
11487 voEiPcth.division = loEiPOth.division
11488 voEiPcth.doc_num = loEiPOth.doc_num
11489 voEiPcth.edi_store = loEiPOth.edi_store
11490 voEiPcth.store = loEiPOth.store
11491 voEiPcth.isa_num = loEiPOth.isa_num
11492 voEiPcth.our_id = loEiPOth.our_id
11493 voEiPcth.our_qual = loEiPOth.our_qual
11494 voEiPcth.po_num = loEiPOth.po_num
11495 voEiPcth.vnd_id = loEiPOth.vnd_id
11496 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11497 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11498 voEiPcth.po_type = loEiPOth.po_type
11499 voEiPcth.vnd_key = loEiPOth.vnd_key
11500 ENDWITH
11501
11502 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11503
11504 REPLACE Is860 WITH 'X' IN (pceipoTH)
11505
11506 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11507 IF llRetVal AND !EMPTY(lcInsertDtl) AND voEiPcth.pkey > 0
11508 lnLineSeq = 1
11509
11510 SELECT (pceipoTD)
11511 SCAN FOR fkey = loEiPOth.pkey AND !EMPTY(qual_860)
11512 SCATTER NAME loEiPOtd MEMO
11513
11514 WITH voEiPctd
11515 voEiPctd.pkey = v_NextPkey("zzeipctd")
11516 voEiPctd.line_seq = lnLineSeq
11517 voEiPctd.fkey = voEiPcth.pkey
11518 voEiPctd.qualifier = loEiPOtd.qual_860
11519 voEiPctd.upc = loEiPOtd.upc
11520 voEiPctd.sku = loEiPOtd.sku
11521 voEiPctd.aux_sku = loEiPOtd.aux_sku
11522 voEiPctd.division = loEiPOtd.division
11523 voEiPctd.style = loEiPOtd.style
11524 voEiPctd.color_code = loEiPOtd.color_code
11525 voEiPctd.lbl_code = loEiPOtd.lbl_code
11526 voEiPctd.dimension = loEiPOtd.dimension
11527 voEiPctd.size_desc = loEiPOtd.size_desc
11528 voEiPctd.sizebucket = loEiPOtd.sizebucket
11529 voEiPctd.ean = loEiPOtd.ean
11530 voEiPctd.udfoordd1c = loEiPOtd.udfoordd1c
11531 voEiPctd.udfoordd2c = loEiPOtd.udfoordd2c
11532 voEiPctd.start_date = loEiPOtd.start_date
11533 voEiPctd.end_date = loEiPOtd.end_date
11534 voEiPctd.delv_code = loEiPOtd.delv_code
11535 voEiPctd.qty_change = loEiPOtd.total_qty
11536 voEiPctd.total_qty = loEiPOtd.total_qty
11537 voEiPctd.poc_cost = loEiPOtd.price
11538 voEiPctd.poc_price = loEiPOtd.retail1
11539 voEiPctd.poc_retail2 = loEiPOtd.retail2
11540 ENDWITH
11541
11542 llRetVal = llRetVal AND .vSqlExec(lcInsertDtl)
11543 lnLineSeq = lnLineSeq + 1
11544 ENDSCAN
11545 ENDIF
11546 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11547
11548 IF .lUserInterface
11549 lnRecNo = lnRecNo + 1
11550 .AdvanceThermo(lnRecNo)
11551 ENDIF
11552 USE IN SELECT("__tcipcth")
11553 ENDSCAN
11554 ENDIF
11555 .TableClose(lcAlias)
11556 .TableClose("tcCRPkey")
11557 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11558 .TableClose("tcOrders")
11559 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11560 ENDWITH
11561
11562 RELEASE voEiPcth
11563 SELECT (lnSelect)
11564 RETURN llRetVal
11565 ENDPROC
11566 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11567
11568 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11569 PROCEDURE ValidateLocation
11570 LPARAMETERS pcHeader
11571
11572 LOCAL llRetVal, lnOldSelect
11573
11574 llRetVal= true
11575 lnOldSelect= Select()
11576
11577 SELECT Distinct Location FROM (pcHeader) ;
11578 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11579
11580 SELECT __tmpLocation
11581 WITH This
11582 .cSQLTempTable=""
11583 IF .GenerateSQLTempTable('__tmpLocation')
11584 IF .PopulateSQLTempTable('__tmpLocation')
11585 IF !EMPTY(.cSQLTempTable)
11586 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11587 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11588 llRetVal = v_SqlExec(lcSQLString, "_Location")
11589 IF llRetVal
11590 SELECT _Location
11591 INDEX On Location TAG Location
11592 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11593 IF llRetVal
11594 SELECT (pcHeader)
11595 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11596 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11597 SET RELATION TO
11598 ENDIF
11599 ENDIF
11600 ENDIF
11601 ENDIF
11602 ENDIF
11603 ENDWITH
11604
11605 IF USED("__tmpLocation")
11606 USE IN __tmpLocation
11607 ENDIF
11608 IF USED("_Location")
11609 USE IN _Location
11610 ENDIF
11611
11612 Select(lnOldSelect)
11613 Return llRetVal
11614 ENDPROC
11615 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11616
11617 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11618 PROCEDURE GetFldsList
11619 LPARAMETERS lcpceipoTH, lczzeoprth
11620
11621 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11622
11623 lnOldSelect= Select()
11624
11625 *- get common fields from both aliases
11626 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11627
11628 *- get fields from source table to validate 850 filter bros
11629 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11630
11631 *- Retrieve all 850 filter bros
11632 lcSQLString = "Select OBJID from zzxsfxrf " +;
11633 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11634
11635 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11636
11637 SELECT _Filter
11638
11639 SCAN
11640 lcFld = UPPER(TRIM(objid))
11641 *- Check filter bros and add them in required fields list if valid
11642 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11643 lcFldsList = lcFldsList + ", " + lcFld
11644 ENDIF
11645 ENDSCAN
11646
11647 *- Adding additional fields used in 850 filter string and insert sql in calling method
11648 IF NOT "IS940I" $ UPPER(lcFldsList)
11649 lcFldsList = lcFldsList + ", IS940I"
11650 ENDIF
11651
11652 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11653 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11654 ENDIF
11655
11656 IF NOT "REQ_855" $ UPPER(lcFldsList)
11657 lcFldsList = lcFldsList + ", REQ_855"
11658 ENDIF
11659
11660 IF NOT "PROC_855" $ UPPER(lcFldsList)
11661 lcFldsList = lcFldsList + ", PROC_855"
11662 ENDIF
11663
11664 IF USED("_Filter")
11665 USE IN _Filter
11666 ENDIF
11667
11668 Select(lnOldSelect)
11669
11670 Return lcFldsList
11671
11672 ENDPROC
11673 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11674
11675 *============================================================
11676
11677 *--- TechRec 1082601 24-Dec-2014 jisingh ---
11678 PROCEDURE Validate860Qual
11679 LPARAMETERS pcHeader, pcDetail
11680 LOCAL llRetVal, lnSelect
11681
11682 lnSelect = SELECT()
11683 llRetVal = .SetRelation(pcHeader, "pkey", pcDetail, "fkey")
11684
11685 REPLACE ALL errs_msg_d WITH errs_msg_d + "Item has 860 change code (" + ALLTRIM(qual_860) + ")" + CRLF, ;
11686 errs_flg_d WITH "Y" FOR !EMPTY(qual_860) AND &pcHeader..po_purp = "05" IN (pcDetail)
11687 SET RELATION TO
11688
11689 SELECT (lnSelect)
11690 RETURN llRetVal
11691 ENDPROC
11692 *=== TechRec 1082601 24-Dec-2014 jisingh ===
11693
11694 *- TR 1089110 FH
11695 PROCEDURE ValidateZeroQty
11696 LPARAMETERS pceipoTD
11697
11698 LOCAL llRetVal, lnOldSelect
11699 lnOldSelect = SELECT()
11700 llRetVal = .t.
11701
11702 UPDATE td SET Errs_flg_d = 'Y', Errs_msg_d = Errs_msg_d + 'Item has 0 Quantity' + CRLF ;
11703 FROM (pceipoTD) td WHERE total_qty = 0
11704
11705 Select(lnOldSelect)
11706 Return llRetVal
11707 ENDPROC
11708 *- TR 1089110 FH
11709
11710*============================================================
11711 *--- TR 1090280 3-Oct-2015 Goutam
11712 FUNCTION ValidateImplosionType
11713 LPARAMETERS tceipoTH, tceipoTD, tceipoCR
11714 LOCAL llRetVal, lnSelect
11715
11716 llRetVal = true
11717 lnSelect = SELECT()
11718
11719 WITH This
11720
11721 llRetVal= llRetVal And .SetRelation(tceipoCR, "divcust", tceipoTH, "division + customer")
11722 IF llRetVal
11723 Replace Errs_msg_H With Errs_msg_H + "Empty implosion bulk for implosion flag B." +CRLF ,;
11724 Errs_flg_h With "Y" FOR &pceipoCR..impl_ok = 'B' AND EMPTY(impl_bulk) In (pceipoTH)
11725 Set Relation To
11726 ENDIF
11727
11728 llRetVal = llRetVal And .SetRelation(tceipoTH, "pkey", tceipoTD, "fkey")
11729 IF llRetVal
11730 Replace Errs_msg_D With Errs_msg_D + "Empty implosion bulk in header for implosion flag B." +CRLF ,;
11731 Errs_flg_d With "Y" FOR 'Empty implosion bulk for implosion flag B' $ &tceipoTH..Errs_msg_H In (pceipoTD)
11732 Set Relation To
11733 ENDIF
11734
11735 ENDWITH
11736
11737 SELECT (lnSelect)
11738 RETURN llRetVal
11739 ENDFUNC
11740 *=== TR 1090280 3-Oct-2015 Goutam
11741
11742 *--- TR 1098918 26-Sep-2016 HGORE ---
11743 PROCEDURE UpdateReq_855ForAllocation
11744 LPARAMETERS pcHeader
11745
11746 LOCAL llRetVal, lnOldSelect
11747
11748 llRetVal= true
11749 lnOldSelect= Select()
11750
11751 SELECT DISTINCT Customer, Division FROM (pcHeader) ;
11752 WHERE NOT EMPTY(Customer) AND NOT EMPTY(Division) INTO CURSOR __tmpCustDivn
11753
11754 SELECT __tmpCustDivn
11755 WITH This
11756 .cSQLTempTable=""
11757 IF .GenerateSQLTempTable('__tmpCustDivn')
11758 IF .PopulateSQLTempTable('__tmpCustDivn')
11759 IF !EMPTY(.cSQLTempTable)
11760 lcSQLString= "SELECT c.Customer, c.Division FROM zzeoprcr c, " + .cSQLTempTable + " t " +;
11761 "WHERE c.Customer = t.Customer AND c.Division = t.Division "+;
11762 " AND c.Use_Allocation = 'Y' "
11763 llRetVal = v_SqlExec(lcSQLString, "_CustDivn")
11764 IF llRetVal
11765 SELECT _CustDivn
11766 INDEX On Customer + Division TAG CustDivn
11767 llRetVal= .SetRelation("_CustDivn", "CustDivn", pcHeader, "Customer+Division")
11768 IF llRetVal
11769 SELECT (pcHeader)
11770 REPLACE req_855 WITH 'A' FOR req_855 = 'R' AND customer = _CustDivn.Customer AND Division = _CustDivn.Division
11771 SET RELATION TO
11772 ENDIF
11773 ENDIF
11774 ENDIF
11775 ENDIF
11776 ENDIF
11777 ENDWITH
11778
11779 .TableClose("__tmpCustDivn")
11780 .TableClose("_CustDivn")
11781
11782 Select(lnOldSelect)
11783 Return llRetVal
11784
11785 ENDPROC
11786 *
11787 *--------------------------------------------------------------
11788 * 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.
11789 PROCEDURE ResetReq_855
11790 LPARAMETERS pcHeader
11791
11792 LOCAL llRetVal, lnOldSelect
11793
11794 llRetVal= true
11795 lnOldSelect= Select()
11796
11797 SELECT (pcHeader)
11798 REPLACE req_855 WITH 'R' FOR req_855 = 'A' IN (pcHeader)
11799
11800 Select(lnOldSelect)
11801 Return llRetVal
11802
11803 ENDPROC
11804 *=== TR 1098918 26-Sep-2016 HGORE ===
11805 *
11806*============================================================
11807
11808 *- 1111325 FH
11809 *- I have 3 scenarios here, either control_pkey is populated from FindCustomerUsingTradingPartnerID (great),
11810 *- or it wasn't able to find it, or customer is passed on flat file.
11811 *- If customer is passed on flat file, see if it exists in zzeipocr_expl, if it does just take top 1 pkey as control_pkey
11812 *- Error out all records that have control_pkey = 0. This will prevent 850 from processing base on control_pkey = 0
11813 FUNCTION ResolveControlPkey
11814 LPARAMETERS pceipoTH
11815 LOCAL llRetVal, lnSelect, lcCust, lcSql, lnControlPkey, lcErrs_Msg
11816
11817 llRetVal = .T.
11818 lnSelect = SELECT()
11819
11820 WITH This
11821 SELECT h.pkey ,h.control_pkey, h.customer FROM (pceipoTH) h WHERE h.control_pkey = 0 AND !EMPTY(h.customer) INTO CURSOR tmpCurs
11822 Select tmpCurs
11823
11824 SCAN
11825 lcCust = customer
11826 lcSql = "select top 1 pkey from zzeipocr_expl where customer = '" + lcCust + "'"
11827 llRetVal = llRetVal And v_SqlExec(lcSql, "_tmpCust")
11828 IF RECCOUNT("_tmpCust") <> 0
11829 lnControlPkey = _tmpCust.pkey
11830 SELECT tmpCurs
11831 IF SEEK(pkey, (pceipoth), "pkey")
11832 replace control_pkey WITH lnControlPkey IN (pceipoTH)
11833 ENDIF
11834 ENDIF
11835 SELECT tmpCurs
11836 ENDSCAN
11837
11838 SELECT (pceipoTH)
11839 lcErrs_Msg = "Control pkey is 0, 850 Can not find matching 850 control base on trading partner." + CRLF
11840 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg, Errs_flg_H With "Y" For control_pkey = 0 In (pcEiPOth)
11841
11842 ENDWITH
11843
11844 SELECT (lnSelect)
11845 RETURN llRetVal
11846 ENDFUNC
11847
11848*============================================================
11849*--- TR 1101199 6-Feb-2017 Goutam
11850 FUNCTION PopulateControlpkey
11851 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
11852 LOCAL llRetVal, lnSelect
11853
11854 llRetVal = true
11855 lnSelect = SELECT()
11856
11857 WITH This
11858*--- TR 1110158 03-Jan-2018 Akmishra- cust_group replaced with customer
11859 .LogEntry("Resolving header division based on customer group.")
11860
11861 SELECT DISTINCT d.fkey, d.division, c.division AS ctrl_division, c.pkey as control_pkey, h.customer, ;
11862 IIF(c.validate_division = "Y" OR This.lValidateDivision, "Y", "N") AS validate_division ;
11863 FROM (pceipoTH) h ;
11864 JOIN (pceipoTD) d ON d.fkey = h.pkey ;
11865 JOIN (pceipoCR) c ON c.customer = h.customer ;
11866 ORDER BY d.fkey, c.customer, c.division ;
11867 WHERE !EMPTY(d.division) AND !EMPTY(h.customer) INTO CURSOR tmpCurs
11868
11869 Select tmpCurs
11870 If This.lUserInterface
11871 * Init Thermometer
11872 This.InitThermo(Reccount('tmpCurs'))
11873 l_nThermoCnt = 0
11874 ENDIF
11875
11876 Scan
11877 If This.lUserInterface
11878 * Advance progress bar, if we're using one.
11879 l_nThermoCnt = l_nThermoCnt + 1
11880 This.AdvanceThermo(l_nThermoCnt)
11881 Endif
11882 Select (pceipoTH)
11883
11884 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
11885
11886 SELECT tmpCurs
11887 lnFkey = fkey
11888 lccust_group = customer
11889 LOCATE FOR ctrl_division = division WHILE fkey = lnFkey AND customer= lccust_group
11890 llDivfound = FOUND()
11891 IF !llDivfound
11892 skip-1
11893 ENDIF
11894 Select (pceipoTH)
11895
11896 IF !llDivfound AND tmpCurs.validate_division = "Y" AND tmpCurs.ctrl_division <> tmpCurs.division
11897 REPLACE errs_msg_h WITH errs_msg_h + ;
11898 "Mismatch between division(" + ALLTRIM(tmpCurs.ctrl_division) + ;
11899 ") and resolved UPC/SKU division(" + ALLTRIM(tmpCurs.division) + ")." + CRLF,;
11900 errs_flg_h WITH "Y" IN (pceipoTH)
11901 ELSE
11902 Replace division With tmpCurs.division, control_pkey WITH tmpCurs.control_pkey In (pceipoTH)
11903 ENDIF
11904
11905 IF llDivfound
11906 SELECT tmpCurs
11907 LOCATE FOR customer <> lccust_group WHILE fkey = lnFkey
11908 IF !FOUND()
11909 skip-1
11910 ENDIF
11911 ENDIF
11912 Endif
11913 Endscan
11914 Use In tmpCurs
11915*=== TR 1110158 03-Jan-2018 Akmishra
11916 ENDWITH
11917
11918 SELECT (lnSelect)
11919 RETURN llRetVal
11920 ENDFUNC
11921
11922 *=== TR 1101199 6-Feb-2017 Goutam
11923
11924*============================================================
11925
11926Enddefine