· 9 years ago · Dec 15, 2016, 08:40 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 *--------------------------------------------------------------------------
50
51 Procedure Init
52 Lparameters toHostProcess
53 LOCAL llRetVal
54 llRetVal = .t.
55 llRetVal = llRetVal and DODEFAULT(toHostProcess)
56
57 *--- TR 1052729 10-Mar-11 SK
58 This.oPopulateSqlTempTable = Null
59
60 *--- TR 1065271 27-Nov-2012 BNarayanan ---
61 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
62 *=== TR 1065271 27-Nov-2012 BNarayanan ===
63
64 this.GetImplodeSQL()
65
66 RETURN llRetVal
67 Endproc
68
69 *--------------------------------------------------------------------------
70
71 *-- [Main procedure]
72 Procedure PreValidation
73 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
74 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
75 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
76 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
77 Local llRetVal, lcSQLSelect, lcSQLOrder
78 llRetVal = .T.
79 PRIVATE vcLogName
80 vcLogName = this.cLogName
81 With This
82 .LogEntry("Resetting all error messages in transaction tables.")
83 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
84 vcLogName)
85 *--- TechRec 1005163 17-May-2004 GS ---
86 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
87 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
88 *=== TechRec 1005163 17-May-2004 GS ===
89
90 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
91 vcLogName)
92
93 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
94 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
95 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
96 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
97
98 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
99 vcLogName)
100 *--- TechRec 1005163 17-May-2004 GS ---
101 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
102 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
103 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
104 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
105 *=== TechRec 1005163 17-May-2004 GS ===
106 Endwith
107 Return llRetVal
108 Endproc
109
110 *--------------------------------------------------------------------------
111
112 * Clear all previous errors
113 Procedure ClearErrors
114 Lparameters pceipoTH, pceipoTD,;
115 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
116 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
117 Local llRetVal, lnOldSelect, laTables[2]
118 llRetVal = .T.
119 lnOldSelect = Select()
120 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
121 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
122 * we don't allow explosion happen again therefore cannot clearout division)
123 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
124 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
125 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
126 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
127 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
128 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
129 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
130 *=== 1010206 11/10/2005 Ilya.
131
132 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
133
134 *--- TR 1064141 3-Oct-2012 Goutam
135 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
136 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
137
138 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
139 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
140 *=== TR 1064141 3-Oct-2012 Goutam
141
142 *=== TR 1003801 - BD
143 *--- TechRec 1005163 17-May-2004 GS ---
144 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
145 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
146 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
147 *=== TechRec 1005163 17-May-2004 GS ===
148
149 *--- TechRec 1028745 05-Feb-2008 GSternik ---
150 If .oHostProcess.lHaveChrgs
151 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
152 Endif
153 *=== TechRec 1028745 05-Feb-2008 GSternik ===
154
155 *---TR 1008342 10-JAN-2005 RG
156 Replace All Pending_Flg With 'N' In (pceipoTH)
157 *===TR 1008342 10-JAN-2005 RG
158
159 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
160 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
161 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
162 IN (pceipoTH)
163 *=== TR 1073346 05-Sep-13 SK
164
165 *- 1041285 07/10/09 YIK
166 *- Populate force errors into error fields
167 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
168 FOR Errs_flg_fh = 'Y' ;
169 IN (pceipoTH)
170
171 *--- TR 1043191 23-Oct-2009 JK ---
172 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
173 *=== TR 1043191 23-Oct-2009 JK ===
174
175 Select(lnOldSelect)
176 Return llRetVal
177 Endproc
178
179 *--------------------------------------------------------------------------
180
181 ************************************************************************************
182 * Error check EDI headers
183 ************************************************************************************
184 Procedure CheckHeader
185 Lparameters pceipoTH, pceipoCR, pceipoTD
186 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
187
188 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
189 llRetVal = .T.
190 lnOldSelect = Select()
191 With This
192
193 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
194 *--- LOCAL MOD
195 *If llRetVal And .lRBACustSku
196 If llRetVal And .oHostProcess.lRBACustSku
197 .LogEntry("Resolve RBA Customer")
198 llRetVal= .ResolveBCCustomer(pceipoTH)
199 Else
200 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
201
202 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
203
204 *--- TR 1045965 09-MAR-2010 HNISAR
205*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
206 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
207 *=== TR 1045965 09-MAR-2010 HNISAR
208
209 If llRetVal
210 .LogEntry("Validating customer.")
211 llRetVal= .CheckCustomer(pceipoTH)
212 *- 01/29/02 YIK TAN 29056
213 If llRetVal
214 .LogEntry("Verifying Multiple customer.")
215 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
216 *= TAN 29056
217 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
218 Endif
219 Endif
220 Endif
221 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
222
223 *--- TR 1041542 NSD 7/22/09
224 IF llRetVal
225 .LogEntry("Resolving Register Number")
226 llRetVal = .ResolveRegisterNumber(pceipoTH)
227 ENDIF
228 *=== TR 1041542 NSD 7/22/09
229
230 If llRetVal
231 .LogEntry("Validating EDI store.")
232 llRetVal= .CheckStore(pceipoTH, pceipoCR)
233 If llRetVal
234 .LogEntry("Validating EDI center.")
235 llRetVal= .CheckDistribution(pceipoTH)
236 *- 1007452 10/22/04 YIK
237 *- Checking notes type
238 If llRetVal
239 .LogEntry("Validating Header Notes type.")
240 llRetVal= .CheckNoteType(pceipoTH)
241 Endif
242 *= 1007452
243 Endif
244 Endif
245
246 *--- TR 1022625 4-Mar-2007 TT
247 If llRetVal
248 .LogEntry("Checking for Terminations in PO_TYPE")
249 llRetVal= .CheckTerminationInPoType(pceipoTH)
250 Endif
251
252 *--- TR 1022625 4-Mar-2007 TT
253 *!* ENDIF
254 *!* ENDIF
255
256 *--- TR 1030441 17-Apr-2008 Goutam
257 If llRetVal
258 .LogEntry("Validating shipper code.")
259 llRetVal= .CheckShipper(pceipoTH)
260 Endif
261 *=== TR 1030441 17-Apr-2008 Goutam
262
263 *--- TechRec 1066487 05-Feb-2013 MANI. ---
264 IF llRetVal
265 .LogEntry("Validating Location.")
266 llRetVal= .ValidateLocation(pceipoTH)
267 Endif
268 *=== TechRec 1066487 05-Feb-2013 MANI. ===
269
270 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
271 If llRetVal
272 .LogEntry("Validating 855 Header status code.")
273 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
274 Endif
275 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
276
277 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
278 * TR 1037925 - As per Krishna/Shenba
279 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
280 * This is getting moved in TR 1037925
281*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
282*!* IF llRetVal
283*!* .LogEntry("Resolving Customer Shipper.")
284*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
285*!* ENDIF
286*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
287 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
288
289 Endwith
290 Select(lnOldSelect)
291 Return llRetVal
292 Endproc
293
294 *--------------------------------------------------------------------------------------
295
296 Function ResolveBCCustomer
297
298 Lparameters pceipoTH
299 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
300
301 llRetVal = True
302 lnSelect = Select()
303 With This
304 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
305 lcSQLString = " Select * From ZZXCSTCR "
306 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
307
308 If llRetVal
309 lcCursor = GetUniqueFileName()
310
311 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
312
313 Select lcCursor
314 lcErrs_Msg = " No matching record in Customer Store cross reference "
315
316 lnCnt = Recc()
317 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
318
319 Scan
320 lccustomer = Alltrim(rtl_cust)
321 lcDepartment = Alltrim(rtl_dept)
322 lcOrd_type = Alltrim(rtl_ord_type)
323
324 .LogEntry("Retail Customer: " + lccustomer )
325 .LogEntry("Retail Dept: " + lcDepartment)
326 .LogEntry("Retail order type: " + lcOrd_type)
327
328 Select tcCustcr
329 .LogEntry("Select: tcCustcr")
330
331 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
332 If Not Found()
333 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
334 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
335 IN (pceipoTH)
336 .LogEntry(lcErrs_Msg)
337 Else
338 lcBCCustomer = tcCustcr.customer
339 lcBCEDIStore = tcCustcr.Store
340
341 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
342
343 * TR 1019260 Added- , ord_type WITH '' ;
344
345 Replace customer With lcBCCustomer ;
346 EDI_STORE With lcBCEDIStore , ord_type With '' ;
347 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
348 IN (pceipoTH)
349
350 Endif
351 Endscan
352 .TableClose(lcCursor)
353 .TableClose("tcCustcr")
354
355 Endif
356 Endwith
357
358 Select (lnSelect)
359 Return llRetVal
360 Endfunc
361
362 *-----------------------------------------------------------------------------------
363
364 * TAN 29056 YIK
365 Procedure CheckForMultiCust
366 Lparameter pceipoTH, pceipoCR
367 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
368 llRetVal, llMultiCust
369 Private pcCustomer
370
371 lnSelect = Select()
372 Select (pceipoCR)
373 Scan For mult_cust = 'Y'
374
375 *--- TR 1031442 25-Jun-2008 Goutam
376 *llMultiCust = .T.
377 *--- TR 1031442 25-Jun-2008 Goutam
378
379 pcCustomer = customer
380 lcDiv = division
381 lcCursor = GetUniqueFileName()
382 *- YIK 01/30/02
383 *- We may have multiple POs/regions per customer in one tceipoth file
384 Select Distinct Region From (pceipoTH) ;
385 WHERE customer = pcCustomer ;
386 AND !Empty(Region) ;
387 INTO Cursor &lcCursor
388 Select (lcCursor)
389 Scan
390
391 *--- TR 1031442 25-Jun-2008 Goutam
392 llMultiCust = .T.
393 *--- TR 1031442 25-Jun-2008 Goutam
394
395 pcRegion = Region
396 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
397 Replace &pceipoTH..customer With lcNewCustID ;
398 FOR customer = pcCustomer And Region = pcRegion;
399 IN (pceipoTH)
400 Endscan
401 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
402 Select (pceipoCR)
403 Endscan
404 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
405 Select (lnSelect)
406 Return llRetVal
407 Endproc
408
409 *-----------------------------------------------------------------------------------
410
411 Procedure CheckStore
412 Lparameters pcHeader, pcControl
413 Local llRetVal, lnOldSelect
414 llRetVal= .T.
415 lnOldSelect= Select()
416
417 * 1st - group get store using cust,edi_store but not overwrite existing store
418 * users could change store in Trans Maint.
419 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
420 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
421 Select __TmpCursor
422 With This
423 .cSQLTempTable=""
424 If .GenerateSQLTempTable('__TmpCursor')
425 If .PopulateSQLTempTable('__TmpCursor')
426 If !Empty(.cSQLTempTable)
427 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
428 * also, populate center_code, consol_code if empty
429 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
430 " from zzxstorr s, " + .cSQLTempTable + " t " +;
431 "Where s.customer= t.customer and s.edi_store= t.edi_store"
432 llRetVal = v_SqlExec(lcSQLString, "_Storr")
433 If llRetVal
434 Select _Storr
435 Index On customer+EDI_STORE Tag CustStore
436 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
437 "customer+edi_store")
438 If llRetVal
439 Select (pcHeader)
440
441
442 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
443 * Otherwise we will not be able to resolve currency later and that will
444
445
446 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
447 * Confirm order(with store) for the same customer
448 * the Bulk order will have "Invalid Store" message.
449 * Only Scan for !Empty(edi_store)
450 Scan For !Empty(EDI_STORE)
451 Do Case
452 Case Empty(_Storr.customer)
453 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
454 Errs_flg_h With "Y" In (pcHeader)
455 Case _Storr.active_ok <> 'Y'
456 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
457 Errs_flg_h With "Y" In (pcHeader)
458 Otherwise
459 If Empty(Store) && don't want to overwrite previous data
460 Replace Store With _Storr.Store
461 Endif
462 *- YIK 1017307 07/18/06
463 *- Added AND EMPTY(edi_center)
464 *--- TR 1042564 14-Sep-2008 JK ---
465 * if the dts flag on the order is not Y, then populate.
466 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
467 *=== TR 1042564 14-Sep-2008 JK ===
468 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
469 Replace center_code With _Storr.center_code
470 Endif
471 If Empty(consol_code) And !Empty(_Storr.consol_code)
472 Replace consol_code With _Storr.consol_code
473 Endif
474 *--- TR 1042564 14-Sep-2008 JK ---
475 ENDIF
476 *=== TR 1042564 14-Sep-2008 JK ===
477 *== 1009508
478 Endcase
479
480 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
481
482 Endscan
483 Set Relation To
484 Use In _Storr
485 Endif
486 Endif
487 Endif
488 Endif
489 Endif
490 Endwith
491 If Used("__TmpCursor")
492 Use In __TmpCursor
493 Endif
494
495 * 2nd - validate store by cust,store
496 * Notes: cannot reuse the above server side cursor because have
497 * to resolve it to tran header local 1st before validate happen
498 Select Distinct customer, Store From (pcHeader) ;
499 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
500 Select __TmpCursor
501 With This
502 .cSQLTempTable=""
503 If .GenerateSQLTempTable('__TmpCursor')
504 If .PopulateSQLTempTable('__TmpCursor')
505 If !Empty(.cSQLTempTable)
506 lcSQLString= "Select s.customer, s.store " +;
507 " from zzxstorr s, " + .cSQLTempTable + " t " +;
508 "Where s.customer= t.customer and s.store= t.store"
509 llRetVal = v_SqlExec(lcSQLString, "_Storr")
510 If llRetVal
511 Select _Storr
512 Index On customer+Store Tag CustStore
513 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
514 "customer+store")
515 If llRetVal
516 Select (pcHeader)
517 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
518 * Confirm order(with store) for the same customer
519 * the Bulk order will have "Invalid Store" message.
520 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
521 * Don't have conf_type as "A" or "B" yet
522 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
523 *- assortment orders with no store.
524
525 *--- TR1055827 NSD/FGCjr
526 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
527 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))
528 *=== TR1055827
529 If Empty(_Storr.customer)
530 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
531 Errs_flg_h With "Y" In (pcHeader)
532 Endif
533 Endscan
534 Set Relation To
535 Use In _Storr
536 Endif
537 Endif
538 Endif
539 Endif
540 Endif
541 Endwith
542 If Used("__TmpCursor")
543 Use In __TmpCursor
544 Endif
545
546 If Used("_Storr")
547 Use In _Storr
548 Endif
549
550 Select(lnOldSelect)
551 Return llRetVal
552 Endproc
553
554 *------------------------------------------------------------------------------------------
555
556 ************************************************************************************
557 * Validate EDI Distribution Center
558 * ATS# 2757 PL 06/09/99- validate against edi_center
559 * use edi_center in tran header for validation, when found
560 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
561 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
562 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
563 ************************************************************************************
564 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
565 * 1. Select Distinct customer, distribution center from work header.
566 * 2. Check for valid distribution center. If faile the check update all headers for
567 * the same customer, distribution center with "Invalid Store code." and
568 * Errs_Flg with "Y"
569 * Return: True= All pass validation
570 * False= If one of them fail the check
571 ************************************************************************************
572 Procedure CheckDistribution
573 Lparameters pceipoTH
574 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
575 llRetVal = .T.
576 lnOldSelect = Select()
577
578 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
579 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
580 Into Cursor CntrList
581 Select CntrList
582 If This.lUserInterface
583 * Init Thermometer
584 This.UpdateThermoCaption("Validating Distribution Center(s)...")
585 * TAN 31891 - JAZ - 5/20/02
586 * This.InitThermo(RECC('CntrList'))
587 This.InitThermo(Reccount('CntrList'))
588 * End TAN 31891 - JAZ - 5/20/02
589 l_nThermoCnt = 0
590 Endif
591 Scan
592 If This.lUserInterface
593 * Advance progress bar, if we're using one.
594 l_nThermoCnt = l_nThermoCnt + 1
595 This.AdvanceThermo(l_nThermoCnt)
596 Endif
597 * Empty(center_code) resolve using edi_center
598 If Empty(center_code)
599 lcErrs_Msg= ""
600 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
601 lcErrs_Msg= lcErrs_Msg + CRLF
602 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
603 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
604 IN (pceipoTH)
605 Else
606 * replace center_code with shipthru.center_code when found edi_center
607 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
608 * COMMENT OUT replace ship_dc with "D" also.
609 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
610 * Do not update center code unless dts_flag <> Y
611 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
612 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
613 IN (pceipoTH)
614
615 Endif
616 Else
617 * user may overwrite with wrong center_code, validate distribution center
618 lcErrs_Msg= ""
619 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
620 lcErrs_Msg= lcErrs_Msg + CRLF
621 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
622 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
623 IN (pceipoTH)
624 Endif
625 Endif
626
627 Endscan
628 Use In CntrList
629
630 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
631 * also, populate center_code, consol_code if empty
632 * populate Ship_dc base on center/consol_code
633 Select (pceipoTH)
634 Scan
635 lcShip_dc = ""
636 *- 1009508 03/16/05
637 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
638 *-- DO CASE
639 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
640 *-- lcShip_dc = "B"
641 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
642 *-- lcShip_dc = "D"
643 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
644 *-- lcShip_dc = "C"
645 *-- ENDCASE
646
647 If !Empty(center_code) Or !Empty(consol_code)
648 Do Case
649 Case !Empty(center_code) And !Empty(consol_code)
650 lcShip_dc = "B"
651 Case !Empty(center_code) And Empty(consol_code)
652 lcShip_dc = "D"
653 Case Empty(center_code) And !Empty(consol_code)
654 lcShip_dc = "C"
655 Endcase
656 *= 1009508 YIK
657 If !Empty(lcShip_dc)
658 Replace ship_dc With lcShip_dc In (pceipoTH)
659 Endif
660 Endif
661 Endscan
662
663 If This.lUserInterface
664 * Reset Thermometer
665 This.ResetThermo()
666 Endif
667
668 If Used("CntrList")
669 Use In CntrList
670 Endif
671 If Used("tcDistr")
672 Use In tcDistr
673 Endif
674 Select(lnOldSelect)
675 Return llRetVal
676 Endproc
677
678 *---------------------------------------------------------------------------------
679
680 Procedure CheckNoteType
681 Lparameters tcEiPOth
682 Local llRetVal, lcNotes, laNotes
683 llRetVal = .T.
684 Select (tcEiPOth)
685 Scan For !Empty(notes)
686 lcNotes = notes
687 Declare laNotes[2]
688 laNotes = ""
689 If At("|", lcNotes) > 0 && has note_type
690 *- 1030497 02/29/08 TT
691 *--StringToArray(lcNotes, @laNotes, "|")
692 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
693 *- 1030497 02/29/08 TT
694 lnNotes = Alen(laNotes)/2
695 For lnCnt = 1 To lnNotes
696 If !vl_notyp(laNotes[2*lnCnt - 1])
697 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
698 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
699 Endif
700 Endfor
701 Endif
702 Endscan
703 Return llRetVal
704 Endproc
705 *---------------------------------------------------------------------------------
706
707 *--- TR 1022625 4-Mar-2007 TT
708 Function CheckTerminationInPoType
709 Lparameters pceipoTH
710 LOCAL llRetVal, lnOldSelect
711 lnOldSelect = SELECT()
712 llRetVal = .t.
713 Local lnLastOrder
714 Select (pceipoTH)
715 lnLastOrder = Order()
716 Set Order To Tag po_type
717 If Seek("TR", pceipoTH, "po_type")
718 Scan While po_type = 'TR'
719 Replace Errs_msg_H With Errs_msg_H + ;
720 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
721 Errs_flg_h With "Y" In (pceipoTH)
722 Endscan
723 Endif
724 Set Order To lnLastOrder
725 SELECT(lnOldSelect)
726 RETURN llRetVal
727 Endfunc
728 *--- TR 1022625 4-Mar-2007 TT
729
730 *---------------------------------------------------------------------------------
731
732 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
733 PROCEDURE Validate855Status
734 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
735
736 Local llRetVal, lnOldSelect, lcSourceFilter
737 llRetVal= true
738 lnOldSelect= Select()
739
740 IF pcHeaderDetail = 'H'
741 SELECT Distinct status_855 FROM (pcHeader) ;
742 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
743 lcSourceFilter = " s.source = 'BAK02'"
744 ELSE
745 SELECT DISTINCT d.status_855 ;
746 FROM (pcDetail) d ;
747 JOIN (pcHeader) h ;
748 ON h.pkey = d.fkey ;
749 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
750 INTO CURSOR __tmp855Status
751 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
752 ENDIF
753
754 SELECT __tmp855Status
755 WITH This
756 .cSQLTempTable=""
757 IF .GenerateSQLTempTable('__tmp855Status')
758 IF .PopulateSQLTempTable('__tmp855Status')
759 IF !EMPTY(.cSQLTempTable)
760
761 lcSQLString= "Select s.status_855 from " +;
762 " zzeopakr s, " + .cSQLTempTable + " t " +;
763 "Where s.status_855 = t.status_855 and " + lcSourceFilter
764
765 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
766 IF llRetVal
767 SELECT _Ststus855
768 INDEX On status_855 TAG status_855
769 IF pcHeaderDetail = 'H'
770 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
771 ELSE
772 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
773 ENDIF
774
775 IF llRetVal
776 IF pcHeaderDetail = 'H'
777 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
778 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
779 ELSE
780 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
781 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) In (pcDetail)
782
783 * mark headers errors here as the Run855Process which runs next will rely on header errors.
784 SELECT (pcDetail)
785 SCAN FOR errs_flg_d = 'Y'
786 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
787 AND EVALUATE(pcHeader+'.req_855') = 'R'
788 ENDSCAN
789 ENDIF
790
791 SET RELATION TO
792 ENDIF
793 ENDIF
794 ENDIF
795 ENDIF
796 ENDIF
797 ENDWITH
798
799 IF USED("__tmp855Status")
800 USE IN __tmp855Status
801 ENDIF
802 IF USED("_Ststus855")
803 USE IN _Ststus855
804 ENDIF
805
806 Select(lnOldSelect)
807 Return llRetVal
808 ENDPROC
809 *=== TR 1074251 03-Jan-2014 Goutam
810
811 *---------------------------------------------------------------------------------
812
813 *--- TR 1030441 17-Apr-2008 Goutam
814 Procedure CheckShipper
815 LPARAMETERS pcHeader
816 Local llRetVal, lnOldSelect
817 llRetVal= true
818 lnOldSelect= Select()
819
820 SELECT Distinct shipper FROM (pcHeader) ;
821 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
822
823 SELECT __tmpShipper
824 WITH This
825 .cSQLTempTable=""
826 IF .GenerateSQLTempTable('__tmpShipper')
827 IF .PopulateSQLTempTable('__tmpShipper')
828 IF !EMPTY(.cSQLTempTable)
829 lcSQLString= "Select s.shipper from " +;
830 " zzxshipr s, " + .cSQLTempTable + " t " +;
831 "Where s.shipper= t.shipper"
832 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
833 IF llRetVal
834 SELECT _Shiper
835 INDEX On shipper TAG Shipper
836 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
837 IF llRetVal
838 SELECT (pcHeader)
839 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
840 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
841 SET RELATION TO
842 ENDIF
843 ENDIF
844 ENDIF
845 ENDIF
846 ENDIF
847 ENDWITH
848
849 IF USED("__tmpShipper")
850 USE IN __tmpShipper
851 ENDIF
852 IF USED("_Shiper")
853 USE IN _Shiper
854 ENDIF
855
856 Select(lnOldSelect)
857 Return llRetVal
858 Endproc
859 *=== TR 1030441 17-Apr-2008 Goutam
860
861 *---------------------------------------------------------------------------------
862
863 ************************************************************************************
864 * Error check all raw EDI details
865 ************************************************************************************
866 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
867 * Move codes to CheckUPC() and CheckSKU()
868 * Add:ResolveCustomerLabel()
869 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
870 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
871 * [div,sty,col,lbl,dim,size] allow or not
872 *
873 Procedure CheckDetail
874 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
875 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
876 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
877 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
878 Local llRetVal, lnOldSelect
879 llRetVal = .T.
880 lnOldSelect = Select()
881 With This
882 *--- TechRec 1048792 17-Dec-2010 jisingh ---
883 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
884 *=== TechRec 1048792 17-Dec-2010 jisingh ===
885
886 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
887 *--- TR 1019697 NH
888 .LogEntry("Cascading Customer To Detail.")
889 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
890 .LogEntry("Cascading Customer To SLN.")
891 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
892 *=== TR 1019697 NH
893 *=== TechRec 1048667 03-May-2011 GSternik ===
894
895
896 *--- TechRec 1024522 18-Sep-2007 GSternik ---
897 *--- LOCAL MOD
898 *If This.lHaveSLN
899 If This.oHostProcess.lHaveSLN
900 .LogEntry("Resolving SLNs/Prepack Style.")
901 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
902 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
903 EndIf
904 *=== TechRec 1024522 18-Sep-2007 GSternik ===
905
906 .LogEntry("Resolving style using UPC.")
907 *--- TechRec 1005163 17-May-2004 GS ---
908 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
909 *--- TR 1019697 NH
910 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
911 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
912*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
913 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
914 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
915
916 *--- TR 1036917 04-Feb-2009 Partha ---
917 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
918 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
919
920 *=== TR 1036917 04-Feb-2009 Partha ===
921
922 *=== TR 1019697 NH
923 *=== TechRec 1005163 17-May-2004 GS ===
924 *--- TR 1023892 NH
925 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
926 *=== TR 1023892 NH
927
928 *--- TR 1044885 13-JAN-2010 BR Moved from above
929 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
930
931 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
932 *--- TechRec 1005163 17-May-2004 GS ---
933 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
934 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
935 *=== TechRec 1005163 17-May-2004 GS ===
936 *= 39222
937
938 *- TR 1003801 - 03/25/04 BD - Resolve EAN
939 .LogEntry("Resolving style using EAN.")
940
941 *--- TechRec 1005163 17-May-2004 GS ---
942 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
943 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
944 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
945 *=== TR 1061652 05/18/12 ATHIRUNAVU
946
947 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
948 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
949 *--- TR 1035223 NH
950 .LogEntry("Setting Skip SLN Check flag.")
951 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
952 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
953 *=== TR 1035223 NH
954
955 *--- TR 1053820 26-May-2011 Goutam
956 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
957 .LogEntry("Generate Customer SKU (Style_ColorSize).")
958 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
959 ENDIF
960 *=== TR 1053820 26-May-2011 Goutam
961
962 .LogEntry("Confirming SKU for UPC/EAN.")
963 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
964 *=== TechRec 1005163 17-May-2004 GS ===
965 *=== TR 1003801
966
967 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
968 If llRetVal And .oHostProcess.lRBACustSku
969 .LogEntry("Verifying Customer SKU.")
970 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
971 Endif
972 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
973
974 .LogEntry("Resolving style using SKU.")
975 *--- TechRec 1005163 17-May-2004 GS ---
976 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
977
978 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
979 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
980 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
981 *=== TR 1010097 07/27/05 TK
982 *=== TechRec 1005163 17-May-2004 GS ===
983
984 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
985 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
986 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
987
988 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
989 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
990 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
991
992 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
993 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
994 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
995
996 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
997 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
998 *=== TR 1040432 MAY-20-2009 BR
999
1000 *--- TR 1013007 NH
1001 *--- check if req_855 if 'R' and status flag is empty then set error flag
1002 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1003 *=== TR 1013007 NH
1004
1005 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1006 If llRetVal
1007 .LogEntry("Validating detail 855 status code.")
1008 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1009 Endif
1010 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1011
1012 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1013 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1014 vcLogName)
1015
1016 *--- TR 1013007 NH 2005-10-11
1017 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1018 If .lSend855
1019 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1020
1021 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1022 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1023 *=== TR 1040432 MAY-20-2009 BR
1024
1025 *--- Error out IPO records which has no corresponding OPRCR control ref
1026 *--- IPO and OPRCR link is customer, division, oVnd_Key
1027 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1028 *=== TR 1034481 NH
1029 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1030 *--- If req_855 = 'R'
1031 *--- then run process 855
1032 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1033 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1034 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1035 Endif
1036 *=== TR 1013007 NH
1037
1038 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1039 .LogEntry("Resolving Is 860.")
1040 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1041
1042 .LogEntry("Creating 860 Transaction records.")
1043 llRetVal = llRetVal And .Create860TM(pceipoTH)
1044 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1045
1046 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1047 .LogEntry("Resolving Multi-UPCs.")
1048 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1049 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1050
1051 .LogEntry("Resolving range style.")
1052 *--- TR 1023892 NH -
1053 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1054 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1055 *=== TR 1023892 NH
1056
1057 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1058 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1059 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1060 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1061
1062 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1063 vcLogName)
1064 *- 36262 6/11/03 YIK
1065 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1066 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1067 vcLogName)
1068 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1069 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1070 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1071 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1072 * === TR 1046519 7/26/10 CM
1073
1074 *=
1075
1076 *- 1044723 01/06/10 YIK
1077 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1078 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1079
1080 *- TR 1042748 09/23/09 YIK
1081 *- Call it here to populate Impl_ok flag (3d parameter).
1082 *- MOved it to clsipopr, so need to call with .oHostProcess
1083 *- This method will be called again after implosion. Ok per JRoth
1084 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1085
1086
1087 * 3/25/02 30854 - Implosion single prepack
1088 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1089 vcLogName)
1090 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
1091
1092 *- 1006607 09/01/04 YIK
1093 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1094 vcLogName)
1095 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1096 *=========
1097
1098 *--- TechRec 1005163 17-May-2004 GS ---
1099 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1100 If .oHostProcess.lHaveSLN
1101 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1102
1103 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1104*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1105*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1106 *=== TR 1049029 27-Aug-2010 Partha ===
1107
1108 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1109
1110 .LogEntry("Validating SLN vs. Prepack.")
1111 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1112 Endif
1113 *=== TechRec 1005163 17-May-2004 GS ===
1114
1115 *--- TR 1011644 23-AUG-2005 KA
1116 *If this.oResolvePrepack.lMultipack
1117 If this.lMultipack
1118 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1119 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1120 Endif
1121 *=== TR 1011644 23-AUG-2005 KA
1122
1123 .LogMajorStage("Resolving and getting default fields.")
1124 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1125 .LogEntry("Resolving customer label.")
1126 *--- TechRec 1005163 18-May-2004 GS ---
1127 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1128 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1129 *=== TechRec 1005163 18-May-2004 GS ===
1130
1131 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1132 vcLogName)
1133
1134 .LogEntry("Validating style.")
1135 *--- TechRec 1005163 21-Jun-2004 GS ---
1136 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1137 *--- TechRec 1016817 04-May-2006 GS ---
1138 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1139 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1140 *=== TechRec 1016817 04-May-2006 GS ===
1141 *=== TechRec 1005163 21-Jun-2004 GS ===
1142
1143 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1144 If This.oHostProcess.lHaveChrgs
1145 .LogEntry("Validating Charges.")
1146 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1147 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1148 EndIf
1149 *-- This is not needed anymore:
1150 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1151 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1152 * vcLogName)
1153 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1154
1155 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1156 *!* .LogEntry("Validating MinMultiple.")
1157 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1158 *===TR 1012978 VK 23/11/05
1159
1160 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1161 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1162 vcLogName)
1163 .LogEntry("Converting inbound UOM.")
1164 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1165
1166 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1167 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1168 lcSqlString = " UPDATE h SET " + ;
1169 " ReResvStyle = c.ReResvStyle " + ;
1170 " FROM (pcEipoTH) h " + ;
1171 " JOIN (pcEipoCR) c " + ;
1172 " ON h.division = c.division " + ;
1173 " AND h.customer = c.customer " + ;
1174 " WHERE h.ReResvStyle = '' "
1175
1176 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1177 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1178 EndWith
1179
1180 Select(lnOldSelect)
1181 Return llRetVal
1182 ENDPROC
1183
1184 *----------------------------------------------------------------------------------------
1185 * TR 1037976 JAN-22-2008 BR
1186 *----------------------------------------------------------------------------------------
1187 Procedure UpdtHeaderDivs
1188 Lparameters pceipoTH, pceipoTD
1189 Local llRetVal, lnOldSelect, llUpdate
1190 llRetVal = .T.
1191 lnOldSelect = Select()
1192
1193 .LogEntry("Resolving header division.")
1194 *- 1005164 07/12/04 YIK
1195 *- Removed ..And Empty(Errs_Msg_D)
1196 Select Distinct fkey, division From (pceipoTD) ;
1197 WHERE !Empty(division) Into Cursor tmpCurs
1198 Select tmpCurs
1199 If This.lUserInterface
1200 * Init Thermometer
1201 * TAN 31891 - JAZ - 5/20/02
1202 * This.InitThermo(RECC('tmpCurs'))
1203 This.InitThermo(Reccount('tmpCurs'))
1204 * End TAN 31891 - JAZ - 5/20/02
1205 l_nThermoCnt = 0
1206 Endif
1207 Scan
1208 If This.lUserInterface
1209 * Advance progress bar, if we're using one.
1210 l_nThermoCnt = l_nThermoCnt + 1
1211 This.AdvanceThermo(l_nThermoCnt)
1212 Endif
1213 Select (pceipoTH)
1214
1215 * --- TR 1022896 NSD 05-10-07
1216 * Convert LOCATE to SEEK
1217 *LOCATE FOR pkey = tmpCurs.fkey
1218 *IF FOUND()
1219 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1220 * === TR 1022896 NSD 05-10-07
1221
1222 Replace division With tmpCurs.division In (pceipoTH)
1223 Endif
1224 Endscan
1225 Use In tmpCurs
1226
1227 If This.lUserInterface
1228 * Reset Thermometer
1229 This.ResetThermo()
1230 Endif
1231 Select(lnOldSelect)
1232 Return llRetVal
1233 ENDPROC
1234 *----------------------------------------------------------------------------------------
1235 * TR 1037976 JAN-22-2008 BR
1236 *----------------------------------------------------------------------------------------
1237
1238 *---------------------------------------------------------------------------------
1239
1240 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1241 ************************************************************************************
1242 * Resolve BC SKU from SLN records and create customer style data.
1243 ************************************************************************************
1244 Procedure ResolveStyleFromSLN
1245 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1246 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1247 *--- TR 1035491 4-Nov-2008 Goutam
1248 *--- This entire function splitted into two different part ;
1249 1. ResolveBCSkuFromSLN ;
1250 2. ResolvePPKSkuAndUpdateDetail
1251
1252 Local llRetVal, lnOldSelect
1253 lnOldSelect = Select()
1254 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1255 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1256
1257
1258 Select(lnOldSelect)
1259 Return llRetVal
1260 Endproc
1261
1262 *----------------------------------------------------------------------------------
1263 ************************************************************************************
1264 * Validate UPC for all details
1265 ************************************************************************************
1266 Procedure CheckUpc
1267 Lparameters pceipoTH, pceipoTD,;
1268 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1269
1270 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1271 * Added Parameter pceipocr
1272 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1273
1274 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1275 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1276 lnSize_desc, llSLN
1277
1278 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1279 LOCAL lcIs_upcsku
1280 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1281
1282 llRetVal = .T.
1283 lcErrs_Msg= ""
1284 lnOldSelect = Select()
1285
1286 * cannot check for UPC if customer is empty
1287 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1288 * on Cust SKU or UPC.
1289 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1290
1291 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1292 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1293 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1294
1295 *--- TechRec 1005163 17-May-2004 GS ---
1296 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1297 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1298 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1299 *Order by h.customer, d.upc Into Cursor tmpCurs
1300
1301 *---- TR 1024667 NSD 5/31/07
1302 * If sizebucket = 0 then re-resolve.
1303
1304 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1305 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1306*!* If This.lHaveSLN
1307*!* Select h.customer,;
1308*!* d.upc,;
1309*!* d.pkey,;
1310*!* (pceipoTD) As Src;
1311*!* FROM (pceipoTH) h ;
1312*!* JOIN (pceipoTD) d ;
1313*!* ON h.pkey = d.fkey ;
1314*!* WHERE !Empty(d.upc) ;
1315*!* AND !Empty(h.customer) ;
1316*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1317*!* UNION All ;
1318*!* SELECT h.customer,;
1319*!* s.SLN_UPC As upc,;
1320*!* s.pkey,;
1321*!* (pceipoTS) As Src ;
1322*!* FROM (pceipoTH) h ;
1323*!* JOIN (pceipoTD) d ;
1324*!* ON d.fkey = h.pkey ;
1325*!* JOIN (pceipoTS) s ;
1326*!* ON s.fkey = d.pkey ;
1327*!* WHERE !Empty(s.SLN_UPC) ;
1328*!* AND !Empty(h.customer) ;
1329*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1330*!* ORDER By 1, 2 ;
1331*!* INTO Cursor tmpCurs
1332*!* Else
1333*!* Select h.Customer,;
1334*!* d.UPC,;
1335*!* d.PKey,;
1336*!* (pceipoTD) As Src;
1337*!* FROM (pceipoTH) h ;
1338*!* JOIN (pceipoTD) d ;
1339*!* ON h.pkey = d.fkey ;
1340*!* WHERE !Empty(d.upc) ;
1341*!* AND !Empty(h.customer) ;
1342*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1343*!* ORDER By 1, 2;
1344*!* INTO Cursor tmpCurs
1345*!* Endif
1346 *=== TechRec 1005163 17-May-2004 GS ===
1347
1348 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1349 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1350 FROM (pceipocr) ;
1351 GROUP BY customer ;
1352 INTO CURSOR __ResvCustSKU
1353 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1354
1355 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1356*!* select h.Customer;
1357*!* , d.UPC;
1358*!* , d.PKey;
1359*!* from (pceipoTH) h;
1360*!* join (pceipoTD) d;
1361*!* on h.PKey = d.FKey;
1362*!* where !Empty(d.UPC);
1363*!* and !Empty(h.Customer);
1364*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1365*!* order by 1, 2;
1366*!* into Cursor tmpCurs ReadWrite
1367
1368 *- 1035314 08/28/08 YIK
1369 *- Added r.ResvCustSKU to the list of fields
1370 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1371
1372.oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1373
1374 Select h.customer;
1375 , d.upc;
1376 , d.pkey;
1377 ,(pceipoTD) AS Src;
1378 ,r.ResvCustSKU ;
1379 from (pceipoTH) h;
1380 join (pceipoTD) d;
1381 on h.pkey = d.fkey;
1382 JOIN __ResvCustSKU r ;
1383 ON r.Customer = H.Customer ;
1384 where !Empty(d.upc);
1385 and !Empty(h.customer);
1386 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1387 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1388 order By 1, 2;
1389 into Cursor tmpCurs Readwrite
1390 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1391 *= 08/12/08 YIK TR 1035314
1392*=== TechRec 1024522 25-Sep-2007 GSternik ===
1393
1394*-1040686
1395 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1396 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1397 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1398 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1399 IF llRetVal
1400 .PopulateSQLTempTable("tcCustUpc")
1401 ENDIF
1402
1403 llRetVal = llRetVal AND v_sqlexec(;
1404 "SELECT x.upc,d.* "+;
1405 " FROM zzxcstdr d"+ ;
1406 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1407 " JOIN " + this.cSQLTempTable + " x " + ;
1408 " ON d.customer = x.customer " +;
1409 " AND d.cust_style = x.upc " + ;
1410 " WHERE h.IB_resolv = 'Y'" + ;
1411 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1412 SELECT tmpCstdr_upc
1413 INDEX on customer + upc TAG cust_upc
1414
1415
1416 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1417 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1418 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1419 IF llRetVal
1420 .PopulateSQLTempTable("tcDistUpc")
1421 ENDIF
1422
1423 llRetVal = llRetVal AND v_sqlexec(;
1424 "SELECT x.upc,d.* "+;
1425 " FROM zzeupcnr d"+ ;
1426 " JOIN " + this.cSQLTempTable + " x " + ;
1427 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1428 SELECT tmpUpcnr
1429 INDEX on upc TAG upc
1430 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1431*-1040686
1432
1433 lcOldCust = ""
1434 lcOldItem = ""
1435 Select tmpCurs
1436 If This.lUserInterface
1437 * Init Thermometer
1438 This.UpdateThermoCaption("Validating UPC(s)...")
1439 * TAN 31891 - JAZ - 5/20/02
1440 * This.InitThermo(RECC('tmpCurs'))
1441 This.InitThermo(RecCount('tmpCurs'))
1442 * End TAN 31891 - JAZ - 5/20/02
1443 l_nThermoCnt = 0
1444 EndIf
1445
1446 Scan
1447 If This.lUserInterface
1448 * Advance progress bar, if we're using one.
1449 l_nThermoCnt = l_nThermoCnt + 1
1450 This.AdvanceThermo(l_nThermoCnt)
1451 Endif
1452 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1453 lcErrs_Msg = ""
1454 lcOldCust = tmpCurs.customer
1455 lcOldItem = tmpCurs.upc
1456 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1457 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1458
1459 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1460 lcIs_upcsku = ' '
1461 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1462
1463 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1464 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1465
1466 *- 1040686 - tmpCstdr_upc...
1467 lcDivision = tmpCstdr_upc.division
1468 lcStyle = tmpCstdr_upc.Style
1469 lcColor_code = tmpCstdr_upc.color_code
1470 lcLbl_code = tmpCstdr_upc.lbl_code
1471 lcDimension = tmpCstdr_upc.Dimension
1472 lnSizeBucket = tmpCstdr_upc.size_bk
1473 lnSize_desc = tmpCstdr_upc.size_desc
1474 *- 1040686 - tmpCstdr_upc...
1475
1476 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1477 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1478 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1479
1480 ELSE
1481 *- 08/12/08 YIK TR 1035314
1482 IF ResvCustSKU <> 'Y'
1483 lcErrs_Msg = ""
1484 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1485 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1486 lcDivision = tmpUpcnr.division
1487 lcStyle = tmpUpcnr.Style
1488 lcColor_code = tmpUpcnr.color_code
1489 lcLbl_code = tmpUpcnr.lbl_code
1490 lcDimension = tmpUpcnr.Dimension
1491 lnSizeBucket = tmpUpcnr.sizebucket
1492 lnSize_desc = tmpUpcnr.size_desc
1493 Else
1494 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1495 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1496 Store 0 To lnSizeBucket
1497 Endif
1498 *- 08/12/08 YIK TR 1035314
1499 ELSE
1500 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1501 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1502 STORE 0 TO lnSizeBucket
1503 ENDIF
1504 *= 08/12/08 YIK TR 1035314
1505 Endif
1506 Endif && level break
1507
1508 *--- TechRec 1005163 17-May-2004 GS ---
1509 *Select (pceipoTD)
1510*!* llSLN = (tmpCurs.Src = pceipoTS)
1511*!* If llSLN
1512*!* Select (pceipoTS)
1513*!* Else
1514 Select (pceipoTD)
1515*!* Endif
1516 *=== TechRec 1005163 17-May-2004 GS ===
1517 *- 1010682 04/25/05 YIK
1518 *- Locate For pkey = tmpCurs.pkey
1519 lnWorkArea = Select()
1520 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1521 Scatter Name loEiPOtd Memo
1522 If !Empty(lcErrs_Msg)
1523*!* *--- TechRec 1005163 17-May-2004 GS ---
1524*!* If llSLN
1525*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1526*!* loEiPOtd.Errs_Flg_S = "Y"
1527*!* Else
1528*!* *=== TechRec 1005163 17-May-2004 GS ===
1529 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1530 loEiPOtd.Errs_Flg_D = "Y"
1531*!* Endif
1532 Endif
1533 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1534 loEiPOtd.Division = lcDivision
1535 loEiPOtd.Style = lcStyle
1536 loEiPOtd.Color_Code = lcColor_code
1537 loEiPOtd.Lbl_Code = lcLbl_code
1538 loEiPOtd.Dimension = lcDimension
1539 loEiPOtd.SizeBucket = lnSizeBucket
1540 loEiPOtd.Size_Desc = lnSize_desc
1541
1542 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1543 IF !EMPTY(lcIs_upcsku)
1544 loEiPOtd.Is_upcsku = lcIs_upcsku
1545 ENDIF
1546 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1547
1548 *--- TR 1019697 NH : clear rang style when bc style is set
1549 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1550 loEiPOtd.rng_style = ''
1551 loEiPOtd.rng_color = ''
1552 loEiPOtd.rng_lbl = ''
1553 loEiPOtd.rng_pack = ''
1554 Endif
1555 *=== TR 1019697 NH
1556 Endif
1557
1558 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1559 * only replace our SKU when no range style explosion happen
1560 *--- TechRec 1005163 17-May-2004 GS ---
1561 *If empty(&pceipoTD..rng_style)
1562 * Replace division With loEiPOtd.division, ;
1563 * style With loEiPOtd.style, ;
1564 * color_code With loEiPOtd.color_code, ;
1565 * lbl_code With loEiPOtd.lbl_code, ;
1566 * dimension With loEiPOtd.dimension, ;
1567 * sizebucket With loEiPOtd.sizebucket, ;
1568 * size_desc With loEiPOtd.size_desc, ;
1569 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1570 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1571 * In (pceipoTD)
1572 *Endif
1573 *- 1009508 3/16/05 YIK
1574 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1575 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1576 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1577 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1578 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1579
1580 Gather Name loEiPOtd Memo
1581 Endif
1582 *=== TechRec 1005163 17-May-2004 GS ===
1583
1584 Endscan
1585 Use In tmpCurs
1586
1587 If This.lUserInterface
1588 * Reset Thermometer
1589 This.ResetThermo()
1590 Endif
1591
1592 If Used("tmpCstdr")
1593 Use In tmpCstdr
1594 Endif
1595 If Used("tmpUpcnr")
1596 Use In tmpUpcnr
1597 ENDIF
1598
1599 *- 1040686
1600 USE IN SELECT("tcCustUpc")
1601 USE IN SELECT("tmpCstdr_upc")
1602 USE IN SELECT("tcDistUpc")
1603 USE IN SELECT("tmpUpcnr")
1604 *- 1040686
1605
1606 Select(lnOldSelect)
1607 Return llRetVal
1608 Endproc
1609
1610 *----------------------------------------------------------------------------------
1611
1612 *--- TR 1035223 NH
1613 PROCEDURE ClearErrorsForSkipSlnCheck
1614 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1615
1616 LOCAL llRetVal, lnOldSelect
1617 lnOldSelect = SELECT()
1618 llRetVal = .t.
1619
1620 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1621 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1622
1623 *--- TR 1038353 NH
1624 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'
1625 *=== TR 1038353 NH
1626
1627 Select(lnOldSelect)
1628 Return llRetVal
1629 Endproc
1630
1631 *----------------------------------------------------------------------------------
1632
1633 PROCEDURE SetupSkipSLNCheck
1634 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1635
1636 LOCAL lnOldSelect, llRetVal
1637 lnOldSelect = SELECT()
1638 llRetVal = .t.
1639 *--- take division from trans detail
1640 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1641 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1642 inner join (pceipoCR) r on r.customer = th.customer AND r.division = td.division ;
1643 WHERE th.customer > '' AND td.division > ''
1644
1645 *--- Setup in pceipoTS
1646 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1647 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1648
1649 Select(lnOldSelect)
1650 Return llRetVal
1651
1652 Endproc
1653 *=== TR 1035223 NH
1654
1655 *----------------------------------------------------------------------------------
1656
1657 *--- TR 1023892 NH
1658 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1659 PROCEDURE Populate_Cust_lbl
1660 LPARAMETERS pcTransHeader, pcTransDetail
1661 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1662 llRetVal = .t.
1663 lnOldSelect = SELECT()
1664 lcSQLString = ""
1665 lcFkeySku = ""
1666 lcCust_lbl = ""
1667
1668
1669 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl ;
1670 FROM (pcTransHeader) h, (pcTransDetail) d ;
1671 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1672 and d.lbl_code = '' ;
1673 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1674
1675 IF RECCOUNT("__TmpCursor") = 0
1676 *-- no valid style to process
1677 this.LogEntry("No detail record found to populate customer label.")
1678 SELECT(lnOldSelect)
1679 RETURN llRetVal
1680 ENDIF
1681
1682 WITH this
1683 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1684 .cSQLTempTable = ""
1685 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1686 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1687 lcCustSku = "#CustSku" + SYS(2015)
1688
1689 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1690 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1691 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1692 *--- Used sc.Division instead of c.Division.
1693 TEXT TO lcSQLString NOSHOW
1694 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1695 case when d.orig_lbl <> '' then d.orig_lbl
1696 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1697 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1698 else d.lbl_code end as cust_lbl
1699 FROM #Temp d INNER JOIN zzeipocr_expl c on d.customer = c.customer and d.division = c.division
1700 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1701 AND sc.style = d.style AND sc.color_code = d.color_code
1702 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1703 ENDTEXT
1704
1705 lcCustLbl = SYS(2015)
1706 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1707 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1708 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1709 IF llRetVal
1710 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1711 SELECT(pcTransDetail)
1712 lcZzeipotd_order = ORDER()
1713 SET ORDER TO fkeySku
1714 SELECT (lcCustLbl)
1715 SCAN
1716 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1717 lcCust_lbl = Cust_lbl
1718 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1719 SELECT(pcTransDetail)
1720 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1721 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1722 ENDSCAN
1723 ENDIF
1724 ENDSCAN
1725 SELECT(pcTransDetail)
1726 SET ORDER TO (lcZzeipotd_order)
1727 ENDIF
1728 ENDWITH
1729 SELECT(lnOldSelect)
1730 RETURN llRetVal
1731 ENDPROC
1732
1733 *-----------------------------------------------------------------------------------
1734 *=== TR 1023892 NH
1735
1736 ************************************************************************************
1737 * Validate EAN for all details
1738 * Created on 03/24/04 - BD- TR 1003801
1739 ************************************************************************************
1740 Procedure CheckEAN
1741 Lparameters pceipoTH, pceipoTD,;
1742 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1743 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1744
1745 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1746 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1747 lnSize_desc, llSLN
1748 llRetVal = .T.
1749 lcErrs_Msg= ""
1750 lnOldSelect = Select()
1751
1752 *--- TR 1061652 05/18/12 ATHIRUNAVU
1753 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1754 FROM (pceipocr) ;
1755 GROUP BY customer ;
1756 INTO CURSOR __ResvCustSKU
1757 *=== TR 1061652 05/18/12 ATHIRUNAVU
1758
1759 *- Check EAN only if customer is empty
1760 *--- TechRec 1005163 17-May-2004 GS ---
1761 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1762 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1763 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1764 *Order by h.customer, d.ean Into Cursor tmpCurs
1765
1766 *---- TR 1024667 NSD 5/31/07
1767 * If sizebucket = 0 then re-resolve.
1768
1769 If This.oHostProcess.lHaveSLN
1770 *--- TR 1061652 05/18/12 ATHIRUNAVU
1771 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1772 Select h.customer,;
1773 d.ean,;
1774 d.pkey, ;
1775 r.ResvCustSKU, ;
1776 (pceipoTD) As Src;
1777 FROM (pceipoTD) d ;
1778 JOIN (pceipoTH) h ;
1779 ON h.pkey = d.fkey ;
1780 JOIN __ResvCustSKU r ;
1781 ON r.Customer = H.Customer ;
1782 WHERE !Empty(d.ean) ;
1783 AND !Empty(h.customer) ;
1784 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1785 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1786 Union All ;
1787 SELECT h.customer,;
1788 s.SLN_EAN As ean,;
1789 s.pkey, ;
1790 r.ResvCustSKU, ;
1791 (pceipoTS) As Src;
1792 FROM (pceipoTD) d ;
1793 JOIN (pceipoTH) h ;
1794 ON h.pkey = d.fkey ;
1795 JOIN (pceipoTS) s ;
1796 ON s.fkey = d.pkey ;
1797 JOIN __ResvCustSKU r ;
1798 ON r.Customer = H.Customer ;
1799 WHERE !Empty(s.SLN_EAN) ;
1800 AND !Empty(h.customer) ;
1801 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1802 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1803 ORDER By 1, 2 ;
1804 INTO Cursor tmpCurs
1805 Else
1806 *--- TR 1061652 05/18/12 ATHIRUNAVU
1807 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1808 Select h.customer,;
1809 d.ean,;
1810 d.pkey, ;
1811 r.ResvCustSKU, ;
1812 (pceipoTD) As Src;
1813 FROM (pceipoTD) d ;
1814 JOIN (pceipoTH) h ;
1815 ON h.pkey = d.fkey ;
1816 JOIN __ResvCustSKU r ;
1817 ON r.Customer = H.Customer ;
1818 WHERE !Empty(d.ean) ;
1819 AND !Empty(h.customer) ;
1820 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1821 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1822 Order By h.customer, d.ean ;
1823 INTO Cursor tmpCurs
1824 Endif
1825 *=== TechRec 1005163 17-May-2004 GS ===
1826
1827 lcOldCust = ""
1828 lcOldItem = ""
1829 Select tmpCurs
1830 If This.lUserInterface
1831 * Init Thermometer
1832 This.UpdateThermoCaption("Validating EAN(s)...")
1833 This.InitThermo(RecCount('tmpCurs'))
1834 l_nThermoCnt = 0
1835 Endif
1836 Scan
1837 If This.lUserInterface
1838 * Advance progress bar, if we're using one.
1839 l_nThermoCnt = l_nThermoCnt + 1
1840 This.AdvanceThermo(l_nThermoCnt)
1841 Endif
1842 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
1843 lcErrs_Msg = ""
1844 lcOldCust = tmpCurs.customer
1845 lcOldItem = tmpCurs.ean
1846 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1847 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1848
1849 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
1850 lcDivision = tmpCstdr.division
1851 lcStyle = tmpCstdr.Style
1852 lcColor_code = tmpCstdr.color_code
1853 lcLbl_code = tmpCstdr.lbl_code
1854 lcDimension = tmpCstdr.Dimension
1855 lnSizeBucket = tmpCstdr.size_bk
1856 lnSize_desc = tmpCstdr.size_desc
1857 Else
1858
1859 *--- TR 1061652 05/18/12 ATHIRUNAVU
1860 IF ResvCustSKU <> 'Y'
1861 *=== TR 1061652 05/18/12 ATHIRUNAVU
1862
1863 lcErrs_Msg = ""
1864 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
1865 lcDivision = tmpUpcnr.division
1866 lcStyle = tmpUpcnr.Style
1867 lcColor_code = tmpUpcnr.color_code
1868 lcLbl_code = tmpUpcnr.lbl_code
1869 lcDimension = tmpUpcnr.Dimension
1870 lnSizeBucket = tmpUpcnr.sizebucket
1871 lnSize_desc = tmpUpcnr.size_desc
1872 Else
1873 lcErrs_Msg = lcErrs_Msg + CRLF
1874 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1875 Store 0 To lnSizeBucket
1876 Endif
1877
1878 *--- TR 1061652 05/18/12 ATHIRUNAVU
1879 ELSE
1880 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
1881 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1882 STORE 0 TO lnSizeBucket
1883 ENDIF
1884 *=== TR 1061652 05/18/12 ATHIRUNAVU
1885
1886 Endif
1887 Endif && level break
1888
1889 *--- TechRec 1005163 17-May-2004 GS ---
1890 *Select (pceipoTD)
1891 llSLN = (tmpCurs.Src = pceipoTS)
1892 If llSLN
1893 Select (pceipoTS)
1894 Else
1895 Select (pceipoTD)
1896 Endif
1897 *=== TechRec 1005163 17-May-2004 GS ===
1898
1899 *- 1010682 04/25/05 YIK
1900 *- Locate For pkey = tmpCurs.pkey
1901 lnWorkArea = Select()
1902 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1903 Scatter Name loEiPOtd Memo
1904 If !Empty(lcErrs_Msg)
1905 *--- TechRec 1005163 17-May-2004 GS ---
1906 If llSLN
1907 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1908 loEiPOtd.Errs_Flg_S = "Y"
1909 Else
1910 *=== TechRec 1005163 17-May-2004 GS ===
1911 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1912 loEiPOtd.Errs_Flg_D = "Y"
1913 Endif &&--- TechRec 1005163 17-May-2004 GS ===
1914 Endif
1915 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1916 loEiPOtd.division = lcDivision
1917 loEiPOtd.Style = lcStyle
1918 loEiPOtd.color_code = lcColor_code
1919 loEiPOtd.lbl_code = lcLbl_code
1920 loEiPOtd.Dimension = lcDimension
1921 loEiPOtd.sizebucket = lnSizeBucket
1922 loEiPOtd.size_desc = lnSize_desc
1923 Endif
1924
1925 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1926 * only replace our SKU when no range style explosion happen
1927 *--- TechRec 1005163 17-May-2004 GS ---
1928 *If empty(&pceipoTD..rng_style)
1929 * Replace division With loEiPOtd.division, ;
1930 * style With loEiPOtd.style, ;
1931 * color_code With loEiPOtd.color_code, ;
1932 * lbl_code With loEiPOtd.lbl_code, ;
1933 * dimension With loEiPOtd.dimension, ;
1934 * sizebucket With loEiPOtd.sizebucket, ;
1935 * size_desc With loEiPOtd.size_desc, ;
1936 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1937 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1938 * In (pceipoTD)
1939 *- 1009508 3/16/05 YIK
1940 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1941 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
1942
1943 Gather Name loEiPOtd Memo
1944 *=== TechRec 1005163 17-May-2004 GS ===
1945 Endif
1946 Endscan
1947 Use In tmpCurs
1948
1949 If This.lUserInterface
1950 * Reset Thermometer
1951 This.ResetThermo()
1952 Endif
1953
1954 If Used("tmpCstdr")
1955 Use In tmpCstdr
1956 Endif
1957 If Used("tmpUpcnr")
1958 Use In tmpUpcnr
1959 Endif
1960
1961 Select(lnOldSelect)
1962 Return llRetVal
1963 Endproc
1964
1965 *-----------------------------------------------------------------------------------
1966
1967 *--- 39222 5/1/03 YIK
1968 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
1969 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
1970 *- matches the sku sent in transmission.
1971
1972 *--- TechRec 1005163 17-May-2004 GS:
1973 *- Combined ConfirmUPC and ConfirmEAN
1974
1975 Procedure ConfirmSku
1976 Lparameters pceipoTH, pceipoTD, pceipoCR,;
1977 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
1978
1979 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
1980 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
1981 lcSku, lcErrs_Msg, llSLN
1982
1983 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
1984 llRetVal = .T.
1985 lcErrs_Msg= ""
1986
1987 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
1988 lcWarnMsg = ""
1989 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
1990
1991 lnOldSelect = Select()
1992
1993 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
1994
1995 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
1996 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
1997 *- 1003788 2/25/04 YIK
1998 *- use d.division, not h.division which is still empty
1999
2000 *--- TechRec 1005163 17-May-2004 GS ---
2001 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2002
2003 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2004 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2005 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2006 *--- TR 1078000 16-4-2014 VKK Added cust_size
2007 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2008 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass , cust_size ;
2009 from (pceipoTD) Into Cursor __eipoTD
2010
2011 If This.oHostProcess.lHaveSLN
2012 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2013 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2014 *--- TR 1078000 16-4-2014 VKK Added cust_size
2015 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2016 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass , cust_size From (pceipoTS) Into Cursor __EiPOts
2017 Endif
2018 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2019 *--- NH - 08/10/07
2020 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2021 Select(lnOldSelect)
2022 RETURN llRetVal
2023 ENDIF
2024 *=== TR 1022625
2025
2026 With This
2027 .cSQLTempTable = ""
2028 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2029 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2030 lceipoTD_tmp = .cSQLTempTable
2031 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2032
2033 If This.oHostProcess.lHaveSLN
2034 .cSQLTempTable = ""
2035 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2036 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2037 lceipoTS_tmp = .cSQLTempTable
2038 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2039 Endif
2040 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2041 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2042 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2043 ENDWITH
2044
2045
2046 This.MakeCursorWritable("tmpCursR","tmpCurs")
2047 *=== TR 1019697 NH
2048 *=== TechRec 1005163 17-May-2004 GS ===
2049
2050.LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2051 Select tmpCurs
2052 If This.lUserInterface
2053 * Init Thermometer
2054 This.UpdateThermoCaption("Comparing SKU(s)...")
2055 This.InitThermo(RecCount('tmpCurs'))
2056 l_nThermoCnt = 0
2057 Endif
2058 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2059 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2060 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2061 *=== TR 1019697 NH
2062
2063 *-1040686
2064 *=-=-=-=-=-=-=-=-=-=
2065 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2066 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2067 IF llRetVal
2068 .PopulateSQLTempTable("tcDistCustSku")
2069 ENDIF
2070 llRetVal = llRetVal AND v_sqlexec(;
2071 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2072 " , d.aux_sku, d.pkey " +;
2073 " FROM zzxcstdr d"+ ;
2074 " JOIN " + this.cSQLTempTable + " x " + ;
2075 " ON d.customer = x.customer " +;
2076 " AND d.division = x.division " + ;
2077 " AND d.style = x.style " + ;
2078 " AND d.color_code = x.color_code " + ;
2079 " AND d.lbl_code = x.lbl_code " + ;
2080 " AND d.dimension = x.dimension " + ;
2081 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2082 SELECT tmpCstdr
2083 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2084
2085 *=-=-=-=-=-=-=-=-=-=
2086
2087 SELECT tmpCurs
2088 *- 1040686
2089
2090
2091 Local lnSizeBk
2092 lnSizeBk = 0
2093 Scan
2094 If This.lUserInterface
2095 * Advance progress bar, if we're using one.
2096 l_nThermoCnt = l_nThermoCnt + 1
2097 This.AdvanceThermo(l_nThermoCnt)
2098 Endif
2099 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2100 lcErrs_Msg = ""
2101 *=== TechRec 1005163 17-May-2004 GS, YK ===
2102
2103 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2104 lcWarnMsg = ""
2105 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2106
2107 *-1040686
2108 *=-=-=-=-=-=-=-=-=-
2109 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2110 DIMENSION, sizebucket, "tmpCstdr")
2111 lcSku = ""
2112 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2113 lcSku = tmpCstdr.cust_style
2114 ELSE
2115 lcErrs_Msg = "Missing SKU code."
2116 ENDIF
2117 *=-=-=-=-=-=-=-=-=-
2118 *-1040686
2119
2120 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2121 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2122 If !(lcSku == tmpCurs.sku)
2123 If Empty(lcSku) And GenCustSKU = 'Y'
2124 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2125 Replace AddCustSKU With .T. In (tmpCurs.Src)
2126 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2127 lcErrs_Msg = ""
2128 Else
2129 If Confirm_SKU = 'Y'
2130 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2131 Else
2132 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2133 CRLF + "Unable to generate new customer Sku." + CRLF
2134 Endif
2135 ENDIF
2136 *--- TR 1061151 2-MAY-12 Venuk.
2137 Else
2138 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2139 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2140 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2141 v_SqlExec(lcSQL)
2142 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2143 ELSE
2144 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2145 lcWarnMsg = "Aux sku already exist."
2146 ENDIF
2147 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2148 ENDIF
2149 *=== TR 1061151 2-MAY-12 Venuk.
2150 Endif
2151
2152 *--- TechRec 1005163 17-May-2004 GS ---
2153 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2154 * Replace ;
2155 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2156 * Errs_Flg_D With "Y" ;
2157 * In (pceipoTD)
2158
2159 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2160 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2161 llSLN = (tmpCurs.Src = pceipoTS)
2162 If llSLN
2163 Select (pceipoTS)
2164 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2165 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2166 IF !EMPTY(lcErrs_Msg)
2167 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2168 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2169 Replace ;
2170 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2171 Errs_Flg_S With "Y"
2172 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2173 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2174 Errs_Flg_D With 'Y' In (pceipoTD)
2175 Endif
2176 ENDIF
2177 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2178 ELSE
2179 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2180 Warn_Flg_D With "Y" In (pceipoTD)
2181 ENDIF
2182 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2183 Else
2184 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2185 Select (pceipoTD)
2186 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2187 IF !EMPTY(lcErrs_Msg)
2188 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2189 Replace ;
2190 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2191 Errs_Flg_D With "Y"
2192 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2193 ELSE
2194 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2195 Warn_Flg_D With "Y"
2196 ENDIF
2197 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2198 Endif
2199 *=== TechRec 1005163 17-May-2004 GS ===
2200 Endif
2201 ENDSCAN
2202 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2203 *--- TR 1019697 NH :
2204 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2205 *=== TR 1019697 NH
2206 Use In tmpCurs
2207
2208 If This.lUserInterface
2209 * Reset Thermometer
2210 This.ResetThermo()
2211 Endif
2212
2213 If Used("tmpCstdr")
2214 Use In tmpCstdr
2215 ENDIF
2216
2217 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2218
2219 Select(lnOldSelect)
2220 Return llRetVal
2221 Endproc
2222
2223 *-----------------------------------------------------------------------------------
2224
2225 *--- TR 1019697 NH
2226 **************************************************************************************
2227 Procedure GetConfrimSkuSql
2228 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2229 Local lcSQL, lcSqlSln, lnOldSelect
2230 lnOldSelect = Select()
2231
2232 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2233 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2234
2235 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2236 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2237 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2238 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2239 *--- TR 1078000 16-4-2014 VKK Added cust_size
2240 lcSQL = ;
2241 "select d.customer"+;
2242 " , d.division"+;
2243 " , d.sku"+;
2244 " , d.STYLE"+;
2245 " , d.color_code"+;
2246 " , case"+;
2247 " when r.rng_style is null"+;
2248 " and d.lbl_code = ''"+;
2249 " and c.resv_label = 'Y' then c.lbl_code"+;
2250 " when r.rng_style is null"+;
2251 " and d.lbl_code = ''"+;
2252 " and c.resv_label = 'V'"+;
2253 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2254 " else d.lbl_code"+;
2255 " end as lbl_code"+;
2256 " , d.lbl_code as lbl_codeOrig"+;
2257 " , c.resv_label"+;
2258 " , d.DIMENSION"+;
2259 " , d.Sizebucket"+;
2260 " , d.upc"+;
2261 " , d.pkey"+;
2262 " , C.GenCustSKU"+;
2263 " , C.Confirm_SKU"+;
2264 " , 'N' as AddCustSKU"+;
2265 " , d.size_desc"+;
2266 " , '" + Trim(pceipoTD) + "' as Src"+;
2267 " , d.aux_sku " + ;
2268 " , d.subclass " + ;
2269 " , d.cust_size " + ;
2270 " from " + pceipoTD_tmp + " d"+;
2271 " join " + This.c850Control + " C"+;
2272 " on d.customer = C.customer"+;
2273 " and d.division = C.division"+;
2274 " left join zzxrangh r"+;
2275 " on r.division = d.division"+;
2276 " and r.rng_style = d.style"+;
2277 " and r.rng_color = d.color_code"+;
2278 " and r.rng_lbl = d.lbl_code"+;
2279 " and r.rng_pack = d.dimension"+;
2280 " left join zzxscolr sc"+;
2281 " on sc.division = d.division"+;
2282 " and sc.style = d.style"+;
2283 " and sc.color_code = d.color_code"+;
2284 " and sc.lbl_code = c.lbl_code"+;
2285 " and sc.dimension = d.dimension"+;
2286 " where d.customer > ''"+;
2287 " and d.SKU > ''"+;
2288 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2289 " and d.Division > ''"+;
2290 " and d.Style > ''"+;
2291 " and d.Color_Code > ''"+;
2292 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2293 " and d.Rng_Style = '' "
2294
2295 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2296 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2297 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2298 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2299 *--- Used sc.Division instead of c.Division.
2300 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2301 *--- TR 1078000 16-4-2014 VKK Added cust_size
2302 lcSqlSln = ;
2303 "select d.Customer"+;
2304 " , d.Division"+;
2305 " , s.SLN_SKU as sku"+;
2306 " , s.STYLE"+;
2307 " , s.Color_Code"+;
2308 " , case when s.Lbl_Code = ''"+;
2309 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2310 " when s.Lbl_Code = ''"+;
2311 " and c.Resv_Label = 'V'"+;
2312 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2313 " else s.lbl_code"+;
2314 " end as lbl_code"+;
2315 " , s.lbl_code as lbl_codeOrig"+;
2316 " , c.resv_label"+;
2317 " , s.DIMENSION"+;
2318 " , s.Sizebucket"+;
2319 " , s.SLN_UPC as upc"+;
2320 " , s.pkey"+;
2321 " , C.GenCustSKU"+;
2322 " , C.Confirm_SKU"+;
2323 " , 'N' as AddCustSKU"+;
2324 " , s.size_desc"+;
2325 " , '" + Trim(pceipoTS) + "' as Src"+;
2326 " , s.aux_sku " + ;
2327 " , s.subclass " + ;
2328 " , s.cust_size " + ;
2329 " from " + pceipoTD_tmp + " d"+;
2330 " join " + pceipoTS_tmp + " s"+;
2331 " on s.fkey = d.pkey"+;
2332 " join " + This.c850Control + " C"+;
2333 " on d.customer = C.customer"+;
2334 " and d.division = C.division"+;
2335 " left join zzxscolr sc"+;
2336 " on sc.division = d.division"+;
2337 " and sc.style = s.style"+;
2338 " and sc.color_code = s.color_code"+;
2339 " and sc.lbl_code = c.lbl_code"+;
2340 " and sc.dimension = s.dimension"+;
2341 " where d.Customer > ''"+;
2342 " and s.SLN_SKU > ''"+;
2343 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2344 " and d.Division > ''"+;
2345 " and s.Style > ''"+;
2346 " and s.Color_Code > ''"+;
2347 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2348 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2349 Endif
2350
2351 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2352 Select(lnOldSelect)
2353 Return lcSQL
2354 Endproc
2355
2356 *-----------------------------------------------------------------------------------
2357
2358 Procedure CreateOurSkuFromTmpCurs
2359 If Not Used("TmpCurs")
2360 Return .F.
2361 Endif
2362 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2363 llRetVal = .T.
2364 lnOldSelect = Select()
2365 With This
2366 Select tmpCurs
2367 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2368
2369 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2370 lcDistSku = Getuniquefilename()
2371 lcExistingSku = Getuniquefilename()
2372 lcCustLbl = Getuniquefilename()
2373
2374 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2375 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2376 *- We need this because cursor lcCustLbl has customer field.
2377 *- 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
2378 *- with auto_style = 'Y', we will add both auto_style twice.
2379
2380 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2381 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2382 *- because style exists in zzxscolr (we just addeded)
2383 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2384 *- so we will add it twice by accident.
2385
2386 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2387 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2388 *-FH 1066967
2389
2390
2391 *-FH 1066967 - added customer
2392 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2393 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2394 IF llRetVal
2395 .PopulateSQLTempTable(lcDistSku)
2396 ENDIF
2397
2398 llRetVal = llRetVal AND v_sqlexec(;
2399 "SELECT x.* "+;
2400 " FROM zzxscolr d"+ ;
2401 " JOIN " + this.cSQLTempTable + " x " + ;
2402 " ON d.division = x.division " +;
2403 " AND d.style = x.style " + ;
2404 " AND d.color_code = x.color_code " + ;
2405 " AND d.lbl_code = x.lbl_code " + ;
2406 " AND d.dimension = x.dimension " ,lcExistingSku )
2407 SELECT (lcExistingSku)
2408 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2409
2410 IF llRetVal
2411 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2412 ENDIF
2413
2414 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2415 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2416 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2417 SELECT(lcCustLbl)
2418 INDEX on customer + lbl_code TAG cust_lbl
2419
2420 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2421 SELECT (lcDistSku) && FH 1066967
2422 Scan
2423 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2424 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2425 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2426*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2427*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2428*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2429*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2430*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2431*!* Else
2432*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2433*!* Endif
2434*!* ENDIF
2435
2436 IF NOT EMPTY(&lcDistSku..lbl_code)
2437 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2438 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2439 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2440 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2441
2442 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2443 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2444 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2445 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2446
2447 .oLog.LogEntry("Created style: " + lcOurSKU )
2448 Else
2449 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2450 ENDIF
2451 ENDIF
2452 Endif
2453 ENDIF
2454
2455 ENDSCAN
2456 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2457
2458 USE IN SELECT(lcDistSku)
2459 USE IN SELECT(lcExistingSku)
2460 USE IN SELECT(lcCustLbl)
2461
2462 USE IN SELECT('lcStyleAdded') && FH 1066967
2463
2464 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2465 Endwith
2466 Select (lnOldSelect)
2467 Return llRetVal
2468 Endproc
2469
2470 *-----------------------------------------------------------------------------------
2471
2472 Procedure GenerateCustomerSkuFromCursor
2473 Parameters tcSkuCursor
2474 Local lnOldSelect, llRetVal
2475 llRetVal = .T.
2476 lnOldSelect = Select()
2477
2478 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2479 lcPrevSkuIpotd = ""
2480 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2481 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2482 *--- TR 1078000 16-4-2014 VKK Added cust_size
2483 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2484 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2485 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2486 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2487
2488 With This
2489 lnCount = Reccount("tmpCurs1")
2490
2491 If lnCount = 0
2492 Select (lnOldSelect)
2493 Return
2494 Endif
2495
2496 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2497 Select (lnOldSelect)
2498 Return
2499 Endif
2500
2501 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2502 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2503 lnCount = lnCount - 1
2504 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2505 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2506
2507 Select VZZXCSTHR
2508 Scatter Memvar Blank
2509 Select VZZXCSTDR
2510 Scatter Memvar Blank
2511
2512 m.Last_mod = Datetime()
2513 m.User_id = 'CGSADMIN'
2514 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2515
2516 * --- TR 1039603 4/6/09 CM
2517 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2518 m.active_ok = 'Y'
2519 m.anti_theft = 'N'
2520 * === TR 1039603 4/6/09 CM
2521
2522 m.notes = ''
2523
2524 lcPrevSKU = ' '
2525
2526 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2527 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2528 Select("tmpCursSrc")
2529 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2530 Scan
2531 Select (Alltrim(tmpCursSrc.Src))
2532 lcOldOrder = Order()
2533 Set Order To CstBcSku
2534 Replace oldOrder With lcOldOrder In tmpCursSrc
2535 ENDSCAN
2536 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2537
2538 Select tmpCurs1
2539 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2540 Scan
2541 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2542 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2543 *--- TR 1078000 16-4-2014 VKK Added cust_size
2544 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2545 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2546 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2547 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2548 If lcPrevSKU # lcSku
2549 lcPrevSKU = lcSku
2550 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2551 If Empty(lnHDRpKey)
2552 lnHDRpKey = lnCstHrPkey
2553 Insert Into VZZXCSTHR From Memvar
2554 Replace pkey With lnHDRpKey In VZZXCSTHR
2555 Endif
2556 Endif
2557 *--- clear AddCustSKU for all matching rows in zzeipotd
2558 Select (tmpCurs1.Src)
2559 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2560 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2561 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2562 Endscan
2563 lcPrevSkuIpotd = lcSkuIpotd
2564
2565 *-TR 1059834 FH -moved in IF statement
2566 Select tmpCurs1
2567 Insert Into VZZXCSTDR From Memvar
2568 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2569 lnCstDrPkey = lnCstDrPkey +1
2570 lnCstHrPkey = lnCstHrPkey +1
2571 *-TR 1059834 FH -moved in IF statement
2572
2573 Endif
2574 ENDSCAN
2575 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2576 Select("tmpCursSrc")
2577 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2578 Scan
2579 Select (Alltrim(tmpCursSrc.Src))
2580 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2581* If Not Empty(lcOldOrder)
2582 Set Order To (lcOldOrder)
2583* Endif
2584 ENDSCAN
2585 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2586 Use In tmpCursSrc
2587
2588 Dimension laTables[2]
2589 laTables[1]= "VZZXCSTHR"
2590 laTables[2]= "VZZXCSTDR"
2591
2592 llBeganTransaction = .BeginTransaction()
2593 llRetVal = .Tableupdate(@laTables)
2594
2595 If llRetVal
2596 If llBeganTransaction
2597 This.EndTransaction()
2598 Endif
2599 Else
2600 If llBeganTransaction
2601 This.RollbackTransaction()
2602 Endif
2603 Endif
2604 Endwith
2605 If Used("tmpCurs1")
2606 Use In tmpCurs1
2607 Endif
2608 Select(lnOldSelect)
2609 Return llRetVal
2610 Endproc
2611
2612 *-----------------------------------------------------------------------------------
2613 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2614
2615 Function GenerateRBACustSKU
2616 Lparameters pceipoTH,pceipoTD
2617
2618 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2619 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2620
2621
2622 llRetVal = True
2623 lnSelect = Select()
2624 lcRBADivision = 'TFG'
2625 With This
2626
2627 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2628
2629 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2630 *- 12/12/06 YIK
2631 *- No distinct since includes pkey. Change order.
2632 *-- SELECT DISTINCT ;
2633 *-- h.customer,;
2634 *-- lcRBADivision as division,;
2635 *-- d.pkey as dtlpkey ,;
2636 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2637 *-- d.color_code,;
2638 *-- .GetCustLabel(h.customer) as lbl_code,;
2639 *-- "" as DIMENSION,;
2640 *-- h.store as cust_store ,;
2641 *-- d.sku as cust_style ,;
2642 *-- d.price as cust_price , ;
2643 *-- d.size_desc, ;
2644 *-- 0 as size_bk ;
2645 *-- FROM (pceipoTH) h ;
2646 *-- JOIN (pceipoTD) d ;
2647 *-- ON d.fkey = h.pkey ;
2648 *-- INTO CURSOR __tmpCur ;
2649 *-- ORDER BY 1,2,3,4,5,6
2650
2651 *** Size_BK needs to be 00 and NOT 0
2652 Select ;
2653 h.customer,;
2654 lcRBADivision As division,;
2655 d.pkey As dtlpkey ,;
2656 d.Style As Style, ;
2657 d.color_code,;
2658 .GetCustLabel(h.customer) As lbl_code,;
2659 "" As Dimension,;
2660 h.Store As cust_store ,;
2661 d.sku As Cust_style ,;
2662 d.price As cust_price , ;
2663 d.size_desc, ;
2664 00 As size_bk ;
2665 FROM (pceipoTH) h ;
2666 JOIN (pceipoTD) d ;
2667 ON d.fkey = h.pkey ;
2668 WHERE h.Errs_flg_h < 'Y' And ;
2669 d.Errs_Flg_D < 'Y' ;
2670 INTO Cursor __tmpCur ;
2671 ORDER By 1,2,4,5,6,7, 11
2672 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2673
2674 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2675
2676 lnCount = Reccount("tmpCurs")
2677
2678 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
2679
2680 If lnCount = 0
2681 If Used("tmpCurs")
2682 Use In tmpCurs
2683 Endif
2684 Select (lnSelect)
2685 Return
2686 Endif
2687
2688 Select tmpCurs
2689 *
2690 * Make it a loop for safety
2691 *
2692 Scan
2693 *** .LogEntry("Original Style " + style)
2694 lcStyle = .GetBCStyle(lcRBADivision,Style)
2695 *** .LogEntry("Resolved Style " + lcStyle)
2696 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
2697 Replace Style With lcStyle , size_bk With lnSize_BK
2698 Endscan
2699 .LogEntry("Resolved Styles/Size_BK")
2700
2701 *- 12/12/06 YIK
2702 *- Index just in case somebody changes the SELECT above
2703 Select tmpCurs
2704 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
2705 TAG sku
2706
2707 .LogEntry("Load Customer Style.")
2708
2709 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2710 If Used("tmpCurs")
2711 Use In tmpCurs
2712 Endif
2713 Select (lnSelect)
2714 Return
2715 Endif
2716
2717 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2718 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2719 lnCount = lnCount - 1
2720 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2721 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2722
2723 Select VZZXCSTHR
2724 Scatter Memvar Blank
2725 Select VZZXCSTDR
2726 Scatter Memvar Blank
2727
2728 m.Last_mod = Datetime()
2729 m.User_id = 'CGSADMIN'
2730 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2731 m.notes = ''
2732
2733 lcPrevSKU = ' '
2734 lcPrevSkuSize = ''
2735
2736 *- 12/12/06 YIK
2737 *- inserted details counter
2738 Local lnInsertCount
2739 lnInsertCount = 0
2740
2741 Select tmpCurs
2742
2743 Scan
2744 .LogEntry("Loading Customer Style...")
2745 .LogEntry("Style :" + Style )
2746 .LogEntry("Color_code :" + color_code )
2747
2748 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
2749 .LogEntry("Invalid Style or Color_code or Size_bk " )
2750 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
2751 FOR pkey = dtlpkey In (pceipoTD)
2752 Loop
2753 Endif
2754
2755 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2756 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
2757 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2758 If lcPrevSKU # lcSku
2759 lcPrevSKU = lcSku
2760 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
2761 .LogEntry("Customer :" + m.customer )
2762 .LogEntry("Division : " + m.division)
2763 .LogEntry("Style :" + Style )
2764 .LogEntry("Color_code :" + m.color_code )
2765 .LogEntry("Label code :" + m.lbl_code )
2766 .LogEntry("dimension : " + m.dimension)
2767 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
2768 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2769 If Empty(lnHDRpKey)
2770 lnHDRpKey = lnCstHrPkey
2771 .LogEntry("Inserting into header..")
2772 Insert Into VZZXCSTHR From Memvar
2773 Replace pkey With lnHDRpKey In VZZXCSTHR
2774 Endif
2775 Endif
2776 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
2777 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
2778 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
2779 If Empty(lnDtlKey)
2780 lnDtlpKey = lnCstDrPkey
2781 .LogEntry("Inserting into detail..")
2782 Insert Into VZZXCSTDR From Memvar
2783 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
2784 *- 12/12/06 YIK
2785 lnInsertCount = lnInsertCount + 1
2786 Endif
2787 Endif
2788 lnCstDrPkey = lnCstDrPkey +1
2789 lnCstHrPkey = lnCstHrPkey +1
2790
2791 Endscan
2792
2793 Dimension laTables[2]
2794 laTables[1]= "VZZXCSTHR"
2795 laTables[2]= "VZZXCSTDR"
2796
2797 llBeganTransaction = .BeginTransaction()
2798 llRetVal = .Tableupdate(@laTables)
2799
2800 If llRetVal
2801 If llBeganTransaction
2802 This.EndTransaction()
2803 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
2804 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
2805 Endif
2806 Else
2807 If llBeganTransaction
2808 This.RollbackTransaction()
2809 .LogEntry("Table Update failed - Roll back Transaction " )
2810 Endif
2811 Endif
2812
2813 Endwith
2814
2815 If Used("tmpCurs")
2816 Use In tmpCurs
2817 Endif
2818
2819 Select (lnSelect)
2820 Return llRetVal
2821 Endfunc
2822
2823 *-----------------------------------------------------------------------------------
2824
2825 Function GetBCStyle
2826 Lparameters tcDivision, tcUDFStyle
2827 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
2828
2829 llRetVal = True
2830 lnSelect = Select()
2831 l_vRetVal = ''
2832
2833 lcCursor = GetUniqueFileName()
2834 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
2835 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
2836
2837 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
2838
2839 If llRetVal
2840 Select(lcCursor)
2841 l_vRetVal = Alltrim(Style)
2842 Use In (lcCursor)
2843 Endif
2844
2845 Select (lnSelect)
2846 Return l_vRetVal
2847 Endfunc
2848
2849 *-----------------------------------------------------------------------------------
2850
2851 Function GetSizeBkt
2852 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
2853 p_cKeyField4, p_cKeyField5, p_cKeyField6
2854 Local l_cSQLString, l_vRetVal
2855
2856 l_nOldSele = Select()
2857 pnSizeBucket = 0
2858
2859 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
2860 l_vRetVal = 0
2861 Return l_vRetVal
2862 Endif
2863
2864 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
2865 p_cKeyField2)
2866 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
2867 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
2868 p_cKeyField3, p_cKeyField4, p_cKeyField5)
2869 Select TmpSavlr
2870 For l_n=1 To 24
2871 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
2872 If l_lAlwSz
2873 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
2874 If l_cSize_Desc = p_cKeyField6
2875 ***l_vRetVal = .T.
2876 pnSizeBucket = l_n
2877 Endif
2878 Endif
2879 Endfor
2880 Use In TmpSavlr
2881 Use In TmpSizer
2882 Endif
2883 Endif
2884
2885 l_vRetVal = pnSizeBucket
2886
2887 Select (l_nOldSele)
2888 Return l_vRetVal
2889
2890 Endfunc
2891
2892 *-----------------------------------------------------------------------------------
2893 * Validate SKU for all details
2894 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
2895
2896 Procedure CheckSku
2897 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
2898 Lparameters pceipoTH, pceipoTD,;
2899 pceipoTS, pceipoCR
2900 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
2901 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
2902 lnSize_desc, llSLN
2903
2904 *--- TR 1013117 NH
2905 Local lcSku_resolv
2906 Dimension lasku_resolv[1]
2907 lcSku_resolv = ""
2908 lasku_resolv[1] = ""
2909 *=== TR 1013117 NH
2910
2911 * --- TR 1045305 2/3/10 CM
2912 LOCAL lnSkuPkey
2913 lnSkuPkey = 0
2914 * === TR 1045305 2/3/10 CM
2915
2916
2917 llRetVal = .T.
2918 lcErrs_Msg= ""
2919 lnOldSelect = Select()
2920
2921 * cannot check for SKU if customer is empty
2922 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
2923 * on Cust SKU or UPC.
2924 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
2925
2926 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
2927 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
2928 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
2929
2930 *--- TechRec 1005163 17-May-2004 GS ---
2931 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
2932 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
2933 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
2934 *Order by h.customer, d.sku Into Cursor tmpCurs
2935
2936 *---- TR 1024667 NSD 5/31/07
2937 * If sizebucket = 0 then re-resolve.
2938
2939 If This.oHostProcess.lHaveSLN
2940 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
2941 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
2942 *!* SELECT h.customer,;
2943 *!* c.sku_resolv, ;
2944 *!* JOIN (pceipoCR) C;
2945 *!* ON d.division= C.division ;
2946 *!* AND h.customer= C.customer ;
2947
2948 *!* c.sku_resolv, ; && after union
2949 *!* JOIN (pceipoCR) C;
2950 *!* ON d.division= C.division ;
2951 *!* AND h.customer= C.customer ;
2952
2953 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
2954 Select h.customer,;
2955 h.department, ;
2956 h.Store, ;
2957 d.sku,;
2958 d.upc, ;
2959 d.pkey, ;
2960 (pceipoTD) As Src ;
2961 FROM (pceipoTD) d ;
2962 JOIN (pceipoTH) h ;
2963 ON h.pkey = d.fkey ;
2964 WHERE !Empty(h.customer) ;
2965 AND !Empty(d.sku) ;
2966 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
2967 UNION All ;
2968 SELECT h.customer,;
2969 h.department, ;
2970 h.Store, ;
2971 s.SLN_SKU As sku,;
2972 s.SLN_UPC As upc,;
2973 s.pkey, ;
2974 (pceipoTS) As Src ;
2975 FROM (pceipoTS) s ;
2976 JOIN (pceipoTD) d ;
2977 ON d.pkey = s.fkey ;
2978 JOIN (pceipoTH) h ;
2979 ON h.pkey = d.fkey ;
2980 WHERE !Empty(h.customer) ;
2981 AND !Empty(s.SLN_SKU) ;
2982 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
2983 ORDER By 1, 2 ;
2984 INTO Cursor tmpCurs
2985 *=== TR 1010097 07/27/05 TK
2986 Else
2987 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
2988 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
2989 *!* SELECT h.customer,;
2990 *!* c.sku_resolv, ;
2991 *!* JOIN (pceipoCR) C;
2992 *!* ON d.division= C.division ;
2993 *!* AND h.customer= C.customer ;
2994 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
2995 Select h.customer,;
2996 h.department, ;
2997 h.Store, ;
2998 d.sku,;
2999 d.upc, ;
3000 d.pkey, ;
3001 (pceipoTD) As Src ;
3002 FROM (pceipoTD) d ;
3003 JOIN (pceipoTH) h ;
3004 ON h.pkey = d.fkey ;
3005 WHERE !Empty(h.customer) ;
3006 AND !Empty(d.sku) ;
3007 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3008 Order By h.customer, d.sku ;
3009 INTO Cursor tmpCurs
3010 *=== TR 1010097 07/27/05 TK
3011 Endif
3012 *=== TechRec 1005163 17-May-2004 GS ===
3013
3014*- 1040686
3015 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3016 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3017 IF llRetVal
3018 .PopulateSQLTempTable("tcDistCustSku")
3019 ENDIF
3020 llRetVal = llRetVal AND v_sqlexec(;
3021 "SELECT x.sku,d.* "+;
3022 " FROM zzxcstdr d"+ ;
3023 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3024 " JOIN " + this.cSQLTempTable + " x " + ;
3025 " ON d.customer = x.customer " +;
3026 " AND d.cust_style = x.sku " + ;
3027 " WHERE h.IB_resolv = 'Y'" + ;
3028 " AND d.Size_Desc>'' " + ;
3029 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3030 SELECT tmpCstdr_sku
3031 INDEX ON customer + cust_style TAG cust_sku
3032
3033 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3034 UNION ;
3035 SELECT customer,sku FROM tmpCstdr_sku ;
3036 GROUP BY customer,sku ;
3037 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3038 INDEX ON customer+sku TAG cust_sku
3039 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3040*- 1040686
3041
3042
3043 lcOldCust = ""
3044 lcOldItem = ""
3045 lcOldSku_resolv = ""
3046 Select tmpCurs
3047 If This.lUserInterface
3048 * Init Thermometer
3049 This.UpdateThermoCaption("Validating SKU(s)...")
3050 * TAN 31891 - JAZ - 5/20/02
3051 * This.InitThermo(RECC('tmpCurs'))
3052 This.InitThermo(RecCount('tmpCurs'))
3053 * End TAN 31891 - JAZ - 5/20/02
3054 l_nThermoCnt = 0
3055 Endif
3056 SCAN
3057 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3058 *-- Skip sku resolution
3059 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3060 LOOP
3061 ENDIF
3062 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3063
3064 If This.lUserInterface
3065 * Advance progress bar, if we're using one.
3066 l_nThermoCnt = l_nThermoCnt + 1
3067 This.AdvanceThermo(l_nThermoCnt)
3068 Endif
3069
3070 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3071 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3072 *--- TR 1013117 NH 20050908
3073 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3074 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3075 *=== TR 1013117 NH 20050908
3076 *=== TR 1010097 07/27/05 TK
3077
3078 *---TR 1037976 JAN-07-08 BR
3079 IF !(tmpCurs.customer == lcOldCust)
3080 lcCustomer = tmpCurs.customer
3081 IF SEEK(lcCustomer,pceipocr,"customer")
3082 lcSku_resolv = &pceipocr..sku_resolv
3083 ENDIF
3084 ENDIF
3085 *===TR 1037976 JAN-07-08 BR
3086
3087 lcErrs_Msg = ""
3088 lcOldCust = tmpCurs.customer
3089 lcOldItem = tmpCurs.sku
3090 *--- TR 1013117 NH
3091 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3092 *=== TR 1013117 NH
3093
3094 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3095
3096
3097
3098 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3099 *--- TR 1013117 NH 20050908
3100 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3101 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3102
3103 *- 1040686 - COMMENT
3104*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3105*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3106*!* *=== TR 1013117 NH 20050908
3107*!* *--- TR 1010097 07/27/05 TK
3108
3109*!* lcDivision = tmpCstdr.division
3110*!* lcStyle = tmpCstdr.Style
3111*!* lcColor_code = tmpCstdr.color_code
3112*!* lcLbl_code = tmpCstdr.lbl_code
3113*!* lcDimension = tmpCstdr.Dimension
3114*!* lnSizeBucket = tmpCstdr.size_bk
3115*!* lnSize_desc = tmpCstdr.size_desc
3116*!*
3117*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3118*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3119*!* If tmpCstdr.fkey > 0
3120*!* lnSkuPkey = tmpCstdr.fkey
3121*!* Endif
3122*!* * === TR 1045305 2/3/10 CM
3123*!*
3124*!*
3125*!* Else
3126*!* lcErrs_Msg = lcErrs_Msg + CRLF
3127*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3128*!* Store 0 To lnSizeBucket
3129*!* Endif
3130
3131 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3132 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3133 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3134 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3135 Store 0 To lnSizeBucket
3136 ELSE
3137 *- TR 1074276 FH - adding UPPER()
3138 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3139 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3140 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3141 Store 0 To lnSizeBucket
3142 ELSE
3143 lcDivision = tmpCstdr_sku.division
3144 lcStyle = tmpCstdr_sku.Style
3145 lcColor_code = tmpCstdr_sku.color_code
3146 lcLbl_code = tmpCstdr_sku.lbl_code
3147 lcDimension = tmpCstdr_sku.Dimension
3148 lnSizeBucket = tmpCstdr_sku.size_bk
3149 lnSize_desc = tmpCstdr_sku.size_desc
3150
3151 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3152 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3153 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3154 If tmpCstdr_sku.fkey > 0
3155 lnSkuPkey = tmpCstdr_sku.fkey
3156 Endif
3157 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3158 *!* * === TR 1045305 2/3/10 CM
3159
3160 ENDIF
3161 ENDIF
3162*- 1040686 - COMMENT
3163
3164 Endif && level break
3165
3166 *--- TechRec 1005163 17-May-2004 GS ---
3167 *Select (pceipoTD)
3168 llSLN = (tmpCurs.Src = pceipoTS)
3169 If llSLN
3170 Select (pceipoTS)
3171 Else
3172 Select (pceipoTD)
3173 Endif
3174 *!* Locate For pkey = tmpCurs.pkey
3175 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3176 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3177 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3178 *=== TechRec 1005163 17-May-2004 GS ===
3179 Scatter Name loEiPOtd Memo
3180 If !Empty(lcErrs_Msg)
3181 *--- TechRec 1005163 17-May-2004 GS ---
3182 If llSLN
3183 *- 1008827 04/22/05 YIK
3184 *- correct a typo
3185 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3186
3187 loEiPOtd.Errs_Flg_S = "Y"
3188 Else
3189 *=== TechRec 1005163 17-May-2004 GS ===
3190 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3191 loEiPOtd.Errs_Flg_D = "Y"
3192 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3193 Endif
3194 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3195 loEiPOtd.division = lcDivision
3196 loEiPOtd.Style = lcStyle
3197 loEiPOtd.color_code = lcColor_code
3198 loEiPOtd.lbl_code = lcLbl_code
3199 loEiPOtd.Dimension = lcDimension
3200 loEiPOtd.sizebucket = lnSizeBucket
3201 loEiPOtd.size_desc = lnSize_desc
3202
3203 * --- TR 1045305 2/3/10 CM
3204 loEiPOtd.sku_pkey = lnSkuPkey
3205 * === TR 1045305 2/3/10 CM
3206
3207 Endif
3208
3209 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3210 * only replace our SKU when no range style explosion happen
3211 *--- TechRec 1005163 17-May-2004 GS ---
3212 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3213 * Replace division With loEiPOtd.division, ;
3214 * style With loEiPOtd.style, ;
3215 * color_code With loEiPOtd.color_code, ;
3216 * lbl_code With loEiPOtd.lbl_code, ;
3217 * dimension With loEiPOtd.dimension, ;
3218 * sizebucket With loEiPOtd.sizebucket, ;
3219 * size_desc With loEiPOtd.size_desc, ;
3220 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3221 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3222 * In (pceipoTD)
3223 *- 1009508 3/16/05 YIK
3224 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3225 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3226 Gather Name loEiPOtd Memo
3227 *=== TechRec 1005163 17-May-2004 GS ===
3228 Endif
3229
3230 *=== TechRec 1005163 17-May-2004 GS ===
3231 Endif
3232 Endscan
3233 Use In tmpCurs
3234
3235 If This.lUserInterface
3236 * Reset Thermometer
3237 This.ResetThermo()
3238 Endif
3239
3240 If Used("tmpCstdr")
3241 Use In tmpCstdr
3242 ENDIF
3243
3244 *-1040686
3245 USE IN SELECT("tcDistCustSku")
3246 USE IN SELECT("tmpCstdr_sku")
3247 USE IN SELECT("tcAmbigSku")
3248 *-1040686
3249
3250 Select(lnOldSelect)
3251 Return llRetVal
3252 Endproc
3253
3254 *-----------------------------------------------------------------------------------
3255 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3256 PROCEDURE PopulateOrigLabel
3257 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3258 LOCAL llRetVal, lnOldSelect
3259 lnOldSelect = SELECT()
3260
3261 .PopRecordSet()
3262 SELECT (pceipoTD)
3263
3264 SELECT d.pkey ;
3265 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3266 WHERE c.accept_lbl = 'Y' and ;
3267 c.customer = h.customer and ;
3268 c.division = d.division and ;
3269 h.pkey = d.fkey and ;
3270 h.errs_flg_h <> 'Y' and ;
3271 d.errs_flg_d <> 'Y' ;
3272 ORDER BY d.pkey ;
3273 INTO CURSOR 'cursTmpTD'
3274
3275 Index On pkey Tag pkey
3276
3277 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3278
3279 goto top in "cursTmpTD"
3280
3281 If llRetVal AND !EOF('cursTmpTD')
3282 SELECT (pceipoTD)
3283 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3284 In (pceipoTD)
3285 Endif
3286
3287 .PushRecordSet()
3288
3289 Set Relation to
3290 USE IN 'cursTmpTD'
3291 SELECT (lnOldSelect)
3292 RETURN llRetVal
3293 ENDPROC
3294 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3295 *-----------------------------------------------------------------------------------
3296
3297 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3298 Procedure ConfirmUPC
3299 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3300
3301 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3302 lcUPC, lcErrs_Msg, llSLN
3303
3304 llRetVal = .T.
3305 lcErrs_Msg= ""
3306 lnOldSelect = Select()
3307
3308 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3309
3310 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3311
3312 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3313 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3314 from (pceipoTD) Into Cursor __eipoTD
3315
3316 If This.oHostProcess.lHaveSLN
3317 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3318 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3319 Endif
3320
3321 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3322 Select(lnOldSelect)
3323 Return llRetVal
3324 Endif
3325
3326 With This
3327 .cSQLTempTable = ""
3328 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3329 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3330 lceipoTD_tmp = .cSQLTempTable
3331 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3332
3333 If This.oHostProcess.lHaveSLN
3334 .cSQLTempTable = ""
3335 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3336 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3337 lceipoTS_tmp = .cSQLTempTable
3338 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3339 Endif
3340 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3341 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3342 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3343 Endwith
3344
3345
3346 This.MakeCursorWritable("tmpCursR","tmpCurs")
3347
3348 Select tmpCurs
3349 If This.lUserInterface
3350 * Init Thermometer
3351 This.UpdateThermoCaption("Comparing UPC(s)...")
3352 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3353 l_nThermoCnt = 0
3354 Endif
3355
3356
3357*- 1040686
3358 *=-=-=-=-=-=-=-=-=-=
3359 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3360 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3361 IF llRetVal
3362 .PopulateSQLTempTable("tcDistUpc")
3363 ENDIF
3364 llRetVal = llRetVal AND v_sqlexec(;
3365 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3366 " FROM zveupcnr d"+ ;
3367 " JOIN " + this.cSQLTempTable + " x " + ;
3368 " ON d.division = x.division " + ;
3369 " AND d.style = x.style " + ;
3370 " AND d.color_code = x.roll_color " + ;
3371 " AND d.lbl_code = x.lbl_code " + ;
3372 " AND d.dimension = x.dimension " + ;
3373 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3374 SELECT tmpCstdr
3375 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3376 *=-=-=-=-=-=-=-=-=-=
3377 SELECT tmpCurs
3378
3379*- 1040686
3380 Local lnSizeBk
3381 lnSizeBk = 0
3382 Scan
3383 If This.lUserInterface
3384 * Advance progress bar, if we're using one.
3385 l_nThermoCnt = l_nThermoCnt + 1
3386 This.AdvanceThermo(l_nThermoCnt)
3387 Endif
3388
3389 lcErrs_Msg = ""
3390
3391 *- 1040686
3392 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3393 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3394 DIMENSION, sizebucket, "tmpCstdr")
3395 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3396 DIMENSION, sizebucket, "tmpCstdr")
3397
3398 lcUPC = ""
3399 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3400 lcErrs_Msg = "Missing UPC number."
3401 ELSE
3402 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3403 ENDIF
3404
3405 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3406 *-1040686
3407
3408 If !(lcUPC == tmpCurs.UPC)
3409 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3410 Endif
3411
3412 If !Empty(lcErrs_Msg)
3413 llSLN = (tmpCurs.Src = pceipoTS)
3414 If llSLN
3415 Select (pceipoTS)
3416 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3417 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3418 Replace ;
3419 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3420 Errs_Flg_S With "Y"
3421 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3422 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3423 Errs_Flg_D With 'Y' In (pceipoTD)
3424 Endif
3425 ENDIF &&--- TR 1035223 NH
3426 Else
3427 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3428 Select (pceipoTD)
3429 Replace ;
3430 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3431 Errs_Flg_D With "Y"
3432 Endif
3433 Endif
3434 Endscan
3435
3436 Use In tmpCurs
3437
3438 If This.lUserInterface
3439 * Reset Thermometer
3440 This.ResetThermo()
3441 Endif
3442
3443 If Used("tmpCstdr")
3444 Use In tmpCstdr
3445 ENDIF
3446
3447 USE IN SELECT("tcDistUpc") &&1040686
3448
3449 Select(lnOldSelect)
3450 Return llRetVal
3451 ENDPROC
3452
3453 *-----------------------------------------------------------------------------------
3454
3455 Procedure GetConfrimUPCSql
3456 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3457 Local lcSql, lcSqlSln, lnOldSelect
3458 lnOldSelect = Select()
3459
3460 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3461 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3462 * this is a straight join and not a date resolution.
3463 lcSql = ;
3464 "select d.customer"+;
3465 " , d.division"+;
3466 " , d.sku"+;
3467 " , d.STYLE"+;
3468 " , d.color_code"+;
3469 " , case"+;
3470 " when r.rng_style is null"+;
3471 " and d.lbl_code = ''"+;
3472 " and c.resv_label = 'Y' then c.lbl_code"+;
3473 " when r.rng_style is null"+;
3474 " and d.lbl_code = ''"+;
3475 " and c.resv_label = 'V'"+;
3476 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3477 " else d.lbl_code"+;
3478 " end as lbl_code"+;
3479 " , d.lbl_code as lbl_codeOrig"+;
3480 " , c.resv_label"+;
3481 " , d.DIMENSION"+;
3482 " , d.Sizebucket"+;
3483 " , d.upc"+;
3484 " , d.pkey"+;
3485 " , C.Confirm_UPC"+;
3486 " , d.size_desc"+;
3487 " , '" + Trim(pceipoTD) + "' as Src"+;
3488 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3489 " from " + pceipoTD_tmp + " d"+;
3490 " join zzeipocr C"+;
3491 " on d.customer = C.customer"+;
3492 " and d.division = C.division"+;
3493 " left join zzxrangh r"+;
3494 " on r.division = d.division"+;
3495 " and r.rng_style = d.style"+;
3496 " and r.rng_color = d.color_code"+;
3497 " and r.rng_lbl = d.lbl_code"+;
3498 " and r.rng_pack = d.dimension"+;
3499 " left join zzxscolr sc"+;
3500 " on sc.division = d.division"+;
3501 " and sc.style = d.style"+;
3502 " and sc.color_code = d.color_code"+;
3503 " and sc.lbl_code = c.lbl_code"+;
3504 " and sc.dimension = d.dimension"+;
3505 " left join zzxrupcd rc " + ;
3506 " on rc.division = d.division"+;
3507 " and rc.style = d.style"+;
3508 " and rc.new_color = d.color_code"+;
3509 " and rc.lbl_code = d.lbl_code"+;
3510 " and rc.dimension = d.dimension"+;
3511 " where d.customer > ''"+;
3512 " and d.SKU > ''"+;
3513 " and (d.UPC > '' or d.EAN > '' )"+;
3514 " and d.Division > ''"+;
3515 " and d.Style > ''"+;
3516 " and d.Color_Code > ''"+;
3517 " and C.Confirm_UPC = 'Y' "+;
3518 " and d.Rng_Style = '' "
3519
3520 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3521 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3522 *--- Used sc.Division instead of c.Division.
3523 lcSqlSln = ;
3524 "select d.Customer"+;
3525 " , d.Division"+;
3526 " , s.SLN_SKU as sku"+;
3527 " , s.STYLE"+;
3528 " , s.Color_Code"+;
3529 " , case when s.Lbl_Code = ''"+;
3530 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3531 " when s.Lbl_Code = ''"+;
3532 " and c.Resv_Label = 'V'"+;
3533 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3534 " else s.lbl_code"+;
3535 " end as lbl_code"+;
3536 " , s.lbl_code as lbl_codeOrig"+;
3537 " , c.resv_label"+;
3538 " , s.DIMENSION"+;
3539 " , s.Sizebucket"+;
3540 " , s.SLN_UPC as upc"+;
3541 " , s.pkey"+;
3542 " , C.Confirm_UPC"+;
3543 " , s.size_desc"+;
3544 " , '" + Trim(pceipoTS) + "' as Src"+;
3545 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3546 " from " + pceipoTD_tmp + " d"+;
3547 " join " + pceipoTS_tmp + " s"+;
3548 " on s.fkey = d.pkey"+;
3549 " join zzeipocr C"+;
3550 " on d.customer = C.customer"+;
3551 " and d.division = C.division"+;
3552 " left join zzxscolr sc"+;
3553 " on sc.division = d.division"+;
3554 " and sc.style = s.style"+;
3555 " and sc.color_code = s.color_code"+;
3556 " and sc.lbl_code = c.lbl_code"+;
3557 " and sc.dimension = s.dimension"+;
3558 " left join zzxrupcd rc " + ;
3559 " on rc.division = d.division"+;
3560 " and rc.style = s.style"+;
3561 " and rc.new_color = s.color_code"+;
3562 " and rc.lbl_code = c.lbl_code"+;
3563 " and rc.dimension = s.dimension"+;
3564 " where d.Customer > ''"+;
3565 " and s.SLN_SKU > ''"+;
3566 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3567 " and d.Division > ''"+;
3568 " and s.Style > ''"+;
3569 " and s.Color_Code > ''"+;
3570 " and c.Confirm_UPC = 'Y'"+;
3571 " and d.Rng_Style > ''"
3572 Endif
3573
3574 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3575 Select(lnOldSelect)
3576 Return lcSql
3577 Endproc
3578 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3579
3580 *-----------------------------------------------------------------------------------
3581
3582 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3583 PROCEDURE MarkHeaderwithDetailOrSLNInError
3584 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3585 * This is customized method from clsEDI
3586
3587 LOCAL llRetVal, lnOldSelect
3588 LOCAL lnBadOrderCount
3589 llRetVal = .T.
3590 lnOldSelect = SELECT()
3591
3592 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3593 pcEW = "E"
3594 ENDIF
3595 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3596 LOCAL lcErrorMsg, lcErrorMsgSLN
3597 lnBadOrderCount = 0
3598 IF pcEW = 'W'
3599 lcErrorMsg = "Has Warnings in Details."
3600 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3601 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3602 ELSE
3603 lcErrorMsg = "Has Errors in Details."
3604 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3605 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3606
3607 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3608 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3609 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3610 ENDIF
3611
3612 SELECT tcBadOrders
3613 IF THIS.lUserInterface
3614 * Init Thermometer
3615 THIS.InitThermo(lnBadOrderCount)
3616 l_nThermoCnt = 0
3617 ENDIF
3618 SCAN
3619 IF THIS.lUserInterface
3620 * Advance progress bar, if we're using one.
3621 l_nThermoCnt = l_nThermoCnt + 1
3622 THIS.AdvanceThermo(l_nThermoCnt)
3623 ENDIF
3624 SELECT (pceipoTH)
3625 IF pcEW = 'W'
3626 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3627 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3628 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3629 IN (pceipoTH)
3630 ENDIF
3631 ENDIF
3632 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3633 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3634 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3635 IN (pceipoTH)
3636 ENDIF
3637 ENDIF
3638 ELSE
3639 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3640 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3641
3642 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3643 IN (pceipoTH)
3644 ENDIF
3645 ENDIF
3646 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3647 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3648
3649 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3650 IN (pceipoTH)
3651 ENDIF
3652 ENDIF
3653 ENDIF
3654 ENDSCAN
3655 USE IN tcBadOrders
3656 USE IN tcBadOrdersSLN
3657
3658 IF THIS.lUserInterface
3659 THIS.ResetThermo()
3660 ENDIF
3661 SELECT(lnOldSelect)
3662 RETURN llRetVal
3663 ENDPROC
3664 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3665
3666 *-----------------------------------------------------------------------------------
3667
3668 *--- TR 1013007 NH
3669 *--- checks if pceipoTH.req_855 is 'R'
3670 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
3671 *--- if default status value is not empty then set Send855 flag to true and return true
3672 *--- if default status value is empty then set Send855 flag to true and return false and
3673 *--- set error message 'Missing 855 status code'
3674 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
3675 *--- then set Send855 flag to true and return false and
3676 *--- set error message 'Missing 855 status code'
3677
3678 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
3679 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
3680 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
3681 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
3682 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
3683
3684
3685 Procedure Check855Required
3686 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
3687
3688 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
3689 llRetVal = .T.
3690 lnOldSelect = Select()
3691 lcOldPO_num = ""
3692 lcPO_Status_855 = ""
3693 This.LogEntry("Starting procedure" + Program())
3694 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
3695
3696 *--- prepare detail zzeipotd for cascading status_855 code
3697 Select(pceipoTD)
3698 lnOldOrder_TD = Val(Sys(21)) && getting the current order
3699 Set Order To Tagno('FKEY') && settting order by 'fkey'
3700
3701 Select(pceipoTH)
3702 Scan For req_855 = 'R'
3703 Scatter Name loEiPOth Memo
3704 *--- when this.lSend855 flag is true then data will be sent to server
3705 This.lSend855 = .T.
3706
3707 *--- TR 1040432 MAY-20-2009 BR
3708 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
3709 If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
3710 *=== TR 1040432 MAY-20-2009 BR
3711 Select(pceipoCR)
3712 If Auto_855 = 'Y'
3713 If Not Empty(def_855)
3714 *--- set default value
3715 loEiPOth.status_855 = def_855
3716 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
3717 llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
3718 Else
3719 loEiPOth.Errs_flg_h = 'Y'
3720 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
3721 Endif
3722 Endif
3723 Endif
3724
3725 *--- status_855 code is still empty
3726 If Empty(loEiPOth.status_855)
3727 loEiPOth.Errs_flg_h = 'Y'
3728 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
3729 Endif
3730
3731 *--- check if defferent status_855 code exists in orders with same po number
3732 If lcOldPO_num <> loEiPOth.po_num
3733 lcOldPO_num = loEiPOth.po_num
3734 lcPO_Status_855 = loEiPOth.status_855
3735 Else
3736 If lcPO_Status_855 <> loEiPOth.status_855
3737 loEiPOth.Errs_flg_h = 'Y'
3738 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
3739 Endif
3740 Endif
3741
3742 *--- all records will only be get updated. No insert is need here.
3743 Select(pceipoTH)
3744 Gather Name loEiPOth Memo
3745
3746 If Not llRetVal
3747 Exit
3748 Endif
3749 Endscan
3750 *--- set back to old order by
3751 Select(pceipoTD)
3752 Set Order To (lnOldOrder_TD)
3753 *-- when one order is flaged error then all order of PO will be make
3754 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
3755 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
3756 Select(lnOldSelect)
3757 Return llRetVal
3758
3759 ENDPROC
3760
3761 *-----------------------------------------------------------------------------------
3762
3763 *--- must set order by 'FKey' in pceipoTD
3764 Procedure Cascade855AckCode
3765 Lparameters poeipoTH, pceipoTD
3766
3767 Local llRetVal, lnOldSelect
3768 lnOldSelect = Select()
3769 llRetVal = .T.
3770
3771 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
3772 Return .F.
3773 Endif
3774 *- 1034481 10/06/08 YIK
3775 *- Cascade ALL status codes to details.
3776 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
3777 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
3778 Select(pceipoTD)
3779 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
3780 Scan While fkey = poeipoTH.pkey
3781 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
3782 Endscan
3783 ENDIF
3784 *- 1034481
3785 *- Endif
3786
3787 Select(lnOldSelect)
3788 Return llRetVal
3789 Endproc
3790
3791 *----------------------------------------------------------------------------------------
3792 *--- TR 1034481 NH
3793 PROCEDURE MarkHeaderForMissing855ControlRef
3794 LPARAMETERS pceipoTH
3795
3796 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
3797
3798 llRetVal = .t.
3799 lnOldSelect = SELECT()
3800 lcZzeoprcr = "Oprcr" + SYS(2015)
3801 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
3802 llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
3803
3804 IF USED(lcZzeoprcr)
3805 INDEX on customer TAG customer
3806 INDEX on division TAG division
3807
3808 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
3809 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
3810 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
3811
3812 USE IN (lcZzeoprcr)
3813 ENDIF
3814
3815 SELECT(lnOldSelect)
3816 RETURN llRetVal
3817
3818 ENDPROC
3819 *=== TR 1034481 NH
3820 *----------------------------------------------------------------------------------------
3821
3822 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
3823
3824 Local laTables[4]
3825 laTables[1] = "VzzeiPOth_iPOproc"
3826 laTables[2] = "VzzeiPOtd_iPOproc"
3827 laTables[3] = "VzzeiPOts_iPOproc"
3828 * --- TR 1018184 RLN 1018184
3829 laTables[4] = "VzzeiPOtsac_iPOproc"
3830
3831 Local llRetVal, llBeganTransaction, loEiPOth
3832 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
3833 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
3834
3835 llRetVal = .T.
3836
3837 With This
3838 .LogEntry("Starting Program : " + Program())
3839 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
3840
3841 Select(pceipoTH)
3842 Scan
3843 Scatter Name loEiPOth Memo
3844 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
3845 Select('VzzeiPOth_iPOproc')
3846 Gather Name loEiPOth Memo
3847 Endif
3848 Endscan
3849
3850 Select(pceipoTD)
3851 Scan
3852 Scatter Name loEiPOtd Memo
3853 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
3854 Select('VzzeiPOtd_iPOproc')
3855 Gather Name loEiPOtd Memo
3856 Endif
3857 Endscan
3858
3859 Select(pceipoTS)
3860 Scan
3861 Scatter Name loeipoTS Memo
3862 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
3863 Select('VzzeiPOts_iPOproc')
3864 Gather Name loeipoTS Memo
3865 Endif
3866 Endscan
3867
3868 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
3869 If This.BeginTransaction()
3870 llRetVal = This.Tableupdate(@laTables)
3871 If llRetVal
3872 This.EndTransaction()
3873 Else
3874 This.RollbackTransaction()
3875 Endif
3876 Endif
3877 *--- close views.
3878 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
3879 Endwith
3880
3881 Return llRetVal
3882
3883 Endfunc
3884
3885 *----------------------------------------------------------------------------------------
3886
3887 Procedure Run855Process
3888 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
3889 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
3890 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
3891
3892 Local lnOldSelect, llRetVal, loStatusCur
3893 lnOldSelect = Select()
3894 llRetVal = .T.
3895 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
3896 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
3897 Local lcStatusCur, loStatus
3898 lcStatusCur = Sys(2015)
3899 With This
3900
3901 *--- TR 1044017 07-JAN-2010 HNISAR
3902*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
3903 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
3904 *=== TR 1044017 07-JAN-2010 HNISAR
3905
3906 .LogEntry("Starting program " + Program())
3907
3908 * --- TR 1048571 9/9/10 CM
3909 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
3910 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
3911 * === TR 1048571 9/9/10 CM
3912
3913 If llRetVal
3914 Select (lcStatusCur )
3915 Scatter Name loStatus
3916 Use In (lcStatusCur)
3917 ENDIF
3918 *- 1034481 10/03/08 YIK
3919 *- Check if there are no 855(o) to process
3920 llHas855ToSend = .T.
3921
3922 *--- req_855 must be more the status missing count
3923 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
3924 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
3925 *-- move 850 data to 855 transaction
3926 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
3927
3928 *- 1034481 10/03/08 YIK
3929 *- Added parameter pceipoTH and llHas855ToSend
3930 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
3931 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
3932 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
3933
3934 *--- TR 1044017 07-JAN-2010 HNISAR
3935*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
3936 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
3937 *===TR 1044017 07-JAN-2010 HNISAR
3938
3939 *- 1034481 10/03/08 YIK
3940 *- Check if there are no 855(o) to process
3941 IF llHas855ToSend
3942 *-- create flat files
3943 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
3944 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
3945 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
3946 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
3947
3948 *--- update 855 flag of 850 tran header
3949 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
3950
3951 *--- TR 1044017 07-JAN-2010 HNISAR
3952*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
3953 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
3954 *=== TR 1044017 07-JAN-2010 HNISAR
3955
3956 *--- drop temp tables
3957 *- 1030497 02/29/08 TT
3958 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
3959 *!* .dropTempTable(lceoprth,.T.)
3960 *!* .dropTempTable(lceoprtd,.T.)
3961 *!* .dropTempTable(lceoprtc,.T.)
3962 *!* .dropTempTable(lceoprta,.T.)
3963 *!* .dropTempTable(lceoprth_notes,.T.)
3964 *!* .dropTempTable(lceoprtd_notes,.T.)
3965 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
3966 .oCopyUtil.dropTempTable(lceoprth,.T.)
3967 .oCopyUtil.dropTempTable(lceoprtd,.T.)
3968 .oCopyUtil.dropTempTable(lceoprtc,.T.)
3969 .oCopyUtil.dropTempTable(lceoprta,.T.)
3970 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
3971 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
3972
3973 *- 1034481 10/03/08 YIK
3974 ELSE
3975 .LogEntry("No 855(o) transaction data to send.")
3976 ENDIF
3977 *= 1034481 *- 1030497 02/29/08 TT
3978 Endif
3979
3980 *- 1034481 10/03/08 YIK
3981 *- Added ..AND loStatus.STATUS_855_MISSING > 0
3982 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
3983 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
3984 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
3985 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
3986 .oHostProcess.c855Msg
3987 Endif
3988 Release loStatus
3989 Endwith
3990
3991 Select(lnOldSelect)
3992 Return llRetVal
3993
3994 Endfunc
3995
3996 *----------------------------------------------------------------------------------------
3997
3998 Procedure get855Status
3999 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4000 Lparameters tcCursor, pceipoTH
4001
4002 * --- TR 1048571 9/9/10 CM
4003 *Local lcSQL, lnOldSelect,llRetVal
4004 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4005
4006 lceipoth = "#Ipoth" + SYS(2015)
4007 * === TR 1048571 9/9/10 CM
4008
4009 lnOldSelect = Select()
4010 llRetVal = .T.
4011
4012 * --- TR 1048571 9/9/10 CM
4013 With This
4014 .cSQLTempTable=""
4015 IF .GenerateSQLTempTable(pceipoTH)
4016 IF .PopulateSQLTempTable(pceipoTH)
4017 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4018 llRetVal = llRetVal And v_SqlExec(lcSQL)
4019 ENDIF
4020 ENDIF
4021 Endwith
4022 * === TR 1048571 9/9/10 CM
4023
4024 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4025 lcSQL = " select sum(1) rec_count, " + ;
4026 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4027 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4028 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4029 " from " + lceipoth + " h " + This.cFilterCriteria
4030
4031 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4032 Select(lnOldSelect)
4033 Return llRetVal
4034 Endproc
4035
4036 *----------------------------------------------------------------------------------------
4037
4038 Procedure MoveTo855TempTransaction
4039 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4040 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4041 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4042
4043 Local llRetVal, lnOldSelect
4044 lnOldSelect = Select()
4045 llRetVal = .T.
4046 With This
4047 *--- create temporary 855 transaction tables at server
4048 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4049 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4050
4051 *--- copy data from 850 trans table to 855 temp trans tables
4052 *- 1034481 10/03/08 YIK
4053 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4054 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4055 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4056
4057 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4058 IF plHas855ToSend
4059 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4060 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4061
4062 *--- update header division from detail
4063 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4064 ENDIF
4065 *= 1034481
4066 Endwith
4067
4068 Select(lnOldSelect)
4069 Return llRetVal
4070
4071 Endproc
4072
4073 *----------------------------------------------------------------------------------------
4074
4075 Procedure CreateOPRTempTables
4076 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4077
4078 Local llRetVal, lnOldSelect, lcUnique
4079 lnOldSelect = Select()
4080 llRetVal = .T.
4081 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4082 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4083 AND Vartype(pcRefeoprtd_notes) == "C" )
4084
4085 lcUnique = Sys(2015)
4086 With This
4087 .LogEntry("Starting " + Program())
4088 .LogEntry("Creating OPR Temp Tables.")
4089
4090 *--- zzeipoth
4091 pcRefeoprth = "#zzeoprth" + lcUnique
4092 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4093 llRetVal = llRetVal And v_SqlExec(lcSQL)
4094
4095 *--- TR 1044208
4096 .oHostProcess.AddToTempTables(pcRefeoprth)
4097 *=== TR 1044208
4098
4099 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4100 *--- zzeipotd
4101 pcRefeoprtd = "#zzeoprtd" + lcUnique
4102 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4103 llRetVal = llRetVal And v_SqlExec(lcSQL)
4104 *--- TR 1044208
4105 .oHostProcess.AddToTempTables(pcRefeoprtd)
4106 *=== TR 1044208
4107 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4108
4109 *--- zzeipotc
4110 pcRefeoprtc = "#zzeoprtc" + lcUnique
4111 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4112 llRetVal = llRetVal And v_SqlExec(lcSQL)
4113 *--- TR 1044208
4114 .oHostProcess.AddToTempTables(pcRefeoprtc )
4115 *=== TR 1044208
4116 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4117
4118 *--- zzeipota
4119 pcRefeoprta = "#zzeoprta" + lcUnique
4120 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4121 llRetVal = llRetVal And v_SqlExec(lcSQL)
4122 *--- TR 1044208
4123 .oHostProcess.AddToTempTables(pcRefeoprta )
4124 *=== TR 1044208
4125 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4126
4127 *---- sysnotes_oprth
4128 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4129 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4130 llRetVal = llRetVal And v_SqlExec(lcSQL)
4131 *--- TR 1044208
4132 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4133 *=== TR 1044208
4134 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4135
4136 *---- sysnotes_oprtd
4137 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4138 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4139 llRetVal = llRetVal And v_SqlExec(lcSQL)
4140 *--- TR 1044208
4141 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4142 *=== TR 1044208
4143 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4144
4145 Endwith
4146
4147 Select(lnOldSelect)
4148 Return llRetVal
4149
4150 Endproc
4151
4152 *----------------------------------------------------------------------------------------
4153
4154 Procedure IPODataToOPRTmpTable
4155 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4156 pceipoTD
4157 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4158 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4159 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4160
4161 lcOPR_TMP = ""
4162 lnOldSelect = Select()
4163 llRetVal = .T.
4164 lcCommonFields = ""
4165 lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4166 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4167 lcLeftOnlyDefaults = ""
4168 lcLeftOnlyFields = ""
4169 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4170
4171 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4172
4173 * --- TR 1048571 9/9/10 CM
4174 lcipotd = "#Zzeipotd" + SYS(2015)
4175 * === TR 1048571 9/9/10 CM
4176
4177 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4178
4179 With This
4180 *-- TR 1044604 DEC-29-2009 BR
4181 .cSQLTempTable=""
4182 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4183*!* IF .GenerateSQLTempTable(pceipoTH)
4184*!* IF .PopulateSQLTempTable(pceipoTH)
4185 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4186 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4187 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4188
4189 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4190 &lcCmnd
4191
4192*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4193 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4194 IF .GenerateSQLTempTable(lcTempIPOTH)
4195
4196 IF .PopulateSQLTempTable(lcTempIPOTH)
4197 Use In Select(lcTempIPOTH)
4198 *=== TR 1043191 23-Oct-2009 JK ===
4199 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4200 llRetVal = llRetVal And v_SqlExec(lcSQL)
4201 ENDIF
4202 ENDIF
4203 *== TR 1044604 DEC-29-2009 BR
4204
4205 * --- TR 1048571 9/9/10 CM
4206 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4207 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4208 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4209 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4210 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4211 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4212 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4213 *.ScatterGather(pceipoTD, "tcIpoDtls")
4214 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4215 .ScatterGather("__tceipoTD", "tcIpoDtls")
4216 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4217
4218 SELECT tcIpoDtls
4219 LOCATE
4220 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4221 .cSQLTempTable=""
4222 IF .GenerateSQLTempTable("tcFinalDtls")
4223 IF .PopulateSQLTempTable("tcFinalDtls")
4224 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4225 llRetVal = llRetVal And v_SqlExec(lcSQL)
4226 ENDIF
4227 ENDIF
4228 * === TR 1048571 9/9/10 CM
4229
4230 *--- IPOTH -> OPRTH
4231 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4232 *--- lcCalFldsOPR : fields need calculation or map or constant values
4233 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4234
4235 *--- for example if term_type field data will go to terms_type field and blank term_type
4236 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4237 *!* lcCalFldsOPR = "term_type, terms_type"
4238 *!* lcCalFldsOPR_val = "' ',term_type"
4239 lcCalFldsOPR_SQL = "'PROC_855'"
4240 lcCalFldsOPR = "PROC_855"
4241 lcCalFldsOPR_val = "' '"
4242 lcFlds = ""
4243 lcValues = ""
4244
4245 lcOPR_TMP = pceoprth
4246 *- 1030497 02/29/08 TT
4247 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4248 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4249
4250 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4251 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4252 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4253 *- 1030497 02/29/08 TT
4254 *--- 1034481 set correct flag value 'P' for Proc_855
4255 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4256 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4257 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4258 llRetVal = llRetVal And v_SqlExec(lcSQL)
4259
4260 *--- IPOTD -> OPRTD
4261 lcCalFldsOPR_SQL = ""
4262 lcCalFldsOPR = ""
4263 lcCalFldsOPR_val = ""
4264 lcFlds = ""
4265 lcValues = ""
4266
4267 lcOPR_TMP = pceoprtd
4268 *- 1030497 02/29/08 TT
4269 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4270 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4271 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4272 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4273 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4274 *- 1030497 02/29/08 TT
4275 *- 1034481 10/03/08 YIK
4276 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4277 DECLARE la855Cnt[1]
4278 la855Cnt[1] = 0
4279 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4280 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4281 " INTO ARRAY la855Cnt"
4282 &lcSQL
4283
4284 plHas855ToSend = (la855Cnt[1] > 0)
4285
4286 IF plHas855ToSend
4287 *--- 1034481 set correct flag value 'P' for Proc_855
4288 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4289 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4290 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4291 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4292 " ( select * from " + lcipoth + " h " + lcFilter + ;
4293 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4294
4295 llRetVal = llRetVal And v_SqlExec(lcSQL)
4296
4297 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4298 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4299 " on d.fkey = h.pkey "
4300 llRetVal = llRetVal And v_SqlExec(lcSQL)
4301
4302 *--- IPOTC -> OPRTC
4303 lcOPR_TMP = pceoprtc
4304 lcCalFldsOPR_SQL = ""
4305 lcCalFldsOPR = ""
4306 lcCalFldsOPR_val = ""
4307 lcFlds = ""
4308 lcValues = ""
4309
4310 *- 1030497 02/29/08 TT
4311 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4312 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4313 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4314 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4315 *- 1030497 02/29/08 TT
4316 *--- 1034481 set correct flag value 'P' for Proc_855
4317 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4318 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4319 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4320 " (select * from " + lcipoth + " h " + lcFilter + ;
4321 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4322
4323 llRetVal = llRetVal And v_SqlExec(lcSQL)
4324
4325 *--- IPOTA -> OPRTA
4326 lcOPR_TMP = pceoprta
4327 lcCalFldsOPR_SQL = ""
4328 lcCalFldsOPR = ""
4329 lcCalFldsOPR_val = ""
4330 lcFlds = ""
4331 lcValues = ""
4332
4333 *- 1030497 02/29/08 TT
4334 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4335 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4336 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4337 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4338 *- 1030497 02/29/08 TT
4339 *--- 1034481 set correct flag value 'P' for Proc_855
4340
4341 *--- 1042063 10/12/09 CM
4342 *--- We're unconditionally going to remove characters greater than 25,
4343 * for 855 address1,address2 fields since max field size is 25.
4344 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4345 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4346 *=== 1042063 10/12/09 CM
4347
4348 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4349 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4350 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4351 " (select * from " + lcipoth + " h " + lcFilter + ;
4352 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4353
4354 llRetVal = llRetVal And v_SqlExec(lcSQL)
4355
4356 *--- sysnotes - zzeoprth
4357 lcOPR_TMP = pceoprth_notes
4358 *--- 1034481 set correct flag value 'P' for Proc_855
4359 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4360 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4361 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4362 " (select * from " + lcipoth + " h " + lcFilter + ;
4363 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4364
4365 llRetVal = llRetVal And v_SqlExec(lcSQL)
4366
4367 *--- sysnotes - zzeoprtd
4368 lcOPR_TMP = pceoprtd_notes
4369 *--- 1034481 set correct flag value 'P' for Proc_855
4370 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4371 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4372 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4373 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4374 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4375 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4376 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4377
4378 llRetVal = llRetVal And v_SqlExec(lcSQL)
4379 *- 1034481 10/03/08 YIK
4380 ENDIF &&plHas855ToSend
4381
4382 *-- TR 1044604 DEC-29-2009 BR
4383 lcSQL = "DROP TABLE " + lcipoth
4384 v_SqlExec(lcSQL)
4385 *== TR 1044604 DEC-29-2009 BR
4386 Endwith
4387
4388 * --- TR 1048571 9/9/10 CM
4389 USE IN SELECT("tcIpoDtls")
4390 USE IN SELECT("tcFinalDtls")
4391 USE IN SELECT("tcTmpDtls")
4392 * === TR 1048571 9/9/10 CM
4393
4394 Select(lnOldSelect)
4395 Return llRetVal
4396 Endproc
4397
4398
4399 *----------------------------------------------------------------------------------------
4400
4401 Procedure ResetPkey_OPRTmpTable
4402 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4403
4404 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4405 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4406
4407 lnOldSelect = Select()
4408 llRetVal = .T.
4409 lcOPR_TMP = pceoprth
4410 lnRecCount = 0
4411 lnMaxPkey = 0
4412 lcUnique = Sys(2015)
4413
4414 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4415 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4416 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4417 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4418 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4419 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4420 lcNewPkeyCol_TH = "PKEY_OPRTH"
4421 lcNewPkeyCol_TD = "PKEY_OPRTD"
4422 With This
4423 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4424 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4425 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4426 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4427 *- 1030497 02/29/08 TT
4428 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4429 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4430 *- 1030497 02/29/08 TT
4431
4432 *--- fkey updates for all chield tables
4433 *--- ipotd -> oprtd : fkey
4434 lcOPR_TMP = pceoprtd
4435 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4436 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4437 llRetVal = llRetVal And v_SqlExec(lcSQL)
4438
4439 *--- ipota -> oprta : fkey
4440 lcOPR_TMP = pceoprta
4441 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4442 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4443
4444 llRetVal = llRetVal And v_SqlExec(lcSQL)
4445
4446 *--- ipotc -> oprtc : fkey
4447 lcOPR_TMP = pceoprtc
4448 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4449 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4450 llRetVal = llRetVal And v_SqlExec(lcSQL)
4451
4452 *-- sysnotes :
4453 *-- table_name
4454 lcOPR_TMP = pceoprth_notes
4455 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4456 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4457 llRetVal = llRetVal And v_SqlExec(lcSQL)
4458
4459 *-- update detail pkey
4460 *- 1030497 02/29/08 TT
4461 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4462 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4463 *- 1030497 02/29/08 TT
4464
4465 *-- sysnotes : update table_name, fkey
4466 lcOPR_TMP = pceoprtd_notes
4467 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4468 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4469 llRetVal = llRetVal And v_SqlExec(lcSQL)
4470
4471 *--- update header notes pkey
4472 *- 1030497 02/29/08 TT
4473 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4474 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4475 *- 1030497 02/29/08 TT
4476 *--- update detail notes pkey
4477 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4478 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4479
4480 *-- update pkey
4481 *- 1030497 02/29/08 TT
4482 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4483 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4484
4485 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4486 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4487 *- 1030497 02/29/08 TT
4488
4489 *--- drop all temp tables
4490 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4491 *- 1030497 02/29/08 TT
4492 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4493 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4494 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4495 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4496 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4497
4498 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4499 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4500 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4501 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4502 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4503 *- 1030497 02/29/08 TT
4504
4505 Endwith
4506
4507 Select(lnOldSelect)
4508 Return llRetVal
4509 Endproc
4510
4511 *----------------------------------------------------------------------------------------
4512
4513 Procedure UpdateOPRTempHDRDivisionFromDtl
4514 Lparameters pcRefeoprth,pcRefeoprtd
4515
4516 Local llRetVal, lnOldSelect
4517 llRetVal = .T.
4518 lnOldSelect = Select()
4519 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4520 llRetVal = llRetVal And v_SqlExec(lcSQL)
4521 Select(lnOldSelect)
4522 Return llRetVal
4523
4524 Endproc
4525
4526 *----------------------------------------------------------------------------------------
4527
4528 Procedure Launch855Process
4529 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4530 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4531 Local llRetVal, lnOldSelect
4532 lnOldSelect = Select()
4533 llRetVal = .T.
4534
4535 Local lo855
4536 Local lc855DataTbls, lc855Msg
4537 lcFilterCriteria = ""
4538 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4539 llRetVal = (Vartype(lo855) = 'O')
4540 lc855Msg = ""
4541
4542 If llRetVal
4543 *--- TR 1037976 JAN-22-2008 BR
4544 *lo855 = This
4545 lo855.oLog = THIS.oLog
4546 *=== TR 1037976 JAN-22-2008 BR
4547 lo855.oFrmProgressBar = This.oFrmProgressBar
4548 Endif
4549 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4550 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4551 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4552 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4553 This.oHostProcess.c855Msg = lc855Msg
4554 Select(lnOldSelect)
4555 Return llRetVal
4556
4557 Endproc
4558
4559 *----------------------------------------------------------------------------------------
4560
4561 Procedure Update855ProcFlag
4562 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4563
4564 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4565 lnOldSelect = Select()
4566 llRetVal = .T.
4567 lcCursor = Sys(2015)
4568 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4569 *--- 1034481 set correct flag value 'P' for Proc_855
4570 *- 1034481 10/03/08 YIK
4571 *- Also populate error flag and error message from zzeoprth to the 850(i)
4572 *- otherwise 850(i) goes through while the 855(o) errors out.
4573 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4574 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4575 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4576 " t on o.pkey = t.pkey_oprth" + ;
4577 " LEFT JOIN zzeoprth th " + ;
4578 " on th.pkey = t.pkey_oprth"
4579
4580 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4581 If llRetVal
4582 Select (lcCursor)
4583 SCAN
4584 Scatter Name loCursor Memo
4585 DO CASE
4586 CASE proc_855 = 'P'
4587 *- 1014298 12/02/05 YIK, NH
4588 *- it was ..proc_855 WITH 'Y'
4589 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4590 CASE errs_flg_h = 'Y'
4591 REPLACE errs_flg_h WITH 'Y', ;
4592 errs_msg_h WITH errs_msg_h + ;
4593 " ---- 855(o) process ----" + CRLF + ;
4594 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4595 For pkey = loCursor.pkey In (pceipoTH)
4596 OTHERWISE
4597 ENDCASE
4598 Endscan
4599 Endif
4600 *= 1034481
4601 Select(lnOldSelect)
4602 Return llRetVal
4603
4604 Endproc
4605
4606 *----------------------------------------------------------------------------------------
4607
4608 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4609
4610 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4611 *!* In this case label must be with empty.
4612
4613 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4614
4615 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4616 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4617 *!* style '9040' color 'RED' label 'WM'.
4618
4619 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4620 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4621 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4622
4623 Procedure CheckMultiUPC
4624 Lparameters tcEiPOth, tcEiPOtd
4625
4626 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
4627
4628 llRetVal = True
4629 lnSelect = Select()
4630
4631 With This
4632
4633 lcWorkAlias = GetUniqueFileName()
4634
4635 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4636 *-- Change h.division to d.division
4637 SELECT d.pkey, ;
4638 h.customer, ;
4639 d.division, ;
4640 d.upc ;
4641 FROM tceipoth h ;
4642 JOIN tceipotd d ;
4643 ON h.pkey = d.fkey ;
4644 INTO ;
4645 CURSOR (lcworkAlias)
4646
4647 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
4648 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
4649 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
4650 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
4651
4652 If llRetVal
4653
4654 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4655 *-- Included 'V' in the condition of pocr.resv_label
4656 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
4657 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
4658
4659 lcSql = " SELECT upcd.lbl_code, t.* " + ;
4660 " FROM " + lcTempTbl + " t " + ;
4661 " JOIN zzemupch upch " + ;
4662 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
4663 " JOIN zzemupcd upcd " + ;
4664 " ON upch.pkey = upcd.fkey " + ;
4665 " AND upcd.active_ok = 'Y' " + ;
4666 " JOIN " + This.c850Control + " pocr " + ;
4667 " ON pocr.customer = t.customer " + ;
4668 " AND pocr.division = t.division " + ;
4669 " AND pocr.lbl_code = upcd.lbl_code " + ;
4670 " AND pocr.resv_label IN ('Y','V') "
4671
4672 lcWorkAlias = GetUniqueFileName()
4673
4674 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
4675
4676 If Reccount(lcWorkAlias) > 0
4677 Select (tcEiPOtd)
4678 Scan
4679 lnPKey = pkey
4680
4681 Select(lcWorkAlias)
4682 Locat For pkey = lnPKey
4683
4684 If Found()
4685 lcLbl_code = lbl_code
4686 Select (tcEiPOtd)
4687 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
4688 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
4689 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
4690 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
4691 Endif
4692
4693 Select (tcEiPOtd)
4694 Endscan
4695 Endif
4696
4697 Endif
4698
4699 .TableClose(lcWorkAlias)
4700
4701 Endwith
4702
4703 Select (lnSelect)
4704 Return llRetVal
4705 Endproc
4706 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
4707
4708 *----------------------------------------------------------------------------------------
4709
4710 Procedure RangeStyle
4711 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
4712 Local llRetVal, lnOldSelect, lcErrs_Msg
4713 llRetVal = .T.
4714 lnOldSelect = Select()
4715
4716 *****************************************************************************
4717 * 1st Getting all range style (hdr/dtl) that relate to the
4718 * passing order line for this run
4719
4720 *--- TR 1038376 05-May-2009 Goutam
4721 LOCAL lctmpCursor
4722 lctmpCursor = GetUniqueFileName()
4723
4724 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
4725 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
4726
4727 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
4728 * TR 1059142 FH - adding h.ord_type to the group by clause
4729 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type FROM (pcTransHeader) h ;
4730 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4731 WHERE d.errs_flg_d <> 'Y' ;
4732 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
4733 INTO CURSOR __TmpCursor
4734
4735 .cSQLTempTable=""
4736 If .GenerateSQLTempTable('__TmpCursor')
4737 If .PopulateSQLTempTable('__TmpCursor')
4738 If !Empty(.cSQLTempTable)
4739 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4740 lcSqlString = "Update " + .cSQLTempTable + ;
4741 " Set price_code = coalesce((Select Top 1 price_code " + ;
4742 " From zzxcslsr " + ;
4743 " Where Customer = h.customer " + ;
4744 " and (Store = h.store or Store = '') " + ;
4745 " and (Division = h.division or Division = '') " + ;
4746 " and (Department = h.department or Department = '') " + ;
4747 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4748 " and price_code <> '' " + ;
4749 " order by rank_seq),'') " + ;
4750 " From " + .cSQLTempTable + " h"
4751
4752 llRetVal = v_sqlExec(lcSqlString)
4753
4754 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
4755 lcSqlString = "UPDATE " + .cSQLTempTable + ;
4756 " Set price_code = c.price_code "+;
4757 " From " + .cSQLTempTable + " h "+;
4758 " , zzocntrc c "+;
4759 " Where h.division = c.division " +;
4760 " and h.price_code = '' "
4761 llRetVal = v_sqlExec(lcSqlString)
4762 *- TR 1056061 FH 08/17/11
4763
4764
4765 IF llRetVal
4766 lcSqlString = "Select * from " + .cSQLTempTable
4767 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
4768
4769 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
4770 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4771*!* lcSqlString = "UPDATE h " + ;
4772*!* " SET price_code = c.price_code " + ;
4773*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
4774*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
4775*!* " on d.division = c.division " + ;
4776*!* " And d.customer = c.customer " + ;
4777*!* " And h.Store = c.Store " + ;
4778*!* " And h.department = c.department " + ;
4779*!* " And h.ord_type = c.ord_type " + ;
4780*!* "Where d.errs_flg_d <> 'Y' "
4781
4782 lcSqlString = "UPDATE h " + ;
4783 " SET price_code = c.price_code " + ;
4784 " From " + pcTransheader + " h " + ;
4785 " join " + lcTmpCursor + " c " + ;
4786 " on h.division = c.division " + ;
4787 " And h.customer = c.customer " + ;
4788 " And h.Store = c.Store " + ;
4789 " And h.department = c.department " + ;
4790 " And h.ord_type = c.ord_type " + ;
4791 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
4792
4793 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
4794
4795 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
4796 ENDIF
4797
4798 IF llRetVal
4799 *-1061331 FH - simpilifed update query
4800 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
4801 *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 ;
4802 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4803 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4804 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4805
4806 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 ;
4807 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
4808
4809 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
4810 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
4811 *- TR 1054873 FH - changed error message
4812 &&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 ;
4813 &&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 ;
4814 *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 ;
4815 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4816 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4817 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4818 ENDIF
4819
4820 endif
4821 endif
4822 endif
4823 .cSQLTempTable=""
4824
4825 *=== TR 1038376 05-May-2009 Goutam
4826
4827 * additional past for range style verification/explotion
4828 *-- TR 1023892 5-3-07 BR
4829 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
4830 IF .lALLOW_RANGE_HDR_LABEL
4831 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
4832 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
4833 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 ;
4834 FROM (pcTransHeader) h, (pcTransDetail) d ;
4835 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
4836 AND d.Errs_Flg_D= 'N' AND ;
4837 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
4838 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
4839 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
4840 ELSE
4841 *=== TR 1023892 NH
4842 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
4843 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
4844 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
4845 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
4846 FROM (pcTransHeader) h, (pcTransDetail) d ;
4847 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
4848 And d.Errs_Flg_D= "N" And ;
4849 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
4850 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
4851 Order By 1,2,3,4,5 Into Cursor __TmpCursor
4852 ENDIF && TR 1023892 NH
4853
4854 With This
4855 .cSQLTempTable=""
4856 If .GenerateSQLTempTable('__TmpCursor')
4857 If .PopulateSQLTempTable('__TmpCursor')
4858 If !Empty(.cSQLTempTable)
4859
4860 .LogEntry("Exploding range style.")
4861 * Get range style header
4862 *- 1000984 9/11/03 YIK
4863 *- do not explode range styles type 'P'rint
4864 *- Added ..and h.rng_type <> 'P'
4865 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
4866 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
4867 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
4868 IF .lALLOW_RANGE_HDR_LABEL
4869 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
4870 "Where h.division= t.division and h.rng_style = t.style and "+;
4871 "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 "+;
4872 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
4873 ELSE
4874 *=== TR 1023892 NH
4875 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
4876 "Where h.division= t.division and h.rng_style = t.style and "+;
4877 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
4878 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
4879 *= 1000984
4880 ENDIF && TR 1023892 NH
4881 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
4882
4883 * TAN 31891 - JAZ - 5/20/02
4884 * llHaveRangeStyleToExplode= Recc("__RangH")>0
4885 llHaveRangeStyleToExplode= RecCount("__RangH")>0
4886 * End TAN 31891 - JAZ - 5/20/02
4887
4888 If llHaveRangeStyleToExplode
4889 * Get range style detail
4890 *- 1000984 9/11/03 YIK
4891 *- do not explode range styles type 'P'rint
4892 *- Added ..and h.rng_type <> 'P'
4893
4894 *--- TR 1038376 05-May-2009 Goutam
4895 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
4896
4897 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
4898 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
4899*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
4900*!* " case t.price_code when 'A' then h.a_price " + ;
4901*!* " when 'B' then h.b_price " + ;
4902*!* " when 'C' then h.c_price " + ;
4903*!* " when 'D' then h.d_price " + ;
4904*!* " when 'E' then h.e_price " + ;
4905*!* " else h.a_price end rnghdr_Price " + ;
4906*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
4907*!* "join " + .cSQLTempTable + " t " +;
4908*!* "on h.division= t.division and h.rng_style = t.style and "+;
4909*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
4910*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
4911*!* " (case t.price_code when 'A' then h.a_price " + ;
4912*!* " when 'B' then h.b_price " + ;
4913*!* " when 'C' then h.c_price " + ;
4914*!* " when 'D' then h.d_price " + ;
4915*!* " when 'E' then h.e_price " + ;
4916*!* " else h.a_price end " + ;
4917*!* " <> t.org_price)" +;
4918*!* " AND t.sizebucket = h.rng_bk"
4919
4920 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
4921 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
4922 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
4923 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
4924 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
4925 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
4926 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
4927 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
4928 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
4929 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
4930
4931 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
4932 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
4933 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
4934 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
4935 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
4936 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
4937 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
4938 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
4939 " Left join zzxcsrgh cs "+ ;
4940 " on cs.hdrpkey = h.pkey "+ ;
4941 " and cs.dtlpkey = 0 " +;
4942 "join " + .cSQLTempTable + " t " +;
4943 "on h.division= t.division and h.rng_style = t.style and "+;
4944 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
4945 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
4946 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
4947 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
4948 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
4949 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
4950 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
4951 " else coalesce(cs.a_price,h.a_price) end " + ;
4952 " <> t.org_price)" +;
4953 " AND t.sizebucket = h.rng_bk"+ ;
4954 " Where cs.customer = t.customer "
4955 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
4956 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
4957
4958 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
4959 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
4960 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) " + ;
4961 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
4962 " on d.division= r.division and d.style = r.rng_style and " + ;
4963 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
4964 " d.dimension= r.Rng_Pack " + ;
4965 " join zzeipocr c on c.division = d.division and h.customer = c.customer " + ;
4966 "where d.rng_type <> 'P' AND c.price_err = 'Y' AND r.sizebucket = d.sizebucket"
4967
4968 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
4969
4970 *- TR 1048790 FH 10/04/10
4971 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
4972 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
4973 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
4974
4975 IF .lALLOW_RANGE_HDR_LABEL
4976 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 ;
4977 FROM (pcTransHeader) h, (pcTransDetail) d ;
4978 WHERE h.pkey = d.fkey ;
4979 AND d.Errs_Flg_D= 'N' AND ;
4980 Not EMPTY(h.price_code) AND ;
4981 d.rng_style= '' ;
4982 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
4983 ELSE
4984 *--- TR 1084745 02/25/15 JJANAND/ATHIRUNAVU Added h.customer
4985 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
4986 FROM (pcTransHeader) h, (pcTransDetail) d ;
4987 WHERE h.pkey = d.fkey ;
4988 And d.Errs_Flg_D= "N" And ;
4989 Not EMPTY(h.price_code) AND ;
4990 d.rng_style= '' ;
4991 Order By 1,2,3,4,5 Into Cursor __TmpCursor
4992 ENDIF
4993
4994 .cSQLTempTable=""
4995 If .GenerateSQLTempTable('__TmpCursor')
4996 If .PopulateSQLTempTable('__TmpCursor')
4997 *- TR 1048790 FH 10/04/10
4998
4999 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5000 *-- TR 1040759 JUN-29-2009 BR
5001 IF .lALLOW_RANGE_HDR_LABEL
5002 *- TR 1048790 FH 10/04/10 - removed price check
5003 *- TR 1050589 12/13/10 FH
5004 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5005*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5006*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5007*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5008*!* "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 "+;
5009*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5010 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5011*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5012*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5013*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5014*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5015*!* "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 "+;
5016*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5017
5018 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5019 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5020 "join " + .cSQLTempTable + " t " +;
5021 "on h.division= t.division and h.rng_style = t.style and "+;
5022 "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 "+;
5023 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5024 " t.sizebucket = h.rng_bk"+ ;
5025 " Left join zzxcsrgh cs "+ ;
5026 " on cs.hdrpkey = h.pkey "+ ;
5027 " and cs.dtlpkey = d.pkey " +;
5028 " and cs.customer = t.customer " + ;
5029 " where d.fkey in " +;
5030 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5031 "Where h.division= t.division and h.rng_style = t.style and "+;
5032 "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 "+;
5033 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5034 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5035 *- TR 1050589 12/13/10 FH
5036 ELSE
5037 *== TR 1040759 JUN-29-2009 BR
5038 *- TR 1048790 FH 10/04/10 - removed price check
5039 *- TR 1050589 12/13/10 FH
5040 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5041
5042*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5043*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5044*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5045*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5046*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5047*!*
5048 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5049*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5050*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5051*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5052*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5053*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5054*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5055
5056 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5057 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5058 "join " + .cSQLTempTable + " t " +;
5059 "on h.division= t.division and h.rng_style = t.style and "+;
5060 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5061 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5062 " t.sizebucket = h.rng_bk"+ ;
5063 " Left join zzxcsrgh cs "+ ;
5064 " on cs.hdrpkey = h.pkey "+ ;
5065 " and cs.dtlpkey = d.pkey " +;
5066 " and cs.customer = t.customer " + ;
5067 " where fkey in " +;
5068 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5069 "Where h.division= t.division and h.rng_style = t.style and "+;
5070 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5071 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5072 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5073 *- TR 1050589 12/13/10 FH
5074 ENDIF && TR 1040759 JUN-29-2009 BR
5075 *=== TR 1038376 05-May-2009 Goutam
5076 endif &&- TR 1048790 FH 10/04/10
5077 ENDIF &&- TR 1048790 FH 10/04/10
5078
5079 *= 1000984
5080 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5081
5082 * turn Range detail to vertical (with sizebucket,size_desc)
5083 * have to explode in vertical format
5084 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5085 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5086 WHERE 0=1 Into Cursor __Range2
5087 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5088 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5089 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5090 If Used("__Range1")
5091 Use In __Range1
5092 Endif
5093 If Used("__Range2")
5094 Use In __Range2
5095 Endif
5096
5097 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5098 Select __RangH
5099 Index On pkey Tag pkey
5100 Select __RangD
5101 Index On division+Style Tag DivStyle
5102 Select tcRangeVer
5103 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5104 Set Order To RangeSKU
5105 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5106
5107 *****************************************************************************
5108 * 2). Validate "Run"- type of range style. divisible by range header qty
5109 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5110
5111 *****************************************************************************
5112 * 3). Explode range style only once good tran detail that have
5113 * matching range style. Vertical range style explosion
5114 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5115 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5116 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5117 Select Distinct d.pkey ;
5118 FROM __RangD r, (pcTransDetail) d ;
5119 WHERE d.Errs_Flg_D= "N" And ; &&no error
5120 d.rng_style= '' And ; &&never explode before
5121 r.division= d.division And r.rng_style = d.Style And ; && matching range
5122 r.rng_color= d.color_code And ;
5123 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
5124 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5125 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5126 INTO Cursor __DtlExpl
5127 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5128 Endif
5129 Endif
5130 Endif
5131 Endif
5132 Endif
5133 Endwith
5134
5135 If Used("__RangH")
5136 Use In __RangH
5137 Endif
5138 If Used("__RangD")
5139 Use In __RangD
5140 Endif
5141 If Used("tcRangeVer")
5142 Use In tcRangeVer
5143 Endif
5144 If Used("__DtlExpl")
5145 Use In __DtlExpl
5146 Endif
5147 If Used("__TmpCursor")
5148 Use In __TmpCursor
5149 Endif
5150
5151 *--- TR 1038376 05-May-2009 Goutam
5152 If Used("__RangTmpD")
5153 Use In __RangTmpD
5154 ENDIF
5155 this.TableClose(lcTmpCursor)
5156 *=== TR 1038376 05-May-2009 Goutam
5157
5158 Select(lnOldSelect)
5159 Return llRetVal
5160 Endproc
5161 *----------------------------------------------------------------------------------------
5162
5163 Procedure ExplodeRangeRef
5164 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5165 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5166 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5167
5168 lnOldSele= Select()
5169 lcDivStyle= ""
5170 * TAN 31891 - JAZ - 5/20/02
5171 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5172 lnSourceCnt= RecCount(pcRangeDetail)
5173 * End TAN 31891 - JAZ - 5/20/02
5174 llRetVal= .T.
5175 lnCurDtlFkey= 0
5176
5177 Select (pcRangeDetail)
5178 Set Order To DivStyle
5179 Scan
5180 *- 1009508 03/16/05 YIK
5181 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5182 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5183 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5184 *-- m.rng_type= &pcRangeHeader..rng_type
5185 *-- m.rng_qty= &pcRangeHeader..rng_qty
5186
5187 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5188 *-- m.coord_code= &pcRangeHeader..coord_code
5189 *-- m.rng_type= &pcRangeHeader..rng_type
5190 If lnCurDtlFkey<> fkey
5191 lnCurDtlFkey= fkey
5192 If Seek(fkey, pcRangeHeader , "PKEY")
5193 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5194 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5195 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5196 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5197 *= 1009508 YIK
5198 Else
5199 llRetVal = .F.
5200 Exit
5201 Endif
5202 Endif
5203
5204 * only run once per Div + Style
5205 If !(lcDivStyle == division + Style)
5206 lcDivStyle = division + Style
5207 * Insert a record for each size bucket with a caption *
5208 If !v_GetSizeHeadings(division, Style, "__xSizer")
5209 llRetVal = .F.
5210 Exit
5211 Endif
5212 Endif
5213
5214 Select (pcRangeDetail)
5215 Scatter Memvar Memo
5216 For lnSizePosition = 1 To goEnv.MaxBuckets
5217 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5218 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5219 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5220 m.sizebucket = lnSizePosition
5221 m.size_desc = lcSizeName
5222 m.total_qty = lnSizeQty
5223 If lnSizeQty > 0 && Only want buckets with activity!
5224 Insert Into (pcRangeDetailTarget) From Memvar
5225 Endif
5226 Endfor
5227
5228 Endscan
5229 This.TableClose("__xSizer")
5230 Select (pcRangeDetail)
5231 Select (lnOldSele)
5232 Return llRetVal
5233 Endproc
5234
5235 *----------------------------------------------------------------------------------------
5236
5237 Procedure ValidateRangeStyle
5238 Lparameters pcRangeStyle, pcTransDetail
5239 Local llRetVal, lnOldSelect, lcErrs_Msg
5240 llRetVal = .T.
5241 lnOldSelect = Select()
5242 lcErrs_Msg= "Total Units must be divisible by "
5243
5244 Select (pcRangeStyle)
5245 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5246 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5247 "division+style+color_code+lbl_code+dimension")
5248
5249 If llRetVal
5250 .LogEntry("Validating range style.")
5251 * Verify range style "R"un order in min multiple of rng_qty
5252 * no need for "S"et verification of range type --just explode to
5253 * range detail
5254 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5255 *- 1023438 04/06/07 YIK
5256 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5257 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5258 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5259 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5260 Errs_Flg_D With "Y" ;
5261 IN (pcTransDetail)
5262 Endif
5263 Endscan
5264 Endif
5265
5266 Set Relation To
5267 Select(lnOldSelect)
5268 Return llRetVal
5269 Endproc
5270
5271 *----------------------------------------------------------------------------------------
5272
5273 Procedure ExplodeRangeStyleVertical
5274 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5275 Local llRetVal, lnOldSelect, lcErrs_Msg
5276 llRetVal = .T.
5277 lnOldSelect = Select()
5278
5279 * --- TR 1034963 12/15/08 CM
5280 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5281 * === TR 1034963 12/15/08 CM
5282
5283 Select (pcDetailtoExplode)
5284 Scan
5285 * Find detail line that need range style exploding using PKEY
5286 If Seek(pkey, pcTransDetail, "Pkey")
5287 * Current working trans detail
5288 Select (pcTransDetail)
5289
5290
5291 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5292 *-- TR 1040759 JUN-29-2009 BR
5293*!* IF !EMPTY(lbl_code)
5294*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5295*!* ELSE
5296*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5297*!* ENDIF
5298 *== TR 1040759 JUN-29-2009 BR
5299 IF .lALLOW_RANGE_HDR_LABEL
5300
5301 IF !EMPTY(lbl_code)
5302 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5303
5304 else
5305 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5306 ENDIF
5307 else
5308
5309 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5310
5311 endIF
5312 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5313
5314 lnCurDtlTotal_qty= total_qty
5315
5316 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5317 *- 1009508 3/16/05 YIK
5318 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5319 lnRangeBucket = sizebucket
5320
5321 Scatter Name loTransDetail Memo
5322
5323 *--- TR 1038376 16-Feb-2009 Goutam
5324 loTransDetail.Rng_Price = loTransDetail.org_price
5325 *--- TR 1038376 16-Feb-2009 Goutam
5326
5327 * delete current working trans detail already have image
5328 * in loTransDetail
5329 Delete In (pcTransDetail)
5330
5331 * --- TR 1034963 12/15/08 CM
5332 lnDetailPkey = loTransDetail.pkey
5333 * === TR 1034963 12/15/08 CM
5334
5335 * --- TR 1018184 RLN 01/10/07
5336 lnDetailPkey = loTransDetail.pkey
5337 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5338 * === TR 1018184
5339
5340 Select (pcRangeDetailVert)
5341 * Find 1st match of OURSKU
5342 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5343 * calculate lnMultiplier regardless of rng_type
5344 * --"R"un only divisible by rng_qty will get to this point
5345 * --otherwise will stay in errs_dtl_F/msg
5346
5347 *- 1009508 3/16/05 YIK
5348 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5349 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5350 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5351 lnCurDtlTotal_qty/rng_qty)
5352
5353 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5354 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5355 * Exploding detail line
5356 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5357 If !Empty(loTransDetail.pkey)
5358
5359 * --- TR 1034963 12/15/08 CM
5360 lcDetailNotes = GetUniqueFileName()
5361 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey)
5362 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5363 * === TR 1034963 12/15/08 CM
5364
5365 *- 1009508 3/16/05 YIK
5366 Select (pcRangeDetailVert)
5367 Scatter Name loVert Memo
5368 *= 1009508
5369
5370 Select (pcTransDetail)
5371 Append Blank
5372 Gather Name loTransDetail Memo
5373
5374 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5375 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5376 * only recording a..e_price to zzeipoth and resetting org_price
5377 *org_price with &pcRangeDetailVert..a_price,
5378
5379 *- 1009508 3/16/05 YIK
5380 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5381 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5382 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5383 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5384 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5385 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5386 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5387 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5388 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5389 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5390 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5391 *-- division WITH &pcRangeDetailVert..division, ;
5392 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5393 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5394 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5395 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5396 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5397 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5398 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5399 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5400 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5401 *-- e_price WITH &pcRangeDetailVert..e_price ;
5402 *-- IN (pcTransDetail)
5403
5404 *- 1022149 03/06/07 YIK
5405 *- do not zero out org_price for MultiUPC
5406 Replace rng_style With loVert.rng_style, ;
5407 rng_color With loVert.rng_color, ;
5408 rng_lbl With loVert.rng_lbl, ;
5409 rng_pack With loVert.rng_pack, ;
5410 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5411 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5412 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5413 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5414 total_qty With lnMultiplier * loVert.total_qty, ;
5415 sizebucket With loVert.sizebucket, ;
5416 size_desc With loVert.size_desc, ;
5417 division With loVert.division, ;
5418 STYLE With loVert.Style, ;
5419 color_code With loVert.color_code, ;
5420 lbl_code With loVert.lbl_code, ;
5421 DIMENSION With loVert.Dimension, ;
5422 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5423 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5424 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5425 a_price With loVert.a_price,; && 4186- store a..e_price
5426 b_price With loVert.b_price,; && from range style detail
5427 c_price With loVert.c_price,; && to use latter when have
5428 d_price With loVert.d_price,; && price_code
5429 e_price With loVert.e_price ;
5430 IN (pcTransDetail)
5431 *= 1009508 03/16/05 YIK
5432 * --- TR 1018184 RLN 01/10/07
5433 Select tmpRngSacs
5434 Scan
5435 Scatter Name loTmpSACs Memo
5436 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5437 loTmpSACs.dfkey = loTransDetail.pkey
5438 Insert Into (tcTransSAC) From Name loTmpSACs
5439 Endscan
5440 * === TR 1018184
5441
5442 * --- TR 1034963 12/15/08 CM
5443 If llDtlRangeNotes
5444 Select (lcDetailNotes)
5445 Scan
5446 Scatter Name loTmpDetNotes Memo
5447
5448 * --- TR 1045865 3/8/10 CM
5449 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5450 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5451 * === TR 1045865 3/8/10 CM
5452
5453 loTmpDetNotes.fkey = loTransDetail.pkey
5454 SELECT('Vzzeipotd_notes_iPOproc')
5455 Append Blank
5456 Gather Name loTmpDetNotes Memo
5457 Endscan
5458 Endif
5459
5460 IF USED(lcDetailNotes)
5461 USE IN (lcDetailNotes)
5462 ENDIF
5463 * === TR 1034963 12/15/08 CM
5464
5465 Else
5466 llRetVal= .F. && Cannot get Pkey from bcsysnum
5467 Exit
5468 Endif
5469
5470 Select (pcRangeDetailVert)
5471 Endscan
5472 Else
5473 llRetVal= .F. && Should be in pcrangdetailvert
5474 Exit
5475 Endif
5476 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5477 Endif
5478
5479 If !llRetVal &&Get out of scan when have some problem
5480 Exit
5481 Endif
5482 Endscan
5483
5484 * --- TR 1034963 12/15/08 CM
5485 If llDtlRangeNotes
5486 This.UpdateSysNotes()
5487 Endif
5488 * === TR 1034963 12/15/08 CM
5489
5490 Select(lnOldSelect)
5491 Return llRetVal
5492 Endproc
5493
5494 *----------------------------------------------------------------------------------------
5495
5496 Procedure PrepackConversion
5497 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5498 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5499 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5500 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5501 llRetVal = .T.
5502 lnOldSelect = Select()
5503
5504 * --- TR 1046519 7/26/10 CM
5505 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5506 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5507
5508 STORE "" To lcSumSln, lcError, lcPPKAction
5509 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5510 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5511 * === TR 1046519 7/26/10 CM
5512
5513 *****************************************************************************
5514 * 1st Getting all prepack headers
5515 *--- 1001112 9/26/03 YIK
5516 *- process all.
5517 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5518 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5519 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5520 *!* and d.rng_style= '' ; && none exploded range style
5521 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5522 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5523
5524 *- 1013522 10/10/05 12/02/05 YIK
5525 *- Exclude range style P from the consideration
5526 *- Do not close this cursor. It is needed in CheckSLN()
5527 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5528 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5529
5530 *- 1025153 10/22/07 YIK - comment out
5531 * --- TR 1022896 NSD 05-10-07
5532*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5533 * === TR 1022896 NSD 05-10-07
5534
5535 *- 1005499 07/06/04 YIK
5536 *- Change d.rng_style = '' to EMPTY(d.rng_style)
5537
5538 *- 1023438 04/05/07 YIK
5539 *- Allow to check Range Style type 'R'.
5540 *- Needed for MultiUPC and a good idea anyway.
5541 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
5542
5543 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
5544
5545*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5546*!* FROM (pcTransDetail) d ;
5547*!* WHERE Empty(d.rng_style) ; && none exploded range style
5548*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5549*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5550*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5551*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5552
5553 *--- TechRec 1044487 18-Mar-2010 JK ---
5554*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5555*!* FROM (pcTransDetail) d ;
5556*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
5557*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5558*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5559*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5560*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5561
5562 * --- TR 1046519 7/26/10 CM
5563 IF RECCOUNT(pcSLN) > 0
5564 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
5565 JOIN (pcTransDetail) d ;
5566 ON s.fkey = d.pkey ;
5567 JOIN (pceipoCR) c ;
5568 ON d.division = c.division ;
5569 AND d.customer = c.customer ;
5570 WHERE s.sln_qty > 0 ;
5571 GROUP BY s.fkey ;
5572 INTO CURSOR __SumSlnQty
5573
5574 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
5575
5576 WITH THIS
5577 .cSQLTempTable=""
5578 IF .GenerateSQLTempTable('__SumSlnQty')
5579 IF .PopulateSQLTempTable('__SumSlnQty')
5580 lcSumSln = .cSQLTempTable
5581 IF !EMPTY(lcSumSln)
5582 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
5583 ENDIF
5584 ENDIF
5585 ENDIF
5586 ENDWITH
5587 ENDIF
5588 * === TR 1046519 7/26/10 CM
5589
5590 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
5591 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
5592 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
5593 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
5594 FROM (pcTransDetail) d ;
5595 JOIN (pceipoCR) c ON c.customer = d.customer ;
5596 AND c.division = d.division ;
5597 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
5598 AND (c.rngp_conv = 'P' ;
5599 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
5600 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
5601 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5602 AND c.ppk_conv <> 'N' ;
5603 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5604 *=== TechRec 1044487 18-Mar-2010 JK ===
5605
5606 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
5607 *== 1023438
5608
5609 *=== 1013522
5610 *=== 1001112
5611 With This
5612 .cSQLTempTable=""
5613 If .GenerateSQLTempTable('__TmpCursor')
5614 If .PopulateSQLTempTable('__TmpCursor')
5615 If !Empty(.cSQLTempTable)
5616 *- TR 1025153 06/14/07 YIK
5617 *- Use the OUTER JOIN, then we have all details needed
5618 *- and can simply scan for !EOF() later on.
5619*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
5620*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
5621*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
5622*-- "s.style= t.style and s.color_code= t.color_code and " +;
5623*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
5624*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
5625*-- "s.dimension= ph.ppk_code"
5626 *--- TR 1026025 NH - use size_code from zzxstylr
5627 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
5628 * using sln_qty instead of ppk_qty
5629
5630 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
5631 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
5632 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
5633 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
5634 " ,st.size_code " +; && 1026025
5635 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
5636 " from " + .cSQLTempTable + " t " +;
5637 " JOIN zzxscolr s " + ;
5638 " ON s.division= t.division and " +;
5639 " s.style= t.style and s.color_code= t.color_code and " +;
5640 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
5641 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
5642 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
5643 " LEFT OUTER JOIN zzxppakh ph " + ;
5644 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
5645 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
5646 " Where s.ppack_ok= 'Y' "
5647
5648 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
5649 If Used("_PPK_Qty")
5650 Select ("_PPK_Qty")
5651 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
5652 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
5653 "division+style+color_code+lbl_code+dimension")
5654 SELECT ("__TmpCursor")
5655
5656 If llRetVal
5657 .LogEntry("Validating prepack style.")
5658 lcErrs_Msg = "No valid prepack code found"
5659 Select (pcTransDetail)
5660 *- 1005499 07/06/04 YIK
5661 *- Replace ..Errs_Flg_D= "N") and rng_style=''
5662 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
5663 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
5664*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
5665 *- TR 1025153 06/14/07 YIK
5666 *- Since we use the OUTER JOIN, can simply scan for !EOF()
5667 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
5668 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
5669
5670 If Empty(_PPK_Qty.pack_qty)
5671 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
5672 Errs_Flg_D With "Y" ;
5673 IN (pcTransDetail)
5674 Else
5675 Do Case
5676
5677 * --- TR 1040838 6/11/09 CM
5678 * --- Check prepack action based on Transaction detail
5679 * Removed _PPK_Qty Alias
5680 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
5681 Case ppk_action = 'Q' && multiply qty
5682 * === TR 1040838 6/11/09 CM
5683
5684 * --- TR 1046519 7/26/10 CM
5685 * At this point we know we have some slns to use for our alternate
5686 * conversion, lets just make sure that the conversion type is 'E'
5687 IF llConvertBySln
5688 lcPPKAction = ppk_action
5689 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5690 lnOrigQty = total_qty
5691 lnPpkQty = ppk_qty
5692 ENDIF
5693 * === TR 1046519 7/26/10 CM
5694
5695 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5696 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5697 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5698 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5699 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
5700 In (pcTransDetail)
5701
5702 * --- TR 1046519 7/26/10 CM
5703 IF llSlnConvert
5704 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5705 IF llRemain
5706 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5707 Errs_Flg_D WITH "Y" , ;
5708 ppk_action WITH lcPPKAction , ;
5709 total_qty WITH lnOrigQty ;
5710 In (pcTransDetail)
5711 ENDIF
5712 ENDIF
5713 * ==== TR 1046519 7/26/10 CM
5714
5715 * --- TR 1040838 6/11/09 CM
5716 * Removed _PPK_Qty Alias
5717 *Case _PPK_Qty.ppk_action = 'P' && divide price
5718 Case ppk_action = 'P' && divide price
5719 * === TR 1040838 6/11/09 CM
5720
5721 * --- TR 1046519 7/26/10 CM
5722 * At this point we know we have some slns to use for our alternate
5723 * conversion, lets just make sure that the conversion type is 'E'
5724 IF llConvertBySln
5725 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5726 ENDIF
5727 * === TR 1046519 7/26/10 CM
5728
5729 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5730 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5731 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5732 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5733 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5734 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5735 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5736 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
5737 In (pcTransDetail)
5738 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
5739 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
5740 *- Range style price will be populated later from a_price..e_price
5741 *- not from org_price. Need to updated these prices here.
5742 IF rng_type = 'R'
5743 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
5744 b_price WITH b_price/_PPK_Qty.pack_qty, ;
5745 c_price WITH c_price/_PPK_Qty.pack_qty, ;
5746 d_price WITH d_price/_PPK_Qty.pack_qty, ;
5747 e_price WITH e_price/_PPK_Qty.pack_qty ;
5748 In (pcTransDetail)
5749 ENDIF
5750 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
5751
5752 * --- TR 1040838 6/11/09 CM
5753 * Removed _PPK_Qty Alias
5754 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
5755 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
5756 * === TR 1040838 6/11/09 CM
5757
5758 * --- TR 1046519 7/26/10 CM
5759 IF llConvertBySln
5760 lcPPKAction = ppk_action
5761 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5762 lnOrigQty = total_qty
5763 lnPrice = org_price
5764 lnretail1 = retail1
5765 lnretail2 = retail2
5766 lnPpkQty = ppk_qty
5767 ENDIF
5768 * === TR 1046519 7/26/10 CM
5769
5770 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5771 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5772 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5773 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5774 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5775 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5776 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5777 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5778 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
5779 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
5780 In (pcTransDetail)
5781
5782 * --- TR 1046519 7/26/10 CM
5783 IF llSlnConvert
5784 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5785 IF llRemain
5786 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5787 Errs_Flg_D WITH "Y", ;
5788 ppk_action WITH lcPPKAction , ;
5789 total_qty WITH lnOrigQty , ;
5790 org_price WITH lnPrice , ;
5791 retail1 WITH lnretail1 , ;
5792 retail2 WITH lnretail2 , ;
5793 ppk_qty WITH lnPpkQty ;
5794 In (pcTransDetail)
5795 ENDIF
5796 ENDIF
5797 * ==== TR 1046519 7/26/10 CM
5798
5799 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
5800 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
5801 IF rng_type = 'R'
5802 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
5803 b_price WITH b_price/_PPK_Qty.pack_qty, ;
5804 c_price WITH c_price/_PPK_Qty.pack_qty, ;
5805 d_price WITH d_price/_PPK_Qty.pack_qty, ;
5806 e_price WITH e_price/_PPK_Qty.pack_qty ;
5807 In (pcTransDetail)
5808 ENDIF
5809 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
5810
5811 Otherwise
5812 Endcase
5813 Endif
5814 Endscan
5815 Endif
5816 Set Relation To
5817 Endif
5818 Endif
5819 Endif
5820 Endif
5821 Endwith
5822 If Used("__TmpCursor")
5823 Use In __TmpCursor
5824 Endif
5825 If Used("_PPK_Qty")
5826 Use In _PPK_Qty
5827 Endif
5828
5829 * --- TR 1046519 7/26/10 CM
5830 IF USED("__SumSlnQty")
5831 USE IN __SumSlnQty
5832 ENDIF
5833 * === TR 1046519 7/26/10 CM
5834
5835 Select(lnOldSelect)
5836 Return llRetVal
5837
5838 *----------------------------------------------------------------------------------------
5839 *- 1006607 09/02/04 YIK
5840 Function ResolveRangeP
5841 Lparameters pceipoTH, pceipoTD, pceipoCR
5842
5843 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
5844 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
5845 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
5846 llRetVal = .T.
5847 lnOldSelect = Select()
5848
5849 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
5850 lcRngp_conv = ""
5851 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
5852
5853 With This
5854 .oLog.LogMajorStage("Range Style Implosion.")
5855 *- do we have any range styles 'P' in BC
5856 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
5857 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
5858 If !llRetVal Or Recc("tcTemp") = 0
5859 .oLog.LogEntry("No range styles for implosion")
5860 Return llRetVal
5861 Endif
5862
5863 *- 1007637 11/17/04 YIK
5864 *- Allow open stock: Rng_impl = 'O'
5865 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
5866 *- implode only orders that have not been range imploded (empty range style)
5867 *- and were not prepack imploded (implosion <> "Y")
5868 *!* select distinct fkey ;
5869 *!* from (pceipoTd) d ;
5870 *!* join (pceipoCR) c ;
5871 *!* on d.division = c.division and d.customer = c.customer ;
5872 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
5873 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
5874 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
5875 *!* into cursor rng_det
5876
5877*- 1047842/1048069 07/01/10 YIK
5878*- Implode only orders with no detail errors
5879*-- Select Distinct fkey, C.Rng_impl ;
5880*-- FROM (pceipoTD) d ;
5881*-- JOIN (pceipoCR) C ;
5882*-- ON d.division = C.division And d.customer = C.customer ;
5883*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
5884*-- AND !Empty(d.division) And !Empty(d.customer) ;
5885*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
5886*-- INTO Cursor rng_det
5887
5888 *- TR 1058336 FH - added division to select, and group by
5889 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
5890 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
5891 FROM (pceipoTD) d ;
5892 JOIN (pceipoCR) C ;
5893 ON d.division = C.division And d.customer = C.customer ;
5894 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
5895 AND !Empty(d.division) And !Empty(d.customer) ;
5896 AND Empty(d.rng_style) And d.implosion <> "Y" ;
5897 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
5898 HAVING MAX(errs_flg_d) = 'N' ;
5899 INTO Cursor rng_det
5900*===
5901
5902 *==
5903 *--- TR 1023892 NH
5904 IF .lALLOW_RANGE_HDR_LABEL
5905 &&- TR 1058336 FH - added qualifier for division
5906 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
5907 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
5908 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 ;
5909 FROM (pceipoTD) d ;
5910 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
5911 WHERE !EMPTY(d.STYLE) ;
5912 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
5913 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
5914 INTO CURSOR __TmpCurs
5915 ELSE
5916 &&- TR 1058336 FH - added qualifier for division
5917 *=== TR 1023892 NH
5918 *- 1047842/1048069 07/01/10 YIK
5919 *- Added d.pkey
5920 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
5921 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
5922 FROM (pceipoTD) d ;
5923 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
5924 WHERE !Empty(d.Style) ;
5925 AND !Empty(d.division) And !Empty(d.customer) ;
5926 AND Empty(d.rng_style) And d.implosion <> "Y" ;
5927 INTO Cursor __tmpCurs
5928 ENDIF && TR 1023892 NH
5929 .cSQLTempTable=""
5930 If .GenerateSQLTempTable('__TmpCurs')
5931 If .PopulateSQLTempTable('__TmpCurs')
5932 If !Empty(.cSQLTempTable)
5933 Select rng_det
5934 Scan
5935 lnFKey = rng_det.fkey
5936 *- 1007637 11/17/04 YIK
5937 lcRng_Impl = rng_det.Rng_impl
5938
5939 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
5940 lcRngp_conv = rng_det.Rngp_conv
5941 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
5942
5943 lcDivision = rng_det.division &&- TR 1058336 FH
5944
5945 *- one order at a time. Select on the server side.
5946 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
5947 dtl = SQLTableFromQuery(lcSQLStr )
5948 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
5949
5950 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
5951 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
5952
5953 Select (pceipoTD)
5954 Do Case
5955 Case lnResult = 0 && match not found
5956 *- 1007637 11/17/04 YIK
5957 If lcRng_Impl = 'Y'
5958
5959 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
5960 Errs_Flg_D With "Y" ;
5961 FOR fkey = lnFKey And !Empty(Style) ;
5962 AND !Empty(division) And !Empty(customer) ;
5963 AND Empty(rng_style) And implosion <> "Y"
5964 Endif
5965 Case lnResult > 1 && ambiguous
5966 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
5967 *- 1049007 08/24/10 YIK
5968 *- List all ambiguous Range Styles
5969 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
5970 Errs_Flg_D With "Y" ;
5971 FOR fkey = lnFKey And !Empty(Style) ;
5972 AND !Empty(division) And !Empty(customer) ;
5973 AND Empty(rng_style) And implosion <> "Y"
5974*!* lcErrorMsg = " Ambiguous range styles "
5975*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
5976*!* lcErrorMsg = lcErrorMsg + ": "
5977*!* SELECT __tmp
5978*!* SCAN
5979*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
5980*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
5981*!* EndScan
5982*!* SELECT(pceipoTD)
5983*!* ENDIF
5984*!*
5985*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
5986*!* Errs_Flg_D With "Y" ;
5987*!* FOR fkey = lnFKey And !Empty(Style) ;
5988*!* AND !Empty(division) And !Empty(customer) ;
5989*!* AND Empty(rng_style) And implosion <> "Y"
5990 *=== 1049007
5991 Endcase
5992 Endscan
5993 Endif
5994 Endif
5995 Endif
5996
5997 Endwith
5998 Select (lnOldSelect)
5999 Return llRetVal
6000 Endfunc
6001
6002 Function RangeImplosion
6003 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6004 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6005 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6006
6007 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6008 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6009 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6010
6011 llRetVal = .T.
6012 lnOldSelect = Select()
6013 With This
6014
6015 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6016 *- turn them vertical into SQL-side temp table var. RangD
6017 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6018 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6019*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6020*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6021*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6022*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6023*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6024*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6025
6026*!* Added following join
6027*!* " join " + dtl + " td1 " +;
6028*!* " on d.style = td1.style " +;
6029*!* " and d.color_code = td1.color_code " +;
6030*!* " and d.lbl_code = td1.lbl_code " +;
6031*!* " and d.dimension = td1.dimension "
6032
6033 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6034
6035 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6036 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6037 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6038 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6039 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6040 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6041 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6042 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6043 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6044 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6045 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6046 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6047 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6048 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6049 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6050 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6051 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6052 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6053 "coalesce(cs.e_price,d.e_price) as e_price "+;
6054 "from ( " +;
6055 " select dd.* from zzxrangd dd " +;
6056 " where fkey in ( " +;
6057 " select distinct ph.pkey " +;
6058 " from zzxrangh ph " +;
6059 " join zzxrangd pd " +;
6060 " on ph.Pkey = Pd.Fkey " +;
6061 " join " + dtl + " td1 " +;
6062 " on pd.style = td1.style " +;
6063 " and pd.color_code = td1.color_code " +;
6064 " and pd.lbl_code = td1.lbl_code " +;
6065 " and pd.dimension = td1.dimension " +;
6066 " where ph.rng_type = 'P' " +;
6067 " and not exists( " +;
6068 " select * " +;
6069 " from zzxrangd da " +;
6070 " left join " + dtl + " det " +;
6071 " on det.style = da.style " +;
6072 " and det.color_code = da.color_code " +;
6073 " and det.lbl_code = da.lbl_code " +;
6074 " and det.dimension = da.dimension " +;
6075 " where da.Fkey = ph.pkey " +;
6076 " and (det.Pkey is null " +;
6077 " or case det.SizeBucket " +;
6078 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6079 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6080 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6081 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6082 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6083 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6084 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6085 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6086 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6087 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6088 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6089 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6090 " ) ) d " +;
6091 " join zzxbuckt b " +;
6092 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6093 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6094 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6095 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6096 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6097 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6098 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6099 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6100 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6101 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6102 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6103 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 "+ ;
6104 " join " + dtl + " td1 " +;
6105 " on d.style = td1.style " +;
6106 " and d.color_code = td1.color_code " +;
6107 " and d.lbl_code = td1.lbl_code " +;
6108 " and d.dimension = td1.dimension "+;
6109 " Left join zzxcsrgh cs "+ ;
6110 " on cs.dtlpkey = d.pkey "+ ;
6111 " and cs.customer = td1.customer "
6112
6113
6114 RangD = SQLTableFromQuery(lcSQLString)
6115
6116 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6117 *- possible combinations of RangD that cover them.
6118 *- Result is SQL-side temp table var. RangeSet
6119 *- 1047842/1048069 07/01/10 YIK
6120 *- Added td.pkey
6121 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6122 *--- 1049007 08/24/10 YIK
6123 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6124 *- to check for components divisibility
6125 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6126 lcSQLString = ;
6127 'select td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6128 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6129 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6130 ',td.pkey as dtl_pkey ' + ;
6131 ' from ' + dtl + ' td ' + ;
6132 ' cross join ( ' + ;
6133 ' select * ' + ;
6134 ' from zzxrangh H ' + ;
6135 ' where exists ( ' + ;
6136 ' select * ' + ;
6137 ' from ' + RangD + ' dd ' + ;
6138 ' join ' + dtl + ' td1 ' + ;
6139 ' on dd.Division = td1.Division ' + ;
6140 ' and dd.style = td1.style ' + ;
6141 ' and dd.color_code = td1.color_code ' + ;
6142 ' and dd.lbl_code = td1.lbl_code ' + ;
6143 ' and dd.dimension = td1.dimension ' + ;
6144 ' and dd.size_bk = td1.sizebucket ' + ;
6145 ' where dd.FKey = H.PKey )) mtch ' + ;
6146 ' left join ' + RangD + ' D ' + ;
6147 ' on d.FKey = mtch.PKey ' + ;
6148 ' and d.Division = td.Division ' + ;
6149 ' and d.style = td.style ' + ;
6150 ' and d.color_code = td.color_code ' + ;
6151 ' and d.lbl_code = td.lbl_code ' + ;
6152 ' and d.dimension = td.dimension ' + ;
6153 ' and d.size_bk = td.sizebucket ' + ;
6154 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6155 *==104900708/24/10YIK
6156 RangeSet = SQLTableFromQuery(lcSQLString)
6157
6158 * --- TR 1048126 8/23/10 CM
6159 v_SqlExec(lcSQLString, "tcRangeSet")
6160
6161 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6162*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6163*!*
6164*!* UPDATE d ;
6165*!* SET ppk_qty = -1 ;
6166*!* FROM (pceipoTD) d ;
6167*!* JOIN tcRangeSet r ;
6168*!* ON d.pkey = r.dtl_pkey ;
6169*!* WHERE d.ppk_action $ 'XM'
6170*!*
6171*!* ENDIF
6172 *=== TR 1051390 23-Dec-2010 Goutam
6173
6174 * === TR 1048126 8/23/10 CM
6175
6176 *- how many different range styles were found for this order
6177 *--- 1049007 08/24/10 YIK
6178 *- Modify logic to determine ambiguos Range Styles
6179*-- lcSQLString = ;
6180*-- ' select count(*) PPKCnt ' + ;
6181*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6182
6183 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6184 *= 1049007
6185
6186 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6187 lnPPKCnt = tmp_cnt.PPKCnt
6188
6189 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6190 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6191 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6192
6193 *--- the result (Query #2):
6194 *- See if any single range style in the RangeSet fully matches DTL
6195 *- 1047842/1048069 07/01/10 YIK
6196 *- added t1dtl_pkey
6197 lcSQLString = ;
6198 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6199 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6200 ' from ' + dtl + ' dtl ' + ;
6201 ' join ' + RangeSet + ' t1 ' + ;
6202 ' on dtl.style = t1.style ' + ;
6203 ' and dtl.color_code = t1.color_code ' + ;
6204 ' and dtl.lbl_code = t1.lbl_code ' + ;
6205 ' and dtl.dimension = t1.dimension ' + ;
6206 ' and dtl.sizebucket = t1.sizebucket ' + ;
6207 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6208 ' having count(*) = (select count(*) from ' + dtl + ') '
6209 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6210 lnCnt = Reccount()
6211
6212 *- 1049007 08/24/10 YIK
6213 *- Exclude Range styles that are not divisible
6214 IF (lnCnt > 0)
6215 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6216 lnCnt = _TALLY
6217 ENDIF
6218 *=
6219
6220 llSingleMatch = .F.
6221 llAmbig = .F.
6222 *- 1047842/1048069 07/01/10 YIK
6223 *- Added ValidDetail
6224 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6225 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6226 Do Case
6227 Case lnCnt > 1
6228 *- 1049007 08/24/10 YIK
6229 USE IN SELECT("__tmp")
6230 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6231 *=
6232 llAmbig = .T. && ambiguos, give error message and do not continue
6233 Case lnCnt = 1
6234 llSingleMatch = .T.
6235 *- 1047842/1048069 07/01/10 YIK
6236 *- Added ValidDetail
6237 *- 1049007 08/26/10 YIK
6238 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6239* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6240 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6241 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6242
6243 Otherwise
6244 Endcase
6245 *- 1049007 08/24/10 YIK
6246 *- commented out. This method is not called with this parameter = .T.
6247*--- IF tlNoConsol
6248*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6249*--- ENDIF
6250
6251 lnResult = lnCnt
6252
6253 If !llAmbig
6254 *- If none single range style in the RangeSet fully matches DTL,
6255 *- or even if a match was found
6256 *- start going through combinations of 2,3... - may be ambiguous
6257
6258 *- 1047842/1048069 07/01/10 YIK
6259 *- added t1dtl_pkey
6260 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6261
6262 lcTopStr = ;
6263 ' from ' + dtl + ' dtl ' + ;
6264 ' join ' + RangeSet + ' t1 ' + ;
6265 ' on dtl.style = t1.style ' + ;
6266 ' and dtl.color_code = t1.color_code ' + ;
6267 ' and dtl.lbl_code = t1.lbl_code ' + ;
6268 ' and dtl.dimension = t1.dimension ' + ;
6269 ' and dtl.sizebucket = t1.sizebucket '
6270
6271 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6272 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6273 lcMiddleStr = ''
6274 lcCoalStr_pkey = 't1.pkey'
6275 lcCoalRevStr_pkey = 't1.pkey'
6276 lcCoalStr_ratio = 't1.ratio'
6277 lcCoalRevStr_ratio = 't1.ratio'
6278 lcGroupFkeyStr = ' t1.FKey'
6279 lcGroupStr = ''
6280
6281 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6282 *lnPrepacks = Min(lnPPKCnt, 6)
6283 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6284 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6285 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6286
6287 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6288
6289 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6290 llFoundNext = .F.
6291
6292 lcnum = Trans(j, "9")
6293 lcPrevNum = Trans(j - 1, "9")
6294 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6295 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6296
6297 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6298
6299 *-- TR 1049817 Oct-12-2010 BR
6300 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6301 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6302 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6303 *== TR 1049817 Oct-12-2010 BR
6304
6305 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6306
6307 *--- TR 1049817 Oct-12-2010 BR
6308 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6309 lcGroupStr = lcGroupFkeyStr
6310 *=== TR 1049817 Oct-12-2010 BR
6311
6312 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6313 *- 06/30/10 YIK LOCAL ONLY
6314 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6315 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6316 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6317 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6318
6319 lcMiddleStr = lcMiddleStr + ;
6320 "join " + RangeSet + " t" + lcnum + ;
6321 ' on dtl.style = t' + lcnum + '.style ' + ;
6322 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6323 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6324 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6325 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6326 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6327
6328 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6329 ' Group by ' + lcGroupStr
6330
6331 *--- TR 1049817 Oct-12-2010 BR
6332 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6333 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6334 *=== TR 1049817 Oct-12-2010 BR
6335
6336 *--- TR 1050754 NOV-15-2010 BR
6337 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6338 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6339 *=== TR 1050754 NOV-15-2010 BR
6340
6341 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6342 lnCnt = Reccount()
6343 llFoundNext = (lnCnt = 1)
6344 *- ambig when either prev or this SQL returned more than 1 row or
6345 *- one match was found before AND one is found now - making it two.
6346 If lnCnt > 0
6347 Scan
6348 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6349 *- divisible by the number of items in the range style!!!
6350
6351 *---TR 1049817 Oct-12-2010 BR
6352 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6353 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6354 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6355 *===TR 1049817 Oct-12-2010 BR
6356 Else
6357 lcInsertStr = Trans(fkey)
6358 *- 1047842 06/17/10 YIK
6359 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6360
6361 For lnCounter = 2 To j
6362
6363 *- TR 1055009 FH - added If statement
6364 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6365
6366 else
6367 *- 1047842 06/17/10 YIK
6368 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6369 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6370 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6371 *- Added ValidDetail
6372 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6373 ENDIF
6374 *- TR 1055009 FH
6375
6376 Endfor
6377
6378 *---TR 1049817 Oct-12-2010 BR
6379 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6380 lcInsertRatioStr = Trans(t1_ratio)
6381
6382 For lnCounter = 2 To j
6383 *- TR 1055009 FH - added If statement
6384 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6385
6386 ELSE
6387 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6388 ENDIF
6389 *- TR 1055009 FH - added If statement
6390 ENDFOR
6391 *== =TR 1049817 Oct-12-2010 BR
6392
6393 *- 1047842/1048069 07/01/10 YIK
6394 *- Added ValidDetail
6395 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6396 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6397
6398 Endif
6399 Endscan
6400 Endif
6401 lnResultCnt = Recc("q_Result")
6402 llAmbig = (lnResultCnt > 1)
6403 llSingleMatch = (lnResultCnt = 1)
6404 If llAmbig
6405 lnResult = lnResultCnt
6406 Exit
6407 Endif
6408 Endfor
6409 If llSingleMatch
6410 lnResult = 1
6411 IF NOT tlNoConsol
6412 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6413
6414 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6415 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6416 ENDIF
6417 Endif
6418 Else && ambiguous
6419 lnResult = lnCnt
6420 Endif
6421
6422 *--- TR 1051390 23-Dec-2010 Goutam
6423 IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6424 UPDATE d ;
6425 SET ppk_qty = -1 ;
6426 FROM (pceipoTD) d ;
6427 JOIN tcRangeSet r ;
6428 ON d.pkey = r.dtl_pkey ;
6429 WHERE d.ppk_action $ 'XM'
6430 ENDIF
6431 *=== TR 1051390 23-Dec-2010 Goutam
6432
6433 Endwith
6434 Return lnResult
6435
6436 Procedure ConsolidateRangeP
6437 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6438 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6439 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6440
6441 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6442
6443 LOCAL lcDvision && 1058336 FH
6444
6445 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6446 LOCAL lnOrgPrice
6447 IF EMPTY(pcRngp_conv )
6448 pcRngp_conv = "N"
6449 ENDIF
6450 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6451
6452 llRetVal = .T.
6453 lnOldSelect = Select()
6454
6455 *- insert range styles that match zzxrangd.fkey from q_result
6456 *- into pceipotd.
6457 *- parse the string from cursor q_result to get the list of fkeys
6458 *- 1047842/1048069 07/01/10 YIK
6459 *- Moved Locate down
6460*-- Select (pceipoTD)
6461*-- Locate For fkey = pnFkey
6462*-- Scatter Name oDtl Memo
6463
6464 Declare aRange[1]
6465 aRange = ''
6466 Select q_Result
6467 Scatter Memvar Memo
6468 *- 1030497 02/29/08 TT
6469 *--StringToArray(m.ValidRange, @aRange, ",")
6470
6471 *--TR 1040854 Jun-11-09 BR
6472 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6473 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6474 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6475 *==TR 1040854 Jun-11-09 BR
6476
6477 *- 1030497 02/29/08 TT
6478 *-- TR 1049817 Oct-12-2010 BR
6479 *lnLen = Alen(aRange) - 1 && the last element is ratio
6480 lnLen = Alen(aRange)
6481 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6482 *== TR 1049817 Oct-12-2010 BR
6483
6484 *- 1047842/1048069 07/01/10 YIK
6485 Declare aDetail[1]
6486 aDetail = ''
6487 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6488 *= 1047842/1048069
6489
6490 *-- TR 1049817 Oct-12-2010 BR
6491 DECLARE aRatios[1]
6492 aRatios = ''
6493 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6494 *== TR 1049817 Oct-12-2010 BR
6495
6496 For j = 1 To lnLen
6497 lcFkey = aRange[j]
6498 *- 1047842/1048069 07/01/10 YIK
6499 lnDtl_Pkey = EVALUATE(aDetail[j])
6500 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6501
6502 Select (pceipoTD)
6503 Locate For pkey = lnDtl_Pkey
6504 Scatter Name oDtl Memo
6505 *= 1047842/1048069
6506 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6507*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6508 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6509 " coalesce(cs.a_price,h.a_price) as a_price, "+;
6510 " coalesce(cs.b_price,h.b_price) as b_price, "+;
6511 " coalesce(cs.c_price,h.c_price) as c_price, "+;
6512 " coalesce(cs.d_price,h.d_price) as d_price, "+;
6513 " coalesce(cs.e_price,h.e_price) as e_price "+;
6514 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
6515 " h.SOURCETYPE,h.RNG_PACK_001,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
6516 " From zzxrangh h " + ;
6517 " Left Join zzxcsrgh cs "+ ;
6518 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
6519 " and cs.customer = "+ SQLFormatChar(oDtl.Customer)
6520 v_SqlExec(lcSQL ,"__RangH")
6521 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
6522 lcDvision = __RangH.division && 1058336 FH
6523
6524 oDtl.Style = __RangH.rng_style
6525 oDtl.color_code = __RangH.rng_color
6526 oDtl.lbl_code = __RangH.rng_lbl
6527 oDtl.Dimension = __RangH.rng_pack
6528 oDtl.rng_style = __RangH.rng_style
6529 oDtl.rng_color = __RangH.rng_color
6530 oDtl.rng_lbl = __RangH.rng_lbl
6531 oDtl.rng_pack = __RangH.rng_pack
6532 oDtl.rng_qty = __RangH.rng_qty
6533 oDtl.rng_type = __RangH.rng_type
6534 *- don't have to have upc or sku for the imploded range style
6535 oDtl.upc = ''
6536 oDtl.sku = ''
6537 oDtl.coord_code = __RangH.coord_code
6538 oDtl.a_price = __RangH.a_price
6539 oDtl.b_price = __RangH.b_price
6540 oDtl.c_price = __RangH.c_price
6541 oDtl.d_price = __RangH.d_price
6542 oDtl.e_price = __RangH.e_price
6543 *- clear err msg and err flag which may have error after unsuccessful implosion
6544 oDtl.Errs_Msg_D = ""
6545
6546 *- 1009211 03/09/05 YIK
6547 *- Initializ3e errs_flg_d to N, not blank
6548 *- oDtl.Errs_Flg_D = " "
6549 oDtl.Errs_Flg_D = "N"
6550 *- org_price is based on zzocntrc (cust sales) price_code
6551 *- we'll get the proper price_code in ValidOrderControl()
6552 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
6553
6554 *- 1009211 02/24/05 YIK
6555 *- Keep quantity in cases and use price per case.
6556 *- and zero out orig price which will be resolved.
6557 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
6558
6559 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6560 lnOrgPrice = oDtl.org_price
6561 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6562
6563 oDtl.total_qty = lnRatio
6564 oDtl.org_price = 0
6565
6566 *--- TR 1060800 24-May-2012 Goutam.
6567 oDtl.Rng_Impl = pcRng_Impl
6568 oDtl.Rngp_conv = pcRngp_conv
6569 *=== TR 1060800 24-May-2012 Goutam.
6570
6571 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6572 IF pcRngp_conv = "R"
6573 *--- TechRec 1057383 15-Dec-2011 jisingh ---
6574*!* oDtl.ppk_qty = __RangH.rng_qty
6575*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
6576*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6577*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6578*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
6579*!* oDtl.ppk_action = 'X'
6580
6581 IF EMPTY(oDtl.ppk_action)
6582 oDtl.org_price = lnOrgPrice
6583 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
6584 ENDIF
6585
6586 IF oDtl.ppk_action = "B"
6587 oDtl.org_price = lnOrgPrice
6588 oDtl.ppk_qty = __RangH.rng_qty
6589 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6590 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6591 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6592 oDtl.ppk_action = 'X'
6593 ENDIF
6594
6595 IF oDtl.ppk_action = "Q" && Qty conversion only
6596 oDtl.org_price = lnOrgPrice
6597 oDtl.ppk_qty = __RangH.rng_qty
6598 oDtl.retail1 = oDtl.retail1
6599 oDtl.retail2 = oDtl.retail2
6600 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6601 oDtl.ppk_action = 'M'
6602 ENDIF
6603
6604 IF oDtl.ppk_action = "P" && Price conversion only
6605 oDtl.org_price = lnOrgPrice
6606 oDtl.ppk_qty = __RangH.rng_qty
6607 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6608 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6609 oDtl.total_qty = oDtl.total_qty
6610 oDtl.ppk_action = 'D'
6611 ENDIF
6612 *=== TechRec 1057383 15-Dec-2011 jisingh ===
6613 ENDIF
6614 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6615
6616 *= 1009211
6617 *- 1047842/1048069 07/01/10 YIK
6618 *- Clear po1_upc and po1_sku as they get populated on the way out
6619 oDtl.po1_upc = ''
6620 oDtl.po1_sku = ''
6621
6622
6623 *- Per JR, put into the 1st available size bucket
6624 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
6625 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
6626 If !llRetVal
6627 Exit
6628 Else
6629 *-- TR 1049817 Oct-12-2010 BR
6630 *oDtl.sizebucket = At("Y", __tmp.sizes)
6631 oDtl.sizebucket = __RangH.rng_bk
6632 oDtl.rng_bk = oDtl.sizebucket
6633 lcSzStr = __tmp.sizes
6634 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
6635 *== TR 1049817 Oct-12-2010 BR
6636 Endif
6637 *-- TR 1049817 Oct-12-2010 BR
6638 IF !llValidRngBk
6639 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
6640 oDtl.errs_flg_d = 'Y'
6641 ELSE
6642 *== TR 1049817 Oct-12-2010 BR
6643 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
6644 llRetVal = .F.
6645 Exit
6646 Endif
6647 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
6648 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
6649
6650 *--- TR 1059965 6-Mar-12 Venuk
6651 *oDtl.pkey = v_nextPkey("ZZEIPOID")
6652 * ENDIF
6653 ENDIF
6654 oDtl.pkey = v_nextPkey("ZZEIPOID")
6655 *=== TR 1059965 6-Mar-12 Venuk
6656
6657 Select (pceipoTD)
6658 Append Blank
6659
6660 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
6661 *Gather Name oDtl
6662 Gather Name oDtl memo
6663 *=== TR 1065271 11-Jan-2013 BNarayanan ===
6664
6665 Endfor
6666 If llRetVal
6667 *- delete components
6668 Delete For fkey = pnFkey And !Empty(Style) ;
6669 AND !Empty(division) And !Empty(customer) ;
6670 AND Empty(rng_style) And implosion <> "Y" ;
6671 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
6672 IN (pceipoTD)
6673 Endif
6674 Select (lnOldSelect)
6675 Return llRetVal
6676 *========== 1006607 09/02/04 YIK
6677
6678 *----------------------------------------------------------------------------------------
6679
6680 *--- TechRec 1005163 17-May-2004 GS ---
6681 *-- Validating SLN vs. Prepack
6682 Procedure CheckSLN
6683 Parameters pceipoTH, pceipoTD, pceipoTS
6684 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
6685 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
6686 lcDtl_lbl_code && *-TR 1075660 SK
6687
6688 lnOldDtlPKey = -1
6689 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
6690 *--- TR 1023892 NH
6691 lnOldSelect = SELECT()
6692 llRetVal = .t.
6693 *=== TR 1023892 NH
6694 Select (pceipoTS)
6695 Set Order To Tag fkey
6696
6697 SCAN
6698 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
6699 IF SkipSlnChk = "Y"
6700 LOOP
6701 ENDIF
6702 *=== TR 1035223 NH
6703
6704 If lnOldDtlPKey != fkey
6705 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
6706 *-- this checks that there is no more records left in BC PrePack info
6707 *-- after all matching to SLNs deleted. Made as a separate routine
6708 *-- because it must be called when detail key changed and when scan is finished.
6709 *-- Error info applied to Detail.
6710 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
6711 Endif
6712 lnOldDtlPKey = fkey
6713 lcPPackError = ""
6714 lcDtlError = ""
6715 Select (pceipoTD)
6716 *- 1008909 01/18/05 YIK
6717 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
6718 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
6719 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
6720 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
6721 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
6722 lcDtl_lbl_code = IIF(llRangeStyle, NULL, lbl_code) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
6723
6724 *- 1013522 10/17/05 12/02/05 YIK
6725 *- Check for the range style type P. For it there's no explosion to components and the range
6726 *- style info is not written into detail table, but it is still a range style and we should skip it.
6727 Local Array laRangP[1]
6728 laRangP[1] = 0
6729 *--- TR 1023892 NH
6730 IF .lALLOW_RANGE_HDR_LABEL
6731 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
6732 SELECT COUNT(*) ;
6733 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6734 ON d.division = r.division ;
6735 AND d.STYLE = r.rng_style ;
6736 AND d.color_code = r.rng_color ;
6737 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
6738 AND d.DIMENSION = r.rng_pack ;
6739 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
6740 INTO ARRAY laRangP
6741 ELSE
6742 *=== TR 1023892 NH
6743 Select Count(*) ;
6744 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6745 On d.division = r.division ;
6746 AND d.Style = r.rng_style ;
6747 AND d.color_code = r.rng_color ;
6748 AND d.lbl_code = r.rng_lbl ;
6749 AND d.Dimension = r.rng_pack ;
6750 INTO Array laRangP
6751 ENDIF && TR 1023892 NH
6752 llRangeStyle = llRangeStyle Or laRangP[1] > 0
6753 *= 1013522 YIK
6754
6755 llDtlHasError = (Errs_Flg_D = 'Y')
6756 *- 1008909 01/18/05 YIK
6757 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
6758 If llDtlHasError Or llRangeStyle
6759 *= 1008909
6760 Loop && For unresolved Details do not even bother...
6761 Endif
6762
6763 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
6764 *-- set to NULL if any C and/or L can be used for the PrePack:
6765 *- 08/25/04 YIK
6766 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
6767 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
6768 lcSQL = ;
6769 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
6770 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
6771 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
6772 " d.Dimension, Pack_Total," +;
6773 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
6774 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
6775 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
6776 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
6777 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
6778 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
6779 " Size_Num as Sizebucket" +;
6780 " from zzxscolr c" +;
6781 " join zzxstylr st"+;
6782 " on st.pkey = c.fkey "+;
6783 " join zzxppakh h" +;
6784 " on h.Division = c.Division" +;
6785 " and h.PPK_CODE = c.Dimension" +;
6786 " and h.Size_Code = st.Size_Code" +; && TR 1026025
6787 " join zzxppakd d" +;
6788 " on d.Fkey = h.PKey" +;
6789 " cross join zzxbuckt" +;
6790 " where c.Division = " + SQLFormatChar(division ) + ;
6791 " and c.Style = " + SQLFormatChar(Style ) + ;
6792 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
6793 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
6794 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
6795 " and c.PPack_Ok = 'Y'" +;
6796 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
6797 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
6798 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
6799 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
6800 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
6801 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
6802 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
6803
6804 v_SqlExec(lcSQL, "tcPPK")
6805 If Reccount("tcPPK") > 0
6806 lnPPK_SLN_Diff = pack_qty
6807 Else
6808 lnPPK_SLN_Diff = 0
6809 Endif
6810 Endif
6811 *- 1008909 01/18/05 YIK
6812 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
6813 If llDtlHasError Or llRangeStyle
6814 Loop && For unresolved Details do not even bother...
6815 Endif
6816
6817 Select (pceipoTS)
6818
6819 If Reccount("tcPPK") = 0
6820 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
6821 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
6822 Loop
6823 Endif
6824
6825 If tcPPK.active_ok = 'N'
6826 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
6827 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
6828 Loop
6829 Endif
6830
6831 If Errs_Flg_S = 'Y'
6832 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
6833 Loop && UPC/EAN/SKU is unesolved.
6834 Endif
6835
6836 lcStyle = style && *- TR 1064758 FH
6837 lcColor_code = color_code
6838 lcLbl_code = lbl_code
6839 lcDimension = Dimension
6840 lnSLN_Qty = SLN_Qty
6841 lnSizeBucket = sizebucket
6842
6843 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
6844 Select tcPPK
6845
6846 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
6847 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
6848 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
6849 AND Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code && *--- TR 1075660 03-Jan-2014 SK ===
6850
6851 If Found()
6852 Delete && in PrePack info leave only unresolved ones.
6853 Else
6854 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
6855 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
6856 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
6857 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
6858 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
6859 If !"Has errors in SLNs."$lcDtlError
6860 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
6861 Endif
6862 Endif
6863
6864 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
6865 *if lnPPK_SLN_Diff < 0
6866 *endif
6867 Endscan
6868 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
6869
6870 *- 1008909 01/18/05 YIK
6871 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
6872 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
6873 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
6874 Endif
6875 *- 1013522 10/17/05 12/02/05 YIK
6876 If Used("__RangeP")
6877 Use In __RangeP
6878 Endif
6879 *=
6880 *--- TR 1023892 NH
6881 SELECT(lnOldSelect)
6882 RETURN llRetVal
6883 *== TR 1023892 NH
6884
6885 Endproc
6886
6887 *----------------------------------------------------------------------------------------
6888 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
6889 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
6890 Procedure CheckSlnSet
6891 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
6892
6893 Local lnOldSelect
6894
6895 lnOldSelect = Select()
6896
6897 If !Empty(tcPPKError)
6898 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
6899 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
6900 Return
6901 Endif
6902
6903 Select tcPPK
6904 Scan
6905 tcDtlError = tcDtlError +;
6906 "Missing Prepack Component" + ;
6907 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
6908 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
6909 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
6910 "; Qty:"+Transform(Qty) + CRLF
6911 Endscan
6912
6913 If !Empty(tcDtlError)
6914 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
6915 Local lcErr
6916 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
6917 If !Empty(lcErr)
6918 tcDtlError = CRLF + tcDtlError
6919 Endif
6920 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
6921 Endif
6922
6923 Select (lnOldSelect)
6924
6925 Endproc
6926
6927 *----------------------------------------------------------------------------------------
6928
6929 ************************************************************************************
6930 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
6931 * 1. Try to substitute lbl_code with customer label when have the following conditions:
6932 * Header: customer
6933 * Detail: division,style,color_code
6934 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
6935 * resolve all detail division into header )
6936 ************************************************************************************
6937 Procedure ResolveCustomerLabel
6938 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
6939 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
6940 Local llRetVal, lnOldSelect
6941 llRetVal = .T.
6942 lnOldSelect = Select()
6943 With This
6944 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
6945 *--- TechRec 1048667 03-May-2011 GSternik ---
6946 *-- Not needed, already done in the calling CheckDetail
6947 *.LogEntry("Cascading Customer To Detail.")
6948 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
6949 *=== TechRec 1048667 03-May-2011 GSternik ===
6950 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
6951 .LogEntry("Substituding customer label.")
6952 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
6953 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
6954 .LogEntry("Auto creating style.")
6955 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
6956 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
6957 * PL 08/22/01 27847 Auto-create Customer SKU
6958 .LogEntry("Auto creating customer style.")
6959 *--- TechRec 1005163 18-May-2004 GS ---
6960 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
6961 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
6962 *=== TechRec 1005163 18-May-2004 GS ===
6963
6964 Endwith
6965 Select(lnOldSelect)
6966 Return llRetVal
6967 Endproc
6968
6969
6970 *----------------------------------------------------------------------------------------
6971 ************************************************************************************
6972 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
6973 ************************************************************************************
6974 Procedure CascadingCustomerToDetail
6975 Lparameters pceipoTH, pceipoTD
6976 Local llRetVal, lnOldSelect
6977 llRetVal = .T.
6978 lnOldSelect = Select()
6979 With This
6980 * set header/detail Relation
6981 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
6982 * --- TR 1019358 RLN 10/30/06
6983 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
6984 Replace All customer With &pceipoTH..customer, ;
6985 department With &pceipoTH..department ;
6986 IN (pceipoTD)
6987 * === TR 1019358
6988 Set Relation To
6989 Endwith
6990 Select(lnOldSelect)
6991 Return llRetVal
6992 Endproc
6993
6994 *----------------------------------------------------------------------------------------
6995 *---- TR 1019697 NH
6996 Procedure CascadingCustomerToSLN
6997 Lparameters pceipoTD, pceipoTS
6998 Local llRetVal, lnOldSelect
6999 llRetVal = .T.
7000 lnOldSelect = Select()
7001 With This
7002 * set detail/SLN Relation
7003 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7004 Replace All customer With &pceipoTD..customer In (pceipoTS)
7005 Set Relation To
7006 Endwith
7007 Select(lnOldSelect)
7008 Return llRetVal
7009 Endproc
7010 *==== TR 1019697 NH
7011
7012 *----------------------------------------------------------------------------------------
7013 ************************************************************************************
7014 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7015 ************************************************************************************
7016 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7017 * regardless of auto_create of style flag set in Customer Label Ref.
7018 Procedure SubstitudeValidLabel
7019 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7020 Local llRetVal, lnOldSelect
7021 llRetVal = .T.
7022 lnOldSelect = Select()
7023 With This
7024 *- 1010285 05/18/05 YIK
7025 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7026 *- if the SKU with the label is valid and active in the style master.
7027 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7028 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7029 *-- WHERE h.pkey= d.fkey AND ;
7030 *-- d.division= C.division AND h.customer= C.customer AND ;
7031 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7032 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7033 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7034 *-- INTO CURSOR tmpCurs
7035
7036 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7037 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7038 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7039 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7040 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7041 WHERE h.pkey= d.fkey And ;
7042 d.division= C.division And h.customer= C.customer And ;
7043 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7044 Not (MultiUPC = 'Y') And ;
7045 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7046 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7047 INTO Cursor tmpCurs
7048 *==
7049
7050 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7051 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7052 "customer+division+style+color_code+dimension")
7053 If llRetVal
7054 *- 1010285 05/18/05 YIK
7055 *- 1004785 05/04/04 YIK
7056 *- Added .. AND Empty(Errs_Msg_D)
7057 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7058 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7059 Select (pceipoTD)
7060 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7061 If tmpCurs.resv_label = "Y" Or ;
7062 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7063 AND tmpscolr.active_ok = "Y" )
7064 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7065 Endif
7066 Endscan
7067 *= 1010285
7068 Set Relation To
7069 Endif
7070 .TableClose('tmpCurs')
7071 Endwith
7072 Select(lnOldSelect)
7073 Return llRetVal
7074 Endproc
7075
7076 *----------------------------------------------------------------------------------------
7077 ************************************************************************************
7078 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7079 ************************************************************************************
7080 * encounter for both set up in customer label ref:
7081 * 1. empty label apply to all customer
7082 * 2. none empty customer will be specificly create only for that customer
7083 * either 1 or 2 exists but never both
7084 *
7085 * Get a list of distinct ourSKU to server side to join zzxcolr
7086 Procedure CreateOurSKU
7087 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7088 Local llRetVal, lnOldSelect
7089 llRetVal = .T.
7090 lnOldSelect = Select()
7091 With This
7092 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7093 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7094 WHERE h.pkey= d.fkey And ;
7095 d.division= C.division And h.customer= C.customer And ;
7096 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7097 l.auto_style= 'Y' And ;
7098 C.resv_label= 'Y' And ;
7099 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7100 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7101 INTO Cursor tmpCurs
7102 *--- TR 1019697 NH
7103 *!* SCAN
7104 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7105 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7106 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7107 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7108 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7109 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7110 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7111 *!* .LogEntry("Created style: " + lcOurSKU )
7112 *!* ELSE
7113 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7114 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7115 *!* ENDIF
7116 *!* ENDIF
7117 *!* ENDSCAN
7118 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7119 *=== TR 1019697 NH
7120 Endwith
7121 Select(lnOldSelect)
7122 Return llRetVal
7123 Endproc
7124
7125 *----------------------------------------------------------------------------------------
7126
7127 Procedure CreateCustomerStyle
7128 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7129 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7130 Local llRetVal, lnOldSelect
7131 llRetVal = .T.
7132 lnOldSelect = Select()
7133 With This
7134 *--- TechRec 1005164 18-May-2004 GS ---
7135 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7136 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7137 * Where h.pkey= d.fkey and ;
7138 * d.division= C.division and h.customer= C.customer and ;
7139 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7140 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7141 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7142 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7143 * Into Cursor tmpCurs
7144 If This.oHostProcess.lHaveSLN
7145 Select Distinct C.customer,;
7146 d.division,;
7147 d.Style,;
7148 d.color_code,;
7149 C.lbl_code,;
7150 d.Dimension ;
7151 FROM (pceipoTD) d ;
7152 JOIN (pceipoTH) h ;
7153 ON h.pkey = d.fkey ;
7154 JOIN (pceipoCR) C;
7155 ON d.division= C.division ;
7156 AND h.customer= C.customer ;
7157 JOIN (pcxclblr) l ;
7158 ON C.lbl_code= l.lbl_code ;
7159 WHERE l.auto_style= 'Y' ;
7160 AND C.resv_label= 'Y' ;
7161 AND C.AutoCustSKU= 'Y' ;
7162 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7163 And h.customer > ' ' ;
7164 AND d.division > ' ' ;
7165 AND d.Style > ' ' ;
7166 AND d.color_code > ' ';
7167 UNION ;
7168 SELECT Distinct C.customer,;
7169 d.division,;
7170 d.Style,;
7171 s.color_code,;
7172 C.lbl_code,;
7173 s.Dimension ;
7174 FROM (pceipoTS) s ;
7175 JOIN (pceipoTD) d ;
7176 ON d.pkey = s.fkey ;
7177 JOIN (pceipoTH) h ;
7178 ON h.pkey = d.fkey ;
7179 JOIN (pceipoCR) C ;
7180 ON d.division= C.division ;
7181 AND h.customer= C.customer ;
7182 JOIN (pcxclblr) l ;
7183 ON C.lbl_code= l.lbl_code ;
7184 WHERE l.auto_style= 'Y' ;
7185 AND C.resv_label= 'Y' ;
7186 AND C.AutoCustSKU= 'Y' ;
7187 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7188 And h.customer > ' ' ;
7189 AND d.division > ' ' ;
7190 AND d.Style > ' ' ;
7191 AND s.color_code > ' ';
7192 INTO Cursor tmpCurs
7193
7194 Else
7195
7196 Select Distinct C.customer,;
7197 d.division,;
7198 d.Style,;
7199 d.color_code,;
7200 C.lbl_code,;
7201 d.Dimension ;
7202 FROM (pceipoTD) d ;
7203 JOIN (pceipoTH) h ;
7204 ON h.pkey = d.fkey ;
7205 JOIN (pceipoCR) C ;
7206 ON d.division= C.division ;
7207 AND h.customer= C.customer ;
7208 JOIN (pcxclblr) l ;
7209 ON C.lbl_code= l.lbl_code ;
7210 WHERE l.auto_style= 'Y' ;
7211 AND C.resv_label= 'Y' ;
7212 AND C.AutoCustSKU= 'Y' ;
7213 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7214 And h.customer > ' ' ;
7215 AND d.division > ' ' ;
7216 AND d.Style > ' ' ;
7217 AND d.color_code > ' ';
7218 INTO Cursor tmpCurs
7219
7220 Endif
7221 *=== TechRec 1005164 18-May-2004 GS ===
7222 Scan
7223 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7224 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7225 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7226 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7227 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7228 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7229 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7230 .LogEntry("Created customer style: " + lcCustSKU )
7231 Else
7232 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7233 .LogWarning("Unable to create customer style: " + lcCustSKU )
7234 Endif
7235 Endif
7236 Endscan
7237 Endwith
7238 Select(lnOldSelect)
7239 Return llRetVal
7240 Endproc
7241
7242 *----------------------------------------------------------------------------------------
7243 ************************************************************************************
7244 * Validate UPC for all details
7245 ************************************************************************************
7246 Procedure CheckUpc
7247 Lparameters pceipoTH, pceipoTD,;
7248 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7249
7250 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7251 * Added Parameter pceipocr
7252 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7253
7254 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7255 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7256 lnSize_desc, llSLN
7257
7258 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7259 LOCAL lcIs_upcsku
7260 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7261
7262 llRetVal = .T.
7263 lcErrs_Msg= ""
7264 lnOldSelect = Select()
7265
7266 * cannot check for UPC if customer is empty
7267 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7268 * on Cust SKU or UPC.
7269 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7270
7271 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7272 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7273 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7274
7275 *--- TechRec 1005163 17-May-2004 GS ---
7276 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7277 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7278 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7279 *Order by h.customer, d.upc Into Cursor tmpCurs
7280
7281 *---- TR 1024667 NSD 5/31/07
7282 * If sizebucket = 0 then re-resolve.
7283
7284 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7285 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7286*!* If This.lHaveSLN
7287*!* Select h.customer,;
7288*!* d.upc,;
7289*!* d.pkey,;
7290*!* (pceipoTD) As Src;
7291*!* FROM (pceipoTH) h ;
7292*!* JOIN (pceipoTD) d ;
7293*!* ON h.pkey = d.fkey ;
7294*!* WHERE !Empty(d.upc) ;
7295*!* AND !Empty(h.customer) ;
7296*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7297*!* UNION All ;
7298*!* SELECT h.customer,;
7299*!* s.SLN_UPC As upc,;
7300*!* s.pkey,;
7301*!* (pceipoTS) As Src ;
7302*!* FROM (pceipoTH) h ;
7303*!* JOIN (pceipoTD) d ;
7304*!* ON d.fkey = h.pkey ;
7305*!* JOIN (pceipoTS) s ;
7306*!* ON s.fkey = d.pkey ;
7307*!* WHERE !Empty(s.SLN_UPC) ;
7308*!* AND !Empty(h.customer) ;
7309*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7310*!* ORDER By 1, 2 ;
7311*!* INTO Cursor tmpCurs
7312*!* Else
7313*!* Select h.Customer,;
7314*!* d.UPC,;
7315*!* d.PKey,;
7316*!* (pceipoTD) As Src;
7317*!* FROM (pceipoTH) h ;
7318*!* JOIN (pceipoTD) d ;
7319*!* ON h.pkey = d.fkey ;
7320*!* WHERE !Empty(d.upc) ;
7321*!* AND !Empty(h.customer) ;
7322*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7323*!* ORDER By 1, 2;
7324*!* INTO Cursor tmpCurs
7325*!* Endif
7326 *=== TechRec 1005163 17-May-2004 GS ===
7327
7328 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7329 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7330 FROM (pceipocr) ;
7331 GROUP BY customer ;
7332 INTO CURSOR __ResvCustSKU
7333 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7334
7335 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7336*!* select h.Customer;
7337*!* , d.UPC;
7338*!* , d.PKey;
7339*!* from (pceipoTH) h;
7340*!* join (pceipoTD) d;
7341*!* on h.PKey = d.FKey;
7342*!* where !Empty(d.UPC);
7343*!* and !Empty(h.Customer);
7344*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7345*!* order by 1, 2;
7346*!* into Cursor tmpCurs ReadWrite
7347
7348 Select h.customer;
7349 , d.upc;
7350 , d.pkey,;
7351 (pceipoTD) AS Src;
7352 from (pceipoTH) h;
7353 join (pceipoTD) d;
7354 on h.pkey = d.fkey;
7355 JOIN __ResvCustSKU r ;
7356 ON r.Customer = H.Customer ;
7357 where !Empty(d.upc);
7358 and !Empty(h.customer);
7359 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7360 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7361 order By 1, 2;
7362 into Cursor tmpCurs Readwrite
7363 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7364
7365*=== TechRec 1024522 25-Sep-2007 GSternik ===
7366
7367 lcOldCust = ""
7368 lcOldItem = ""
7369 Select tmpCurs
7370 If This.lUserInterface
7371 * Init Thermometer
7372 This.UpdateThermoCaption("Validating UPC(s)...")
7373 * TAN 31891 - JAZ - 5/20/02
7374 * This.InitThermo(RECC('tmpCurs'))
7375 This.InitThermo(RecCount('tmpCurs'))
7376 * End TAN 31891 - JAZ - 5/20/02
7377 l_nThermoCnt = 0
7378 EndIf
7379
7380 Scan
7381 If This.lUserInterface
7382 * Advance progress bar, if we're using one.
7383 l_nThermoCnt = l_nThermoCnt + 1
7384 This.AdvanceThermo(l_nThermoCnt)
7385 Endif
7386 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7387 lcErrs_Msg = ""
7388 lcOldCust = tmpCurs.customer
7389 lcOldItem = tmpCurs.upc
7390 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7391 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7392
7393 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7394 lcIs_upcsku = ' '
7395 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7396
7397 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7398 lcDivision = tmpCstdr.division
7399 lcStyle = tmpCstdr.Style
7400 lcColor_code = tmpCstdr.color_code
7401 lcLbl_code = tmpCstdr.lbl_code
7402 lcDimension = tmpCstdr.Dimension
7403 lnSizeBucket = tmpCstdr.size_bk
7404 lnSize_desc = tmpCstdr.size_desc
7405
7406 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7407 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7408 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7409
7410 Else
7411 lcErrs_Msg = ""
7412 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7413 lcDivision = tmpUpcnr.division
7414 lcStyle = tmpUpcnr.Style
7415 lcColor_code = tmpUpcnr.color_code
7416 lcLbl_code = tmpUpcnr.lbl_code
7417 lcDimension = tmpUpcnr.Dimension
7418 lnSizeBucket = tmpUpcnr.sizebucket
7419 lnSize_desc = tmpUpcnr.size_desc
7420 Else
7421 lcErrs_Msg = lcErrs_Msg + CRLF
7422 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7423 Store 0 To lnSizeBucket
7424 Endif
7425 Endif
7426 Endif && level break
7427
7428 *--- TechRec 1005163 17-May-2004 GS ---
7429 *Select (pceipoTD)
7430*!* llSLN = (tmpCurs.Src = pceipoTS)
7431*!* If llSLN
7432*!* Select (pceipoTS)
7433*!* Else
7434 Select (pceipoTD)
7435*!* Endif
7436 *=== TechRec 1005163 17-May-2004 GS ===
7437 *- 1010682 04/25/05 YIK
7438 *- Locate For pkey = tmpCurs.pkey
7439 lnWorkArea = Select()
7440 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7441 Scatter Name loEiPOtd Memo
7442 If !Empty(lcErrs_Msg)
7443*!* *--- TechRec 1005163 17-May-2004 GS ---
7444*!* If llSLN
7445*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7446*!* loEiPOtd.Errs_Flg_S = "Y"
7447*!* Else
7448*!* *=== TechRec 1005163 17-May-2004 GS ===
7449 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7450 loEiPOtd.Errs_Flg_D = "Y"
7451*!* Endif
7452 Endif
7453 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7454 loEiPOtd.Division = lcDivision
7455 loEiPOtd.Style = lcStyle
7456 loEiPOtd.Color_Code = lcColor_code
7457 loEiPOtd.Lbl_Code = lcLbl_code
7458 loEiPOtd.Dimension = lcDimension
7459 loEiPOtd.SizeBucket = lnSizeBucket
7460 loEiPOtd.Size_Desc = lnSize_desc
7461
7462 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7463 IF !EMPTY(lcIs_upcsku)
7464 loEiPOtd.Is_upcsku = lcIs_upcsku
7465 ENDIF
7466 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7467
7468 *--- TR 1019697 NH : clear rang style when bc style is set
7469 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7470 loEiPOtd.rng_style = ''
7471 loEiPOtd.rng_color = ''
7472 loEiPOtd.rng_lbl = ''
7473 loEiPOtd.rng_pack = ''
7474 Endif
7475 *=== TR 1019697 NH
7476 Endif
7477
7478 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7479 * only replace our SKU when no range style explosion happen
7480 *--- TechRec 1005163 17-May-2004 GS ---
7481 *If empty(&pceipoTD..rng_style)
7482 * Replace division With loEiPOtd.division, ;
7483 * style With loEiPOtd.style, ;
7484 * color_code With loEiPOtd.color_code, ;
7485 * lbl_code With loEiPOtd.lbl_code, ;
7486 * dimension With loEiPOtd.dimension, ;
7487 * sizebucket With loEiPOtd.sizebucket, ;
7488 * size_desc With loEiPOtd.size_desc, ;
7489 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7490 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7491 * In (pceipoTD)
7492 *Endif
7493 *- 1009508 3/16/05 YIK
7494 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7495 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7496 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7497 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7498 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7499
7500 Gather Name loEiPOtd Memo
7501 Endif
7502 *=== TechRec 1005163 17-May-2004 GS ===
7503 Endscan
7504 Use In tmpCurs
7505
7506 If This.lUserInterface
7507 * Reset Thermometer
7508 This.ResetThermo()
7509 Endif
7510
7511 If Used("tmpCstdr")
7512 Use In tmpCstdr
7513 Endif
7514 If Used("tmpUpcnr")
7515 Use In tmpUpcnr
7516 Endif
7517
7518 Select(lnOldSelect)
7519 Return llRetVal
7520 Endproc
7521
7522 *----------------------------------------------------------------------------------------
7523 ************************************************************************************
7524 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7525 ************************************************************************************
7526 Procedure ValidateOurSKU
7527 Lparameters pceipoTH, pceipoTD, pceipoTS
7528 Local llRetVal, lnOldSelect, lcScolrSQL
7529 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
7530
7531 *--- TechRec 1022705 21-Jun-2007 jjanand ---
7532 LOCAL llActiveCheck
7533 *=== TechRec 1022705 21-Jun-2007 jjanand ===
7534
7535 *--- TR 1017598 14-Sep-2006 SS
7536 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
7537
7538 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
7539
7540 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
7541
7542 *--- TR 1018193 18-NOV-2006 VKK
7543 lcErrs_Allowed_Msg = ""
7544 *=== TR 1018193 18-NOV-2006 VKK
7545
7546 *=== TR 1017598 14-Sep-2006 SS
7547
7548 * --- TR 1039400 3/31/09 CM
7549 LOCAL lcCurrentSku
7550 lcCurrentSku = ""
7551 * === TR 1039400 3/31/09 CM
7552
7553 llRetVal = .T.
7554 lnOldSelect = Select()
7555
7556 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
7557 *--- See VSS for Changes.
7558
7559 * for anything that resove to None blank h.customer, d.div/sty/col-
7560 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
7561 *- TAN 27166
7562 *- 1010682 04/25/05 YIK
7563 *- Added .. WHERE d.rng_style = ' '
7564
7565 *- 1017363 06/02/06 YIK
7566 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
7567
7568 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
7569 Select h.customer;
7570 , d.division;
7571 , d.Style;
7572 , d.color_code;
7573 , d.lbl_code;
7574 , d.Dimension;
7575 , d.sizebucket;
7576 , d.size_desc; && TR 1058045 11-29-2011 RKI
7577 , d.upc; && TR 1058045 11-29-2011 RKI
7578 , d.sku; && TR 1058045 11-29-2011 RKI
7579 , d.ean; && TR 1058045 11-29-2011 RKI
7580 , d.pkey;
7581 , (pceipoTD) As Src ;
7582 from (pceipoTH) h;
7583 join (pceipoTD) d ;
7584 on h.pkey = d.fkey ;
7585 where h.customer >' ' ;
7586 and d.division >' ' ;
7587 and d.Style >' ' ;
7588 and d.color_code >' ' ;
7589 UNION All;
7590 select h.customer;
7591 , s.division;
7592 , s.Style;
7593 , s.color_code;
7594 , s.lbl_code;
7595 , s.Dimension;
7596 , s.sizebucket;
7597 , s.size_desc; && TR 1058045 11-29-2011 RKI
7598 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
7599 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
7600 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
7601 , s.pkey;
7602 , (pceipoTS) As Src ;
7603 from (pceipoTS) s;
7604 join (pceipoTD) d ;
7605 on d.pkey = s.fkey;
7606 join (pceipoTH) h ;
7607 on h.pkey = d.fkey ;
7608 and h.customer > ' ' ;
7609 and s.division > ' ' ;
7610 and s.Style > ' ' ;
7611 and s.color_code > ' ' ;
7612 where d.rng_style = ' ' ;
7613 order By 2, 3, 4, 5, 6, 7, 1 ;
7614 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
7615
7616 *-- Order by SKU + Bucket + Customer !!!
7617 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
7618
7619 lcCnt = Reccount("tmpCurs")
7620 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
7621
7622 *--- This cursor will be used to cache Customer-Label Validations:
7623 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
7624 Index On customer + lbl_code Tag CustLbl
7625
7626 lcErrs_Msg = ''
7627 Select tmpCurs
7628 Scatter Memo Name oTmpCurs Blank
7629 * --- TR 1014834 RLN 08/10/06
7630
7631 *--- TR 1017598 14-Sep-2006 SS
7632 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7633
7634 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7635 llBookUnavail = (lcbk_unavl_sku = 'Y')
7636 llErrUnavail = (lcbk_unavl_sku = 'E')
7637 *=== TR 1017598 14-Sep-2006 SS
7638
7639 With oTmpCurs
7640 llSize_OK = .T.
7641 Scan
7642 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
7643 * --- TR 1027498 NSD 10/3/07
7644 * Clear error message after every line, not just every sku.
7645 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
7646 * === TR 1027498 NSD 10/3/07
7647
7648 * --- TR 1014834 RLN 08/10/06
7649 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
7650 llSize_OK = .T.
7651 If division # .division ;
7652 or Style # .Style ;
7653 or color_code # .color_code ;
7654 or lbl_code # .lbl_code ;
7655 or Dimension # .Dimension
7656 *-- SKU Changed... Let's make sure it is valid:
7657
7658 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
7659 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7660
7661 * --- TR 1039400 3/31/09 CM
7662 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
7663 * === TR 1039400 3/31/09 CM
7664
7665 * --- TR 1014834 RLN 08/10/06
7666 If division <> .division
7667 *--- TR 1017598 14-Sep-2006 SS
7668 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7669
7670 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7671 llBookUnavail = (lcbk_unavl_sku = 'Y')
7672 llErrUnavail = (lcbk_unavl_sku = 'E')
7673 *=== TR 1017598 14-Sep-2006 SS
7674 Endif
7675 * === TR 1014834
7676 lcErrs_Msg = ""
7677 .division = division
7678 .Style = Style
7679 .color_code = color_code
7680 .Dimension = Dimension
7681 .lbl_code = lbl_code && TR 1057867 FH
7682 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
7683 * --- TR 1014834 RLN 08/09/06
7684 lnSelect = Select()
7685 * Available sizes stored in Scolr
7686 *--- TR: 1021620 BR/NH
7687 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
7688 Lbl_Code, .Dimension)
7689
7690
7691*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
7692*!* "division = " + SQLFormatChar(division) + " AND " + ;
7693*!* "style = " + SQLFormatChar(Style) + " AND " + ;
7694*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
7695*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
7696*!* "dimension = " + SQLFormatChar(Dimension)
7697
7698*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
7699*!* Select (lnSelect)
7700*!* * === TR 1014834
7701*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
7702*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
7703
7704 *--- TechRec 1022705 20-Jun-2007 jjanand ---
7705 *!* IF tcTmpScolr.active_ok = 'N'
7706 llActiveCheck = This.lAllowInactiveStyleColors
7707 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
7708 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
7709 IF llActiveCheck
7710 *=== TechRec 1022705 20-Jun-2007 jjanand ===
7711
7712 lcErrs_Msg = "Inactive Style/Color"
7713 llStyle_OK = .F.
7714 ELSE
7715 lcErrs_Msg = ""
7716 llStyle_OK = .T.
7717 ENDIF
7718
7719 *--- TR 1040614 MAY-29-2009 BR
7720 llUnAvlBkCheck = .T.
7721 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
7722 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
7723
7724 *- 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
7725 IF llStyle_OK
7726 IF llUnAvlBkCheck
7727 lcErrs_Msg = "Style/Color combination is unavailable"
7728 llStyle_OK = .F.
7729 ELSE
7730 lcErrs_Msg = ""
7731 llStyle_OK = .T.
7732 ENDIF
7733 ENDIF
7734 *- TR 1062018 FH 06/08/12
7735 *=== TR 1040614 MAY-29-2009 BR
7736 ELSE
7737 *=== TR 1021620
7738 llStyle_OK = .F.
7739 This.GetStyleError(@lcErrs_Msg)
7740 Endif
7741 Endif && SKU Changed
7742
7743 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
7744 *- took out (customer # .customer Or .lbl_code # lbl_code)
7745 If llStyle_OK AND llSKU_changed
7746*!* If llStyle_OK And (;
7747*!* customer # .customer Or .lbl_code # lbl_code)
7748 .lbl_code = lbl_code
7749 .customer = customer
7750 llLabel_OK = .T.
7751 If !Empty(.lbl_code)
7752 If !Seek(.customer+.lbl_code, "curCustLbl")
7753 *- populate cursor of cached Customer/Lbl
7754 *- vl_clblr2() returns .F. if lbl is invalid for the customer
7755 Insert Into curCustLbl Values(;
7756 .customer, .lbl_code,;
7757 vl_clblr2(.lbl_code, "", , .customer))
7758 Endif
7759
7760 If !curCustLbl.is_Valid && always check from the cached table.
7761 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
7762 llLabel_OK = .F.
7763 Endif
7764 Endif
7765 Endif && Style OK
7766
7767 *--- TR 1058045 11-29-2011 RKI ---*
7768 lnPkey = Pkey
7769 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
7770 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
7771 replace sizebucket WITH lnSize_BK
7772 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
7773 DO CASE
7774 CASE tmpCurs.Src = (pceipoTD)
7775 replace sizebucket WITH lnSize_bk IN (pceipoTD)
7776 CASE tempcurs.Src = (pceipoTS)
7777 replace sizebucket WITH lnSize_bk IN (pceipoTD)
7778 Endcase
7779 ENDIF
7780 ENDIF
7781 SELECT tmpCurs
7782 *=== TR 1058045 11-29-2011 RKI ===*
7783
7784 * --- TR 1018184
7785 llAllowedSize_OK = .T.
7786 If llStyle_OK And llLabel_OK
7787 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
7788 .sizebucket = sizebucket
7789 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7790
7791 *- that's why we used Savlr
7792 * --- TR 1014834 RLN 08/09/06
7793 * I guess we really do not need Savlr...
7794 *llSize_OK = Evaluate("__Savlr.allow"
7795 *--- TR 1058045 11-29-2011 RKI ---*
7796 IF BETWEEN(.sizebucket,1,24)
7797 *=== TR 1058045 11-29-2011 RKI ===*
7798 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
7799 Transform(.sizebucket, "@L 99")) = 'Y'
7800
7801 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
7802 *if !llSize_OK
7803 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
7804 Transform(.sizebucket, "@L 99")) = 'Y'
7805 *--- TR 1058045 11-29-2011 RKI ---*
7806 ELSE
7807 llAllowedSize_OK = .F.
7808 ENDIF
7809 *=== TR 1058045 11-29-2011 RKI ===*
7810
7811 If !llAllowedSize_OK
7812 *--TR 1034769 JUL-21-2008 BR
7813 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
7814 lcErrs_Msg = "Invalid Available Sizes."
7815 *==TR 1034769 JUL-21-2008 BR
7816 Else
7817 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
7818 lcErrs_Msg = "Invalid Available Sizes."
7819 Endif
7820 Endif
7821
7822 *=== TR 1017598 14-Sep-2006 SS
7823 Endif
7824 Endif
7825 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
7826
7827 * for each detail line replace detail error msg if have one
7828 *--- TechRec 1005163 21-Jun-2004 GS ---
7829 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
7830 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
7831 * Errs_Flg_D with 'Y' in (pceipoTD)
7832 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
7833 If tmpCurs.Src = (pceipoTD)
7834 *--- TR 1017598 14-Sep-2006 SS
7835 If Not llAllowedSize_OK && if size is not allowed - error out always
7836 *--- TR 1018193 18-NOV-2006 VKK
7837 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
7838 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
7839 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
7840 Errs_Flg_D With 'Y' In (pceipoTD)
7841 *=== TR 1018193 18-NOV-2006 VKK
7842 Else
7843 *=== TR 1017598 14-Sep-2006 SS
7844
7845 * --- TR 1014834 RLN 08/08/06
7846 If !llSize_OK
7847 If llBookUnavail
7848 Replace UnAvailSize With .T. In (pceipoTD)
7849 Else
7850 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
7851 If llErrUnavail && error as invalid available sizes.
7852 * === TR 1014834
7853 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
7854 Errs_Flg_D With 'Y' In (pceipoTD)
7855 Endif
7856 *=== TR 1017598 14-Sep-2006 SS
7857 ENDIF
7858 *--- TR 1021620 NH 04/12/07
7859 ELSE
7860
7861
7862 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
7863 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
7864 IF llSKU_changed
7865 * --- TR 1039400 3/31/09 CM
7866 * Commented out and added seek/scan while to determine how many particular style/color
7867 * combinations should be flagged as inactive
7868 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
7869 Select(pceipoTD)
7870 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
7871 If Seek(lcCurrentSku)
7872 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
7873 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
7874 Endscan
7875 Endif
7876 * === TR 1039400 3/31/09 CM
7877 endif
7878 *--TR 1057867 FH
7879
7880 *=== TR 1021620 NH 04/12/07
7881 Endif && TR 1014834
7882 Endif && TR 1017598
7883 ELSE
7884 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
7885 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
7886 Errs_Flg_S With 'Y' In (pceipoTS)
7887
7888 *- 1010682 04/25/05 YIK
7889 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
7890 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
7891 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
7892 Select(pceipoTS)
7893 lnFKey = fkey
7894 Select(pceipoTD)
7895 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
7896 *=== TechRec 1016817 04-May-2006 GS ===
7897 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
7898 Errs_Flg_D With 'Y' In (pceipoTD)
7899 ENDIF
7900 ENDIF
7901 Endif
7902 *=== TechRec 1005163 21-Jun-2004 GS ===
7903 Endif
7904 Endscan
7905 Endwith
7906
7907 Use In Select("curCustLbl")
7908
7909 Select(lnOldSelect)
7910 Return llRetVal
7911 Endproc
7912
7913 *----------------------------------------------------------------------------------------
7914
7915 Function GetCustLabel
7916 Lparameters pcCust
7917 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
7918
7919 llRetVal = True
7920 lnSelect = Select()
7921 l_vRetVal = ''
7922 lcCursor = GetUniqueFileName()
7923
7924 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
7925
7926 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
7927
7928 If llRetVal
7929 Select(lcCursor)
7930 l_vRetVal = Alltrim(lbl_code )
7931
7932 Use In (lcCursor)
7933 Endif
7934
7935 Select (lnSelect)
7936 Return l_vRetVal
7937 Endfunc
7938
7939 *----------------------------------------------------------------------------------------
7940 Function ResolveMultiPrepacks
7941 Lparameters pcTransHeader, pcTransDetail, pcMppk
7942 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
7943
7944 llRetVal = True
7945 lnOldSelect = Select()
7946
7947
7948
7949 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
7950 FROM (pcTransHeader) h, (pcTransDetail) d ;
7951 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
7952 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
7953 Order By 1,2,3,4,5 Into Cursor __TmpCursor
7954
7955 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
7956 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
7957 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
7958 *!* d.rng_style= '' ;
7959 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
7960
7961 With This
7962 .cSQLTempTable=""
7963
7964 If .GenerateSQLTempTable('__TmpCursor')
7965 If .PopulateSQLTempTable('__TmpCursor')
7966 If !Empty(.cSQLTempTable)
7967
7968 .LogEntry("Exploding MultiPack.")
7969
7970 *AND h.mpack_code = t.dimension
7971 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
7972 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
7973
7974 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
7975
7976 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
7977
7978 If llMultPpkToExplode
7979
7980 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
7981 "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
7982
7983 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
7984
7985
7986 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
7987
7988 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
7989 WHERE 0=1 Into Cursor __ppk2
7990
7991
7992 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
7993 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
7994
7995
7996 If Used("__ppk1")
7997 Use In __ppk1
7998 Endif
7999
8000 If Used("__ppk2")
8001 Use In __ppk2
8002 Endif
8003
8004 Select __MppkH
8005 Index On pkey Tag pkey
8006 Select __MppkD
8007 Index On division+Style Tag DivStyle
8008 Select tcMppkVer
8009 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8010 Set Order To MpackRef
8011 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8012
8013 *****************************************************************************
8014 *!* SELECT DISTINCT pkey FROM __MppkD ;
8015 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8016 *!* INTO CURSOR __DtlExpl
8017
8018
8019 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8020 *!* FROM __MppkD m, (pcTransDetail) d ;
8021 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8022 *!* INTO CURSOR __DtlExpl
8023
8024 && TR 1011644 VSS 27-09-2005
8025
8026 Select Distinct d.pkey ;
8027 FROM __MppkD mp, (pcTransDetail) d ;
8028 WHERE d.Errs_Flg_D= "N" ; &&no error
8029 And mp.Style = d.Style ;
8030 AND mp.color_code = d.color_code ;
8031 AND mp.lbl_code = d.lbl_code ;
8032 AND mp.Dimension = d.Dimension;
8033 AND d.implosion = 'Y';
8034 INTO Cursor __DtlExpl
8035
8036 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8037
8038 Endif
8039 Endif
8040 Endif
8041 Endif
8042 Endwith
8043
8044 If Used("__MppkH")
8045 Use In __MppkH
8046 Endif
8047 If Used("__MppkD")
8048 Use In __MppkD
8049 Endif
8050 If Used("tcMppkVer")
8051 Use In tcMppkVer
8052 Endif
8053 If Used("__DtlExpl")
8054 Use In __DtlExpl
8055 Endif
8056 If Used("__TmpCursor")
8057 Use In __TmpCursor
8058 Endif
8059
8060 Select(lnOldSelect)
8061 Return llRetVal
8062
8063 Endfunc
8064
8065 *----------------------------------------------------------------------------------------
8066 Procedure ExplodeMultiPackVertical
8067 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8068 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8069 llRetVal = .T.
8070 lnOldSelect = Select()
8071
8072 .LogEntry("Exploding multi pack details into vertical cursor.")
8073 Select (pcDetailtoExplode)
8074
8075 Scan
8076
8077 If Seek(pkey, pcTransDetail, "Pkey")
8078
8079 * Current working trans detail
8080 Select (pcTransDetail)
8081 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8082 lnCurDtlTotal_qty= total_qty
8083
8084
8085 Scatter Name loTransDetail Memo
8086 * delete current working trans detail already have image
8087 * in loTransDetail
8088 Delete In (pcTransDetail)
8089
8090
8091 Select (pcMultDetailVert)
8092 * Find 1st match of OURSKU
8093 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8094 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8095
8096
8097 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8098 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8099 * Exploding detail line
8100 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8101 If !Empty(loTransDetail.pkey)
8102
8103 Select (pcMultDetailVert)
8104 Scatter Name loVert Memo
8105
8106 Select (pcTransDetail)
8107 Append Blank
8108 Gather Name loTransDetail Memo
8109
8110 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8111 sizebucket With loVert.sizebucket, ;
8112 size_desc With loVert.size_desc, ;
8113 division With loVert.division, ;
8114 STYLE With loVert.Style, ;
8115 color_code With loVert.color_code, ;
8116 lbl_code With loVert.lbl_code, ;
8117 DIMENSION With loVert.ppk_code In (pcTransDetail)
8118 Else
8119 .LogEntry("Pkey cannot be empty.")
8120 llRetVal= .F. && Cannot get Pkey from bcsysnum
8121 Exit
8122 Endif
8123
8124 Select (pcMultDetailVert)
8125 Endscan
8126 Else
8127 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8128 llRetVal= .F. && Should be in pcMultDetailVert
8129 Exit
8130 Endif
8131 Endif
8132
8133 If !llRetVal &&Get out of scan when have some problem
8134 Exit
8135 Endif
8136 Endscan
8137
8138 Select(lnOldSelect)
8139 Return llRetVal
8140 Endproc
8141 *=== TR 1011644 23-AUG-2005 KA
8142
8143 *----------------------------------------------------------------------------------------
8144 Procedure ExplodeMultPackRef
8145 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8146 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8147 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8148
8149 lnOldSele = Select()
8150 lcDivStyle = ""
8151 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8152
8153 llRetVal= .T.
8154 lnCurDtlFkey= 0
8155 lnMultiplyQty = 0
8156
8157 .LogEntry("Exploding multi pack details.")
8158
8159 Select (pcMultPackDetail)
8160 Set Order To DivStyle
8161 Scan
8162
8163 If lnCurDtlFkey<> fkey
8164 lnCurDtlFkey = fkey
8165 If Seek(fkey, pcMultPackHeader , "PKEY")
8166 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8167 Else
8168 llRetVal = .F.
8169 Exit
8170 Endif
8171 Endif
8172
8173
8174 * only run once per Div + Style
8175 If !(lcDivStyle == division + Style)
8176 lcDivStyle = division + Style
8177 * Insert a record for each size bucket with a caption *
8178 If !v_GetSizeHeadings(division, Style, "__xSizer")
8179 llRetVal = .F.
8180 Exit
8181 Endif
8182 Endif
8183
8184
8185 lnSizeQty = 1
8186 Select (pcMultPackDetail)
8187 Scatter Memvar Memo
8188
8189 lnSizePosition = 1
8190 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8191 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8192 lnSizeQty = ppk_qty
8193
8194 m.sizebucket = lnSizePosition
8195 m.size_desc = lcSizeName
8196 m.total_qty = lnSizeQty
8197 m.multQty = lnMultiplyQty
8198
8199 If lnSizeQty > 0 && Only want buckets with activity!
8200 Insert Into (pcMultPackTarget) From Memvar
8201 Endif
8202 Select (pcMultPackDetail)
8203
8204 Endscan
8205
8206 This.TableClose("__xSizer")
8207 Select (pcMultPackDetail)
8208 Select (lnOldSele)
8209 Return llRetVal
8210 Endproc
8211
8212 *----------------------------------------------------------------------------------------
8213 *--- TechRec 1016817 04-May-2006 GS ---
8214 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8215 Procedure GetStyleError
8216
8217 Lparameter tcErrorMsg, toTmpCurs
8218
8219 Do Case
8220 Case vl_scolr(division,,, Style, color_code, lbl_code)
8221 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8222
8223 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8224 tcErrorMsg = "Invalid Label code." + CRLF
8225
8226 Case !Empty(Style) And vl_Stylr(division,,, Style)
8227 tcErrorMsg = "Invalid Color code." + CRLF
8228
8229 Otherwise
8230 tcErrorMsg = "Invalid Style." + CRLF
8231 Endcase
8232 Endproc
8233
8234 *----------------------------------------------------------------------------------------
8235
8236 **********************************************************************************
8237 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8238 **********************************************************************************
8239 Procedure PopulateInboundUOM
8240 Lparameters pceipoTH, pceipoTD, pceipoCR
8241 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8242 llRetVal = .T.
8243 lnOldSelect = Select()
8244
8245 With This
8246
8247 *****************************************************************************
8248 * unconditionally reset all base_uom and uom_factor
8249 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8250
8251 *****************************************************************************
8252 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8253 * Server-side join previous list to get cursor of scolr to populate base_uom
8254 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8255 FROM (pceipoTH) h, (pceipoTD) d ;
8256 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8257 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8258 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8259 * TAN 31891 - JAZ - 5/20/02 @@@
8260 * If Recc("__TmpCursor")> 0
8261 If Reccount("__TmpCursor")> 0
8262 * End TAN 31891 - JAZ - 5/20/02
8263 .cSQLTempTable=""
8264 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8265 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8266 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8267 "Where s.division= t.division and s.style= t.style and "+;
8268 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8269 "s.dimension= t.dimension"
8270 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8271 * Populate style UOM
8272 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8273 Endif
8274 .TableClose("tcUOM")
8275 .TableClose("__TmpCursor")
8276
8277 *****************************************************************************
8278 * Get distinct list of Inbound UOM and style UOM
8279 * Server-side join previous list to populate UOM conversion factor
8280 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8281 WHERE ib_uom<>'' And base_uom<>'' ;
8282 INTO Cursor __TmpCursor
8283 * TAN 31891 - JAZ - 5/20/02
8284 * If Recc("__TmpCursor")> 0
8285 If Reccount("__TmpCursor")> 0
8286 * End TAN 31891 - JAZ - 5/20/02
8287 .cSQLTempTable=""
8288 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8289 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8290 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8291 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8292 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8293 * Populate style UOM
8294 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8295 Endif
8296 .TableClose("tcUOMFactor")
8297 .TableClose("__TmpCursor")
8298
8299 Endwith
8300 Select(lnOldSelect)
8301 Return llRetVal
8302 Endproc
8303
8304 *----------------------------------------------------------------------------------------
8305
8306 Procedure PopulateBaseUOM
8307 Lparameters pceipoTD, pcUOM
8308 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8309 llRetVal = .T.
8310 lnOldSelect = Select()
8311
8312 With This
8313 Select (pcUOM)
8314 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8315 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8316 "division+style+color_code+lbl_code+dimension")
8317 Select (pceipoTD)
8318 If llRetVal
8319 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8320 FOR !Empty(&pcUOM..uom)
8321 Endif
8322 Set Relation To
8323 Endwith
8324 Select(lnOldSelect)
8325 Return llRetVal
8326 Endproc
8327
8328 *----------------------------------------------------------------------------------------
8329
8330 Procedure PopulateUOMFactor
8331 Lparameters pceipoTD, pcUOMFactor
8332 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8333 llRetVal = .T.
8334 lnOldSelect = Select()
8335
8336 With This
8337 Select (pcUOMFactor)
8338 Index On uom+uom_convert Tag IB_BaseUOM
8339 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8340 "ib_uom+base_uom")
8341 Select (pceipoTD)
8342 If llRetVal
8343 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8344 FOR !Empty(&pcUOMFactor..uom_factor)
8345 Endif
8346 Set Relation To
8347 Endwith
8348 Select(lnOldSelect)
8349 Return llRetVal
8350 Endproc
8351
8352 *----------------------------------------------------------------------------------------
8353
8354 Procedure ResolvePrepack
8355 Lparameters pceipoTH, pceipoTD, pceipoCR
8356
8357 LOCAL llRetVal
8358 llRetVal = .t.
8359 IF VARTYPE(This.oResolvePrepack) <> "O"
8360 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8361 ENDIF
8362
8363 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8364
8365 IF NOT llRetVal
8366 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8367 RETURN llRetVal
8368 ENDIF
8369
8370 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8371 this.oResolvePrepack.cLogName = this.cLogName
8372
8373 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8374 This.oResolvePrepack.c850Control = This.c850Control
8375 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8376
8377 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
8378
8379 RETURN llRetVal
8380
8381 ENDPROC
8382
8383 *------------------------------------------------------------------------
8384
8385 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8386 Procedure ValidateCharges
8387 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8388
8389 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8390 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8391 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8392 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8393 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8394 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8395 lcDtlError = "Has errors in Charges." + CRLF
8396 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8397 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8398 SELECT (tcEipoTH)
8399 lntcEipoTHrec = RECNO()
8400 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8401
8402 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8403 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8404 v_sqlExec(;
8405 "select d.FKey"+;
8406 " , d.Chrg_Type"+;
8407 " , d.Chrg_Flag"+;
8408 " , d.Active_Ok"+;
8409 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8410 " from zzxChrgD d"+;
8411 " join zzxChrTR t"+;
8412 " on t.Chrg_Type = d.Chrg_Type"+;
8413 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8414 Select qChrgD
8415 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8416 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8417 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8418 v_sqlExec(;
8419 "select Customer"+;
8420 " , Division"+;
8421 " , Store"+;
8422 " , Center_Code"+;
8423 " , Season"+;
8424 " , PKey"+;
8425 " , Rank_Seq"+;
8426 " from zzxchrgh", "qChrgH")
8427 Select qChrgH
8428 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8429 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8430 Index On division+customer+Store+Center_Code+Season Tag divcust
8431 If division = ' ' And customer = ' '
8432 lnDefaultKey = pkey
8433 Endif
8434
8435 Select (tcEiPOTR)
8436 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8437 Scan
8438 lcChrg_Type = Chrg_Type
8439 Select (tcEiPOtd)
8440 lcDivision = division
8441 lcCustomer = customer
8442 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8443 lnFkeyEipoTD = fkey
8444 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8445 lcCenter_Code = &tcEipoTH..center_Code
8446 lcStore = &tcEipoTH..Store
8447 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8448 lcSeason = &tcEipoTH..Season
8449 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8450 ELSE
8451 lcCenter_Code = ""
8452 lcStore = ""
8453 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8454 lcSeason = ""
8455 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8456 ENDIF
8457 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8458
8459 Select qChrgH
8460 Do Case
8461 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8462*!* Case Seek(lcDivision+lcCustomer)
8463*!* lnFKey = pkey
8464*!* Case Seek(' '+lcCustomer, "qChrgH")
8465*!* lnFKey = pkey
8466*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8467*!* Case Seek(lcDivision+' ')
8468*!* lnFKey = pkey
8469*!* Otherwise
8470*!* lnFKey = lnDefaultKey
8471 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8472*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8473*!* lnFKey = pkey
8474*!*
8475*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8476*!* lnFKey = pkey
8477*!*
8478*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8479*!* lnFKey = pkey
8480*!*
8481*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8482*!* lnFKey = pkey
8483
8484*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8485*!* lnFKey = pkey
8486*!*
8487*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8488*!* lnFKey = pkey
8489
8490 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
8491 lnFKey = pkey
8492
8493 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
8494 lnFKey = pkey
8495
8496 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
8497 lnFKey = pkey
8498
8499 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
8500 lnFKey = pkey
8501
8502 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
8503 lnFKey = pkey
8504
8505 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
8506 lnFKey = pkey
8507
8508 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
8509 lnFKey = pkey
8510
8511 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
8512 lnFKey = pkey
8513
8514 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
8515 lnFKey = pkey
8516
8517 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
8518 lnFKey = pkey
8519 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8520
8521 Otherwise
8522 lnFKey = lnDefaultKey
8523 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8524 Endcase
8525 Select (tcEiPOTR)
8526 If Empty(lnFKey)
8527 Replace Errs_Flg_R With "Y",;
8528 Errs_Msg_R With "No Charges set up for "+;
8529 Trim(lcDivision)+'/'+Trim(lcCustomer)
8530 Else
8531 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
8532 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
8533
8534 *--- Check if the Charge still active:
8535 If qChrgD.Active_Ok # 'Y'
8536 Replace Errs_Flg_R With "Y",;
8537 Errs_Msg_R With lcErrorMsg3
8538 Endif
8539
8540 If Empty(Chrg_Flag)
8541 *-- Set Charge Type from Resolution if success
8542 If Errs_Flg_R # "Y"
8543 Replace Chrg_Flag With lcResolved_Chrg_Flag
8544 Endif
8545 Else
8546 If Chrg_Flag # lcResolved_Chrg_Flag
8547 Replace Errs_Flg_R With "Y",;
8548 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
8549 Endif
8550 Endif
8551 Else
8552 Replace Errs_Flg_R With "Y",;
8553 Errs_Msg_R With lcErrorMsg1
8554 lnFKey = fkey
8555 lcResolved_Chrg_Flag = ""
8556 Endif
8557 Endif
8558
8559 If Errs_Flg_R = "Y"
8560 Select(tcEiPOtd)
8561 If !lcDtlError$Errs_Msg_D
8562 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
8563 Errs_Flg_D With 'Y'
8564 Endif
8565 ELSE
8566 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
8567* Replace Chrg_Cost With qChrgD.Chrg_Cost
8568 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
8569 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
8570 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
8571 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
8572 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
8573 Endif
8574 Endscan
8575
8576 Set Relation To
8577 Use In Select("qChrgH")
8578 Use In Select("qChrgD")
8579 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8580 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
8581 GO lntcEipoTHrec IN (tcEipoTH)
8582 ENDIF
8583 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8584
8585 Endproc
8586 *=== TechRec 1028745 05-Feb-2008 GSternik ===
8587
8588 *------------------------------------------------------------------------
8589
8590 *----------------------------------------------------------------------------------------
8591 *--- TR 1034481 NH
8592 PROCEDURE MarkHeaderForMissing855ControlRef
8593 LPARAMETERS pceipoTH
8594
8595 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
8596
8597 llRetVal = .t.
8598 lnOldSelect = SELECT()
8599 lcZzeoprcr = "Oprcr" + SYS(2015)
8600 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
8601 llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
8602
8603 IF USED(lcZzeoprcr)
8604 INDEX on customer TAG customer
8605 INDEX on division TAG division
8606
8607 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
8608 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
8609 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
8610
8611 USE IN (lcZzeoprcr)
8612 ENDIF
8613
8614 SELECT(lnOldSelect)
8615 RETURN llRetVal
8616
8617 ENDPROC
8618 *=== TR 1034481 NH
8619 *----------------------------------------------------------------------------------------
8620
8621 *--- TR 1035491 4-Nov-2008 Goutam
8622 ************************************************************************************
8623 * Move SLN to Detail.
8624 ************************************************************************************
8625 Procedure MoveSLNToDTLs
8626 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8627 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8628 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
8629 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
8630
8631 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
8632 lnLine_Seq
8633
8634 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8635 LOCAL lcSQL ,loIPOtdn
8636 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8637
8638 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
8639
8640 llRetVal = true
8641 lnOldSelect = Select()
8642 lnDetailPrice = 0
8643
8644 *--- TR 1036614 8-Jun-2009 Goutam
8645 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
8646
8647*!* select t.Customer ;
8648*!* , t.FKey ;
8649*!* , t.PKey ;
8650*!* , c.price_flg ;
8651*!* from (pcTmpCursor) t ;
8652*!* join zzeipocr c ;
8653*!* on c.division = t.division ;
8654*!* and c.customer = t.customer ;
8655*!* join (pceipoTD) d ;
8656*!* on d.pkey = t.dtlPkey ;
8657*!* where c.slntodtl = 'Y' ;
8658*!* and d.slntodtl <> 'Y' ;
8659*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
8660*!* into Cursor __tmpipots ;
8661*!* order by t.fkey, t.Customer, t.PKey
8662
8663 *=== TR 1036614 8-Jun-2009 Goutam
8664
8665 *-- #1 Create detail record from pceipoTS
8666 SELECT __tmpipots
8667 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
8668 GO top
8669 lnSkipedPSFkey = 0
8670 lnPSFkey = 0
8671 lnCoor_Code = 1
8672 lnLine_Seq = 0
8673 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
8674
8675 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8676 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8677 ENDIF
8678 DO WHILE NOT EOF()
8679 lnPSFkey = Fkey
8680
8681 *--- TR 1049029 24-Aug-2010 Partha ---
8682 IF lnPSFkey <> lnSkipedPSFkey
8683 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
8684 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
8685 ENDIF
8686 *=== TR 1049029 24-Aug-2010 Partha ===
8687
8688 lnStartPkey = lnStartPkey + 1
8689 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8690 lnLine_Seq = lnLine_Seq + 1
8691 SELECT (pceipoTD)
8692 SCATTER NAME loIPOtd MEMO
8693 loIPOtd.pkey = lnStartPkey
8694 loIPOtd.Line_Seq = lnLine_Seq
8695
8696 *-FH 1077588 - detail's header pkey
8697 lnHfkey = fkey
8698
8699 *--- TechRec 1056973 06-Dec-2011 jisingh ---
8700 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
8701 *- 1060291 04/02/2012 YIK/FH
8702*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8703*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
8704 SELECT (pczzeiPOtWhse)
8705 lnDocNum = doc_num
8706 lnEdiLine = edi_line
8707 lnSlnLine = sln_line
8708
8709 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8710 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
8711 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
8712
8713 SELECT (pceipoTD)
8714 *= 1060291
8715 ENDIF
8716 *=== TechRec 1056973 06-Dec-2011 jisingh ===
8717
8718 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
8719*!* loIPOtd.slntodtl = 'Y'
8720
8721 *--- TR 1045922 05-MAR-2010 HNISAR
8722 *- 1060291 03/30/2012 YIK
8723 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
8724*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8725*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
8726 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8727 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
8728 *=== TechRec 1056973 09-Nov-2011 jisingh ===
8729 *=== TR 1045922 05-MAR-2010 HNISAR
8730
8731
8732
8733 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
8734 *--- TechRec 1063327 16-Aug-2012 jjanand ---
8735 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
8736*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
8737*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
8738*!* loIPOtd.assort_qty = loIPOtd.total_qty
8739*!* ENDIF
8740 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
8741*!* IF EMPTY(loIPOtd.Assortment)
8742*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8743*!* IF loIPOtd.assort_qty = 0
8744*!* loIPOtd.assort_qty = loIPOtd.total_qty
8745*!* ENDIF
8746*!* ENDIF
8747
8748 IF EMPTY(loIPOtd.Assortment)
8749 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8750 ENDIF
8751 IF EMPTY(loIPOtd.assort_qty)
8752 loIPOtd.assort_qty = loIPOtd.total_qty
8753 ENDIF
8754 *=== TechRec 1063327 16-Aug-2012 jjanand ===
8755 *- TR 1062810 FH
8756
8757 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
8758 loIPOtd.PO1_UPC = loIPOtd.UPC
8759 loIPOtd.PO1_SKU = loIPOtd.SKU
8760 loIPOtd.po1_price = loIPOtd.org_price
8761 loIPOtd.Division = &pceipoTS..Division
8762 loIPOtd.Style = &pceipoTS..Style
8763 loIPOtd.Color_code = &pceipoTS..Color_code
8764 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
8765 loIPOtd.Dimension = &pceipoTS..Dimension
8766 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
8767 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
8768 loIPOtd.UPC = &pceipoTS..SLN_UPC
8769 *- 03/19/09 1038539, 1039344 YIK
8770 loIPOtd.SKU = &pceipoTS..SLN_SKU
8771 *- TR 1051757 FH 04/19/11
8772 loIPOtd.aux_sku = &pceipoTS..aux_sku
8773
8774 *--- TechRec 1056973 07-Dec-2011 jisingh ---
8775 loIPOtd.sln01 = &pceipoTS..sln01
8776 *=== TechRec 1056973 07-Dec-2011 jisingh ===
8777
8778 *--- TR 1049029 30-Aug-2010 Partha ---
8779
8780*!* *--- TR 1047912 23-Jun-2010 Partha ---
8781*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
8782*!* *=== TR 1047912 23-Jun-2010 Partha ===
8783*!*
8784*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
8785*!*
8786*!* *=== TR 1047912 23-Jun-2010 Partha ===
8787*!* ENDIF
8788*!* *=== TR 1047912 23-Jun-2010 Partha ===
8789*!*
8790*!* *--- TR 1047912 23-Jun-2010 Partha ---
8791*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
8792*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8793*!* ELSE
8794*!* lnDetailPrice = &pceipoTD..Org_Price
8795*!* ENDIF
8796*!* *=== TR 1047912 23-Jun-2010 Partha ===
8797
8798 DO CASE
8799 CASE loIPOtd.ppk_action = 'B'
8800 *- 02/18/11 1052584 YIK
8801 *- Moved calculation of ppk_qty here
8802 loIPOtd.ppk_qty = lnTotSLNQty
8803
8804 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
8805
8806 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
8807 *loIPOtd.ppk_action = 'X'
8808 loIPOtd.ppk_action = 'S'
8809 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
8810 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
8811 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
8812 *- 02/18/11 YIK 1052584
8813 *- moved calculation of ppk_qty higher
8814 *-loIPOtd.ppk_qty = loIPOtd.total_qty
8815
8816 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
8817 *- 02/18/11 YIK 1052584
8818 *- Moved calculation of ppk_qty here
8819 loIPOtd.ppk_qty = lnTotSLNQty
8820
8821 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
8822
8823 IF loIPOtd.ppk_action = 'Q'
8824 loIPOtd.ppk_action = 'M'
8825 ENDIF
8826
8827 *- 02/18/11 YIK 1052584
8828 *- moved calculation of ppk_qty higher
8829 *-loIPOtd.ppk_qty = loIPOtd.total_qty
8830
8831 lnDetailPrice = &pceipoTD..Org_Price
8832
8833 CASE loIPOtd.ppk_action = 'P'
8834 *-TR 1062018/1064343 FH - moved up
8835 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
8836 *- TR 1062018/1064343 FH - moved up
8837 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
8838 loIPOtd.ppk_action = 'D'
8839 lnDetailPrice = loIPOtd. Org_Price/ lnTotSLNQty
8840 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
8841 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
8842
8843
8844 OTHERWISE
8845 *-TR 1062018/1064343 FH - moved up
8846 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
8847 *- TR 1062018/1064343 FH - moved up
8848 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
8849 lnDetailPrice = &pceipoTD..Org_Price
8850 loIPOtd.ppk_qty = lnTotSLNQty
8851
8852 ENDCASE
8853 *=== TR 1049029 30-Aug-2010 Partha ===
8854
8855 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
8856 IF __tmpipots.price_flg = "E"
8857 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
8858 ELSE
8859 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
8860 ENDIF
8861
8862 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
8863 loIPOtd.Errs_flg_d = "N"
8864 loIPOtd.Errs_msg_d = ""
8865 *=== TR 1038353 NH
8866
8867 APPEND BLANK
8868 GATHER NAME loIPOtd MEMO
8869
8870 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
8871
8872 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
8873 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
8874 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
8875
8876 &lcSQL
8877 SELECT _tmpipodnt
8878 SCAN
8879 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
8880 SELECT "Vzzeipotd_notes_iPOproc"
8881 SCATTER NAME loIPOtdn MEMO
8882
8883 APPEND BLANK
8884 loIPOtdn.Fkey = lnStartPkey
8885 loIPOtdn.Pkey = v_nextPkey("SysNotes")
8886
8887 GATHER NAME loIPOtdn MEMO
8888 ENDIF
8889
8890 ENDSCAN
8891 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
8892
8893 ENDIF && TR 1043037 OCT-06-2009 BR
8894 ENDIF
8895 SELECT __tmpipots
8896 SKIP IN __tmpipots
8897 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
8898
8899 *- TR 1062018/1064343 FH
8900 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
8901 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
8902 *- TR 1062018/1064343 FH
8903 DELETE IN (pceipoTD)
8904
8905 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
8906
8907 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
8908 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
8909 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
8910
8911 ENDIF && TR 1043037 OCT-06-2009 BR
8912
8913 lnCoor_Code = lnCoor_Code + 1
8914 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8915 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8916 ENDIF
8917 lnLine_Seq = 0
8918 ENDIF
8919 ENDDO
8920 USE IN __tmpipots
8921
8922 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
8923
8924 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8925 This.Tableupdate("Vzzeipotd_notes_iPOproc")
8926 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8927
8928 ENDIF && TR 1043037 OCT-06-2009 BR
8929
8930 SELECT (lnOldSelect)
8931 RETURN llRetVal
8932 ENDPROC
8933
8934*=======================================================================
8935
8936 *---- get total sln qty for a detail line
8937 FUNCTION getPriceFromIPOts
8938 LPARAMETERS pceipoTS, pnPrice
8939 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
8940 lnUnitPrice = 0
8941 IF pnPrice > 0
8942 lnOldSelect = SELECT()
8943
8944 SELECT (pceipoTS)
8945 lnFkey = Fkey
8946 lnSLNQty = SLN_Qty
8947 .PushRecordSet()
8948 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
8949 lnUnitPrice = pnPrice/lnSLNTotalQty
8950 .PopRecordSet()
8951
8952 SELECT (lnOldSelect)
8953 ENDIF
8954
8955 RETURN lnUnitPrice
8956 ENDFUNC
8957
8958 ************************************************************************************
8959 * Resolve BC SKU from SLN records and create customer style data.
8960 *--- This is splitted 1st part from function ResolveStyleFromSLN
8961 ************************************************************************************
8962 Procedure ResolveBCSkuFromSLN
8963 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8964 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8965 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
8966 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
8967 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
8968 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
8969
8970 lnOldSelect = Select()
8971 llRetVal = .T. && 1040686
8972 *--- TR 1036614 3-Mar-2010 Goutam
8973 lcErrs_Msg = ""
8974 lcDivision = ""
8975 *=== TR 1036614 3-Mar-2010 Goutam
8976
8977 *-- #1 Resolve SLN SKUs
8978 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
8979 *- 03/19/09 TR ? Retrofit TR1038539 YIK
8980 *- added SLN_SKU
8981 *- Removed WHERE ...and !Empty(s.SLN_UPC)
8982
8983 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
8984 * Added , s.sln_qty
8985 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
8986
8987 select h.Customer;
8988 , s.FKey;
8989 , s.SLN_UPC as UPC;
8990 , s.SLN_SKU as SKU ;
8991 , h.department ;
8992 , h.store ;
8993 , s.PKey;
8994 , .F. as SLN_Error;
8995 , Empty(d.SizeBucket) as Unresolved;
8996 , s.Division;
8997 , s.Style;
8998 , s.Color_Code;
8999 , s.SizeBucket;
9000 , d.Pkey as dtlPkey;
9001 , 'N' as IsPPK;
9002 , SPACE(5) as ppk_code;
9003 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9004 , s.sln_qty ;
9005 from (pceipoTH) h;
9006 join (pceipoTD) d ;
9007 on d.FKey = h.PKey;
9008 join (pceipoTS) s ;
9009 on s.FKey = d.PKey ;
9010 where !Empty(h.Customer) ;
9011 order by 1, 2;
9012 into Cursor tmpCurs ReadWrite
9013
9014* , s.Lbl_Code;
9015* , s.Dimension;
9016
9017*- 1040686
9018
9019 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9020 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9021 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9022 IF llRetVal
9023 .PopulateSQLTempTable("tcCustUpc")
9024 ENDIF
9025
9026 llRetVal = llRetVal AND v_sqlexec(;
9027 "SELECT x.upc,d.* "+;
9028 " FROM zzxcstdr d"+ ;
9029 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9030 " JOIN " + this.cSQLTempTable + " x " + ;
9031 " ON d.customer = x.customer " +;
9032 " AND d.cust_style = x.upc " + ;
9033 " WHERE h.IB_resolv = 'Y'" + ;
9034 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9035 SELECT tmpCstdr_upc
9036 INDEX on customer + upc TAG cust_upc
9037
9038
9039 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9040 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9041 IF llRetVal
9042 .PopulateSQLTempTable("tcDistUpc")
9043 ENDIF
9044
9045 llRetVal = llRetVal AND v_sqlexec(;
9046 "SELECT x.upc,d.* "+;
9047 " FROM zzeupcnr d"+ ;
9048 " JOIN " + this.cSQLTempTable + " x " + ;
9049 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9050 SELECT tmpUpcnr
9051 INDEX on upc TAG upc
9052
9053
9054 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9055 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9056 IF llRetVal
9057 .PopulateSQLTempTable("tcDistCustSku")
9058 ENDIF
9059 llRetVal = llRetVal AND v_sqlexec(;
9060 "SELECT x.sku,d.* "+;
9061 " FROM zzxcstdr d"+ ;
9062 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9063 " JOIN " + this.cSQLTempTable + " x " + ;
9064 " ON d.customer = x.customer " +;
9065 " AND d.cust_style = x.sku " + ;
9066 " WHERE h.IB_resolv = 'Y'" + ;
9067 " AND d.Size_Desc>'' " + ;
9068 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9069 SELECT tmpCstdr_sku
9070 INDEX ON customer + cust_style TAG cust_sku
9071
9072 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9073 UNION ;
9074 SELECT customer,sku FROM tmpCstdr_sku ;
9075 GROUP BY customer,sku ;
9076 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9077 INDEX ON customer+sku TAG cust_sku
9078 *=-===-=-=-=-=-=-=-
9079
9080*- 1040686
9081
9082 Select tmpCurs
9083 If This.lUserInterface
9084 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9085 This.InitThermo(RecCount())
9086 EndIf
9087
9088 lcOldCust = ""
9089 lcOldUPC = ""
9090 *- 03/19/09 1038539 YIK
9091 lcOldItem = ''
9092 Local lcSku_resolv, lcOldSku_resolv
9093 lcSku_resolv = ""
9094 *=
9095
9096 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9097 If This.lUserInterface
9098 * Advance progress bar, if we're using one.
9099 This.AdvanceThermo(RecNo())
9100 EndIf
9101 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9102 IF !EMPTY(tmpCurs.UPC)
9103
9104 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9105 lcErrs_Msg = ""
9106 lcOldCust = tmpCurs.Customer
9107 lcOldUPC = tmpCurs.UPC
9108
9109 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9110 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9111*- 1040686
9112*!* lcDivision = tmpCstdr.division
9113*!* lcStyle = tmpCstdr.Style
9114*!* lcColor_Code = tmpCstdr.Color_Code
9115*!* lcLbl_Code = tmpCstdr.Lbl_Code
9116*!* lcDimension = tmpCstdr.Dimension
9117*!* lnSizeBucket = tmpCstdr.Size_Bk
9118*!* lnSize_Desc = tmpCstdr.Size_Desc
9119 lcDivision = tmpCstdr_upc.division
9120 lcStyle = tmpCstdr_upc.Style
9121 lcColor_Code = tmpCstdr_upc.Color_Code
9122 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9123 lcDimension = tmpCstdr_upc.Dimension
9124 lnSizeBucket = tmpCstdr_upc.Size_Bk
9125 lnSize_Desc = tmpCstdr_upc.Size_Desc
9126*- 1040686
9127 Else
9128 lcErrs_Msg = ""
9129 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9130 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9131 lcDivision = tmpUpcnr.Division
9132 lcStyle = tmpUpcnr.Style
9133 lcColor_Code = tmpUpcnr.Color_Code
9134 lcLbl_Code = tmpUpcnr.Lbl_Code
9135 lcDimension = tmpUpcnr.Dimension
9136 lnSizeBucket = tmpUpcnr.SizeBucket
9137 lnSize_Desc = tmpUpcnr.Size_Desc
9138 ELSE
9139 *-&&1040686
9140 *lcErrs_Msg = lcErrs_Msg + CRLF
9141 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9142 *-&&1040686
9143 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9144 lnSizeBucket = 0
9145 Endif
9146 Endif
9147 Endif && level break
9148 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9149 *- Added resolution on SKU
9150 ENDIF && TmpCurs.UPC
9151 *- 03/17/09 TR 1038539 YIK
9152 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9153 *- but UPC resolution failed.
9154 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9155 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9156
9157 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9158 lcErrs_Msg = ""
9159 lcOldCust = tmpCurs.customer
9160 lcOldItem = tmpCurs.sku
9161
9162 *- 1040686
9163 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9164 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9165 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9166 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9167 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9168 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9169 Store 0 To lnSizeBucket
9170 ELSE
9171 *- TR 1074276 FH - adding UPPER()
9172 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9173 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9174 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9175 Store 0 To lnSizeBucket
9176 ELSE
9177*!* lcDivision = tmpCstdr.division
9178*!* lcStyle = tmpCstdr.Style
9179*!* lcColor_code = tmpCstdr.color_code
9180*!* lcLbl_code = tmpCstdr.lbl_code
9181*!* lcDimension = tmpCstdr.Dimension
9182*!* lnSizeBucket = tmpCstdr.size_bk
9183*!* lnSize_desc = tmpCstdr.size_desc
9184 lcDivision = tmpCstdr_sku.division
9185 lcStyle = tmpCstdr_sku.Style
9186 lcColor_code = tmpCstdr_sku.color_code
9187 lcLbl_code = tmpCstdr_sku.lbl_code
9188 lcDimension = tmpCstdr_sku.Dimension
9189 lnSizeBucket = tmpCstdr_sku.size_bk
9190 lnSize_desc = tmpCstdr_sku.size_desc
9191 ENDIF
9192 ENDIF
9193 *- 1040686
9194 ENDIF
9195 ENDIF
9196 *== 1038539 Resolution on SKU
9197
9198 Select (pceipoTS)
9199 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9200
9201 Scatter Name loEiPOTS Memo
9202 If !Empty(lcErrs_Msg)
9203 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9204 loEiPOTS.Errs_Flg_S = "Y"
9205 replace Sln_Error with .T. in tmpCurs
9206 Else
9207 replace Division with lcDivision in tmpCurs
9208 Endif
9209
9210 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9211 loEiPOTS.Division = lcDivision
9212 loEiPOTS.Style = lcStyle
9213 loEiPOTS.Color_Code = lcColor_code
9214 loEiPOTS.Lbl_Code = lcLbl_code
9215 loEiPOTS.Dimension = lcDimension
9216 loEiPOTS.SizeBucket = lnSizeBucket
9217 loEiPOTS.Size_Desc = lnSize_Desc
9218 Endif
9219
9220 Gather Name loEiPOTS Memo
9221
9222 EndScan
9223
9224*- 1060291 07/02/12 YIK
9225*- The code below makes no sense. It takes the first prepack found for the SLN.
9226*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9227 *--- TR 1036614 17-Mar-2010 Goutam
9228*-- SELECT tmpCurs
9229*-- SCAN FOR IsPPK = 'N'
9230*-- Select (pceipoTS)
9231*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9232*-- Scatter Name loEiPOTS Memo
9233*--
9234*-- IF NOT EMPTY(loEiPOTS.Dimension)
9235*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9236*-- IF !EMPTY(lcppk_code)
9237*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9238*-- ENDIF
9239*-- ENDIF
9240*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9241*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9242*-- 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')
9243*-- SELECT __tmpDimCurs
9244*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9245*-- lcppk_code = dimension
9246*-- USE IN SELECT('__tmpDimCurs')
9247*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9248*-- 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)
9249*-- SELECT __tmpDimCurs
9250*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9251*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9252*-- ENDIF
9253*-- USE IN SELECT('__tmpDimCurs')
9254*-- ENDIF
9255*-- ENDIF
9256*-- ENDSCAN
9257 *--- TR 1036614 17-Mar-2010 Goutam
9258
9259 *--- TR 1038353 NH - error out dtl line for SLN error
9260 UPDATE td SET Style_SLN_OK = 'N' ;
9261 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9262 WHERE ts.errs_flg_s ='Y'
9263 *=== TR 1038353 NH
9264
9265 If This.lUserInterface
9266 * Reset Thermometer
9267 This.ResetThermo()
9268 EndIf
9269
9270 *--- TR 1036614 8-Jun-2009 Goutam
9271 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9272 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9273
9274 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9275 lnSelect = SELECT()
9276
9277 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9278 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9279
9280 Select tmpErrSlnLines
9281 Scan
9282 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9283 Endscan
9284
9285 This.TableClose("tmpErrSlnLines")
9286
9287 Select (lnSelect )
9288 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9289
9290 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9291 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9292 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9293 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9294 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9295 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9296 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9297 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9298
9299 This.TableClose("tmpCurs")
9300
9301 *=== TR 1036614 8-Jun-2009 Goutam
9302
9303 *-1040686
9304 USE IN SELECT("tcCustUpc")
9305 USE IN SELECT("tmpCstdr_upc")
9306 USE IN SELECT("tcDistUpc")
9307 USE IN SELECT("tmpUpcnr")
9308 USE IN SELECT("tcDistCustSku")
9309 USE IN SELECT("tmpCstdr_sku")
9310 USE IN SELECT("tcAmbigSku")
9311 *-1040686
9312
9313 Select(lnOldSelect)
9314 Return llRetVal
9315 Endproc
9316
9317
9318 *--------------------------------------------
9319 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9320 *--------------------------------------------
9321 Procedure GetImplodeSQL
9322 *-- Populates cImplodeSQL
9323 SET TextMerge OFF NoShow
9324*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9325 Text to this.cImplodeSQL flags 1
9326--* TR-1067132, made it as sql comment -- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9327declare @Division char(3), @Style varChar(50), @Customer char(7),
9328 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9329
9330set @Customer = ?cCustomer
9331set @Division = ?cDivision
9332set @Style = ?cStyle
9333
9334-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9335select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9336 from zzeipocr_expl
9337 where Customer = @Customer
9338 and Division = @Division
9339
9340select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9341
9342--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9343
9344-- Output Values:
9345--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9346declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9347
9348-- first SQL:
9349if @CR_Lbl > ''
9350select top 1 @Color_Code = c.Color_Code
9351 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9352 , @Dimension = c.Dimension
9353 , @Size = Min(z.Size01)
9354-- , c.Lbl_Code as SColR_Lbl
9355 from zzxSColR c
9356 join zzxStylR st
9357 on st.PKey = c.FKey
9358 join zzxPPakH ph
9359 on ph.Division = c.Division
9360 and ph.Size_Code = st.Size_Code
9361 and ph.Ppk_Code = c.Dimension
9362 and c.Color_Code = case
9363 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9364 else c.Color_Code end
9365 join zzxPPakD pd
9366 on pd.FKey = ph.PKey
9367 join zzxSizer z
9368 on z.Division = c.Division
9369 and z.Size_Code = st.Size_Code
9370 cross join zzxBuckt b
9371 left join #ImplodeSLN i
9372 on i.Color_Code = case
9373 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9374 else pd.Color_Code end
9375 and (i.Lbl_Code = case
9376 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9377 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9378 and i.Dimension = pd.Dimension
9379 and i.SizeBucket = b.Size_Num
9380 where c.Style = @Style
9381 and c.Division = @Division
9382 and c.PPack_OK = 'Y'
9383 and c.Active_OK = 'Y'
9384 and ph.Active_OK = 'Y'
9385 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9386 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9387 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9388 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9389 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9390 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9391 and (c.Lbl_Code = case
9392 when @SLN_Lbl > ''
9393 then @SLN_Lbl
9394 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9395 group by c.PKey, ph.Pack_qty
9396 , c.Color_code, c.Lbl_Code, c.Dimension
9397having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9398 and sum(i.Qty) = ph.Pack_qty
9399 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9400 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9401
9402IF @CR_Lbl > '' and @@ROWCOUNT > 0
9403 select @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01
9404
9405ELSE BEGIN
9406
9407select top 1 @Color_Code = c.Color_Code
9408 , @Lbl_Code = c.Lbl_Code
9409 , @Dimension = c.Dimension
9410 , @Size = Min(z.Size01)
9411 from zzxSColR c
9412 join zzxStylR st
9413 on st.PKey = c.FKey
9414 join zzxPPakH ph
9415 on ph.Division = c.Division
9416 and ph.Size_Code = st.Size_Code
9417 and ph.Ppk_Code = c.Dimension
9418 and c.Color_Code = case
9419 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9420 else c.Color_Code end
9421 join zzxPPakD pd
9422 on pd.FKey = ph.PKey
9423 join zzxSizer z
9424 on z.Division = c.Division
9425 and z.Size_Code = st.Size_Code
9426 cross join zzxBuckt b
9427 left join #ImplodeSLN i
9428 on i.Color_Code = case
9429 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9430 else pd.Color_Code end
9431 and (i.Lbl_Code = case
9432 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9433 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9434 and i.Dimension = pd.Dimension
9435 and i.SizeBucket = b.Size_Num
9436 where c.Style = @Style
9437 and c.Division = @Division
9438 and c.PPack_OK = 'Y'
9439 and c.Active_OK = 'Y'
9440 and ph.Active_OK = 'Y'
9441 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9442 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9443 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9444 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9445 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9446 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9447 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9448 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9449 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9450 group by c.PKey, ph.Pack_qty
9451 , c.Color_code, c.Lbl_Code, c.Dimension
9452having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9453 and sum(i.Qty) = ph.Pack_qty
9454 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9455 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9456 , c.Lbl_code -- blank one goes first if there is no match
9457
9458select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9459 where @Color_Code is not null
9460END
9461EndText
9462
9463*--- TechRec 1073664 20-Sep-2013 GSternik ---
9464 Text to this.cImplodeRangeSQL flags 1
9465declare @Division char(3)
9466set @Division = ?cDivision
9467
9468-- Output Values:
9469declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9470
9471select @Style = rh.Rng_Style
9472 , @Color_Code = rh.Rng_Color
9473 , @Lbl_Code = rh.Rng_Lbl
9474 , @Dimension = rh.Rng_Pack
9475 , @SizeBucket = rng_bk
9476 from zzxRangH rh with (NoLock)
9477 join zzxRangD rd with (NoLock)
9478 on rd.FKey = rh.PKey
9479 --join zzxSColR c
9480 -- on c.Division = rh.Division
9481 -- and c.Style = rh.Rng_Style
9482 -- and c.Color_Code = rh.Rng_Color
9483 -- and c.Lbl_Code = rh.Rng_Lbl
9484 -- and c.Dimension = rh.Rng_Pack
9485 join zzxBuckt b with (NoLock)
9486 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9487 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9488 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9489 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9490 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9491 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
9492 left join #ImplodeSLN i
9493 on i.Style = rd.Style
9494 and i.Color_Code = rd.Color_Code
9495 and i.Lbl_Code = rd.Lbl_Code
9496 and i.Dimension = rd.Dimension
9497 and i.SizeBucket = b.Size_Num
9498 and i.Division = rd.Division
9499 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9500 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9501 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9502 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9503 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9504 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
9505 where rh.Rng_Type = 'P'
9506 and rh.Division = @Division
9507-- and c.Active_OK = 'Y'
9508 group by rh.Rng_Style
9509 , rh.Rng_Color
9510 , rh.Rng_Lbl
9511 , rh.Rng_Pack
9512 , rng_bk
9513having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9514 and sum(i.Qty) = Max(rh.Rng_Qty)
9515
9516if @Style is not null -- @@RowCount > 0
9517select @Size = case @SizeBucket
9518 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
9519 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
9520 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
9521 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
9522 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
9523 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
9524 from zzxStylR s with (NoLock)
9525 join zzxSizeR z with (NoLock)
9526 on z.Division = s.Division
9527 and z.Size_Code = s.Size_Code
9528 where s.Division = @Division
9529 and s.Style = @Style
9530
9531select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
9532 where @Style is not null
9533EndText
9534*=== TechRec 1073664 20-Sep-2013 GSternik ===
9535
9536 EndProc
9537
9538 *---------------------------------
9539 *--- This function will generate PPK SKU and updates detail with it.
9540 *--- This is splitted 2nd part from function ResolveStyleFromSLN
9541 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
9542 *---------------------------------
9543 Procedure ResolvePPKSkuAndUpdateDetail
9544 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
9545 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9546 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9547 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
9548 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
9549 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
9550
9551 llRetVal = .T.
9552 lnOldSelect = Select()
9553
9554 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
9555 Dimension laBuckets(goEnv.MaxBuckets)
9556
9557 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
9558 Select tmpCurs
9559 lnFKey = 0
9560
9561 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
9562
9563 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
9564 Scan
9565 If FKey # lnFKey
9566 lnFKey = FKey
9567
9568 If SLN_Error or !Unresolved
9569 llDeleteSLN = .T.
9570 Else
9571 llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
9572
9573 If !llDeleteSLN
9574 Select (pceipoCR)
9575 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
9576
9577 *--- TR 1036614 10-Jun-2009 Goutam
9578 *llDeleteSLN = StyleFromSLN < "Y"
9579 llDeleteSLN = StyleFromSLN < "O"
9580 *=== TR 1036614 10-Jun-2009 Goutam
9581
9582 Select tmpCurs
9583 EndIf
9584 EndIf
9585
9586 If !llDeleteSLN
9587 lnRecNo = RecNo()
9588
9589 Scan while FKey = lnFKey
9590 If SLN_Error
9591 *-- One SLN with error exists.
9592 llDeleteSLN = .T.
9593 Exit
9594 EndIf
9595 EndScan
9596
9597 Go lnRecNo
9598 EndIf
9599 EndIf
9600
9601 If llDeleteSLN
9602 Delete
9603 EndIf
9604 EndScan
9605
9606
9607 *-- #3 -- Updating Details with PPK BC SKU:
9608 lcOldCust = ""
9609 lcOldSKU = ""
9610 lnFKey = 0
9611 lnRecNo = This.CountTotalRecs('tmpCurs')
9612
9613 If lnRecNo > 0
9614 *-- Need for optimization:
9615
9616 If This.lUserInterface
9617 This.UpdateThermoCaption("Resolving Style From SLN...")
9618 This.InitThermo(lnRecNo + 1)
9619 lnRecNo = 1
9620 Endif
9621 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
9622
9623 *- 1041704 07/30/09 YIK
9624 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9625 *-- Let's rely on the field types in the UPC table:
9626 *v_SQLExec("create table #ImplodeSLN " + ;
9627 * "( 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)
9628 * " Size_Desc Char(10), Qty Int, PKey Int)")
9629 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
9630 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
9631 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9632
9633 Select (pceipoTD)
9634 lcOldOrder = Order()
9635
9636 *- 03/23/09 YIK
9637 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
9638 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
9639 Index on Customer+SKU+UPC+Assortment tag CustSKU
9640 lcOldUPC = ''
9641 *==
9642
9643 If This.lUserInterface
9644 This.AdvanceThermo(lnRecNo)
9645 EndIf
9646
9647 Select tmpCurs
9648 Locate
9649 cCustomer = Customer
9650
9651 Do while .T. && Scan replacement
9652 if FKey # lnFKey && Will trigger @ EOF :o)
9653 If llProcess
9654 If llImplodeOK
9655 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
9656
9657 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9658 *-- Let's check if they belong to the Range Style 'P'
9659 If Reccount("qPPK") = 0 && Prepack not found
9660 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
9661 EndIf
9662 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9663
9664 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
9665 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9666 Select (pceipoTS)
9667 *- insert into #implodeSLN
9668 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
9669 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9670 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9671 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9672 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9673 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
9674 Endif
9675 EndIf && llImplodeOK
9676 *========= 1041704 07/30/09 YIK
9677
9678 select (pceipoTD)
9679 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
9680 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9681 lcOldCust = Customer
9682 lcOldSKU = SKU
9683
9684 *- 03/23/09 YIK
9685 *-- Update all records with the same CustSKU
9686 *- =Seek(lcOldCust+lcOldSKU) && First matching record
9687 lcOldUPC = UPC
9688 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
9689
9690 *==
9691 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
9692 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9693 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
9694 replace Division with cDivision, ;
9695 Style with qPPK.Style, ;
9696 Color_Code with qPPK.Color_Code, ;
9697 Lbl_Code with qPPK.Lbl_Code, ;
9698 Dimension with qPPK.Dimension,;
9699 SizeBucket with qPPK.SizeBucket;
9700 Size_Desc with qPPk.Size01;
9701 Style_SLN_OK with 'Y' ;
9702 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9703 Else
9704
9705 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
9706 *--- TR 1036614 12-Jun-2009 Goutam
9707 IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
9708 *=== TR 1036614 12-Jun-2009 Goutam
9709 *--- TR 1056329 02-Nov-11 SK
9710 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9711 replace Style_SLN_OK with 'N' ;
9712 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9713 *--- TR 1036614 12-Jun-2009 Goutam
9714 ENDIF
9715 *=== TR 1036614 12-Jun-2009 Goutam
9716
9717 ENDIF
9718 Else && llProcess flag is not set
9719 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9720 Select (pceipoTS)
9721 *- insert into #implodeSLN
9722 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
9723 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9724 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9725 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9726 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9727 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
9728 *=== 1041704
9729 EndIf
9730 EndIf && Process Detail
9731
9732 Select tmpCurs
9733 if Eof()
9734 Exit
9735 EndIf
9736
9737 lnFKey = FKey
9738 cCustomer = Customer
9739 Select (pceipoTD)
9740 =Seek(lnFKey, pceipoTD, "PKey")
9741
9742 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
9743
9744 llImplodeOK = llProcess
9745
9746 If llImplodeOK
9747 store 0 to laBuckets
9748 lnPackTotal = 0
9749
9750 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
9751 Select (pceipoTS)
9752 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9753
9754 cDivision = Division
9755 cStyle = Style
9756 lcColor_Code = Color_Code
9757 lcLbl_Code = Lbl_Code
9758 lcDimension = Dimension
9759 EndIf
9760
9761 Else && The same FKey
9762 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
9763 Select (pceipoTS)
9764 if Division # cDivision;
9765 or Style # cStyle
9766 *- 1041704 YIK 07/29/09
9767 *- Allow multicolor prepacks
9768 *-- or Color_Code # lcColor_Code;
9769 *-- or Lbl_Code # lcLbl_Code;
9770 *-- or Dimension # lcDimension
9771
9772 llImplodeOK = .F.
9773 ELSE
9774 *- insert into #implodeSLN
9775 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
9776 v_SQLExec("insert into #ImplodeSLN values ('"+;
9777 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
9778 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
9779 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
9780 *=== 1041704
9781 EndIf
9782 EndIf
9783 EndIf && FKey Changed
9784
9785 if llImplodeOK
9786 *-- (pceipoTS) is selected!
9787 laBuckets[SizeBucket] = Sln_Qty
9788 lnPackTotal = lnPackTotal + Sln_Qty
9789 EndIf
9790
9791 Select tmpCurs
9792 Skip
9793
9794 If This.lUserInterface
9795 lnRecNo = lnRecNo + 1
9796 This.AdvanceThermo(lnRecNo)
9797 Endif
9798 EndDo && Endscan
9799
9800 Select (pceipoTD)
9801 Set Order to (lcOldOrder)
9802 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
9803 *v_SQLExec("DROP table #ImplodeSLN ")
9804 EndIf && Have data to Implode
9805
9806 *--- TR 1036614 11-Jun-2009 Goutam
9807 *Use In tmpCurs
9808 *=== TR 1036614 11-Jun-2009 Goutam
9809
9810 If This.lUserInterface
9811 * Reset Thermometer
9812 This.ResetThermo()
9813 Endif
9814
9815 Select(lnOldSelect)
9816 Return llRetVal
9817 Endproc
9818 *=== TR 1035491 4-Nov-2008 Goutam
9819
9820*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
9821*!*
9822* TR 1037925 - As per Krishna/Shenba
9823* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
9824* This is getting moved in TR 1037925
9825
9826*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
9827*!* *===========================================================================================
9828*!* Function ResolveCustShipper
9829*!* Lparameters pceipoTH, pceipoCR
9830*!* LOCAL lnSelect, llRetVal
9831
9832*!* lnSelect = SELECT()
9833
9834*!* WITH This
9835*!*
9836*!* SELECT distinct h.customer, h.division, ;
9837*!* h.cust_shipper ;
9838*!* FROM (pceipoTH) h, (pceipoCR) r ;
9839*!* WHERE r.resv_cust_ship = 'Y' and ;
9840*!* h.customer = r.customer and ;
9841*!* h.division = r.division ;
9842*!* INTO CURSOR '_tmpCustShipper'
9843*!*
9844*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
9845*!*
9846*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
9847*!*
9848*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
9849*!* REPLACE ALL shipper WITH '' In (pceipoTH)
9850*!* SET RELATION TO
9851*!* ENDIF
9852*!*
9853*!* SELECT '_tmpCustShipper'
9854
9855*!* .cSQLTempTable = ""
9856*!*
9857*!* IF .GenerateSQLTempTable('_tmpCustShipper')
9858*!* IF .PopulateSQLTempTable('_tmpCustShipper')
9859*!* IF !EMPTY(.cSQLTempTable)
9860*!*
9861*!* *---- Matching with customer, cust_shipper, division
9862*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
9863*!* "s.shipper " + ;
9864*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
9865*!* "Where s.customer = t.customer and " + ;
9866*!* "s.division = t.division and " + ;
9867*!* "s.cust_shipper = t.cust_shipper "
9868*!*
9869*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
9870*!*
9871*!* IF llRetVal and RECCOUNT('_custShipper') > 0
9872*!* SELECT _custShipper
9873*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
9874*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
9875*!* IF llRetVal
9876*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
9877*!* SET RELATION TO
9878*!* ENDIF
9879*!* ENDIF
9880*!* ENDIF
9881*!* ENDIF
9882*!* ENDIF
9883*!*
9884*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
9885*!* FROM (pceipoTH) h, (pceipoCR) r ;
9886*!* WHERE r.resv_cust_ship = 'Y' and ;
9887*!* h.customer = r.customer and ;
9888*!* h.division = r.division and ;
9889*!* EMPTY(h.shipper) ;
9890*!* INTO CURSOR '_tmpCustShipper'
9891*!*
9892*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
9893*!*
9894*!* SELECT '_tmpCustShipper'
9895
9896*!* .cSQLTempTable = ""
9897*!*
9898*!* IF .GenerateSQLTempTable('_tmpCustShipper')
9899*!* IF .PopulateSQLTempTable('_tmpCustShipper')
9900*!* IF !EMPTY(.cSQLTempTable)
9901*!*
9902*!* *---- Matching with customer, cust shipper, and division = ''
9903*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
9904*!* "s.shipper " + ;
9905*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
9906*!* "Where s.customer = t.customer and " + ;
9907*!* "s.division = '' and " + ;
9908*!* "s.cust_shipper = t.cust_shipper "
9909*!*
9910*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
9911*!*
9912*!* IF llRetVal and RECCOUNT('_custShipper') > 0
9913*!* SELECT _custShipper
9914*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
9915*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
9916*!*
9917*!* IF llRetVal
9918*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
9919*!* SET RELATION TO
9920*!* ENDIF
9921*!*
9922*!* ENDIF
9923*!* ENDIF
9924*!* ENDIF
9925*!* ENDIF
9926
9927*!* USE in '_tmpCustShipper'
9928*!*
9929*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
9930*!* FROM (pceipoTH) h, (pceipoCR) r ;
9931*!* WHERE r.resv_cust_ship = 'Y' and ;
9932*!* h.customer = r.customer and ;
9933*!* h.division = r.division and ;
9934*!* EMPTY(h.shipper) ;
9935*!* INTO CURSOR '_tmpCustShipper'
9936*!*
9937*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
9938*!*
9939*!* IF RECCOUNT('_tmpCustShipper') > 0
9940*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
9941*!*
9942*!* IF llRetVal
9943*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
9944*!* Errs_flg_h WITH "Y" ;
9945*!* FOR customer = _tmpCustShipper.customer and ;
9946*!* division = _tmpCustShipper.division and ;
9947*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
9948*!*
9949*!* SET RELATION TO
9950*!* ENDIF
9951*!*
9952*!* ENDIF
9953*!*
9954*!* ENDWITH
9955*!*
9956*!* USE in '_tmpCustShipper'
9957*!* USE in '_custShipper'
9958*!* SELECT(lnSelect)
9959*!*
9960*!* RETURN llRetVal
9961*!* ENDFUNC
9962*!* *===========================================================================================
9963*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
9964*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
9965
9966*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
9967*============================================================
9968 FUNCTION CalculateSLNs
9969 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
9970 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
9971 lnTotal_qty
9972
9973 llRetVal = true
9974 lnSelect = SELECT()
9975
9976 lcCursor = GetUniqueFileName()
9977 WITH This
9978
9979 *--- TR 1047450 28-May-2010 Partha ---
9980 * removed c.Template = 'GAP'
9981 * from where clause of following qry
9982
9983*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
9984*!* " FROM (pceipoTD) d " + ;
9985*!* " JOIN (pceipoTH) H " + ;
9986*!* " ON H.pkey = d.fkey " + ;
9987*!* " JOIN (pceipoCR) C " + ;
9988*!* " ON D.division = C.Division " + ;
9989*!* " AND H.Customer = C.Customer " + ;
9990*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
9991
9992 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
9993 " FROM (pceipoTD) d " + ;
9994 " JOIN (pceipoTH) H " + ;
9995 " ON H.pkey = d.fkey " + ;
9996 " JOIN (pceipoCR) C " + ;
9997 " ON D.division = C.Division " + ;
9998 " AND H.Customer = C.Customer " + ;
9999 " WHERE NOT (d.Gap_ok = 'Y') "
10000 *=== TR 1047450 28-May-2010 Partha ===
10001
10002 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10003
10004 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10005 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10006 lcDeatil = .cSQLTempTable
10007
10008 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10009 " FROM " + lcDeatil + " t " + ;
10010 " JOIN zzxscolr s " + ;
10011 " ON s.division= t.division and " +;
10012 " s.style= t.style and s.color_code= t.color_code and " +;
10013 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10014 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10015 " LEFT OUTER JOIN zzxppakh ph " + ;
10016 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10017 " s.dimension= ph.ppk_code " + ;
10018 " Where s.ppack_ok= 'Y' "
10019
10020 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10021
10022 IF llRetVal
10023 *--- TR 1038394 YIK 01/29/09
10024 *- Select(lcCursor)
10025 *--INDEX on Pkey TAG Pkey
10026 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10027 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10028
10029 lnPrePack = 0
10030 SELECT(lcCursor)
10031 SCAN
10032 lnPkey = Pkey
10033 lnpack_qty = pack_qty
10034
10035 lnTotal_qty = &pceipoTD..Total_qty
10036
10037 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10038 lcErrs_Msg = " Can not Calculate number of prepacks. "
10039
10040 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10041 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10042 Errs_Flg_D With "Y" ;
10043 IN (pceipoTD)
10044 LOOP
10045 ELSE
10046 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10047 IF lnpack_qty >0
10048 lnTotal_qty = lnTotal_qty /lnpack_qty
10049 ENDIF
10050 ENDIF
10051 Endif
10052
10053 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10054 lnPrePack = (lnTotal_qty/lnpack_qty)
10055 SELECT(pceipoTS)
10056 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10057
10058 IF lnSlnqty >0
10059 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10060 SELECT(pceipoTS)
10061 SCAN FOR Fkey = lnPkey
10062 IF MOD(sln_qty,lnPrePack) >0
10063 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10064 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10065 Errs_Flg_S With "Y"
10066 ENDIF
10067 ENDSCAN
10068 LOOP
10069 ELSE
10070 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10071*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10072 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10073 ENDIF
10074
10075 ENDIF
10076 ENDSCAN
10077
10078 ENDIF
10079 ENDIF
10080 .TableClose(lcCursor)
10081 ENDWITH
10082
10083 SELECT (lnSelect)
10084 RETURN llRetVal
10085 ENDFUNC
10086*============================================================
10087
10088*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10089
10090
10091*--- TR 1036917 04-Feb-2009 Partha ---
10092
10093*============================================================
10094 FUNCTION ChangeColor
10095 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10096 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10097 lnTotal_qty
10098
10099 llRetVal = true
10100 lnSelect = SELECT()
10101
10102 WITH This
10103 *--- TR 1039262 NSD - Use current system date, not PO date.
10104 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10105 If This.oHostProcess.lHaveSLN
10106 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.
10107 " 'D' AS Source " + ;
10108 " FROM (pceipoTD) d " + ;
10109 " JOIN (pceipoTH) H " + ;
10110 " ON H.pkey = d.fkey " + ;
10111 " WHERE d.Errs_flg_d <> 'Y' " + ;
10112 " AND d.org_color = ' ' " +;
10113 " UNION ALL " + ;
10114 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10115 " 'S' AS Source " + ;
10116 " FROM (pceipoTD) d " + ;
10117 " JOIN (pceipoTH) H " + ;
10118 " ON H.pkey = d.fkey " + ;
10119 " JOIN (pceipoTS) S " + ;
10120 " ON D.pkey = s.fkey " + ;
10121 " WHERE s.Errs_flg_s <> 'Y' " + ;
10122 " AND s.org_color = ' ' "
10123 ELSE
10124 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10125 " 'D' AS Source " + ;
10126 " FROM (pceipoTD) d " + ;
10127 " JOIN (pceipoTH) H " + ;
10128 " ON H.pkey = d.fkey " + ;
10129 " WHERE d.Errs_flg_d <> 'Y' " + ;
10130 " AND d.org_color = ' ' "
10131 ENDIF
10132
10133 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10134
10135 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10136 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10137 lcDeatil = .cSQLTempTable
10138 *--- 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)
10139 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10140 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10141 " FROM " + lcDeatil + " t " + ;
10142 " JOIN zzxrupch h " + ;
10143 " ON h.division= t.division " + ;
10144 " and h.style= t.style " + ;
10145 " and h.color_code= t.color_code " + ;
10146 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10147 " and h.dimension = t.dimension " + ;
10148 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10149 " WHERE h.active_ok = 'Y' " + ;
10150 " AND d.active_color = 'Y' " + ;
10151 " AND d.effect_Date = " + ;
10152 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10153 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10154 " ORDER BY d1.effect_date DESC ) "
10155
10156 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10157
10158 IF llRetVal
10159 Select("__RollingUpc")
10160 INDEX on Pkey TAG Pkey
10161 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10162
10163 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10164 org_Color WITH __RollingUpc.TempColr ;
10165 FOR NOT EOF("__RollingUpc") ;
10166 AND __RollingUpc.Source = "D" IN (pceipoTD)
10167
10168 Set Relation To
10169
10170 If This.oHostProcess.lHaveSLN
10171 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10172 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10173 org_Color WITH __RollingUpc.TempColr ;
10174 FOR NOT EOF("__RollingUpc") ;
10175 AND __RollingUpc.Source = "S" IN (pceipoTS)
10176 Set Relation To
10177 ENDIF
10178
10179 ENDIF
10180
10181 .TableClose("__RollingUpc")
10182
10183 ENDIF
10184 ENDWITH
10185
10186 SELECT (lnSelect)
10187 RETURN true
10188 ENDFUNC
10189*============================================================
10190
10191*=== TR 1036917 04-Feb-2009 Partha ===
10192
10193**************************************************************************************
10194
10195 * --- TR 1034963 12/15/08 CM
10196 * This procedure will write back to sysnotes exploded components of Range Styles
10197
10198 Procedure UpdateSysNotes
10199
10200 Local laTables[1]
10201 laTables[1] = "Vzzeipotd_notes_iPOproc"
10202
10203 Local llRetVal, llBeganTransaction
10204
10205 llRetVal = .T.
10206
10207 If This.BeginTransaction()
10208 llRetVal = This.Tableupdate(@laTables)
10209 If llRetVal
10210 This.EndTransaction()
10211 Else
10212 This.RollbackTransaction()
10213 Endif
10214 Endif
10215
10216 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10217
10218 Endproc
10219 * --- TR 1034963 12/15/08 CM
10220
10221**************************************************************************************
10222
10223 *--------------------------------------------------
10224 *--- TR 1041542 NSD 7/22/09
10225 * Register Number can be assigned by a sort now.
10226 PROCEDURE ResolveRegisterNumber
10227 LPARAMETERS pceipoTH
10228
10229 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10230 llRetVal = .T.
10231 lnSelect = SELECT()
10232
10233 WITH THIS
10234
10235 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10236 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10237 lcColList = "pkey,customer,reg_num"
10238 SELECT tcAllCols
10239 SCAN
10240 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10241 ENDSCAN
10242
10243 * Retrieve just the columns we need
10244 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10245 &lcSQL
10246
10247 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10248 * Push records to server to work with.
10249 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10250 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10251 lcAllTmp = .cSQLTempTable
10252
10253 * Find distinct customer
10254 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10255 SELECT tcRegNum_cust
10256 SCAN
10257 * Process 1 customer
10258
10259 * Get the grouping
10260 lcCustTmp = "#" + GetUniqueFileName()
10261 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10262 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10263 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10264 IF llRetVal
10265 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10266 lcGrouping = "CUSTOMER,PO_NUM"
10267 ELSE
10268 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10269 ENDIF
10270
10271 * Need to have a SQL Filter for the groupings
10272 STRINGTOARRAY(lcGrouping,@laGroupFields)
10273 lcGroupFieldsFilter = ""
10274 FOR x = 1 TO ALEN(laGroupFields,1)
10275 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10276 ENDFOR
10277 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10278
10279 * Create temp table of unique reg nums
10280 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10281 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10282 " GROUP BY " + lcGrouping
10283 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10284
10285 * Count distinct records and generate enough reg_nums
10286 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10287 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10288
10289 * Calculate New reg_nums
10290 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10291
10292 * Write back to table
10293 llRetVal = llRetVal AND v_sqlexec(;
10294 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10295 lcGroupFieldsFilter )
10296
10297 ENDIF
10298
10299 USE IN SELECT("tcRegNum_Sort")
10300 USE IN SELECT("tcRegNum_cnt")
10301 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10302 ENDSCAN
10303
10304 * Get all records back from Temp table. Loop through and apply to main cursor
10305 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10306 IF llRetVal
10307 SELECT tcRegNum_res
10308 SCAN
10309 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10310 SELECT (pceipoTH)
10311 REPLACE reg_num WITH tcRegNum_res.reg_num
10312 ENDIF
10313 ENDSCAN
10314
10315 ENDIF
10316
10317 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10318 ENDIF
10319
10320
10321 USE IN SELECT("tcRegNum_res")
10322 USE IN SELECT("tcAllCols")
10323 USE IN SELECT("tcRegNum_All")
10324 USE IN SELECT("tcRegNum_cust")
10325
10326 ENDWITH
10327
10328 SELECT(lnSelect)
10329 RETURN llRetVal
10330 ENDPROC
10331 *=== TR 1041542 NSD 7/22/09
10332
10333*===============================================================
10334
10335 *--- TR 1036614 8-Jun-2009 Goutam
10336 Procedure CreateSingleSLNCursor
10337 Lparameters pcTmpCursor
10338
10339 Local llRetVal, lnOldSelect, lcSQLString
10340
10341 llRetVal = true
10342 lnOldSelect = Select()
10343
10344 *---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.
10345
10346 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10347
10348 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10349*!* select t.Customer ;
10350*!* , t.FKey ;
10351*!* , t.PKey ;
10352*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10353*!* , c.template ; && TR 1050793
10354*!* , c.slntodtl ; && TR 1050793
10355*!* from (pcTmpCursor) t ;
10356*!* join zzeipocr c ;
10357*!* on c.division = t.division ;
10358*!* and c.customer = t.customer ;
10359*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10360*!* on s.division = t.division ;
10361*!* and s.customer = t.customer ;
10362*!* and s.store = t.store ;
10363*!* where c.slntodtl = 'N' ;
10364*!* and (c.stylefromsln = 'O' ;
10365*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10366*!* into Cursor __tmpipots ;
10367*!* order by t.fkey, t.Customer, t.PKey
10368
10369 select t.Customer ;
10370 , t.FKey ;
10371 , t.PKey ;
10372 , NVL(s.price_flg, c.price_flg) as price_flg ;
10373 , c.template ; && TR 1050793
10374 , c.slntodtl ; && TR 1050793
10375 from (pcTmpCursor) t ;
10376 join zzeipocr c ;
10377 on c.division = t.division ;
10378 and c.customer = t.customer ;
10379 left join (this.oHostProcess.cCustomerStoreTable) s ;
10380 on s.division = t.division ;
10381 and s.customer = t.customer ;
10382 and s.store = t.store ;
10383 where c.slntodtl = 'N' ;
10384 and (c.stylefromsln = 'O' ;
10385 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10386 JOIN zzeipocr c ;
10387 on c.division = t.division ;
10388 and c.customer = t.customer ;
10389 group by t.fkey having (count(t.pkey)=1) and ;
10390 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10391 into Cursor __tmpipots ;
10392 order by t.fkey, t.Customer, t.PKey
10393 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10394
10395 Select(lnOldSelect)
10396 Return llRetVal
10397 Endproc
10398 *=== TR 1036614 8-Jun-2009 Goutam
10399
10400 *--- TR 1036614 8-Jun-2009 Goutam
10401 *--- This is the splited function from MoveSLNToDTLs
10402 PROCEDURE CreateCursorSLNToDtl
10403 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10404
10405 LOCAL llRetVal, lnOldSelect
10406 lnOldSelect = SELECT()
10407 llRetVal = true
10408
10409 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10410*!* select t.Customer ;
10411*!* , t.FKey ;
10412*!* , t.PKey ;
10413*!* , c.price_flg ;
10414*!* from (pcTmpCursor) t ;
10415*!* join zzeipocr c ;
10416*!* on c.division = t.division ;
10417*!* and c.customer = t.customer ;
10418*!* join (pceipoTD) d ;
10419*!* on d.pkey = t.dtlPkey ;
10420*!* where c.slntodtl = 'Y' ;
10421*!* and d.slntodtl <> 'Y' ;
10422*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10423*!* into Cursor __tmpipots ;
10424*!* order by t.fkey, t.Customer, t.PKey
10425
10426 *--- TR 1045922 05-MAR-2010 HNISAR
10427 * Added 'I' to Inlis in below statements
10428*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10429*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10430 *=== TR 1045922 05-MAR-2010 HNISAR
10431
10432 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10433 select t.Customer ;
10434 , t.FKey ;
10435 , t.PKey ;
10436 , NVL(s.price_flg, c.price_flg) as price_flg ;
10437 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10438 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
10439 from (pcTmpCursor) t ;
10440 join zzeipocr c ;
10441 on c.division = t.division ;
10442 and c.customer = t.customer ;
10443 left join (this.oHostProcess.cCustomerStoreTable) s ;
10444 on s.division = t.division ;
10445 and s.customer = t.customer ;
10446 and s.store = t.store ;
10447 join (pceipoTD) d ;
10448 on d.pkey = t.dtlPkey ;
10449 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
10450 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10451 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10452 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
10453 into Cursor __tmpipots ;
10454 order by t.fkey, t.Customer, t.PKey
10455 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
10456
10457 SELECT(lnOldSelect)
10458 RETURN llRetVal
10459
10460 ENDPROC
10461
10462 Procedure ResolveSingleSLNDetail
10463 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
10464
10465 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
10466
10467 llRetVal = true
10468 lnOldSelect = Select()
10469
10470 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10471 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
10472 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10473 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10474
10475 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10476*!* select t.Customer ;
10477*!* , t.FKey ;
10478*!* , t.PKey ;
10479*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10480*!* , t.ppk_code ;
10481*!* from (pcTmpCursor) t ;
10482*!* join zzeipocr c ;
10483*!* on c.division = t.division ;
10484*!* and c.customer = t.customer ;
10485*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10486*!* on s.division = t.division ;
10487*!* and s.customer = t.customer ;
10488*!* and s.store = t.store ;
10489*!* where c.slntodtl = 'N' ;
10490*!* AND ((c.stylefromsln in ('Y','O') ;
10491*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10492*!* into Cursor __tmpipots ;
10493*!* order by t.fkey, t.Customer, t.PKey
10494
10495 select t.Customer ;
10496 , t.FKey ;
10497 , t.PKey ;
10498 , NVL(s.price_flg, c.price_flg) as price_flg ;
10499 , t.ppk_code ;
10500 from (pcTmpCursor) t ;
10501 join zzeipocr c ;
10502 on c.division = t.division ;
10503 and c.customer = t.customer ;
10504 left join (this.oHostProcess.cCustomerStoreTable) s ;
10505 on s.division = t.division ;
10506 and s.customer = t.customer ;
10507 and s.store = t.store ;
10508 where c.slntodtl = 'N' ;
10509 AND ((c.stylefromsln in ('Y','O') ;
10510 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10511 JOIN zzeipocr c ;
10512 on c.division = t.division ;
10513 and c.customer = t.customer ;
10514 group by t.fkey having (count(t.pkey)=1) and ;
10515 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10516 into Cursor __tmpipots ;
10517 order by t.fkey, t.Customer, t.PKey
10518 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10519
10520 SELECT __tmpipots
10521 SCAN
10522 lnFKey = Fkey
10523
10524 Select (pceipoTS)
10525 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
10526
10527 lcDivision = Division
10528 lcStyle = Style
10529 lcColor_Code = Color_Code
10530 lcLbl_Code = Lbl_Code
10531 lcDimension = __tmpipots.PPK_Code
10532 lcSize_Desc = Size_Desc
10533
10534 select (pceipoTD)
10535 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
10536
10537 replace Division with lcDivision, ;
10538 Style with lcStyle, ;
10539 Color_Code with lcColor_Code, ;
10540 Lbl_Code with lcLbl_Code, ;
10541 Dimension with lcDimension,;
10542 SizeBucket with 1;
10543 Size_Desc with lcSize_Desc;
10544 Style_SLN_OK with 'Y' ;
10545 IN (pceipoTD)
10546 ENDIF
10547 ENDIF
10548 ENDSCAN
10549
10550 IF USED("__tmpipots")
10551 USE IN __tmpipots
10552 ENDIF
10553
10554 Select(lnOldSelect)
10555 Return llRetVal
10556 Endproc
10557
10558 *=== TR 1036614 8-Jun-2009 Goutam
10559
10560 *- 1044723 05/20/10 YIK
10561 *- Moved this method from postvalidation()
10562 PROCEDURE ResolveNewStoreOrd_type
10563 LPARAMETERS pcEipoTH
10564 LOCAL llRetVal, lnOldSelect
10565 llRetVal = .t.
10566 lnOldSelect = SELECT()
10567 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
10568 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
10569
10570 LOCAL lcSql, lcEipoTh, lcSQLTempTable
10571 lcEipoTh = SYS(2015)
10572 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
10573
10574 IF RECCOUNT(lcEipoTh) = 0
10575 USE IN (lcEipoTh)
10576 SELECT(lnOldSelect)
10577 RETURN llRetVal
10578 ENDIF
10579
10580 LOCAL lcOrd_typeResult
10581 lcOrd_typeResult = SYS(2015)
10582 WITH this
10583 .cSQLTempTable=""
10584 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
10585 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
10586 lcSQLTempTable = .cSQLTempTable
10587
10588 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
10589 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
10590 " inner join zzotyper r on r.ns_ord_type = 'Y'"
10591 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
10592 IF llRetVal
10593 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
10594 ENDIF
10595 ENDWITH
10596
10597 IF USED(lcEipoTh)
10598 USE IN (lcEipoTh)
10599 ENDIF
10600 IF USED(lcOrd_typeResult)
10601 USE IN (lcOrd_typeResult)
10602 ENDIF
10603
10604 Select(lnOldSelect)
10605 Return llRetVal
10606 Endproc
10607 *=== TR 1035678 NH
10608
10609 *--- TR 1049029 24-Aug-2010 Partha ---
10610 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
10611 FUNCTION GetTotSLNQty
10612 LPARAMETERS tnPSFkey, pceipoTS
10613
10614 LOCAL lnTotSlnQty, lnOldSelect
10615 LOCAL ARRAY laTotSlnQty[1]
10616
10617 lnOldSelect = SELECT()
10618 lnTotSlnQty = 0
10619
10620 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
10621 lnTotSlnQty = laTotSlnQty[1]
10622
10623 Select(lnOldSelect)
10624 Return lnTotSlnQty
10625 ENDFUNC
10626
10627 *=== TR 1049029 24-Aug-2010 Partha ===
10628
10629 *--- TechRec 1048792 17-Dec-2010 jisingh ---
10630 FUNCTION ClearSkus
10631 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
10632 LOCAL llRetVal, lnSelect, lcSqlString
10633
10634 llRetVal = true
10635 lnSelect = SELECT()
10636
10637 *-- Populate new flag from Control in Transaction Maintenance
10638 lcSqlString = " UPDATE h SET " + ;
10639 " ReResvStyle = c.ReResvStyle " + ;
10640 " FROM (pcEipoTH) h " + ;
10641 " JOIN (pcEipoCR) c " + ;
10642 " ON h.division = c.division " + ;
10643 " AND h.customer = c.customer " + ;
10644 " WHERE h.ReResvStyle = '' "
10645
10646 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10647
10648 *-- Make SKUs blank in Transaction Maintenance detail
10649 lcSqlString = " UPDATE d SET " + ;
10650 " Style = '', " + ;
10651 " Color_Code = '', " + ;
10652 " Lbl_Code = '', " + ;
10653 " Dimension = '', " + ;
10654 " SizeBucket = 0, " + ;
10655 " Size_Desc = '' " + ;
10656 " FROM (pcEipoTD) d " + ;
10657 " JOIN (pcEipoTH) h " + ;
10658 " ON h.pkey = d.fkey " + ;
10659 " WHERE h.ReResvStyle = 'Y' " + ;
10660 " AND (d.upc > '' OR d.sku > '') "
10661
10662 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10663
10664 *-- Make SKUs blank in SLN
10665 lcSqlString = " UPDATE s SET " + ;
10666 " Style = '', " + ;
10667 " Color_Code = '', " + ;
10668 " Lbl_Code = '', " + ;
10669 " Dimension = '', " + ;
10670 " SizeBucket = 0, " + ;
10671 " Size_Desc = '' " + ;
10672 " FROM (pcEipoTD) d " + ;
10673 " JOIN (pcEipoTH) h " + ;
10674 " ON h.pkey = d.fkey " + ;
10675 " JOIN (pcEipoTS) s " + ;
10676 " ON s.fkey = d.pkey " + ;
10677 " WHERE h.ReResvStyle = 'Y' " + ;
10678 " AND (s.sln_upc > '' OR s.sln_sku > '') "
10679
10680 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10681
10682 SELECT (lnSelect)
10683 RETURN llRetVal
10684 ENDFUNC
10685 *=== TechRec 1048792 17-Dec-2010 jisingh ===
10686
10687 *--- TR 1053820 25-May-2011 Goutam
10688 Function GenerateCustomerSKU_Style_ColorSize
10689 Lparameters pceipoTH,pceipoTD
10690
10691 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
10692 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
10693
10694 llRetVal = True
10695 lnSelect = Select()
10696 With This
10697
10698 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
10699
10700 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
10701
10702 *** Size_BK needs to be 00 and NOT 0
10703 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
10704 Select ;
10705 h.customer,;
10706 d.division,;
10707 d.pkey As dtlpkey ,;
10708 d.Style As Style, ;
10709 d.color_code,;
10710 d.lbl_code,;
10711 d.Dimension,;
10712 h.Store As cust_store ,;
10713 d.price As cust_price , ;
10714 d.size_desc, ;
10715 d.sizebucket as size_bk, ;
10716 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
10717 d.aux_sku ;
10718 from (pceipoTH) h ;
10719 join (pceipoTD) d ;
10720 on d.fkey = h.pkey ;
10721 join zzeipocr c ;
10722 on c.division = d.division ;
10723 and c.customer = h.customer ;
10724 where c.GenCustSKU = 'Y' ;
10725 and d.sku = '' ;
10726 and h.Errs_flg_h < 'Y' ;
10727 and d.Errs_Flg_D < 'Y' ;
10728 into cursor tmpCurs ;
10729 order by 1,2,4,5,6,7, 11
10730 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
10731
10732 lnCount = Reccount("tmpCurs")
10733
10734 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
10735
10736 If lnCount = 0
10737 If Used("tmpCurs")
10738 Use In tmpCurs
10739 Endif
10740 Select (lnSelect)
10741 Return
10742 Endif
10743
10744 *- Index just in case somebody changes the SELECT above
10745 Select tmpCurs
10746 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
10747 TAG sku
10748
10749 .LogEntry("Load Customer Style.")
10750
10751 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
10752 If Used("tmpCurs")
10753 Use In tmpCurs
10754 Endif
10755 Select (lnSelect)
10756 Return
10757 Endif
10758
10759 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
10760 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
10761 lnCount = lnCount - 1
10762 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
10763 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
10764
10765 Select VZZXCSTHR
10766 Scatter Memvar Blank
10767 Select VZZXCSTDR
10768 Scatter Memvar Blank
10769
10770 m.Last_mod = Datetime()
10771 m.User_id = 'CGSADMIN'
10772 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
10773 m.notes = ''
10774
10775 *--- TR 1057011 7-10-2011 VKK
10776 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
10777 m.active_ok = 'Y'
10778 m.anti_theft = 'N'
10779 *=== TR 1057011 7-10-2011 VKK
10780
10781 lcPrevSKU = ' '
10782 lcPrevSkuSize = ''
10783
10784 *- inserted details counter
10785 Local lnInsertCount
10786 lnInsertCount = 0
10787
10788 Select tmpCurs
10789
10790 Scan
10791 .LogEntry("Loading Customer Style...")
10792 .LogEntry("Style :" + Style )
10793 .LogEntry("Color_code :" + color_code )
10794
10795 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
10796 .LogEntry("Invalid Style or Color_code or Size_bk " )
10797 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
10798 FOR pkey = dtlpkey In (pceipoTD)
10799 Loop
10800 Endif
10801
10802 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
10803 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
10804 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
10805
10806 *--- Client Soffe wants to display size description in dimension's place if it is empty
10807 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
10808 If lcPrevSKU # lcSku
10809 lcPrevSKU = lcSku
10810 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
10811 .LogEntry("Customer :" + m.customer )
10812 .LogEntry("Division : " + m.division)
10813 .LogEntry("Style :" + Style )
10814 .LogEntry("Color_code :" + m.color_code )
10815 .LogEntry("Label code :" + m.lbl_code )
10816 .LogEntry("dimension : " + m.dimension)
10817 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
10818 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))
10819 If Empty(lnHDRpKey)
10820 lnHDRpKey = lnCstHrPkey
10821 .LogEntry("Inserting into header..")
10822 Insert Into VZZXCSTHR From Memvar
10823 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
10824 In VZZXCSTHR
10825 Endif
10826 Endif
10827 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
10828 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
10829 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
10830 *- 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)
10831 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
10832 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)
10833
10834 If Empty(lnDtlKey)
10835 lnDtlpKey = lnCstDrPkey
10836 .LogEntry("Inserting into detail..")
10837 Insert Into VZZXCSTDR From Memvar
10838 *- TR 1071542 FH- need to add replace for dimension here as well
10839 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
10840 lnInsertCount = lnInsertCount + 1
10841 Endif
10842 Endif
10843 lnCstDrPkey = lnCstDrPkey +1
10844 lnCstHrPkey = lnCstHrPkey +1
10845
10846 Endscan
10847
10848 Dimension laTables[2]
10849 laTables[1]= "VZZXCSTHR"
10850 laTables[2]= "VZZXCSTDR"
10851
10852 llBeganTransaction = .BeginTransaction()
10853 llRetVal = .Tableupdate(@laTables)
10854
10855 If llRetVal
10856 If llBeganTransaction
10857 This.EndTransaction()
10858 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
10859 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
10860 Endif
10861 Else
10862 If llBeganTransaction
10863 This.RollbackTransaction()
10864 .LogEntry("Table Update failed - Roll back Transaction " )
10865 Endif
10866 Endif
10867
10868 Endwith
10869
10870 If Used("tmpCurs")
10871 Use In tmpCurs
10872 Endif
10873
10874 Select (lnSelect)
10875 Return llRetVal
10876 Endfunc
10877
10878 *=== TR 1053820 25-May-2011 Goutam
10879
10880*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
10881 *============================================================
10882 Procedure RangePConversion
10883 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
10884 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
10885 llRetVal = .T.
10886 lnOldSelect = Select()
10887
10888 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
10889
10890 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
10891 * 1st Getting all range headers
10892 *- process all.
10893 *- Exclude range style P from the consideration
10894 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
10895 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
10896
10897 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
10898 FROM (pcTransDetail) d ;
10899 JOIN (pceipoCR) c ON c.customer = d.customer ;
10900 AND c.division = d.division ;
10901 WHERE ((d.rng_type = 'P' OR ;
10902 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
10903 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
10904 )AND c.rngp_conv = 'R') ; && requires Range P conversion
10905 AND d.ppk_action $ 'QPBO' ;
10906 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
10907
10908 With This
10909 .cSQLTempTable=""
10910 If .GenerateSQLTempTable('__TmpCursor')
10911 If .PopulateSQLTempTable('__TmpCursor')
10912 If !Empty(.cSQLTempTable)
10913
10914 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
10915 " st.size_code " +;
10916 " FROM " + .cSQLTempTable + " t " +;
10917 " JOIN zzxscolr s " + ;
10918 " ON s.division = t.division " +;
10919 " AND s.style = t.style " + ;
10920 " AND s.color_code = t.color_code " + ;
10921 " AND s.lbl_code = t.lbl_code " + ;
10922 " AND s.dimension = t.dimension " + ;
10923 " INNER JOIN zzxstylr st " + ;
10924 " ON st.pkey = s.fkey " + ;
10925 " JOIN zzxrangh rh " + ;
10926 " ON rh.division = t.division " + ;
10927 " AND rh.rng_Style = t.style " + ;
10928 " AND rh.rng_color = t.color_Code " + ;
10929 " AND rh.rng_lbl = t.lbl_Code " + ;
10930 " AND rh.rng_pack = t.dimension "
10931
10932 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
10933
10934 If Used("_PPK_Qty")
10935 Select ("_PPK_Qty")
10936 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
10937 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
10938 "division+style+color_code+lbl_code+dimension")
10939 SELECT ("__TmpCursor")
10940
10941 If llRetVal
10942 .LogEntry("Validating Range style.")
10943 lcErrs_Msg = "No valid Range Style found"
10944 Select (pcTransDetail)
10945 SCAN FOR !EOF("_PPK_Qty")
10946
10947 If Empty(_PPK_Qty.pack_qty)
10948 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
10949 Errs_Flg_D With "Y" ;
10950 IN (pcTransDetail)
10951 Else
10952 Do Case
10953
10954 Case ppk_action = 'Q' && multiply qty
10955
10956 Replace ppk_qty With _PPK_Qty.pack_qty, ;
10957 total_qty With total_qty*_PPK_Qty.pack_qty, ;
10958 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
10959 In (pcTransDetail)
10960
10961 Case ppk_action = 'P' && divide price
10962
10963 Replace ppk_qty With _PPK_Qty.pack_qty, ;
10964 org_price With org_price/_PPK_Qty.pack_qty, ;
10965 retail1 With retail1/_PPK_Qty.pack_qty, ;
10966 retail2 With retail2/_PPK_Qty.pack_qty, ;
10967 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
10968 In (pcTransDetail)
10969
10970 *- Range style price will be populated later from a_price..e_price
10971 *- not from org_price. Need to updated these prices here.
10972 IF rng_type = 'R'
10973 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
10974 b_price WITH b_price/_PPK_Qty.pack_qty, ;
10975 c_price WITH c_price/_PPK_Qty.pack_qty, ;
10976 d_price WITH d_price/_PPK_Qty.pack_qty, ;
10977 e_price WITH e_price/_PPK_Qty.pack_qty ;
10978 In (pcTransDetail)
10979 ENDIF
10980
10981 Case ppk_action = 'B' OR ppk_action = 'O'
10982
10983 Replace ppk_qty With _PPK_Qty.pack_qty, ;
10984 org_price With org_price/_PPK_Qty.pack_qty, ;
10985 retail1 With retail1/_PPK_Qty.pack_qty, ;
10986 retail2 With retail2/_PPK_Qty.pack_qty, ;
10987 total_qty With total_qty*_PPK_Qty.pack_qty, ;
10988 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
10989 In (pcTransDetail)
10990
10991 IF rng_type = 'R'
10992 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
10993 b_price WITH b_price/_PPK_Qty.pack_qty, ;
10994 c_price WITH c_price/_PPK_Qty.pack_qty, ;
10995 d_price WITH d_price/_PPK_Qty.pack_qty, ;
10996 e_price WITH e_price/_PPK_Qty.pack_qty ;
10997 In (pcTransDetail)
10998 ENDIF
10999
11000 Otherwise
11001 Endcase
11002 Endif
11003 Endscan
11004 Endif
11005 Set Relation To
11006 Endif
11007 Endif
11008 Endif
11009 Endif
11010
11011 Endwith
11012
11013 If Used("__TmpCursor")
11014 Use In __TmpCursor
11015 Endif
11016
11017 If Used("_PPK_Qty")
11018 Use In _PPK_Qty
11019 Endif
11020
11021 If Used("__RangeP")
11022 Use In __RangeP
11023 Endif
11024
11025 Select(lnOldSelect)
11026 Return llRetVal
11027 *============================================================
11028 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11029
11030 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11031 PROCEDURE PopulateIs860
11032 LPARAMETERS pceipoTH, pceipoCR
11033 LOCAL llRetVal, lnSelect, lcUpdate
11034
11035 llRetVal = true
11036 lnSelect = SELECT()
11037
11038 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11039
11040 *--- TR 1070268 26-Jun-2013 Goutam
11041 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11042 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11043 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11044
11045 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11046 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11047 " 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')))"
11048
11049 *=== TR 1070268 26-Jun-2013 Goutam
11050
11051 &lcUpdate
11052
11053 SELECT (lnSelect)
11054 RETURN llRetVal
11055 ENDPROC
11056
11057 *============================================================
11058
11059 PROCEDURE Create860TM
11060 LPARAMETERS pceipoTH
11061 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql
11062
11063 llRetVal = true
11064 lnSelect = SELECT()
11065 lcAlias = GetUniqueFileName()
11066 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11067
11068 WITH This
11069 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11070 *IF !EMPTY(lcInsert)
11071 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11072 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11073 ORDER By h.division, h.customer INTO CURSOR tcOrders
11074
11075 .cSQLTempTable = ""
11076 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11077 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11078 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11079
11080 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11081 " FROM zzoordrh rh " + ;
11082 " JOIN " + .cSQLTempTable + " t " + ;
11083 " ON t.customer = rh.customer " + ;
11084 " AND t.division = rh.division " + ;
11085 " AND t.po_num = rh.po_num " + ;
11086 " AND t.store = rh.store " + ;
11087 " WHERE t.is860 = 'Y' "
11088
11089 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11090
11091 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11092 SELECT tcOrders
11093 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11094 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11095 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11096 SELECT (lcAlias)
11097 SCATTER NAME voEiPcth MEMO
11098
11099 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11100 SELECT tcCRPkey
11101 INDEX ON customer+division TAG cudiv
11102
11103 SELECT (pceipoTH)
11104 COUNT TO lnRecNo FOR Is860 = 'Y'
11105
11106 IF .lUserInterface
11107 .AdvanceThermo(lnRecNo)
11108 ENDIF
11109
11110 SELECT (pceipoTH)
11111 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11112 *SCAN FOR Is860 = 'Y'
11113 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11114 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11115 SCATTER NAME loEiPOth MEMO
11116
11117 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11118 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11119
11120 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11121
11122 IF RECCOUNT("__tcipcth") > 0
11123 REPLACE Is860 WITH 'X' IN (pceipoTH)
11124 USE IN SELECT("__tcipcth")
11125 LOOP
11126 ENDIF
11127
11128 WITH voEiPcth
11129 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11130 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11131 voEiPcth.poc_purp = "01"
11132 voEiPcth.customer = loEiPOth.customer
11133 voEiPcth.division = loEiPOth.division
11134 voEiPcth.doc_num = loEiPOth.doc_num
11135 voEiPcth.edi_store = loEiPOth.edi_store
11136 voEiPcth.store = loEiPOth.store
11137 voEiPcth.isa_num = loEiPOth.isa_num
11138 voEiPcth.our_id = loEiPOth.our_id
11139 voEiPcth.our_qual = loEiPOth.our_qual
11140 voEiPcth.po_num = loEiPOth.po_num
11141 voEiPcth.vnd_id = loEiPOth.vnd_id
11142 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11143 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11144 voEiPcth.po_type = loEiPOth.po_type
11145 voEiPcth.vnd_key = loEiPOth.vnd_key
11146 ENDWITH
11147
11148 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11149
11150 REPLACE Is860 WITH 'X' IN (pceipoTH)
11151
11152 IF .lUserInterface
11153 lnRecNo = lnRecNo + 1
11154 .AdvanceThermo(lnRecNo)
11155 ENDIF
11156 USE IN SELECT("__tcipcth")
11157 ENDSCAN
11158 ENDIF
11159 .TableClose(lcAlias)
11160 .TableClose("tcCRPkey")
11161 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11162 .TableClose("tcOrders")
11163 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11164 ENDWITH
11165
11166 RELEASE voEiPcth
11167 SELECT (lnSelect)
11168 RETURN llRetVal
11169 ENDPROC
11170 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11171
11172 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11173 PROCEDURE ValidateLocation
11174 LPARAMETERS pcHeader
11175
11176 LOCAL llRetVal, lnOldSelect
11177
11178 llRetVal= true
11179 lnOldSelect= Select()
11180
11181 SELECT Distinct Location FROM (pcHeader) ;
11182 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11183
11184 SELECT __tmpLocation
11185 WITH This
11186 .cSQLTempTable=""
11187 IF .GenerateSQLTempTable('__tmpLocation')
11188 IF .PopulateSQLTempTable('__tmpLocation')
11189 IF !EMPTY(.cSQLTempTable)
11190 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11191 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11192 llRetVal = v_SqlExec(lcSQLString, "_Location")
11193 IF llRetVal
11194 SELECT _Location
11195 INDEX On Location TAG Location
11196 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11197 IF llRetVal
11198 SELECT (pcHeader)
11199 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11200 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11201 SET RELATION TO
11202 ENDIF
11203 ENDIF
11204 ENDIF
11205 ENDIF
11206 ENDIF
11207 ENDWITH
11208
11209 IF USED("__tmpLocation")
11210 USE IN __tmpLocation
11211 ENDIF
11212 IF USED("_Location")
11213 USE IN _Location
11214 ENDIF
11215
11216 Select(lnOldSelect)
11217 Return llRetVal
11218 ENDPROC
11219 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11220
11221 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11222 PROCEDURE GetFldsList
11223 LPARAMETERS lcpceipoTH, lczzeoprth
11224
11225 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11226
11227 lnOldSelect= Select()
11228
11229 *- get common fields from both aliases
11230 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11231
11232 *- get fields from source table to validate 850 filter bros
11233 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11234
11235 *- Retrieve all 850 filter bros
11236 lcSQLString = "Select OBJID from zzxsfxrf " +;
11237 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11238
11239 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11240
11241 SELECT _Filter
11242
11243 SCAN
11244 lcFld = UPPER(TRIM(objid))
11245 *- Check filter bros and add them in required fields list if valid
11246 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11247 lcFldsList = lcFldsList + ", " + lcFld
11248 ENDIF
11249 ENDSCAN
11250
11251 *- Adding additional fields used in 850 filter string and insert sql in calling method
11252 IF NOT "IS940I" $ UPPER(lcFldsList)
11253 lcFldsList = lcFldsList + ", IS940I"
11254 ENDIF
11255
11256 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11257 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11258 ENDIF
11259
11260 IF NOT "REQ_855" $ UPPER(lcFldsList)
11261 lcFldsList = lcFldsList + ", REQ_855"
11262 ENDIF
11263
11264 IF NOT "PROC_855" $ UPPER(lcFldsList)
11265 lcFldsList = lcFldsList + ", PROC_855"
11266 ENDIF
11267
11268 IF USED("_Filter")
11269 USE IN _Filter
11270 ENDIF
11271
11272 Select(lnOldSelect)
11273
11274 Return lcFldsList
11275
11276 ENDPROC
11277 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11278
11279 *============================================================
11280
11281
11282Enddefine