· 8 years ago · Jan 23, 2018, 10: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 *--------------------------------------------------------------------------
54
55 Procedure Init
56 Lparameters toHostProcess
57 LOCAL llRetVal
58 llRetVal = .t.
59 llRetVal = llRetVal and DODEFAULT(toHostProcess)
60
61 *--- TR 1052729 10-Mar-11 SK
62 This.oPopulateSqlTempTable = Null
63
64 *--- TR 1065271 27-Nov-2012 BNarayanan ---
65 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
66 *=== TR 1065271 27-Nov-2012 BNarayanan ===
67
68 this.GetImplodeSQL()
69
70 RETURN llRetVal
71 Endproc
72
73 *--------------------------------------------------------------------------
74
75 *-- [Main procedure]
76 Procedure PreValidation
77 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
78 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
79 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
80 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
81 Local llRetVal, lcSQLSelect, lcSQLOrder
82 llRetVal = .T.
83 PRIVATE vcLogName
84 vcLogName = this.cLogName
85 With This
86 .LogEntry("Resetting all error messages in transaction tables.")
87 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
88 vcLogName)
89 *--- TechRec 1005163 17-May-2004 GS ---
90 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
91 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
92 *=== TechRec 1005163 17-May-2004 GS ===
93
94 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
95 vcLogName)
96
97 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
98 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
99 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
100 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
101
102 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
103 vcLogName)
104 *--- TechRec 1005163 17-May-2004 GS ---
105 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
106 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
107 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
108 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
109 *=== TechRec 1005163 17-May-2004 GS ===
110 Endwith
111 Return llRetVal
112 Endproc
113
114 *--------------------------------------------------------------------------
115
116 * Clear all previous errors
117 Procedure ClearErrors
118 Lparameters pceipoTH, pceipoTD,;
119 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
120 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
121 Local llRetVal, lnOldSelect, laTables[2]
122 llRetVal = .T.
123 lnOldSelect = Select()
124 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
125 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
126 * we don't allow explosion happen again therefore cannot clearout division)
127 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
128 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
129 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
130 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
131 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
132 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
133 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
134 *=== 1010206 11/10/2005 Ilya.
135
136 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
137
138 *--- TR 1064141 3-Oct-2012 Goutam
139 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
140 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
141
142 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
143 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
144 *=== TR 1064141 3-Oct-2012 Goutam
145
146 *=== TR 1003801 - BD
147 *--- TechRec 1005163 17-May-2004 GS ---
148 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
149 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
150 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
151 *=== TechRec 1005163 17-May-2004 GS ===
152
153 *--- TechRec 1028745 05-Feb-2008 GSternik ---
154 If .oHostProcess.lHaveChrgs
155 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
156 Endif
157 *=== TechRec 1028745 05-Feb-2008 GSternik ===
158
159 *---TR 1008342 10-JAN-2005 RG
160 Replace All Pending_Flg With 'N' In (pceipoTH)
161 *===TR 1008342 10-JAN-2005 RG
162
163 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
164 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
165 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
166 IN (pceipoTH)
167 *=== TR 1073346 05-Sep-13 SK
168
169 *- 1041285 07/10/09 YIK
170 *- Populate force errors into error fields
171 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
172 FOR Errs_flg_fh = 'Y' ;
173 IN (pceipoTH)
174
175 *--- TR 1043191 23-Oct-2009 JK ---
176 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
177 *=== TR 1043191 23-Oct-2009 JK ===
178
179 Select(lnOldSelect)
180 Return llRetVal
181 Endproc
182
183 *--------------------------------------------------------------------------
184
185 ************************************************************************************
186 * Error check EDI headers
187 ************************************************************************************
188 Procedure CheckHeader
189 Lparameters pceipoTH, pceipoCR, pceipoTD
190 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
191
192 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
193 llRetVal = .T.
194 lnOldSelect = Select()
195 With This
196
197 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
198 *--- LOCAL MOD
199 *If llRetVal And .lRBACustSku
200 If llRetVal And .oHostProcess.lRBACustSku
201 .LogEntry("Resolve RBA Customer")
202 llRetVal= .ResolveBCCustomer(pceipoTH)
203 Else
204 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
205
206 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
207
208 *--- TR 1045965 09-MAR-2010 HNISAR
209*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
210 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
211 *=== TR 1045965 09-MAR-2010 HNISAR
212
213 If llRetVal
214 .LogEntry("Validating customer.")
215 llRetVal= .CheckCustomer(pceipoTH)
216 *- 01/29/02 YIK TAN 29056
217 If llRetVal
218 .LogEntry("Verifying Multiple customer.")
219 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
220 *= TAN 29056
221 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
222 Endif
223 Endif
224 Endif
225 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
226
227 *--- TR 1041542 NSD 7/22/09
228 IF llRetVal
229 .LogEntry("Resolving Register Number")
230 llRetVal = .ResolveRegisterNumber(pceipoTH)
231 ENDIF
232 *=== TR 1041542 NSD 7/22/09
233
234 If llRetVal
235 .LogEntry("Validating EDI store.")
236 llRetVal= .CheckStore(pceipoTH, pceipoCR)
237 If llRetVal
238 .LogEntry("Validating EDI center.")
239 llRetVal= .CheckDistribution(pceipoTH)
240 *- 1007452 10/22/04 YIK
241 *- Checking notes type
242 If llRetVal
243 .LogEntry("Validating Header Notes type.")
244 llRetVal= .CheckNoteType(pceipoTH)
245 Endif
246 *= 1007452
247 Endif
248 Endif
249
250 *--- TR 1022625 4-Mar-2007 TT
251 If llRetVal
252 .LogEntry("Checking for Terminations in PO_TYPE")
253 llRetVal= .CheckTerminationInPoType(pceipoTH)
254 Endif
255
256 *--- TR 1022625 4-Mar-2007 TT
257 *!* ENDIF
258 *!* ENDIF
259
260 *--- TR 1030441 17-Apr-2008 Goutam
261 If llRetVal
262 .LogEntry("Validating shipper code.")
263 llRetVal= .CheckShipper(pceipoTH)
264 Endif
265 *=== TR 1030441 17-Apr-2008 Goutam
266
267 *--- TechRec 1066487 05-Feb-2013 MANI. ---
268 IF llRetVal
269 .LogEntry("Validating Location.")
270 llRetVal= .ValidateLocation(pceipoTH)
271 Endif
272 *=== TechRec 1066487 05-Feb-2013 MANI. ===
273
274 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
275 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
276*!* If llRetVal
277*!* .LogEntry("Validating 855 Header status code.")
278*!* llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
279*!* Endif
280 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
281 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
282
283 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
284 * TR 1037925 - As per Krishna/Shenba
285 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
286 * This is getting moved in TR 1037925
287*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
288*!* IF llRetVal
289*!* .LogEntry("Resolving Customer Shipper.")
290*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
291*!* ENDIF
292*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
293 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
294
295 Endwith
296 Select(lnOldSelect)
297 Return llRetVal
298 Endproc
299
300 *--------------------------------------------------------------------------------------
301
302 Function ResolveBCCustomer
303
304 Lparameters pceipoTH
305 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
306
307 llRetVal = True
308 lnSelect = Select()
309 With This
310 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
311 lcSQLString = " Select * From ZZXCSTCR "
312 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
313
314 If llRetVal
315 lcCursor = GetUniqueFileName()
316
317 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
318
319 Select lcCursor
320 lcErrs_Msg = " No matching record in Customer Store cross reference "
321
322 lnCnt = Recc()
323 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
324
325 Scan
326 lccustomer = Alltrim(rtl_cust)
327 lcDepartment = Alltrim(rtl_dept)
328 lcOrd_type = Alltrim(rtl_ord_type)
329
330 .LogEntry("Retail Customer: " + lccustomer )
331 .LogEntry("Retail Dept: " + lcDepartment)
332 .LogEntry("Retail order type: " + lcOrd_type)
333
334 Select tcCustcr
335 .LogEntry("Select: tcCustcr")
336
337 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
338 If Not Found()
339 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
340 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
341 IN (pceipoTH)
342 .LogEntry(lcErrs_Msg)
343 Else
344 lcBCCustomer = tcCustcr.customer
345 lcBCEDIStore = tcCustcr.Store
346
347 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
348
349 * TR 1019260 Added- , ord_type WITH '' ;
350
351 Replace customer With lcBCCustomer ;
352 EDI_STORE With lcBCEDIStore , ord_type With '' ;
353 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
354 IN (pceipoTH)
355
356 Endif
357 Endscan
358 .TableClose(lcCursor)
359 .TableClose("tcCustcr")
360
361 Endif
362 Endwith
363
364 Select (lnSelect)
365 Return llRetVal
366 Endfunc
367
368 *-----------------------------------------------------------------------------------
369
370 * TAN 29056 YIK
371 Procedure CheckForMultiCust
372 Lparameter pceipoTH, pceipoCR
373 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
374 llRetVal, llMultiCust
375 Private pcCustomer
376
377 lnSelect = Select()
378 Select (pceipoCR)
379 Scan For mult_cust = 'Y'
380
381 *--- TR 1031442 25-Jun-2008 Goutam
382 *llMultiCust = .T.
383 *--- TR 1031442 25-Jun-2008 Goutam
384
385 pcCustomer = customer
386 lcDiv = division
387 lcCursor = GetUniqueFileName()
388 *- YIK 01/30/02
389 *- We may have multiple POs/regions per customer in one tceipoth file
390 Select Distinct Region From (pceipoTH) ;
391 WHERE customer = pcCustomer ;
392 AND !Empty(Region) ;
393 INTO Cursor &lcCursor
394 Select (lcCursor)
395 Scan
396
397 *--- TR 1031442 25-Jun-2008 Goutam
398 llMultiCust = .T.
399 *--- TR 1031442 25-Jun-2008 Goutam
400
401 pcRegion = Region
402 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
403 Replace &pceipoTH..customer With lcNewCustID ;
404 FOR customer = pcCustomer And Region = pcRegion;
405 IN (pceipoTH)
406 Endscan
407 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
408 Select (pceipoCR)
409 Endscan
410 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
411 Select (lnSelect)
412 Return llRetVal
413 Endproc
414
415 *-----------------------------------------------------------------------------------
416
417 Procedure CheckStore
418 Lparameters pcHeader, pcControl
419 Local llRetVal, lnOldSelect
420 llRetVal= .T.
421 lnOldSelect= Select()
422
423 * 1st - group get store using cust,edi_store but not overwrite existing store
424 * users could change store in Trans Maint.
425 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
426 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
427 Select __TmpCursor
428 With This
429 .cSQLTempTable=""
430 If .GenerateSQLTempTable('__TmpCursor')
431 If .PopulateSQLTempTable('__TmpCursor')
432 If !Empty(.cSQLTempTable)
433 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
434 * also, populate center_code, consol_code if empty
435 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
436 " from zzxstorr s, " + .cSQLTempTable + " t " +;
437 "Where s.customer= t.customer and s.edi_store= t.edi_store"
438 llRetVal = v_SqlExec(lcSQLString, "_Storr")
439 If llRetVal
440 Select _Storr
441 Index On customer+EDI_STORE Tag CustStore
442 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
443 "customer+edi_store")
444 If llRetVal
445 Select (pcHeader)
446
447
448 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
449 * Otherwise we will not be able to resolve currency later and that will
450
451
452 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
453 * Confirm order(with store) for the same customer
454 * the Bulk order will have "Invalid Store" message.
455 * Only Scan for !Empty(edi_store)
456 Scan For !Empty(EDI_STORE)
457 Do Case
458 Case Empty(_Storr.customer)
459 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
460 Errs_flg_h With "Y" In (pcHeader)
461 Case _Storr.active_ok <> 'Y'
462 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
463 Errs_flg_h With "Y" In (pcHeader)
464 Otherwise
465 If Empty(Store) && don't want to overwrite previous data
466 Replace Store With _Storr.Store
467 Endif
468 *- YIK 1017307 07/18/06
469 *- Added AND EMPTY(edi_center)
470 *--- TR 1042564 14-Sep-2008 JK ---
471 * if the dts flag on the order is not Y, then populate.
472 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
473 *=== TR 1042564 14-Sep-2008 JK ===
474 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
475 Replace center_code With _Storr.center_code
476 Endif
477 If Empty(consol_code) And !Empty(_Storr.consol_code)
478 Replace consol_code With _Storr.consol_code
479 Endif
480 *--- TR 1042564 14-Sep-2008 JK ---
481 ENDIF
482 *=== TR 1042564 14-Sep-2008 JK ===
483 *== 1009508
484 Endcase
485
486 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
487
488 Endscan
489 Set Relation To
490 Use In _Storr
491 Endif
492 Endif
493 Endif
494 Endif
495 Endif
496 Endwith
497 If Used("__TmpCursor")
498 Use In __TmpCursor
499 Endif
500
501 * 2nd - validate store by cust,store
502 * Notes: cannot reuse the above server side cursor because have
503 * to resolve it to tran header local 1st before validate happen
504 Select Distinct customer, Store From (pcHeader) ;
505 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
506 Select __TmpCursor
507 With This
508 .cSQLTempTable=""
509 If .GenerateSQLTempTable('__TmpCursor')
510 If .PopulateSQLTempTable('__TmpCursor')
511 If !Empty(.cSQLTempTable)
512 lcSQLString= "Select s.customer, s.store " +;
513 " from zzxstorr s, " + .cSQLTempTable + " t " +;
514 "Where s.customer= t.customer and s.store= t.store"
515 llRetVal = v_SqlExec(lcSQLString, "_Storr")
516 If llRetVal
517 Select _Storr
518 Index On customer+Store Tag CustStore
519 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
520 "customer+store")
521 If llRetVal
522 Select (pcHeader)
523 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
524 * Confirm order(with store) for the same customer
525 * the Bulk order will have "Invalid Store" message.
526 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
527 * Don't have conf_type as "A" or "B" yet
528 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
529 *- assortment orders with no store.
530
531 *--- TR1055827 NSD/FGCjr
532 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
533 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))
534 *=== TR1055827
535 If Empty(_Storr.customer)
536 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
537 Errs_flg_h With "Y" In (pcHeader)
538 Endif
539 Endscan
540 Set Relation To
541 Use In _Storr
542 Endif
543 Endif
544 Endif
545 Endif
546 Endif
547 Endwith
548 If Used("__TmpCursor")
549 Use In __TmpCursor
550 Endif
551
552 If Used("_Storr")
553 Use In _Storr
554 Endif
555
556 Select(lnOldSelect)
557 Return llRetVal
558 Endproc
559
560 *------------------------------------------------------------------------------------------
561
562 ************************************************************************************
563 * Validate EDI Distribution Center
564 * ATS# 2757 PL 06/09/99- validate against edi_center
565 * use edi_center in tran header for validation, when found
566 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
567 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
568 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
569 ************************************************************************************
570 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
571 * 1. Select Distinct customer, distribution center from work header.
572 * 2. Check for valid distribution center. If faile the check update all headers for
573 * the same customer, distribution center with "Invalid Store code." and
574 * Errs_Flg with "Y"
575 * Return: True= All pass validation
576 * False= If one of them fail the check
577 ************************************************************************************
578 Procedure CheckDistribution
579 Lparameters pceipoTH
580 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
581 llRetVal = .T.
582 lnOldSelect = Select()
583
584 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
585 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
586 Into Cursor CntrList
587 Select CntrList
588 If This.lUserInterface
589 * Init Thermometer
590 This.UpdateThermoCaption("Validating Distribution Center(s)...")
591 * TAN 31891 - JAZ - 5/20/02
592 * This.InitThermo(RECC('CntrList'))
593 This.InitThermo(Reccount('CntrList'))
594 * End TAN 31891 - JAZ - 5/20/02
595 l_nThermoCnt = 0
596 Endif
597 Scan
598 If This.lUserInterface
599 * Advance progress bar, if we're using one.
600 l_nThermoCnt = l_nThermoCnt + 1
601 This.AdvanceThermo(l_nThermoCnt)
602 Endif
603 * Empty(center_code) resolve using edi_center
604 If Empty(center_code)
605 lcErrs_Msg= ""
606 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
607 lcErrs_Msg= lcErrs_Msg + CRLF
608 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
609 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
610 IN (pceipoTH)
611 Else
612 * replace center_code with shipthru.center_code when found edi_center
613 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
614 * COMMENT OUT replace ship_dc with "D" also.
615 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
616 * Do not update center code unless dts_flag <> Y
617 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
618 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
619 IN (pceipoTH)
620
621 Endif
622 Else
623 * user may overwrite with wrong center_code, validate distribution center
624 lcErrs_Msg= ""
625 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
626 lcErrs_Msg= lcErrs_Msg + CRLF
627 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
628 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
629 IN (pceipoTH)
630 Endif
631 Endif
632
633 Endscan
634 Use In CntrList
635
636 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
637 * also, populate center_code, consol_code if empty
638 * populate Ship_dc base on center/consol_code
639 Select (pceipoTH)
640 Scan
641 lcShip_dc = ""
642 *- 1009508 03/16/05
643 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
644 *-- DO CASE
645 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
646 *-- lcShip_dc = "B"
647 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
648 *-- lcShip_dc = "D"
649 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
650 *-- lcShip_dc = "C"
651 *-- ENDCASE
652
653 If !Empty(center_code) Or !Empty(consol_code)
654 Do Case
655 Case !Empty(center_code) And !Empty(consol_code)
656 lcShip_dc = "B"
657 Case !Empty(center_code) And Empty(consol_code)
658 lcShip_dc = "D"
659 Case Empty(center_code) And !Empty(consol_code)
660 lcShip_dc = "C"
661 Endcase
662 *= 1009508 YIK
663 If !Empty(lcShip_dc)
664 Replace ship_dc With lcShip_dc In (pceipoTH)
665 Endif
666 Endif
667 Endscan
668
669 If This.lUserInterface
670 * Reset Thermometer
671 This.ResetThermo()
672 Endif
673
674 If Used("CntrList")
675 Use In CntrList
676 Endif
677 If Used("tcDistr")
678 Use In tcDistr
679 Endif
680 Select(lnOldSelect)
681 Return llRetVal
682 Endproc
683
684 *---------------------------------------------------------------------------------
685
686 Procedure CheckNoteType
687 Lparameters tcEiPOth
688 Local llRetVal, lcNotes, laNotes
689 llRetVal = .T.
690 Select (tcEiPOth)
691 Scan For !Empty(notes)
692 lcNotes = notes
693 Declare laNotes[2]
694 laNotes = ""
695 If At("|", lcNotes) > 0 && has note_type
696 *- 1030497 02/29/08 TT
697 *--StringToArray(lcNotes, @laNotes, "|")
698 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
699 *- 1030497 02/29/08 TT
700 lnNotes = Alen(laNotes)/2
701 For lnCnt = 1 To lnNotes
702 If !vl_notyp(laNotes[2*lnCnt - 1])
703 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
704 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
705 Endif
706 Endfor
707 Endif
708 Endscan
709 Return llRetVal
710 Endproc
711 *---------------------------------------------------------------------------------
712
713 *--- TR 1022625 4-Mar-2007 TT
714 Function CheckTerminationInPoType
715 Lparameters pceipoTH
716 LOCAL llRetVal, lnOldSelect
717 lnOldSelect = SELECT()
718 llRetVal = .t.
719 Local lnLastOrder
720 Select (pceipoTH)
721 lnLastOrder = Order()
722 Set Order To Tag po_type
723 If Seek("TR", pceipoTH, "po_type")
724 Scan While po_type = 'TR'
725 Replace Errs_msg_H With Errs_msg_H + ;
726 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
727 Errs_flg_h With "Y" In (pceipoTH)
728 Endscan
729 Endif
730 Set Order To lnLastOrder
731 SELECT(lnOldSelect)
732 RETURN llRetVal
733 Endfunc
734 *--- TR 1022625 4-Mar-2007 TT
735
736 *---------------------------------------------------------------------------------
737
738 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
739 PROCEDURE Validate855Status
740 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
741
742 Local llRetVal, lnOldSelect, lcSourceFilter
743 llRetVal= true
744 lnOldSelect= Select()
745
746 IF pcHeaderDetail = 'H'
747 SELECT Distinct status_855 FROM (pcHeader) ;
748 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
749 lcSourceFilter = " s.source = 'BAK02'"
750 ELSE
751 SELECT DISTINCT d.status_855 ;
752 FROM (pcDetail) d ;
753 JOIN (pcHeader) h ;
754 ON h.pkey = d.fkey ;
755 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
756 INTO CURSOR __tmp855Status
757 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
758 ENDIF
759
760 SELECT __tmp855Status
761 WITH This
762 .cSQLTempTable=""
763 IF .GenerateSQLTempTable('__tmp855Status')
764 IF .PopulateSQLTempTable('__tmp855Status')
765 IF !EMPTY(.cSQLTempTable)
766
767 lcSQLString= "Select s.status_855 from " +;
768 " zzeopakr s, " + .cSQLTempTable + " t " +;
769 "Where s.status_855 = t.status_855 and " + lcSourceFilter
770
771 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
772 IF llRetVal
773 SELECT _Ststus855
774 INDEX On status_855 TAG status_855
775 IF pcHeaderDetail = 'H'
776 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
777 ELSE
778 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
779 ENDIF
780
781 IF llRetVal
782 IF pcHeaderDetail = 'H'
783 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
784 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
785 ELSE
786 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
787 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) In (pcDetail)
788
789 * mark headers errors here as the Run855Process which runs next will rely on header errors.
790 SELECT (pcDetail)
791 SCAN FOR errs_flg_d = 'Y'
792 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
793 AND EVALUATE(pcHeader+'.req_855') = 'R'
794 ENDSCAN
795 ENDIF
796
797 SET RELATION TO
798 ENDIF
799 ENDIF
800 ENDIF
801 ENDIF
802 ENDIF
803 ENDWITH
804
805 IF USED("__tmp855Status")
806 USE IN __tmp855Status
807 ENDIF
808 IF USED("_Ststus855")
809 USE IN _Ststus855
810 ENDIF
811
812 Select(lnOldSelect)
813 Return llRetVal
814 ENDPROC
815 *=== TR 1074251 03-Jan-2014 Goutam
816
817 *---------------------------------------------------------------------------------
818
819 *--- TR 1030441 17-Apr-2008 Goutam
820 Procedure CheckShipper
821 LPARAMETERS pcHeader
822 Local llRetVal, lnOldSelect
823 llRetVal= true
824 lnOldSelect= Select()
825
826 SELECT Distinct shipper FROM (pcHeader) ;
827 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
828
829 SELECT __tmpShipper
830 WITH This
831 .cSQLTempTable=""
832 IF .GenerateSQLTempTable('__tmpShipper')
833 IF .PopulateSQLTempTable('__tmpShipper')
834 IF !EMPTY(.cSQLTempTable)
835 lcSQLString= "Select s.shipper from " +;
836 " zzxshipr s, " + .cSQLTempTable + " t " +;
837 "Where s.shipper= t.shipper"
838 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
839 IF llRetVal
840 SELECT _Shiper
841 INDEX On shipper TAG Shipper
842 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
843 IF llRetVal
844 SELECT (pcHeader)
845 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
846 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
847 SET RELATION TO
848 ENDIF
849 ENDIF
850 ENDIF
851 ENDIF
852 ENDIF
853 ENDWITH
854
855 IF USED("__tmpShipper")
856 USE IN __tmpShipper
857 ENDIF
858 IF USED("_Shiper")
859 USE IN _Shiper
860 ENDIF
861
862 Select(lnOldSelect)
863 Return llRetVal
864 Endproc
865 *=== TR 1030441 17-Apr-2008 Goutam
866
867 *---------------------------------------------------------------------------------
868
869 ************************************************************************************
870 * Error check all raw EDI details
871 ************************************************************************************
872 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
873 * Move codes to CheckUPC() and CheckSKU()
874 * Add:ResolveCustomerLabel()
875 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
876 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
877 * [div,sty,col,lbl,dim,size] allow or not
878 *
879 Procedure CheckDetail
880 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
881 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
882 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
883 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
884 Local llRetVal, lnOldSelect
885 llRetVal = .T.
886 lnOldSelect = Select()
887 With This
888 *--- TechRec 1048792 17-Dec-2010 jisingh ---
889 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
890 *=== TechRec 1048792 17-Dec-2010 jisingh ===
891
892 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
893 *--- TR 1019697 NH
894 .LogEntry("Cascading Customer To Detail.")
895 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
896 .LogEntry("Cascading Customer To SLN.")
897 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
898 *=== TR 1019697 NH
899 *=== TechRec 1048667 03-May-2011 GSternik ===
900
901
902 *--- TechRec 1024522 18-Sep-2007 GSternik ---
903 *--- LOCAL MOD
904 *If This.lHaveSLN
905 If This.oHostProcess.lHaveSLN
906 .LogEntry("Resolving SLNs/Prepack Style.")
907 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
908 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
909 EndIf
910 *=== TechRec 1024522 18-Sep-2007 GSternik ===
911
912 .LogEntry("Resolving style using UPC.")
913 *--- TechRec 1005163 17-May-2004 GS ---
914 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
915 *--- TR 1019697 NH
916 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
917 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
918*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
919 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
920 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
921
922 *--- TR 1036917 04-Feb-2009 Partha ---
923 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
924 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
925
926 *=== TR 1036917 04-Feb-2009 Partha ===
927
928 *=== TR 1019697 NH
929 *=== TechRec 1005163 17-May-2004 GS ===
930 *--- TR 1023892 NH
931 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
932 *=== TR 1023892 NH
933
934 *--- TR 1044885 13-JAN-2010 BR Moved from above
935 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
936
937 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
938 *--- TechRec 1005163 17-May-2004 GS ---
939 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
940 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
941 *=== TechRec 1005163 17-May-2004 GS ===
942 *= 39222
943
944 *- TR 1003801 - 03/25/04 BD - Resolve EAN
945 .LogEntry("Resolving style using EAN.")
946
947 *--- TechRec 1005163 17-May-2004 GS ---
948 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
949 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
950 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
951 *=== TR 1061652 05/18/12 ATHIRUNAVU
952
953 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
954 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
955 *--- TR 1035223 NH
956 .LogEntry("Setting Skip SLN Check flag.")
957 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
958 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
959 *=== TR 1035223 NH
960
961 *--- TR 1053820 26-May-2011 Goutam
962 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
963 .LogEntry("Generate Customer SKU (Style_ColorSize).")
964 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
965 ENDIF
966 *=== TR 1053820 26-May-2011 Goutam
967
968 .LogEntry("Confirming SKU for UPC/EAN.")
969 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
970 *=== TechRec 1005163 17-May-2004 GS ===
971 *=== TR 1003801
972
973 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
974 If llRetVal And .oHostProcess.lRBACustSku
975 .LogEntry("Verifying Customer SKU.")
976 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
977 Endif
978 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
979
980 .LogEntry("Resolving style using SKU.")
981 *--- TechRec 1005163 17-May-2004 GS ---
982 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
983
984 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
985 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
986 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
987 *=== TR 1010097 07/27/05 TK
988 *=== TechRec 1005163 17-May-2004 GS ===
989
990 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
991 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
992 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
993
994 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
995 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
996 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
997
998 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
999 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
1000 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1001
1002 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
1003 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1004 *=== TR 1040432 MAY-20-2009 BR
1005
1006 *--- TR 1013007 NH
1007 *--- check if req_855 if 'R' and status flag is empty then set error flag
1008 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1009 *=== TR 1013007 NH
1010
1011 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1012 If llRetVal
1013 .LogEntry("Validating detail 855 status code.")
1014 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1015 Endif
1016 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1017
1018 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1019 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1020 vcLogName)
1021
1022 *--- TR 1013007 NH 2005-10-11
1023 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1024 If .lSend855
1025 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1026
1027 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1028 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1029 *=== TR 1040432 MAY-20-2009 BR
1030
1031 *--- Error out IPO records which has no corresponding OPRCR control ref
1032 *--- IPO and OPRCR link is customer, division, oVnd_Key
1033 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1034 *=== TR 1034481 NH
1035 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1036 *--- If req_855 = 'R'
1037 *--- then run process 855
1038 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1039 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1040 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1041 Endif
1042 *=== TR 1013007 NH
1043
1044 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1045 .LogEntry("Resolving Is 860.")
1046 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1047
1048 .LogEntry("Creating 860 Transaction records.")
1049 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
1050 llRetVal = llRetVal And .Create860TM(pceipoTH, pceipoTD)
1051 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1052
1053 *--- TechRec 1082601 24-Dec-2014 jisingh ---
1054 .LogEntry("Validating detail 860 qual.")
1055 llRetVal = llRetVal And .Validate860Qual(pceipoTH, pceipoTD)
1056 *=== TechRec 1082601 24-Dec-2014 jisingh ===
1057
1058 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1059 .LogEntry("Resolving Multi-UPCs.")
1060 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1061 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1062
1063 .LogEntry("Resolving range style.")
1064 *--- TR 1023892 NH -
1065 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1066 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1067 *=== TR 1023892 NH
1068
1069 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1070 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1071 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1072 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1073
1074 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1075 vcLogName)
1076 *- 36262 6/11/03 YIK
1077 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1078 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1079 vcLogName)
1080 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1081 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1082 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1083 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1084 * === TR 1046519 7/26/10 CM
1085
1086 *=
1087
1088 *- 1044723 01/06/10 YIK
1089 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1090 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1091
1092 *- TR 1042748 09/23/09 YIK
1093 *- Call it here to populate Impl_ok flag (3d parameter).
1094 *- MOved it to clsipopr, so need to call with .oHostProcess
1095 *- This method will be called again after implosion. Ok per JRoth
1096 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1097
1098
1099 * 3/25/02 30854 - Implosion single prepack
1100 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1101 vcLogName)
1102 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
1103
1104 *- 1006607 09/01/04 YIK
1105 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1106 vcLogName)
1107 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1108 *=========
1109
1110 *--- TechRec 1005163 17-May-2004 GS ---
1111 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1112 If .oHostProcess.lHaveSLN
1113 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1114
1115 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1116*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1117*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1118 *=== TR 1049029 27-Aug-2010 Partha ===
1119
1120 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1121
1122 .LogEntry("Validating SLN vs. Prepack.")
1123 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1124 Endif
1125 *=== TechRec 1005163 17-May-2004 GS ===
1126
1127 *--- TR 1011644 23-AUG-2005 KA
1128 *If this.oResolvePrepack.lMultipack
1129 If this.lMultipack
1130 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1131 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1132 Endif
1133 *=== TR 1011644 23-AUG-2005 KA
1134
1135 .LogMajorStage("Resolving and getting default fields.")
1136 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1137 .LogEntry("Resolving customer label.")
1138 *--- TechRec 1005163 18-May-2004 GS ---
1139 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1140 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1141 *=== TechRec 1005163 18-May-2004 GS ===
1142
1143 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1144 vcLogName)
1145
1146 .LogEntry("Validating style.")
1147 *--- TechRec 1005163 21-Jun-2004 GS ---
1148 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1149 *--- TechRec 1016817 04-May-2006 GS ---
1150 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1151 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1152 *=== TechRec 1016817 04-May-2006 GS ===
1153 *=== TechRec 1005163 21-Jun-2004 GS ===
1154
1155 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1156 If This.oHostProcess.lHaveChrgs
1157 .LogEntry("Validating Charges.")
1158 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1159 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1160 EndIf
1161 *-- This is not needed anymore:
1162 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1163 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1164 * vcLogName)
1165 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1166
1167 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1168 *!* .LogEntry("Validating MinMultiple.")
1169 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1170 *===TR 1012978 VK 23/11/05
1171
1172 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1173 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1174 vcLogName)
1175 .LogEntry("Converting inbound UOM.")
1176 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1177
1178 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1179 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1180 lcSqlString = " UPDATE h SET " + ;
1181 " ReResvStyle = c.ReResvStyle " + ;
1182 " FROM (pcEipoTH) h " + ;
1183 " JOIN (pcEipoCR) c " + ;
1184 " ON h.division = c.division " + ;
1185 " AND h.customer = c.customer " + ;
1186 " WHERE h.ReResvStyle = '' "
1187
1188 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1189 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1190 EndWith
1191
1192 Select(lnOldSelect)
1193 Return llRetVal
1194 ENDPROC
1195
1196 *----------------------------------------------------------------------------------------
1197 * TR 1037976 JAN-22-2008 BR
1198 *----------------------------------------------------------------------------------------
1199 Procedure UpdtHeaderDivs
1200 Lparameters pceipoTH, pceipoTD
1201 Local llRetVal, lnOldSelect, llUpdate
1202 llRetVal = .T.
1203 lnOldSelect = Select()
1204
1205 .LogEntry("Resolving header division.")
1206 *- 1005164 07/12/04 YIK
1207 *- Removed ..And Empty(Errs_Msg_D)
1208 Select Distinct fkey, division From (pceipoTD) ;
1209 WHERE !Empty(division) Into Cursor tmpCurs
1210 Select tmpCurs
1211 If This.lUserInterface
1212 * Init Thermometer
1213 * TAN 31891 - JAZ - 5/20/02
1214 * This.InitThermo(RECC('tmpCurs'))
1215 This.InitThermo(Reccount('tmpCurs'))
1216 * End TAN 31891 - JAZ - 5/20/02
1217 l_nThermoCnt = 0
1218 Endif
1219 Scan
1220 If This.lUserInterface
1221 * Advance progress bar, if we're using one.
1222 l_nThermoCnt = l_nThermoCnt + 1
1223 This.AdvanceThermo(l_nThermoCnt)
1224 Endif
1225 Select (pceipoTH)
1226
1227 * --- TR 1022896 NSD 05-10-07
1228 * Convert LOCATE to SEEK
1229 *LOCATE FOR pkey = tmpCurs.fkey
1230 *IF FOUND()
1231 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1232 * === TR 1022896 NSD 05-10-07
1233
1234 Replace division With tmpCurs.division In (pceipoTH)
1235 Endif
1236 Endscan
1237 Use In tmpCurs
1238
1239 If This.lUserInterface
1240 * Reset Thermometer
1241 This.ResetThermo()
1242 Endif
1243 Select(lnOldSelect)
1244 Return llRetVal
1245 ENDPROC
1246 *----------------------------------------------------------------------------------------
1247 * TR 1037976 JAN-22-2008 BR
1248 *----------------------------------------------------------------------------------------
1249
1250 *---------------------------------------------------------------------------------
1251
1252 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1253 ************************************************************************************
1254 * Resolve BC SKU from SLN records and create customer style data.
1255 ************************************************************************************
1256 Procedure ResolveStyleFromSLN
1257 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1258 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1259 *--- TR 1035491 4-Nov-2008 Goutam
1260 *--- This entire function splitted into two different part ;
1261 1. ResolveBCSkuFromSLN ;
1262 2. ResolvePPKSkuAndUpdateDetail
1263
1264 Local llRetVal, lnOldSelect
1265 lnOldSelect = Select()
1266 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1267 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1268
1269
1270 Select(lnOldSelect)
1271 Return llRetVal
1272 Endproc
1273
1274 *----------------------------------------------------------------------------------
1275 ************************************************************************************
1276 * Validate UPC for all details
1277 ************************************************************************************
1278 Procedure CheckUpc
1279 Lparameters pceipoTH, pceipoTD,;
1280 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1281
1282 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1283 * Added Parameter pceipocr
1284 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1285
1286 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1287 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1288 lnSize_desc, llSLN
1289
1290 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1291 LOCAL lcIs_upcsku
1292 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1293
1294 llRetVal = .T.
1295 lcErrs_Msg= ""
1296 lnOldSelect = Select()
1297
1298 * cannot check for UPC if customer is empty
1299 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1300 * on Cust SKU or UPC.
1301 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1302
1303 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1304 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1305 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1306
1307 *--- TechRec 1005163 17-May-2004 GS ---
1308 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1309 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1310 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1311 *Order by h.customer, d.upc Into Cursor tmpCurs
1312
1313 *---- TR 1024667 NSD 5/31/07
1314 * If sizebucket = 0 then re-resolve.
1315
1316 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1317 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1318*!* If This.lHaveSLN
1319*!* Select h.customer,;
1320*!* d.upc,;
1321*!* d.pkey,;
1322*!* (pceipoTD) As Src;
1323*!* FROM (pceipoTH) h ;
1324*!* JOIN (pceipoTD) d ;
1325*!* ON h.pkey = d.fkey ;
1326*!* WHERE !Empty(d.upc) ;
1327*!* AND !Empty(h.customer) ;
1328*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1329*!* UNION All ;
1330*!* SELECT h.customer,;
1331*!* s.SLN_UPC As upc,;
1332*!* s.pkey,;
1333*!* (pceipoTS) As Src ;
1334*!* FROM (pceipoTH) h ;
1335*!* JOIN (pceipoTD) d ;
1336*!* ON d.fkey = h.pkey ;
1337*!* JOIN (pceipoTS) s ;
1338*!* ON s.fkey = d.pkey ;
1339*!* WHERE !Empty(s.SLN_UPC) ;
1340*!* AND !Empty(h.customer) ;
1341*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1342*!* ORDER By 1, 2 ;
1343*!* INTO Cursor tmpCurs
1344*!* Else
1345*!* Select h.Customer,;
1346*!* d.UPC,;
1347*!* d.PKey,;
1348*!* (pceipoTD) As Src;
1349*!* FROM (pceipoTH) h ;
1350*!* JOIN (pceipoTD) d ;
1351*!* ON h.pkey = d.fkey ;
1352*!* WHERE !Empty(d.upc) ;
1353*!* AND !Empty(h.customer) ;
1354*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1355*!* ORDER By 1, 2;
1356*!* INTO Cursor tmpCurs
1357*!* Endif
1358 *=== TechRec 1005163 17-May-2004 GS ===
1359
1360 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1361 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1362 FROM (pceipocr) ;
1363 GROUP BY customer ;
1364 INTO CURSOR __ResvCustSKU
1365 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1366
1367 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1368*!* select h.Customer;
1369*!* , d.UPC;
1370*!* , d.PKey;
1371*!* from (pceipoTH) h;
1372*!* join (pceipoTD) d;
1373*!* on h.PKey = d.FKey;
1374*!* where !Empty(d.UPC);
1375*!* and !Empty(h.Customer);
1376*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1377*!* order by 1, 2;
1378*!* into Cursor tmpCurs ReadWrite
1379
1380 *- 1035314 08/28/08 YIK
1381 *- Added r.ResvCustSKU to the list of fields
1382 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1383
1384.oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1385
1386 Select h.customer;
1387 , d.upc;
1388 , d.pkey;
1389 ,(pceipoTD) AS Src;
1390 ,r.ResvCustSKU ;
1391 from (pceipoTH) h;
1392 join (pceipoTD) d;
1393 on h.pkey = d.fkey;
1394 JOIN __ResvCustSKU r ;
1395 ON r.Customer = H.Customer ;
1396 where !Empty(d.upc);
1397 and !Empty(h.customer);
1398 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1399 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1400 order By 1, 2;
1401 into Cursor tmpCurs Readwrite
1402 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1403 *= 08/12/08 YIK TR 1035314
1404*=== TechRec 1024522 25-Sep-2007 GSternik ===
1405
1406*-1040686
1407 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1408 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1409 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1410 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1411 IF llRetVal
1412 .PopulateSQLTempTable("tcCustUpc")
1413 ENDIF
1414
1415 llRetVal = llRetVal AND v_sqlexec(;
1416 "SELECT x.upc,d.* "+;
1417 " FROM zzxcstdr d"+ ;
1418 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1419 " JOIN " + this.cSQLTempTable + " x " + ;
1420 " ON d.customer = x.customer " +;
1421 " AND d.cust_style = x.upc " + ;
1422 " WHERE h.IB_resolv = 'Y'" + ;
1423 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1424 SELECT tmpCstdr_upc
1425 INDEX on customer + upc TAG cust_upc
1426
1427
1428 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1429 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1430 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1431 IF llRetVal
1432 .PopulateSQLTempTable("tcDistUpc")
1433 ENDIF
1434
1435 llRetVal = llRetVal AND v_sqlexec(;
1436 "SELECT x.upc,d.* "+;
1437 " FROM zzeupcnr d"+ ;
1438 " JOIN " + this.cSQLTempTable + " x " + ;
1439 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1440 SELECT tmpUpcnr
1441 INDEX on upc TAG upc
1442 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1443*-1040686
1444
1445 lcOldCust = ""
1446 lcOldItem = ""
1447 Select tmpCurs
1448 If This.lUserInterface
1449 * Init Thermometer
1450 This.UpdateThermoCaption("Validating UPC(s)...")
1451 * TAN 31891 - JAZ - 5/20/02
1452 * This.InitThermo(RECC('tmpCurs'))
1453 This.InitThermo(RecCount('tmpCurs'))
1454 * End TAN 31891 - JAZ - 5/20/02
1455 l_nThermoCnt = 0
1456 EndIf
1457
1458 Scan
1459 If This.lUserInterface
1460 * Advance progress bar, if we're using one.
1461 l_nThermoCnt = l_nThermoCnt + 1
1462 This.AdvanceThermo(l_nThermoCnt)
1463 Endif
1464 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1465 lcErrs_Msg = ""
1466 lcOldCust = tmpCurs.customer
1467 lcOldItem = tmpCurs.upc
1468 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1469 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1470
1471 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1472 lcIs_upcsku = ' '
1473 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1474
1475 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1476 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1477
1478 *- 1040686 - tmpCstdr_upc...
1479 lcDivision = tmpCstdr_upc.division
1480 lcStyle = tmpCstdr_upc.Style
1481 lcColor_code = tmpCstdr_upc.color_code
1482 lcLbl_code = tmpCstdr_upc.lbl_code
1483 lcDimension = tmpCstdr_upc.Dimension
1484 lnSizeBucket = tmpCstdr_upc.size_bk
1485 lnSize_desc = tmpCstdr_upc.size_desc
1486 *- 1040686 - tmpCstdr_upc...
1487
1488 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1489 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1490 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1491
1492 ELSE
1493 *- 08/12/08 YIK TR 1035314
1494 IF ResvCustSKU <> 'Y'
1495 lcErrs_Msg = ""
1496 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1497 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1498 lcDivision = tmpUpcnr.division
1499 lcStyle = tmpUpcnr.Style
1500 lcColor_code = tmpUpcnr.color_code
1501 lcLbl_code = tmpUpcnr.lbl_code
1502 lcDimension = tmpUpcnr.Dimension
1503 lnSizeBucket = tmpUpcnr.sizebucket
1504 lnSize_desc = tmpUpcnr.size_desc
1505 Else
1506 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1507 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1508 Store 0 To lnSizeBucket
1509 Endif
1510 *- 08/12/08 YIK TR 1035314
1511 ELSE
1512 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1513 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1514 STORE 0 TO lnSizeBucket
1515 ENDIF
1516 *= 08/12/08 YIK TR 1035314
1517 Endif
1518 Endif && level break
1519
1520 *--- TechRec 1005163 17-May-2004 GS ---
1521 *Select (pceipoTD)
1522*!* llSLN = (tmpCurs.Src = pceipoTS)
1523*!* If llSLN
1524*!* Select (pceipoTS)
1525*!* Else
1526 Select (pceipoTD)
1527*!* Endif
1528 *=== TechRec 1005163 17-May-2004 GS ===
1529 *- 1010682 04/25/05 YIK
1530 *- Locate For pkey = tmpCurs.pkey
1531 lnWorkArea = Select()
1532 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1533 Scatter Name loEiPOtd Memo
1534 If !Empty(lcErrs_Msg)
1535*!* *--- TechRec 1005163 17-May-2004 GS ---
1536*!* If llSLN
1537*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1538*!* loEiPOtd.Errs_Flg_S = "Y"
1539*!* Else
1540*!* *=== TechRec 1005163 17-May-2004 GS ===
1541 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1542 loEiPOtd.Errs_Flg_D = "Y"
1543*!* Endif
1544 Endif
1545 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1546 loEiPOtd.Division = lcDivision
1547 loEiPOtd.Style = lcStyle
1548 loEiPOtd.Color_Code = lcColor_code
1549 loEiPOtd.Lbl_Code = lcLbl_code
1550 loEiPOtd.Dimension = lcDimension
1551 loEiPOtd.SizeBucket = lnSizeBucket
1552 loEiPOtd.Size_Desc = lnSize_desc
1553
1554 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1555 IF !EMPTY(lcIs_upcsku)
1556 loEiPOtd.Is_upcsku = lcIs_upcsku
1557 ENDIF
1558 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1559
1560 *--- TR 1019697 NH : clear rang style when bc style is set
1561 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1562 loEiPOtd.rng_style = ''
1563 loEiPOtd.rng_color = ''
1564 loEiPOtd.rng_lbl = ''
1565 loEiPOtd.rng_pack = ''
1566 Endif
1567 *=== TR 1019697 NH
1568 Endif
1569
1570 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1571 * only replace our SKU when no range style explosion happen
1572 *--- TechRec 1005163 17-May-2004 GS ---
1573 *If empty(&pceipoTD..rng_style)
1574 * Replace division With loEiPOtd.division, ;
1575 * style With loEiPOtd.style, ;
1576 * color_code With loEiPOtd.color_code, ;
1577 * lbl_code With loEiPOtd.lbl_code, ;
1578 * dimension With loEiPOtd.dimension, ;
1579 * sizebucket With loEiPOtd.sizebucket, ;
1580 * size_desc With loEiPOtd.size_desc, ;
1581 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1582 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1583 * In (pceipoTD)
1584 *Endif
1585 *- 1009508 3/16/05 YIK
1586 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1587 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1588 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1589 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1590 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1591
1592 Gather Name loEiPOtd Memo
1593 Endif
1594 *=== TechRec 1005163 17-May-2004 GS ===
1595
1596 Endscan
1597 Use In tmpCurs
1598
1599 If This.lUserInterface
1600 * Reset Thermometer
1601 This.ResetThermo()
1602 Endif
1603
1604 If Used("tmpCstdr")
1605 Use In tmpCstdr
1606 Endif
1607 If Used("tmpUpcnr")
1608 Use In tmpUpcnr
1609 ENDIF
1610
1611 *- 1040686
1612 USE IN SELECT("tcCustUpc")
1613 USE IN SELECT("tmpCstdr_upc")
1614 USE IN SELECT("tcDistUpc")
1615 USE IN SELECT("tmpUpcnr")
1616 *- 1040686
1617
1618 Select(lnOldSelect)
1619 Return llRetVal
1620 Endproc
1621
1622 *----------------------------------------------------------------------------------
1623
1624 *--- TR 1035223 NH
1625 PROCEDURE ClearErrorsForSkipSlnCheck
1626 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1627
1628 LOCAL llRetVal, lnOldSelect
1629 lnOldSelect = SELECT()
1630 llRetVal = .t.
1631
1632 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1633 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1634
1635 *--- TR 1038353 NH
1636 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'
1637 *=== TR 1038353 NH
1638
1639 Select(lnOldSelect)
1640 Return llRetVal
1641 Endproc
1642
1643 *----------------------------------------------------------------------------------
1644
1645 PROCEDURE SetupSkipSLNCheck
1646 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1647
1648 LOCAL lnOldSelect, llRetVal
1649 lnOldSelect = SELECT()
1650 llRetVal = .t.
1651 *--- take division from trans detail
1652 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1653 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1654 inner join (pceipoCR) r on r.customer = th.customer AND r.division = td.division ;
1655 WHERE th.customer > '' AND td.division > ''
1656
1657 *--- Setup in pceipoTS
1658 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1659 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1660
1661 Select(lnOldSelect)
1662 Return llRetVal
1663
1664 Endproc
1665 *=== TR 1035223 NH
1666
1667 *----------------------------------------------------------------------------------
1668
1669 *--- TR 1023892 NH
1670 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1671 PROCEDURE Populate_Cust_lbl
1672 LPARAMETERS pcTransHeader, pcTransDetail
1673 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1674 llRetVal = .t.
1675 lnOldSelect = SELECT()
1676 lcSQLString = ""
1677 lcFkeySku = ""
1678 lcCust_lbl = ""
1679
1680
1681 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl ;
1682 FROM (pcTransHeader) h, (pcTransDetail) d ;
1683 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1684 and d.lbl_code = '' ;
1685 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1686
1687 IF RECCOUNT("__TmpCursor") = 0
1688 *-- no valid style to process
1689 this.LogEntry("No detail record found to populate customer label.")
1690 SELECT(lnOldSelect)
1691 RETURN llRetVal
1692 ENDIF
1693
1694 WITH this
1695 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1696 .cSQLTempTable = ""
1697 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1698 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1699 lcCustSku = "#CustSku" + SYS(2015)
1700
1701 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1702 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1703 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1704 *--- Used sc.Division instead of c.Division.
1705 TEXT TO lcSQLString NOSHOW
1706 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1707 case when d.orig_lbl <> '' then d.orig_lbl
1708 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1709 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1710 else d.lbl_code end as cust_lbl
1711 FROM #Temp d INNER JOIN zzeipocr_expl c on d.customer = c.customer and d.division = c.division
1712 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1713 AND sc.style = d.style AND sc.color_code = d.color_code
1714 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1715 ENDTEXT
1716
1717 lcCustLbl = SYS(2015)
1718 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1719 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1720 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1721 IF llRetVal
1722 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1723 SELECT(pcTransDetail)
1724 lcZzeipotd_order = ORDER()
1725 SET ORDER TO fkeySku
1726 SELECT (lcCustLbl)
1727 SCAN
1728 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1729 lcCust_lbl = Cust_lbl
1730 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1731 SELECT(pcTransDetail)
1732 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1733 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1734 ENDSCAN
1735 ENDIF
1736 ENDSCAN
1737 SELECT(pcTransDetail)
1738 SET ORDER TO (lcZzeipotd_order)
1739 ENDIF
1740 ENDWITH
1741 SELECT(lnOldSelect)
1742 RETURN llRetVal
1743 ENDPROC
1744
1745 *-----------------------------------------------------------------------------------
1746 *=== TR 1023892 NH
1747
1748 ************************************************************************************
1749 * Validate EAN for all details
1750 * Created on 03/24/04 - BD- TR 1003801
1751 ************************************************************************************
1752 Procedure CheckEAN
1753 Lparameters pceipoTH, pceipoTD,;
1754 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1755 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1756
1757 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1758 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1759 lnSize_desc, llSLN
1760 llRetVal = .T.
1761 lcErrs_Msg= ""
1762 lnOldSelect = Select()
1763
1764 *--- TR 1061652 05/18/12 ATHIRUNAVU
1765 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1766 FROM (pceipocr) ;
1767 GROUP BY customer ;
1768 INTO CURSOR __ResvCustSKU
1769 *=== TR 1061652 05/18/12 ATHIRUNAVU
1770
1771 *- Check EAN only if customer is empty
1772 *--- TechRec 1005163 17-May-2004 GS ---
1773 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1774 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1775 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1776 *Order by h.customer, d.ean Into Cursor tmpCurs
1777
1778 *---- TR 1024667 NSD 5/31/07
1779 * If sizebucket = 0 then re-resolve.
1780
1781 If This.oHostProcess.lHaveSLN
1782 *--- TR 1061652 05/18/12 ATHIRUNAVU
1783 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1784 Select h.customer,;
1785 d.ean,;
1786 d.pkey, ;
1787 r.ResvCustSKU, ;
1788 (pceipoTD) As Src;
1789 FROM (pceipoTD) d ;
1790 JOIN (pceipoTH) h ;
1791 ON h.pkey = d.fkey ;
1792 JOIN __ResvCustSKU r ;
1793 ON r.Customer = H.Customer ;
1794 WHERE !Empty(d.ean) ;
1795 AND !Empty(h.customer) ;
1796 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1797 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1798 Union All ;
1799 SELECT h.customer,;
1800 s.SLN_EAN As ean,;
1801 s.pkey, ;
1802 r.ResvCustSKU, ;
1803 (pceipoTS) As Src;
1804 FROM (pceipoTD) d ;
1805 JOIN (pceipoTH) h ;
1806 ON h.pkey = d.fkey ;
1807 JOIN (pceipoTS) s ;
1808 ON s.fkey = d.pkey ;
1809 JOIN __ResvCustSKU r ;
1810 ON r.Customer = H.Customer ;
1811 WHERE !Empty(s.SLN_EAN) ;
1812 AND !Empty(h.customer) ;
1813 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1814 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1815 ORDER By 1, 2 ;
1816 INTO Cursor tmpCurs
1817 Else
1818 *--- TR 1061652 05/18/12 ATHIRUNAVU
1819 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1820 Select h.customer,;
1821 d.ean,;
1822 d.pkey, ;
1823 r.ResvCustSKU, ;
1824 (pceipoTD) As Src;
1825 FROM (pceipoTD) d ;
1826 JOIN (pceipoTH) h ;
1827 ON h.pkey = d.fkey ;
1828 JOIN __ResvCustSKU r ;
1829 ON r.Customer = H.Customer ;
1830 WHERE !Empty(d.ean) ;
1831 AND !Empty(h.customer) ;
1832 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1833 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1834 Order By h.customer, d.ean ;
1835 INTO Cursor tmpCurs
1836 Endif
1837 *=== TechRec 1005163 17-May-2004 GS ===
1838
1839 lcOldCust = ""
1840 lcOldItem = ""
1841 Select tmpCurs
1842 If This.lUserInterface
1843 * Init Thermometer
1844 This.UpdateThermoCaption("Validating EAN(s)...")
1845 This.InitThermo(RecCount('tmpCurs'))
1846 l_nThermoCnt = 0
1847 Endif
1848 Scan
1849 If This.lUserInterface
1850 * Advance progress bar, if we're using one.
1851 l_nThermoCnt = l_nThermoCnt + 1
1852 This.AdvanceThermo(l_nThermoCnt)
1853 Endif
1854 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
1855 lcErrs_Msg = ""
1856 lcOldCust = tmpCurs.customer
1857 lcOldItem = tmpCurs.ean
1858 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1859 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1860
1861 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
1862 lcDivision = tmpCstdr.division
1863 lcStyle = tmpCstdr.Style
1864 lcColor_code = tmpCstdr.color_code
1865 lcLbl_code = tmpCstdr.lbl_code
1866 lcDimension = tmpCstdr.Dimension
1867 lnSizeBucket = tmpCstdr.size_bk
1868 lnSize_desc = tmpCstdr.size_desc
1869 Else
1870
1871 *--- TR 1061652 05/18/12 ATHIRUNAVU
1872 IF ResvCustSKU <> 'Y'
1873 *=== TR 1061652 05/18/12 ATHIRUNAVU
1874
1875 lcErrs_Msg = ""
1876 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
1877 lcDivision = tmpUpcnr.division
1878 lcStyle = tmpUpcnr.Style
1879 lcColor_code = tmpUpcnr.color_code
1880 lcLbl_code = tmpUpcnr.lbl_code
1881 lcDimension = tmpUpcnr.Dimension
1882 lnSizeBucket = tmpUpcnr.sizebucket
1883 lnSize_desc = tmpUpcnr.size_desc
1884 Else
1885 lcErrs_Msg = lcErrs_Msg + CRLF
1886 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1887 Store 0 To lnSizeBucket
1888 Endif
1889
1890 *--- TR 1061652 05/18/12 ATHIRUNAVU
1891 ELSE
1892 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
1893 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1894 STORE 0 TO lnSizeBucket
1895 ENDIF
1896 *=== TR 1061652 05/18/12 ATHIRUNAVU
1897
1898 Endif
1899 Endif && level break
1900
1901 *--- TechRec 1005163 17-May-2004 GS ---
1902 *Select (pceipoTD)
1903 llSLN = (tmpCurs.Src = pceipoTS)
1904 If llSLN
1905 Select (pceipoTS)
1906 Else
1907 Select (pceipoTD)
1908 Endif
1909 *=== TechRec 1005163 17-May-2004 GS ===
1910
1911 *- 1010682 04/25/05 YIK
1912 *- Locate For pkey = tmpCurs.pkey
1913 lnWorkArea = Select()
1914 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1915 Scatter Name loEiPOtd Memo
1916 If !Empty(lcErrs_Msg)
1917 *--- TechRec 1005163 17-May-2004 GS ---
1918 If llSLN
1919 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1920 loEiPOtd.Errs_Flg_S = "Y"
1921 Else
1922 *=== TechRec 1005163 17-May-2004 GS ===
1923 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1924 loEiPOtd.Errs_Flg_D = "Y"
1925 Endif &&--- TechRec 1005163 17-May-2004 GS ===
1926 Endif
1927 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1928 loEiPOtd.division = lcDivision
1929 loEiPOtd.Style = lcStyle
1930 loEiPOtd.color_code = lcColor_code
1931 loEiPOtd.lbl_code = lcLbl_code
1932 loEiPOtd.Dimension = lcDimension
1933 loEiPOtd.sizebucket = lnSizeBucket
1934 loEiPOtd.size_desc = lnSize_desc
1935 Endif
1936
1937 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1938 * only replace our SKU when no range style explosion happen
1939 *--- TechRec 1005163 17-May-2004 GS ---
1940 *If empty(&pceipoTD..rng_style)
1941 * Replace division With loEiPOtd.division, ;
1942 * style With loEiPOtd.style, ;
1943 * color_code With loEiPOtd.color_code, ;
1944 * lbl_code With loEiPOtd.lbl_code, ;
1945 * dimension With loEiPOtd.dimension, ;
1946 * sizebucket With loEiPOtd.sizebucket, ;
1947 * size_desc With loEiPOtd.size_desc, ;
1948 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1949 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1950 * In (pceipoTD)
1951 *- 1009508 3/16/05 YIK
1952 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1953 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
1954
1955 Gather Name loEiPOtd Memo
1956 *=== TechRec 1005163 17-May-2004 GS ===
1957 Endif
1958 Endscan
1959 Use In tmpCurs
1960
1961 If This.lUserInterface
1962 * Reset Thermometer
1963 This.ResetThermo()
1964 Endif
1965
1966 If Used("tmpCstdr")
1967 Use In tmpCstdr
1968 Endif
1969 If Used("tmpUpcnr")
1970 Use In tmpUpcnr
1971 Endif
1972
1973 Select(lnOldSelect)
1974 Return llRetVal
1975 Endproc
1976
1977 *-----------------------------------------------------------------------------------
1978
1979 *--- 39222 5/1/03 YIK
1980 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
1981 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
1982 *- matches the sku sent in transmission.
1983
1984 *--- TechRec 1005163 17-May-2004 GS:
1985 *- Combined ConfirmUPC and ConfirmEAN
1986
1987 Procedure ConfirmSku
1988 Lparameters pceipoTH, pceipoTD, pceipoCR,;
1989 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
1990
1991 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
1992 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
1993 lcSku, lcErrs_Msg, llSLN
1994
1995 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
1996 llRetVal = .T.
1997 lcErrs_Msg= ""
1998
1999 *--- TR 1085322 24-Sep-2015 Goutam
2000 LOCAL llCustStyleDupeCheck, llCustStyleFound,lcStyle, lcColor, lcLabel
2001 *=== TR 1085322 24-Sep-2015 Goutam
2002
2003 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2004 lcWarnMsg = ""
2005 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2006
2007 lnOldSelect = Select()
2008
2009 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
2010
2011 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
2012 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
2013 *- 1003788 2/25/04 YIK
2014 *- use d.division, not h.division which is still empty
2015
2016 *--- TechRec 1005163 17-May-2004 GS ---
2017 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2018
2019 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2020 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2021 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2022 *--- TR 1078000 16-4-2014 VKK Added cust_size
2023 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2024 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass , cust_size ;
2025 from (pceipoTD) Into Cursor __eipoTD
2026
2027 If This.oHostProcess.lHaveSLN
2028 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2029 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2030 *--- TR 1078000 16-4-2014 VKK Added cust_size
2031 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2032 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass , cust_size From (pceipoTS) Into Cursor __EiPOts
2033 Endif
2034 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2035 *--- NH - 08/10/07
2036 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2037 Select(lnOldSelect)
2038 RETURN llRetVal
2039 ENDIF
2040 *=== TR 1022625
2041
2042 With This
2043 .cSQLTempTable = ""
2044 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2045 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2046 lceipoTD_tmp = .cSQLTempTable
2047 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2048
2049 If This.oHostProcess.lHaveSLN
2050 .cSQLTempTable = ""
2051 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2052 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2053 lceipoTS_tmp = .cSQLTempTable
2054 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2055 Endif
2056 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2057 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2058 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2059 ENDWITH
2060
2061
2062 This.MakeCursorWritable("tmpCursR","tmpCurs")
2063 *=== TR 1019697 NH
2064 *=== TechRec 1005163 17-May-2004 GS ===
2065
2066 *--- TR 1085322 24-Sep-2015 Goutam
2067 IF llRetVal AND !EMPTY(lceipoTD_tmp)
2068 lcSql = "select b.cust_style, b.division, b.style, b.color_code, b.lbl_code, b.dimension, b.size_bk " +;
2069 " from " + lceipoTD_tmp + " a join zzxcstdr b " +;
2070 " on a.sku = b.cust_style"
2071
2072 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpBCSKUCurs")
2073 IF llRetVal
2074 SELECT tmpBCSKUCurs
2075 INDEX on cust_style+division+style+color_code+lbl_code+dimension+STR(size_bk) TAG cust_style
2076 SET ORDER TO
2077 ENDIF
2078 ENDIF
2079 *=== TR 1085322 24-Sep-2015 Goutam
2080
2081 .LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2082 Select tmpCurs
2083 If This.lUserInterface
2084 * Init Thermometer
2085 This.UpdateThermoCaption("Comparing SKU(s)...")
2086 This.InitThermo(RecCount('tmpCurs'))
2087 l_nThermoCnt = 0
2088 Endif
2089 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2090 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2091 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2092 *=== TR 1019697 NH
2093
2094 *-1040686
2095 *=-=-=-=-=-=-=-=-=-=
2096 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2097 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2098 IF llRetVal
2099 .PopulateSQLTempTable("tcDistCustSku")
2100 ENDIF
2101 llRetVal = llRetVal AND v_sqlexec(;
2102 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2103 " , d.aux_sku, d.pkey " +;
2104 " FROM zzxcstdr d"+ ;
2105 " JOIN " + this.cSQLTempTable + " x " + ;
2106 " ON d.customer = x.customer " +;
2107 " AND d.division = x.division " + ;
2108 " AND d.style = x.style " + ;
2109 " AND d.color_code = x.color_code " + ;
2110 " AND d.lbl_code = x.lbl_code " + ;
2111 " AND d.dimension = x.dimension " + ;
2112 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2113 SELECT tmpCstdr
2114 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2115
2116 INDEX on cust_style TAG custsty && TR 1085322 KISHORE 22-SEP-2015
2117 *=-=-=-=-=-=-=-=-=-=
2118
2119 * TR 1085322 KISHORE 12-MAR-2015
2120 llCustStyleDupeCheck = (goEnv.sv("CUST_STYLE_DUPE_CHECK","N") = "Y")
2121
2122 SELECT tmpCurs
2123 *- 1040686
2124
2125
2126 Local lnSizeBk
2127 lnSizeBk = 0
2128 Scan
2129 llCustStyleFound = false &&*--- TR 1085322 24-Sep-2015 Goutam
2130
2131 If This.lUserInterface
2132 * Advance progress bar, if we're using one.
2133 l_nThermoCnt = l_nThermoCnt + 1
2134 This.AdvanceThermo(l_nThermoCnt)
2135 Endif
2136 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2137 lcErrs_Msg = ""
2138 *=== TechRec 1005163 17-May-2004 GS, YK ===
2139
2140 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2141 lcWarnMsg = ""
2142 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2143
2144 *-1040686
2145 *=-=-=-=-=-=-=-=-=-
2146 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2147 DIMENSION, sizebucket, "tmpCstdr")
2148 lcSku = ""
2149 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2150 lcSku = tmpCstdr.cust_style
2151 ELSE
2152 lcErrs_Msg = "Missing SKU code."
2153 ENDIF
2154 *=-=-=-=-=-=-=-=-=-
2155 *-1040686
2156
2157 *--- TR 1085322 24-Sep-2015 Goutam.
2158 *Note: Cust_sku must be unique in zzxcstdr if the system parameter CUST_STYLE_DUPE_CHECK = ‘Y’
2159 IF SEEK(tmpCurs.sku, "tmpBCSKUCurs", "cust_style")
2160 lcStyle = ALLTRIM(tmpBCSKUCurs.style)
2161 lcColor = ALLTRIM(tmpBCSKUCurs.color_code)
2162 lcLabel = ALLTRIM(tmpBCSKUCurs.lbl_code)
2163 IF llCustStyleDupeCheck AND !SEEK(tmpCurs.sku+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpBCSKUCurs", "cust_style")
2164 lcErrs_Msg = "Customer Style " + ALLTRIM(tmpCurs.sku) + " already exists for Style " + lcstyle + ", Color " + lcColor + " and label " + lcLabel
2165 llCustStyleFound = true
2166 ENDIF
2167 *--- TR 1095258 04/28/16 ATHIRUNAVU Added tmpcurs.customer
2168 *IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2169 IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2170 Replace AddCustSKU With .T. In (tmpCurs.Src)
2171 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2172 llCustStyleFound = true
2173 ENDIF
2174 ENDIF
2175 *=== TR 1085322 24-Sep-2015 Goutam
2176
2177 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2178 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2179
2180 IF !llCustStyleFound &&*--- TR 1085322 24-Sep-2015 Goutam
2181 If !(lcSku == tmpCurs.sku)
2182
2183 * TR 1085322 KISHORE 12-MAR-2015 added OR Upd_CustSku = 'Y'
2184 If (Empty(lcSku) And GenCustSKU = 'Y') OR Upd_CustSku = 'Y'
2185 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2186 *--- TR 1085322 24-Sep-2015 Goutam
2187 IF Upd_CustSku = 'Y'
2188 IF SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.Style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.DIMENSION+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku") ;
2189 AND (tmpCurs.SKU <> tmpCstdr.cust_style)
2190
2191 lcSQL = "Update zzxcstdr set cust_style = " + SQLFormatChar(tmpCurs.sku) + ;
2192 ", last_mod = " + SQLFormatTs(DATETIME()) + ", user_id = " + SQLFormatChar(EDI_USER) + ;
2193 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2194 llRetVal = llRetVal And v_SqlExec(lcSQL)
2195 ENDIF
2196 ELSE
2197 *=== TR 1085322 24-Sep-2015 Goutam
2198 Replace AddCustSKU With .T. In (tmpCurs.Src)
2199 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2200
2201 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2202 lcErrs_Msg = ""
2203 Else
2204 If Confirm_SKU = 'Y'
2205 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2206 Else
2207 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2208 CRLF + "Unable to generate new customer Sku." + CRLF
2209 Endif
2210 ENDIF
2211 *--- TR 1061151 2-MAY-12 Venuk.
2212 Else
2213 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2214 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2215 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2216 v_SqlExec(lcSQL)
2217 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2218 ELSE
2219 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2220 lcWarnMsg = "Aux sku already exist."
2221 ENDIF
2222 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2223 ENDIF
2224 *=== TR 1061151 2-MAY-12 Venuk.
2225 Endif
2226
2227 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2228
2229 *--- TechRec 1005163 17-May-2004 GS ---
2230 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2231 * Replace ;
2232 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2233 * Errs_Flg_D With "Y" ;
2234 * In (pceipoTD)
2235
2236 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2237 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2238 llSLN = (tmpCurs.Src = pceipoTS)
2239 If llSLN
2240 Select (pceipoTS)
2241 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2242 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2243 IF !EMPTY(lcErrs_Msg)
2244 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2245 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2246 Replace ;
2247 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2248 Errs_Flg_S With "Y"
2249 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2250 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2251 Errs_Flg_D With 'Y' In (pceipoTD)
2252 Endif
2253 ENDIF
2254 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2255 ELSE
2256 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2257 Warn_Flg_D With "Y" In (pceipoTD)
2258 ENDIF
2259 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2260 Else
2261 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2262 Select (pceipoTD)
2263 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2264 IF !EMPTY(lcErrs_Msg)
2265 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2266 Replace ;
2267 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2268 Errs_Flg_D With "Y"
2269 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2270 ELSE
2271 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2272 Warn_Flg_D With "Y"
2273 ENDIF
2274 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2275 Endif
2276 *=== TechRec 1005163 17-May-2004 GS ===
2277 Endif
2278 ENDSCAN
2279 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2280 *--- TR 1019697 NH :
2281 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2282 *=== TR 1019697 NH
2283 Use In tmpCurs
2284
2285 If This.lUserInterface
2286 * Reset Thermometer
2287 This.ResetThermo()
2288 Endif
2289
2290 If Used("tmpCstdr")
2291 Use In tmpCstdr
2292 ENDIF
2293
2294 *--- TR 1085322 24-Sep-2015 Goutam
2295 USE IN SELECT("tmpBCSKUCurs")
2296 *=== TR 1085322 24-Sep-2015 Goutam
2297
2298 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2299
2300 Select(lnOldSelect)
2301 Return llRetVal
2302 Endproc
2303
2304 *-----------------------------------------------------------------------------------
2305
2306 *--- TR 1019697 NH
2307 **************************************************************************************
2308 Procedure GetConfrimSkuSql
2309 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2310 Local lcSQL, lcSqlSln, lnOldSelect
2311 lnOldSelect = Select()
2312
2313 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2314 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2315
2316 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2317 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2318 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2319 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2320 *--- TR 1078000 16-4-2014 VKK Added cust_size
2321 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2322 lcSQL = ;
2323 "select d.customer"+;
2324 " , d.division"+;
2325 " , d.sku"+;
2326 " , d.STYLE"+;
2327 " , d.color_code"+;
2328 " , case"+;
2329 " when r.rng_style is null"+;
2330 " and d.lbl_code = ''"+;
2331 " and c.resv_label = 'Y' then c.lbl_code"+;
2332 " when r.rng_style is null"+;
2333 " and d.lbl_code = ''"+;
2334 " and c.resv_label = 'V'"+;
2335 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2336 " else d.lbl_code"+;
2337 " end as lbl_code"+;
2338 " , d.lbl_code as lbl_codeOrig"+;
2339 " , c.resv_label"+;
2340 " , d.DIMENSION"+;
2341 " , d.Sizebucket"+;
2342 " , d.upc"+;
2343 " , d.pkey"+;
2344 " , C.GenCustSKU"+;
2345 " , C.Confirm_SKU"+;
2346 " , C.upd_custsku " + ;
2347 " , 'N' as AddCustSKU"+;
2348 " , d.size_desc"+;
2349 " , '" + Trim(pceipoTD) + "' as Src"+;
2350 " , d.aux_sku " + ;
2351 " , d.subclass " + ;
2352 " , d.cust_size " + ;
2353 " from " + pceipoTD_tmp + " d"+;
2354 " join " + This.c850Control + " C"+;
2355 " on d.customer = C.customer"+;
2356 " and d.division = C.division"+;
2357 " left join zzxrangh r"+;
2358 " on r.division = d.division"+;
2359 " and r.rng_style = d.style"+;
2360 " and r.rng_color = d.color_code"+;
2361 " and r.rng_lbl = d.lbl_code"+;
2362 " and r.rng_pack = d.dimension"+;
2363 " left join zzxscolr sc"+;
2364 " on sc.division = d.division"+;
2365 " and sc.style = d.style"+;
2366 " and sc.color_code = d.color_code"+;
2367 " and sc.lbl_code = c.lbl_code"+;
2368 " and sc.dimension = d.dimension"+;
2369 " where d.customer > ''"+;
2370 " and d.SKU > ''"+;
2371 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2372 " and d.Division > ''"+;
2373 " and d.Style > ''"+;
2374 " and d.Color_Code > ''"+;
2375 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2376 " and d.Rng_Style = '' "
2377
2378 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2379 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2380 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2381 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2382 *--- Used sc.Division instead of c.Division.
2383 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2384 *--- TR 1078000 16-4-2014 VKK Added cust_size
2385 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2386 lcSqlSln = ;
2387 "select d.Customer"+;
2388 " , d.Division"+;
2389 " , s.SLN_SKU as sku"+;
2390 " , s.STYLE"+;
2391 " , s.Color_Code"+;
2392 " , case when s.Lbl_Code = ''"+;
2393 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2394 " when s.Lbl_Code = ''"+;
2395 " and c.Resv_Label = 'V'"+;
2396 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2397 " else s.lbl_code"+;
2398 " end as lbl_code"+;
2399 " , s.lbl_code as lbl_codeOrig"+;
2400 " , c.resv_label"+;
2401 " , s.DIMENSION"+;
2402 " , s.Sizebucket"+;
2403 " , s.SLN_UPC as upc"+;
2404 " , s.pkey"+;
2405 " , C.GenCustSKU"+;
2406 " , C.Confirm_SKU"+;
2407 " , C.upd_custsku " + ;
2408 " , 'N' as AddCustSKU"+;
2409 " , s.size_desc"+;
2410 " , '" + Trim(pceipoTS) + "' as Src"+;
2411 " , s.aux_sku " + ;
2412 " , s.subclass " + ;
2413 " , s.cust_size " + ;
2414 " from " + pceipoTD_tmp + " d"+;
2415 " join " + pceipoTS_tmp + " s"+;
2416 " on s.fkey = d.pkey"+;
2417 " join " + This.c850Control + " C"+;
2418 " on d.customer = C.customer"+;
2419 " and d.division = C.division"+;
2420 " left join zzxscolr sc"+;
2421 " on sc.division = d.division"+;
2422 " and sc.style = s.style"+;
2423 " and sc.color_code = s.color_code"+;
2424 " and sc.lbl_code = c.lbl_code"+;
2425 " and sc.dimension = s.dimension"+;
2426 " where d.Customer > ''"+;
2427 " and s.SLN_SKU > ''"+;
2428 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2429 " and d.Division > ''"+;
2430 " and s.Style > ''"+;
2431 " and s.Color_Code > ''"+;
2432 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2433 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2434 Endif
2435
2436 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2437 Select(lnOldSelect)
2438 Return lcSQL
2439 Endproc
2440
2441 *-----------------------------------------------------------------------------------
2442
2443 Procedure CreateOurSkuFromTmpCurs
2444 If Not Used("TmpCurs")
2445 Return .F.
2446 Endif
2447 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2448 llRetVal = .T.
2449 lnOldSelect = Select()
2450 With This
2451 Select tmpCurs
2452 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2453
2454 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2455 lcDistSku = Getuniquefilename()
2456 lcExistingSku = Getuniquefilename()
2457 lcCustLbl = Getuniquefilename()
2458
2459 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2460 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2461 *- We need this because cursor lcCustLbl has customer field.
2462 *- 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
2463 *- with auto_style = 'Y', we will add both auto_style twice.
2464
2465 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2466 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2467 *- because style exists in zzxscolr (we just addeded)
2468 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2469 *- so we will add it twice by accident.
2470
2471 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2472 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2473 *-FH 1066967
2474
2475
2476 *-FH 1066967 - added customer
2477 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2478 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2479 IF llRetVal
2480 .PopulateSQLTempTable(lcDistSku)
2481 ENDIF
2482
2483 llRetVal = llRetVal AND v_sqlexec(;
2484 "SELECT x.* "+;
2485 " FROM zzxscolr d"+ ;
2486 " JOIN " + this.cSQLTempTable + " x " + ;
2487 " ON d.division = x.division " +;
2488 " AND d.style = x.style " + ;
2489 " AND d.color_code = x.color_code " + ;
2490 " AND d.lbl_code = x.lbl_code " + ;
2491 " AND d.dimension = x.dimension " ,lcExistingSku )
2492 SELECT (lcExistingSku)
2493 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2494
2495 IF llRetVal
2496 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2497 ENDIF
2498
2499 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2500 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2501 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2502 SELECT(lcCustLbl)
2503 INDEX on customer + lbl_code TAG cust_lbl
2504
2505 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2506 SELECT (lcDistSku) && FH 1066967
2507 Scan
2508 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2509 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2510 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2511*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2512*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2513*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2514*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2515*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2516*!* Else
2517*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2518*!* Endif
2519*!* ENDIF
2520
2521 IF NOT EMPTY(&lcDistSku..lbl_code)
2522 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2523 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2524 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2525 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2526
2527 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2528 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2529 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2530 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2531
2532 .oLog.LogEntry("Created style: " + lcOurSKU )
2533 Else
2534 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2535 ENDIF
2536 ENDIF
2537 Endif
2538 ENDIF
2539
2540 ENDSCAN
2541 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2542
2543 USE IN SELECT(lcDistSku)
2544 USE IN SELECT(lcExistingSku)
2545 USE IN SELECT(lcCustLbl)
2546
2547 USE IN SELECT('lcStyleAdded') && FH 1066967
2548
2549 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2550 Endwith
2551 Select (lnOldSelect)
2552 Return llRetVal
2553 Endproc
2554
2555 *-----------------------------------------------------------------------------------
2556
2557 Procedure GenerateCustomerSkuFromCursor
2558 Parameters tcSkuCursor
2559 Local lnOldSelect, llRetVal
2560 llRetVal = .T.
2561 lnOldSelect = Select()
2562
2563 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2564 lcPrevSkuIpotd = ""
2565 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2566 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2567 *--- TR 1078000 16-4-2014 VKK Added cust_size
2568 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2569 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2570 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2571 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2572
2573 With This
2574 lnCount = Reccount("tmpCurs1")
2575
2576 If lnCount = 0
2577 Select (lnOldSelect)
2578 Return
2579 Endif
2580
2581 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2582 Select (lnOldSelect)
2583 Return
2584 Endif
2585
2586 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2587 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2588 lnCount = lnCount - 1
2589 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2590 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2591
2592 Select VZZXCSTHR
2593 Scatter Memvar Blank
2594 Select VZZXCSTDR
2595 Scatter Memvar Blank
2596
2597 m.Last_mod = Datetime()
2598 m.User_id = 'CGSADMIN'
2599 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2600
2601 * --- TR 1039603 4/6/09 CM
2602 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2603 m.active_ok = 'Y'
2604 m.anti_theft = 'N'
2605 * === TR 1039603 4/6/09 CM
2606
2607 m.notes = ''
2608
2609 lcPrevSKU = ' '
2610
2611 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2612 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2613 Select("tmpCursSrc")
2614 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2615 Scan
2616 Select (Alltrim(tmpCursSrc.Src))
2617 lcOldOrder = Order()
2618 Set Order To CstBcSku
2619 Replace oldOrder With lcOldOrder In tmpCursSrc
2620 ENDSCAN
2621 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2622
2623 Select tmpCurs1
2624 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2625 Scan
2626 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2627 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2628 *--- TR 1078000 16-4-2014 VKK Added cust_size
2629 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2630 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2631 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2632 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2633 If lcPrevSKU # lcSku
2634 lcPrevSKU = lcSku
2635 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2636 If Empty(lnHDRpKey)
2637 lnHDRpKey = lnCstHrPkey
2638 Insert Into VZZXCSTHR From Memvar
2639 Replace pkey With lnHDRpKey In VZZXCSTHR
2640 Endif
2641 Endif
2642 *--- clear AddCustSKU for all matching rows in zzeipotd
2643 Select (tmpCurs1.Src)
2644 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2645 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2646 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2647 Endscan
2648 lcPrevSkuIpotd = lcSkuIpotd
2649
2650 *-TR 1059834 FH -moved in IF statement
2651 Select tmpCurs1
2652 Insert Into VZZXCSTDR From Memvar
2653 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2654 lnCstDrPkey = lnCstDrPkey +1
2655 lnCstHrPkey = lnCstHrPkey +1
2656 *-TR 1059834 FH -moved in IF statement
2657
2658 Endif
2659 ENDSCAN
2660 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2661 Select("tmpCursSrc")
2662 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2663 Scan
2664 Select (Alltrim(tmpCursSrc.Src))
2665 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2666* If Not Empty(lcOldOrder)
2667 Set Order To (lcOldOrder)
2668* Endif
2669 ENDSCAN
2670 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2671 Use In tmpCursSrc
2672
2673 Dimension laTables[2]
2674 laTables[1]= "VZZXCSTHR"
2675 laTables[2]= "VZZXCSTDR"
2676
2677 llBeganTransaction = .BeginTransaction()
2678 llRetVal = .Tableupdate(@laTables)
2679
2680 If llRetVal
2681 If llBeganTransaction
2682 This.EndTransaction()
2683 Endif
2684 Else
2685 If llBeganTransaction
2686 This.RollbackTransaction()
2687 Endif
2688 Endif
2689 Endwith
2690 If Used("tmpCurs1")
2691 Use In tmpCurs1
2692 Endif
2693 Select(lnOldSelect)
2694 Return llRetVal
2695 Endproc
2696
2697 *-----------------------------------------------------------------------------------
2698 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2699
2700 Function GenerateRBACustSKU
2701 Lparameters pceipoTH,pceipoTD
2702
2703 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2704 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2705
2706
2707 llRetVal = True
2708 lnSelect = Select()
2709 lcRBADivision = 'TFG'
2710 With This
2711
2712 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2713
2714 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2715 *- 12/12/06 YIK
2716 *- No distinct since includes pkey. Change order.
2717 *-- SELECT DISTINCT ;
2718 *-- h.customer,;
2719 *-- lcRBADivision as division,;
2720 *-- d.pkey as dtlpkey ,;
2721 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2722 *-- d.color_code,;
2723 *-- .GetCustLabel(h.customer) as lbl_code,;
2724 *-- "" as DIMENSION,;
2725 *-- h.store as cust_store ,;
2726 *-- d.sku as cust_style ,;
2727 *-- d.price as cust_price , ;
2728 *-- d.size_desc, ;
2729 *-- 0 as size_bk ;
2730 *-- FROM (pceipoTH) h ;
2731 *-- JOIN (pceipoTD) d ;
2732 *-- ON d.fkey = h.pkey ;
2733 *-- INTO CURSOR __tmpCur ;
2734 *-- ORDER BY 1,2,3,4,5,6
2735
2736 *** Size_BK needs to be 00 and NOT 0
2737 Select ;
2738 h.customer,;
2739 lcRBADivision As division,;
2740 d.pkey As dtlpkey ,;
2741 d.Style As Style, ;
2742 d.color_code,;
2743 .GetCustLabel(h.customer) As lbl_code,;
2744 "" As Dimension,;
2745 h.Store As cust_store ,;
2746 d.sku As Cust_style ,;
2747 d.price As cust_price , ;
2748 d.size_desc, ;
2749 00 As size_bk ;
2750 FROM (pceipoTH) h ;
2751 JOIN (pceipoTD) d ;
2752 ON d.fkey = h.pkey ;
2753 WHERE h.Errs_flg_h < 'Y' And ;
2754 d.Errs_Flg_D < 'Y' ;
2755 INTO Cursor __tmpCur ;
2756 ORDER By 1,2,4,5,6,7, 11
2757 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2758
2759 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2760
2761 lnCount = Reccount("tmpCurs")
2762
2763 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
2764
2765 If lnCount = 0
2766 If Used("tmpCurs")
2767 Use In tmpCurs
2768 Endif
2769 Select (lnSelect)
2770 Return
2771 Endif
2772
2773 Select tmpCurs
2774 *
2775 * Make it a loop for safety
2776 *
2777 Scan
2778 *** .LogEntry("Original Style " + style)
2779 lcStyle = .GetBCStyle(lcRBADivision,Style)
2780 *** .LogEntry("Resolved Style " + lcStyle)
2781 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
2782 Replace Style With lcStyle , size_bk With lnSize_BK
2783 Endscan
2784 .LogEntry("Resolved Styles/Size_BK")
2785
2786 *- 12/12/06 YIK
2787 *- Index just in case somebody changes the SELECT above
2788 Select tmpCurs
2789 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
2790 TAG sku
2791
2792 .LogEntry("Load Customer Style.")
2793
2794 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2795 If Used("tmpCurs")
2796 Use In tmpCurs
2797 Endif
2798 Select (lnSelect)
2799 Return
2800 Endif
2801
2802 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2803 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2804 lnCount = lnCount - 1
2805 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2806 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2807
2808 Select VZZXCSTHR
2809 Scatter Memvar Blank
2810 Select VZZXCSTDR
2811 Scatter Memvar Blank
2812
2813 m.Last_mod = Datetime()
2814 m.User_id = 'CGSADMIN'
2815 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2816 m.notes = ''
2817
2818 lcPrevSKU = ' '
2819 lcPrevSkuSize = ''
2820
2821 *- 12/12/06 YIK
2822 *- inserted details counter
2823 Local lnInsertCount
2824 lnInsertCount = 0
2825
2826 Select tmpCurs
2827
2828 Scan
2829 .LogEntry("Loading Customer Style...")
2830 .LogEntry("Style :" + Style )
2831 .LogEntry("Color_code :" + color_code )
2832
2833 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
2834 .LogEntry("Invalid Style or Color_code or Size_bk " )
2835 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
2836 FOR pkey = dtlpkey In (pceipoTD)
2837 Loop
2838 Endif
2839
2840 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2841 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
2842 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2843 If lcPrevSKU # lcSku
2844 lcPrevSKU = lcSku
2845 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
2846 .LogEntry("Customer :" + m.customer )
2847 .LogEntry("Division : " + m.division)
2848 .LogEntry("Style :" + Style )
2849 .LogEntry("Color_code :" + m.color_code )
2850 .LogEntry("Label code :" + m.lbl_code )
2851 .LogEntry("dimension : " + m.dimension)
2852 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
2853 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2854 If Empty(lnHDRpKey)
2855 lnHDRpKey = lnCstHrPkey
2856 .LogEntry("Inserting into header..")
2857 Insert Into VZZXCSTHR From Memvar
2858 Replace pkey With lnHDRpKey In VZZXCSTHR
2859 Endif
2860 Endif
2861 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
2862 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
2863 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
2864 If Empty(lnDtlKey)
2865 lnDtlpKey = lnCstDrPkey
2866 .LogEntry("Inserting into detail..")
2867 Insert Into VZZXCSTDR From Memvar
2868 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
2869 *- 12/12/06 YIK
2870 lnInsertCount = lnInsertCount + 1
2871 Endif
2872 Endif
2873 lnCstDrPkey = lnCstDrPkey +1
2874 lnCstHrPkey = lnCstHrPkey +1
2875
2876 Endscan
2877
2878 Dimension laTables[2]
2879 laTables[1]= "VZZXCSTHR"
2880 laTables[2]= "VZZXCSTDR"
2881
2882 llBeganTransaction = .BeginTransaction()
2883 llRetVal = .Tableupdate(@laTables)
2884
2885 If llRetVal
2886 If llBeganTransaction
2887 This.EndTransaction()
2888 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
2889 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
2890 Endif
2891 Else
2892 If llBeganTransaction
2893 This.RollbackTransaction()
2894 .LogEntry("Table Update failed - Roll back Transaction " )
2895 Endif
2896 Endif
2897
2898 Endwith
2899
2900 If Used("tmpCurs")
2901 Use In tmpCurs
2902 Endif
2903
2904 Select (lnSelect)
2905 Return llRetVal
2906 Endfunc
2907
2908 *-----------------------------------------------------------------------------------
2909
2910 Function GetBCStyle
2911 Lparameters tcDivision, tcUDFStyle
2912 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
2913
2914 llRetVal = True
2915 lnSelect = Select()
2916 l_vRetVal = ''
2917
2918 lcCursor = GetUniqueFileName()
2919 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
2920 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
2921
2922 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
2923
2924 If llRetVal
2925 Select(lcCursor)
2926 l_vRetVal = Alltrim(Style)
2927 Use In (lcCursor)
2928 Endif
2929
2930 Select (lnSelect)
2931 Return l_vRetVal
2932 Endfunc
2933
2934 *-----------------------------------------------------------------------------------
2935
2936 Function GetSizeBkt
2937 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
2938 p_cKeyField4, p_cKeyField5, p_cKeyField6
2939 Local l_cSQLString, l_vRetVal
2940
2941 l_nOldSele = Select()
2942 pnSizeBucket = 0
2943
2944 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
2945 l_vRetVal = 0
2946 Return l_vRetVal
2947 Endif
2948
2949 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
2950 p_cKeyField2)
2951 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
2952 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
2953 p_cKeyField3, p_cKeyField4, p_cKeyField5)
2954 Select TmpSavlr
2955 For l_n=1 To 24
2956 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
2957 If l_lAlwSz
2958 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
2959 If l_cSize_Desc = p_cKeyField6
2960 ***l_vRetVal = .T.
2961 pnSizeBucket = l_n
2962 Endif
2963 Endif
2964 Endfor
2965 Use In TmpSavlr
2966 Use In TmpSizer
2967 Endif
2968 Endif
2969
2970 l_vRetVal = pnSizeBucket
2971
2972 Select (l_nOldSele)
2973 Return l_vRetVal
2974
2975 Endfunc
2976
2977 *-----------------------------------------------------------------------------------
2978 * Validate SKU for all details
2979 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
2980
2981 Procedure CheckSku
2982 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
2983 Lparameters pceipoTH, pceipoTD,;
2984 pceipoTS, pceipoCR
2985 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
2986 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
2987 lnSize_desc, llSLN
2988
2989 *--- TR 1013117 NH
2990 Local lcSku_resolv
2991 Dimension lasku_resolv[1]
2992 lcSku_resolv = ""
2993 lasku_resolv[1] = ""
2994 *=== TR 1013117 NH
2995
2996 * --- TR 1045305 2/3/10 CM
2997 LOCAL lnSkuPkey
2998 lnSkuPkey = 0
2999 * === TR 1045305 2/3/10 CM
3000
3001
3002 llRetVal = .T.
3003 lcErrs_Msg= ""
3004 lnOldSelect = Select()
3005
3006 * cannot check for SKU if customer is empty
3007 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
3008 * on Cust SKU or UPC.
3009 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
3010
3011 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
3012 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
3013 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
3014
3015 *--- TechRec 1005163 17-May-2004 GS ---
3016 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
3017 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
3018 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
3019 *Order by h.customer, d.sku Into Cursor tmpCurs
3020
3021 *---- TR 1024667 NSD 5/31/07
3022 * If sizebucket = 0 then re-resolve.
3023
3024 If This.oHostProcess.lHaveSLN
3025 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3026 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3027 *!* SELECT h.customer,;
3028 *!* c.sku_resolv, ;
3029 *!* JOIN (pceipoCR) C;
3030 *!* ON d.division= C.division ;
3031 *!* AND h.customer= C.customer ;
3032
3033 *!* c.sku_resolv, ; && after union
3034 *!* JOIN (pceipoCR) C;
3035 *!* ON d.division= C.division ;
3036 *!* AND h.customer= C.customer ;
3037
3038 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3039 Select h.customer,;
3040 h.department, ;
3041 h.Store, ;
3042 d.sku,;
3043 d.upc, ;
3044 d.pkey, ;
3045 (pceipoTD) As Src ;
3046 FROM (pceipoTD) d ;
3047 JOIN (pceipoTH) h ;
3048 ON h.pkey = d.fkey ;
3049 WHERE !Empty(h.customer) ;
3050 AND !Empty(d.sku) ;
3051 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
3052 UNION All ;
3053 SELECT h.customer,;
3054 h.department, ;
3055 h.Store, ;
3056 s.SLN_SKU As sku,;
3057 s.SLN_UPC As upc,;
3058 s.pkey, ;
3059 (pceipoTS) As Src ;
3060 FROM (pceipoTS) s ;
3061 JOIN (pceipoTD) d ;
3062 ON d.pkey = s.fkey ;
3063 JOIN (pceipoTH) h ;
3064 ON h.pkey = d.fkey ;
3065 WHERE !Empty(h.customer) ;
3066 AND !Empty(s.SLN_SKU) ;
3067 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
3068 ORDER By 1, 2 ;
3069 INTO Cursor tmpCurs
3070 *=== TR 1010097 07/27/05 TK
3071 Else
3072 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3073 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3074 *!* SELECT h.customer,;
3075 *!* c.sku_resolv, ;
3076 *!* JOIN (pceipoCR) C;
3077 *!* ON d.division= C.division ;
3078 *!* AND h.customer= C.customer ;
3079 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3080 Select h.customer,;
3081 h.department, ;
3082 h.Store, ;
3083 d.sku,;
3084 d.upc, ;
3085 d.pkey, ;
3086 (pceipoTD) As Src ;
3087 FROM (pceipoTD) d ;
3088 JOIN (pceipoTH) h ;
3089 ON h.pkey = d.fkey ;
3090 WHERE !Empty(h.customer) ;
3091 AND !Empty(d.sku) ;
3092 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3093 Order By h.customer, d.sku ;
3094 INTO Cursor tmpCurs
3095 *=== TR 1010097 07/27/05 TK
3096 Endif
3097 *=== TechRec 1005163 17-May-2004 GS ===
3098
3099*- 1040686
3100 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3101 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3102 IF llRetVal
3103 .PopulateSQLTempTable("tcDistCustSku")
3104 ENDIF
3105 llRetVal = llRetVal AND v_sqlexec(;
3106 "SELECT x.sku,d.* "+;
3107 " FROM zzxcstdr d"+ ;
3108 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3109 " JOIN " + this.cSQLTempTable + " x " + ;
3110 " ON d.customer = x.customer " +;
3111 " AND d.cust_style = x.sku " + ;
3112 " WHERE h.IB_resolv = 'Y'" + ;
3113 " AND d.Size_Desc>'' " + ;
3114 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3115 SELECT tmpCstdr_sku
3116 INDEX ON customer + cust_style TAG cust_sku
3117
3118 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3119 UNION ;
3120 SELECT customer,sku FROM tmpCstdr_sku ;
3121 GROUP BY customer,sku ;
3122 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3123 INDEX ON customer+sku TAG cust_sku
3124 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3125*- 1040686
3126
3127
3128 lcOldCust = ""
3129 lcOldItem = ""
3130 lcOldSku_resolv = ""
3131 Select tmpCurs
3132 If This.lUserInterface
3133 * Init Thermometer
3134 This.UpdateThermoCaption("Validating SKU(s)...")
3135 * TAN 31891 - JAZ - 5/20/02
3136 * This.InitThermo(RECC('tmpCurs'))
3137 This.InitThermo(RecCount('tmpCurs'))
3138 * End TAN 31891 - JAZ - 5/20/02
3139 l_nThermoCnt = 0
3140 Endif
3141 SCAN
3142 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3143 *-- Skip sku resolution
3144 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3145 LOOP
3146 ENDIF
3147 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3148
3149 If This.lUserInterface
3150 * Advance progress bar, if we're using one.
3151 l_nThermoCnt = l_nThermoCnt + 1
3152 This.AdvanceThermo(l_nThermoCnt)
3153 Endif
3154
3155 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3156 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3157 *--- TR 1013117 NH 20050908
3158 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3159 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3160 *=== TR 1013117 NH 20050908
3161 *=== TR 1010097 07/27/05 TK
3162
3163 *---TR 1037976 JAN-07-08 BR
3164 IF !(tmpCurs.customer == lcOldCust)
3165 lcCustomer = tmpCurs.customer
3166 IF SEEK(lcCustomer,pceipocr,"customer")
3167 lcSku_resolv = &pceipocr..sku_resolv
3168 ENDIF
3169 ENDIF
3170 *===TR 1037976 JAN-07-08 BR
3171
3172 lcErrs_Msg = ""
3173 lcOldCust = tmpCurs.customer
3174 lcOldItem = tmpCurs.sku
3175 *--- TR 1013117 NH
3176 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3177 *=== TR 1013117 NH
3178
3179 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3180
3181
3182
3183 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3184 *--- TR 1013117 NH 20050908
3185 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3186 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3187
3188 *- 1040686 - COMMENT
3189*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3190*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3191*!* *=== TR 1013117 NH 20050908
3192*!* *--- TR 1010097 07/27/05 TK
3193
3194*!* lcDivision = tmpCstdr.division
3195*!* lcStyle = tmpCstdr.Style
3196*!* lcColor_code = tmpCstdr.color_code
3197*!* lcLbl_code = tmpCstdr.lbl_code
3198*!* lcDimension = tmpCstdr.Dimension
3199*!* lnSizeBucket = tmpCstdr.size_bk
3200*!* lnSize_desc = tmpCstdr.size_desc
3201*!*
3202*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3203*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3204*!* If tmpCstdr.fkey > 0
3205*!* lnSkuPkey = tmpCstdr.fkey
3206*!* Endif
3207*!* * === TR 1045305 2/3/10 CM
3208*!*
3209*!*
3210*!* Else
3211*!* lcErrs_Msg = lcErrs_Msg + CRLF
3212*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3213*!* Store 0 To lnSizeBucket
3214*!* Endif
3215
3216 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3217 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3218 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3219 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3220 Store 0 To lnSizeBucket
3221 ELSE
3222 *- TR 1074276 FH - adding UPPER()
3223 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3224 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3225 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3226 Store 0 To lnSizeBucket
3227 ELSE
3228 lcDivision = tmpCstdr_sku.division
3229 lcStyle = tmpCstdr_sku.Style
3230 lcColor_code = tmpCstdr_sku.color_code
3231 lcLbl_code = tmpCstdr_sku.lbl_code
3232 lcDimension = tmpCstdr_sku.Dimension
3233 lnSizeBucket = tmpCstdr_sku.size_bk
3234 lnSize_desc = tmpCstdr_sku.size_desc
3235
3236 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3237 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3238 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3239 If tmpCstdr_sku.fkey > 0
3240 lnSkuPkey = tmpCstdr_sku.fkey
3241 Endif
3242 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3243 *!* * === TR 1045305 2/3/10 CM
3244
3245 ENDIF
3246 ENDIF
3247*- 1040686 - COMMENT
3248
3249 Endif && level break
3250
3251 *--- TechRec 1005163 17-May-2004 GS ---
3252 *Select (pceipoTD)
3253 llSLN = (tmpCurs.Src = pceipoTS)
3254 If llSLN
3255 Select (pceipoTS)
3256 Else
3257 Select (pceipoTD)
3258 Endif
3259 *!* Locate For pkey = tmpCurs.pkey
3260 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3261 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3262 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3263 *=== TechRec 1005163 17-May-2004 GS ===
3264 Scatter Name loEiPOtd Memo
3265 If !Empty(lcErrs_Msg)
3266 *--- TechRec 1005163 17-May-2004 GS ---
3267 If llSLN
3268 *- 1008827 04/22/05 YIK
3269 *- correct a typo
3270 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3271
3272 loEiPOtd.Errs_Flg_S = "Y"
3273 Else
3274 *=== TechRec 1005163 17-May-2004 GS ===
3275 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3276 loEiPOtd.Errs_Flg_D = "Y"
3277 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3278 Endif
3279 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3280 loEiPOtd.division = lcDivision
3281 loEiPOtd.Style = lcStyle
3282 loEiPOtd.color_code = lcColor_code
3283 loEiPOtd.lbl_code = lcLbl_code
3284 loEiPOtd.Dimension = lcDimension
3285 loEiPOtd.sizebucket = lnSizeBucket
3286 loEiPOtd.size_desc = lnSize_desc
3287
3288 * --- TR 1045305 2/3/10 CM
3289 loEiPOtd.sku_pkey = lnSkuPkey
3290 * === TR 1045305 2/3/10 CM
3291
3292 Endif
3293
3294 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3295 * only replace our SKU when no range style explosion happen
3296 *--- TechRec 1005163 17-May-2004 GS ---
3297 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3298 * Replace division With loEiPOtd.division, ;
3299 * style With loEiPOtd.style, ;
3300 * color_code With loEiPOtd.color_code, ;
3301 * lbl_code With loEiPOtd.lbl_code, ;
3302 * dimension With loEiPOtd.dimension, ;
3303 * sizebucket With loEiPOtd.sizebucket, ;
3304 * size_desc With loEiPOtd.size_desc, ;
3305 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3306 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3307 * In (pceipoTD)
3308 *- 1009508 3/16/05 YIK
3309 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3310 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3311 Gather Name loEiPOtd Memo
3312 *=== TechRec 1005163 17-May-2004 GS ===
3313 Endif
3314
3315 *=== TechRec 1005163 17-May-2004 GS ===
3316 Endif
3317 Endscan
3318 Use In tmpCurs
3319
3320 If This.lUserInterface
3321 * Reset Thermometer
3322 This.ResetThermo()
3323 Endif
3324
3325 If Used("tmpCstdr")
3326 Use In tmpCstdr
3327 ENDIF
3328
3329 *-1040686
3330 USE IN SELECT("tcDistCustSku")
3331 USE IN SELECT("tmpCstdr_sku")
3332 USE IN SELECT("tcAmbigSku")
3333 *-1040686
3334
3335 Select(lnOldSelect)
3336 Return llRetVal
3337 Endproc
3338
3339 *-----------------------------------------------------------------------------------
3340 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3341 PROCEDURE PopulateOrigLabel
3342 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3343 LOCAL llRetVal, lnOldSelect
3344 lnOldSelect = SELECT()
3345
3346 .PopRecordSet()
3347 SELECT (pceipoTD)
3348
3349 SELECT d.pkey ;
3350 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3351 WHERE c.accept_lbl = 'Y' and ;
3352 c.customer = h.customer and ;
3353 c.division = d.division and ;
3354 h.pkey = d.fkey and ;
3355 h.errs_flg_h <> 'Y' and ;
3356 d.errs_flg_d <> 'Y' ;
3357 ORDER BY d.pkey ;
3358 INTO CURSOR 'cursTmpTD'
3359
3360 Index On pkey Tag pkey
3361
3362 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3363
3364 goto top in "cursTmpTD"
3365
3366 If llRetVal AND !EOF('cursTmpTD')
3367 SELECT (pceipoTD)
3368 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3369 In (pceipoTD)
3370 Endif
3371
3372 .PushRecordSet()
3373
3374 Set Relation to
3375 USE IN 'cursTmpTD'
3376 SELECT (lnOldSelect)
3377 RETURN llRetVal
3378 ENDPROC
3379 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3380 *-----------------------------------------------------------------------------------
3381
3382 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3383 Procedure ConfirmUPC
3384 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3385
3386 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3387 lcUPC, lcErrs_Msg, llSLN
3388
3389 llRetVal = .T.
3390 lcErrs_Msg= ""
3391 lnOldSelect = Select()
3392
3393 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3394
3395 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3396
3397 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3398 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3399 from (pceipoTD) Into Cursor __eipoTD
3400
3401 If This.oHostProcess.lHaveSLN
3402 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3403 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3404 Endif
3405
3406 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3407 Select(lnOldSelect)
3408 Return llRetVal
3409 Endif
3410
3411 With This
3412 .cSQLTempTable = ""
3413 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3414 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3415 lceipoTD_tmp = .cSQLTempTable
3416 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3417
3418 If This.oHostProcess.lHaveSLN
3419 .cSQLTempTable = ""
3420 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3421 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3422 lceipoTS_tmp = .cSQLTempTable
3423 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3424 Endif
3425 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3426 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3427 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3428 Endwith
3429
3430
3431 This.MakeCursorWritable("tmpCursR","tmpCurs")
3432
3433 Select tmpCurs
3434 If This.lUserInterface
3435 * Init Thermometer
3436 This.UpdateThermoCaption("Comparing UPC(s)...")
3437 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3438 l_nThermoCnt = 0
3439 Endif
3440
3441
3442*- 1040686
3443 *=-=-=-=-=-=-=-=-=-=
3444 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3445 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3446 IF llRetVal
3447 .PopulateSQLTempTable("tcDistUpc")
3448 ENDIF
3449 llRetVal = llRetVal AND v_sqlexec(;
3450 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3451 " FROM zveupcnr d"+ ;
3452 " JOIN " + this.cSQLTempTable + " x " + ;
3453 " ON d.division = x.division " + ;
3454 " AND d.style = x.style " + ;
3455 " AND d.color_code = x.roll_color " + ;
3456 " AND d.lbl_code = x.lbl_code " + ;
3457 " AND d.dimension = x.dimension " + ;
3458 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3459 SELECT tmpCstdr
3460 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3461 *=-=-=-=-=-=-=-=-=-=
3462 SELECT tmpCurs
3463
3464*- 1040686
3465 Local lnSizeBk
3466 lnSizeBk = 0
3467 Scan
3468 If This.lUserInterface
3469 * Advance progress bar, if we're using one.
3470 l_nThermoCnt = l_nThermoCnt + 1
3471 This.AdvanceThermo(l_nThermoCnt)
3472 Endif
3473
3474 lcErrs_Msg = ""
3475
3476 *- 1040686
3477 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3478 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3479 DIMENSION, sizebucket, "tmpCstdr")
3480 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3481 DIMENSION, sizebucket, "tmpCstdr")
3482
3483 lcUPC = ""
3484 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3485 lcErrs_Msg = "Missing UPC number."
3486 ELSE
3487 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3488 ENDIF
3489
3490 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3491 *-1040686
3492
3493 If !(lcUPC == tmpCurs.UPC)
3494 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3495 Endif
3496
3497 If !Empty(lcErrs_Msg)
3498 llSLN = (tmpCurs.Src = pceipoTS)
3499 If llSLN
3500 Select (pceipoTS)
3501 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3502 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3503 Replace ;
3504 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3505 Errs_Flg_S With "Y"
3506 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3507 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3508 Errs_Flg_D With 'Y' In (pceipoTD)
3509 Endif
3510 ENDIF &&--- TR 1035223 NH
3511 Else
3512 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3513 Select (pceipoTD)
3514 Replace ;
3515 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3516 Errs_Flg_D With "Y"
3517 Endif
3518 Endif
3519 Endscan
3520
3521 Use In tmpCurs
3522
3523 If This.lUserInterface
3524 * Reset Thermometer
3525 This.ResetThermo()
3526 Endif
3527
3528 If Used("tmpCstdr")
3529 Use In tmpCstdr
3530 ENDIF
3531
3532 USE IN SELECT("tcDistUpc") &&1040686
3533
3534 Select(lnOldSelect)
3535 Return llRetVal
3536 ENDPROC
3537
3538 *-----------------------------------------------------------------------------------
3539
3540 Procedure GetConfrimUPCSql
3541 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3542 Local lcSql, lcSqlSln, lnOldSelect
3543 lnOldSelect = Select()
3544
3545 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3546 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3547 * this is a straight join and not a date resolution.
3548 lcSql = ;
3549 "select d.customer"+;
3550 " , d.division"+;
3551 " , d.sku"+;
3552 " , d.STYLE"+;
3553 " , d.color_code"+;
3554 " , case"+;
3555 " when r.rng_style is null"+;
3556 " and d.lbl_code = ''"+;
3557 " and c.resv_label = 'Y' then c.lbl_code"+;
3558 " when r.rng_style is null"+;
3559 " and d.lbl_code = ''"+;
3560 " and c.resv_label = 'V'"+;
3561 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3562 " else d.lbl_code"+;
3563 " end as lbl_code"+;
3564 " , d.lbl_code as lbl_codeOrig"+;
3565 " , c.resv_label"+;
3566 " , d.DIMENSION"+;
3567 " , d.Sizebucket"+;
3568 " , d.upc"+;
3569 " , d.pkey"+;
3570 " , C.Confirm_UPC"+;
3571 " , d.size_desc"+;
3572 " , '" + Trim(pceipoTD) + "' as Src"+;
3573 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3574 " from " + pceipoTD_tmp + " d"+;
3575 " join zzeipocr C"+;
3576 " on d.customer = C.customer"+;
3577 " and d.division = C.division"+;
3578 " left join zzxrangh r"+;
3579 " on r.division = d.division"+;
3580 " and r.rng_style = d.style"+;
3581 " and r.rng_color = d.color_code"+;
3582 " and r.rng_lbl = d.lbl_code"+;
3583 " and r.rng_pack = d.dimension"+;
3584 " left join zzxscolr sc"+;
3585 " on sc.division = d.division"+;
3586 " and sc.style = d.style"+;
3587 " and sc.color_code = d.color_code"+;
3588 " and sc.lbl_code = c.lbl_code"+;
3589 " and sc.dimension = d.dimension"+;
3590 " left join zzxrupcd rc " + ;
3591 " on rc.division = d.division"+;
3592 " and rc.style = d.style"+;
3593 " and rc.new_color = d.color_code"+;
3594 " and rc.lbl_code = d.lbl_code"+;
3595 " and rc.dimension = d.dimension"+;
3596 " where d.customer > ''"+;
3597 " and d.SKU > ''"+;
3598 " and (d.UPC > '' or d.EAN > '' )"+;
3599 " and d.Division > ''"+;
3600 " and d.Style > ''"+;
3601 " and d.Color_Code > ''"+;
3602 " and C.Confirm_UPC = 'Y' "+;
3603 " and d.Rng_Style = '' "
3604
3605 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3606 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3607 *--- Used sc.Division instead of c.Division.
3608 lcSqlSln = ;
3609 "select d.Customer"+;
3610 " , d.Division"+;
3611 " , s.SLN_SKU as sku"+;
3612 " , s.STYLE"+;
3613 " , s.Color_Code"+;
3614 " , case when s.Lbl_Code = ''"+;
3615 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3616 " when s.Lbl_Code = ''"+;
3617 " and c.Resv_Label = 'V'"+;
3618 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3619 " else s.lbl_code"+;
3620 " end as lbl_code"+;
3621 " , s.lbl_code as lbl_codeOrig"+;
3622 " , c.resv_label"+;
3623 " , s.DIMENSION"+;
3624 " , s.Sizebucket"+;
3625 " , s.SLN_UPC as upc"+;
3626 " , s.pkey"+;
3627 " , C.Confirm_UPC"+;
3628 " , s.size_desc"+;
3629 " , '" + Trim(pceipoTS) + "' as Src"+;
3630 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3631 " from " + pceipoTD_tmp + " d"+;
3632 " join " + pceipoTS_tmp + " s"+;
3633 " on s.fkey = d.pkey"+;
3634 " join zzeipocr C"+;
3635 " on d.customer = C.customer"+;
3636 " and d.division = C.division"+;
3637 " left join zzxscolr sc"+;
3638 " on sc.division = d.division"+;
3639 " and sc.style = s.style"+;
3640 " and sc.color_code = s.color_code"+;
3641 " and sc.lbl_code = c.lbl_code"+;
3642 " and sc.dimension = s.dimension"+;
3643 " left join zzxrupcd rc " + ;
3644 " on rc.division = d.division"+;
3645 " and rc.style = s.style"+;
3646 " and rc.new_color = s.color_code"+;
3647 " and rc.lbl_code = c.lbl_code"+;
3648 " and rc.dimension = s.dimension"+;
3649 " where d.Customer > ''"+;
3650 " and s.SLN_SKU > ''"+;
3651 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3652 " and d.Division > ''"+;
3653 " and s.Style > ''"+;
3654 " and s.Color_Code > ''"+;
3655 " and c.Confirm_UPC = 'Y'"+;
3656 " and d.Rng_Style > ''"
3657 Endif
3658
3659 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3660 Select(lnOldSelect)
3661 Return lcSql
3662 Endproc
3663 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3664
3665 *-----------------------------------------------------------------------------------
3666
3667 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3668 PROCEDURE MarkHeaderwithDetailOrSLNInError
3669 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3670 * This is customized method from clsEDI
3671
3672 LOCAL llRetVal, lnOldSelect
3673 LOCAL lnBadOrderCount
3674 llRetVal = .T.
3675 lnOldSelect = SELECT()
3676
3677 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3678 pcEW = "E"
3679 ENDIF
3680 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3681 LOCAL lcErrorMsg, lcErrorMsgSLN
3682 lnBadOrderCount = 0
3683 IF pcEW = 'W'
3684 lcErrorMsg = "Has Warnings in Details."
3685 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3686 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3687 ELSE
3688 lcErrorMsg = "Has Errors in Details."
3689 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3690 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3691
3692 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3693 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3694 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3695 ENDIF
3696
3697 SELECT tcBadOrders
3698 IF THIS.lUserInterface
3699 * Init Thermometer
3700 THIS.InitThermo(lnBadOrderCount)
3701 l_nThermoCnt = 0
3702 ENDIF
3703 SCAN
3704 IF THIS.lUserInterface
3705 * Advance progress bar, if we're using one.
3706 l_nThermoCnt = l_nThermoCnt + 1
3707 THIS.AdvanceThermo(l_nThermoCnt)
3708 ENDIF
3709 SELECT (pceipoTH)
3710 IF pcEW = 'W'
3711 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3712 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3713 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3714 IN (pceipoTH)
3715 ENDIF
3716 ENDIF
3717 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3718 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3719 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3720 IN (pceipoTH)
3721 ENDIF
3722 ENDIF
3723 ELSE
3724 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3725 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3726
3727 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3728 IN (pceipoTH)
3729 ENDIF
3730 ENDIF
3731 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3732 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3733
3734 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3735 IN (pceipoTH)
3736 ENDIF
3737 ENDIF
3738 ENDIF
3739 ENDSCAN
3740 USE IN tcBadOrders
3741 USE IN tcBadOrdersSLN
3742
3743 IF THIS.lUserInterface
3744 THIS.ResetThermo()
3745 ENDIF
3746 SELECT(lnOldSelect)
3747 RETURN llRetVal
3748 ENDPROC
3749 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3750
3751 *-----------------------------------------------------------------------------------
3752
3753 *--- TR 1013007 NH
3754 *--- checks if pceipoTH.req_855 is 'R'
3755 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
3756 *--- if default status value is not empty then set Send855 flag to true and return true
3757 *--- if default status value is empty then set Send855 flag to true and return false and
3758 *--- set error message 'Missing 855 status code'
3759 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
3760 *--- then set Send855 flag to true and return false and
3761 *--- set error message 'Missing 855 status code'
3762
3763 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
3764 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
3765 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
3766 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
3767 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
3768
3769
3770 Procedure Check855Required
3771 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
3772
3773 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
3774 llRetVal = .T.
3775 lnOldSelect = Select()
3776 lcOldPO_num = ""
3777 lcPO_Status_855 = ""
3778 This.LogEntry("Starting procedure" + Program())
3779 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
3780
3781 *--- prepare detail zzeipotd for cascading status_855 code
3782 Select(pceipoTD)
3783 lnOldOrder_TD = Val(Sys(21)) && getting the current order
3784 Set Order To Tagno('FKEY') && settting order by 'fkey'
3785
3786 Select(pceipoTH)
3787 Scan For req_855 = 'R'
3788 Scatter Name loEiPOth Memo
3789 *--- when this.lSend855 flag is true then data will be sent to server
3790 This.lSend855 = .T.
3791
3792 *--- TR 1040432 MAY-20-2009 BR
3793 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
3794 If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
3795 *=== TR 1040432 MAY-20-2009 BR
3796 Select(pceipoCR)
3797 If Auto_855 = 'Y'
3798 If Not Empty(def_855)
3799 *--- set default value
3800 loEiPOth.status_855 = def_855
3801 *--- TR 1080293 KISHORE 26-AUG-2014
3802 IF NOT EMPTY(def_855dtl)
3803 lcDetail855Code = EVALUATE(pceipoCR + ".def_855dtl")
3804 REPLACE ALL status_855 WITH lcDetail855Code ;
3805 IN (pceipoTD) ;
3806 FOR fkey = loeipoTH.pkey AND EMPTY(EVALUATE(pceipoTD + ".status_855"))
3807 ELSE
3808 *=== TR 1080293 KISHORE 26-AUG-2014
3809 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
3810 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
3811*!* llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
3812 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
3813 ENDIF && TR 1080293 KISHORE 26-AUG-2014
3814 Else
3815 loEiPOth.Errs_flg_h = 'Y'
3816 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
3817 Endif
3818 Endif
3819 Endif
3820
3821 *--- status_855 code is still empty
3822 If Empty(loEiPOth.status_855)
3823 loEiPOth.Errs_flg_h = 'Y'
3824 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
3825 Endif
3826
3827 *--- check if defferent status_855 code exists in orders with same po number
3828 If lcOldPO_num <> loEiPOth.po_num
3829 lcOldPO_num = loEiPOth.po_num
3830 lcPO_Status_855 = loEiPOth.status_855
3831 Else
3832 If lcPO_Status_855 <> loEiPOth.status_855
3833 loEiPOth.Errs_flg_h = 'Y'
3834 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
3835 Endif
3836 Endif
3837
3838 *--- all records will only be get updated. No insert is need here.
3839 Select(pceipoTH)
3840 Gather Name loEiPOth Memo
3841
3842 If Not llRetVal
3843 Exit
3844 Endif
3845 Endscan
3846 *--- set back to old order by
3847 Select(pceipoTD)
3848 Set Order To (lnOldOrder_TD)
3849 *-- when one order is flaged error then all order of PO will be make
3850 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
3851 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
3852 Select(lnOldSelect)
3853 Return llRetVal
3854
3855 ENDPROC
3856
3857 *-----------------------------------------------------------------------------------
3858
3859 *--- must set order by 'FKey' in pceipoTD
3860 Procedure Cascade855AckCode
3861 Lparameters poeipoTH, pceipoTD
3862
3863 Local llRetVal, lnOldSelect
3864 lnOldSelect = Select()
3865 llRetVal = .T.
3866
3867 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
3868 Return .F.
3869 Endif
3870 *- 1034481 10/06/08 YIK
3871 *- Cascade ALL status codes to details.
3872 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
3873 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
3874 Select(pceipoTD)
3875 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
3876 Scan While fkey = poeipoTH.pkey
3877 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
3878 Endscan
3879 ENDIF
3880 *- 1034481
3881 *- Endif
3882
3883 Select(lnOldSelect)
3884 Return llRetVal
3885 Endproc
3886
3887 *----------------------------------------------------------------------------------------
3888 *--- TR 1034481 NH
3889 PROCEDURE MarkHeaderForMissing855ControlRef
3890 LPARAMETERS pceipoTH
3891
3892 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
3893
3894 llRetVal = .t.
3895 lnOldSelect = SELECT()
3896 lcZzeoprcr = "Oprcr" + SYS(2015)
3897 lcZzxlookp = "LOOKP" + SYS(2015) && TR 1083402 20-Jan-2015 Partha
3898
3899 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
3900ASSERT .f.
3901 *--- TR 1083402 20-Jan-2015 Partha ---
3902*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
3903
3904 llRetVal = llRetVal and v_sqlexec("select customer, division, ack29_req from zzeoprcr", lcZzeoprcr)
3905 llRetVal = llRetVal and v_sqlexec("SELECT p.lk_code FROM zzxlookp p WHERE p.Lk_Type ='ACK29 Codes' ", lcZzxlookp)
3906 *=== TR 1083402 20-Jan-2015 Partha ===
3907
3908 IF USED(lcZzeoprcr)
3909
3910 SELECT (lcZzeoprcr) && TR 1083402 20-Jan-2015 Partha
3911
3912 INDEX on customer TAG customer
3913 INDEX on division TAG division
3914
3915 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
3916 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
3917 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
3918
3919 *--- TR 1083402 20-Jan-2015 Partha ---
3920 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Valid ACK29 Code required.' + CRLF ;
3921 from (pceipoTH) th ;
3922 JOIN (pceipoTD) td ON th.pkey=td.fkey ;
3923 WHERE th.req_855 ='R' ;
3924 AND EXISTS ( select c.customer from (lcZzeoprcr) c ;
3925 WHERE c.customer = th.customer AND c.division = th.division AND c.ack29_req='Y') ;
3926 AND ( EMPTY(td.ack29) ;
3927 OR NOT EXISTS (SELECT 1 FROM (lcZzxlookp) p WHERE p.LK_CODE = td.ack29 ))
3928 *=== TR 1083402 20-Jan-2015 Partha ===
3929
3930 USE IN (lcZzeoprcr)
3931 USE IN (lcZzxlookp) && TR 1083402 20-Jan-2015 Partha
3932 ENDIF
3933
3934 SELECT(lnOldSelect)
3935 RETURN llRetVal
3936
3937 ENDPROC
3938 *=== TR 1034481 NH
3939 *----------------------------------------------------------------------------------------
3940
3941 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
3942
3943 Local laTables[4]
3944 laTables[1] = "VzzeiPOth_iPOproc"
3945 laTables[2] = "VzzeiPOtd_iPOproc"
3946 laTables[3] = "VzzeiPOts_iPOproc"
3947 * --- TR 1018184 RLN 1018184
3948 laTables[4] = "VzzeiPOtsac_iPOproc"
3949
3950 Local llRetVal, llBeganTransaction, loEiPOth
3951 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
3952 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
3953
3954 llRetVal = .T.
3955
3956 With This
3957 .LogEntry("Starting Program : " + Program())
3958 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
3959
3960 Select(pceipoTH)
3961 Scan
3962 Scatter Name loEiPOth Memo
3963 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
3964 Select('VzzeiPOth_iPOproc')
3965 Gather Name loEiPOth Memo
3966 Endif
3967 Endscan
3968
3969 Select(pceipoTD)
3970 Scan
3971 Scatter Name loEiPOtd Memo
3972 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
3973 Select('VzzeiPOtd_iPOproc')
3974 Gather Name loEiPOtd Memo
3975 Endif
3976 Endscan
3977
3978 Select(pceipoTS)
3979 Scan
3980 Scatter Name loeipoTS Memo
3981 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
3982 Select('VzzeiPOts_iPOproc')
3983 Gather Name loeipoTS Memo
3984 Endif
3985 Endscan
3986
3987 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
3988 If This.BeginTransaction()
3989 llRetVal = This.Tableupdate(@laTables)
3990 If llRetVal
3991 This.EndTransaction()
3992 Else
3993 This.RollbackTransaction()
3994 Endif
3995 Endif
3996 *--- close views.
3997 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
3998 Endwith
3999
4000 Return llRetVal
4001
4002 Endfunc
4003
4004 *----------------------------------------------------------------------------------------
4005
4006 Procedure Run855Process
4007 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4008 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
4009 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4010
4011 Local lnOldSelect, llRetVal, loStatusCur
4012 lnOldSelect = Select()
4013 llRetVal = .T.
4014 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4015 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4016 Local lcStatusCur, loStatus
4017 lcStatusCur = Sys(2015)
4018 With This
4019
4020 *--- TR 1044017 07-JAN-2010 HNISAR
4021*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
4022 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
4023 *=== TR 1044017 07-JAN-2010 HNISAR
4024
4025 .LogEntry("Starting program " + Program())
4026
4027 * --- TR 1048571 9/9/10 CM
4028 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
4029 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
4030 * === TR 1048571 9/9/10 CM
4031
4032 If llRetVal
4033 Select (lcStatusCur )
4034 Scatter Name loStatus
4035 Use In (lcStatusCur)
4036 ENDIF
4037 *- 1034481 10/03/08 YIK
4038 *- Check if there are no 855(o) to process
4039 llHas855ToSend = .T.
4040
4041 *--- req_855 must be more the status missing count
4042 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
4043 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
4044 *-- move 850 data to 855 transaction
4045 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
4046
4047 *- 1034481 10/03/08 YIK
4048 *- Added parameter pceipoTH and llHas855ToSend
4049 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4050 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
4051 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
4052
4053 *--- TR 1044017 07-JAN-2010 HNISAR
4054*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4055 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4056 *===TR 1044017 07-JAN-2010 HNISAR
4057
4058 *- 1034481 10/03/08 YIK
4059 *- Check if there are no 855(o) to process
4060 IF llHas855ToSend
4061 *-- create flat files
4062 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4063 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
4064 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
4065 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
4066
4067 *--- update 855 flag of 850 tran header
4068 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
4069
4070 *--- TR 1044017 07-JAN-2010 HNISAR
4071*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
4072 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
4073 *=== TR 1044017 07-JAN-2010 HNISAR
4074
4075 *--- drop temp tables
4076 *- 1030497 02/29/08 TT
4077 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
4078 *!* .dropTempTable(lceoprth,.T.)
4079 *!* .dropTempTable(lceoprtd,.T.)
4080 *!* .dropTempTable(lceoprtc,.T.)
4081 *!* .dropTempTable(lceoprta,.T.)
4082 *!* .dropTempTable(lceoprth_notes,.T.)
4083 *!* .dropTempTable(lceoprtd_notes,.T.)
4084 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
4085 .oCopyUtil.dropTempTable(lceoprth,.T.)
4086 .oCopyUtil.dropTempTable(lceoprtd,.T.)
4087 .oCopyUtil.dropTempTable(lceoprtc,.T.)
4088 .oCopyUtil.dropTempTable(lceoprta,.T.)
4089 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
4090 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
4091
4092 *- 1034481 10/03/08 YIK
4093 ELSE
4094 .LogEntry("No 855(o) transaction data to send.")
4095 ENDIF
4096 *= 1034481 *- 1030497 02/29/08 TT
4097 Endif
4098
4099 *- 1034481 10/03/08 YIK
4100 *- Added ..AND loStatus.STATUS_855_MISSING > 0
4101 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
4102 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
4103 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
4104 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
4105 .oHostProcess.c855Msg
4106 Endif
4107 Release loStatus
4108 Endwith
4109
4110 Select(lnOldSelect)
4111 Return llRetVal
4112
4113 Endfunc
4114
4115 *----------------------------------------------------------------------------------------
4116
4117 Procedure get855Status
4118 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4119 Lparameters tcCursor, pceipoTH
4120
4121 * --- TR 1048571 9/9/10 CM
4122 *Local lcSQL, lnOldSelect,llRetVal
4123 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4124
4125 lceipoth = "#Ipoth" + SYS(2015)
4126 * === TR 1048571 9/9/10 CM
4127
4128 lnOldSelect = Select()
4129 llRetVal = .T.
4130
4131 * --- TR 1048571 9/9/10 CM
4132 With This
4133 .cSQLTempTable=""
4134 IF .GenerateSQLTempTable(pceipoTH)
4135 IF .PopulateSQLTempTable(pceipoTH)
4136 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4137 llRetVal = llRetVal And v_SqlExec(lcSQL)
4138 ENDIF
4139 ENDIF
4140 Endwith
4141 * === TR 1048571 9/9/10 CM
4142
4143 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4144 lcSQL = " select sum(1) rec_count, " + ;
4145 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4146 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4147 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4148 " from " + lceipoth + " h " + This.cFilterCriteria
4149
4150 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4151 Select(lnOldSelect)
4152 Return llRetVal
4153 Endproc
4154
4155 *----------------------------------------------------------------------------------------
4156
4157 Procedure MoveTo855TempTransaction
4158 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4159 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4160 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4161
4162 Local llRetVal, lnOldSelect
4163 lnOldSelect = Select()
4164 llRetVal = .T.
4165 With This
4166 *--- create temporary 855 transaction tables at server
4167 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4168 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4169
4170 *--- copy data from 850 trans table to 855 temp trans tables
4171 *- 1034481 10/03/08 YIK
4172 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4173 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4174 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4175
4176 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4177 IF plHas855ToSend
4178 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4179 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4180
4181 *--- update header division from detail
4182 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4183 ENDIF
4184 *= 1034481
4185 Endwith
4186
4187 Select(lnOldSelect)
4188 Return llRetVal
4189
4190 Endproc
4191
4192 *----------------------------------------------------------------------------------------
4193
4194 Procedure CreateOPRTempTables
4195 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4196
4197 Local llRetVal, lnOldSelect, lcUnique
4198 lnOldSelect = Select()
4199 llRetVal = .T.
4200 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4201 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4202 AND Vartype(pcRefeoprtd_notes) == "C" )
4203
4204 lcUnique = Sys(2015)
4205 With This
4206 .LogEntry("Starting " + Program())
4207 .LogEntry("Creating OPR Temp Tables.")
4208
4209 *--- zzeipoth
4210 pcRefeoprth = "#zzeoprth" + lcUnique
4211 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4212 llRetVal = llRetVal And v_SqlExec(lcSQL)
4213
4214 *--- TR 1044208
4215 .oHostProcess.AddToTempTables(pcRefeoprth)
4216 *=== TR 1044208
4217
4218 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4219 *--- zzeipotd
4220 pcRefeoprtd = "#zzeoprtd" + lcUnique
4221 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4222 llRetVal = llRetVal And v_SqlExec(lcSQL)
4223 *--- TR 1044208
4224 .oHostProcess.AddToTempTables(pcRefeoprtd)
4225 *=== TR 1044208
4226 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4227
4228 *--- zzeipotc
4229 pcRefeoprtc = "#zzeoprtc" + lcUnique
4230 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4231 llRetVal = llRetVal And v_SqlExec(lcSQL)
4232 *--- TR 1044208
4233 .oHostProcess.AddToTempTables(pcRefeoprtc )
4234 *=== TR 1044208
4235 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4236
4237 *--- zzeipota
4238 pcRefeoprta = "#zzeoprta" + lcUnique
4239 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4240 llRetVal = llRetVal And v_SqlExec(lcSQL)
4241 *--- TR 1044208
4242 .oHostProcess.AddToTempTables(pcRefeoprta )
4243 *=== TR 1044208
4244 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4245
4246 *---- sysnotes_oprth
4247 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4248 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4249 llRetVal = llRetVal And v_SqlExec(lcSQL)
4250 *--- TR 1044208
4251 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4252 *=== TR 1044208
4253 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4254
4255 *---- sysnotes_oprtd
4256 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4257 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4258 llRetVal = llRetVal And v_SqlExec(lcSQL)
4259 *--- TR 1044208
4260 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4261 *=== TR 1044208
4262 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4263
4264 Endwith
4265
4266 Select(lnOldSelect)
4267 Return llRetVal
4268
4269 Endproc
4270
4271 *----------------------------------------------------------------------------------------
4272
4273 Procedure IPODataToOPRTmpTable
4274 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4275 pceipoTD
4276 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4277 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4278 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4279
4280 lcOPR_TMP = ""
4281 lnOldSelect = Select()
4282 llRetVal = .T.
4283 lcCommonFields = ""
4284 lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4285 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4286 lcLeftOnlyDefaults = ""
4287 lcLeftOnlyFields = ""
4288 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4289
4290 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4291
4292 * --- TR 1048571 9/9/10 CM
4293 lcipotd = "#Zzeipotd" + SYS(2015)
4294 * === TR 1048571 9/9/10 CM
4295
4296 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4297
4298 With This
4299 *-- TR 1044604 DEC-29-2009 BR
4300 .cSQLTempTable=""
4301 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4302*!* IF .GenerateSQLTempTable(pceipoTH)
4303*!* IF .PopulateSQLTempTable(pceipoTH)
4304 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4305 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4306 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4307
4308 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4309 &lcCmnd
4310
4311*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4312 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4313 IF .GenerateSQLTempTable(lcTempIPOTH)
4314
4315 IF .PopulateSQLTempTable(lcTempIPOTH)
4316 Use In Select(lcTempIPOTH)
4317 *=== TR 1043191 23-Oct-2009 JK ===
4318 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4319 llRetVal = llRetVal And v_SqlExec(lcSQL)
4320 ENDIF
4321 ENDIF
4322 *== TR 1044604 DEC-29-2009 BR
4323
4324 * --- TR 1048571 9/9/10 CM
4325 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4326 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4327 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4328 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4329 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4330 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4331 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4332 *.ScatterGather(pceipoTD, "tcIpoDtls")
4333 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4334 .ScatterGather("__tceipoTD", "tcIpoDtls")
4335 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4336
4337 SELECT tcIpoDtls
4338 LOCATE
4339 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4340 .cSQLTempTable=""
4341 IF .GenerateSQLTempTable("tcFinalDtls")
4342 IF .PopulateSQLTempTable("tcFinalDtls")
4343 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4344 llRetVal = llRetVal And v_SqlExec(lcSQL)
4345 ENDIF
4346 ENDIF
4347 * === TR 1048571 9/9/10 CM
4348
4349 *--- IPOTH -> OPRTH
4350 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4351 *--- lcCalFldsOPR : fields need calculation or map or constant values
4352 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4353
4354 *--- for example if term_type field data will go to terms_type field and blank term_type
4355 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4356 *!* lcCalFldsOPR = "term_type, terms_type"
4357 *!* lcCalFldsOPR_val = "' ',term_type"
4358 lcCalFldsOPR_SQL = "'PROC_855'"
4359 lcCalFldsOPR = "PROC_855"
4360 lcCalFldsOPR_val = "' '"
4361 lcFlds = ""
4362 lcValues = ""
4363
4364 lcOPR_TMP = pceoprth
4365 *- 1030497 02/29/08 TT
4366 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4367 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4368
4369 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4370 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4371 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4372 *- 1030497 02/29/08 TT
4373 *--- 1034481 set correct flag value 'P' for Proc_855
4374 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4375 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4376 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4377 llRetVal = llRetVal And v_SqlExec(lcSQL)
4378
4379 *--- IPOTD -> OPRTD
4380 lcCalFldsOPR_SQL = ""
4381 lcCalFldsOPR = ""
4382 lcCalFldsOPR_val = ""
4383 lcFlds = ""
4384 lcValues = ""
4385
4386 lcOPR_TMP = pceoprtd
4387 *- 1030497 02/29/08 TT
4388 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4389 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4390 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4391 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4392 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4393 *- 1030497 02/29/08 TT
4394 *- 1034481 10/03/08 YIK
4395 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4396 DECLARE la855Cnt[1]
4397 la855Cnt[1] = 0
4398 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4399 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4400 " INTO ARRAY la855Cnt"
4401 &lcSQL
4402
4403 plHas855ToSend = (la855Cnt[1] > 0)
4404
4405 IF plHas855ToSend
4406 *--- 1034481 set correct flag value 'P' for Proc_855
4407 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4408 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4409 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4410 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4411 " ( select * from " + lcipoth + " h " + lcFilter + ;
4412 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4413
4414 llRetVal = llRetVal And v_SqlExec(lcSQL)
4415
4416 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4417 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4418 " on d.fkey = h.pkey "
4419 llRetVal = llRetVal And v_SqlExec(lcSQL)
4420
4421 *--- IPOTC -> OPRTC
4422 lcOPR_TMP = pceoprtc
4423 lcCalFldsOPR_SQL = ""
4424 lcCalFldsOPR = ""
4425 lcCalFldsOPR_val = ""
4426 lcFlds = ""
4427 lcValues = ""
4428
4429 *- 1030497 02/29/08 TT
4430 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4431 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4432 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4433 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4434 *- 1030497 02/29/08 TT
4435 *--- 1034481 set correct flag value 'P' for Proc_855
4436 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4437 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4438 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4439 " (select * from " + lcipoth + " h " + lcFilter + ;
4440 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4441
4442 llRetVal = llRetVal And v_SqlExec(lcSQL)
4443
4444 *--- IPOTA -> OPRTA
4445 lcOPR_TMP = pceoprta
4446 lcCalFldsOPR_SQL = ""
4447 lcCalFldsOPR = ""
4448 lcCalFldsOPR_val = ""
4449 lcFlds = ""
4450 lcValues = ""
4451
4452 *- 1030497 02/29/08 TT
4453 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4454 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4455 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4456 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4457 *- 1030497 02/29/08 TT
4458 *--- 1034481 set correct flag value 'P' for Proc_855
4459
4460 *--- 1042063 10/12/09 CM
4461 *--- We're unconditionally going to remove characters greater than 25,
4462 * for 855 address1,address2 fields since max field size is 25.
4463 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4464 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4465 *=== 1042063 10/12/09 CM
4466
4467 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4468 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4469 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4470 " (select * from " + lcipoth + " h " + lcFilter + ;
4471 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4472
4473 llRetVal = llRetVal And v_SqlExec(lcSQL)
4474
4475 *--- sysnotes - zzeoprth
4476 lcOPR_TMP = pceoprth_notes
4477 *--- 1034481 set correct flag value 'P' for Proc_855
4478 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4479 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4480 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4481 " (select * from " + lcipoth + " h " + lcFilter + ;
4482 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4483
4484 llRetVal = llRetVal And v_SqlExec(lcSQL)
4485
4486 *--- sysnotes - zzeoprtd
4487 lcOPR_TMP = pceoprtd_notes
4488 *--- 1034481 set correct flag value 'P' for Proc_855
4489 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4490 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4491 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4492 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4493 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4494 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4495 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4496
4497 llRetVal = llRetVal And v_SqlExec(lcSQL)
4498 *- 1034481 10/03/08 YIK
4499 ENDIF &&plHas855ToSend
4500
4501 *-- TR 1044604 DEC-29-2009 BR
4502 lcSQL = "DROP TABLE " + lcipoth
4503 v_SqlExec(lcSQL)
4504 *== TR 1044604 DEC-29-2009 BR
4505 Endwith
4506
4507 * --- TR 1048571 9/9/10 CM
4508 USE IN SELECT("tcIpoDtls")
4509 USE IN SELECT("tcFinalDtls")
4510 USE IN SELECT("tcTmpDtls")
4511 * === TR 1048571 9/9/10 CM
4512
4513 Select(lnOldSelect)
4514 Return llRetVal
4515 Endproc
4516
4517
4518 *----------------------------------------------------------------------------------------
4519
4520 Procedure ResetPkey_OPRTmpTable
4521 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4522
4523 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4524 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4525
4526 lnOldSelect = Select()
4527 llRetVal = .T.
4528 lcOPR_TMP = pceoprth
4529 lnRecCount = 0
4530 lnMaxPkey = 0
4531 lcUnique = Sys(2015)
4532
4533 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4534 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4535 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4536 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4537 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4538 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4539 lcNewPkeyCol_TH = "PKEY_OPRTH"
4540 lcNewPkeyCol_TD = "PKEY_OPRTD"
4541 With This
4542 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4543 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4544 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4545 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4546 *- 1030497 02/29/08 TT
4547 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4548 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4549 *- 1030497 02/29/08 TT
4550
4551 *--- fkey updates for all chield tables
4552 *--- ipotd -> oprtd : fkey
4553 lcOPR_TMP = pceoprtd
4554 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4555 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4556 llRetVal = llRetVal And v_SqlExec(lcSQL)
4557
4558 *--- ipota -> oprta : fkey
4559 lcOPR_TMP = pceoprta
4560 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4561 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4562
4563 llRetVal = llRetVal And v_SqlExec(lcSQL)
4564
4565 *--- ipotc -> oprtc : fkey
4566 lcOPR_TMP = pceoprtc
4567 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4568 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4569 llRetVal = llRetVal And v_SqlExec(lcSQL)
4570
4571 *-- sysnotes :
4572 *-- table_name
4573 lcOPR_TMP = pceoprth_notes
4574 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4575 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4576 llRetVal = llRetVal And v_SqlExec(lcSQL)
4577
4578 *-- update detail pkey
4579 *- 1030497 02/29/08 TT
4580 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4581 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4582 *- 1030497 02/29/08 TT
4583
4584 *-- sysnotes : update table_name, fkey
4585 lcOPR_TMP = pceoprtd_notes
4586 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4587 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4588 llRetVal = llRetVal And v_SqlExec(lcSQL)
4589
4590 *--- update header notes pkey
4591 *- 1030497 02/29/08 TT
4592 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4593 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4594 *- 1030497 02/29/08 TT
4595 *--- update detail notes pkey
4596 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4597 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4598
4599 *-- update pkey
4600 *- 1030497 02/29/08 TT
4601 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4602 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4603
4604 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4605 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4606 *- 1030497 02/29/08 TT
4607
4608 *--- drop all temp tables
4609 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4610 *- 1030497 02/29/08 TT
4611 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4612 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4613 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4614 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4615 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4616
4617 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4618 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4619 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4620 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4621 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4622 *- 1030497 02/29/08 TT
4623
4624 Endwith
4625
4626 Select(lnOldSelect)
4627 Return llRetVal
4628 Endproc
4629
4630 *----------------------------------------------------------------------------------------
4631
4632 Procedure UpdateOPRTempHDRDivisionFromDtl
4633 Lparameters pcRefeoprth,pcRefeoprtd
4634
4635 Local llRetVal, lnOldSelect
4636 llRetVal = .T.
4637 lnOldSelect = Select()
4638 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4639 llRetVal = llRetVal And v_SqlExec(lcSQL)
4640 Select(lnOldSelect)
4641 Return llRetVal
4642
4643 Endproc
4644
4645 *----------------------------------------------------------------------------------------
4646
4647 Procedure Launch855Process
4648 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4649 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4650 Local llRetVal, lnOldSelect
4651 lnOldSelect = Select()
4652 llRetVal = .T.
4653
4654 Local lo855
4655 Local lc855DataTbls, lc855Msg
4656 lcFilterCriteria = ""
4657 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4658 llRetVal = (Vartype(lo855) = 'O')
4659 lc855Msg = ""
4660
4661 If llRetVal
4662 *--- TR 1037976 JAN-22-2008 BR
4663 *lo855 = This
4664 lo855.oLog = THIS.oLog
4665 *=== TR 1037976 JAN-22-2008 BR
4666 lo855.oFrmProgressBar = This.oFrmProgressBar
4667 Endif
4668 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4669 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4670 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4671 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4672 This.oHostProcess.c855Msg = lc855Msg
4673 Select(lnOldSelect)
4674 Return llRetVal
4675
4676 Endproc
4677
4678 *----------------------------------------------------------------------------------------
4679
4680 Procedure Update855ProcFlag
4681 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4682
4683 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4684 lnOldSelect = Select()
4685 llRetVal = .T.
4686 lcCursor = Sys(2015)
4687 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4688 *--- 1034481 set correct flag value 'P' for Proc_855
4689 *- 1034481 10/03/08 YIK
4690 *- Also populate error flag and error message from zzeoprth to the 850(i)
4691 *- otherwise 850(i) goes through while the 855(o) errors out.
4692 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4693 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4694 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4695 " t on o.pkey = t.pkey_oprth" + ;
4696 " LEFT JOIN zzeoprth th " + ;
4697 " on th.pkey = t.pkey_oprth"
4698
4699 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4700 If llRetVal
4701 Select (lcCursor)
4702 SCAN
4703 Scatter Name loCursor Memo
4704 DO CASE
4705 CASE proc_855 = 'P'
4706 *- 1014298 12/02/05 YIK, NH
4707 *- it was ..proc_855 WITH 'Y'
4708 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4709 CASE errs_flg_h = 'Y'
4710 REPLACE errs_flg_h WITH 'Y', ;
4711 errs_msg_h WITH errs_msg_h + ;
4712 " ---- 855(o) process ----" + CRLF + ;
4713 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4714 For pkey = loCursor.pkey In (pceipoTH)
4715 OTHERWISE
4716 ENDCASE
4717 Endscan
4718 Endif
4719 *= 1034481
4720 Select(lnOldSelect)
4721 Return llRetVal
4722
4723 Endproc
4724
4725 *----------------------------------------------------------------------------------------
4726
4727 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4728
4729 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4730 *!* In this case label must be with empty.
4731
4732 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4733
4734 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4735 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4736 *!* style '9040' color 'RED' label 'WM'.
4737
4738 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4739 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4740 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4741
4742 Procedure CheckMultiUPC
4743 Lparameters tcEiPOth, tcEiPOtd
4744
4745 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
4746
4747 llRetVal = True
4748 lnSelect = Select()
4749
4750 With This
4751
4752 lcWorkAlias = GetUniqueFileName()
4753
4754 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4755 *-- Change h.division to d.division
4756 SELECT d.pkey, ;
4757 h.customer, ;
4758 d.division, ;
4759 d.upc ;
4760 FROM tceipoth h ;
4761 JOIN tceipotd d ;
4762 ON h.pkey = d.fkey ;
4763 INTO ;
4764 CURSOR (lcworkAlias)
4765
4766 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
4767 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
4768 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
4769 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
4770
4771 If llRetVal
4772
4773 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4774 *-- Included 'V' in the condition of pocr.resv_label
4775 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
4776 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
4777
4778 lcSql = " SELECT upcd.lbl_code, t.* " + ;
4779 " FROM " + lcTempTbl + " t " + ;
4780 " JOIN zzemupch upch " + ;
4781 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
4782 " JOIN zzemupcd upcd " + ;
4783 " ON upch.pkey = upcd.fkey " + ;
4784 " AND upcd.active_ok = 'Y' " + ;
4785 " JOIN " + This.c850Control + " pocr " + ;
4786 " ON pocr.customer = t.customer " + ;
4787 " AND pocr.division = t.division " + ;
4788 " AND pocr.lbl_code = upcd.lbl_code " + ;
4789 " AND pocr.resv_label IN ('Y','V') "
4790
4791 lcWorkAlias = GetUniqueFileName()
4792
4793 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
4794
4795 If Reccount(lcWorkAlias) > 0
4796 Select (tcEiPOtd)
4797 Scan
4798 lnPKey = pkey
4799
4800 Select(lcWorkAlias)
4801 Locat For pkey = lnPKey
4802
4803 If Found()
4804 lcLbl_code = lbl_code
4805 Select (tcEiPOtd)
4806 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
4807 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
4808 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
4809 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
4810 Endif
4811
4812 Select (tcEiPOtd)
4813 Endscan
4814 Endif
4815
4816 Endif
4817
4818 .TableClose(lcWorkAlias)
4819
4820 Endwith
4821
4822 Select (lnSelect)
4823 Return llRetVal
4824 Endproc
4825 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
4826
4827 *----------------------------------------------------------------------------------------
4828
4829 Procedure RangeStyle
4830 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
4831 Local llRetVal, lnOldSelect, lcErrs_Msg
4832 llRetVal = .T.
4833 lnOldSelect = Select()
4834
4835 *****************************************************************************
4836 * 1st Getting all range style (hdr/dtl) that relate to the
4837 * passing order line for this run
4838
4839 *--- TR 1038376 05-May-2009 Goutam
4840 LOCAL lctmpCursor
4841 lctmpCursor = GetUniqueFileName()
4842
4843 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
4844 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
4845
4846 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
4847 * TR 1059142 FH - adding h.ord_type to the group by clause
4848 *--- TR 1088126 2-JUL-2015 Venuk -- Added 'as price_code' else MAX(h.price_code) will be max_price_Code ===
4849 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) as price_code, h.ord_type FROM (pcTransHeader) h ;
4850 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4851 WHERE d.errs_flg_d <> 'Y' ;
4852 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
4853 INTO CURSOR __TmpCursor
4854
4855 .cSQLTempTable=""
4856 If .GenerateSQLTempTable('__TmpCursor')
4857 If .PopulateSQLTempTable('__TmpCursor')
4858 If !Empty(.cSQLTempTable)
4859 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4860 lcSqlString = "Update " + .cSQLTempTable + ;
4861 " Set price_code = coalesce((Select Top 1 price_code " + ;
4862 " From zzxcslsr " + ;
4863 " Where Customer = h.customer " + ;
4864 " and (Store = h.store or Store = '') " + ;
4865 " and (Division = h.division or Division = '') " + ;
4866 " and (Department = h.department or Department = '') " + ;
4867 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4868 " and price_code <> '' " + ;
4869 " order by rank_seq),'') " + ;
4870 " From " + .cSQLTempTable + " h"
4871
4872 llRetVal = v_sqlExec(lcSqlString)
4873
4874 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
4875 lcSqlString = "UPDATE " + .cSQLTempTable + ;
4876 " Set price_code = c.price_code "+;
4877 " From " + .cSQLTempTable + " h "+;
4878 " , zzocntrc c "+;
4879 " Where h.division = c.division " +;
4880 " and h.price_code = '' "
4881 llRetVal = v_sqlExec(lcSqlString)
4882 *- TR 1056061 FH 08/17/11
4883
4884
4885 IF llRetVal
4886 lcSqlString = "Select * from " + .cSQLTempTable
4887 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
4888
4889 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
4890 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4891*!* lcSqlString = "UPDATE h " + ;
4892*!* " SET price_code = c.price_code " + ;
4893*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
4894*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
4895*!* " on d.division = c.division " + ;
4896*!* " And d.customer = c.customer " + ;
4897*!* " And h.Store = c.Store " + ;
4898*!* " And h.department = c.department " + ;
4899*!* " And h.ord_type = c.ord_type " + ;
4900*!* "Where d.errs_flg_d <> 'Y' "
4901
4902 lcSqlString = "UPDATE h " + ;
4903 " SET price_code = c.price_code " + ;
4904 " From " + pcTransheader + " h " + ;
4905 " join " + lcTmpCursor + " c " + ;
4906 " on h.division = c.division " + ;
4907 " And h.customer = c.customer " + ;
4908 " And h.Store = c.Store " + ;
4909 " And h.department = c.department " + ;
4910 " And h.ord_type = c.ord_type " + ;
4911 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
4912
4913 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
4914
4915 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
4916 ENDIF
4917
4918 IF llRetVal
4919 *-1061331 FH - simpilifed update query
4920 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
4921 *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 ;
4922 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4923 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4924 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4925
4926 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 ;
4927 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
4928
4929 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
4930 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
4931 *- TR 1054873 FH - changed error message
4932 &&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 ;
4933 &&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 ;
4934 *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 ;
4935 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4936 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4937 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4938 ENDIF
4939
4940 endif
4941 endif
4942 ENDIF
4943
4944
4945 *--- TR 1088126 2-JUL-2015 Venuk
4946 IF This.oBPOSalesOrder.lRslv_pricecode_cssld
4947 SELECT CRS_pkey, d.pkey as dtlpkey, d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type, ;
4948 d.style, d.color_code, d.lbl_code, d.dimension ;
4949 FROM (pcTransHeader) h ;
4950 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4951 WHERE d.errs_flg_d <> 'Y' ;
4952 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type, d.pkey ;
4953 INTO CURSOR __TmpCursor
4954
4955 .cSQLTempTable=""
4956 If .GenerateSQLTempTable('__TmpCursor')
4957 If .PopulateSQLTempTable('__TmpCursor')
4958 If !Empty(.cSQLTempTable)
4959
4960 lcSqlString = "Update " + .cSQLTempTable + ;
4961 " Set CRS_pkey = coalesce((Select Top 1 pkey " + ;
4962 " From zzxcslsr " + ;
4963 " Where Customer = h.customer " + ;
4964 " and (Store = h.store or Store = '') " + ;
4965 " and (Division = h.division or Division = '') " + ;
4966 " and (Department = h.department or Department = '') " + ;
4967 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4968 " and price_code <> '' " + ;
4969 " order by rank_seq),'') " + ;
4970 " From " + .cSQLTempTable + " h"
4971 llRetVal = v_sqlExec(lcSqlString)
4972
4973 lcSqlString = ;
4974 " Select r.dtlpkey as dtlpkey, " + ;
4975 " case when Coalesce(d.price_code,'')='' then h.price_code else d.price_code end as price_Code " + ;
4976 " from zzxcslsr h " + ;
4977 " join "+ .cSQLTempTable + " r" + ;
4978 " on h.pkey = r.CRS_pkey " + ;
4979 " join zzxscolr c " + ;
4980 " on c.division = h.division " + ;
4981 " and c.style = r.style" + ;
4982 " and c.color_Code = r.color_Code " + ;
4983 " and c.lbl_Code = r.lbl_code " + ;
4984 " and c.dimension = r.dimension " + ;
4985 " join zzxcslsd d " + ;
4986 " on h.pkey = d.fkey " + ;
4987 " and h.group_Type = d.group_type " + ;
4988 " and d.group_code = " + ;
4989 " case when d.Group_type='A' then c.Group_Code1 " + ;
4990 " when h.Group_type='B' then c.Group_Code2 " + ;
4991 " when h.Group_type='C' then c.Group_Code3 " + ;
4992 " when h.Group_type='D' then c.Group_Code4 " + ;
4993 " when h.Group_type='E' then c.Group_Code5 " + ;
4994 " when h.Group_type='F' then c.Group_Code6 " + ;
4995 " when h.Group_type='G' then c.Group_Code7 " + ;
4996 " when h.Group_type='H' then c.Group_Code8 " + ;
4997 " when h.Group_type='I' then c.Group_Code9 " + ;
4998 " when h.Group_type='J' then c.Group_Code10 " + ;
4999 " when h.Group_type='K' then c.Group_Code11 " + ;
5000 " when h.Group_type='L' then c.Group_Code12 " + ;
5001 " when h.Group_type='M' then c.Group_Code13 end "
5002
5003 llRetVal = v_sqlExec(lcSqlString, "tcPriceCode")
5004
5005 If(USED("tcPriceCode"))
5006 SELECT tcPriceCode
5007 INDEX on dtlpkey TAG dtlpkey
5008 llRetval = .SetRelation("tcPriceCode", "dtlpkey", pcTransDetail,"pkey")
5009
5010 REPLACE ALL PRICE_CODE WITH tcPriceCode.price_Code IN (pcTransDetail)
5011
5012 Set Relation To
5013 USE IN tcPriceCode
5014 ENDIF
5015 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 ;
5016 from (pcTransDetail) d WHERE EMPTY(d.price_code) AND d.errs_flg_d <> 'Y'
5017
5018 ENDIF
5019 ENDIF
5020 ENDIF
5021 USE IN __TmpCursor
5022 ELSE
5023 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey where d.price_code=''
5024 Endif
5025 *=== TR 1088126 2-JUL-2015 Venuk
5026
5027 .cSQLTempTable=""
5028
5029 *=== TR 1038376 05-May-2009 Goutam
5030
5031 * additional past for range style verification/explotion
5032 *-- TR 1023892 5-3-07 BR
5033 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5034 IF .lALLOW_RANGE_HDR_LABEL
5035 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5036 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5037 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 ;
5038 FROM (pcTransHeader) h, (pcTransDetail) d ;
5039 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5040 AND d.Errs_Flg_D= 'N' AND ;
5041 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5042 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5043 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5044 ELSE
5045 *=== TR 1023892 NH
5046 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5047 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5048 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
5049 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5050 FROM (pcTransHeader) h, (pcTransDetail) d ;
5051 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5052 And d.Errs_Flg_D= "N" And ;
5053 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5054 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5055 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5056 ENDIF && TR 1023892 NH
5057
5058 With This
5059 .cSQLTempTable=""
5060 If .GenerateSQLTempTable('__TmpCursor')
5061 If .PopulateSQLTempTable('__TmpCursor')
5062 If !Empty(.cSQLTempTable)
5063
5064 .LogEntry("Exploding range style.")
5065 * Get range style header
5066 *- 1000984 9/11/03 YIK
5067 *- do not explode range styles type 'P'rint
5068 *- Added ..and h.rng_type <> 'P'
5069 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
5070 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
5071 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
5072 IF .lALLOW_RANGE_HDR_LABEL
5073 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5074 "Where h.division= t.division and h.rng_style = t.style and "+;
5075 "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 "+;
5076 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5077 ELSE
5078 *=== TR 1023892 NH
5079 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5080 "Where h.division= t.division and h.rng_style = t.style and "+;
5081 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5082 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5083 *= 1000984
5084 ENDIF && TR 1023892 NH
5085 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
5086
5087 * TAN 31891 - JAZ - 5/20/02
5088 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5089 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5090 * End TAN 31891 - JAZ - 5/20/02
5091
5092 If llHaveRangeStyleToExplode
5093 * Get range style detail
5094 *- 1000984 9/11/03 YIK
5095 *- do not explode range styles type 'P'rint
5096 *- Added ..and h.rng_type <> 'P'
5097
5098 *--- TR 1038376 05-May-2009 Goutam
5099 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5100
5101 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
5102 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
5103*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
5104*!* " case t.price_code when 'A' then h.a_price " + ;
5105*!* " when 'B' then h.b_price " + ;
5106*!* " when 'C' then h.c_price " + ;
5107*!* " when 'D' then h.d_price " + ;
5108*!* " when 'E' then h.e_price " + ;
5109*!* " else h.a_price end rnghdr_Price " + ;
5110*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5111*!* "join " + .cSQLTempTable + " t " +;
5112*!* "on h.division= t.division and h.rng_style = t.style and "+;
5113*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5114*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5115*!* " (case t.price_code when 'A' then h.a_price " + ;
5116*!* " when 'B' then h.b_price " + ;
5117*!* " when 'C' then h.c_price " + ;
5118*!* " when 'D' then h.d_price " + ;
5119*!* " when 'E' then h.e_price " + ;
5120*!* " else h.a_price end " + ;
5121*!* " <> t.org_price)" +;
5122*!* " AND t.sizebucket = h.rng_bk"
5123
5124 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5125 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
5126 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
5127 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
5128 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
5129 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
5130 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
5131 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
5132 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
5133 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5134
5135 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
5136 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5137 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
5138 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
5139 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
5140 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
5141 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
5142 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5143 " Left join zzxcsrgh cs "+ ;
5144 " on cs.hdrpkey = h.pkey "+ ;
5145 " and cs.dtlpkey = 0 " +;
5146 "join " + .cSQLTempTable + " t " +;
5147 "on h.division= t.division and h.rng_style = t.style and "+;
5148 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5149 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5150 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5151 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
5152 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
5153 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
5154 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
5155 " else coalesce(cs.a_price,h.a_price) end " + ;
5156 " <> t.org_price)" +;
5157 " AND t.sizebucket = h.rng_bk"+ ;
5158 " Where cs.customer = t.customer "
5159 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
5160 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
5161
5162 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5163 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
5164 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) " + ;
5165 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
5166 " on d.division= r.division and d.style = r.rng_style and " + ;
5167 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
5168 " d.dimension= r.Rng_Pack " + ;
5169 " join zzeipocr c on c.division = d.division and h.customer = c.customer " + ;
5170 "where d.rng_type <> 'P' AND c.price_err = 'Y' AND r.sizebucket = d.sizebucket"
5171
5172 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
5173
5174 *- TR 1048790 FH 10/04/10
5175 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
5176 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
5177 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5178
5179 IF .lALLOW_RANGE_HDR_LABEL
5180 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 ;
5181 FROM (pcTransHeader) h, (pcTransDetail) d ;
5182 WHERE h.pkey = d.fkey ;
5183 AND d.Errs_Flg_D= 'N' AND ;
5184 Not EMPTY(h.price_code) AND ;
5185 d.rng_style= '' ;
5186 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5187 ELSE
5188 *--- TechRec 1084745 14-May-2015 jjanand === Added h.customer
5189 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5190 FROM (pcTransHeader) h, (pcTransDetail) d ;
5191 WHERE h.pkey = d.fkey ;
5192 And d.Errs_Flg_D= "N" And ;
5193 Not EMPTY(h.price_code) AND ;
5194 d.rng_style= '' ;
5195 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5196 ENDIF
5197
5198 .cSQLTempTable=""
5199 If .GenerateSQLTempTable('__TmpCursor')
5200 If .PopulateSQLTempTable('__TmpCursor')
5201 *- TR 1048790 FH 10/04/10
5202
5203 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5204 *-- TR 1040759 JUN-29-2009 BR
5205 IF .lALLOW_RANGE_HDR_LABEL
5206 *- TR 1048790 FH 10/04/10 - removed price check
5207 *- TR 1050589 12/13/10 FH
5208 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5209*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5210*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5211*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5212*!* "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 "+;
5213*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5214 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5215*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5216*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5217*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5218*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5219*!* "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 "+;
5220*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5221
5222 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5223 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5224 "join " + .cSQLTempTable + " t " +;
5225 "on h.division= t.division and h.rng_style = t.style and "+;
5226 "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 "+;
5227 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5228 " t.sizebucket = h.rng_bk"+ ;
5229 " Left join zzxcsrgh cs "+ ;
5230 " on cs.hdrpkey = h.pkey "+ ;
5231 " and cs.dtlpkey = d.pkey " +;
5232 " and cs.customer = t.customer " + ;
5233 " where d.fkey in " +;
5234 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5235 "Where h.division= t.division and h.rng_style = t.style and "+;
5236 "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 "+;
5237 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5238 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5239 *- TR 1050589 12/13/10 FH
5240 ELSE
5241 *== TR 1040759 JUN-29-2009 BR
5242 *- TR 1048790 FH 10/04/10 - removed price check
5243 *- TR 1050589 12/13/10 FH
5244 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5245
5246*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5247*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5248*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5249*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5250*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5251*!*
5252 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5253*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5254*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5255*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5256*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5257*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5258*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5259
5260 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5261 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5262 "join " + .cSQLTempTable + " t " +;
5263 "on h.division= t.division and h.rng_style = t.style and "+;
5264 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5265 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5266 " t.sizebucket = h.rng_bk"+ ;
5267 " Left join zzxcsrgh cs "+ ;
5268 " on cs.hdrpkey = h.pkey "+ ;
5269 " and cs.dtlpkey = d.pkey " +;
5270 " and cs.customer = t.customer " + ;
5271 " where fkey in " +;
5272 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5273 "Where h.division= t.division and h.rng_style = t.style and "+;
5274 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5275 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5276 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5277 *- TR 1050589 12/13/10 FH
5278 ENDIF && TR 1040759 JUN-29-2009 BR
5279 *=== TR 1038376 05-May-2009 Goutam
5280 endif &&- TR 1048790 FH 10/04/10
5281 ENDIF &&- TR 1048790 FH 10/04/10
5282
5283 *= 1000984
5284 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5285
5286 * turn Range detail to vertical (with sizebucket,size_desc)
5287 * have to explode in vertical format
5288 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5289 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5290 WHERE 0=1 Into Cursor __Range2
5291 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5292 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5293 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5294 If Used("__Range1")
5295 Use In __Range1
5296 Endif
5297 If Used("__Range2")
5298 Use In __Range2
5299 Endif
5300
5301 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5302 Select __RangH
5303 Index On pkey Tag pkey
5304 Select __RangD
5305 Index On division+Style Tag DivStyle
5306 Select tcRangeVer
5307 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5308 Set Order To RangeSKU
5309 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5310
5311 *****************************************************************************
5312 * 2). Validate "Run"- type of range style. divisible by range header qty
5313 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5314
5315 *****************************************************************************
5316 * 3). Explode range style only once good tran detail that have
5317 * matching range style. Vertical range style explosion
5318 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5319 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5320 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5321 Select Distinct d.pkey ;
5322 FROM __RangD r, (pcTransDetail) d ;
5323 WHERE d.Errs_Flg_D= "N" And ; &&no error
5324 d.rng_style= '' And ; &&never explode before
5325 r.division= d.division And r.rng_style = d.Style And ; && matching range
5326 r.rng_color= d.color_code And ;
5327 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
5328 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5329 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5330 INTO Cursor __DtlExpl
5331 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5332 Endif
5333 Endif
5334 Endif
5335 Endif
5336 Endif
5337 Endwith
5338
5339 If Used("__RangH")
5340 Use In __RangH
5341 Endif
5342 If Used("__RangD")
5343 Use In __RangD
5344 Endif
5345 If Used("tcRangeVer")
5346 Use In tcRangeVer
5347 Endif
5348 If Used("__DtlExpl")
5349 Use In __DtlExpl
5350 Endif
5351 If Used("__TmpCursor")
5352 Use In __TmpCursor
5353 Endif
5354
5355 *--- TR 1038376 05-May-2009 Goutam
5356 If Used("__RangTmpD")
5357 Use In __RangTmpD
5358 ENDIF
5359 this.TableClose(lcTmpCursor)
5360 *=== TR 1038376 05-May-2009 Goutam
5361
5362 Select(lnOldSelect)
5363 Return llRetVal
5364 Endproc
5365 *----------------------------------------------------------------------------------------
5366
5367 Procedure ExplodeRangeRef
5368 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5369 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5370 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5371
5372 lnOldSele= Select()
5373 lcDivStyle= ""
5374 * TAN 31891 - JAZ - 5/20/02
5375 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5376 lnSourceCnt= RecCount(pcRangeDetail)
5377 * End TAN 31891 - JAZ - 5/20/02
5378 llRetVal= .T.
5379 lnCurDtlFkey= 0
5380
5381 Select (pcRangeDetail)
5382 Set Order To DivStyle
5383 Scan
5384 *- 1009508 03/16/05 YIK
5385 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5386 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5387 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5388 *-- m.rng_type= &pcRangeHeader..rng_type
5389 *-- m.rng_qty= &pcRangeHeader..rng_qty
5390
5391 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5392 *-- m.coord_code= &pcRangeHeader..coord_code
5393 *-- m.rng_type= &pcRangeHeader..rng_type
5394 If lnCurDtlFkey<> fkey
5395 lnCurDtlFkey= fkey
5396 If Seek(fkey, pcRangeHeader , "PKEY")
5397 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5398 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5399 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5400 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5401 *= 1009508 YIK
5402 Else
5403 llRetVal = .F.
5404 Exit
5405 Endif
5406 Endif
5407
5408 * only run once per Div + Style
5409 If !(lcDivStyle == division + Style)
5410 lcDivStyle = division + Style
5411 * Insert a record for each size bucket with a caption *
5412 If !v_GetSizeHeadings(division, Style, "__xSizer")
5413 llRetVal = .F.
5414 Exit
5415 Endif
5416 Endif
5417
5418 Select (pcRangeDetail)
5419 Scatter Memvar Memo
5420 For lnSizePosition = 1 To goEnv.MaxBuckets
5421 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5422 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5423 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5424 m.sizebucket = lnSizePosition
5425 m.size_desc = lcSizeName
5426 m.total_qty = lnSizeQty
5427 If lnSizeQty > 0 && Only want buckets with activity!
5428 Insert Into (pcRangeDetailTarget) From Memvar
5429 Endif
5430 Endfor
5431
5432 Endscan
5433 This.TableClose("__xSizer")
5434 Select (pcRangeDetail)
5435 Select (lnOldSele)
5436 Return llRetVal
5437 Endproc
5438
5439 *----------------------------------------------------------------------------------------
5440
5441 Procedure ValidateRangeStyle
5442 Lparameters pcRangeStyle, pcTransDetail
5443 Local llRetVal, lnOldSelect, lcErrs_Msg
5444 llRetVal = .T.
5445 lnOldSelect = Select()
5446 lcErrs_Msg= "Total Units must be divisible by "
5447
5448 Select (pcRangeStyle)
5449 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5450 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5451 "division+style+color_code+lbl_code+dimension")
5452
5453 If llRetVal
5454 .LogEntry("Validating range style.")
5455 * Verify range style "R"un order in min multiple of rng_qty
5456 * no need for "S"et verification of range type --just explode to
5457 * range detail
5458 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5459 *- 1023438 04/06/07 YIK
5460 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5461 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5462 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5463 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5464 Errs_Flg_D With "Y" ;
5465 IN (pcTransDetail)
5466 Endif
5467 Endscan
5468 Endif
5469
5470 Set Relation To
5471 Select(lnOldSelect)
5472 Return llRetVal
5473 Endproc
5474
5475 *----------------------------------------------------------------------------------------
5476
5477 Procedure ExplodeRangeStyleVertical
5478 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5479 Local llRetVal, lnOldSelect, lcErrs_Msg
5480 llRetVal = .T.
5481 lnOldSelect = Select()
5482
5483 * --- TR 1034963 12/15/08 CM
5484 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5485 * === TR 1034963 12/15/08 CM
5486
5487 Select (pcDetailtoExplode)
5488 Scan
5489 * Find detail line that need range style exploding using PKEY
5490 If Seek(pkey, pcTransDetail, "Pkey")
5491 * Current working trans detail
5492 Select (pcTransDetail)
5493
5494
5495 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5496 *-- TR 1040759 JUN-29-2009 BR
5497*!* IF !EMPTY(lbl_code)
5498*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5499*!* ELSE
5500*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5501*!* ENDIF
5502 *== TR 1040759 JUN-29-2009 BR
5503 IF .lALLOW_RANGE_HDR_LABEL
5504
5505 IF !EMPTY(lbl_code)
5506 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5507
5508 else
5509 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5510 ENDIF
5511 else
5512
5513 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5514
5515 endIF
5516 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5517
5518 lnCurDtlTotal_qty= total_qty
5519
5520 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5521 *- 1009508 3/16/05 YIK
5522 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5523 lnRangeBucket = sizebucket
5524
5525 Scatter Name loTransDetail Memo
5526
5527 *--- TR 1038376 16-Feb-2009 Goutam
5528 loTransDetail.Rng_Price = loTransDetail.org_price
5529 *--- TR 1038376 16-Feb-2009 Goutam
5530
5531 * delete current working trans detail already have image
5532 * in loTransDetail
5533 Delete In (pcTransDetail)
5534
5535 * --- TR 1034963 12/15/08 CM
5536 lnDetailPkey = loTransDetail.pkey
5537 * === TR 1034963 12/15/08 CM
5538
5539 * --- TR 1018184 RLN 01/10/07
5540 lnDetailPkey = loTransDetail.pkey
5541 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5542 * === TR 1018184
5543
5544 Select (pcRangeDetailVert)
5545 * Find 1st match of OURSKU
5546 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5547 * calculate lnMultiplier regardless of rng_type
5548 * --"R"un only divisible by rng_qty will get to this point
5549 * --otherwise will stay in errs_dtl_F/msg
5550
5551 *- 1009508 3/16/05 YIK
5552 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5553 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5554 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5555 lnCurDtlTotal_qty/rng_qty)
5556
5557 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5558 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5559 * Exploding detail line
5560 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5561 If !Empty(loTransDetail.pkey)
5562
5563 * --- TR 1034963 12/15/08 CM
5564 lcDetailNotes = GetUniqueFileName()
5565 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey)
5566 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5567 * === TR 1034963 12/15/08 CM
5568
5569 *- 1009508 3/16/05 YIK
5570 Select (pcRangeDetailVert)
5571 Scatter Name loVert Memo
5572 *= 1009508
5573
5574 Select (pcTransDetail)
5575 Append Blank
5576 Gather Name loTransDetail Memo
5577
5578 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5579 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5580 * only recording a..e_price to zzeipoth and resetting org_price
5581 *org_price with &pcRangeDetailVert..a_price,
5582
5583 *- 1009508 3/16/05 YIK
5584 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5585 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5586 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5587 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5588 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5589 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5590 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5591 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5592 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5593 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5594 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5595 *-- division WITH &pcRangeDetailVert..division, ;
5596 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5597 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5598 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5599 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5600 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5601 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5602 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5603 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5604 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5605 *-- e_price WITH &pcRangeDetailVert..e_price ;
5606 *-- IN (pcTransDetail)
5607
5608 *- 1022149 03/06/07 YIK
5609 *- do not zero out org_price for MultiUPC
5610 Replace rng_style With loVert.rng_style, ;
5611 rng_color With loVert.rng_color, ;
5612 rng_lbl With loVert.rng_lbl, ;
5613 rng_pack With loVert.rng_pack, ;
5614 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5615 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5616 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5617 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5618 total_qty With lnMultiplier * loVert.total_qty, ;
5619 sizebucket With loVert.sizebucket, ;
5620 size_desc With loVert.size_desc, ;
5621 division With loVert.division, ;
5622 STYLE With loVert.Style, ;
5623 color_code With loVert.color_code, ;
5624 lbl_code With loVert.lbl_code, ;
5625 DIMENSION With loVert.Dimension, ;
5626 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5627 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5628 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5629 a_price With loVert.a_price,; && 4186- store a..e_price
5630 b_price With loVert.b_price,; && from range style detail
5631 c_price With loVert.c_price,; && to use latter when have
5632 d_price With loVert.d_price,; && price_code
5633 e_price With loVert.e_price ;
5634 IN (pcTransDetail)
5635 *= 1009508 03/16/05 YIK
5636 * --- TR 1018184 RLN 01/10/07
5637 Select tmpRngSacs
5638 Scan
5639 Scatter Name loTmpSACs Memo
5640 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5641 loTmpSACs.dfkey = loTransDetail.pkey
5642 Insert Into (tcTransSAC) From Name loTmpSACs
5643 Endscan
5644 * === TR 1018184
5645
5646 * --- TR 1034963 12/15/08 CM
5647 If llDtlRangeNotes
5648 Select (lcDetailNotes)
5649 Scan
5650 Scatter Name loTmpDetNotes Memo
5651
5652 * --- TR 1045865 3/8/10 CM
5653 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5654 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5655 * === TR 1045865 3/8/10 CM
5656
5657 loTmpDetNotes.fkey = loTransDetail.pkey
5658 SELECT('Vzzeipotd_notes_iPOproc')
5659 Append Blank
5660 Gather Name loTmpDetNotes Memo
5661 Endscan
5662 Endif
5663
5664 IF USED(lcDetailNotes)
5665 USE IN (lcDetailNotes)
5666 ENDIF
5667 * === TR 1034963 12/15/08 CM
5668
5669 Else
5670 llRetVal= .F. && Cannot get Pkey from bcsysnum
5671 Exit
5672 Endif
5673
5674 Select (pcRangeDetailVert)
5675 Endscan
5676 Else
5677 llRetVal= .F. && Should be in pcrangdetailvert
5678 Exit
5679 Endif
5680 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5681 Endif
5682
5683 If !llRetVal &&Get out of scan when have some problem
5684 Exit
5685 Endif
5686 Endscan
5687
5688 * --- TR 1034963 12/15/08 CM
5689 If llDtlRangeNotes
5690 This.UpdateSysNotes()
5691 Endif
5692 * === TR 1034963 12/15/08 CM
5693
5694 Select(lnOldSelect)
5695 Return llRetVal
5696 Endproc
5697
5698 *----------------------------------------------------------------------------------------
5699
5700 Procedure PrepackConversion
5701 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5702 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5703 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5704 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5705 llRetVal = .T.
5706 lnOldSelect = Select()
5707
5708 * --- TR 1046519 7/26/10 CM
5709 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5710 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5711
5712 STORE "" To lcSumSln, lcError, lcPPKAction
5713 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5714 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5715 * === TR 1046519 7/26/10 CM
5716
5717 *****************************************************************************
5718 * 1st Getting all prepack headers
5719 *--- 1001112 9/26/03 YIK
5720 *- process all.
5721 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5722 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5723 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5724 *!* and d.rng_style= '' ; && none exploded range style
5725 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5726 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5727
5728 *- 1013522 10/10/05 12/02/05 YIK
5729 *- Exclude range style P from the consideration
5730 *- Do not close this cursor. It is needed in CheckSLN()
5731 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5732 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5733
5734 *- 1025153 10/22/07 YIK - comment out
5735 * --- TR 1022896 NSD 05-10-07
5736*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5737 * === TR 1022896 NSD 05-10-07
5738
5739 *- 1005499 07/06/04 YIK
5740 *- Change d.rng_style = '' to EMPTY(d.rng_style)
5741
5742 *- 1023438 04/05/07 YIK
5743 *- Allow to check Range Style type 'R'.
5744 *- Needed for MultiUPC and a good idea anyway.
5745 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
5746
5747 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
5748
5749*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5750*!* FROM (pcTransDetail) d ;
5751*!* WHERE Empty(d.rng_style) ; && none exploded range style
5752*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5753*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5754*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5755*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5756
5757 *--- TechRec 1044487 18-Mar-2010 JK ---
5758*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5759*!* FROM (pcTransDetail) d ;
5760*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
5761*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5762*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5763*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5764*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5765
5766 * --- TR 1046519 7/26/10 CM
5767 IF RECCOUNT(pcSLN) > 0
5768 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
5769 JOIN (pcTransDetail) d ;
5770 ON s.fkey = d.pkey ;
5771 JOIN (pceipoCR) c ;
5772 ON d.division = c.division ;
5773 AND d.customer = c.customer ;
5774 WHERE s.sln_qty > 0 ;
5775 GROUP BY s.fkey ;
5776 INTO CURSOR __SumSlnQty
5777
5778 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
5779
5780 WITH THIS
5781 .cSQLTempTable=""
5782 IF .GenerateSQLTempTable('__SumSlnQty')
5783 IF .PopulateSQLTempTable('__SumSlnQty')
5784 lcSumSln = .cSQLTempTable
5785 IF !EMPTY(lcSumSln)
5786 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
5787 ENDIF
5788 ENDIF
5789 ENDIF
5790 ENDWITH
5791 ENDIF
5792 * === TR 1046519 7/26/10 CM
5793
5794 *--- TechRec 1089737 21-Dec-2015 jisingh ---
5795 IF !EMPTY(This.cOverridePpkAction)
5796 REPLACE ALL ppk_action WITH This.cOverridePpkAction ;
5797 FOR EMPTY(ppk_action) OR ppk_action $ 'QPBO' IN (pcTransDetail)
5798 ENDIF
5799 *=== TechRec 1089737 21-Dec-2015 jisingh ===
5800
5801 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
5802 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
5803 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
5804 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
5805 FROM (pcTransDetail) d ;
5806 JOIN (pceipoCR) c ON c.customer = d.customer ;
5807 AND c.division = d.division ;
5808 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
5809 AND (c.rngp_conv = 'P' ;
5810 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
5811 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
5812 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5813 AND c.ppk_conv <> 'N' ;
5814 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5815 *=== TechRec 1044487 18-Mar-2010 JK ===
5816
5817 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
5818 *== 1023438
5819
5820 *=== 1013522
5821 *=== 1001112
5822 With This
5823 .cSQLTempTable=""
5824 If .GenerateSQLTempTable('__TmpCursor')
5825 If .PopulateSQLTempTable('__TmpCursor')
5826 If !Empty(.cSQLTempTable)
5827 *- TR 1025153 06/14/07 YIK
5828 *- Use the OUTER JOIN, then we have all details needed
5829 *- and can simply scan for !EOF() later on.
5830*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
5831*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
5832*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
5833*-- "s.style= t.style and s.color_code= t.color_code and " +;
5834*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
5835*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
5836*-- "s.dimension= ph.ppk_code"
5837 *--- TR 1026025 NH - use size_code from zzxstylr
5838 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
5839 * using sln_qty instead of ppk_qty
5840
5841 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
5842 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
5843 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
5844 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
5845 " ,st.size_code " +; && 1026025
5846 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
5847 " from " + .cSQLTempTable + " t " +;
5848 " JOIN zzxscolr s " + ;
5849 " ON s.division= t.division and " +;
5850 " s.style= t.style and s.color_code= t.color_code and " +;
5851 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
5852 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
5853 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
5854 " LEFT OUTER JOIN zzxppakh ph " + ;
5855 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
5856 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
5857 " Where s.ppack_ok= 'Y' "
5858
5859 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
5860 If Used("_PPK_Qty")
5861 Select ("_PPK_Qty")
5862 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
5863 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
5864 "division+style+color_code+lbl_code+dimension")
5865 SELECT ("__TmpCursor")
5866
5867 If llRetVal
5868 .LogEntry("Validating prepack style.")
5869 lcErrs_Msg = "No valid prepack code found"
5870 Select (pcTransDetail)
5871 *- 1005499 07/06/04 YIK
5872 *- Replace ..Errs_Flg_D= "N") and rng_style=''
5873 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
5874 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
5875*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
5876 *- TR 1025153 06/14/07 YIK
5877 *- Since we use the OUTER JOIN, can simply scan for !EOF()
5878 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
5879 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
5880
5881 If Empty(_PPK_Qty.pack_qty)
5882 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
5883 Errs_Flg_D With "Y" ;
5884 IN (pcTransDetail)
5885 Else
5886 Do Case
5887
5888 * --- TR 1040838 6/11/09 CM
5889 * --- Check prepack action based on Transaction detail
5890 * Removed _PPK_Qty Alias
5891 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
5892 Case ppk_action = 'Q' && multiply qty
5893 * === TR 1040838 6/11/09 CM
5894
5895 * --- TR 1046519 7/26/10 CM
5896 * At this point we know we have some slns to use for our alternate
5897 * conversion, lets just make sure that the conversion type is 'E'
5898 IF llConvertBySln
5899 lcPPKAction = ppk_action
5900 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5901 lnOrigQty = total_qty
5902 lnPpkQty = ppk_qty
5903 ENDIF
5904 * === TR 1046519 7/26/10 CM
5905
5906 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5907 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5908 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5909 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5910 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
5911 In (pcTransDetail)
5912
5913 * --- TR 1046519 7/26/10 CM
5914 IF llSlnConvert
5915 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5916 IF llRemain
5917 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5918 Errs_Flg_D WITH "Y" , ;
5919 ppk_action WITH lcPPKAction , ;
5920 total_qty WITH lnOrigQty ;
5921 In (pcTransDetail)
5922 ENDIF
5923 ENDIF
5924 * ==== TR 1046519 7/26/10 CM
5925
5926 * --- TR 1040838 6/11/09 CM
5927 * Removed _PPK_Qty Alias
5928 *Case _PPK_Qty.ppk_action = 'P' && divide price
5929 Case ppk_action = 'P' && divide price
5930 * === TR 1040838 6/11/09 CM
5931
5932 * --- TR 1046519 7/26/10 CM
5933 * At this point we know we have some slns to use for our alternate
5934 * conversion, lets just make sure that the conversion type is 'E'
5935 IF llConvertBySln
5936 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5937 ENDIF
5938 * === TR 1046519 7/26/10 CM
5939
5940 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5941 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5942 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5943 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5944 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5945 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5946 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5947 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
5948 In (pcTransDetail)
5949 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
5950 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
5951 *- Range style price will be populated later from a_price..e_price
5952 *- not from org_price. Need to updated these prices here.
5953 IF rng_type = 'R'
5954 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
5955 b_price WITH b_price/_PPK_Qty.pack_qty, ;
5956 c_price WITH c_price/_PPK_Qty.pack_qty, ;
5957 d_price WITH d_price/_PPK_Qty.pack_qty, ;
5958 e_price WITH e_price/_PPK_Qty.pack_qty ;
5959 In (pcTransDetail)
5960 ENDIF
5961 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
5962
5963 * --- TR 1040838 6/11/09 CM
5964 * Removed _PPK_Qty Alias
5965 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
5966 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
5967 * === TR 1040838 6/11/09 CM
5968
5969 * --- TR 1046519 7/26/10 CM
5970 IF llConvertBySln
5971 lcPPKAction = ppk_action
5972 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5973 lnOrigQty = total_qty
5974 lnPrice = org_price
5975 lnretail1 = retail1
5976 lnretail2 = retail2
5977 lnPpkQty = ppk_qty
5978 ENDIF
5979 * === TR 1046519 7/26/10 CM
5980
5981 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5982 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5983 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5984 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5985 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5986 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5987 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5988 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5989 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
5990 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
5991 In (pcTransDetail)
5992
5993 * --- TR 1046519 7/26/10 CM
5994 IF llSlnConvert
5995 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5996 IF llRemain
5997 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5998 Errs_Flg_D WITH "Y", ;
5999 ppk_action WITH lcPPKAction , ;
6000 total_qty WITH lnOrigQty , ;
6001 org_price WITH lnPrice , ;
6002 retail1 WITH lnretail1 , ;
6003 retail2 WITH lnretail2 , ;
6004 ppk_qty WITH lnPpkQty ;
6005 In (pcTransDetail)
6006 ENDIF
6007 ENDIF
6008 * ==== TR 1046519 7/26/10 CM
6009
6010 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6011 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6012 IF rng_type = 'R'
6013 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6014 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6015 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6016 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6017 e_price WITH e_price/_PPK_Qty.pack_qty ;
6018 In (pcTransDetail)
6019 ENDIF
6020 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6021
6022 Otherwise
6023 Endcase
6024 Endif
6025 Endscan
6026 Endif
6027 Set Relation To
6028 Endif
6029 Endif
6030 Endif
6031 Endif
6032 Endwith
6033 If Used("__TmpCursor")
6034 Use In __TmpCursor
6035 Endif
6036 If Used("_PPK_Qty")
6037 Use In _PPK_Qty
6038 Endif
6039
6040 * --- TR 1046519 7/26/10 CM
6041 IF USED("__SumSlnQty")
6042 USE IN __SumSlnQty
6043 ENDIF
6044 * === TR 1046519 7/26/10 CM
6045
6046 Select(lnOldSelect)
6047 Return llRetVal
6048
6049 *----------------------------------------------------------------------------------------
6050 *- 1006607 09/02/04 YIK
6051 Function ResolveRangeP
6052 Lparameters pceipoTH, pceipoTD, pceipoCR
6053
6054 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
6055 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
6056 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
6057 llRetVal = .T.
6058 lnOldSelect = Select()
6059
6060 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6061 lcRngp_conv = ""
6062 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6063
6064 With This
6065 .oLog.LogMajorStage("Range Style Implosion.")
6066 *- do we have any range styles 'P' in BC
6067 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
6068 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
6069 If !llRetVal Or Recc("tcTemp") = 0
6070 .oLog.LogEntry("No range styles for implosion")
6071 Return llRetVal
6072 Endif
6073
6074 *- 1007637 11/17/04 YIK
6075 *- Allow open stock: Rng_impl = 'O'
6076 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
6077 *- implode only orders that have not been range imploded (empty range style)
6078 *- and were not prepack imploded (implosion <> "Y")
6079 *!* select distinct fkey ;
6080 *!* from (pceipoTd) d ;
6081 *!* join (pceipoCR) c ;
6082 *!* on d.division = c.division and d.customer = c.customer ;
6083 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
6084 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
6085 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
6086 *!* into cursor rng_det
6087
6088*- 1047842/1048069 07/01/10 YIK
6089*- Implode only orders with no detail errors
6090*-- Select Distinct fkey, C.Rng_impl ;
6091*-- FROM (pceipoTD) d ;
6092*-- JOIN (pceipoCR) C ;
6093*-- ON d.division = C.division And d.customer = C.customer ;
6094*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6095*-- AND !Empty(d.division) And !Empty(d.customer) ;
6096*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
6097*-- INTO Cursor rng_det
6098
6099 *- TR 1058336 FH - added division to select, and group by
6100 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
6101 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6102 FROM (pceipoTD) d ;
6103 JOIN (pceipoCR) C ;
6104 ON d.division = C.division And d.customer = C.customer ;
6105 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6106 AND !Empty(d.division) And !Empty(d.customer) ;
6107 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6108 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6109 HAVING MAX(errs_flg_d) = 'N' ;
6110 INTO Cursor rng_det
6111*===
6112
6113 *==
6114 *--- TR 1023892 NH
6115 IF .lALLOW_RANGE_HDR_LABEL
6116 &&- TR 1058336 FH - added qualifier for division
6117 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
6118 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6119 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 ;
6120 FROM (pceipoTD) d ;
6121 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6122 WHERE !EMPTY(d.STYLE) ;
6123 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
6124 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
6125 INTO CURSOR __TmpCurs
6126 ELSE
6127 &&- TR 1058336 FH - added qualifier for division
6128 *=== TR 1023892 NH
6129 *- 1047842/1048069 07/01/10 YIK
6130 *- Added d.pkey
6131 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6132 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
6133 FROM (pceipoTD) d ;
6134 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6135 WHERE !Empty(d.Style) ;
6136 AND !Empty(d.division) And !Empty(d.customer) ;
6137 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6138 INTO Cursor __tmpCurs
6139 ENDIF && TR 1023892 NH
6140 .cSQLTempTable=""
6141 If .GenerateSQLTempTable('__TmpCurs')
6142 If .PopulateSQLTempTable('__TmpCurs')
6143 If !Empty(.cSQLTempTable)
6144 Select rng_det
6145 Scan
6146 lnFKey = rng_det.fkey
6147 *- 1007637 11/17/04 YIK
6148 lcRng_Impl = rng_det.Rng_impl
6149
6150 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6151 lcRngp_conv = rng_det.Rngp_conv
6152 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6153
6154 lcDivision = rng_det.division &&- TR 1058336 FH
6155
6156 *- one order at a time. Select on the server side.
6157 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
6158 dtl = SQLTableFromQuery(lcSQLStr )
6159 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
6160
6161 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
6162 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
6163
6164 Select (pceipoTD)
6165 Do Case
6166 Case lnResult = 0 && match not found
6167 *- 1007637 11/17/04 YIK
6168 If lcRng_Impl = 'Y'
6169
6170 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
6171 Errs_Flg_D With "Y" ;
6172 FOR fkey = lnFKey And !Empty(Style) ;
6173 AND !Empty(division) And !Empty(customer) ;
6174 AND Empty(rng_style) And implosion <> "Y"
6175 Endif
6176 Case lnResult > 1 && ambiguous
6177 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
6178 *- 1049007 08/24/10 YIK
6179 *- List all ambiguous Range Styles
6180 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
6181 Errs_Flg_D With "Y" ;
6182 FOR fkey = lnFKey And !Empty(Style) ;
6183 AND !Empty(division) And !Empty(customer) ;
6184 AND Empty(rng_style) And implosion <> "Y"
6185*!* lcErrorMsg = " Ambiguous range styles "
6186*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
6187*!* lcErrorMsg = lcErrorMsg + ": "
6188*!* SELECT __tmp
6189*!* SCAN
6190*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
6191*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
6192*!* EndScan
6193*!* SELECT(pceipoTD)
6194*!* ENDIF
6195*!*
6196*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
6197*!* Errs_Flg_D With "Y" ;
6198*!* FOR fkey = lnFKey And !Empty(Style) ;
6199*!* AND !Empty(division) And !Empty(customer) ;
6200*!* AND Empty(rng_style) And implosion <> "Y"
6201 *=== 1049007
6202 Endcase
6203 Endscan
6204 Endif
6205 Endif
6206 Endif
6207
6208 Endwith
6209 Select (lnOldSelect)
6210 Return llRetVal
6211 Endfunc
6212
6213 Function RangeImplosion
6214 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6215 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6216 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6217
6218 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6219 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6220 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6221
6222 llRetVal = .T.
6223 lnOldSelect = Select()
6224 With This
6225
6226 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6227 *- turn them vertical into SQL-side temp table var. RangD
6228 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6229 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6230*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6231*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6232*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6233*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6234*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6235*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6236
6237*!* Added following join
6238*!* " join " + dtl + " td1 " +;
6239*!* " on d.style = td1.style " +;
6240*!* " and d.color_code = td1.color_code " +;
6241*!* " and d.lbl_code = td1.lbl_code " +;
6242*!* " and d.dimension = td1.dimension "
6243
6244 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6245
6246 *--- TR 1084825 20-Feb-2015 BNarayanan adding the join on division, sizebucket for the dtl table join ---
6247 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6248 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6249 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6250 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6251 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6252 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6253 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6254 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6255 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6256 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6257 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6258 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6259 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6260 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6261 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6262 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6263 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6264 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6265 "coalesce(cs.e_price,d.e_price) as e_price "+;
6266 "from ( " +;
6267 " select dd.* from zzxrangd dd " +;
6268 " where fkey in ( " +;
6269 " select distinct ph.pkey " +;
6270 " from zzxrangh ph " +;
6271 " join zzxrangd pd " +;
6272 " on ph.Pkey = Pd.Fkey " +;
6273 " join " + dtl + " td1 " +;
6274 " on pd.division = td1.division " + ; && TR 1084825 03-Mar-2015 BNarayanan
6275 " and pd.style = td1.style " +;
6276 " and pd.color_code = td1.color_code " +;
6277 " and pd.lbl_code = td1.lbl_code " +;
6278 " and pd.dimension = td1.dimension " +;
6279 " where ph.rng_type = 'P' " +;
6280 " and not exists( " +;
6281 " select * " +;
6282 " from zzxrangd da " +;
6283 " left join " + dtl + " det " +;
6284 " on det.division= da.division" +; && TR 1084825 03-Mar-2015 BNarayanan
6285 " and det.style = da.style " +;
6286 " and det.color_code = da.color_code " +;
6287 " and det.lbl_code = da.lbl_code " +;
6288 " and det.dimension = da.dimension " +;
6289 " where da.Fkey = ph.pkey " +;
6290 " and (det.Pkey is null " +;
6291 " or case det.SizeBucket " +;
6292 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6293 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6294 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6295 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6296 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6297 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6298 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6299 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6300 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6301 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6302 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6303 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6304 " ) ) d " +;
6305 " join zzxbuckt b " +;
6306 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6307 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6308 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6309 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6310 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6311 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6312 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6313 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6314 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6315 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6316 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6317 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 "+ ;
6318 " join " + dtl + " td1 " +;
6319 " on d.division = td1.division " +; && TR 1084825 20-Feb-2015 BNarayanan
6320 " and d.style = td1.style " +;
6321 " and d.color_code = td1.color_code " +;
6322 " and d.lbl_code = td1.lbl_code " +;
6323 " and d.dimension = td1.dimension "+;
6324 " and size_num = td1.sizebucket " +; && TR 1084825 20-Feb-2015 BNarayanan
6325 " Left join zzxcsrgh cs "+ ;
6326 " on cs.dtlpkey = d.pkey "+ ;
6327 " and cs.customer = td1.customer "
6328
6329
6330 RangD = SQLTableFromQuery(lcSQLString)
6331
6332 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6333 *- possible combinations of RangD that cover them.
6334 *- Result is SQL-side temp table var. RangeSet
6335 *- 1047842/1048069 07/01/10 YIK
6336 *- Added td.pkey
6337 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6338 *--- 1049007 08/24/10 YIK
6339 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6340 *- to check for components divisibility
6341 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6342 *--- TR 1084825 03-Mar-2015 BNarayanan added td.division in the select ---
6343 lcSQLString = ;
6344 'select td.division, td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6345 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6346 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6347 ',td.pkey as dtl_pkey ' + ;
6348 ' from ' + dtl + ' td ' + ;
6349 ' cross join ( ' + ;
6350 ' select * ' + ;
6351 ' from zzxrangh H ' + ;
6352 ' where exists ( ' + ;
6353 ' select * ' + ;
6354 ' from ' + RangD + ' dd ' + ;
6355 ' join ' + dtl + ' td1 ' + ;
6356 ' on dd.Division = td1.Division ' + ;
6357 ' and dd.style = td1.style ' + ;
6358 ' and dd.color_code = td1.color_code ' + ;
6359 ' and dd.lbl_code = td1.lbl_code ' + ;
6360 ' and dd.dimension = td1.dimension ' + ;
6361 ' and dd.size_bk = td1.sizebucket ' + ;
6362 ' where dd.FKey = H.PKey )) mtch ' + ;
6363 ' left join ' + RangD + ' D ' + ;
6364 ' on d.FKey = mtch.PKey ' + ;
6365 ' and d.Division = td.Division ' + ;
6366 ' and d.style = td.style ' + ;
6367 ' and d.color_code = td.color_code ' + ;
6368 ' and d.lbl_code = td.lbl_code ' + ;
6369 ' and d.dimension = td.dimension ' + ;
6370 ' and d.size_bk = td.sizebucket ' + ;
6371 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6372 *==104900708/24/10YIK
6373 RangeSet = SQLTableFromQuery(lcSQLString)
6374
6375 * --- TR 1048126 8/23/10 CM
6376 v_SqlExec(lcSQLString, "tcRangeSet")
6377
6378 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6379*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6380*!*
6381*!* UPDATE d ;
6382*!* SET ppk_qty = -1 ;
6383*!* FROM (pceipoTD) d ;
6384*!* JOIN tcRangeSet r ;
6385*!* ON d.pkey = r.dtl_pkey ;
6386*!* WHERE d.ppk_action $ 'XM'
6387*!*
6388*!* ENDIF
6389 *=== TR 1051390 23-Dec-2010 Goutam
6390
6391 * === TR 1048126 8/23/10 CM
6392
6393 *- how many different range styles were found for this order
6394 *--- 1049007 08/24/10 YIK
6395 *- Modify logic to determine ambiguos Range Styles
6396*-- lcSQLString = ;
6397*-- ' select count(*) PPKCnt ' + ;
6398*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6399
6400 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6401 *= 1049007
6402
6403 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6404 lnPPKCnt = tmp_cnt.PPKCnt
6405
6406 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6407 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6408 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6409
6410 *--- the result (Query #2):
6411 *- See if any single range style in the RangeSet fully matches DTL
6412 *- 1047842/1048069 07/01/10 YIK
6413 *- added t1dtl_pkey
6414 lcSQLString = ;
6415 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6416 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6417 ' from ' + dtl + ' dtl ' + ;
6418 ' join ' + RangeSet + ' t1 ' + ;
6419 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6420 ' and dtl.style = t1.style ' + ;
6421 ' and dtl.color_code = t1.color_code ' + ;
6422 ' and dtl.lbl_code = t1.lbl_code ' + ;
6423 ' and dtl.dimension = t1.dimension ' + ;
6424 ' and dtl.sizebucket = t1.sizebucket ' + ;
6425 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6426 ' having count(*) = (select count(*) from ' + dtl + ') '
6427 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6428 lnCnt = Reccount()
6429
6430 *- 1049007 08/24/10 YIK
6431 *- Exclude Range styles that are not divisible
6432 IF (lnCnt > 0)
6433 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6434 lnCnt = _TALLY
6435 ENDIF
6436 *=
6437
6438 llSingleMatch = .F.
6439 llAmbig = .F.
6440 *- 1047842/1048069 07/01/10 YIK
6441 *- Added ValidDetail
6442 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6443 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6444 Do Case
6445 Case lnCnt > 1
6446 *- 1049007 08/24/10 YIK
6447 USE IN SELECT("__tmp")
6448 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6449 *=
6450 llAmbig = .T. && ambiguos, give error message and do not continue
6451 Case lnCnt = 1
6452 llSingleMatch = .T.
6453 *- 1047842/1048069 07/01/10 YIK
6454 *- Added ValidDetail
6455 *- 1049007 08/26/10 YIK
6456 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6457* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6458 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6459 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6460
6461 Otherwise
6462 Endcase
6463 *- 1049007 08/24/10 YIK
6464 *- commented out. This method is not called with this parameter = .T.
6465*--- IF tlNoConsol
6466*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6467*--- ENDIF
6468
6469 lnResult = lnCnt
6470
6471 If !llAmbig
6472 *- If none single range style in the RangeSet fully matches DTL,
6473 *- or even if a match was found
6474 *- start going through combinations of 2,3... - may be ambiguous
6475
6476 *- 1047842/1048069 07/01/10 YIK
6477 *- added t1dtl_pkey
6478 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6479
6480 lcTopStr = ;
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
6490 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6491 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6492 lcMiddleStr = ''
6493 lcCoalStr_pkey = 't1.pkey'
6494 lcCoalRevStr_pkey = 't1.pkey'
6495 lcCoalStr_ratio = 't1.ratio'
6496 lcCoalRevStr_ratio = 't1.ratio'
6497 lcGroupFkeyStr = ' t1.FKey'
6498 lcGroupStr = ''
6499
6500 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6501 *lnPrepacks = Min(lnPPKCnt, 6)
6502 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6503 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6504 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6505
6506 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6507
6508 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6509 llFoundNext = .F.
6510
6511 lcnum = Trans(j, "9")
6512 lcPrevNum = Trans(j - 1, "9")
6513 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6514 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6515
6516 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6517
6518 *-- TR 1049817 Oct-12-2010 BR
6519 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6520 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6521 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6522 *== TR 1049817 Oct-12-2010 BR
6523
6524 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6525
6526 *--- TR 1049817 Oct-12-2010 BR
6527 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6528 lcGroupStr = lcGroupFkeyStr
6529 *=== TR 1049817 Oct-12-2010 BR
6530
6531 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6532 *- 06/30/10 YIK LOCAL ONLY
6533 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6534 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6535 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6536 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6537
6538 lcMiddleStr = lcMiddleStr + ;
6539 "join " + RangeSet + " t" + lcnum + ;
6540 ' on dtl.division = t' + lcnum + '.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6541 ' and dtl.style = t' + lcnum + '.style ' + ;
6542 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6543 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6544 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6545 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6546 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6547
6548 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6549 ' Group by ' + lcGroupStr
6550
6551 *--- TR 1049817 Oct-12-2010 BR
6552 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6553 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6554 *=== TR 1049817 Oct-12-2010 BR
6555
6556 *--- TR 1050754 NOV-15-2010 BR
6557 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6558 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6559 *=== TR 1050754 NOV-15-2010 BR
6560
6561 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6562 lnCnt = Reccount()
6563 llFoundNext = (lnCnt = 1)
6564 *- ambig when either prev or this SQL returned more than 1 row or
6565 *- one match was found before AND one is found now - making it two.
6566 If lnCnt > 0
6567 Scan
6568 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6569 *- divisible by the number of items in the range style!!!
6570
6571 *---TR 1049817 Oct-12-2010 BR
6572 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6573 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6574 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6575 *===TR 1049817 Oct-12-2010 BR
6576 Else
6577 lcInsertStr = Trans(fkey)
6578 *- 1047842 06/17/10 YIK
6579 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6580
6581 For lnCounter = 2 To j
6582
6583 *- TR 1055009 FH - added If statement
6584 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6585
6586 else
6587 *- 1047842 06/17/10 YIK
6588 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6589 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6590 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6591 *- Added ValidDetail
6592 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6593 ENDIF
6594 *- TR 1055009 FH
6595
6596 Endfor
6597
6598 *---TR 1049817 Oct-12-2010 BR
6599 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6600 lcInsertRatioStr = Trans(t1_ratio)
6601
6602 For lnCounter = 2 To j
6603 *- TR 1055009 FH - added If statement
6604 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6605
6606 ELSE
6607 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6608 ENDIF
6609 *- TR 1055009 FH - added If statement
6610 ENDFOR
6611 *== =TR 1049817 Oct-12-2010 BR
6612
6613 *- 1047842/1048069 07/01/10 YIK
6614 *- Added ValidDetail
6615 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6616 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6617
6618 Endif
6619 Endscan
6620 Endif
6621 lnResultCnt = Recc("q_Result")
6622 llAmbig = (lnResultCnt > 1)
6623 llSingleMatch = (lnResultCnt = 1)
6624 If llAmbig
6625 lnResult = lnResultCnt
6626 Exit
6627 Endif
6628 Endfor
6629 If llSingleMatch
6630 lnResult = 1
6631 IF NOT tlNoConsol
6632 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6633
6634 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6635 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6636 ENDIF
6637 Endif
6638 Else && ambiguous
6639 lnResult = lnCnt
6640 Endif
6641
6642 *--- TR 1051390 23-Dec-2010 Goutam
6643 IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6644 UPDATE d ;
6645 SET ppk_qty = -1 ;
6646 FROM (pceipoTD) d ;
6647 JOIN tcRangeSet r ;
6648 ON d.pkey = r.dtl_pkey ;
6649 WHERE d.ppk_action $ 'XM'
6650 ENDIF
6651 *=== TR 1051390 23-Dec-2010 Goutam
6652
6653 Endwith
6654 Return lnResult
6655
6656 Procedure ConsolidateRangeP
6657 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6658 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6659 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6660
6661 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6662
6663 LOCAL lcDvision && 1058336 FH
6664
6665 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6666 LOCAL lnOrgPrice
6667 IF EMPTY(pcRngp_conv )
6668 pcRngp_conv = "N"
6669 ENDIF
6670 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6671
6672 llRetVal = .T.
6673 lnOldSelect = Select()
6674
6675 *- insert range styles that match zzxrangd.fkey from q_result
6676 *- into pceipotd.
6677 *- parse the string from cursor q_result to get the list of fkeys
6678 *- 1047842/1048069 07/01/10 YIK
6679 *- Moved Locate down
6680*-- Select (pceipoTD)
6681*-- Locate For fkey = pnFkey
6682*-- Scatter Name oDtl Memo
6683
6684 Declare aRange[1]
6685 aRange = ''
6686 Select q_Result
6687 Scatter Memvar Memo
6688 *- 1030497 02/29/08 TT
6689 *--StringToArray(m.ValidRange, @aRange, ",")
6690
6691 *--TR 1040854 Jun-11-09 BR
6692 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6693 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6694 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6695 *==TR 1040854 Jun-11-09 BR
6696
6697 *- 1030497 02/29/08 TT
6698 *-- TR 1049817 Oct-12-2010 BR
6699 *lnLen = Alen(aRange) - 1 && the last element is ratio
6700 lnLen = Alen(aRange)
6701 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6702 *== TR 1049817 Oct-12-2010 BR
6703
6704 *- 1047842/1048069 07/01/10 YIK
6705 Declare aDetail[1]
6706 aDetail = ''
6707 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6708 *= 1047842/1048069
6709
6710 *-- TR 1049817 Oct-12-2010 BR
6711 DECLARE aRatios[1]
6712 aRatios = ''
6713 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6714 *== TR 1049817 Oct-12-2010 BR
6715
6716 For j = 1 To lnLen
6717 lcFkey = aRange[j]
6718 *- 1047842/1048069 07/01/10 YIK
6719 lnDtl_Pkey = EVALUATE(aDetail[j])
6720 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6721
6722 Select (pceipoTD)
6723 Locate For pkey = lnDtl_Pkey
6724 Scatter Name oDtl Memo
6725 *= 1047842/1048069
6726 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6727*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6728 *--- TR 1084825 20-Feb-2015 BNarayanan removed the column h.RNG_PACK_001, which is not available in zzxrangh table and where clause ---
6729 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6730 " coalesce(cs.a_price,h.a_price) as a_price, "+;
6731 " coalesce(cs.b_price,h.b_price) as b_price, "+;
6732 " coalesce(cs.c_price,h.c_price) as c_price, "+;
6733 " coalesce(cs.d_price,h.d_price) as d_price, "+;
6734 " coalesce(cs.e_price,h.e_price) as e_price, "+;
6735 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
6736 " h.SOURCETYPE,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
6737 " From zzxrangh h " + ;
6738 " Left Join zzxcsrgh cs "+ ;
6739 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
6740 " and cs.customer = "+ SQLFormatChar(oDtl.Customer) + ;
6741 " where h.pkey = " + lcFkey && 1084825
6742 v_SqlExec(lcSQL ,"__RangH")
6743 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
6744 lcDvision = __RangH.division && 1058336 FH
6745
6746 oDtl.Style = __RangH.rng_style
6747 oDtl.color_code = __RangH.rng_color
6748 oDtl.lbl_code = __RangH.rng_lbl
6749 oDtl.Dimension = __RangH.rng_pack
6750 oDtl.rng_style = __RangH.rng_style
6751 oDtl.rng_color = __RangH.rng_color
6752 oDtl.rng_lbl = __RangH.rng_lbl
6753 oDtl.rng_pack = __RangH.rng_pack
6754 oDtl.rng_qty = __RangH.rng_qty
6755 oDtl.rng_type = __RangH.rng_type
6756 *- don't have to have upc or sku for the imploded range style
6757 oDtl.upc = ''
6758 oDtl.sku = ''
6759 oDtl.coord_code = __RangH.coord_code
6760 oDtl.a_price = __RangH.a_price
6761 oDtl.b_price = __RangH.b_price
6762 oDtl.c_price = __RangH.c_price
6763 oDtl.d_price = __RangH.d_price
6764 oDtl.e_price = __RangH.e_price
6765 *- clear err msg and err flag which may have error after unsuccessful implosion
6766 oDtl.Errs_Msg_D = ""
6767
6768 *- 1009211 03/09/05 YIK
6769 *- Initializ3e errs_flg_d to N, not blank
6770 *- oDtl.Errs_Flg_D = " "
6771 oDtl.Errs_Flg_D = "N"
6772 *- org_price is based on zzocntrc (cust sales) price_code
6773 *- we'll get the proper price_code in ValidOrderControl()
6774 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
6775
6776 *- 1009211 02/24/05 YIK
6777 *- Keep quantity in cases and use price per case.
6778 *- and zero out orig price which will be resolved.
6779 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
6780
6781 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6782 lnOrgPrice = oDtl.org_price
6783 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6784
6785 oDtl.total_qty = lnRatio
6786 oDtl.org_price = 0
6787
6788 *--- TR 1060800 24-May-2012 Goutam.
6789 oDtl.Rng_Impl = pcRng_Impl
6790 oDtl.Rngp_conv = pcRngp_conv
6791 *=== TR 1060800 24-May-2012 Goutam.
6792
6793 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6794 IF pcRngp_conv = "R"
6795 *--- TechRec 1057383 15-Dec-2011 jisingh ---
6796*!* oDtl.ppk_qty = __RangH.rng_qty
6797*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
6798*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6799*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6800*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
6801*!* oDtl.ppk_action = 'X'
6802
6803 IF EMPTY(oDtl.ppk_action)
6804 oDtl.org_price = lnOrgPrice
6805 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
6806 ENDIF
6807
6808 IF oDtl.ppk_action = "B"
6809 oDtl.org_price = lnOrgPrice
6810 oDtl.ppk_qty = __RangH.rng_qty
6811 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6812 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6813 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6814 oDtl.ppk_action = 'X'
6815 ENDIF
6816
6817 IF oDtl.ppk_action = "Q" && Qty conversion only
6818 oDtl.org_price = lnOrgPrice
6819 oDtl.ppk_qty = __RangH.rng_qty
6820 oDtl.retail1 = oDtl.retail1
6821 oDtl.retail2 = oDtl.retail2
6822 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6823 oDtl.ppk_action = 'M'
6824 ENDIF
6825
6826 IF oDtl.ppk_action = "P" && Price conversion only
6827 oDtl.org_price = lnOrgPrice
6828 oDtl.ppk_qty = __RangH.rng_qty
6829 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6830 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6831 oDtl.total_qty = oDtl.total_qty
6832 oDtl.ppk_action = 'D'
6833 ENDIF
6834 *=== TechRec 1057383 15-Dec-2011 jisingh ===
6835 ENDIF
6836 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6837
6838 *= 1009211
6839 *- 1047842/1048069 07/01/10 YIK
6840 *- Clear po1_upc and po1_sku as they get populated on the way out
6841 oDtl.po1_upc = ''
6842 oDtl.po1_sku = ''
6843
6844
6845 *- Per JR, put into the 1st available size bucket
6846 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
6847 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
6848 If !llRetVal
6849 Exit
6850 Else
6851 *-- TR 1049817 Oct-12-2010 BR
6852 *oDtl.sizebucket = At("Y", __tmp.sizes)
6853 oDtl.sizebucket = __RangH.rng_bk
6854 oDtl.rng_bk = oDtl.sizebucket
6855 lcSzStr = __tmp.sizes
6856 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
6857 *== TR 1049817 Oct-12-2010 BR
6858 Endif
6859 *-- TR 1049817 Oct-12-2010 BR
6860 IF !llValidRngBk
6861 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
6862 oDtl.errs_flg_d = 'Y'
6863 ELSE
6864 *== TR 1049817 Oct-12-2010 BR
6865 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
6866 llRetVal = .F.
6867 Exit
6868 Endif
6869 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
6870 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
6871
6872 *--- TR 1059965 6-Mar-12 Venuk
6873 *oDtl.pkey = v_nextPkey("ZZEIPOID")
6874 * ENDIF
6875 ENDIF
6876 oDtl.pkey = v_nextPkey("ZZEIPOID")
6877 *=== TR 1059965 6-Mar-12 Venuk
6878
6879 Select (pceipoTD)
6880 Append Blank
6881
6882 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
6883 *Gather Name oDtl
6884 Gather Name oDtl memo
6885 *=== TR 1065271 11-Jan-2013 BNarayanan ===
6886
6887 Endfor
6888 If llRetVal
6889 *- delete components
6890 Delete For fkey = pnFkey And !Empty(Style) ;
6891 AND !Empty(division) And !Empty(customer) ;
6892 AND Empty(rng_style) And implosion <> "Y" ;
6893 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
6894 IN (pceipoTD)
6895 Endif
6896 Select (lnOldSelect)
6897 Return llRetVal
6898 *========== 1006607 09/02/04 YIK
6899
6900 *----------------------------------------------------------------------------------------
6901
6902 *--- TechRec 1005163 17-May-2004 GS ---
6903 *-- Validating SLN vs. Prepack
6904 Procedure CheckSLN
6905 Parameters pceipoTH, pceipoTD, pceipoTS
6906 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
6907 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
6908 lcDtl_lbl_code && *-TR 1075660 SK
6909
6910 lnOldDtlPKey = -1
6911 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
6912 *--- TR 1023892 NH
6913 lnOldSelect = SELECT()
6914 llRetVal = .t.
6915 *=== TR 1023892 NH
6916 Select (pceipoTS)
6917 Set Order To Tag fkey
6918
6919 SCAN
6920 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
6921 IF SkipSlnChk = "Y"
6922 LOOP
6923 ENDIF
6924 *=== TR 1035223 NH
6925
6926 If lnOldDtlPKey != fkey
6927 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
6928 *-- this checks that there is no more records left in BC PrePack info
6929 *-- after all matching to SLNs deleted. Made as a separate routine
6930 *-- because it must be called when detail key changed and when scan is finished.
6931 *-- Error info applied to Detail.
6932 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
6933 Endif
6934 lnOldDtlPKey = fkey
6935 lcPPackError = ""
6936 lcDtlError = ""
6937 Select (pceipoTD)
6938 *- 1008909 01/18/05 YIK
6939 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
6940 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
6941 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
6942 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
6943 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
6944 lcDtl_lbl_code = IIF(llRangeStyle, NULL, lbl_code) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
6945
6946 *- 1013522 10/17/05 12/02/05 YIK
6947 *- Check for the range style type P. For it there's no explosion to components and the range
6948 *- style info is not written into detail table, but it is still a range style and we should skip it.
6949 Local Array laRangP[1]
6950 laRangP[1] = 0
6951 *--- TR 1023892 NH
6952 IF .lALLOW_RANGE_HDR_LABEL
6953 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
6954 SELECT COUNT(*) ;
6955 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6956 ON d.division = r.division ;
6957 AND d.STYLE = r.rng_style ;
6958 AND d.color_code = r.rng_color ;
6959 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
6960 AND d.DIMENSION = r.rng_pack ;
6961 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
6962 INTO ARRAY laRangP
6963 ELSE
6964 *=== TR 1023892 NH
6965 Select Count(*) ;
6966 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6967 On d.division = r.division ;
6968 AND d.Style = r.rng_style ;
6969 AND d.color_code = r.rng_color ;
6970 AND d.lbl_code = r.rng_lbl ;
6971 AND d.Dimension = r.rng_pack ;
6972 INTO Array laRangP
6973 ENDIF && TR 1023892 NH
6974 llRangeStyle = llRangeStyle Or laRangP[1] > 0
6975 *= 1013522 YIK
6976
6977 llDtlHasError = (Errs_Flg_D = 'Y')
6978 *- 1008909 01/18/05 YIK
6979 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
6980 If llDtlHasError Or llRangeStyle
6981 *= 1008909
6982 Loop && For unresolved Details do not even bother...
6983 Endif
6984
6985 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
6986 *-- set to NULL if any C and/or L can be used for the PrePack:
6987 *- 08/25/04 YIK
6988 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
6989 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
6990 lcSQL = ;
6991 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
6992 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
6993 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
6994 " d.Dimension, Pack_Total," +;
6995 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
6996 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
6997 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
6998 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
6999 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7000 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
7001 " Size_Num as Sizebucket" +;
7002 " from zzxscolr c" +;
7003 " join zzxstylr st"+;
7004 " on st.pkey = c.fkey "+;
7005 " join zzxppakh h" +;
7006 " on h.Division = c.Division" +;
7007 " and h.PPK_CODE = c.Dimension" +;
7008 " and h.Size_Code = st.Size_Code" +; && TR 1026025
7009 " join zzxppakd d" +;
7010 " on d.Fkey = h.PKey" +;
7011 " cross join zzxbuckt" +;
7012 " where c.Division = " + SQLFormatChar(division ) + ;
7013 " and c.Style = " + SQLFormatChar(Style ) + ;
7014 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
7015 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
7016 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
7017 " and c.PPack_Ok = 'Y'" +;
7018 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7019 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7020 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7021 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7022 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7023 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
7024 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
7025
7026 v_SqlExec(lcSQL, "tcPPK")
7027 If Reccount("tcPPK") > 0
7028 lnPPK_SLN_Diff = pack_qty
7029 Else
7030 lnPPK_SLN_Diff = 0
7031 Endif
7032 Endif
7033 *- 1008909 01/18/05 YIK
7034 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7035 If llDtlHasError Or llRangeStyle
7036 Loop && For unresolved Details do not even bother...
7037 Endif
7038
7039 Select (pceipoTS)
7040
7041 If Reccount("tcPPK") = 0
7042 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
7043 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7044 Loop
7045 Endif
7046
7047 If tcPPK.active_ok = 'N'
7048 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
7049 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7050 Loop
7051 Endif
7052
7053 If Errs_Flg_S = 'Y'
7054 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
7055 Loop && UPC/EAN/SKU is unesolved.
7056 Endif
7057
7058 lcStyle = style && *- TR 1064758 FH
7059 lcColor_code = color_code
7060 lcLbl_code = lbl_code
7061 lcDimension = Dimension
7062 lnSLN_Qty = SLN_Qty
7063 lnSizeBucket = sizebucket
7064
7065 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
7066 Select tcPPK
7067
7068 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
7069 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
7070 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
7071 AND Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code && *--- TR 1075660 03-Jan-2014 SK ===
7072
7073 If Found()
7074 Delete && in PrePack info leave only unresolved ones.
7075 Else
7076 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
7077 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
7078 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
7079 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
7080 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
7081 If !"Has errors in SLNs."$lcDtlError
7082 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
7083 Endif
7084 Endif
7085
7086 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
7087 *if lnPPK_SLN_Diff < 0
7088 *endif
7089 Endscan
7090 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
7091
7092 *- 1008909 01/18/05 YIK
7093 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
7094 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
7095 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7096 Endif
7097 *- 1013522 10/17/05 12/02/05 YIK
7098 If Used("__RangeP")
7099 Use In __RangeP
7100 Endif
7101 *=
7102 *--- TR 1023892 NH
7103 SELECT(lnOldSelect)
7104 RETURN llRetVal
7105 *== TR 1023892 NH
7106
7107 Endproc
7108
7109 *----------------------------------------------------------------------------------------
7110 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
7111 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
7112 Procedure CheckSlnSet
7113 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
7114
7115 Local lnOldSelect
7116
7117 lnOldSelect = Select()
7118
7119 If !Empty(tcPPKError)
7120 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7121 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7122 Return
7123 Endif
7124
7125 Select tcPPK
7126 Scan
7127 tcDtlError = tcDtlError +;
7128 "Missing Prepack Component" + ;
7129 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
7130 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
7131 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
7132 "; Qty:"+Transform(Qty) + CRLF
7133 Endscan
7134
7135 If !Empty(tcDtlError)
7136 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7137 Local lcErr
7138 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
7139 If !Empty(lcErr)
7140 tcDtlError = CRLF + tcDtlError
7141 Endif
7142 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7143 Endif
7144
7145 Select (lnOldSelect)
7146
7147 Endproc
7148
7149 *----------------------------------------------------------------------------------------
7150
7151 ************************************************************************************
7152 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7153 * 1. Try to substitute lbl_code with customer label when have the following conditions:
7154 * Header: customer
7155 * Detail: division,style,color_code
7156 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
7157 * resolve all detail division into header )
7158 ************************************************************************************
7159 Procedure ResolveCustomerLabel
7160 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7161 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
7162 Local llRetVal, lnOldSelect
7163 llRetVal = .T.
7164 lnOldSelect = Select()
7165 With This
7166 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
7167 *--- TechRec 1048667 03-May-2011 GSternik ---
7168 *-- Not needed, already done in the calling CheckDetail
7169 *.LogEntry("Cascading Customer To Detail.")
7170 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
7171 *=== TechRec 1048667 03-May-2011 GSternik ===
7172 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
7173 .LogEntry("Substituding customer label.")
7174 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7175 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
7176 .LogEntry("Auto creating style.")
7177 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7178 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
7179 * PL 08/22/01 27847 Auto-create Customer SKU
7180 .LogEntry("Auto creating customer style.")
7181 *--- TechRec 1005163 18-May-2004 GS ---
7182 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7183 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
7184 *=== TechRec 1005163 18-May-2004 GS ===
7185
7186 Endwith
7187 Select(lnOldSelect)
7188 Return llRetVal
7189 Endproc
7190
7191
7192 *----------------------------------------------------------------------------------------
7193 ************************************************************************************
7194 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7195 ************************************************************************************
7196 Procedure CascadingCustomerToDetail
7197 Lparameters pceipoTH, pceipoTD
7198 Local llRetVal, lnOldSelect
7199 llRetVal = .T.
7200 lnOldSelect = Select()
7201 With This
7202 * set header/detail Relation
7203 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
7204 * --- TR 1019358 RLN 10/30/06
7205 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
7206 Replace All customer With &pceipoTH..customer, ;
7207 department With &pceipoTH..department ;
7208 IN (pceipoTD)
7209 * === TR 1019358
7210 Set Relation To
7211 Endwith
7212 Select(lnOldSelect)
7213 Return llRetVal
7214 Endproc
7215
7216 *----------------------------------------------------------------------------------------
7217 *---- TR 1019697 NH
7218 Procedure CascadingCustomerToSLN
7219 Lparameters pceipoTD, pceipoTS
7220 Local llRetVal, lnOldSelect
7221 llRetVal = .T.
7222 lnOldSelect = Select()
7223 With This
7224 * set detail/SLN Relation
7225 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7226 Replace All customer With &pceipoTD..customer In (pceipoTS)
7227 Set Relation To
7228 Endwith
7229 Select(lnOldSelect)
7230 Return llRetVal
7231 Endproc
7232 *==== TR 1019697 NH
7233
7234 *----------------------------------------------------------------------------------------
7235 ************************************************************************************
7236 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7237 ************************************************************************************
7238 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7239 * regardless of auto_create of style flag set in Customer Label Ref.
7240 Procedure SubstitudeValidLabel
7241 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7242 Local llRetVal, lnOldSelect
7243 llRetVal = .T.
7244 lnOldSelect = Select()
7245 With This
7246 *- 1010285 05/18/05 YIK
7247 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7248 *- if the SKU with the label is valid and active in the style master.
7249 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7250 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7251 *-- WHERE h.pkey= d.fkey AND ;
7252 *-- d.division= C.division AND h.customer= C.customer AND ;
7253 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7254 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7255 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7256 *-- INTO CURSOR tmpCurs
7257
7258 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7259 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7260 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7261 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7262 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7263 WHERE h.pkey= d.fkey And ;
7264 d.division= C.division And h.customer= C.customer And ;
7265 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7266 Not (MultiUPC = 'Y') And ;
7267 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7268 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7269 INTO Cursor tmpCurs
7270 *==
7271
7272 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7273 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7274 "customer+division+style+color_code+dimension")
7275 If llRetVal
7276 *- 1010285 05/18/05 YIK
7277 *- 1004785 05/04/04 YIK
7278 *- Added .. AND Empty(Errs_Msg_D)
7279 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7280 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7281 Select (pceipoTD)
7282 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7283 If tmpCurs.resv_label = "Y" Or ;
7284 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7285 AND tmpscolr.active_ok = "Y" )
7286 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7287 Endif
7288 Endscan
7289 *= 1010285
7290 Set Relation To
7291 Endif
7292 .TableClose('tmpCurs')
7293 Endwith
7294 Select(lnOldSelect)
7295 Return llRetVal
7296 Endproc
7297
7298 *----------------------------------------------------------------------------------------
7299 ************************************************************************************
7300 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7301 ************************************************************************************
7302 * encounter for both set up in customer label ref:
7303 * 1. empty label apply to all customer
7304 * 2. none empty customer will be specificly create only for that customer
7305 * either 1 or 2 exists but never both
7306 *
7307 * Get a list of distinct ourSKU to server side to join zzxcolr
7308 Procedure CreateOurSKU
7309 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7310 Local llRetVal, lnOldSelect
7311 llRetVal = .T.
7312 lnOldSelect = Select()
7313 With This
7314 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7315 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7316 WHERE h.pkey= d.fkey And ;
7317 d.division= C.division And h.customer= C.customer And ;
7318 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7319 l.auto_style= 'Y' And ;
7320 C.resv_label= 'Y' And ;
7321 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7322 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7323 INTO Cursor tmpCurs
7324 *--- TR 1019697 NH
7325 *!* SCAN
7326 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7327 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7328 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7329 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7330 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7331 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7332 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7333 *!* .LogEntry("Created style: " + lcOurSKU )
7334 *!* ELSE
7335 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7336 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7337 *!* ENDIF
7338 *!* ENDIF
7339 *!* ENDSCAN
7340 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7341 *=== TR 1019697 NH
7342 Endwith
7343 Select(lnOldSelect)
7344 Return llRetVal
7345 Endproc
7346
7347 *----------------------------------------------------------------------------------------
7348
7349 Procedure CreateCustomerStyle
7350 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7351 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7352 Local llRetVal, lnOldSelect
7353 llRetVal = .T.
7354 lnOldSelect = Select()
7355 With This
7356 *--- TechRec 1005164 18-May-2004 GS ---
7357 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7358 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7359 * Where h.pkey= d.fkey and ;
7360 * d.division= C.division and h.customer= C.customer and ;
7361 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7362 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7363 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7364 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7365 * Into Cursor tmpCurs
7366 If This.oHostProcess.lHaveSLN
7367 Select Distinct C.customer,;
7368 d.division,;
7369 d.Style,;
7370 d.color_code,;
7371 C.lbl_code,;
7372 d.Dimension ;
7373 FROM (pceipoTD) d ;
7374 JOIN (pceipoTH) h ;
7375 ON h.pkey = d.fkey ;
7376 JOIN (pceipoCR) C;
7377 ON d.division= C.division ;
7378 AND h.customer= C.customer ;
7379 JOIN (pcxclblr) l ;
7380 ON C.lbl_code= l.lbl_code ;
7381 WHERE l.auto_style= 'Y' ;
7382 AND C.resv_label= 'Y' ;
7383 AND C.AutoCustSKU= 'Y' ;
7384 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7385 And h.customer > ' ' ;
7386 AND d.division > ' ' ;
7387 AND d.Style > ' ' ;
7388 AND d.color_code > ' ';
7389 UNION ;
7390 SELECT Distinct C.customer,;
7391 d.division,;
7392 d.Style,;
7393 s.color_code,;
7394 C.lbl_code,;
7395 s.Dimension ;
7396 FROM (pceipoTS) s ;
7397 JOIN (pceipoTD) d ;
7398 ON d.pkey = s.fkey ;
7399 JOIN (pceipoTH) h ;
7400 ON h.pkey = d.fkey ;
7401 JOIN (pceipoCR) C ;
7402 ON d.division= C.division ;
7403 AND h.customer= C.customer ;
7404 JOIN (pcxclblr) l ;
7405 ON C.lbl_code= l.lbl_code ;
7406 WHERE l.auto_style= 'Y' ;
7407 AND C.resv_label= 'Y' ;
7408 AND C.AutoCustSKU= 'Y' ;
7409 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7410 And h.customer > ' ' ;
7411 AND d.division > ' ' ;
7412 AND d.Style > ' ' ;
7413 AND s.color_code > ' ';
7414 INTO Cursor tmpCurs
7415
7416 Else
7417
7418 Select Distinct C.customer,;
7419 d.division,;
7420 d.Style,;
7421 d.color_code,;
7422 C.lbl_code,;
7423 d.Dimension ;
7424 FROM (pceipoTD) d ;
7425 JOIN (pceipoTH) h ;
7426 ON h.pkey = d.fkey ;
7427 JOIN (pceipoCR) C ;
7428 ON d.division= C.division ;
7429 AND h.customer= C.customer ;
7430 JOIN (pcxclblr) l ;
7431 ON C.lbl_code= l.lbl_code ;
7432 WHERE l.auto_style= 'Y' ;
7433 AND C.resv_label= 'Y' ;
7434 AND C.AutoCustSKU= 'Y' ;
7435 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7436 And h.customer > ' ' ;
7437 AND d.division > ' ' ;
7438 AND d.Style > ' ' ;
7439 AND d.color_code > ' ';
7440 INTO Cursor tmpCurs
7441
7442 Endif
7443 *=== TechRec 1005164 18-May-2004 GS ===
7444 Scan
7445 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7446 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7447 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7448 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7449 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7450 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7451 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7452 .LogEntry("Created customer style: " + lcCustSKU )
7453 Else
7454 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7455 .LogWarning("Unable to create customer style: " + lcCustSKU )
7456 Endif
7457 Endif
7458 Endscan
7459 Endwith
7460 Select(lnOldSelect)
7461 Return llRetVal
7462 Endproc
7463
7464 *----------------------------------------------------------------------------------------
7465 ************************************************************************************
7466 * Validate UPC for all details
7467 ************************************************************************************
7468 *--- TR 1088986 31-Jul-2015 BNarayanan Method name changed to avoid duplication. This method is obsolete ---
7469 *Procedure CheckUpc
7470 Procedure CheckUpc_obsolete
7471 *=== TR 1088986 31-Jul-2015 BNarayanan ===
7472 Lparameters pceipoTH, pceipoTD,;
7473 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7474
7475 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7476 * Added Parameter pceipocr
7477 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7478
7479 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7480 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7481 lnSize_desc, llSLN
7482
7483 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7484 LOCAL lcIs_upcsku
7485 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7486
7487 llRetVal = .T.
7488 lcErrs_Msg= ""
7489 lnOldSelect = Select()
7490
7491 * cannot check for UPC if customer is empty
7492 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7493 * on Cust SKU or UPC.
7494 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7495
7496 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7497 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7498 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7499
7500 *--- TechRec 1005163 17-May-2004 GS ---
7501 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7502 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7503 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7504 *Order by h.customer, d.upc Into Cursor tmpCurs
7505
7506 *---- TR 1024667 NSD 5/31/07
7507 * If sizebucket = 0 then re-resolve.
7508
7509 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7510 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7511*!* If This.lHaveSLN
7512*!* Select h.customer,;
7513*!* d.upc,;
7514*!* d.pkey,;
7515*!* (pceipoTD) As Src;
7516*!* FROM (pceipoTH) h ;
7517*!* JOIN (pceipoTD) d ;
7518*!* ON h.pkey = d.fkey ;
7519*!* WHERE !Empty(d.upc) ;
7520*!* AND !Empty(h.customer) ;
7521*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7522*!* UNION All ;
7523*!* SELECT h.customer,;
7524*!* s.SLN_UPC As upc,;
7525*!* s.pkey,;
7526*!* (pceipoTS) As Src ;
7527*!* FROM (pceipoTH) h ;
7528*!* JOIN (pceipoTD) d ;
7529*!* ON d.fkey = h.pkey ;
7530*!* JOIN (pceipoTS) s ;
7531*!* ON s.fkey = d.pkey ;
7532*!* WHERE !Empty(s.SLN_UPC) ;
7533*!* AND !Empty(h.customer) ;
7534*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7535*!* ORDER By 1, 2 ;
7536*!* INTO Cursor tmpCurs
7537*!* Else
7538*!* Select h.Customer,;
7539*!* d.UPC,;
7540*!* d.PKey,;
7541*!* (pceipoTD) As Src;
7542*!* FROM (pceipoTH) h ;
7543*!* JOIN (pceipoTD) d ;
7544*!* ON h.pkey = d.fkey ;
7545*!* WHERE !Empty(d.upc) ;
7546*!* AND !Empty(h.customer) ;
7547*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7548*!* ORDER By 1, 2;
7549*!* INTO Cursor tmpCurs
7550*!* Endif
7551 *=== TechRec 1005163 17-May-2004 GS ===
7552
7553 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7554 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7555 FROM (pceipocr) ;
7556 GROUP BY customer ;
7557 INTO CURSOR __ResvCustSKU
7558 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7559
7560 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7561*!* select h.Customer;
7562*!* , d.UPC;
7563*!* , d.PKey;
7564*!* from (pceipoTH) h;
7565*!* join (pceipoTD) d;
7566*!* on h.PKey = d.FKey;
7567*!* where !Empty(d.UPC);
7568*!* and !Empty(h.Customer);
7569*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7570*!* order by 1, 2;
7571*!* into Cursor tmpCurs ReadWrite
7572
7573 Select h.customer;
7574 , d.upc;
7575 , d.pkey,;
7576 (pceipoTD) AS Src;
7577 from (pceipoTH) h;
7578 join (pceipoTD) d;
7579 on h.pkey = d.fkey;
7580 JOIN __ResvCustSKU r ;
7581 ON r.Customer = H.Customer ;
7582 where !Empty(d.upc);
7583 and !Empty(h.customer);
7584 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7585 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7586 order By 1, 2;
7587 into Cursor tmpCurs Readwrite
7588 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7589
7590*=== TechRec 1024522 25-Sep-2007 GSternik ===
7591
7592 lcOldCust = ""
7593 lcOldItem = ""
7594 Select tmpCurs
7595 If This.lUserInterface
7596 * Init Thermometer
7597 This.UpdateThermoCaption("Validating UPC(s)...")
7598 * TAN 31891 - JAZ - 5/20/02
7599 * This.InitThermo(RECC('tmpCurs'))
7600 This.InitThermo(RecCount('tmpCurs'))
7601 * End TAN 31891 - JAZ - 5/20/02
7602 l_nThermoCnt = 0
7603 EndIf
7604
7605 Scan
7606 If This.lUserInterface
7607 * Advance progress bar, if we're using one.
7608 l_nThermoCnt = l_nThermoCnt + 1
7609 This.AdvanceThermo(l_nThermoCnt)
7610 Endif
7611 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7612 lcErrs_Msg = ""
7613 lcOldCust = tmpCurs.customer
7614 lcOldItem = tmpCurs.upc
7615 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7616 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7617
7618 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7619 lcIs_upcsku = ' '
7620 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7621
7622 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7623 lcDivision = tmpCstdr.division
7624 lcStyle = tmpCstdr.Style
7625 lcColor_code = tmpCstdr.color_code
7626 lcLbl_code = tmpCstdr.lbl_code
7627 lcDimension = tmpCstdr.Dimension
7628 lnSizeBucket = tmpCstdr.size_bk
7629 lnSize_desc = tmpCstdr.size_desc
7630
7631 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7632 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7633 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7634
7635 Else
7636 lcErrs_Msg = ""
7637 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7638 lcDivision = tmpUpcnr.division
7639 lcStyle = tmpUpcnr.Style
7640 lcColor_code = tmpUpcnr.color_code
7641 lcLbl_code = tmpUpcnr.lbl_code
7642 lcDimension = tmpUpcnr.Dimension
7643 lnSizeBucket = tmpUpcnr.sizebucket
7644 lnSize_desc = tmpUpcnr.size_desc
7645 Else
7646 lcErrs_Msg = lcErrs_Msg + CRLF
7647 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7648 Store 0 To lnSizeBucket
7649 Endif
7650 Endif
7651 Endif && level break
7652
7653 *--- TechRec 1005163 17-May-2004 GS ---
7654 *Select (pceipoTD)
7655*!* llSLN = (tmpCurs.Src = pceipoTS)
7656*!* If llSLN
7657*!* Select (pceipoTS)
7658*!* Else
7659 Select (pceipoTD)
7660*!* Endif
7661 *=== TechRec 1005163 17-May-2004 GS ===
7662 *- 1010682 04/25/05 YIK
7663 *- Locate For pkey = tmpCurs.pkey
7664 lnWorkArea = Select()
7665 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7666 Scatter Name loEiPOtd Memo
7667 If !Empty(lcErrs_Msg)
7668*!* *--- TechRec 1005163 17-May-2004 GS ---
7669*!* If llSLN
7670*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7671*!* loEiPOtd.Errs_Flg_S = "Y"
7672*!* Else
7673*!* *=== TechRec 1005163 17-May-2004 GS ===
7674 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7675 loEiPOtd.Errs_Flg_D = "Y"
7676*!* Endif
7677 Endif
7678 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7679 loEiPOtd.Division = lcDivision
7680 loEiPOtd.Style = lcStyle
7681 loEiPOtd.Color_Code = lcColor_code
7682 loEiPOtd.Lbl_Code = lcLbl_code
7683 loEiPOtd.Dimension = lcDimension
7684 loEiPOtd.SizeBucket = lnSizeBucket
7685 loEiPOtd.Size_Desc = lnSize_desc
7686
7687 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7688 IF !EMPTY(lcIs_upcsku)
7689 loEiPOtd.Is_upcsku = lcIs_upcsku
7690 ENDIF
7691 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7692
7693 *--- TR 1019697 NH : clear rang style when bc style is set
7694 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7695 loEiPOtd.rng_style = ''
7696 loEiPOtd.rng_color = ''
7697 loEiPOtd.rng_lbl = ''
7698 loEiPOtd.rng_pack = ''
7699 Endif
7700 *=== TR 1019697 NH
7701 Endif
7702
7703 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7704 * only replace our SKU when no range style explosion happen
7705 *--- TechRec 1005163 17-May-2004 GS ---
7706 *If empty(&pceipoTD..rng_style)
7707 * Replace division With loEiPOtd.division, ;
7708 * style With loEiPOtd.style, ;
7709 * color_code With loEiPOtd.color_code, ;
7710 * lbl_code With loEiPOtd.lbl_code, ;
7711 * dimension With loEiPOtd.dimension, ;
7712 * sizebucket With loEiPOtd.sizebucket, ;
7713 * size_desc With loEiPOtd.size_desc, ;
7714 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7715 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7716 * In (pceipoTD)
7717 *Endif
7718 *- 1009508 3/16/05 YIK
7719 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7720 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7721 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7722 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7723 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7724
7725 Gather Name loEiPOtd Memo
7726 Endif
7727 *=== TechRec 1005163 17-May-2004 GS ===
7728 Endscan
7729 Use In tmpCurs
7730
7731 If This.lUserInterface
7732 * Reset Thermometer
7733 This.ResetThermo()
7734 Endif
7735
7736 If Used("tmpCstdr")
7737 Use In tmpCstdr
7738 Endif
7739 If Used("tmpUpcnr")
7740 Use In tmpUpcnr
7741 Endif
7742
7743 Select(lnOldSelect)
7744 Return llRetVal
7745 Endproc
7746
7747 *----------------------------------------------------------------------------------------
7748 ************************************************************************************
7749 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7750 ************************************************************************************
7751 Procedure ValidateOurSKU
7752 Lparameters pceipoTH, pceipoTD, pceipoTS
7753 Local llRetVal, lnOldSelect, lcScolrSQL
7754 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
7755
7756 *--- TechRec 1022705 21-Jun-2007 jjanand ---
7757 LOCAL llActiveCheck
7758 *=== TechRec 1022705 21-Jun-2007 jjanand ===
7759
7760 *--- TR 1017598 14-Sep-2006 SS
7761 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
7762
7763 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
7764
7765 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
7766
7767 *--- TR 1018193 18-NOV-2006 VKK
7768 lcErrs_Allowed_Msg = ""
7769 *=== TR 1018193 18-NOV-2006 VKK
7770
7771 *=== TR 1017598 14-Sep-2006 SS
7772
7773 * --- TR 1039400 3/31/09 CM
7774 LOCAL lcCurrentSku
7775 lcCurrentSku = ""
7776 * === TR 1039400 3/31/09 CM
7777
7778 llRetVal = .T.
7779 lnOldSelect = Select()
7780
7781 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
7782 *--- See VSS for Changes.
7783
7784 * for anything that resove to None blank h.customer, d.div/sty/col-
7785 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
7786 *- TAN 27166
7787 *- 1010682 04/25/05 YIK
7788 *- Added .. WHERE d.rng_style = ' '
7789
7790 *- 1017363 06/02/06 YIK
7791 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
7792
7793 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
7794 Select h.customer;
7795 , d.division;
7796 , d.Style;
7797 , d.color_code;
7798 , d.lbl_code;
7799 , d.Dimension;
7800 , d.sizebucket;
7801 , d.size_desc; && TR 1058045 11-29-2011 RKI
7802 , d.upc; && TR 1058045 11-29-2011 RKI
7803 , d.sku; && TR 1058045 11-29-2011 RKI
7804 , d.ean; && TR 1058045 11-29-2011 RKI
7805 , d.pkey;
7806 , (pceipoTD) As Src ;
7807 from (pceipoTH) h;
7808 join (pceipoTD) d ;
7809 on h.pkey = d.fkey ;
7810 where h.customer >' ' ;
7811 and d.division >' ' ;
7812 and d.Style >' ' ;
7813 and d.color_code >' ' ;
7814 UNION All;
7815 select h.customer;
7816 , s.division;
7817 , s.Style;
7818 , s.color_code;
7819 , s.lbl_code;
7820 , s.Dimension;
7821 , s.sizebucket;
7822 , s.size_desc; && TR 1058045 11-29-2011 RKI
7823 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
7824 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
7825 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
7826 , s.pkey;
7827 , (pceipoTS) As Src ;
7828 from (pceipoTS) s;
7829 join (pceipoTD) d ;
7830 on d.pkey = s.fkey;
7831 join (pceipoTH) h ;
7832 on h.pkey = d.fkey ;
7833 and h.customer > ' ' ;
7834 and s.division > ' ' ;
7835 and s.Style > ' ' ;
7836 and s.color_code > ' ' ;
7837 where d.rng_style = ' ' ;
7838 order By 2, 3, 4, 5, 6, 7, 1 ;
7839 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
7840
7841 *-- Order by SKU + Bucket + Customer !!!
7842 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
7843
7844 lcCnt = Reccount("tmpCurs")
7845 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
7846
7847 *--- This cursor will be used to cache Customer-Label Validations:
7848 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
7849 Index On customer + lbl_code Tag CustLbl
7850
7851 lcErrs_Msg = ''
7852 Select tmpCurs
7853 Scatter Memo Name oTmpCurs Blank
7854 * --- TR 1014834 RLN 08/10/06
7855
7856 *--- TR 1017598 14-Sep-2006 SS
7857 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7858
7859 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7860 llBookUnavail = (lcbk_unavl_sku = 'Y')
7861 llErrUnavail = (lcbk_unavl_sku = 'E')
7862 *=== TR 1017598 14-Sep-2006 SS
7863
7864 With oTmpCurs
7865 llSize_OK = .T.
7866 Scan
7867 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
7868 * --- TR 1027498 NSD 10/3/07
7869 * Clear error message after every line, not just every sku.
7870 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
7871 * === TR 1027498 NSD 10/3/07
7872
7873 * --- TR 1014834 RLN 08/10/06
7874 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
7875 llSize_OK = .T.
7876 If division # .division ;
7877 or Style # .Style ;
7878 or color_code # .color_code ;
7879 or lbl_code # .lbl_code ;
7880 or Dimension # .Dimension
7881 *-- SKU Changed... Let's make sure it is valid:
7882
7883 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
7884 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7885
7886 * --- TR 1039400 3/31/09 CM
7887 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
7888 * === TR 1039400 3/31/09 CM
7889
7890 * --- TR 1014834 RLN 08/10/06
7891 If division <> .division
7892 *--- TR 1017598 14-Sep-2006 SS
7893 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7894
7895 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7896 llBookUnavail = (lcbk_unavl_sku = 'Y')
7897 llErrUnavail = (lcbk_unavl_sku = 'E')
7898 *=== TR 1017598 14-Sep-2006 SS
7899 Endif
7900 * === TR 1014834
7901 lcErrs_Msg = ""
7902 .division = division
7903 .Style = Style
7904 .color_code = color_code
7905 .Dimension = Dimension
7906 .lbl_code = lbl_code && TR 1057867 FH
7907 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
7908 * --- TR 1014834 RLN 08/09/06
7909 lnSelect = Select()
7910 * Available sizes stored in Scolr
7911 *--- TR: 1021620 BR/NH
7912 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
7913 Lbl_Code, .Dimension)
7914
7915
7916*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
7917*!* "division = " + SQLFormatChar(division) + " AND " + ;
7918*!* "style = " + SQLFormatChar(Style) + " AND " + ;
7919*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
7920*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
7921*!* "dimension = " + SQLFormatChar(Dimension)
7922
7923*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
7924*!* Select (lnSelect)
7925*!* * === TR 1014834
7926*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
7927*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
7928
7929 *--- TechRec 1022705 20-Jun-2007 jjanand ---
7930 *!* IF tcTmpScolr.active_ok = 'N'
7931 llActiveCheck = This.lAllowInactiveStyleColors
7932 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
7933 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
7934 IF llActiveCheck
7935 *=== TechRec 1022705 20-Jun-2007 jjanand ===
7936
7937 lcErrs_Msg = "Inactive Style/Color"
7938 llStyle_OK = .F.
7939 ELSE
7940 lcErrs_Msg = ""
7941 llStyle_OK = .T.
7942 ENDIF
7943
7944 *--- TR 1040614 MAY-29-2009 BR
7945 llUnAvlBkCheck = .T.
7946 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
7947 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
7948
7949 *- 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
7950 IF llStyle_OK
7951 IF llUnAvlBkCheck
7952 lcErrs_Msg = "Style/Color combination is unavailable"
7953 llStyle_OK = .F.
7954 ELSE
7955 lcErrs_Msg = ""
7956 llStyle_OK = .T.
7957 ENDIF
7958 ENDIF
7959 *- TR 1062018 FH 06/08/12
7960 *=== TR 1040614 MAY-29-2009 BR
7961 ELSE
7962 *=== TR 1021620
7963 llStyle_OK = .F.
7964 This.GetStyleError(@lcErrs_Msg)
7965 Endif
7966 Endif && SKU Changed
7967
7968 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
7969 *- took out (customer # .customer Or .lbl_code # lbl_code)
7970 If llStyle_OK AND llSKU_changed
7971*!* If llStyle_OK And (;
7972*!* customer # .customer Or .lbl_code # lbl_code)
7973 .lbl_code = lbl_code
7974 .customer = customer
7975 llLabel_OK = .T.
7976 If !Empty(.lbl_code)
7977 If !Seek(.customer+.lbl_code, "curCustLbl")
7978 *- populate cursor of cached Customer/Lbl
7979 *- vl_clblr2() returns .F. if lbl is invalid for the customer
7980 Insert Into curCustLbl Values(;
7981 .customer, .lbl_code,;
7982 vl_clblr2(.lbl_code, "", , .customer))
7983 Endif
7984
7985 If !curCustLbl.is_Valid && always check from the cached table.
7986 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
7987 llLabel_OK = .F.
7988 Endif
7989 Endif
7990 Endif && Style OK
7991
7992 *--- TR 1058045 11-29-2011 RKI ---*
7993 lnPkey = Pkey
7994 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
7995 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
7996 replace sizebucket WITH lnSize_BK
7997 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
7998 DO CASE
7999 CASE tmpCurs.Src = (pceipoTD)
8000 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8001 CASE tempcurs.Src = (pceipoTS)
8002 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8003 Endcase
8004 ENDIF
8005 ENDIF
8006 SELECT tmpCurs
8007 *=== TR 1058045 11-29-2011 RKI ===*
8008
8009 * --- TR 1018184
8010 llAllowedSize_OK = .T.
8011 If llStyle_OK And llLabel_OK
8012 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
8013 .sizebucket = sizebucket
8014 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8015
8016 *- that's why we used Savlr
8017 * --- TR 1014834 RLN 08/09/06
8018 * I guess we really do not need Savlr...
8019 *llSize_OK = Evaluate("__Savlr.allow"
8020 *--- TR 1058045 11-29-2011 RKI ---*
8021 IF BETWEEN(.sizebucket,1,24)
8022 *=== TR 1058045 11-29-2011 RKI ===*
8023 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
8024 Transform(.sizebucket, "@L 99")) = 'Y'
8025
8026 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
8027 *if !llSize_OK
8028 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
8029 Transform(.sizebucket, "@L 99")) = 'Y'
8030 *--- TR 1058045 11-29-2011 RKI ---*
8031 ELSE
8032 llAllowedSize_OK = .F.
8033 ENDIF
8034 *=== TR 1058045 11-29-2011 RKI ===*
8035
8036 If !llAllowedSize_OK
8037 *--TR 1034769 JUL-21-2008 BR
8038 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
8039 lcErrs_Msg = "Invalid Available Sizes."
8040 *==TR 1034769 JUL-21-2008 BR
8041 Else
8042 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
8043 lcErrs_Msg = "Invalid Available Sizes."
8044 Endif
8045 Endif
8046
8047 *=== TR 1017598 14-Sep-2006 SS
8048 Endif
8049 Endif
8050 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
8051
8052 * for each detail line replace detail error msg if have one
8053 *--- TechRec 1005163 21-Jun-2004 GS ---
8054 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
8055 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
8056 * Errs_Flg_D with 'Y' in (pceipoTD)
8057 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
8058 If tmpCurs.Src = (pceipoTD)
8059 *--- TR 1017598 14-Sep-2006 SS
8060 If Not llAllowedSize_OK && if size is not allowed - error out always
8061 *--- TR 1018193 18-NOV-2006 VKK
8062 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
8063 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
8064 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
8065 Errs_Flg_D With 'Y' In (pceipoTD)
8066 *=== TR 1018193 18-NOV-2006 VKK
8067 Else
8068 *=== TR 1017598 14-Sep-2006 SS
8069
8070 * --- TR 1014834 RLN 08/08/06
8071 If !llSize_OK
8072 If llBookUnavail
8073 Replace UnAvailSize With .T. In (pceipoTD)
8074 Else
8075 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
8076 If llErrUnavail && error as invalid available sizes.
8077 * === TR 1014834
8078 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
8079 Errs_Flg_D With 'Y' In (pceipoTD)
8080 Endif
8081 *=== TR 1017598 14-Sep-2006 SS
8082 ENDIF
8083 *--- TR 1021620 NH 04/12/07
8084 ELSE
8085
8086
8087 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
8088 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
8089 IF llSKU_changed
8090 * --- TR 1039400 3/31/09 CM
8091 * Commented out and added seek/scan while to determine how many particular style/color
8092 * combinations should be flagged as inactive
8093 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8094 Select(pceipoTD)
8095 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
8096 If Seek(lcCurrentSku)
8097 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
8098 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8099 Endscan
8100 Endif
8101 * === TR 1039400 3/31/09 CM
8102 endif
8103 *--TR 1057867 FH
8104
8105 *=== TR 1021620 NH 04/12/07
8106 Endif && TR 1014834
8107 Endif && TR 1017598
8108 ELSE
8109 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
8110 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
8111 Errs_Flg_S With 'Y' In (pceipoTS)
8112
8113 *- 1010682 04/25/05 YIK
8114 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
8115 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
8116 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
8117 Select(pceipoTS)
8118 lnFKey = fkey
8119 Select(pceipoTD)
8120 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
8121 *=== TechRec 1016817 04-May-2006 GS ===
8122 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
8123 Errs_Flg_D With 'Y' In (pceipoTD)
8124 ENDIF
8125 ENDIF
8126 Endif
8127 *=== TechRec 1005163 21-Jun-2004 GS ===
8128 Endif
8129 Endscan
8130 Endwith
8131
8132 Use In Select("curCustLbl")
8133
8134 Select(lnOldSelect)
8135 Return llRetVal
8136 Endproc
8137
8138 *----------------------------------------------------------------------------------------
8139
8140 Function GetCustLabel
8141 Lparameters pcCust
8142 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
8143
8144 llRetVal = True
8145 lnSelect = Select()
8146 l_vRetVal = ''
8147 lcCursor = GetUniqueFileName()
8148
8149 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
8150
8151 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
8152
8153 If llRetVal
8154 Select(lcCursor)
8155 l_vRetVal = Alltrim(lbl_code )
8156
8157 Use In (lcCursor)
8158 Endif
8159
8160 Select (lnSelect)
8161 Return l_vRetVal
8162 Endfunc
8163
8164 *----------------------------------------------------------------------------------------
8165 Function ResolveMultiPrepacks
8166 Lparameters pcTransHeader, pcTransDetail, pcMppk
8167 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
8168
8169 llRetVal = True
8170 lnOldSelect = Select()
8171
8172
8173
8174 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8175 FROM (pcTransHeader) h, (pcTransDetail) d ;
8176 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
8177 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
8178 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8179
8180 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
8181 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
8182 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
8183 *!* d.rng_style= '' ;
8184 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
8185
8186 With This
8187 .cSQLTempTable=""
8188
8189 If .GenerateSQLTempTable('__TmpCursor')
8190 If .PopulateSQLTempTable('__TmpCursor')
8191 If !Empty(.cSQLTempTable)
8192
8193 .LogEntry("Exploding MultiPack.")
8194
8195 *AND h.mpack_code = t.dimension
8196 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
8197 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8198
8199 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
8200
8201 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
8202
8203 If llMultPpkToExplode
8204
8205 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
8206 "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
8207
8208 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
8209
8210
8211 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
8212
8213 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
8214 WHERE 0=1 Into Cursor __ppk2
8215
8216
8217 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
8218 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
8219
8220
8221 If Used("__ppk1")
8222 Use In __ppk1
8223 Endif
8224
8225 If Used("__ppk2")
8226 Use In __ppk2
8227 Endif
8228
8229 Select __MppkH
8230 Index On pkey Tag pkey
8231 Select __MppkD
8232 Index On division+Style Tag DivStyle
8233 Select tcMppkVer
8234 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8235 Set Order To MpackRef
8236 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8237
8238 *****************************************************************************
8239 *!* SELECT DISTINCT pkey FROM __MppkD ;
8240 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8241 *!* INTO CURSOR __DtlExpl
8242
8243
8244 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8245 *!* FROM __MppkD m, (pcTransDetail) d ;
8246 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8247 *!* INTO CURSOR __DtlExpl
8248
8249 && TR 1011644 VSS 27-09-2005
8250
8251 Select Distinct d.pkey ;
8252 FROM __MppkD mp, (pcTransDetail) d ;
8253 WHERE d.Errs_Flg_D= "N" ; &&no error
8254 And mp.Style = d.Style ;
8255 AND mp.color_code = d.color_code ;
8256 AND mp.lbl_code = d.lbl_code ;
8257 AND mp.Dimension = d.Dimension;
8258 AND d.implosion = 'Y';
8259 INTO Cursor __DtlExpl
8260
8261 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8262
8263 Endif
8264 Endif
8265 Endif
8266 Endif
8267 Endwith
8268
8269 If Used("__MppkH")
8270 Use In __MppkH
8271 Endif
8272 If Used("__MppkD")
8273 Use In __MppkD
8274 Endif
8275 If Used("tcMppkVer")
8276 Use In tcMppkVer
8277 Endif
8278 If Used("__DtlExpl")
8279 Use In __DtlExpl
8280 Endif
8281 If Used("__TmpCursor")
8282 Use In __TmpCursor
8283 Endif
8284
8285 Select(lnOldSelect)
8286 Return llRetVal
8287
8288 Endfunc
8289
8290 *----------------------------------------------------------------------------------------
8291 Procedure ExplodeMultiPackVertical
8292 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8293 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8294 llRetVal = .T.
8295 lnOldSelect = Select()
8296
8297 .LogEntry("Exploding multi pack details into vertical cursor.")
8298 Select (pcDetailtoExplode)
8299
8300 Scan
8301
8302 If Seek(pkey, pcTransDetail, "Pkey")
8303
8304 * Current working trans detail
8305 Select (pcTransDetail)
8306 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8307 lnCurDtlTotal_qty= total_qty
8308
8309
8310 Scatter Name loTransDetail Memo
8311 * delete current working trans detail already have image
8312 * in loTransDetail
8313 Delete In (pcTransDetail)
8314
8315
8316 Select (pcMultDetailVert)
8317 * Find 1st match of OURSKU
8318 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8319 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8320
8321
8322 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8323 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8324 * Exploding detail line
8325 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8326 If !Empty(loTransDetail.pkey)
8327
8328 Select (pcMultDetailVert)
8329 Scatter Name loVert Memo
8330
8331 Select (pcTransDetail)
8332 Append Blank
8333 Gather Name loTransDetail Memo
8334
8335 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8336 sizebucket With loVert.sizebucket, ;
8337 size_desc With loVert.size_desc, ;
8338 division With loVert.division, ;
8339 STYLE With loVert.Style, ;
8340 color_code With loVert.color_code, ;
8341 lbl_code With loVert.lbl_code, ;
8342 DIMENSION With loVert.ppk_code In (pcTransDetail)
8343 Else
8344 .LogEntry("Pkey cannot be empty.")
8345 llRetVal= .F. && Cannot get Pkey from bcsysnum
8346 Exit
8347 Endif
8348
8349 Select (pcMultDetailVert)
8350 Endscan
8351 Else
8352 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8353 llRetVal= .F. && Should be in pcMultDetailVert
8354 Exit
8355 Endif
8356 Endif
8357
8358 If !llRetVal &&Get out of scan when have some problem
8359 Exit
8360 Endif
8361 Endscan
8362
8363 Select(lnOldSelect)
8364 Return llRetVal
8365 Endproc
8366 *=== TR 1011644 23-AUG-2005 KA
8367
8368 *----------------------------------------------------------------------------------------
8369 Procedure ExplodeMultPackRef
8370 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8371 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8372 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8373
8374 lnOldSele = Select()
8375 lcDivStyle = ""
8376 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8377
8378 llRetVal= .T.
8379 lnCurDtlFkey= 0
8380 lnMultiplyQty = 0
8381
8382 .LogEntry("Exploding multi pack details.")
8383
8384 Select (pcMultPackDetail)
8385 Set Order To DivStyle
8386 Scan
8387
8388 If lnCurDtlFkey<> fkey
8389 lnCurDtlFkey = fkey
8390 If Seek(fkey, pcMultPackHeader , "PKEY")
8391 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8392 Else
8393 llRetVal = .F.
8394 Exit
8395 Endif
8396 Endif
8397
8398
8399 * only run once per Div + Style
8400 If !(lcDivStyle == division + Style)
8401 lcDivStyle = division + Style
8402 * Insert a record for each size bucket with a caption *
8403 If !v_GetSizeHeadings(division, Style, "__xSizer")
8404 llRetVal = .F.
8405 Exit
8406 Endif
8407 Endif
8408
8409
8410 lnSizeQty = 1
8411 Select (pcMultPackDetail)
8412 Scatter Memvar Memo
8413
8414 lnSizePosition = 1
8415 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8416 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8417 lnSizeQty = ppk_qty
8418
8419 m.sizebucket = lnSizePosition
8420 m.size_desc = lcSizeName
8421 m.total_qty = lnSizeQty
8422 m.multQty = lnMultiplyQty
8423
8424 If lnSizeQty > 0 && Only want buckets with activity!
8425 Insert Into (pcMultPackTarget) From Memvar
8426 Endif
8427 Select (pcMultPackDetail)
8428
8429 Endscan
8430
8431 This.TableClose("__xSizer")
8432 Select (pcMultPackDetail)
8433 Select (lnOldSele)
8434 Return llRetVal
8435 Endproc
8436
8437 *----------------------------------------------------------------------------------------
8438 *--- TechRec 1016817 04-May-2006 GS ---
8439 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8440 Procedure GetStyleError
8441
8442 Lparameter tcErrorMsg, toTmpCurs
8443
8444 Do Case
8445 Case vl_scolr(division,,, Style, color_code, lbl_code)
8446 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8447
8448 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8449 tcErrorMsg = "Invalid Label code." + CRLF
8450
8451 Case !Empty(Style) And vl_Stylr(division,,, Style)
8452 tcErrorMsg = "Invalid Color code." + CRLF
8453
8454 Otherwise
8455 tcErrorMsg = "Invalid Style." + CRLF
8456 Endcase
8457 Endproc
8458
8459 *----------------------------------------------------------------------------------------
8460
8461 **********************************************************************************
8462 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8463 **********************************************************************************
8464 Procedure PopulateInboundUOM
8465 Lparameters pceipoTH, pceipoTD, pceipoCR
8466 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8467 llRetVal = .T.
8468 lnOldSelect = Select()
8469
8470 With This
8471
8472 *****************************************************************************
8473 * unconditionally reset all base_uom and uom_factor
8474 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8475
8476 *****************************************************************************
8477 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8478 * Server-side join previous list to get cursor of scolr to populate base_uom
8479 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8480 FROM (pceipoTH) h, (pceipoTD) d ;
8481 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8482 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8483 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8484 * TAN 31891 - JAZ - 5/20/02 @@@
8485 * If Recc("__TmpCursor")> 0
8486 If Reccount("__TmpCursor")> 0
8487 * End TAN 31891 - JAZ - 5/20/02
8488 .cSQLTempTable=""
8489 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8490 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8491 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8492 "Where s.division= t.division and s.style= t.style and "+;
8493 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8494 "s.dimension= t.dimension"
8495 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8496 * Populate style UOM
8497 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8498 Endif
8499 .TableClose("tcUOM")
8500 .TableClose("__TmpCursor")
8501
8502 *****************************************************************************
8503 * Get distinct list of Inbound UOM and style UOM
8504 * Server-side join previous list to populate UOM conversion factor
8505 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8506 WHERE ib_uom<>'' And base_uom<>'' ;
8507 INTO Cursor __TmpCursor
8508 * TAN 31891 - JAZ - 5/20/02
8509 * If Recc("__TmpCursor")> 0
8510 If Reccount("__TmpCursor")> 0
8511 * End TAN 31891 - JAZ - 5/20/02
8512 .cSQLTempTable=""
8513 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8514 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8515 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8516 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8517 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8518 * Populate style UOM
8519 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8520 Endif
8521 .TableClose("tcUOMFactor")
8522 .TableClose("__TmpCursor")
8523
8524 Endwith
8525 Select(lnOldSelect)
8526 Return llRetVal
8527 Endproc
8528
8529 *----------------------------------------------------------------------------------------
8530
8531 Procedure PopulateBaseUOM
8532 Lparameters pceipoTD, pcUOM
8533 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8534 llRetVal = .T.
8535 lnOldSelect = Select()
8536
8537 With This
8538 Select (pcUOM)
8539 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8540 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8541 "division+style+color_code+lbl_code+dimension")
8542 Select (pceipoTD)
8543 If llRetVal
8544 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8545 FOR !Empty(&pcUOM..uom)
8546 Endif
8547 Set Relation To
8548 Endwith
8549 Select(lnOldSelect)
8550 Return llRetVal
8551 Endproc
8552
8553 *----------------------------------------------------------------------------------------
8554
8555 Procedure PopulateUOMFactor
8556 Lparameters pceipoTD, pcUOMFactor
8557 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8558 llRetVal = .T.
8559 lnOldSelect = Select()
8560
8561 With This
8562 Select (pcUOMFactor)
8563 Index On uom+uom_convert Tag IB_BaseUOM
8564 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8565 "ib_uom+base_uom")
8566 Select (pceipoTD)
8567 If llRetVal
8568 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8569 FOR !Empty(&pcUOMFactor..uom_factor)
8570 Endif
8571 Set Relation To
8572 Endwith
8573 Select(lnOldSelect)
8574 Return llRetVal
8575 Endproc
8576
8577 *----------------------------------------------------------------------------------------
8578
8579 Procedure ResolvePrepack
8580 Lparameters pceipoTH, pceipoTD, pceipoCR
8581
8582 LOCAL llRetVal
8583 llRetVal = .t.
8584 IF VARTYPE(This.oResolvePrepack) <> "O"
8585 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8586 ENDIF
8587
8588 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8589
8590 IF NOT llRetVal
8591 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8592 RETURN llRetVal
8593 ENDIF
8594
8595 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8596 this.oResolvePrepack.cLogName = this.cLogName
8597
8598 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8599 This.oResolvePrepack.c850Control = This.c850Control
8600 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8601
8602 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
8603
8604 RETURN llRetVal
8605
8606 ENDPROC
8607
8608 *------------------------------------------------------------------------
8609
8610 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8611 Procedure ValidateCharges
8612 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8613
8614 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8615 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8616 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8617 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8618 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8619 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8620 lcDtlError = "Has errors in Charges." + CRLF
8621 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8622 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8623 SELECT (tcEipoTH)
8624 lntcEipoTHrec = RECNO()
8625 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8626
8627 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8628 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8629 v_sqlExec(;
8630 "select d.FKey"+;
8631 " , d.Chrg_Type"+;
8632 " , d.Chrg_Flag"+;
8633 " , d.Active_Ok"+;
8634 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8635 " from zzxChrgD d"+;
8636 " join zzxChrTR t"+;
8637 " on t.Chrg_Type = d.Chrg_Type"+;
8638 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8639 Select qChrgD
8640 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8641 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8642 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8643 v_sqlExec(;
8644 "select Customer"+;
8645 " , Division"+;
8646 " , Store"+;
8647 " , Center_Code"+;
8648 " , Season"+;
8649 " , PKey"+;
8650 " , Rank_Seq"+;
8651 " from zzxchrgh", "qChrgH")
8652 Select qChrgH
8653 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8654 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8655 Index On division+customer+Store+Center_Code+Season Tag divcust
8656 If division = ' ' And customer = ' '
8657 lnDefaultKey = pkey
8658 Endif
8659
8660 Select (tcEiPOTR)
8661 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8662 Scan
8663 lcChrg_Type = Chrg_Type
8664 Select (tcEiPOtd)
8665 lcDivision = division
8666 lcCustomer = customer
8667 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8668 lnFkeyEipoTD = fkey
8669 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8670 lcCenter_Code = &tcEipoTH..center_Code
8671 lcStore = &tcEipoTH..Store
8672 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8673 lcSeason = &tcEipoTH..Season
8674 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8675 ELSE
8676 lcCenter_Code = ""
8677 lcStore = ""
8678 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8679 lcSeason = ""
8680 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8681 ENDIF
8682 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8683
8684 Select qChrgH
8685 Do Case
8686 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8687*!* Case Seek(lcDivision+lcCustomer)
8688*!* lnFKey = pkey
8689*!* Case Seek(' '+lcCustomer, "qChrgH")
8690*!* lnFKey = pkey
8691*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8692*!* Case Seek(lcDivision+' ')
8693*!* lnFKey = pkey
8694*!* Otherwise
8695*!* lnFKey = lnDefaultKey
8696 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8697*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8698*!* lnFKey = pkey
8699*!*
8700*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8701*!* lnFKey = pkey
8702*!*
8703*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8704*!* lnFKey = pkey
8705*!*
8706*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8707*!* lnFKey = pkey
8708
8709*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8710*!* lnFKey = pkey
8711*!*
8712*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8713*!* lnFKey = pkey
8714
8715 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
8716 lnFKey = pkey
8717
8718 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
8719 lnFKey = pkey
8720
8721 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
8722 lnFKey = pkey
8723
8724 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
8725 lnFKey = pkey
8726
8727 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
8728 lnFKey = pkey
8729
8730 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
8731 lnFKey = pkey
8732
8733 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
8734 lnFKey = pkey
8735
8736 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
8737 lnFKey = pkey
8738
8739 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
8740 lnFKey = pkey
8741
8742 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
8743 lnFKey = pkey
8744 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8745
8746 Otherwise
8747 lnFKey = lnDefaultKey
8748 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8749 Endcase
8750 Select (tcEiPOTR)
8751 If Empty(lnFKey)
8752 Replace Errs_Flg_R With "Y",;
8753 Errs_Msg_R With "No Charges set up for "+;
8754 Trim(lcDivision)+'/'+Trim(lcCustomer)
8755 Else
8756 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
8757 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
8758
8759 *--- Check if the Charge still active:
8760 If qChrgD.Active_Ok # 'Y'
8761 Replace Errs_Flg_R With "Y",;
8762 Errs_Msg_R With lcErrorMsg3
8763 Endif
8764
8765 If Empty(Chrg_Flag)
8766 *-- Set Charge Type from Resolution if success
8767 If Errs_Flg_R # "Y"
8768 Replace Chrg_Flag With lcResolved_Chrg_Flag
8769 Endif
8770 Else
8771 If Chrg_Flag # lcResolved_Chrg_Flag
8772 Replace Errs_Flg_R With "Y",;
8773 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
8774 Endif
8775 Endif
8776 Else
8777 Replace Errs_Flg_R With "Y",;
8778 Errs_Msg_R With lcErrorMsg1
8779 lnFKey = fkey
8780 lcResolved_Chrg_Flag = ""
8781 Endif
8782 Endif
8783
8784 If Errs_Flg_R = "Y"
8785 Select(tcEiPOtd)
8786 If !lcDtlError$Errs_Msg_D
8787 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
8788 Errs_Flg_D With 'Y'
8789 Endif
8790 ELSE
8791 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
8792* Replace Chrg_Cost With qChrgD.Chrg_Cost
8793 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
8794 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
8795 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
8796 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
8797 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
8798 Endif
8799 Endscan
8800
8801 Set Relation To
8802 Use In Select("qChrgH")
8803 Use In Select("qChrgD")
8804 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8805 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
8806 GO lntcEipoTHrec IN (tcEipoTH)
8807 ENDIF
8808 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8809
8810 Endproc
8811 *=== TechRec 1028745 05-Feb-2008 GSternik ===
8812
8813 *------------------------------------------------------------------------
8814
8815 *--- TR 1083402 20-Jan-2015 Partha ---
8816 * ROFL - This proc is duplicate :)
8817*!* *----------------------------------------------------------------------------------------
8818*!* *--- TR 1034481 NH
8819*!* PROCEDURE MarkHeaderForMissing855ControlRef
8820*!* LPARAMETERS pceipoTH
8821*!*
8822*!* LOCAL llRetVal, lnOldSelect,lcZzeoprcr
8823*!*
8824*!* llRetVal = .t.
8825*!* lnOldSelect = SELECT()
8826*!* lcZzeoprcr = "Oprcr" + SYS(2015)
8827*!* *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
8828*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
8829*!*
8830*!* IF USED(lcZzeoprcr)
8831*!* INDEX on customer TAG customer
8832*!* INDEX on division TAG division
8833*!*
8834*!* UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
8835*!* from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
8836*!* AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
8837
8838*!* USE IN (lcZzeoprcr)
8839*!* ENDIF
8840*!*
8841*!* SELECT(lnOldSelect)
8842*!* RETURN llRetVal
8843*!*
8844*!* ENDPROC
8845*!* *=== TR 1034481 NH
8846
8847 *=== TR 1083402 20-Jan-2015 Partha ===
8848
8849 *----------------------------------------------------------------------------------------
8850
8851 *--- TR 1035491 4-Nov-2008 Goutam
8852 ************************************************************************************
8853 * Move SLN to Detail.
8854 ************************************************************************************
8855 Procedure MoveSLNToDTLs
8856 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8857 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8858 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
8859 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
8860
8861 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
8862 lnLine_Seq
8863
8864 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8865 LOCAL lcSQL ,loIPOtdn
8866 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8867
8868 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
8869
8870 llRetVal = true
8871 lnOldSelect = Select()
8872 lnDetailPrice = 0
8873
8874 *--- TR 1036614 8-Jun-2009 Goutam
8875 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
8876
8877*!* select t.Customer ;
8878*!* , t.FKey ;
8879*!* , t.PKey ;
8880*!* , c.price_flg ;
8881*!* from (pcTmpCursor) t ;
8882*!* join zzeipocr c ;
8883*!* on c.division = t.division ;
8884*!* and c.customer = t.customer ;
8885*!* join (pceipoTD) d ;
8886*!* on d.pkey = t.dtlPkey ;
8887*!* where c.slntodtl = 'Y' ;
8888*!* and d.slntodtl <> 'Y' ;
8889*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
8890*!* into Cursor __tmpipots ;
8891*!* order by t.fkey, t.Customer, t.PKey
8892
8893 *=== TR 1036614 8-Jun-2009 Goutam
8894
8895 *-- #1 Create detail record from pceipoTS
8896 SELECT __tmpipots
8897 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
8898 GO top
8899 lnSkipedPSFkey = 0
8900 lnPSFkey = 0
8901 lnCoor_Code = 1
8902 lnLine_Seq = 0
8903 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
8904
8905 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8906 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8907 ENDIF
8908 DO WHILE NOT EOF()
8909 lnPSFkey = Fkey
8910
8911 *--- TR 1049029 24-Aug-2010 Partha ---
8912 IF lnPSFkey <> lnSkipedPSFkey
8913 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
8914 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
8915 ENDIF
8916 *=== TR 1049029 24-Aug-2010 Partha ===
8917
8918 lnStartPkey = lnStartPkey + 1
8919 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8920 lnLine_Seq = lnLine_Seq + 1
8921 SELECT (pceipoTD)
8922 SCATTER NAME loIPOtd MEMO
8923 loIPOtd.pkey = lnStartPkey
8924 loIPOtd.Line_Seq = lnLine_Seq
8925
8926 *-FH 1077588 - detail's header pkey
8927 lnHfkey = fkey
8928
8929 *--- TechRec 1056973 06-Dec-2011 jisingh ---
8930 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
8931 *- 1060291 04/02/2012 YIK/FH
8932*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8933*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
8934 SELECT (pczzeiPOtWhse)
8935 lnDocNum = doc_num
8936 lnEdiLine = edi_line
8937 lnSlnLine = sln_line
8938
8939 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8940 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
8941 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
8942
8943 SELECT (pceipoTD)
8944 *= 1060291
8945 ENDIF
8946 *=== TechRec 1056973 06-Dec-2011 jisingh ===
8947
8948 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
8949*!* loIPOtd.slntodtl = 'Y'
8950
8951 *--- TR 1045922 05-MAR-2010 HNISAR
8952 *- 1060291 03/30/2012 YIK
8953 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
8954*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8955*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
8956 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8957 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
8958 *=== TechRec 1056973 09-Nov-2011 jisingh ===
8959 *=== TR 1045922 05-MAR-2010 HNISAR
8960
8961
8962
8963 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
8964 *--- TechRec 1063327 16-Aug-2012 jjanand ---
8965 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
8966*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
8967*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
8968*!* loIPOtd.assort_qty = loIPOtd.total_qty
8969*!* ENDIF
8970 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
8971*!* IF EMPTY(loIPOtd.Assortment)
8972*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8973*!* IF loIPOtd.assort_qty = 0
8974*!* loIPOtd.assort_qty = loIPOtd.total_qty
8975*!* ENDIF
8976*!* ENDIF
8977
8978 IF EMPTY(loIPOtd.Assortment)
8979 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8980 ENDIF
8981 IF EMPTY(loIPOtd.assort_qty)
8982 loIPOtd.assort_qty = loIPOtd.total_qty
8983 ENDIF
8984 *=== TechRec 1063327 16-Aug-2012 jjanand ===
8985 *- TR 1062810 FH
8986
8987 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
8988 loIPOtd.PO1_UPC = loIPOtd.UPC
8989 loIPOtd.PO1_SKU = loIPOtd.SKU
8990 loIPOtd.po1_price = loIPOtd.org_price
8991 loIPOtd.Division = &pceipoTS..Division
8992 loIPOtd.Style = &pceipoTS..Style
8993 loIPOtd.Color_code = &pceipoTS..Color_code
8994 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
8995 loIPOtd.Dimension = &pceipoTS..Dimension
8996 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
8997 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
8998 loIPOtd.UPC = &pceipoTS..SLN_UPC
8999 *- 03/19/09 1038539, 1039344 YIK
9000 loIPOtd.SKU = &pceipoTS..SLN_SKU
9001 *- TR 1051757 FH 04/19/11
9002 loIPOtd.aux_sku = &pceipoTS..aux_sku
9003
9004 *--- TechRec 1056973 07-Dec-2011 jisingh ---
9005 loIPOtd.sln01 = &pceipoTS..sln01
9006 *=== TechRec 1056973 07-Dec-2011 jisingh ===
9007
9008 *--- TR 1049029 30-Aug-2010 Partha ---
9009
9010*!* *--- TR 1047912 23-Jun-2010 Partha ---
9011*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
9012*!* *=== TR 1047912 23-Jun-2010 Partha ===
9013*!*
9014*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9015*!*
9016*!* *=== TR 1047912 23-Jun-2010 Partha ===
9017*!* ENDIF
9018*!* *=== TR 1047912 23-Jun-2010 Partha ===
9019*!*
9020*!* *--- TR 1047912 23-Jun-2010 Partha ---
9021*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
9022*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9023*!* ELSE
9024*!* lnDetailPrice = &pceipoTD..Org_Price
9025*!* ENDIF
9026*!* *=== TR 1047912 23-Jun-2010 Partha ===
9027
9028 DO CASE
9029 CASE loIPOtd.ppk_action = 'B'
9030 *- 02/18/11 1052584 YIK
9031 *- Moved calculation of ppk_qty here
9032 loIPOtd.ppk_qty = lnTotSLNQty
9033
9034 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9035
9036 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
9037 *loIPOtd.ppk_action = 'X'
9038 loIPOtd.ppk_action = 'S'
9039 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
9040 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9041 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9042 *- 02/18/11 YIK 1052584
9043 *- moved calculation of ppk_qty higher
9044 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9045
9046 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
9047 *- 02/18/11 YIK 1052584
9048 *- Moved calculation of ppk_qty here
9049 loIPOtd.ppk_qty = lnTotSLNQty
9050
9051 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9052
9053 IF loIPOtd.ppk_action = 'Q'
9054 loIPOtd.ppk_action = 'M'
9055 ENDIF
9056
9057 *- 02/18/11 YIK 1052584
9058 *- moved calculation of ppk_qty higher
9059 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9060
9061 lnDetailPrice = &pceipoTD..Org_Price
9062
9063 CASE loIPOtd.ppk_action = 'P'
9064 *-TR 1062018/1064343 FH - moved up
9065 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9066 *- TR 1062018/1064343 FH - moved up
9067 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9068 loIPOtd.ppk_action = 'D'
9069 lnDetailPrice = loIPOtd. Org_Price/ lnTotSLNQty
9070 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9071 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9072
9073
9074 OTHERWISE
9075 *-TR 1062018/1064343 FH - moved up
9076 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9077 *- TR 1062018/1064343 FH - moved up
9078 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9079 lnDetailPrice = &pceipoTD..Org_Price
9080 loIPOtd.ppk_qty = lnTotSLNQty
9081
9082 ENDCASE
9083 *=== TR 1049029 30-Aug-2010 Partha ===
9084
9085 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
9086 IF __tmpipots.price_flg = "E"
9087 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9088 ELSE
9089 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9090 ENDIF
9091
9092 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
9093 loIPOtd.Errs_flg_d = "N"
9094 loIPOtd.Errs_msg_d = ""
9095 *=== TR 1038353 NH
9096
9097 APPEND BLANK
9098 GATHER NAME loIPOtd MEMO
9099
9100 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9101
9102 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
9103 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
9104 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
9105
9106 &lcSQL
9107 SELECT _tmpipodnt
9108 SCAN
9109 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
9110 SELECT "Vzzeipotd_notes_iPOproc"
9111 SCATTER NAME loIPOtdn MEMO
9112
9113 APPEND BLANK
9114 loIPOtdn.Fkey = lnStartPkey
9115 loIPOtdn.Pkey = v_nextPkey("SysNotes")
9116
9117 GATHER NAME loIPOtdn MEMO
9118 ENDIF
9119
9120 ENDSCAN
9121 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
9122
9123 ENDIF && TR 1043037 OCT-06-2009 BR
9124 ENDIF
9125 SELECT __tmpipots
9126 SKIP IN __tmpipots
9127 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
9128
9129 *- TR 1062018/1064343 FH
9130 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9131 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9132 *- TR 1062018/1064343 FH
9133 DELETE IN (pceipoTD)
9134
9135 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9136
9137 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
9138 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
9139 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
9140
9141 ENDIF && TR 1043037 OCT-06-2009 BR
9142
9143 lnCoor_Code = lnCoor_Code + 1
9144 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9145 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9146 ENDIF
9147 lnLine_Seq = 0
9148 ENDIF
9149 ENDDO
9150 USE IN __tmpipots
9151
9152 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9153
9154 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9155 This.Tableupdate("Vzzeipotd_notes_iPOproc")
9156 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9157
9158 ENDIF && TR 1043037 OCT-06-2009 BR
9159
9160 SELECT (lnOldSelect)
9161 RETURN llRetVal
9162 ENDPROC
9163
9164*=======================================================================
9165
9166 *---- get total sln qty for a detail line
9167 FUNCTION getPriceFromIPOts
9168 LPARAMETERS pceipoTS, pnPrice
9169 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
9170 lnUnitPrice = 0
9171 IF pnPrice > 0
9172 lnOldSelect = SELECT()
9173
9174 SELECT (pceipoTS)
9175 lnFkey = Fkey
9176 lnSLNQty = SLN_Qty
9177 .PushRecordSet()
9178 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
9179 lnUnitPrice = pnPrice/lnSLNTotalQty
9180 .PopRecordSet()
9181
9182 SELECT (lnOldSelect)
9183 ENDIF
9184
9185 RETURN lnUnitPrice
9186 ENDFUNC
9187
9188 ************************************************************************************
9189 * Resolve BC SKU from SLN records and create customer style data.
9190 *--- This is splitted 1st part from function ResolveStyleFromSLN
9191 ************************************************************************************
9192 Procedure ResolveBCSkuFromSLN
9193 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9194 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9195 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
9196 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9197 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
9198 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
9199
9200 lnOldSelect = Select()
9201 llRetVal = .T. && 1040686
9202 *--- TR 1036614 3-Mar-2010 Goutam
9203 lcErrs_Msg = ""
9204 lcDivision = ""
9205 *=== TR 1036614 3-Mar-2010 Goutam
9206
9207 *-- #1 Resolve SLN SKUs
9208 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
9209 *- 03/19/09 TR ? Retrofit TR1038539 YIK
9210 *- added SLN_SKU
9211 *- Removed WHERE ...and !Empty(s.SLN_UPC)
9212
9213 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
9214 * Added , s.sln_qty
9215 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
9216
9217 select h.Customer;
9218 , s.FKey;
9219 , s.SLN_UPC as UPC;
9220 , s.SLN_SKU as SKU ;
9221 , h.department ;
9222 , h.store ;
9223 , s.PKey;
9224 , .F. as SLN_Error;
9225 , Empty(d.SizeBucket) as Unresolved;
9226 , s.Division;
9227 , s.Style;
9228 , s.Color_Code;
9229 , s.SizeBucket;
9230 , d.Pkey as dtlPkey;
9231 , 'N' as IsPPK;
9232 , SPACE(5) as ppk_code;
9233 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9234 , s.sln_qty ;
9235 from (pceipoTH) h;
9236 join (pceipoTD) d ;
9237 on d.FKey = h.PKey;
9238 join (pceipoTS) s ;
9239 on s.FKey = d.PKey ;
9240 where !Empty(h.Customer) ;
9241 order by 1, 2;
9242 into Cursor tmpCurs ReadWrite
9243
9244* , s.Lbl_Code;
9245* , s.Dimension;
9246
9247*- 1040686
9248
9249 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9250 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9251 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9252 IF llRetVal
9253 .PopulateSQLTempTable("tcCustUpc")
9254 ENDIF
9255
9256 llRetVal = llRetVal AND v_sqlexec(;
9257 "SELECT x.upc,d.* "+;
9258 " FROM zzxcstdr d"+ ;
9259 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9260 " JOIN " + this.cSQLTempTable + " x " + ;
9261 " ON d.customer = x.customer " +;
9262 " AND d.cust_style = x.upc " + ;
9263 " WHERE h.IB_resolv = 'Y'" + ;
9264 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9265 SELECT tmpCstdr_upc
9266 INDEX on customer + upc TAG cust_upc
9267
9268
9269 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9270 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9271 IF llRetVal
9272 .PopulateSQLTempTable("tcDistUpc")
9273 ENDIF
9274
9275 llRetVal = llRetVal AND v_sqlexec(;
9276 "SELECT x.upc,d.* "+;
9277 " FROM zzeupcnr d"+ ;
9278 " JOIN " + this.cSQLTempTable + " x " + ;
9279 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9280 SELECT tmpUpcnr
9281 INDEX on upc TAG upc
9282
9283
9284 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9285 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9286 IF llRetVal
9287 .PopulateSQLTempTable("tcDistCustSku")
9288 ENDIF
9289 llRetVal = llRetVal AND v_sqlexec(;
9290 "SELECT x.sku,d.* "+;
9291 " FROM zzxcstdr d"+ ;
9292 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9293 " JOIN " + this.cSQLTempTable + " x " + ;
9294 " ON d.customer = x.customer " +;
9295 " AND d.cust_style = x.sku " + ;
9296 " WHERE h.IB_resolv = 'Y'" + ;
9297 " AND d.Size_Desc>'' " + ;
9298 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9299 SELECT tmpCstdr_sku
9300 INDEX ON customer + cust_style TAG cust_sku
9301
9302 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9303 UNION ;
9304 SELECT customer,sku FROM tmpCstdr_sku ;
9305 GROUP BY customer,sku ;
9306 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9307 INDEX ON customer+sku TAG cust_sku
9308 *=-===-=-=-=-=-=-=-
9309
9310*- 1040686
9311
9312 Select tmpCurs
9313 If This.lUserInterface
9314 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9315 This.InitThermo(RecCount())
9316 EndIf
9317
9318 lcOldCust = ""
9319 lcOldUPC = ""
9320 *- 03/19/09 1038539 YIK
9321 lcOldItem = ''
9322 Local lcSku_resolv, lcOldSku_resolv
9323 lcSku_resolv = ""
9324 *=
9325
9326 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9327 If This.lUserInterface
9328 * Advance progress bar, if we're using one.
9329 This.AdvanceThermo(RecNo())
9330 EndIf
9331 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9332 IF !EMPTY(tmpCurs.UPC)
9333
9334 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9335 lcErrs_Msg = ""
9336 lcOldCust = tmpCurs.Customer
9337 lcOldUPC = tmpCurs.UPC
9338
9339 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9340 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9341*- 1040686
9342*!* lcDivision = tmpCstdr.division
9343*!* lcStyle = tmpCstdr.Style
9344*!* lcColor_Code = tmpCstdr.Color_Code
9345*!* lcLbl_Code = tmpCstdr.Lbl_Code
9346*!* lcDimension = tmpCstdr.Dimension
9347*!* lnSizeBucket = tmpCstdr.Size_Bk
9348*!* lnSize_Desc = tmpCstdr.Size_Desc
9349 lcDivision = tmpCstdr_upc.division
9350 lcStyle = tmpCstdr_upc.Style
9351 lcColor_Code = tmpCstdr_upc.Color_Code
9352 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9353 lcDimension = tmpCstdr_upc.Dimension
9354 lnSizeBucket = tmpCstdr_upc.Size_Bk
9355 lnSize_Desc = tmpCstdr_upc.Size_Desc
9356*- 1040686
9357 Else
9358 lcErrs_Msg = ""
9359 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9360 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9361 lcDivision = tmpUpcnr.Division
9362 lcStyle = tmpUpcnr.Style
9363 lcColor_Code = tmpUpcnr.Color_Code
9364 lcLbl_Code = tmpUpcnr.Lbl_Code
9365 lcDimension = tmpUpcnr.Dimension
9366 lnSizeBucket = tmpUpcnr.SizeBucket
9367 lnSize_Desc = tmpUpcnr.Size_Desc
9368 ELSE
9369 *-&&1040686
9370 *lcErrs_Msg = lcErrs_Msg + CRLF
9371 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9372 *-&&1040686
9373 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9374 lnSizeBucket = 0
9375 Endif
9376 Endif
9377 Endif && level break
9378 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9379 *- Added resolution on SKU
9380 ENDIF && TmpCurs.UPC
9381 *- 03/17/09 TR 1038539 YIK
9382 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9383 *- but UPC resolution failed.
9384 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9385 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9386
9387 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9388 lcErrs_Msg = ""
9389 lcOldCust = tmpCurs.customer
9390 lcOldItem = tmpCurs.sku
9391
9392 *- 1040686
9393 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9394 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9395 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9396 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9397 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9398 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9399 Store 0 To lnSizeBucket
9400 ELSE
9401 *- TR 1074276 FH - adding UPPER()
9402 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9403 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9404 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9405 Store 0 To lnSizeBucket
9406 ELSE
9407*!* lcDivision = tmpCstdr.division
9408*!* lcStyle = tmpCstdr.Style
9409*!* lcColor_code = tmpCstdr.color_code
9410*!* lcLbl_code = tmpCstdr.lbl_code
9411*!* lcDimension = tmpCstdr.Dimension
9412*!* lnSizeBucket = tmpCstdr.size_bk
9413*!* lnSize_desc = tmpCstdr.size_desc
9414 lcDivision = tmpCstdr_sku.division
9415 lcStyle = tmpCstdr_sku.Style
9416 lcColor_code = tmpCstdr_sku.color_code
9417 lcLbl_code = tmpCstdr_sku.lbl_code
9418 lcDimension = tmpCstdr_sku.Dimension
9419 lnSizeBucket = tmpCstdr_sku.size_bk
9420 lnSize_desc = tmpCstdr_sku.size_desc
9421 ENDIF
9422 ENDIF
9423 *- 1040686
9424 ENDIF
9425 ENDIF
9426 *== 1038539 Resolution on SKU
9427
9428 Select (pceipoTS)
9429 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9430
9431 Scatter Name loEiPOTS Memo
9432 If !Empty(lcErrs_Msg)
9433 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9434 loEiPOTS.Errs_Flg_S = "Y"
9435 replace Sln_Error with .T. in tmpCurs
9436 Else
9437 replace Division with lcDivision in tmpCurs
9438 Endif
9439
9440 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9441 loEiPOTS.Division = lcDivision
9442 loEiPOTS.Style = lcStyle
9443 loEiPOTS.Color_Code = lcColor_code
9444 loEiPOTS.Lbl_Code = lcLbl_code
9445 loEiPOTS.Dimension = lcDimension
9446 loEiPOTS.SizeBucket = lnSizeBucket
9447 loEiPOTS.Size_Desc = lnSize_Desc
9448 Endif
9449
9450 Gather Name loEiPOTS Memo
9451
9452 EndScan
9453
9454*- 1060291 07/02/12 YIK
9455*- The code below makes no sense. It takes the first prepack found for the SLN.
9456*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9457 *--- TR 1036614 17-Mar-2010 Goutam
9458*-- SELECT tmpCurs
9459*-- SCAN FOR IsPPK = 'N'
9460*-- Select (pceipoTS)
9461*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9462*-- Scatter Name loEiPOTS Memo
9463*--
9464*-- IF NOT EMPTY(loEiPOTS.Dimension)
9465*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9466*-- IF !EMPTY(lcppk_code)
9467*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9468*-- ENDIF
9469*-- ENDIF
9470*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9471*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9472*-- 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')
9473*-- SELECT __tmpDimCurs
9474*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9475*-- lcppk_code = dimension
9476*-- USE IN SELECT('__tmpDimCurs')
9477*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9478*-- 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)
9479*-- SELECT __tmpDimCurs
9480*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9481*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9482*-- ENDIF
9483*-- USE IN SELECT('__tmpDimCurs')
9484*-- ENDIF
9485*-- ENDIF
9486*-- ENDSCAN
9487 *--- TR 1036614 17-Mar-2010 Goutam
9488
9489 *--- TR 1038353 NH - error out dtl line for SLN error
9490 UPDATE td SET Style_SLN_OK = 'N' ;
9491 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9492 WHERE ts.errs_flg_s ='Y'
9493 *=== TR 1038353 NH
9494
9495 If This.lUserInterface
9496 * Reset Thermometer
9497 This.ResetThermo()
9498 EndIf
9499
9500 *--- TR 1036614 8-Jun-2009 Goutam
9501 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9502 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9503
9504 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9505 lnSelect = SELECT()
9506
9507 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9508 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9509
9510 Select tmpErrSlnLines
9511 Scan
9512 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9513 Endscan
9514
9515 This.TableClose("tmpErrSlnLines")
9516
9517 Select (lnSelect )
9518 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9519
9520 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9521 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9522 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9523 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9524 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9525 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9526 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9527 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9528
9529 This.TableClose("tmpCurs")
9530
9531 *=== TR 1036614 8-Jun-2009 Goutam
9532
9533 *-1040686
9534 USE IN SELECT("tcCustUpc")
9535 USE IN SELECT("tmpCstdr_upc")
9536 USE IN SELECT("tcDistUpc")
9537 USE IN SELECT("tmpUpcnr")
9538 USE IN SELECT("tcDistCustSku")
9539 USE IN SELECT("tmpCstdr_sku")
9540 USE IN SELECT("tcAmbigSku")
9541 *-1040686
9542
9543 Select(lnOldSelect)
9544 Return llRetVal
9545 Endproc
9546
9547
9548 *--------------------------------------------
9549 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9550 *--------------------------------------------
9551 Procedure GetImplodeSQL
9552 *-- Populates cImplodeSQL
9553 SET TextMerge OFF NoShow
9554*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9555 Text to this.cImplodeSQL flags 1
9556--* TR-1067132, made it as sql comment -- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9557declare @Division char(3), @Style varChar(50), @Customer char(7),
9558 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9559
9560set @Customer = ?cCustomer
9561set @Division = ?cDivision
9562set @Style = ?cStyle
9563
9564-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9565select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9566 from zzeipocr_expl
9567 where Customer = @Customer
9568 and Division = @Division
9569
9570select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9571
9572--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9573
9574-- Output Values:
9575--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9576declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9577
9578-- first SQL:
9579if @CR_Lbl > ''
9580select top 1 @Color_Code = c.Color_Code
9581 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9582 , @Dimension = c.Dimension
9583 , @Size = Min(z.Size01)
9584-- , c.Lbl_Code as SColR_Lbl
9585 from zzxSColR c
9586 join zzxStylR st
9587 on st.PKey = c.FKey
9588 join zzxPPakH ph
9589 on ph.Division = c.Division
9590 and ph.Size_Code = st.Size_Code
9591 and ph.Ppk_Code = c.Dimension
9592 and c.Color_Code = case
9593 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9594 else c.Color_Code end
9595 join zzxPPakD pd
9596 on pd.FKey = ph.PKey
9597 join zzxSizer z
9598 on z.Division = c.Division
9599 and z.Size_Code = st.Size_Code
9600 cross join zzxBuckt b
9601 left join #ImplodeSLN i
9602 on i.Color_Code = case
9603 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9604 else pd.Color_Code end
9605 and (i.Lbl_Code = case
9606 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9607 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9608 and i.Dimension = pd.Dimension
9609 and i.SizeBucket = b.Size_Num
9610 where c.Style = @Style
9611 and c.Division = @Division
9612 and c.PPack_OK = 'Y'
9613 and c.Active_OK = 'Y'
9614 and ph.Active_OK = 'Y'
9615 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9616 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9617 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9618 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9619 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9620 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9621 and (c.Lbl_Code = case
9622 when @SLN_Lbl > ''
9623 then @SLN_Lbl
9624 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9625 group by c.PKey, ph.Pack_qty
9626 , c.Color_code, c.Lbl_Code, c.Dimension
9627having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9628 and sum(i.Qty) = ph.Pack_qty
9629 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9630 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9631
9632IF @CR_Lbl > '' and @@ROWCOUNT > 0
9633 select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9634ELSE BEGIN
9635
9636select top 1 @Color_Code = c.Color_Code
9637 , @Lbl_Code = c.Lbl_Code
9638 , @Dimension = c.Dimension
9639 , @Size = Min(z.Size01)
9640 from zzxSColR c
9641 join zzxStylR st
9642 on st.PKey = c.FKey
9643 join zzxPPakH ph
9644 on ph.Division = c.Division
9645 and ph.Size_Code = st.Size_Code
9646 and ph.Ppk_Code = c.Dimension
9647 and c.Color_Code = case
9648 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9649 else c.Color_Code end
9650 join zzxPPakD pd
9651 on pd.FKey = ph.PKey
9652 join zzxSizer z
9653 on z.Division = c.Division
9654 and z.Size_Code = st.Size_Code
9655 cross join zzxBuckt b
9656 left join #ImplodeSLN i
9657 on i.Color_Code = case
9658 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9659 else pd.Color_Code end
9660 and (i.Lbl_Code = case
9661 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9662 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9663 and i.Dimension = pd.Dimension
9664 and i.SizeBucket = b.Size_Num
9665 where c.Style = @Style
9666 and c.Division = @Division
9667 and c.PPack_OK = 'Y'
9668 and c.Active_OK = 'Y'
9669 and ph.Active_OK = 'Y'
9670 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9671 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9672 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9673 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9674 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9675 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9676 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9677 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9678 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9679 group by c.PKey, ph.Pack_qty
9680 , c.Color_code, c.Lbl_Code, c.Dimension
9681having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9682 and sum(i.Qty) = ph.Pack_qty
9683 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9684 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9685 , c.Lbl_code -- blank one goes first if there is no match
9686
9687select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9688 where @Color_Code is not null
9689END
9690EndText
9691
9692*--- TechRec 1073664 20-Sep-2013 GSternik ---
9693 Text to this.cImplodeRangeSQL flags 1
9694declare @Division char(3)
9695set @Division = ?cDivision
9696
9697-- Output Values:
9698declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9699
9700select @Style = rh.Rng_Style
9701 , @Color_Code = rh.Rng_Color
9702 , @Lbl_Code = rh.Rng_Lbl
9703 , @Dimension = rh.Rng_Pack
9704 , @SizeBucket = rng_bk
9705 from zzxRangH rh with (NoLock)
9706 join zzxRangD rd with (NoLock)
9707 on rd.FKey = rh.PKey
9708 --join zzxSColR c
9709 -- on c.Division = rh.Division
9710 -- and c.Style = rh.Rng_Style
9711 -- and c.Color_Code = rh.Rng_Color
9712 -- and c.Lbl_Code = rh.Rng_Lbl
9713 -- and c.Dimension = rh.Rng_Pack
9714 join zzxBuckt b with (NoLock)
9715 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9716 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9717 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9718 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9719 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9720 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
9721 left join #ImplodeSLN i
9722 on i.Style = rd.Style
9723 and i.Color_Code = rd.Color_Code
9724 and i.Lbl_Code = rd.Lbl_Code
9725 and i.Dimension = rd.Dimension
9726 and i.SizeBucket = b.Size_Num
9727 and i.Division = rd.Division
9728 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9729 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9730 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9731 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9732 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9733 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
9734 where rh.Rng_Type = 'P'
9735 and rh.Division = @Division
9736-- and c.Active_OK = 'Y'
9737 group by rh.Rng_Style
9738 , rh.Rng_Color
9739 , rh.Rng_Lbl
9740 , rh.Rng_Pack
9741 , rng_bk
9742having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9743 and sum(i.Qty) = Max(rh.Rng_Qty)
9744
9745if @Style is not null -- @@RowCount > 0
9746select @Size = case @SizeBucket
9747 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
9748 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
9749 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
9750 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
9751 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
9752 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
9753 from zzxStylR s with (NoLock)
9754 join zzxSizeR z with (NoLock)
9755 on z.Division = s.Division
9756 and z.Size_Code = s.Size_Code
9757 where s.Division = @Division
9758 and s.Style = @Style
9759
9760select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
9761 where @Style is not null
9762EndText
9763*=== TechRec 1073664 20-Sep-2013 GSternik ===
9764
9765 EndProc
9766
9767 *---------------------------------
9768 *--- This function will generate PPK SKU and updates detail with it.
9769 *--- This is splitted 2nd part from function ResolveStyleFromSLN
9770 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
9771 *---------------------------------
9772 Procedure ResolvePPKSkuAndUpdateDetail
9773 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
9774 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9775 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9776 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
9777 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
9778 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
9779
9780 llRetVal = .T.
9781 lnOldSelect = Select()
9782
9783 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
9784 Dimension laBuckets(goEnv.MaxBuckets)
9785
9786 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
9787 Select tmpCurs
9788 lnFKey = 0
9789
9790 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
9791
9792 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
9793 Scan
9794 If FKey # lnFKey
9795 lnFKey = FKey
9796
9797 If SLN_Error or !Unresolved
9798 llDeleteSLN = .T.
9799 Else
9800 llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
9801
9802 If !llDeleteSLN
9803 Select (pceipoCR)
9804 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
9805
9806 *--- TR 1036614 10-Jun-2009 Goutam
9807 *llDeleteSLN = StyleFromSLN < "Y"
9808 llDeleteSLN = StyleFromSLN < "O"
9809 *=== TR 1036614 10-Jun-2009 Goutam
9810
9811 Select tmpCurs
9812 EndIf
9813 EndIf
9814
9815 If !llDeleteSLN
9816 lnRecNo = RecNo()
9817
9818 Scan while FKey = lnFKey
9819 If SLN_Error
9820 *-- One SLN with error exists.
9821 llDeleteSLN = .T.
9822 Exit
9823 EndIf
9824 EndScan
9825
9826 Go lnRecNo
9827 EndIf
9828 EndIf
9829
9830 If llDeleteSLN
9831 Delete
9832 EndIf
9833 EndScan
9834
9835
9836 *-- #3 -- Updating Details with PPK BC SKU:
9837 lcOldCust = ""
9838 lcOldSKU = ""
9839 lnFKey = 0
9840 lnRecNo = This.CountTotalRecs('tmpCurs')
9841
9842 If lnRecNo > 0
9843 *-- Need for optimization:
9844
9845 If This.lUserInterface
9846 This.UpdateThermoCaption("Resolving Style From SLN...")
9847 This.InitThermo(lnRecNo + 1)
9848 lnRecNo = 1
9849 Endif
9850 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
9851
9852 *- 1041704 07/30/09 YIK
9853 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9854 *-- Let's rely on the field types in the UPC table:
9855 *v_SQLExec("create table #ImplodeSLN " + ;
9856 * "( 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)
9857 * " Size_Desc Char(10), Qty Int, PKey Int)")
9858 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
9859 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
9860 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9861
9862 Select (pceipoTD)
9863 lcOldOrder = Order()
9864
9865 *- 03/23/09 YIK
9866 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
9867 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
9868 Index on Customer+SKU+UPC+Assortment tag CustSKU
9869 lcOldUPC = ''
9870 *==
9871
9872 If This.lUserInterface
9873 This.AdvanceThermo(lnRecNo)
9874 EndIf
9875
9876 Select tmpCurs
9877 Locate
9878 cCustomer = Customer
9879
9880 Do while .T. && Scan replacement
9881 if FKey # lnFKey && Will trigger @ EOF :o)
9882 If llProcess
9883 If llImplodeOK
9884 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
9885
9886 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9887 *-- Let's check if they belong to the Range Style 'P'
9888 If Reccount("qPPK") = 0 && Prepack not found
9889 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
9890 EndIf
9891 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9892
9893 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
9894 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9895 Select (pceipoTS)
9896 *- insert into #implodeSLN
9897 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
9898 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9899 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9900 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9901 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9902 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
9903 Endif
9904 EndIf && llImplodeOK
9905 *========= 1041704 07/30/09 YIK
9906
9907 select (pceipoTD)
9908 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
9909 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9910 lcOldCust = Customer
9911 lcOldSKU = SKU
9912
9913 *- 03/23/09 YIK
9914 *-- Update all records with the same CustSKU
9915 *- =Seek(lcOldCust+lcOldSKU) && First matching record
9916 lcOldUPC = UPC
9917 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
9918
9919 *==
9920 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
9921 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9922 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
9923 replace Division with cDivision, ;
9924 Style with qPPK.Style, ;
9925 Color_Code with qPPK.Color_Code, ;
9926 Lbl_Code with qPPK.Lbl_Code, ;
9927 Dimension with qPPK.Dimension,;
9928 SizeBucket with qPPK.SizeBucket;
9929 Size_Desc with qPPk.Size01;
9930 Style_SLN_OK with 'Y' ;
9931 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9932 Else
9933
9934 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
9935 *--- TR 1036614 12-Jun-2009 Goutam
9936 IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
9937 *=== TR 1036614 12-Jun-2009 Goutam
9938 *--- TR 1056329 02-Nov-11 SK
9939 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9940 replace Style_SLN_OK with 'N' ;
9941 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9942 *--- TR 1036614 12-Jun-2009 Goutam
9943 ENDIF
9944 *=== TR 1036614 12-Jun-2009 Goutam
9945
9946 ENDIF
9947 Else && llProcess flag is not set
9948 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9949 Select (pceipoTS)
9950 *- insert into #implodeSLN
9951 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
9952 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9953 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9954 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9955 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9956 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
9957 *=== 1041704
9958 EndIf
9959 EndIf && Process Detail
9960
9961 Select tmpCurs
9962 if Eof()
9963 Exit
9964 EndIf
9965
9966 lnFKey = FKey
9967 cCustomer = Customer
9968 Select (pceipoTD)
9969 =Seek(lnFKey, pceipoTD, "PKey")
9970
9971 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
9972
9973 llImplodeOK = llProcess
9974
9975 If llImplodeOK
9976 store 0 to laBuckets
9977 lnPackTotal = 0
9978
9979 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
9980 Select (pceipoTS)
9981 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9982
9983 cDivision = Division
9984 cStyle = Style
9985 lcColor_Code = Color_Code
9986 lcLbl_Code = Lbl_Code
9987 lcDimension = Dimension
9988 EndIf
9989
9990 Else && The same FKey
9991 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
9992 Select (pceipoTS)
9993 if Division # cDivision;
9994 or Style # cStyle
9995 *- 1041704 YIK 07/29/09
9996 *- Allow multicolor prepacks
9997 *-- or Color_Code # lcColor_Code;
9998 *-- or Lbl_Code # lcLbl_Code;
9999 *-- or Dimension # lcDimension
10000
10001 llImplodeOK = .F.
10002 ELSE
10003 *- insert into #implodeSLN
10004 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10005 v_SQLExec("insert into #ImplodeSLN values ('"+;
10006 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
10007 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
10008 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10009 *=== 1041704
10010 EndIf
10011 EndIf
10012 EndIf && FKey Changed
10013
10014 if llImplodeOK
10015 *-- (pceipoTS) is selected!
10016 laBuckets[SizeBucket] = Sln_Qty
10017 lnPackTotal = lnPackTotal + Sln_Qty
10018 EndIf
10019
10020 Select tmpCurs
10021 Skip
10022
10023 If This.lUserInterface
10024 lnRecNo = lnRecNo + 1
10025 This.AdvanceThermo(lnRecNo)
10026 Endif
10027 EndDo && Endscan
10028
10029 Select (pceipoTD)
10030 Set Order to (lcOldOrder)
10031 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
10032 *v_SQLExec("DROP table #ImplodeSLN ")
10033 EndIf && Have data to Implode
10034
10035 *--- TR 1036614 11-Jun-2009 Goutam
10036 *Use In tmpCurs
10037 *=== TR 1036614 11-Jun-2009 Goutam
10038
10039 If This.lUserInterface
10040 * Reset Thermometer
10041 This.ResetThermo()
10042 Endif
10043
10044 Select(lnOldSelect)
10045 Return llRetVal
10046 Endproc
10047 *=== TR 1035491 4-Nov-2008 Goutam
10048
10049*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
10050*!*
10051* TR 1037925 - As per Krishna/Shenba
10052* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
10053* This is getting moved in TR 1037925
10054
10055*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
10056*!* *===========================================================================================
10057*!* Function ResolveCustShipper
10058*!* Lparameters pceipoTH, pceipoCR
10059*!* LOCAL lnSelect, llRetVal
10060
10061*!* lnSelect = SELECT()
10062
10063*!* WITH This
10064*!*
10065*!* SELECT distinct h.customer, h.division, ;
10066*!* h.cust_shipper ;
10067*!* FROM (pceipoTH) h, (pceipoCR) r ;
10068*!* WHERE r.resv_cust_ship = 'Y' and ;
10069*!* h.customer = r.customer and ;
10070*!* h.division = r.division ;
10071*!* INTO CURSOR '_tmpCustShipper'
10072*!*
10073*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10074*!*
10075*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10076*!*
10077*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
10078*!* REPLACE ALL shipper WITH '' In (pceipoTH)
10079*!* SET RELATION TO
10080*!* ENDIF
10081*!*
10082*!* SELECT '_tmpCustShipper'
10083
10084*!* .cSQLTempTable = ""
10085*!*
10086*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10087*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10088*!* IF !EMPTY(.cSQLTempTable)
10089*!*
10090*!* *---- Matching with customer, cust_shipper, division
10091*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10092*!* "s.shipper " + ;
10093*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10094*!* "Where s.customer = t.customer and " + ;
10095*!* "s.division = t.division and " + ;
10096*!* "s.cust_shipper = t.cust_shipper "
10097*!*
10098*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10099*!*
10100*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10101*!* SELECT _custShipper
10102*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10103*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10104*!* IF llRetVal
10105*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10106*!* SET RELATION TO
10107*!* ENDIF
10108*!* ENDIF
10109*!* ENDIF
10110*!* ENDIF
10111*!* ENDIF
10112*!*
10113*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10114*!* FROM (pceipoTH) h, (pceipoCR) r ;
10115*!* WHERE r.resv_cust_ship = 'Y' and ;
10116*!* h.customer = r.customer and ;
10117*!* h.division = r.division and ;
10118*!* EMPTY(h.shipper) ;
10119*!* INTO CURSOR '_tmpCustShipper'
10120*!*
10121*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10122*!*
10123*!* SELECT '_tmpCustShipper'
10124
10125*!* .cSQLTempTable = ""
10126*!*
10127*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10128*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10129*!* IF !EMPTY(.cSQLTempTable)
10130*!*
10131*!* *---- Matching with customer, cust shipper, and division = ''
10132*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10133*!* "s.shipper " + ;
10134*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10135*!* "Where s.customer = t.customer and " + ;
10136*!* "s.division = '' and " + ;
10137*!* "s.cust_shipper = t.cust_shipper "
10138*!*
10139*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10140*!*
10141*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10142*!* SELECT _custShipper
10143*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10144*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10145*!*
10146*!* IF llRetVal
10147*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10148*!* SET RELATION TO
10149*!* ENDIF
10150*!*
10151*!* ENDIF
10152*!* ENDIF
10153*!* ENDIF
10154*!* ENDIF
10155
10156*!* USE in '_tmpCustShipper'
10157*!*
10158*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10159*!* FROM (pceipoTH) h, (pceipoCR) r ;
10160*!* WHERE r.resv_cust_ship = 'Y' and ;
10161*!* h.customer = r.customer and ;
10162*!* h.division = r.division and ;
10163*!* EMPTY(h.shipper) ;
10164*!* INTO CURSOR '_tmpCustShipper'
10165*!*
10166*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10167*!*
10168*!* IF RECCOUNT('_tmpCustShipper') > 0
10169*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10170*!*
10171*!* IF llRetVal
10172*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
10173*!* Errs_flg_h WITH "Y" ;
10174*!* FOR customer = _tmpCustShipper.customer and ;
10175*!* division = _tmpCustShipper.division and ;
10176*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
10177*!*
10178*!* SET RELATION TO
10179*!* ENDIF
10180*!*
10181*!* ENDIF
10182*!*
10183*!* ENDWITH
10184*!*
10185*!* USE in '_tmpCustShipper'
10186*!* USE in '_custShipper'
10187*!* SELECT(lnSelect)
10188*!*
10189*!* RETURN llRetVal
10190*!* ENDFUNC
10191*!* *===========================================================================================
10192*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
10193*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
10194
10195*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
10196*============================================================
10197 FUNCTION CalculateSLNs
10198 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10199 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10200 lnTotal_qty
10201
10202 llRetVal = true
10203 lnSelect = SELECT()
10204
10205 lcCursor = GetUniqueFileName()
10206 WITH This
10207
10208 *--- TR 1047450 28-May-2010 Partha ---
10209 * removed c.Template = 'GAP'
10210 * from where clause of following qry
10211
10212*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10213*!* " FROM (pceipoTD) d " + ;
10214*!* " JOIN (pceipoTH) H " + ;
10215*!* " ON H.pkey = d.fkey " + ;
10216*!* " JOIN (pceipoCR) C " + ;
10217*!* " ON D.division = C.Division " + ;
10218*!* " AND H.Customer = C.Customer " + ;
10219*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
10220
10221 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10222 " FROM (pceipoTD) d " + ;
10223 " JOIN (pceipoTH) H " + ;
10224 " ON H.pkey = d.fkey " + ;
10225 " JOIN (pceipoCR) C " + ;
10226 " ON D.division = C.Division " + ;
10227 " AND H.Customer = C.Customer " + ;
10228 " WHERE NOT (d.Gap_ok = 'Y') "
10229 *=== TR 1047450 28-May-2010 Partha ===
10230
10231 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10232
10233 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10234 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10235 lcDeatil = .cSQLTempTable
10236
10237 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10238 " FROM " + lcDeatil + " t " + ;
10239 " JOIN zzxscolr s " + ;
10240 " ON s.division= t.division and " +;
10241 " s.style= t.style and s.color_code= t.color_code and " +;
10242 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10243 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10244 " LEFT OUTER JOIN zzxppakh ph " + ;
10245 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10246 " s.dimension= ph.ppk_code " + ;
10247 " Where s.ppack_ok= 'Y' "
10248
10249 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10250
10251 IF llRetVal
10252 *--- TR 1038394 YIK 01/29/09
10253 *- Select(lcCursor)
10254 *--INDEX on Pkey TAG Pkey
10255 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10256 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10257
10258 lnPrePack = 0
10259 SELECT(lcCursor)
10260 SCAN
10261 lnPkey = Pkey
10262 lnpack_qty = pack_qty
10263
10264 lnTotal_qty = &pceipoTD..Total_qty
10265
10266 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10267 lcErrs_Msg = " Can not Calculate number of prepacks. "
10268
10269 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10270 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10271 Errs_Flg_D With "Y" ;
10272 IN (pceipoTD)
10273 LOOP
10274 ELSE
10275 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10276 IF lnpack_qty >0
10277 lnTotal_qty = lnTotal_qty /lnpack_qty
10278 ENDIF
10279 ENDIF
10280 Endif
10281
10282 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10283 lnPrePack = (lnTotal_qty/lnpack_qty)
10284 SELECT(pceipoTS)
10285 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10286
10287 IF lnSlnqty >0
10288 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10289 SELECT(pceipoTS)
10290 SCAN FOR Fkey = lnPkey
10291 IF MOD(sln_qty,lnPrePack) >0
10292 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10293 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10294 Errs_Flg_S With "Y"
10295 ENDIF
10296 ENDSCAN
10297 LOOP
10298 ELSE
10299 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10300*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10301 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10302 ENDIF
10303
10304 ENDIF
10305 ENDSCAN
10306
10307 ENDIF
10308 ENDIF
10309 .TableClose(lcCursor)
10310 ENDWITH
10311
10312 SELECT (lnSelect)
10313 RETURN llRetVal
10314 ENDFUNC
10315*============================================================
10316
10317*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10318
10319
10320*--- TR 1036917 04-Feb-2009 Partha ---
10321
10322*============================================================
10323 FUNCTION ChangeColor
10324 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10325 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10326 lnTotal_qty
10327
10328 llRetVal = true
10329 lnSelect = SELECT()
10330
10331 WITH This
10332 *--- TR 1039262 NSD - Use current system date, not PO date.
10333 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10334 If This.oHostProcess.lHaveSLN
10335 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.
10336 " 'D' AS Source " + ;
10337 " FROM (pceipoTD) d " + ;
10338 " JOIN (pceipoTH) H " + ;
10339 " ON H.pkey = d.fkey " + ;
10340 " WHERE d.Errs_flg_d <> 'Y' " + ;
10341 " AND d.org_color = ' ' " +;
10342 " UNION ALL " + ;
10343 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10344 " 'S' AS Source " + ;
10345 " FROM (pceipoTD) d " + ;
10346 " JOIN (pceipoTH) H " + ;
10347 " ON H.pkey = d.fkey " + ;
10348 " JOIN (pceipoTS) S " + ;
10349 " ON D.pkey = s.fkey " + ;
10350 " WHERE s.Errs_flg_s <> 'Y' " + ;
10351 " AND s.org_color = ' ' "
10352 ELSE
10353 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10354 " 'D' AS Source " + ;
10355 " FROM (pceipoTD) d " + ;
10356 " JOIN (pceipoTH) H " + ;
10357 " ON H.pkey = d.fkey " + ;
10358 " WHERE d.Errs_flg_d <> 'Y' " + ;
10359 " AND d.org_color = ' ' "
10360 ENDIF
10361
10362 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10363
10364 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10365 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10366 lcDeatil = .cSQLTempTable
10367 *--- 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)
10368 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10369 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10370 " FROM " + lcDeatil + " t " + ;
10371 " JOIN zzxrupch h " + ;
10372 " ON h.division= t.division " + ;
10373 " and h.style= t.style " + ;
10374 " and h.color_code= t.color_code " + ;
10375 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10376 " and h.dimension = t.dimension " + ;
10377 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10378 " WHERE h.active_ok = 'Y' " + ;
10379 " AND d.active_color = 'Y' " + ;
10380 " AND d.effect_Date = " + ;
10381 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10382 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10383 " ORDER BY d1.effect_date DESC ) "
10384
10385 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10386
10387 IF llRetVal
10388 Select("__RollingUpc")
10389 INDEX on Pkey TAG Pkey
10390 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10391
10392 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10393 org_Color WITH __RollingUpc.TempColr ;
10394 FOR NOT EOF("__RollingUpc") ;
10395 AND __RollingUpc.Source = "D" IN (pceipoTD)
10396
10397 Set Relation To
10398
10399 If This.oHostProcess.lHaveSLN
10400 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10401 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10402 org_Color WITH __RollingUpc.TempColr ;
10403 FOR NOT EOF("__RollingUpc") ;
10404 AND __RollingUpc.Source = "S" IN (pceipoTS)
10405 Set Relation To
10406 ENDIF
10407
10408 ENDIF
10409
10410 .TableClose("__RollingUpc")
10411
10412 ENDIF
10413 ENDWITH
10414
10415 SELECT (lnSelect)
10416 RETURN true
10417 ENDFUNC
10418*============================================================
10419
10420*=== TR 1036917 04-Feb-2009 Partha ===
10421
10422**************************************************************************************
10423
10424 * --- TR 1034963 12/15/08 CM
10425 * This procedure will write back to sysnotes exploded components of Range Styles
10426
10427 Procedure UpdateSysNotes
10428
10429 Local laTables[1]
10430 laTables[1] = "Vzzeipotd_notes_iPOproc"
10431
10432 Local llRetVal, llBeganTransaction
10433
10434 llRetVal = .T.
10435
10436 If This.BeginTransaction()
10437 llRetVal = This.Tableupdate(@laTables)
10438 If llRetVal
10439 This.EndTransaction()
10440 Else
10441 This.RollbackTransaction()
10442 Endif
10443 Endif
10444
10445 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10446
10447 Endproc
10448 * --- TR 1034963 12/15/08 CM
10449
10450**************************************************************************************
10451
10452 *--------------------------------------------------
10453 *--- TR 1041542 NSD 7/22/09
10454 * Register Number can be assigned by a sort now.
10455 PROCEDURE ResolveRegisterNumber
10456 LPARAMETERS pceipoTH
10457
10458 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10459 llRetVal = .T.
10460 lnSelect = SELECT()
10461
10462 WITH THIS
10463
10464 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10465 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10466 lcColList = "pkey,customer,reg_num"
10467 SELECT tcAllCols
10468 SCAN
10469 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10470 ENDSCAN
10471
10472 * Retrieve just the columns we need
10473 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10474 &lcSQL
10475
10476 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10477 * Push records to server to work with.
10478 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10479 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10480 lcAllTmp = .cSQLTempTable
10481
10482 * Find distinct customer
10483 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10484 SELECT tcRegNum_cust
10485 SCAN
10486 * Process 1 customer
10487
10488 * Get the grouping
10489 lcCustTmp = "#" + GetUniqueFileName()
10490 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10491 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10492 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10493 IF llRetVal
10494 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10495 lcGrouping = "CUSTOMER,PO_NUM"
10496 ELSE
10497 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10498 ENDIF
10499
10500 * Need to have a SQL Filter for the groupings
10501 STRINGTOARRAY(lcGrouping,@laGroupFields)
10502 lcGroupFieldsFilter = ""
10503 FOR x = 1 TO ALEN(laGroupFields,1)
10504 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10505 ENDFOR
10506 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10507
10508 * Create temp table of unique reg nums
10509 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10510 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10511 " GROUP BY " + lcGrouping
10512 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10513
10514 * Count distinct records and generate enough reg_nums
10515 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10516 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10517
10518 * Calculate New reg_nums
10519 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10520
10521 * Write back to table
10522 llRetVal = llRetVal AND v_sqlexec(;
10523 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10524 lcGroupFieldsFilter )
10525
10526 ENDIF
10527
10528 USE IN SELECT("tcRegNum_Sort")
10529 USE IN SELECT("tcRegNum_cnt")
10530 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10531 ENDSCAN
10532
10533 * Get all records back from Temp table. Loop through and apply to main cursor
10534 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10535 IF llRetVal
10536 SELECT tcRegNum_res
10537 SCAN
10538 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10539 SELECT (pceipoTH)
10540 REPLACE reg_num WITH tcRegNum_res.reg_num
10541 ENDIF
10542 ENDSCAN
10543
10544 ENDIF
10545
10546 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10547 ENDIF
10548
10549
10550 USE IN SELECT("tcRegNum_res")
10551 USE IN SELECT("tcAllCols")
10552 USE IN SELECT("tcRegNum_All")
10553 USE IN SELECT("tcRegNum_cust")
10554
10555 ENDWITH
10556
10557 SELECT(lnSelect)
10558 RETURN llRetVal
10559 ENDPROC
10560 *=== TR 1041542 NSD 7/22/09
10561
10562*===============================================================
10563
10564 *--- TR 1036614 8-Jun-2009 Goutam
10565 Procedure CreateSingleSLNCursor
10566 Lparameters pcTmpCursor
10567
10568 Local llRetVal, lnOldSelect, lcSQLString
10569
10570 llRetVal = true
10571 lnOldSelect = Select()
10572
10573 *---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.
10574
10575 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10576
10577 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10578*!* select t.Customer ;
10579*!* , t.FKey ;
10580*!* , t.PKey ;
10581*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10582*!* , c.template ; && TR 1050793
10583*!* , c.slntodtl ; && TR 1050793
10584*!* from (pcTmpCursor) t ;
10585*!* join zzeipocr c ;
10586*!* on c.division = t.division ;
10587*!* and c.customer = t.customer ;
10588*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10589*!* on s.division = t.division ;
10590*!* and s.customer = t.customer ;
10591*!* and s.store = t.store ;
10592*!* where c.slntodtl = 'N' ;
10593*!* and (c.stylefromsln = 'O' ;
10594*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10595*!* into Cursor __tmpipots ;
10596*!* order by t.fkey, t.Customer, t.PKey
10597
10598 select t.Customer ;
10599 , t.FKey ;
10600 , t.PKey ;
10601 , NVL(s.price_flg, c.price_flg) as price_flg ;
10602 , c.template ; && TR 1050793
10603 , c.slntodtl ; && TR 1050793
10604 from (pcTmpCursor) t ;
10605 join zzeipocr c ;
10606 on c.division = t.division ;
10607 and c.customer = t.customer ;
10608 left join (this.oHostProcess.cCustomerStoreTable) s ;
10609 on s.division = t.division ;
10610 and s.customer = t.customer ;
10611 and s.store = t.store ;
10612 where c.slntodtl = 'N' ;
10613 and (c.stylefromsln = 'O' ;
10614 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10615 JOIN zzeipocr c ;
10616 on c.division = t.division ;
10617 and c.customer = t.customer ;
10618 group by t.fkey having (count(t.pkey)=1) and ;
10619 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10620 into Cursor __tmpipots ;
10621 order by t.fkey, t.Customer, t.PKey
10622 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10623
10624 Select(lnOldSelect)
10625 Return llRetVal
10626 Endproc
10627 *=== TR 1036614 8-Jun-2009 Goutam
10628
10629 *--- TR 1036614 8-Jun-2009 Goutam
10630 *--- This is the splited function from MoveSLNToDTLs
10631 PROCEDURE CreateCursorSLNToDtl
10632 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10633
10634 LOCAL llRetVal, lnOldSelect
10635 lnOldSelect = SELECT()
10636 llRetVal = true
10637
10638 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10639*!* select t.Customer ;
10640*!* , t.FKey ;
10641*!* , t.PKey ;
10642*!* , c.price_flg ;
10643*!* from (pcTmpCursor) t ;
10644*!* join zzeipocr c ;
10645*!* on c.division = t.division ;
10646*!* and c.customer = t.customer ;
10647*!* join (pceipoTD) d ;
10648*!* on d.pkey = t.dtlPkey ;
10649*!* where c.slntodtl = 'Y' ;
10650*!* and d.slntodtl <> 'Y' ;
10651*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10652*!* into Cursor __tmpipots ;
10653*!* order by t.fkey, t.Customer, t.PKey
10654
10655 *--- TR 1045922 05-MAR-2010 HNISAR
10656 * Added 'I' to Inlis in below statements
10657*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10658*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10659 *=== TR 1045922 05-MAR-2010 HNISAR
10660
10661 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10662 select t.Customer ;
10663 , t.FKey ;
10664 , t.PKey ;
10665 , NVL(s.price_flg, c.price_flg) as price_flg ;
10666 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10667 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
10668 from (pcTmpCursor) t ;
10669 join zzeipocr c ;
10670 on c.division = t.division ;
10671 and c.customer = t.customer ;
10672 left join (this.oHostProcess.cCustomerStoreTable) s ;
10673 on s.division = t.division ;
10674 and s.customer = t.customer ;
10675 and s.store = t.store ;
10676 join (pceipoTD) d ;
10677 on d.pkey = t.dtlPkey ;
10678 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
10679 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10680 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10681 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
10682 into Cursor __tmpipots ;
10683 order by t.fkey, t.Customer, t.PKey
10684 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
10685
10686 SELECT(lnOldSelect)
10687 RETURN llRetVal
10688
10689 ENDPROC
10690
10691 Procedure ResolveSingleSLNDetail
10692 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
10693
10694 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
10695
10696 llRetVal = true
10697 lnOldSelect = Select()
10698
10699 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10700 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
10701 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10702 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10703
10704 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10705*!* select t.Customer ;
10706*!* , t.FKey ;
10707*!* , t.PKey ;
10708*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10709*!* , t.ppk_code ;
10710*!* from (pcTmpCursor) t ;
10711*!* join zzeipocr c ;
10712*!* on c.division = t.division ;
10713*!* and c.customer = t.customer ;
10714*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10715*!* on s.division = t.division ;
10716*!* and s.customer = t.customer ;
10717*!* and s.store = t.store ;
10718*!* where c.slntodtl = 'N' ;
10719*!* AND ((c.stylefromsln in ('Y','O') ;
10720*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10721*!* into Cursor __tmpipots ;
10722*!* order by t.fkey, t.Customer, t.PKey
10723
10724 select t.Customer ;
10725 , t.FKey ;
10726 , t.PKey ;
10727 , NVL(s.price_flg, c.price_flg) as price_flg ;
10728 , t.ppk_code ;
10729 from (pcTmpCursor) t ;
10730 join zzeipocr c ;
10731 on c.division = t.division ;
10732 and c.customer = t.customer ;
10733 left join (this.oHostProcess.cCustomerStoreTable) s ;
10734 on s.division = t.division ;
10735 and s.customer = t.customer ;
10736 and s.store = t.store ;
10737 where c.slntodtl = 'N' ;
10738 AND ((c.stylefromsln in ('Y','O') ;
10739 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10740 JOIN zzeipocr c ;
10741 on c.division = t.division ;
10742 and c.customer = t.customer ;
10743 group by t.fkey having (count(t.pkey)=1) and ;
10744 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10745 into Cursor __tmpipots ;
10746 order by t.fkey, t.Customer, t.PKey
10747 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10748
10749 SELECT __tmpipots
10750 SCAN
10751 lnFKey = Fkey
10752
10753 Select (pceipoTS)
10754 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
10755
10756 lcDivision = Division
10757 lcStyle = Style
10758 lcColor_Code = Color_Code
10759 lcLbl_Code = Lbl_Code
10760 lcDimension = __tmpipots.PPK_Code
10761 lcSize_Desc = Size_Desc
10762
10763 select (pceipoTD)
10764 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
10765
10766 replace Division with lcDivision, ;
10767 Style with lcStyle, ;
10768 Color_Code with lcColor_Code, ;
10769 Lbl_Code with lcLbl_Code, ;
10770 Dimension with lcDimension,;
10771 SizeBucket with 1;
10772 Size_Desc with lcSize_Desc;
10773 Style_SLN_OK with 'Y' ;
10774 IN (pceipoTD)
10775 ENDIF
10776 ENDIF
10777 ENDSCAN
10778
10779 IF USED("__tmpipots")
10780 USE IN __tmpipots
10781 ENDIF
10782
10783 Select(lnOldSelect)
10784 Return llRetVal
10785 Endproc
10786
10787 *=== TR 1036614 8-Jun-2009 Goutam
10788
10789 *- 1044723 05/20/10 YIK
10790 *- Moved this method from postvalidation()
10791 PROCEDURE ResolveNewStoreOrd_type
10792 LPARAMETERS pcEipoTH
10793 LOCAL llRetVal, lnOldSelect
10794 llRetVal = .t.
10795 lnOldSelect = SELECT()
10796 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
10797 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
10798
10799 LOCAL lcSql, lcEipoTh, lcSQLTempTable
10800 lcEipoTh = SYS(2015)
10801 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
10802
10803 IF RECCOUNT(lcEipoTh) = 0
10804 USE IN (lcEipoTh)
10805 SELECT(lnOldSelect)
10806 RETURN llRetVal
10807 ENDIF
10808
10809 LOCAL lcOrd_typeResult
10810 lcOrd_typeResult = SYS(2015)
10811 WITH this
10812 .cSQLTempTable=""
10813 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
10814 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
10815 lcSQLTempTable = .cSQLTempTable
10816
10817 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
10818 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
10819 " inner join zzotyper r on r.ns_ord_type = 'Y'"
10820 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
10821 IF llRetVal
10822 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
10823 ENDIF
10824 ENDWITH
10825
10826 IF USED(lcEipoTh)
10827 USE IN (lcEipoTh)
10828 ENDIF
10829 IF USED(lcOrd_typeResult)
10830 USE IN (lcOrd_typeResult)
10831 ENDIF
10832
10833 Select(lnOldSelect)
10834 Return llRetVal
10835 Endproc
10836 *=== TR 1035678 NH
10837
10838 *--- TR 1049029 24-Aug-2010 Partha ---
10839 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
10840 FUNCTION GetTotSLNQty
10841 LPARAMETERS tnPSFkey, pceipoTS
10842
10843 LOCAL lnTotSlnQty, lnOldSelect
10844 LOCAL ARRAY laTotSlnQty[1]
10845
10846 lnOldSelect = SELECT()
10847 lnTotSlnQty = 0
10848
10849 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
10850 lnTotSlnQty = laTotSlnQty[1]
10851
10852 Select(lnOldSelect)
10853 Return lnTotSlnQty
10854 ENDFUNC
10855
10856 *=== TR 1049029 24-Aug-2010 Partha ===
10857
10858 *--- TechRec 1048792 17-Dec-2010 jisingh ---
10859 FUNCTION ClearSkus
10860 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
10861 LOCAL llRetVal, lnSelect, lcSqlString
10862
10863 llRetVal = true
10864 lnSelect = SELECT()
10865
10866 *-- Populate new flag from Control in Transaction Maintenance
10867 lcSqlString = " UPDATE h SET " + ;
10868 " ReResvStyle = c.ReResvStyle " + ;
10869 " FROM (pcEipoTH) h " + ;
10870 " JOIN (pcEipoCR) c " + ;
10871 " ON h.division = c.division " + ;
10872 " AND h.customer = c.customer " + ;
10873 " WHERE h.ReResvStyle = '' "
10874
10875 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10876
10877 *-- Make SKUs blank in Transaction Maintenance detail
10878 lcSqlString = " UPDATE d SET " + ;
10879 " Style = '', " + ;
10880 " Color_Code = '', " + ;
10881 " Lbl_Code = '', " + ;
10882 " Dimension = '', " + ;
10883 " SizeBucket = 0, " + ;
10884 " Size_Desc = '' " + ;
10885 " FROM (pcEipoTD) d " + ;
10886 " JOIN (pcEipoTH) h " + ;
10887 " ON h.pkey = d.fkey " + ;
10888 " WHERE h.ReResvStyle = 'Y' " + ;
10889 " AND (d.upc > '' OR d.sku > '') "
10890
10891 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10892
10893 *-- Make SKUs blank in SLN
10894 lcSqlString = " UPDATE s SET " + ;
10895 " Style = '', " + ;
10896 " Color_Code = '', " + ;
10897 " Lbl_Code = '', " + ;
10898 " Dimension = '', " + ;
10899 " SizeBucket = 0, " + ;
10900 " Size_Desc = '' " + ;
10901 " FROM (pcEipoTD) d " + ;
10902 " JOIN (pcEipoTH) h " + ;
10903 " ON h.pkey = d.fkey " + ;
10904 " JOIN (pcEipoTS) s " + ;
10905 " ON s.fkey = d.pkey " + ;
10906 " WHERE h.ReResvStyle = 'Y' " + ;
10907 " AND (s.sln_upc > '' OR s.sln_sku > '') "
10908
10909 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10910
10911 SELECT (lnSelect)
10912 RETURN llRetVal
10913 ENDFUNC
10914 *=== TechRec 1048792 17-Dec-2010 jisingh ===
10915
10916 *--- TR 1053820 25-May-2011 Goutam
10917 Function GenerateCustomerSKU_Style_ColorSize
10918 Lparameters pceipoTH,pceipoTD
10919
10920 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
10921 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
10922
10923 llRetVal = True
10924 lnSelect = Select()
10925 With This
10926
10927 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
10928
10929 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
10930
10931 *** Size_BK needs to be 00 and NOT 0
10932 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
10933 Select ;
10934 h.customer,;
10935 d.division,;
10936 d.pkey As dtlpkey ,;
10937 d.Style As Style, ;
10938 d.color_code,;
10939 d.lbl_code,;
10940 d.Dimension,;
10941 h.Store As cust_store ,;
10942 d.price As cust_price , ;
10943 d.size_desc, ;
10944 d.sizebucket as size_bk, ;
10945 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
10946 d.aux_sku ;
10947 from (pceipoTH) h ;
10948 join (pceipoTD) d ;
10949 on d.fkey = h.pkey ;
10950 join zzeipocr c ;
10951 on c.division = d.division ;
10952 and c.customer = h.customer ;
10953 where c.GenCustSKU = 'Y' ;
10954 and d.sku = '' ;
10955 and h.Errs_flg_h < 'Y' ;
10956 and d.Errs_Flg_D < 'Y' ;
10957 into cursor tmpCurs ;
10958 order by 1,2,4,5,6,7, 11
10959 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
10960
10961 lnCount = Reccount("tmpCurs")
10962
10963 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
10964
10965 If lnCount = 0
10966 If Used("tmpCurs")
10967 Use In tmpCurs
10968 Endif
10969 Select (lnSelect)
10970 Return
10971 Endif
10972
10973 *- Index just in case somebody changes the SELECT above
10974 Select tmpCurs
10975 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
10976 TAG sku
10977
10978 .LogEntry("Load Customer Style.")
10979
10980 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
10981 If Used("tmpCurs")
10982 Use In tmpCurs
10983 Endif
10984 Select (lnSelect)
10985 Return
10986 Endif
10987
10988 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
10989 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
10990 lnCount = lnCount - 1
10991 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
10992 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
10993
10994 Select VZZXCSTHR
10995 Scatter Memvar Blank
10996 Select VZZXCSTDR
10997 Scatter Memvar Blank
10998
10999 m.Last_mod = Datetime()
11000 m.User_id = 'CGSADMIN'
11001 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
11002 m.notes = ''
11003
11004 *--- TR 1057011 7-10-2011 VKK
11005 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
11006 m.active_ok = 'Y'
11007 m.anti_theft = 'N'
11008 *=== TR 1057011 7-10-2011 VKK
11009
11010 lcPrevSKU = ' '
11011 lcPrevSkuSize = ''
11012
11013 *- inserted details counter
11014 Local lnInsertCount
11015 lnInsertCount = 0
11016
11017 Select tmpCurs
11018
11019 Scan
11020 .LogEntry("Loading Customer Style...")
11021 .LogEntry("Style :" + Style )
11022 .LogEntry("Color_code :" + color_code )
11023
11024 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
11025 .LogEntry("Invalid Style or Color_code or Size_bk " )
11026 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
11027 FOR pkey = dtlpkey In (pceipoTD)
11028 Loop
11029 Endif
11030
11031 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
11032 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
11033 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
11034
11035 *--- Client Soffe wants to display size description in dimension's place if it is empty
11036 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
11037 If lcPrevSKU # lcSku
11038 lcPrevSKU = lcSku
11039 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
11040 .LogEntry("Customer :" + m.customer )
11041 .LogEntry("Division : " + m.division)
11042 .LogEntry("Style :" + Style )
11043 .LogEntry("Color_code :" + m.color_code )
11044 .LogEntry("Label code :" + m.lbl_code )
11045 .LogEntry("dimension : " + m.dimension)
11046 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
11047 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))
11048 If Empty(lnHDRpKey)
11049 lnHDRpKey = lnCstHrPkey
11050 .LogEntry("Inserting into header..")
11051 Insert Into VZZXCSTHR From Memvar
11052 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
11053 In VZZXCSTHR
11054 Endif
11055 Endif
11056 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
11057 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
11058 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
11059 *- 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)
11060 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
11061 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)
11062
11063 If Empty(lnDtlKey)
11064 lnDtlpKey = lnCstDrPkey
11065 .LogEntry("Inserting into detail..")
11066 Insert Into VZZXCSTDR From Memvar
11067 *- TR 1071542 FH- need to add replace for dimension here as well
11068 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
11069 lnInsertCount = lnInsertCount + 1
11070 Endif
11071 Endif
11072 lnCstDrPkey = lnCstDrPkey +1
11073 lnCstHrPkey = lnCstHrPkey +1
11074
11075 Endscan
11076
11077 Dimension laTables[2]
11078 laTables[1]= "VZZXCSTHR"
11079 laTables[2]= "VZZXCSTDR"
11080
11081 llBeganTransaction = .BeginTransaction()
11082 llRetVal = .Tableupdate(@laTables)
11083
11084 If llRetVal
11085 If llBeganTransaction
11086 This.EndTransaction()
11087 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
11088 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
11089 Endif
11090 Else
11091 If llBeganTransaction
11092 This.RollbackTransaction()
11093 .LogEntry("Table Update failed - Roll back Transaction " )
11094 Endif
11095 Endif
11096
11097 Endwith
11098
11099 If Used("tmpCurs")
11100 Use In tmpCurs
11101 Endif
11102
11103 Select (lnSelect)
11104 Return llRetVal
11105 Endfunc
11106
11107 *=== TR 1053820 25-May-2011 Goutam
11108
11109*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
11110 *============================================================
11111 Procedure RangePConversion
11112 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
11113 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
11114 llRetVal = .T.
11115 lnOldSelect = Select()
11116
11117 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11118
11119 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11120 * 1st Getting all range headers
11121 *- process all.
11122 *- Exclude range style P from the consideration
11123 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
11124 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
11125
11126 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
11127 FROM (pcTransDetail) d ;
11128 JOIN (pceipoCR) c ON c.customer = d.customer ;
11129 AND c.division = d.division ;
11130 WHERE ((d.rng_type = 'P' OR ;
11131 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
11132 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
11133 )AND c.rngp_conv = 'R') ; && requires Range P conversion
11134 AND d.ppk_action $ 'QPBO' ;
11135 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
11136
11137 With This
11138 .cSQLTempTable=""
11139 If .GenerateSQLTempTable('__TmpCursor')
11140 If .PopulateSQLTempTable('__TmpCursor')
11141 If !Empty(.cSQLTempTable)
11142
11143 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
11144 " st.size_code " +;
11145 " FROM " + .cSQLTempTable + " t " +;
11146 " JOIN zzxscolr s " + ;
11147 " ON s.division = t.division " +;
11148 " AND s.style = t.style " + ;
11149 " AND s.color_code = t.color_code " + ;
11150 " AND s.lbl_code = t.lbl_code " + ;
11151 " AND s.dimension = t.dimension " + ;
11152 " INNER JOIN zzxstylr st " + ;
11153 " ON st.pkey = s.fkey " + ;
11154 " JOIN zzxrangh rh " + ;
11155 " ON rh.division = t.division " + ;
11156 " AND rh.rng_Style = t.style " + ;
11157 " AND rh.rng_color = t.color_Code " + ;
11158 " AND rh.rng_lbl = t.lbl_Code " + ;
11159 " AND rh.rng_pack = t.dimension "
11160
11161 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
11162
11163 If Used("_PPK_Qty")
11164 Select ("_PPK_Qty")
11165 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
11166 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
11167 "division+style+color_code+lbl_code+dimension")
11168 SELECT ("__TmpCursor")
11169
11170 If llRetVal
11171 .LogEntry("Validating Range style.")
11172 lcErrs_Msg = "No valid Range Style found"
11173 Select (pcTransDetail)
11174 SCAN FOR !EOF("_PPK_Qty")
11175
11176 If Empty(_PPK_Qty.pack_qty)
11177 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
11178 Errs_Flg_D With "Y" ;
11179 IN (pcTransDetail)
11180 Else
11181 Do Case
11182
11183 Case ppk_action = 'Q' && multiply qty
11184
11185 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11186 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11187 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
11188 In (pcTransDetail)
11189
11190 Case ppk_action = 'P' && divide price
11191
11192 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11193 org_price With org_price/_PPK_Qty.pack_qty, ;
11194 retail1 With retail1/_PPK_Qty.pack_qty, ;
11195 retail2 With retail2/_PPK_Qty.pack_qty, ;
11196 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
11197 In (pcTransDetail)
11198
11199 *- Range style price will be populated later from a_price..e_price
11200 *- not from org_price. Need to updated these prices here.
11201 IF rng_type = 'R'
11202 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11203 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11204 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11205 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11206 e_price WITH e_price/_PPK_Qty.pack_qty ;
11207 In (pcTransDetail)
11208 ENDIF
11209
11210 Case ppk_action = 'B' OR ppk_action = 'O'
11211
11212 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11213 org_price With org_price/_PPK_Qty.pack_qty, ;
11214 retail1 With retail1/_PPK_Qty.pack_qty, ;
11215 retail2 With retail2/_PPK_Qty.pack_qty, ;
11216 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11217 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
11218 In (pcTransDetail)
11219
11220 IF rng_type = 'R'
11221 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11222 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11223 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11224 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11225 e_price WITH e_price/_PPK_Qty.pack_qty ;
11226 In (pcTransDetail)
11227 ENDIF
11228
11229 Otherwise
11230 Endcase
11231 Endif
11232 Endscan
11233 Endif
11234 Set Relation To
11235 Endif
11236 Endif
11237 Endif
11238 Endif
11239
11240 Endwith
11241
11242 If Used("__TmpCursor")
11243 Use In __TmpCursor
11244 Endif
11245
11246 If Used("_PPK_Qty")
11247 Use In _PPK_Qty
11248 Endif
11249
11250 If Used("__RangeP")
11251 Use In __RangeP
11252 Endif
11253
11254 Select(lnOldSelect)
11255 Return llRetVal
11256 *============================================================
11257 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11258
11259 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11260 PROCEDURE PopulateIs860
11261 LPARAMETERS pceipoTH, pceipoCR
11262 LOCAL llRetVal, lnSelect, lcUpdate
11263
11264 llRetVal = true
11265 lnSelect = SELECT()
11266
11267 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11268
11269 *--- TR 1070268 26-Jun-2013 Goutam
11270 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11271 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11272 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11273
11274 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11275 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11276 " 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')))"
11277
11278 *=== TR 1070268 26-Jun-2013 Goutam
11279
11280 &lcUpdate
11281
11282 SELECT (lnSelect)
11283 RETURN llRetVal
11284 ENDPROC
11285
11286 *============================================================
11287
11288 PROCEDURE Create860TM
11289 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
11290 LPARAMETERS pceipoTH, pceipoTD
11291 *--- TechRec 1082601 15-Dec-2014 jisingh Added loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp ===
11292 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql, loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp
11293
11294 llRetVal = true
11295 lnSelect = SELECT()
11296 lcAlias = GetUniqueFileName()
11297 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11298 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11299 lcInsertDtl = BuildInsertString("zzeipctd", "voEiPctd")
11300 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11301
11302 WITH This
11303 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11304 *IF !EMPTY(lcInsert)
11305 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11306 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11307 ORDER By h.division, h.customer INTO CURSOR tcOrders
11308
11309 .cSQLTempTable = ""
11310 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11311 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11312 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11313
11314 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11315 " FROM zzoordrh rh " + ;
11316 " JOIN " + .cSQLTempTable + " t " + ;
11317 " ON t.customer = rh.customer " + ;
11318 " AND t.division = rh.division " + ;
11319 " AND t.po_num = rh.po_num " + ;
11320 " AND t.store = rh.store " + ;
11321 " WHERE t.is860 = 'Y' "
11322
11323 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11324
11325 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11326 SELECT tcOrders
11327 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11328 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11329 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11330 SELECT (lcAlias)
11331 SCATTER NAME voEiPcth MEMO
11332
11333 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11334 .vSqlExec("SELECT * FROM zzeipctd WHERE 1 = 2", lcAlias)
11335 SELECT (lcAlias)
11336 SCATTER NAME voEiPctd MEMO
11337 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11338
11339 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11340 SELECT tcCRPkey
11341 INDEX ON customer+division TAG cudiv
11342
11343 SELECT (pceipoTH)
11344 COUNT TO lnRecNo FOR Is860 = 'Y'
11345
11346 IF .lUserInterface
11347 .AdvanceThermo(lnRecNo)
11348 ENDIF
11349
11350 SELECT (pceipoTH)
11351 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11352 *SCAN FOR Is860 = 'Y'
11353 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11354 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11355 SCATTER NAME loEiPOth MEMO
11356
11357 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11358 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11359
11360 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11361
11362 IF RECCOUNT("__tcipcth") > 0
11363 REPLACE Is860 WITH 'X' IN (pceipoTH)
11364 USE IN SELECT("__tcipcth")
11365 LOOP
11366 ENDIF
11367
11368 *--- TechRec 1082601 08-Jan-2015 jisingh ---
11369 lcPocPurp = "01"
11370 SELECT (pceipoTD)
11371 IF SEEK(loEiPOth.pkey, pceipoTD, "fkey")
11372 SCAN WHILE fkey = loEiPOth.pkey
11373 IF !EMPTY(qual_860)
11374 lcPocPurp = "04"
11375 EXIT
11376 ENDIF
11377 ENDSCAN
11378 ENDIF
11379 SELECT (pceipoTH)
11380 *=== TechRec 1082601 08-Jan-2015 jisingh ===
11381
11382 WITH voEiPcth
11383 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11384 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11385 *--- TechRec 1082601 25-Dec-2014 jisingh ---
11386 *voEiPcth.poc_purp = "01"
11387 voEiPcth.poc_purp = lcPocPurp
11388 *=== TechRec 1082601 25-Dec-2014 jisingh ===
11389 voEiPcth.customer = loEiPOth.customer
11390 voEiPcth.division = loEiPOth.division
11391 voEiPcth.doc_num = loEiPOth.doc_num
11392 voEiPcth.edi_store = loEiPOth.edi_store
11393 voEiPcth.store = loEiPOth.store
11394 voEiPcth.isa_num = loEiPOth.isa_num
11395 voEiPcth.our_id = loEiPOth.our_id
11396 voEiPcth.our_qual = loEiPOth.our_qual
11397 voEiPcth.po_num = loEiPOth.po_num
11398 voEiPcth.vnd_id = loEiPOth.vnd_id
11399 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11400 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11401 voEiPcth.po_type = loEiPOth.po_type
11402 voEiPcth.vnd_key = loEiPOth.vnd_key
11403 ENDWITH
11404
11405 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11406
11407 REPLACE Is860 WITH 'X' IN (pceipoTH)
11408
11409 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11410 IF llRetVal AND !EMPTY(lcInsertDtl) AND voEiPcth.pkey > 0
11411 lnLineSeq = 1
11412
11413 SELECT (pceipoTD)
11414 SCAN FOR fkey = loEiPOth.pkey AND !EMPTY(qual_860)
11415 SCATTER NAME loEiPOtd MEMO
11416
11417 WITH voEiPctd
11418 voEiPctd.pkey = v_NextPkey("zzeipctd")
11419 voEiPctd.line_seq = lnLineSeq
11420 voEiPctd.fkey = voEiPcth.pkey
11421 voEiPctd.qualifier = loEiPOtd.qual_860
11422 voEiPctd.upc = loEiPOtd.upc
11423 voEiPctd.sku = loEiPOtd.sku
11424 voEiPctd.aux_sku = loEiPOtd.aux_sku
11425 voEiPctd.division = loEiPOtd.division
11426 voEiPctd.style = loEiPOtd.style
11427 voEiPctd.color_code = loEiPOtd.color_code
11428 voEiPctd.lbl_code = loEiPOtd.lbl_code
11429 voEiPctd.dimension = loEiPOtd.dimension
11430 voEiPctd.size_desc = loEiPOtd.size_desc
11431 voEiPctd.sizebucket = loEiPOtd.sizebucket
11432 voEiPctd.ean = loEiPOtd.ean
11433 voEiPctd.udfoordd1c = loEiPOtd.udfoordd1c
11434 voEiPctd.udfoordd2c = loEiPOtd.udfoordd2c
11435 voEiPctd.start_date = loEiPOtd.start_date
11436 voEiPctd.end_date = loEiPOtd.end_date
11437 voEiPctd.delv_code = loEiPOtd.delv_code
11438 voEiPctd.qty_change = loEiPOtd.total_qty
11439 voEiPctd.total_qty = loEiPOtd.total_qty
11440 voEiPctd.poc_cost = loEiPOtd.price
11441 voEiPctd.poc_price = loEiPOtd.retail1
11442 voEiPctd.poc_retail2 = loEiPOtd.retail2
11443 ENDWITH
11444
11445 llRetVal = llRetVal AND .vSqlExec(lcInsertDtl)
11446 lnLineSeq = lnLineSeq + 1
11447 ENDSCAN
11448 ENDIF
11449 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11450
11451 IF .lUserInterface
11452 lnRecNo = lnRecNo + 1
11453 .AdvanceThermo(lnRecNo)
11454 ENDIF
11455 USE IN SELECT("__tcipcth")
11456 ENDSCAN
11457 ENDIF
11458 .TableClose(lcAlias)
11459 .TableClose("tcCRPkey")
11460 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11461 .TableClose("tcOrders")
11462 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11463 ENDWITH
11464
11465 RELEASE voEiPcth
11466 SELECT (lnSelect)
11467 RETURN llRetVal
11468 ENDPROC
11469 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11470
11471 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11472 PROCEDURE ValidateLocation
11473 LPARAMETERS pcHeader
11474
11475 LOCAL llRetVal, lnOldSelect
11476
11477 llRetVal= true
11478 lnOldSelect= Select()
11479
11480 SELECT Distinct Location FROM (pcHeader) ;
11481 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11482
11483 SELECT __tmpLocation
11484 WITH This
11485 .cSQLTempTable=""
11486 IF .GenerateSQLTempTable('__tmpLocation')
11487 IF .PopulateSQLTempTable('__tmpLocation')
11488 IF !EMPTY(.cSQLTempTable)
11489 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11490 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11491 llRetVal = v_SqlExec(lcSQLString, "_Location")
11492 IF llRetVal
11493 SELECT _Location
11494 INDEX On Location TAG Location
11495 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11496 IF llRetVal
11497 SELECT (pcHeader)
11498 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11499 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11500 SET RELATION TO
11501 ENDIF
11502 ENDIF
11503 ENDIF
11504 ENDIF
11505 ENDIF
11506 ENDWITH
11507
11508 IF USED("__tmpLocation")
11509 USE IN __tmpLocation
11510 ENDIF
11511 IF USED("_Location")
11512 USE IN _Location
11513 ENDIF
11514
11515 Select(lnOldSelect)
11516 Return llRetVal
11517 ENDPROC
11518 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11519
11520 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11521 PROCEDURE GetFldsList
11522 LPARAMETERS lcpceipoTH, lczzeoprth
11523
11524 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11525
11526 lnOldSelect= Select()
11527
11528 *- get common fields from both aliases
11529 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11530
11531 *- get fields from source table to validate 850 filter bros
11532 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11533
11534 *- Retrieve all 850 filter bros
11535 lcSQLString = "Select OBJID from zzxsfxrf " +;
11536 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11537
11538 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11539
11540 SELECT _Filter
11541
11542 SCAN
11543 lcFld = UPPER(TRIM(objid))
11544 *- Check filter bros and add them in required fields list if valid
11545 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11546 lcFldsList = lcFldsList + ", " + lcFld
11547 ENDIF
11548 ENDSCAN
11549
11550 *- Adding additional fields used in 850 filter string and insert sql in calling method
11551 IF NOT "IS940I" $ UPPER(lcFldsList)
11552 lcFldsList = lcFldsList + ", IS940I"
11553 ENDIF
11554
11555 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11556 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11557 ENDIF
11558
11559 IF NOT "REQ_855" $ UPPER(lcFldsList)
11560 lcFldsList = lcFldsList + ", REQ_855"
11561 ENDIF
11562
11563 IF NOT "PROC_855" $ UPPER(lcFldsList)
11564 lcFldsList = lcFldsList + ", PROC_855"
11565 ENDIF
11566
11567 IF USED("_Filter")
11568 USE IN _Filter
11569 ENDIF
11570
11571 Select(lnOldSelect)
11572
11573 Return lcFldsList
11574
11575 ENDPROC
11576 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11577
11578 *============================================================
11579
11580 *--- TechRec 1082601 24-Dec-2014 jisingh ---
11581 PROCEDURE Validate860Qual
11582 LPARAMETERS pcHeader, pcDetail
11583 LOCAL llRetVal, lnSelect
11584
11585 lnSelect = SELECT()
11586 llRetVal = .SetRelation(pcHeader, "pkey", pcDetail, "fkey")
11587
11588 REPLACE ALL errs_msg_d WITH errs_msg_d + "Item has 860 change code (" + ALLTRIM(qual_860) + ")" + CRLF, ;
11589 errs_flg_d WITH "Y" FOR !EMPTY(qual_860) AND &pcHeader..po_purp = "05" IN (pcDetail)
11590 SET RELATION TO
11591
11592 SELECT (lnSelect)
11593 RETURN llRetVal
11594 ENDPROC
11595 *=== TechRec 1082601 24-Dec-2014 jisingh ===
11596
11597Enddefine