· 8 years ago · Jan 23, 2018, 11:16 PM
1**********************************************************************************************
2* Program....: clsIpopr_PreValidation.PRG
3* Author.....: Nasim Huq
4* Date.......: Nov, 2008
5* Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
6* Techreq....: 1032800
7* Abstract...: EDI 850 inbound Pre-Validation
8* Changes....:
9***********************************************************************************************
10
11#include edi.h
12#include system.h
13
14#Define LARGEST_DATE {^2999-01-01}
15#Define EDI_NOT_PROCESSORIGINAL_MSG "Control Flag set to Not Process Original EDI orders into Live Table."
16#Define EDI_NOT_PROCESSCONFIRM_MSG "Control Flag set to Not Process Confirm EDI orders into Live Table."
17#Define EDI_NOT_PROCESSDUPLICATE_MSG "Control Flag set to Not Process Duplicate EDI orders into Live Table."
18#Define NOT_YET_PROCESS "Not yet process."
19#Define NO_UOM_CONVERSION_REF "Require Style UOM."
20#Define UOM_NOT_DIVISIBLE "Total Units must be divisible by "
21#Define NO_UOM_CONVERSION_FACTOR "No conversion factor."
22#Define NO_PREPACK "Unable to determine Prepack code." && 30854 3/25/02
23
24#Define EDI_BULK_ORDER "BK"
25#Define EDI_BLANKET_ORDER "BL"
26*- 1002007 11/13/03 YIK
27#Define EDI_DISCOUNT_CODE "EDI"
28
29
30Define Class clsIpopr_PreValidation As clsIpopr_delegatebase
31
32 oResolvePrepack = Null
33
34 *--- TR 1045965 09-MAR-2010 HNISAR
35 lFrom940i = False
36 *=== TR 1045965 09-MAR-2010 HNISAR
37
38 *--- TechRec 1030517 25-Aug-2010 jisingh ---
39 c850Control = ""
40 *=== TechRec 1030517 25-Aug-2010 jisingh ===
41
42 cImplodeSQL = ""
43 cImplodeRangeSQL = "" &&--- TechRec 1073664 20-Sep-2013 GSternik ===
44
45 *--- TR 1065217 27-Nov-2012 BNarayanan ---
46 nMaxStylesImplode = 0
47 *=== TR 1065217 27-Nov-2012 BNarayanan ===
48
49 *--- TechRec 1089737 20-Nov-2015 jisingh ---
50 cOverridePpkAction = ""
51 *=== TechRec 1089737 20-Nov-2015 jisingh ===
52
53 *--------------------------------------------------------------------------
54
55 Procedure Init
56 Lparameters toHostProcess
57 LOCAL llRetVal
58 llRetVal = .t.
59 llRetVal = llRetVal and DODEFAULT(toHostProcess)
60
61 *--- TR 1052729 10-Mar-11 SK
62 This.oPopulateSqlTempTable = Null
63
64 *--- TR 1065271 27-Nov-2012 BNarayanan ---
65 This.nMaxStylesImplode = VAL(goEnv.SV('EDI_RANGE_P_IMPLOSION_MAX_STYLES', '0'))
66 *=== TR 1065271 27-Nov-2012 BNarayanan ===
67
68 this.GetImplodeSQL()
69
70 RETURN llRetVal
71 Endproc
72
73 *--------------------------------------------------------------------------
74
75 *-- [Main procedure]
76 Procedure PreValidation
77 *--- TechRec 1028745 05-Feb-2008 GSternik --- added tceipoTR
78 Parameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
79 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse && *--- TechRec 1005163 17-May-2004 GS ---
80 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
81 Local llRetVal, lcSQLSelect, lcSQLOrder
82 llRetVal = .T.
83 PRIVATE vcLogName
84 vcLogName = this.cLogName
85 With This
86 .LogEntry("Resetting all error messages in transaction tables.")
87 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
88 vcLogName)
89 *--- TechRec 1005163 17-May-2004 GS ---
90 *llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD)
91 llRetVal= llRetVal And .ClearErrors(pceipoTH, pceipoTD, pceipoTS, tceipoTR)
92 *=== TechRec 1005163 17-May-2004 GS ===
93
94 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
95 vcLogName)
96
97 *--- TechRec 1019260 27-Oct-2006 vkrishnamurthy ---
98 *!* llRetVal= llRetVal AND .CheckHeader(pceipoTH, pceipoCR)
99 llRetVal= llRetVal And .CheckHeader(pceipoTH, pceipoCR, pceipoTD)
100 *=== TechRec 1019260 27-Oct-2006 vkrishnamurthy ===
101
102 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU, Range Style...", ;
103 vcLogName)
104 *--- TechRec 1005163 17-May-2004 GS ---
105 *llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
106 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
107 llRetVal= llRetVal And .CheckDetail(pceipoTH, pceipoTD, pceipoCR, pcxclblr, ;
108 pceipoTS, tceipoTSAC, tceipoTR, pczzeiPOtWhse) &&--- TechRec 1028745 05-Feb-2008 GSternik ---
109 *=== TechRec 1005163 17-May-2004 GS ===
110 Endwith
111 Return llRetVal
112 Endproc
113
114 *--------------------------------------------------------------------------
115
116 * Clear all previous errors
117 Procedure ClearErrors
118 Lparameters pceipoTH, pceipoTD,;
119 pceipoTS,; && *--- TechRec 1005163 17-May-2004 GS ---
120 tceipoTR && *--- TechRec 1028745 05-Feb-2008 GSternik ---
121 Local llRetVal, lnOldSelect, laTables[2]
122 llRetVal = .T.
123 lnOldSelect = Select()
124 * PL 06/06/00 cannot clearout [division with "" ] break rang style explosion
125 * 2nd.past (--when put 850 auto_proc='N' and explosion happend already,
126 * we don't allow explosion happen again therefore cannot clearout division)
127 *--- 1010206 11/10/2005 Ilya: Add Warning fields to clear:
128 *-Ilya--- REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipoTH)
129 *-Ilya--- REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipoTD)
130 Replace All Errs_msg_H With "", Errs_flg_h With "N", ;
131 warn_msg_h With "", warn_flg_h With "N" In (pceipoTH)
132 Replace All Errs_Msg_D With "", Errs_Flg_D With "N", ;
133 warn_msg_d With "", warn_flg_d With "N" In (pceipoTD)
134 *=== 1010206 11/10/2005 Ilya.
135
136 *--- TR 1003801 - BD - 03/30/04 - Added /EAN
137
138 *--- TR 1064141 3-Oct-2012 Goutam
139 *Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
140 FOR Empty(sku) And Empty(upc) And Empty(ean) And Empty(size_desc) In (pceipoTD) && 30854 3/25/02 UPC/SKU could be empty
141
142 Replace Errs_Msg_D With "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D With "Y" ;
143 FOR Empty(sku) And Empty(upc) And Empty(ean) And (Empty(style) or EMPTY(color_code) or Empty(size_desc)) In (pceipoTD)
144 *=== TR 1064141 3-Oct-2012 Goutam
145
146 *=== TR 1003801 - BD
147 *--- TechRec 1005163 17-May-2004 GS ---
148 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipoTS)
149 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
150 FOR Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipoTS)
151 *=== TechRec 1005163 17-May-2004 GS ===
152
153 *--- TechRec 1028745 05-Feb-2008 GSternik ---
154 If .oHostProcess.lHaveChrgs
155 Replace All Errs_Msg_R With "", Errs_Flg_R With "N" In (tceipoTR)
156 Endif
157 *=== TechRec 1028745 05-Feb-2008 GSternik ===
158
159 *---TR 1008342 10-JAN-2005 RG
160 Replace All Pending_Flg With 'N' In (pceipoTH)
161 *===TR 1008342 10-JAN-2005 RG
162
163 *--- TR 1073346 05-Sep-13 SK Resetting HAC Error and Warning flags if messages are empty
164 REPLACE Errs_flg_fh WITH IIF(ALLTRIM(LEFT(Errs_msg_FH, 250)) == "", "N", Errs_flg_fh) ;
165 hac_warn WITH IIF(ALLTRIM(LEFT(hac_warn_msg, 250)) == "", "N", hac_warn) ;
166 IN (pceipoTH)
167 *=== TR 1073346 05-Sep-13 SK
168
169 *- 1041285 07/10/09 YIK
170 *- Populate force errors into error fields
171 REPLACE Errs_msg_H WITH Errs_msg_FH, Errs_flg_h WITH Errs_flg_fh ;
172 FOR Errs_flg_fh = 'Y' ;
173 IN (pceipoTH)
174
175 *--- TR 1043191 23-Oct-2009 JK ---
176 Replace All warn_flg_h With "Y", warn_msg_h With hac_warn_msg For hac_warn = "Y" In (pceipoTH)
177 *=== TR 1043191 23-Oct-2009 JK ===
178
179 Select(lnOldSelect)
180 Return llRetVal
181 Endproc
182
183 *--------------------------------------------------------------------------
184
185 ************************************************************************************
186 * Error check EDI headers
187 ************************************************************************************
188 Procedure CheckHeader
189 Lparameters pceipoTH, pceipoCR, pceipoTD
190 &&&&--- TechRec 1019260 27-Oct-2006 vkrishnamurthy === Added pceipoTD
191
192 Local llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
193 llRetVal = .T.
194 lnOldSelect = Select()
195 With This
196
197 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
198 *--- LOCAL MOD
199 *If llRetVal And .lRBACustSku
200 If llRetVal And .oHostProcess.lRBACustSku
201 .LogEntry("Resolve RBA Customer")
202 llRetVal= .ResolveBCCustomer(pceipoTH)
203 Else
204 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
205
206 .LogEntry("Getting customer code using trading partner ID/Qualifier.")
207
208 *--- TR 1045965 09-MAR-2010 HNISAR
209*!* llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH)
210 llRetVal= .FindCustomerUsingTradingPartnerID(pceipoTH,,IIF(THIS.lFrom940i, " AND is940rec = 'Y' ", " AND is940rec <> 'Y' " ))
211 *=== TR 1045965 09-MAR-2010 HNISAR
212
213 If llRetVal
214 .LogEntry("Validating customer.")
215 llRetVal= .CheckCustomer(pceipoTH)
216 *- 01/29/02 YIK TAN 29056
217 If llRetVal
218 .LogEntry("Verifying Multiple customer.")
219 llRetVal= .CheckForMultiCust(pceipoTH, pceipoCR)
220 *= TAN 29056
221 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy --- Changed the ENDIF structure from below
222 Endif
223 Endif
224 Endif
225 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
226
227 *--- TR 1041542 NSD 7/22/09
228 IF llRetVal
229 .LogEntry("Resolving Register Number")
230 llRetVal = .ResolveRegisterNumber(pceipoTH)
231 ENDIF
232 *=== TR 1041542 NSD 7/22/09
233
234 If llRetVal
235 .LogEntry("Validating EDI store.")
236 llRetVal= .CheckStore(pceipoTH, pceipoCR)
237 If llRetVal
238 .LogEntry("Validating EDI center.")
239 llRetVal= .CheckDistribution(pceipoTH)
240 *- 1007452 10/22/04 YIK
241 *- Checking notes type
242 If llRetVal
243 .LogEntry("Validating Header Notes type.")
244 llRetVal= .CheckNoteType(pceipoTH)
245 Endif
246 *= 1007452
247 Endif
248 Endif
249
250 *--- TR 1022625 4-Mar-2007 TT
251 If llRetVal
252 .LogEntry("Checking for Terminations in PO_TYPE")
253 llRetVal= .CheckTerminationInPoType(pceipoTH)
254 Endif
255
256 *--- TR 1022625 4-Mar-2007 TT
257 *!* ENDIF
258 *!* ENDIF
259
260 *--- TR 1030441 17-Apr-2008 Goutam
261 If llRetVal
262 .LogEntry("Validating shipper code.")
263 llRetVal= .CheckShipper(pceipoTH)
264 Endif
265 *=== TR 1030441 17-Apr-2008 Goutam
266
267 *--- TechRec 1066487 05-Feb-2013 MANI. ---
268 IF llRetVal
269 .LogEntry("Validating Location.")
270 llRetVal= .ValidateLocation(pceipoTH)
271 Endif
272 *=== TechRec 1066487 05-Feb-2013 MANI. ===
273
274 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
275 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
276*!* If llRetVal
277*!* .LogEntry("Validating 855 Header status code.")
278*!* llRetVal= .Validate855Status(pceipoTH, pceipoTD, "H")
279*!* Endif
280 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
281 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
282
283 *--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
284 * TR 1037925 - As per Krishna/Shenba
285 * Moved to clsipopr_PostValidation as division gets populated to header in post validations only
286 * This is getting moved in TR 1037925
287*!* *--- TechRec 1036964 18-Dec-2008 T.Shenbagavalli ---
288*!* IF llRetVal
289*!* .LogEntry("Resolving Customer Shipper.")
290*!* llRetVal = .ResolveCustShipper(pceipoTH, pceipoCR)
291*!* ENDIF
292*!* *=== TechRec 1036964 18-Dec-2008 T.Shenbagavalli ===
293 *=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
294
295 Endwith
296 Select(lnOldSelect)
297 Return llRetVal
298 Endproc
299
300 *--------------------------------------------------------------------------------------
301
302 Function ResolveBCCustomer
303
304 Lparameters pceipoTH
305 Local llRetVal, lnSelect,lcSQLString ,lccustomer ,lcDepartment, lcOrd_type ,lcBCCustomer ,lcBCEDIStore
306
307 llRetVal = True
308 lnSelect = Select()
309 With This
310 .LogEntry("Resolving BC Customer from Customer Store cross reference.")
311 lcSQLString = " Select * From ZZXCSTCR "
312 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcCustcr")
313
314 If llRetVal
315 lcCursor = GetUniqueFileName()
316
317 Select Distinct rtl_cust,rtl_dept,rtl_ord_type From (pceipoTH) Into Cursor lcCursor
318
319 Select lcCursor
320 lcErrs_Msg = " No matching record in Customer Store cross reference "
321
322 lnCnt = Recc()
323 .LogEntry("Customers found: " + Trans(lnCnt, "999,999"))
324
325 Scan
326 lccustomer = Alltrim(rtl_cust)
327 lcDepartment = Alltrim(rtl_dept)
328 lcOrd_type = Alltrim(rtl_ord_type)
329
330 .LogEntry("Retail Customer: " + lccustomer )
331 .LogEntry("Retail Dept: " + lcDepartment)
332 .LogEntry("Retail order type: " + lcOrd_type)
333
334 Select tcCustcr
335 .LogEntry("Select: tcCustcr")
336
337 Locate For Alltrim(rtl_cust) + Alltrim(rtl_dept) + Alltrim(rtl_ord_type) = lccustomer + lcDepartment + lcOrd_type
338 If Not Found()
339 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y" ;
340 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
341 IN (pceipoTH)
342 .LogEntry(lcErrs_Msg)
343 Else
344 lcBCCustomer = tcCustcr.customer
345 lcBCEDIStore = tcCustcr.Store
346
347 .LogEntry("Replacing Customer/Store with " + lcBCCustomer +", " +lcBCEDIStore)
348
349 * TR 1019260 Added- , ord_type WITH '' ;
350
351 Replace customer With lcBCCustomer ;
352 EDI_STORE With lcBCEDIStore , ord_type With '' ;
353 FOR Alltrim(customer) + Alltrim(department) + Alltrim(ord_type) = lccustomer + lcDepartment + lcOrd_type ;
354 IN (pceipoTH)
355
356 Endif
357 Endscan
358 .TableClose(lcCursor)
359 .TableClose("tcCustcr")
360
361 Endif
362 Endwith
363
364 Select (lnSelect)
365 Return llRetVal
366 Endfunc
367
368 *-----------------------------------------------------------------------------------
369
370 * TAN 29056 YIK
371 Procedure CheckForMultiCust
372 Lparameter pceipoTH, pceipoCR
373 Local lnSelect, lcCursor, lcDiv, lcNewCustID, lcSQLExec, ;
374 llRetVal, llMultiCust
375 Private pcCustomer
376
377 lnSelect = Select()
378 Select (pceipoCR)
379 Scan For mult_cust = 'Y'
380
381 *--- TR 1031442 25-Jun-2008 Goutam
382 *llMultiCust = .T.
383 *--- TR 1031442 25-Jun-2008 Goutam
384
385 pcCustomer = customer
386 lcDiv = division
387 lcCursor = GetUniqueFileName()
388 *- YIK 01/30/02
389 *- We may have multiple POs/regions per customer in one tceipoth file
390 Select Distinct Region From (pceipoTH) ;
391 WHERE customer = pcCustomer ;
392 AND !Empty(Region) ;
393 INTO Cursor &lcCursor
394 Select (lcCursor)
395 Scan
396
397 *--- TR 1031442 25-Jun-2008 Goutam
398 llMultiCust = .T.
399 *--- TR 1031442 25-Jun-2008 Goutam
400
401 pcRegion = Region
402 lcNewCustID = Substr(pcCustomer, 1, 4) + Substr(Region, 1, 2)
403 Replace &pceipoTH..customer With lcNewCustID ;
404 FOR customer = pcCustomer And Region = pcRegion;
405 IN (pceipoTH)
406 Endscan
407 Use In Select(lcCursor) && PL 3/25/02 - close temporary cursor
408 Select (pceipoCR)
409 Endscan
410 llRetVal= !llMultiCust Or .CheckCustomer(pceipoTH)
411 Select (lnSelect)
412 Return llRetVal
413 Endproc
414
415 *-----------------------------------------------------------------------------------
416
417 Procedure CheckStore
418 Lparameters pcHeader, pcControl
419 Local llRetVal, lnOldSelect
420 llRetVal= .T.
421 lnOldSelect= Select()
422
423 * 1st - group get store using cust,edi_store but not overwrite existing store
424 * users could change store in Trans Maint.
425 Select Distinct customer, EDI_STORE, Store From (pcHeader) ;
426 WHERE !Empty(customer) And !Empty(EDI_STORE) Into Cursor __TmpCursor
427 Select __TmpCursor
428 With This
429 .cSQLTempTable=""
430 If .GenerateSQLTempTable('__TmpCursor')
431 If .PopulateSQLTempTable('__TmpCursor')
432 If !Empty(.cSQLTempTable)
433 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
434 * also, populate center_code, consol_code if empty
435 lcSQLString= "Select s.customer, s.store, s.edi_store, s.center_code, s.consol_code,s.active_ok " +;
436 " from zzxstorr s, " + .cSQLTempTable + " t " +;
437 "Where s.customer= t.customer and s.edi_store= t.edi_store"
438 llRetVal = v_SqlExec(lcSQLString, "_Storr")
439 If llRetVal
440 Select _Storr
441 Index On customer+EDI_STORE Tag CustStore
442 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
443 "customer+edi_store")
444 If llRetVal
445 Select (pcHeader)
446
447
448 * --- TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
449 * Otherwise we will not be able to resolve currency later and that will
450
451
452 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
453 * Confirm order(with store) for the same customer
454 * the Bulk order will have "Invalid Store" message.
455 * Only Scan for !Empty(edi_store)
456 Scan For !Empty(EDI_STORE)
457 Do Case
458 Case Empty(_Storr.customer)
459 Replace Errs_msg_H With Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
460 Errs_flg_h With "Y" In (pcHeader)
461 Case _Storr.active_ok <> 'Y'
462 Replace Errs_msg_H With Errs_msg_H + "Inactive Store." +CRLF ,;
463 Errs_flg_h With "Y" In (pcHeader)
464 Otherwise
465 If Empty(Store) && don't want to overwrite previous data
466 Replace Store With _Storr.Store
467 Endif
468 *- YIK 1017307 07/18/06
469 *- Added AND EMPTY(edi_center)
470 *--- TR 1042564 14-Sep-2008 JK ---
471 * if the dts flag on the order is not Y, then populate.
472 IF EVALUATE(pcHeader + ".dts_flag") <> 'Y'
473 *=== TR 1042564 14-Sep-2008 JK ===
474 If Empty(center_code) And !Empty(_Storr.center_code) And Empty(edi_center)
475 Replace center_code With _Storr.center_code
476 Endif
477 If Empty(consol_code) And !Empty(_Storr.consol_code)
478 Replace consol_code With _Storr.consol_code
479 Endif
480 *--- TR 1042564 14-Sep-2008 JK ---
481 ENDIF
482 *=== TR 1042564 14-Sep-2008 JK ===
483 *== 1009508
484 Endcase
485
486 * === TR 1030780 NSD -- If there is an inactive store, put the order in transaction maintenance.
487
488 Endscan
489 Set Relation To
490 Use In _Storr
491 Endif
492 Endif
493 Endif
494 Endif
495 Endif
496 Endwith
497 If Used("__TmpCursor")
498 Use In __TmpCursor
499 Endif
500
501 * 2nd - validate store by cust,store
502 * Notes: cannot reuse the above server side cursor because have
503 * to resolve it to tran header local 1st before validate happen
504 Select Distinct customer, Store From (pcHeader) ;
505 WHERE !Empty(customer) And !Empty(Store) Into Cursor __TmpCursor
506 Select __TmpCursor
507 With This
508 .cSQLTempTable=""
509 If .GenerateSQLTempTable('__TmpCursor')
510 If .PopulateSQLTempTable('__TmpCursor')
511 If !Empty(.cSQLTempTable)
512 lcSQLString= "Select s.customer, s.store " +;
513 " from zzxstorr s, " + .cSQLTempTable + " t " +;
514 "Where s.customer= t.customer and s.store= t.store"
515 llRetVal = v_SqlExec(lcSQLString, "_Storr")
516 If llRetVal
517 Select _Storr
518 Index On customer+Store Tag CustStore
519 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
520 "customer+store")
521 If llRetVal
522 Select (pcHeader)
523 * PL 06/05/01 27688 In same run if have Bulk(blank store) and
524 * Confirm order(with store) for the same customer
525 * the Bulk order will have "Invalid Store" message.
526 * Only Scan for NOT BULK/Blanket Order (CONFIRM Order)
527 * Don't have conf_type as "A" or "B" yet
528 *- 37129 2/5/03 YIK - Added check for Empty(edi_store) to be able to bring in
529 *- assortment orders with no store.
530
531 *--- TR1055827 NSD/FGCjr
532 *Scan For Not (po_type= EDI_BLANKET_ORDER Or po_type= EDI_BULK_ORDER Or Empty(EDI_STORE))
533 SCAN FOR (NOT (po_type= EDI_BLANKET_ORDER OR po_type= EDI_BULK_ORDER OR EMPTY(EDI_STORE))) OR (conf_type = 'A' AND NOT EMPTY(store) AND EMPTY(edi_store))
534 *=== TR1055827
535 If Empty(_Storr.customer)
536 Replace Errs_msg_H With Errs_msg_H + "Invalid Store code." +CRLF ,;
537 Errs_flg_h With "Y" In (pcHeader)
538 Endif
539 Endscan
540 Set Relation To
541 Use In _Storr
542 Endif
543 Endif
544 Endif
545 Endif
546 Endif
547 Endwith
548 If Used("__TmpCursor")
549 Use In __TmpCursor
550 Endif
551
552 If Used("_Storr")
553 Use In _Storr
554 Endif
555
556 Select(lnOldSelect)
557 Return llRetVal
558 Endproc
559
560 *------------------------------------------------------------------------------------------
561
562 ************************************************************************************
563 * Validate EDI Distribution Center
564 * ATS# 2757 PL 06/09/99- validate against edi_center
565 * use edi_center in tran header for validation, when found
566 * replace center_code with zzxdistr.center_code; ONLY do validation for empty tran header
567 * center_code and !Empty(edi_center) never get resolve from edi_center yet.
568 * center_code alway start out empty in tran header, and edi map to edi_center in metadata
569 ************************************************************************************
570 * Abstract: ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
571 * 1. Select Distinct customer, distribution center from work header.
572 * 2. Check for valid distribution center. If faile the check update all headers for
573 * the same customer, distribution center with "Invalid Store code." and
574 * Errs_Flg with "Y"
575 * Return: True= All pass validation
576 * False= If one of them fail the check
577 ************************************************************************************
578 Procedure CheckDistribution
579 Lparameters pceipoTH
580 Local llRetVal, lnOldSelect, lcErrs_Msg, lcShip_dc
581 llRetVal = .T.
582 lnOldSelect = Select()
583
584 Select Distinct customer, edi_center, center_code From (pceipoTH) Where ;
585 !Empty(customer) And !Empty(edi_center) ; && ONLY resolve center_code ONCE
586 Into Cursor CntrList
587 Select CntrList
588 If This.lUserInterface
589 * Init Thermometer
590 This.UpdateThermoCaption("Validating Distribution Center(s)...")
591 * TAN 31891 - JAZ - 5/20/02
592 * This.InitThermo(RECC('CntrList'))
593 This.InitThermo(Reccount('CntrList'))
594 * End TAN 31891 - JAZ - 5/20/02
595 l_nThermoCnt = 0
596 Endif
597 Scan
598 If This.lUserInterface
599 * Advance progress bar, if we're using one.
600 l_nThermoCnt = l_nThermoCnt + 1
601 This.AdvanceThermo(l_nThermoCnt)
602 Endif
603 * Empty(center_code) resolve using edi_center
604 If Empty(center_code)
605 lcErrs_Msg= ""
606 If Not This.oBPOSalesOrder.ValidEDIDistribute(@lcErrs_Msg, customer, edi_center, "D", "tcDistr")
607 lcErrs_Msg= lcErrs_Msg + CRLF
608 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
609 FOR customer= CntrList.customer And edi_center= CntrList.edi_center ;
610 IN (pceipoTH)
611 Else
612 * replace center_code with shipthru.center_code when found edi_center
613 * PL 02/15/00 3647 EDI - 850 process does not bring in EDI center code
614 * COMMENT OUT replace ship_dc with "D" also.
615 *--- TR 1042564 14-Sep-2008 JK added "And dts_flag <> 'Y'" ---
616 * Do not update center code unless dts_flag <> Y
617 Replace center_code With tcDistr.center_code ; &&, ship_dc with "D"
618 For customer= CntrList.customer And edi_center= CntrList.edi_center And dts_flag <> 'Y' ;
619 IN (pceipoTH)
620
621 Endif
622 Else
623 * user may overwrite with wrong center_code, validate distribution center
624 lcErrs_Msg= ""
625 If Not This.oBPOSalesOrder.ValidDistribute(@lcErrs_Msg, customer, center_code, "D", "tcDistr")
626 lcErrs_Msg= lcErrs_Msg + CRLF
627 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg, Errs_flg_h With "Y" ;
628 FOR customer= CntrList.customer And center_code= CntrList.center_code ;
629 IN (pceipoTH)
630 Endif
631 Endif
632
633 Endscan
634 Use In CntrList
635
636 * PL 06/28/00 4195 EDI- 850 resolve consolidate/ distribution center from store if not empty
637 * also, populate center_code, consol_code if empty
638 * populate Ship_dc base on center/consol_code
639 Select (pceipoTH)
640 Scan
641 lcShip_dc = ""
642 *- 1009508 03/16/05
643 *-- IF !EMPTY(&pceipoTH..center_code) OR !EMPTY(&pceipoTH..consol_code)
644 *-- DO CASE
645 *-- CASE !EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
646 *-- lcShip_dc = "B"
647 *-- CASE !EMPTY(&pceipoTH..center_code) AND EMPTY(&pceipoTH..consol_code)
648 *-- lcShip_dc = "D"
649 *-- CASE EMPTY(&pceipoTH..center_code) AND !EMPTY(&pceipoTH..consol_code)
650 *-- lcShip_dc = "C"
651 *-- ENDCASE
652
653 If !Empty(center_code) Or !Empty(consol_code)
654 Do Case
655 Case !Empty(center_code) And !Empty(consol_code)
656 lcShip_dc = "B"
657 Case !Empty(center_code) And Empty(consol_code)
658 lcShip_dc = "D"
659 Case Empty(center_code) And !Empty(consol_code)
660 lcShip_dc = "C"
661 Endcase
662 *= 1009508 YIK
663 If !Empty(lcShip_dc)
664 Replace ship_dc With lcShip_dc In (pceipoTH)
665 Endif
666 Endif
667 Endscan
668
669 If This.lUserInterface
670 * Reset Thermometer
671 This.ResetThermo()
672 Endif
673
674 If Used("CntrList")
675 Use In CntrList
676 Endif
677 If Used("tcDistr")
678 Use In tcDistr
679 Endif
680 Select(lnOldSelect)
681 Return llRetVal
682 Endproc
683
684 *---------------------------------------------------------------------------------
685
686 Procedure CheckNoteType
687 Lparameters tcEiPOth
688 Local llRetVal, lcNotes, laNotes
689 llRetVal = .T.
690 Select (tcEiPOth)
691 Scan For !Empty(notes)
692 lcNotes = notes
693 Declare laNotes[2]
694 laNotes = ""
695 If At("|", lcNotes) > 0 && has note_type
696 *- 1030497 02/29/08 TT
697 *--StringToArray(lcNotes, @laNotes, "|")
698 .oCopyUtil.StringToArray(lcNotes, @laNotes, "|")
699 *- 1030497 02/29/08 TT
700 lnNotes = Alen(laNotes)/2
701 For lnCnt = 1 To lnNotes
702 If !vl_notyp(laNotes[2*lnCnt - 1])
703 lcErrs_Msg = "Invalid notes type " + laNotes[2*lnCnt - 1]
704 Replace Errs_msg_H With Errs_msg_H + lcErrs_Msg + CRLF, Errs_flg_h With "Y"
705 Endif
706 Endfor
707 Endif
708 Endscan
709 Return llRetVal
710 Endproc
711 *---------------------------------------------------------------------------------
712
713 *--- TR 1022625 4-Mar-2007 TT
714 Function CheckTerminationInPoType
715 Lparameters pceipoTH
716 LOCAL llRetVal, lnOldSelect
717 lnOldSelect = SELECT()
718 llRetVal = .t.
719 Local lnLastOrder
720 Select (pceipoTH)
721 lnLastOrder = Order()
722 Set Order To Tag po_type
723 If Seek("TR", pceipoTH, "po_type")
724 Scan While po_type = 'TR'
725 Replace Errs_msg_H With Errs_msg_H + ;
726 "Purchase Order Transmitted is to be CANCELED." +CRLF ,;
727 Errs_flg_h With "Y" In (pceipoTH)
728 Endscan
729 Endif
730 Set Order To lnLastOrder
731 SELECT(lnOldSelect)
732 RETURN llRetVal
733 Endfunc
734 *--- TR 1022625 4-Mar-2007 TT
735
736 *---------------------------------------------------------------------------------
737
738 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
739 PROCEDURE Validate855Status
740 LPARAMETERS pcHeader, pcDetail, pcHeaderDetail
741
742 Local llRetVal, lnOldSelect, lcSourceFilter
743 llRetVal= true
744 lnOldSelect= Select()
745
746 IF pcHeaderDetail = 'H'
747 SELECT Distinct status_855 FROM (pcHeader) ;
748 WHERE REQ_855 = 'R' AND NOT EMPTY(STATUS_855) INTO CURSOR __tmp855Status
749 lcSourceFilter = " s.source = 'BAK02'"
750 ELSE
751 SELECT DISTINCT d.status_855 ;
752 FROM (pcDetail) d ;
753 JOIN (pcHeader) h ;
754 ON h.pkey = d.fkey ;
755 WHERE h.req_855 = 'R' AND NOT EMPTY(d.status_855) ;
756 INTO CURSOR __tmp855Status
757 lcSourceFilter = " s.source IN ('ACK01','ACK29')"
758 ENDIF
759
760 SELECT __tmp855Status
761 WITH This
762 .cSQLTempTable=""
763 IF .GenerateSQLTempTable('__tmp855Status')
764 IF .PopulateSQLTempTable('__tmp855Status')
765 IF !EMPTY(.cSQLTempTable)
766
767 lcSQLString= "Select s.status_855 from " +;
768 " zzeopakr s, " + .cSQLTempTable + " t " +;
769 "Where s.status_855 = t.status_855 and " + lcSourceFilter
770
771 llRetVal = v_SqlExec(lcSQLString, "_Ststus855")
772 IF llRetVal
773 SELECT _Ststus855
774 INDEX On status_855 TAG status_855
775 IF pcHeaderDetail = 'H'
776 llRetVal= .SetRelation("_Ststus855", "status_855", pcHeader, "status_855")
777 ELSE
778 llRetVal= .SetRelation("_Ststus855", "status_855", pcDetail, "status_855")
779 ENDIF
780
781 IF llRetVal
782 IF pcHeaderDetail = 'H'
783 Replace Errs_msg_H WITH Errs_msg_H + "Invalid 855 status code." + CRLF , ;
784 Errs_flg_h WITH "Y" FOR EOF("_Ststus855") AND REQ_855 = 'R' AND NOT EMPTY(status_855) In (pcHeader)
785 ELSE
786 Replace Errs_msg_D WITH Errs_msg_D + "Invalid 855 status code." + CRLF , ;
787 Errs_flg_d WITH "Y" FOR EOF("_Ststus855") AND NOT EMPTY(status_855) In (pcDetail)
788
789 * mark headers errors here as the Run855Process which runs next will rely on header errors.
790 SELECT (pcDetail)
791 SCAN FOR errs_flg_d = 'Y'
792 REPLACE errs_flg_h WITH 'Y' IN (pcHeader) FOR EVALUATE(pcDetail+'.fkey') = EVALUATE(pcHeader+'.pkey') ;
793 AND EVALUATE(pcHeader+'.req_855') = 'R'
794 ENDSCAN
795 ENDIF
796
797 SET RELATION TO
798 ENDIF
799 ENDIF
800 ENDIF
801 ENDIF
802 ENDIF
803 ENDWITH
804
805 IF USED("__tmp855Status")
806 USE IN __tmp855Status
807 ENDIF
808 IF USED("_Ststus855")
809 USE IN _Ststus855
810 ENDIF
811
812 Select(lnOldSelect)
813 Return llRetVal
814 ENDPROC
815 *=== TR 1074251 03-Jan-2014 Goutam
816
817 *---------------------------------------------------------------------------------
818
819 *--- TR 1030441 17-Apr-2008 Goutam
820 Procedure CheckShipper
821 LPARAMETERS pcHeader
822 Local llRetVal, lnOldSelect
823 llRetVal= true
824 lnOldSelect= Select()
825
826 SELECT Distinct shipper FROM (pcHeader) ;
827 WHERE NOT EMPTY(shipper) INTO CURSOR __tmpShipper
828
829 SELECT __tmpShipper
830 WITH This
831 .cSQLTempTable=""
832 IF .GenerateSQLTempTable('__tmpShipper')
833 IF .PopulateSQLTempTable('__tmpShipper')
834 IF !EMPTY(.cSQLTempTable)
835 lcSQLString= "Select s.shipper from " +;
836 " zzxshipr s, " + .cSQLTempTable + " t " +;
837 "Where s.shipper= t.shipper"
838 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
839 IF llRetVal
840 SELECT _Shiper
841 INDEX On shipper TAG Shipper
842 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
843 IF llRetVal
844 SELECT (pcHeader)
845 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
846 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
847 SET RELATION TO
848 ENDIF
849 ENDIF
850 ENDIF
851 ENDIF
852 ENDIF
853 ENDWITH
854
855 IF USED("__tmpShipper")
856 USE IN __tmpShipper
857 ENDIF
858 IF USED("_Shiper")
859 USE IN _Shiper
860 ENDIF
861
862 Select(lnOldSelect)
863 Return llRetVal
864 Endproc
865 *=== TR 1030441 17-Apr-2008 Goutam
866
867 *---------------------------------------------------------------------------------
868
869 ************************************************************************************
870 * Error check all raw EDI details
871 ************************************************************************************
872 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
873 * Move codes to CheckUPC() and CheckSKU()
874 * Add:ResolveCustomerLabel()
875 * take ValidateAvailSize() out of both CheckUPC, CheckSKU and consolidated to
876 * Add:ValidateOurSKU() which call after ResolveCustomerLabel() for our SKU validate
877 * [div,sty,col,lbl,dim,size] allow or not
878 *
879 Procedure CheckDetail
880 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
881 pceipoTS, tceipoTSAC,; && *--- TechRec 1005163 17-May-2004 GS ---
882 tceipoTR, pczzeiPOtWhse &&--- TechRec 1028745 05-Feb-2008 GSternik ---
883 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
884 Local llRetVal, lnOldSelect
885 llRetVal = .T.
886 lnOldSelect = Select()
887 With This
888 *--- TechRec 1048792 17-Dec-2010 jisingh ---
889 llRetVal = llRetVal AND .ClearSkus(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
890 *=== TechRec 1048792 17-Dec-2010 jisingh ===
891
892 *--- TechRec 1048667 03-May-2011 GSternik --- Moved here! (used to be after CheckEAN call)
893 *--- TR 1019697 NH
894 .LogEntry("Cascading Customer To Detail.")
895 llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
896 .LogEntry("Cascading Customer To SLN.")
897 llRetVal= llRetVal And .CascadingCustomerToSLN(pceipoTD, pceipoTS)
898 *=== TR 1019697 NH
899 *=== TechRec 1048667 03-May-2011 GSternik ===
900
901
902 *--- TechRec 1024522 18-Sep-2007 GSternik ---
903 *--- LOCAL MOD
904 *If This.lHaveSLN
905 If This.oHostProcess.lHaveSLN
906 .LogEntry("Resolving SLNs/Prepack Style.")
907 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
908 llRetVal= llRetVal AND .ResolveStyleFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
909 EndIf
910 *=== TechRec 1024522 18-Sep-2007 GSternik ===
911
912 .LogEntry("Resolving style using UPC.")
913 *--- TechRec 1005163 17-May-2004 GS ---
914 *llRetVal= llRetVal and .CheckUpc(pceipoTH, pceipoTD)
915 *--- TR 1019697 NH
916 *llRetVal= llRetVal AND .CheckUpc(pceipoTH, pceipoTD, pceipoTS)
917 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
918*!* llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.) && TR 1019697 NH : clear range style info
919 llRetVal= llRetVal And .CheckUpc(pceipoTH, pceipoTD, pceipoTS, .T.,pceipoCR ) && TR 1019697 NH : clear range style info
920 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
921
922 *--- TR 1036917 04-Feb-2009 Partha ---
923 *--- TR 1044885 13-JAN-2010 BR MOVING DOWN
924 *llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
925
926 *=== TR 1036917 04-Feb-2009 Partha ===
927
928 *=== TR 1019697 NH
929 *=== TechRec 1005163 17-May-2004 GS ===
930 *--- TR 1023892 NH
931 llRetVal = llRetVal and .Populate_Cust_lbl(pceipoTH, pceipoTD)
932 *=== TR 1023892 NH
933
934 *--- TR 1044885 13-JAN-2010 BR Moved from above
935 llRetVal= llRetVal And .ChangeColor(pceipoTH, pceipoTD, pceipoTS, pceipoCR )
936
937 *- 39222 4/30/03 YIK - Compare customer sku for the resolved UPC with sku sent in edi file.
938 *--- TechRec 1005163 17-May-2004 GS ---
939 *- Combined ConfirmUPC and ConfirmEAN. in one method, which is called after CheckEAN
940 *llRetVal= llRetVal and .ConfirmSku(pceipoTH, pceipoTD, pceipoCR)
941 *=== TechRec 1005163 17-May-2004 GS ===
942 *= 39222
943
944 *- TR 1003801 - 03/25/04 BD - Resolve EAN
945 .LogEntry("Resolving style using EAN.")
946
947 *--- TechRec 1005163 17-May-2004 GS ---
948 *llRetVal= llRetVal and .CheckEAN(pceipoTH, pceipoTD)
949 *--- TR 1061652 05/18/12 ATHIRUNAVU Added pceipoCR
950 llRetVal= llRetVal And .CheckEAN(pceipoTH, pceipoTD, pceipoTS,pceipoCR)
951 *=== TR 1061652 05/18/12 ATHIRUNAVU
952
953 *- When both EAN and SKU are sent in EDI file, compare customer sku for the resolved EAN with sku sent in edi file.
954 *llRetVal= llRetVal and .ConfirmSkuFromEAN(pceipoTH, pceipoTD, pceipoCR)
955 *--- TR 1035223 NH
956 .LogEntry("Setting Skip SLN Check flag.")
957 llRetVal = llRetVal and this.SetupSkipSLNCheck(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
958 llRetVal = llRetVal and this.ClearErrorsForSkipSlnCheck(pceipoTH, pceipoTD, pceipoTS)
959 *=== TR 1035223 NH
960
961 *--- TR 1053820 26-May-2011 Goutam
962 IF .oHostProcess.l850_Gen_Custsku_Style_Colorsize
963 .LogEntry("Generate Customer SKU (Style_ColorSize).")
964 llRetVal= llRetVal And .GenerateCustomerSKU_Style_ColorSize(pceipoTH, pceipoTD)
965 ENDIF
966 *=== TR 1053820 26-May-2011 Goutam
967
968 .LogEntry("Confirming SKU for UPC/EAN.")
969 llRetVal= llRetVal And .ConfirmSku(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
970 *=== TechRec 1005163 17-May-2004 GS ===
971 *=== TR 1003801
972
973 *--- TechRec 1019260 09-Nov-2006 vkrishnamurthy ---
974 If llRetVal And .oHostProcess.lRBACustSku
975 .LogEntry("Verifying Customer SKU.")
976 llRetVal = .GenerateRBACustSKU(pceipoTH,pceipoTD)
977 Endif
978 *=== TechRec 1019260 09-Nov-2006 vkrishnamurthy ===
979
980 .LogEntry("Resolving style using SKU.")
981 *--- TechRec 1005163 17-May-2004 GS ---
982 *llRetVal= llRetVal and .CheckSku(pceipoTH, pceipoTD)
983
984 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
985 *llRetVal= llRetVal AND .CheckSku(pceipoTH, pceipoTD, pceipoTS)
986 llRetVal= llRetVal And .CheckSku(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
987 *=== TR 1010097 07/27/05 TK
988 *=== TechRec 1005163 17-May-2004 GS ===
989
990 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
991 llRetVal = llRetVal And .PopulateOrigLabel(pceipoTH, pceipoTD, pceipoCR)
992 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
993
994 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
995 llRetVal= llRetVal And .ConfirmUPC(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
996 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
997
998 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
999 llRetVal = llRetVal AND .MarkHeaderwithDetailOrSLNInError(pceipoTH, pceipoTD, pceipoTS)
1000 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
1001
1002 *--- TR 1040432 MAY-20-2009 BR - MOVED: UpdtHeaderDivs, need division before new approach to 855 control ref resolution can be done
1003 llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1004 *=== TR 1040432 MAY-20-2009 BR
1005
1006 *--- TR 1013007 NH
1007 *--- check if req_855 if 'R' and status flag is empty then set error flag
1008 llRetVal = llRetVal And .Check855Required(pceipoTH, pceipoTD, pceipoTS, pceipoCR)
1009 *=== TR 1013007 NH
1010
1011 *--- TR 1074251 03-Jan-2014 Goutam/KISHORE
1012 If llRetVal
1013 .LogEntry("Validating detail 855 status code.")
1014 llRetVal= .Validate855Status(pceipoTH, pceipoTD, "D")
1015 Endif
1016 *=== TR 1074251 03-Jan-2014 Goutam/KISHORE
1017
1018 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1019 .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
1020 vcLogName)
1021
1022 *--- TR 1013007 NH 2005-10-11
1023 *--- ref_855 is not 'Y' in zzeipoth then do not send data back to server
1024 If .lSend855
1025 *--- TR 1034481 NH : need to populate division in trans header for Opr control ref check
1026
1027 *--- TR 1040432 MAY-20-2009 BR - MOVING: UpdtHeaderDivs to get division before Check855Required is executed.
1028 *llRetVal= llRetVal And .UpdtHeaderDivs(pceipoTH, pceipoTD)
1029 *=== TR 1040432 MAY-20-2009 BR
1030
1031 *--- Error out IPO records which has no corresponding OPRCR control ref
1032 *--- IPO and OPRCR link is customer, division, oVnd_Key
1033 llRetVal = llRetVal and .MarkHeaderForMissing855ControlRef(pceipoTH)
1034 *=== TR 1034481 NH
1035 llRetVal = llRetVal And .UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
1036 *--- If req_855 = 'R'
1037 *--- then run process 855
1038 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
1039 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
1040 llRetVal = llRetVal And .Run855Process(pceipoTH, pceipoTD, pczzeiPOtWhse)
1041 Endif
1042 *=== TR 1013007 NH
1043
1044 *--- TechRec 1056904 24-Oct-2011 jisingh ---
1045 .LogEntry("Resolving Is 860.")
1046 llRetVal = llRetVal And .PopulateIs860(pceipoTH, pceipoCR)
1047
1048 .LogEntry("Creating 860 Transaction records.")
1049 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
1050 llRetVal = llRetVal And .Create860TM(pceipoTH, pceipoTD)
1051 *=== TechRec 1056904 24-Oct-2011 jisingh ===
1052
1053 *--- TechRec 1082601 24-Dec-2014 jisingh ---
1054 .LogEntry("Validating detail 860 qual.")
1055 llRetVal = llRetVal And .Validate860Qual(pceipoTH, pceipoTD)
1056 *=== TechRec 1082601 24-Dec-2014 jisingh ===
1057
1058 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
1059 .LogEntry("Resolving Multi-UPCs.")
1060 llRetVal = llRetVal And .CheckMultiUPC(pceipoTH, pceipoTD)
1061 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
1062
1063 .LogEntry("Resolving range style.")
1064 *--- TR 1023892 NH -
1065 *llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC) && "Vzzeipotd_IPOProc"
1066 llRetVal= llRetVal And .RangeStyle(pceipoTH, pceipoTD, tceipoTSAC, pceipoCR) && "Vzzeipotd_IPOProc"
1067 *=== TR 1023892 NH
1068
1069 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
1070 .AdvanceThermoTotalWithCaptionPlus("Range Prepack Conversion...", vcLogName)
1071 llRetVal= llRetVal And .RangePConversion(pceipoTH, pceipoTD, pceipoCR)
1072 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
1073
1074 .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
1075 vcLogName)
1076 *- 36262 6/11/03 YIK
1077 *- EDI Prepack qty/price conversion. Only for upcs or styles not exploded via style range
1078 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
1079 vcLogName)
1080 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
1081 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pceipoTS
1082 *llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR)
1083 llRetVal= llRetVal And .PrepackConversion(pceipoTH, pceipoTD, pceipoCR, pceipoTS)
1084 * === TR 1046519 7/26/10 CM
1085
1086 *=
1087
1088 *- 1044723 01/06/10 YIK
1089 *- Moved this method up here, before ResolveOrdTypeXRef() and implosion
1090 llRetVal = llRetVal and .ResolveNewStoreOrd_type(pceipoTH)
1091
1092 *- TR 1042748 09/23/09 YIK
1093 *- Call it here to populate Impl_ok flag (3d parameter).
1094 *- MOved it to clsipopr, so need to call with .oHostProcess
1095 *- This method will be called again after implosion. Ok per JRoth
1096 llRetVal = llRetVal and .oHostProcess.ResolveOrdTypeXRef(pceipoTH,pceipoTD, .T.)
1097
1098
1099 * 3/25/02 30854 - Implosion single prepack
1100 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
1101 vcLogName)
1102 llRetVal= llRetVal And .ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
1103
1104 *- 1006607 09/01/04 YIK
1105 .AdvanceThermoTotalWithCaptionPlus("Resolving Range Style...", ;
1106 vcLogName)
1107 llRetVal= llRetVal And .ResolveRangeP(pceipoTH, pceipoTD, pceipoCR)
1108 *=========
1109
1110 *--- TechRec 1005163 17-May-2004 GS ---
1111 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack...", vcLogName)
1112 If .oHostProcess.lHaveSLN
1113 *--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
1114
1115 *--- TR 1049029 27-Aug-2010 Partha : blocking this call as suggested by Yuri ---
1116*!* .LogEntry("Calculating SLN quantities based on Prepack.")
1117*!* llRetVal= llRetVal And .CalculateSLNs(pceipoTH,pceipoTD, pceipoTS,pceipoCR)
1118 *=== TR 1049029 27-Aug-2010 Partha ===
1119
1120 *=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
1121
1122 .LogEntry("Validating SLN vs. Prepack.")
1123 llRetVal= llRetVal And .CheckSLN(pceipoTH, pceipoTD, pceipoTS)
1124 Endif
1125 *=== TechRec 1005163 17-May-2004 GS ===
1126
1127 *--- TR 1011644 23-AUG-2005 KA
1128 *If this.oResolvePrepack.lMultipack
1129 If this.lMultipack
1130 *llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.oResolvePrepack.cMPPK)
1131 llRetVal = llRetVal And .ResolveMultiPrepacks(pceipoTH, pceipoTD,this.cMPPK)
1132 Endif
1133 *=== TR 1011644 23-AUG-2005 KA
1134
1135 .LogMajorStage("Resolving and getting default fields.")
1136 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
1137 .LogEntry("Resolving customer label.")
1138 *--- TechRec 1005163 18-May-2004 GS ---
1139 *llRetVal= llRetVal and .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
1140 llRetVal= llRetVal And .ResolveCustomerLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
1141 *=== TechRec 1005163 18-May-2004 GS ===
1142
1143 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
1144 vcLogName)
1145
1146 .LogEntry("Validating style.")
1147 *--- TechRec 1005163 21-Jun-2004 GS ---
1148 *llRetVal= llRetVal and .ValidateOurSKU(pceipoTH, pceipoTD)
1149 *--- TechRec 1016817 04-May-2006 GS ---
1150 *llRetVal= llRetVal AND .ValidateOurSKU(pceipoTH, pceipoTD, .F., pceipoTS)
1151 llRetVal= llRetVal And .ValidateOurSKU(pceipoTH, pceipoTD, pceipoTS)
1152 *=== TechRec 1016817 04-May-2006 GS ===
1153 *=== TechRec 1005163 21-Jun-2004 GS ===
1154
1155 *--- TechRec 1028745 05-Feb-2008 GSternik ---
1156 If This.oHostProcess.lHaveChrgs
1157 .LogEntry("Validating Charges.")
1158 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added pceipoTH ===
1159 llRetVal = llRetVal and .ValidateCharges(pceipoTD, tceipoTR, pceipoTH)
1160 EndIf
1161 *-- This is not needed anymore:
1162 ** PL 02/16/01 2375 - EDI - Mininum Multiple check in 850 process
1163 *.AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
1164 * vcLogName)
1165 *=== TechRec 1028745 05-Feb-2008 GSternik ===
1166
1167 *---TR 1012978 VK 23/11/05 - Moving this code to method CheckDefaults()
1168 *!* .LogEntry("Validating MinMultiple.")
1169 *!* llRetVal= llRetVal AND .ValidateMinMultiple(pceipoTH, pceipoTD)
1170 *===TR 1012978 VK 23/11/05
1171
1172 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
1173 .AdvanceThermoTotalWithCaptionPlus("Checking & Converting Inbound UOM...", ;
1174 vcLogName)
1175 .LogEntry("Converting inbound UOM.")
1176 llRetVal= llRetVal And .PopulateInboundUOM(pceipoTH, pceipoTD)
1177
1178 *--- TechRec 1048792 21-Dec-2010 jisingh ---
1179 *-- Populate new flag from Control in Transaction Maintenance, Rewritten for first time only
1180 lcSqlString = " UPDATE h SET " + ;
1181 " ReResvStyle = c.ReResvStyle " + ;
1182 " FROM (pcEipoTH) h " + ;
1183 " JOIN (pcEipoCR) c " + ;
1184 " ON h.division = c.division " + ;
1185 " AND h.customer = c.customer " + ;
1186 " WHERE h.ReResvStyle = '' "
1187
1188 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
1189 *=== TechRec 1048792 21-Dec-2010 jisingh ===
1190 EndWith
1191
1192 Select(lnOldSelect)
1193 Return llRetVal
1194 ENDPROC
1195
1196 *----------------------------------------------------------------------------------------
1197 * TR 1037976 JAN-22-2008 BR
1198 *----------------------------------------------------------------------------------------
1199 Procedure UpdtHeaderDivs
1200 Lparameters pceipoTH, pceipoTD
1201 Local llRetVal, lnOldSelect, llUpdate
1202 llRetVal = .T.
1203 lnOldSelect = Select()
1204
1205 .LogEntry("Resolving header division.")
1206 *- 1005164 07/12/04 YIK
1207 *- Removed ..And Empty(Errs_Msg_D)
1208 Select Distinct fkey, division From (pceipoTD) ;
1209 WHERE !Empty(division) Into Cursor tmpCurs
1210 Select tmpCurs
1211 If This.lUserInterface
1212 * Init Thermometer
1213 * TAN 31891 - JAZ - 5/20/02
1214 * This.InitThermo(RECC('tmpCurs'))
1215 This.InitThermo(Reccount('tmpCurs'))
1216 * End TAN 31891 - JAZ - 5/20/02
1217 l_nThermoCnt = 0
1218 Endif
1219 Scan
1220 If This.lUserInterface
1221 * Advance progress bar, if we're using one.
1222 l_nThermoCnt = l_nThermoCnt + 1
1223 This.AdvanceThermo(l_nThermoCnt)
1224 Endif
1225 Select (pceipoTH)
1226
1227 * --- TR 1022896 NSD 05-10-07
1228 * Convert LOCATE to SEEK
1229 *LOCATE FOR pkey = tmpCurs.fkey
1230 *IF FOUND()
1231 If Seek(tmpCurs.fkey,pceipoTH,"pkey")
1232 * === TR 1022896 NSD 05-10-07
1233
1234 Replace division With tmpCurs.division In (pceipoTH)
1235 Endif
1236 Endscan
1237 Use In tmpCurs
1238
1239 If This.lUserInterface
1240 * Reset Thermometer
1241 This.ResetThermo()
1242 Endif
1243 Select(lnOldSelect)
1244 Return llRetVal
1245 ENDPROC
1246 *----------------------------------------------------------------------------------------
1247 * TR 1037976 JAN-22-2008 BR
1248 *----------------------------------------------------------------------------------------
1249
1250 *---------------------------------------------------------------------------------
1251
1252 *--- TechRec 1024522 18-Sep-2007 GSternik ---
1253 ************************************************************************************
1254 * Resolve BC SKU from SLN records and create customer style data.
1255 ************************************************************************************
1256 Procedure ResolveStyleFromSLN
1257 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
1258 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1259 *--- TR 1035491 4-Nov-2008 Goutam
1260 *--- This entire function splitted into two different part ;
1261 1. ResolveBCSkuFromSLN ;
1262 2. ResolvePPKSkuAndUpdateDetail
1263
1264 Local llRetVal, lnOldSelect
1265 lnOldSelect = Select()
1266 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
1267 llRetVal = This.ResolveBCSkuFromSLN(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
1268
1269
1270 Select(lnOldSelect)
1271 Return llRetVal
1272 Endproc
1273
1274 *----------------------------------------------------------------------------------
1275 ************************************************************************************
1276 * Validate UPC for all details
1277 ************************************************************************************
1278 Procedure CheckUpc
1279 Lparameters pceipoTH, pceipoTD,;
1280 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
1281
1282 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1283 * Added Parameter pceipocr
1284 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1285
1286 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1287 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1288 lnSize_desc, llSLN
1289
1290 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1291 LOCAL lcIs_upcsku
1292 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1293
1294 llRetVal = .T.
1295 lcErrs_Msg= ""
1296 lnOldSelect = Select()
1297
1298 * cannot check for UPC if customer is empty
1299 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
1300 * on Cust SKU or UPC.
1301 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
1302
1303 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
1304 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
1305 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
1306
1307 *--- TechRec 1005163 17-May-2004 GS ---
1308 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1309 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
1310 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1311 *Order by h.customer, d.upc Into Cursor tmpCurs
1312
1313 *---- TR 1024667 NSD 5/31/07
1314 * If sizebucket = 0 then re-resolve.
1315
1316 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1317 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
1318*!* If This.lHaveSLN
1319*!* Select h.customer,;
1320*!* d.upc,;
1321*!* d.pkey,;
1322*!* (pceipoTD) As Src;
1323*!* FROM (pceipoTH) h ;
1324*!* JOIN (pceipoTD) d ;
1325*!* ON h.pkey = d.fkey ;
1326*!* WHERE !Empty(d.upc) ;
1327*!* AND !Empty(h.customer) ;
1328*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1329*!* UNION All ;
1330*!* SELECT h.customer,;
1331*!* s.SLN_UPC As upc,;
1332*!* s.pkey,;
1333*!* (pceipoTS) As Src ;
1334*!* FROM (pceipoTH) h ;
1335*!* JOIN (pceipoTD) d ;
1336*!* ON d.fkey = h.pkey ;
1337*!* JOIN (pceipoTS) s ;
1338*!* ON s.fkey = d.pkey ;
1339*!* WHERE !Empty(s.SLN_UPC) ;
1340*!* AND !Empty(h.customer) ;
1341*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1342*!* ORDER By 1, 2 ;
1343*!* INTO Cursor tmpCurs
1344*!* Else
1345*!* Select h.Customer,;
1346*!* d.UPC,;
1347*!* d.PKey,;
1348*!* (pceipoTD) As Src;
1349*!* FROM (pceipoTH) h ;
1350*!* JOIN (pceipoTD) d ;
1351*!* ON h.pkey = d.fkey ;
1352*!* WHERE !Empty(d.upc) ;
1353*!* AND !Empty(h.customer) ;
1354*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
1355*!* ORDER By 1, 2;
1356*!* INTO Cursor tmpCurs
1357*!* Endif
1358 *=== TechRec 1005163 17-May-2004 GS ===
1359
1360 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1361 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1362 FROM (pceipocr) ;
1363 GROUP BY customer ;
1364 INTO CURSOR __ResvCustSKU
1365 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1366
1367 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
1368*!* select h.Customer;
1369*!* , d.UPC;
1370*!* , d.PKey;
1371*!* from (pceipoTH) h;
1372*!* join (pceipoTD) d;
1373*!* on h.PKey = d.FKey;
1374*!* where !Empty(d.UPC);
1375*!* and !Empty(h.Customer);
1376*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
1377*!* order by 1, 2;
1378*!* into Cursor tmpCurs ReadWrite
1379
1380 *- 1035314 08/28/08 YIK
1381 *- Added r.ResvCustSKU to the list of fields
1382 *- If 'Y' - we need to resolve against Cust Style reference, but not against UPC.
1383
1384.oLog.LogEntry("CheckUpc: Build tmpCurs") &&1040686
1385
1386 Select h.customer;
1387 , d.upc;
1388 , d.pkey;
1389 ,(pceipoTD) AS Src;
1390 ,r.ResvCustSKU ;
1391 from (pceipoTH) h;
1392 join (pceipoTD) d;
1393 on h.pkey = d.fkey;
1394 JOIN __ResvCustSKU r ;
1395 ON r.Customer = H.Customer ;
1396 where !Empty(d.upc);
1397 and !Empty(h.customer);
1398 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
1399 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1400 order By 1, 2;
1401 into Cursor tmpCurs Readwrite
1402 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
1403 *= 08/12/08 YIK TR 1035314
1404*=== TechRec 1024522 25-Sep-2007 GSternik ===
1405
1406*-1040686
1407 .oLog.LogEntry("CheckUpc: Build tmpCstdr_upc")
1408 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1409 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
1410 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
1411 IF llRetVal
1412 .PopulateSQLTempTable("tcCustUpc")
1413 ENDIF
1414
1415 llRetVal = llRetVal AND v_sqlexec(;
1416 "SELECT x.upc,d.* "+;
1417 " FROM zzxcstdr d"+ ;
1418 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
1419 " JOIN " + this.cSQLTempTable + " x " + ;
1420 " ON d.customer = x.customer " +;
1421 " AND d.cust_style = x.upc " + ;
1422 " WHERE h.IB_resolv = 'Y'" + ;
1423 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
1424 SELECT tmpCstdr_upc
1425 INDEX on customer + upc TAG cust_upc
1426
1427
1428 .oLog.LogEntry("CheckUpc: Build tmpUpcnr")
1429 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
1430 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
1431 IF llRetVal
1432 .PopulateSQLTempTable("tcDistUpc")
1433 ENDIF
1434
1435 llRetVal = llRetVal AND v_sqlexec(;
1436 "SELECT x.upc,d.* "+;
1437 " FROM zzeupcnr d"+ ;
1438 " JOIN " + this.cSQLTempTable + " x " + ;
1439 " ON d.upc_num = x.upc_num ","tmpUpcnr")
1440 SELECT tmpUpcnr
1441 INDEX on upc TAG upc
1442 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-
1443*-1040686
1444
1445 lcOldCust = ""
1446 lcOldItem = ""
1447 Select tmpCurs
1448 If This.lUserInterface
1449 * Init Thermometer
1450 This.UpdateThermoCaption("Validating UPC(s)...")
1451 * TAN 31891 - JAZ - 5/20/02
1452 * This.InitThermo(RECC('tmpCurs'))
1453 This.InitThermo(RecCount('tmpCurs'))
1454 * End TAN 31891 - JAZ - 5/20/02
1455 l_nThermoCnt = 0
1456 EndIf
1457
1458 Scan
1459 If This.lUserInterface
1460 * Advance progress bar, if we're using one.
1461 l_nThermoCnt = l_nThermoCnt + 1
1462 This.AdvanceThermo(l_nThermoCnt)
1463 Endif
1464 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
1465 lcErrs_Msg = ""
1466 lcOldCust = tmpCurs.customer
1467 lcOldItem = tmpCurs.upc
1468 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1469 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1470
1471 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1472 lcIs_upcsku = ' '
1473 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1474
1475 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
1476 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") && 1040686
1477
1478 *- 1040686 - tmpCstdr_upc...
1479 lcDivision = tmpCstdr_upc.division
1480 lcStyle = tmpCstdr_upc.Style
1481 lcColor_code = tmpCstdr_upc.color_code
1482 lcLbl_code = tmpCstdr_upc.lbl_code
1483 lcDimension = tmpCstdr_upc.Dimension
1484 lnSizeBucket = tmpCstdr_upc.size_bk
1485 lnSize_desc = tmpCstdr_upc.size_desc
1486 *- 1040686 - tmpCstdr_upc...
1487
1488 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1489 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
1490 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1491
1492 ELSE
1493 *- 08/12/08 YIK TR 1035314
1494 IF ResvCustSKU <> 'Y'
1495 lcErrs_Msg = ""
1496 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
1497 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&*- 1040686
1498 lcDivision = tmpUpcnr.division
1499 lcStyle = tmpUpcnr.Style
1500 lcColor_code = tmpUpcnr.color_code
1501 lcLbl_code = tmpUpcnr.lbl_code
1502 lcDimension = tmpUpcnr.Dimension
1503 lnSizeBucket = tmpUpcnr.sizebucket
1504 lnSize_desc = tmpUpcnr.size_desc
1505 Else
1506 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF &&*- 1040686
1507 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1508 Store 0 To lnSizeBucket
1509 Endif
1510 *- 08/12/08 YIK TR 1035314
1511 ELSE
1512 lcErrs_Msg = "UPC not found in the Customer Style Reference. " + CRLF
1513 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1514 STORE 0 TO lnSizeBucket
1515 ENDIF
1516 *= 08/12/08 YIK TR 1035314
1517 Endif
1518 Endif && level break
1519
1520 *--- TechRec 1005163 17-May-2004 GS ---
1521 *Select (pceipoTD)
1522*!* llSLN = (tmpCurs.Src = pceipoTS)
1523*!* If llSLN
1524*!* Select (pceipoTS)
1525*!* Else
1526 Select (pceipoTD)
1527*!* Endif
1528 *=== TechRec 1005163 17-May-2004 GS ===
1529 *- 1010682 04/25/05 YIK
1530 *- Locate For pkey = tmpCurs.pkey
1531 lnWorkArea = Select()
1532 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1533 Scatter Name loEiPOtd Memo
1534 If !Empty(lcErrs_Msg)
1535*!* *--- TechRec 1005163 17-May-2004 GS ---
1536*!* If llSLN
1537*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1538*!* loEiPOtd.Errs_Flg_S = "Y"
1539*!* Else
1540*!* *=== TechRec 1005163 17-May-2004 GS ===
1541 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1542 loEiPOtd.Errs_Flg_D = "Y"
1543*!* Endif
1544 Endif
1545 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1546 loEiPOtd.Division = lcDivision
1547 loEiPOtd.Style = lcStyle
1548 loEiPOtd.Color_Code = lcColor_code
1549 loEiPOtd.Lbl_Code = lcLbl_code
1550 loEiPOtd.Dimension = lcDimension
1551 loEiPOtd.SizeBucket = lnSizeBucket
1552 loEiPOtd.Size_Desc = lnSize_desc
1553
1554 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
1555 IF !EMPTY(lcIs_upcsku)
1556 loEiPOtd.Is_upcsku = lcIs_upcsku
1557 ENDIF
1558 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
1559
1560 *--- TR 1019697 NH : clear rang style when bc style is set
1561 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
1562 loEiPOtd.rng_style = ''
1563 loEiPOtd.rng_color = ''
1564 loEiPOtd.rng_lbl = ''
1565 loEiPOtd.rng_pack = ''
1566 Endif
1567 *=== TR 1019697 NH
1568 Endif
1569
1570 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1571 * only replace our SKU when no range style explosion happen
1572 *--- TechRec 1005163 17-May-2004 GS ---
1573 *If empty(&pceipoTD..rng_style)
1574 * Replace division With loEiPOtd.division, ;
1575 * style With loEiPOtd.style, ;
1576 * color_code With loEiPOtd.color_code, ;
1577 * lbl_code With loEiPOtd.lbl_code, ;
1578 * dimension With loEiPOtd.dimension, ;
1579 * sizebucket With loEiPOtd.sizebucket, ;
1580 * size_desc With loEiPOtd.size_desc, ;
1581 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1582 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1583 * In (pceipoTD)
1584 *Endif
1585 *- 1009508 3/16/05 YIK
1586 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1587 *--- TechRec 1024522 25-Sep-2007 GSternik ---
1588 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1589 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
1590 *=== TechRec 1024522 25-Sep-2007 GSternik ===
1591
1592 Gather Name loEiPOtd Memo
1593 Endif
1594 *=== TechRec 1005163 17-May-2004 GS ===
1595
1596 Endscan
1597 Use In tmpCurs
1598
1599 If This.lUserInterface
1600 * Reset Thermometer
1601 This.ResetThermo()
1602 Endif
1603
1604 If Used("tmpCstdr")
1605 Use In tmpCstdr
1606 Endif
1607 If Used("tmpUpcnr")
1608 Use In tmpUpcnr
1609 ENDIF
1610
1611 *- 1040686
1612 USE IN SELECT("tcCustUpc")
1613 USE IN SELECT("tmpCstdr_upc")
1614 USE IN SELECT("tcDistUpc")
1615 USE IN SELECT("tmpUpcnr")
1616 *- 1040686
1617
1618 Select(lnOldSelect)
1619 Return llRetVal
1620 Endproc
1621
1622 *----------------------------------------------------------------------------------
1623
1624 *--- TR 1035223 NH
1625 PROCEDURE ClearErrorsForSkipSlnCheck
1626 LPARAMETERS pceipoTH, pceipoTD, pceipoTS
1627
1628 LOCAL llRetVal, lnOldSelect
1629 lnOldSelect = SELECT()
1630 llRetVal = .t.
1631
1632 UPDATE td SET Style_SLN_OK = ' ' from (pceipoTD) td WHERE SkipSlnChk = "Y"
1633 UPDATE ts SET Errs_flg_s = ' ', Errs_msg_s = ' ' from (pceipoTS) ts WHERE SkipSlnChk = "Y"
1634
1635 *--- TR 1038353 NH
1636 UPDATE td SET Errs_flg_d = 'Y', Errs_msg_d = Errs_msg_d + 'Error in SLN' + CRLF FROM (pceipoTD) td WHERE Style_SLN_OK = 'N'
1637 *=== TR 1038353 NH
1638
1639 Select(lnOldSelect)
1640 Return llRetVal
1641 Endproc
1642
1643 *----------------------------------------------------------------------------------
1644
1645 PROCEDURE SetupSkipSLNCheck
1646 LPARAMETERS pceipoTH, pceipoTD, pceipoTS, pceipoCR
1647
1648 LOCAL lnOldSelect, llRetVal
1649 lnOldSelect = SELECT()
1650 llRetVal = .t.
1651 *--- take division from trans detail
1652 UPDATE td SET SkipSlnChk = r.SkipSlnChk ;
1653 from (pceipoTH) th inner join (pceipoTD) td on td.fkey = th.pkey ;
1654 inner join (pceipoCR) r on r.customer = th.customer AND r.division = td.division ;
1655 WHERE th.customer > '' AND td.division > ''
1656
1657 *--- Setup in pceipoTS
1658 UPDATE ts SET SkipSlnChk = td.SkipSlnChk ;
1659 FROM (pceipoTD) td inner join (pceipoTS) ts on ts.fkey = td.pkey
1660
1661 Select(lnOldSelect)
1662 Return llRetVal
1663
1664 Endproc
1665 *=== TR 1035223 NH
1666
1667 *----------------------------------------------------------------------------------
1668
1669 *--- TR 1023892 NH
1670 *--- zzeipotd.Cust_lbl is a actual field. So, any value that is set to this field will persist until the transaction is deleted.
1671 PROCEDURE Populate_Cust_lbl
1672 LPARAMETERS pcTransHeader, pcTransDetail
1673 LOCAL llRetVal, lnOldSelect, lcSQLString, lcFkeySku, lcCust_lbl, lcZzeipotd_order
1674 llRetVal = .t.
1675 lnOldSelect = SELECT()
1676 lcSQLString = ""
1677 lcFkeySku = ""
1678 lcCust_lbl = ""
1679
1680
1681 SELECT DISTINCT d.fkey, h.customer, d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION, d.orig_lbl ;
1682 FROM (pcTransHeader) h, (pcTransDetail) d ;
1683 WHERE h.pkey = d.fkey AND d.Errs_Flg_D= "N" AND d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
1684 and d.lbl_code = '' ;
1685 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
1686
1687 IF RECCOUNT("__TmpCursor") = 0
1688 *-- no valid style to process
1689 this.LogEntry("No detail record found to populate customer label.")
1690 SELECT(lnOldSelect)
1691 RETURN llRetVal
1692 ENDIF
1693
1694 WITH this
1695 .LogEntry("Number of detail records found for customer label resolution is : " + TRANSFORM(RECCOUNT("__TmpCursor")))
1696 .cSQLTempTable = ""
1697 llRetVal = llRetVal and .GenerateSQLTempTable('__TmpCursor')
1698 llRetVal = llRetVal and .PopulateSQLTempTable('__TmpCursor') and !EMPTY(.cSQLTempTable)
1699 lcCustSku = "#CustSku" + SYS(2015)
1700
1701 *--- TR 1031442 19-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
1702 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli added case when d.orig_lbl <> '' then d.orig_lbl ---
1703 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
1704 *--- Used sc.Division instead of c.Division.
1705 TEXT TO lcSQLString NOSHOW
1706 SELECT d.fkey, d.customer, d.division, d.style, d.color_code, d.DIMENSION, d.lbl_code,
1707 case when d.orig_lbl <> '' then d.orig_lbl
1708 when d.lbl_code = '' AND c.resv_label = 'Y' then c.lbl_code
1709 when d.lbl_code = '' and c.resv_label = 'V' and coalesce(sc.Active_ok,'') = 'Y' then c.lbl_code
1710 else d.lbl_code end as cust_lbl
1711 FROM #Temp d INNER JOIN zzeipocr_expl c on d.customer = c.customer and d.division = c.division
1712 LEFT OUTER JOIN zzxscolr sc on sc.division = d.division
1713 AND sc.style = d.style AND sc.color_code = d.color_code
1714 AND sc.lbl_code = c.lbl_code AND sc.dimension = d.dimension
1715 ENDTEXT
1716
1717 lcCustLbl = SYS(2015)
1718 lcSQLString = STRTRAN(lcSQLString,"#Temp",.cSQLTempTable)
1719 lcSQLString = STRTRAN(lcSQLString,"zzeipocr_expl",This.c850Control) && *--- TechRec 1030517 25-Aug-2010 jisingh ===
1720 llRetVal = llRetVal and v_SqlExec(lcSQLString, lcCustLbl)
1721 IF llRetVal
1722 *--- Now, populate tran detail cust_lbl field with resolved customer label.
1723 SELECT(pcTransDetail)
1724 lcZzeipotd_order = ORDER()
1725 SET ORDER TO fkeySku
1726 SELECT (lcCustLbl)
1727 SCAN
1728 lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1729 lcCust_lbl = Cust_lbl
1730 IF SEEK(lcFkeySku,pcTransDetail,'fkeySku')
1731 SELECT(pcTransDetail)
1732 SCAN WHILE lcFkeySku = STR(fkey) + division + style + color_code + lbl_code + dimension
1733 replace Cust_lbl WITH lcCust_lbl IN (pcTransDetail)
1734 ENDSCAN
1735 ENDIF
1736 ENDSCAN
1737 SELECT(pcTransDetail)
1738 SET ORDER TO (lcZzeipotd_order)
1739 ENDIF
1740 ENDWITH
1741 SELECT(lnOldSelect)
1742 RETURN llRetVal
1743 ENDPROC
1744
1745 *-----------------------------------------------------------------------------------
1746 *=== TR 1023892 NH
1747
1748 ************************************************************************************
1749 * Validate EAN for all details
1750 * Created on 03/24/04 - BD- TR 1003801
1751 ************************************************************************************
1752 Procedure CheckEAN
1753 Lparameters pceipoTH, pceipoTD,;
1754 pceipoTS, pceipoCR && *--- TechRec 1005163 17-May-2004 GS ---
1755 *--- TR 1061652 05/18/12 ATHIRUNAVU Added parameter pceipoCR
1756
1757 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
1758 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
1759 lnSize_desc, llSLN
1760 llRetVal = .T.
1761 lcErrs_Msg= ""
1762 lnOldSelect = Select()
1763
1764 *--- TR 1061652 05/18/12 ATHIRUNAVU
1765 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
1766 FROM (pceipocr) ;
1767 GROUP BY customer ;
1768 INTO CURSOR __ResvCustSKU
1769 *=== TR 1061652 05/18/12 ATHIRUNAVU
1770
1771 *- Check EAN only if customer is empty
1772 *--- TechRec 1005163 17-May-2004 GS ---
1773 *Select h.customer, d.ean, d.pkey From (pceipoTH) h, (pceipoTD) d ;
1774 * Where !Empty(d.ean) and h.pkey = d.fkey And !Empty(h.customer) And ;
1775 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
1776 *Order by h.customer, d.ean Into Cursor tmpCurs
1777
1778 *---- TR 1024667 NSD 5/31/07
1779 * If sizebucket = 0 then re-resolve.
1780
1781 If This.oHostProcess.lHaveSLN
1782 *--- TR 1061652 05/18/12 ATHIRUNAVU
1783 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1784 Select h.customer,;
1785 d.ean,;
1786 d.pkey, ;
1787 r.ResvCustSKU, ;
1788 (pceipoTD) As Src;
1789 FROM (pceipoTD) d ;
1790 JOIN (pceipoTH) h ;
1791 ON h.pkey = d.fkey ;
1792 JOIN __ResvCustSKU r ;
1793 ON r.Customer = H.Customer ;
1794 WHERE !Empty(d.ean) ;
1795 AND !Empty(h.customer) ;
1796 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1797 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1798 Union All ;
1799 SELECT h.customer,;
1800 s.SLN_EAN As ean,;
1801 s.pkey, ;
1802 r.ResvCustSKU, ;
1803 (pceipoTS) As Src;
1804 FROM (pceipoTD) d ;
1805 JOIN (pceipoTH) h ;
1806 ON h.pkey = d.fkey ;
1807 JOIN (pceipoTS) s ;
1808 ON s.fkey = d.pkey ;
1809 JOIN __ResvCustSKU r ;
1810 ON r.Customer = H.Customer ;
1811 WHERE !Empty(s.SLN_EAN) ;
1812 AND !Empty(h.customer) ;
1813 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
1814 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1815 ORDER By 1, 2 ;
1816 INTO Cursor tmpCurs
1817 Else
1818 *--- TR 1061652 05/18/12 ATHIRUNAVU
1819 *- Added r.ResvCustSKU to the list of fields and added Join for __ResvCustSKU
1820 Select h.customer,;
1821 d.ean,;
1822 d.pkey, ;
1823 r.ResvCustSKU, ;
1824 (pceipoTD) As Src;
1825 FROM (pceipoTD) d ;
1826 JOIN (pceipoTH) h ;
1827 ON h.pkey = d.fkey ;
1828 JOIN __ResvCustSKU r ;
1829 ON r.Customer = H.Customer ;
1830 WHERE !Empty(d.ean) ;
1831 AND !Empty(h.customer) ;
1832 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
1833 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
1834 Order By h.customer, d.ean ;
1835 INTO Cursor tmpCurs
1836 Endif
1837 *=== TechRec 1005163 17-May-2004 GS ===
1838
1839 lcOldCust = ""
1840 lcOldItem = ""
1841 Select tmpCurs
1842 If This.lUserInterface
1843 * Init Thermometer
1844 This.UpdateThermoCaption("Validating EAN(s)...")
1845 This.InitThermo(RecCount('tmpCurs'))
1846 l_nThermoCnt = 0
1847 Endif
1848 Scan
1849 If This.lUserInterface
1850 * Advance progress bar, if we're using one.
1851 l_nThermoCnt = l_nThermoCnt + 1
1852 This.AdvanceThermo(l_nThermoCnt)
1853 Endif
1854 If !(tmpCurs.customer == lcOldCust And tmpCurs.ean == lcOldItem)
1855 lcErrs_Msg = ""
1856 lcOldCust = tmpCurs.customer
1857 lcOldItem = tmpCurs.ean
1858 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
1859 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
1860
1861 If This.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
1862 lcDivision = tmpCstdr.division
1863 lcStyle = tmpCstdr.Style
1864 lcColor_code = tmpCstdr.color_code
1865 lcLbl_code = tmpCstdr.lbl_code
1866 lcDimension = tmpCstdr.Dimension
1867 lnSizeBucket = tmpCstdr.size_bk
1868 lnSize_desc = tmpCstdr.size_desc
1869 Else
1870
1871 *--- TR 1061652 05/18/12 ATHIRUNAVU
1872 IF ResvCustSKU <> 'Y'
1873 *=== TR 1061652 05/18/12 ATHIRUNAVU
1874
1875 lcErrs_Msg = ""
1876 If This.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
1877 lcDivision = tmpUpcnr.division
1878 lcStyle = tmpUpcnr.Style
1879 lcColor_code = tmpUpcnr.color_code
1880 lcLbl_code = tmpUpcnr.lbl_code
1881 lcDimension = tmpUpcnr.Dimension
1882 lnSizeBucket = tmpUpcnr.sizebucket
1883 lnSize_desc = tmpUpcnr.size_desc
1884 Else
1885 lcErrs_Msg = lcErrs_Msg + CRLF
1886 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1887 Store 0 To lnSizeBucket
1888 Endif
1889
1890 *--- TR 1061652 05/18/12 ATHIRUNAVU
1891 ELSE
1892 lcErrs_Msg = "EAN not found in the Customer Style Reference. " + CRLF
1893 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
1894 STORE 0 TO lnSizeBucket
1895 ENDIF
1896 *=== TR 1061652 05/18/12 ATHIRUNAVU
1897
1898 Endif
1899 Endif && level break
1900
1901 *--- TechRec 1005163 17-May-2004 GS ---
1902 *Select (pceipoTD)
1903 llSLN = (tmpCurs.Src = pceipoTS)
1904 If llSLN
1905 Select (pceipoTS)
1906 Else
1907 Select (pceipoTD)
1908 Endif
1909 *=== TechRec 1005163 17-May-2004 GS ===
1910
1911 *- 1010682 04/25/05 YIK
1912 *- Locate For pkey = tmpCurs.pkey
1913 lnWorkArea = Select()
1914 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
1915 Scatter Name loEiPOtd Memo
1916 If !Empty(lcErrs_Msg)
1917 *--- TechRec 1005163 17-May-2004 GS ---
1918 If llSLN
1919 loEiPOtd.Errs_Msg_S = Trim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
1920 loEiPOtd.Errs_Flg_S = "Y"
1921 Else
1922 *=== TechRec 1005163 17-May-2004 GS ===
1923 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
1924 loEiPOtd.Errs_Flg_D = "Y"
1925 Endif &&--- TechRec 1005163 17-May-2004 GS ===
1926 Endif
1927 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
1928 loEiPOtd.division = lcDivision
1929 loEiPOtd.Style = lcStyle
1930 loEiPOtd.color_code = lcColor_code
1931 loEiPOtd.lbl_code = lcLbl_code
1932 loEiPOtd.Dimension = lcDimension
1933 loEiPOtd.sizebucket = lnSizeBucket
1934 loEiPOtd.size_desc = lnSize_desc
1935 Endif
1936
1937 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
1938 * only replace our SKU when no range style explosion happen
1939 *--- TechRec 1005163 17-May-2004 GS ---
1940 *If empty(&pceipoTD..rng_style)
1941 * Replace division With loEiPOtd.division, ;
1942 * style With loEiPOtd.style, ;
1943 * color_code With loEiPOtd.color_code, ;
1944 * lbl_code With loEiPOtd.lbl_code, ;
1945 * dimension With loEiPOtd.dimension, ;
1946 * sizebucket With loEiPOtd.sizebucket, ;
1947 * size_desc With loEiPOtd.size_desc, ;
1948 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
1949 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
1950 * In (pceipoTD)
1951 *- 1009508 3/16/05 YIK
1952 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
1953 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style"))
1954
1955 Gather Name loEiPOtd Memo
1956 *=== TechRec 1005163 17-May-2004 GS ===
1957 Endif
1958 Endscan
1959 Use In tmpCurs
1960
1961 If This.lUserInterface
1962 * Reset Thermometer
1963 This.ResetThermo()
1964 Endif
1965
1966 If Used("tmpCstdr")
1967 Use In tmpCstdr
1968 Endif
1969 If Used("tmpUpcnr")
1970 Use In tmpUpcnr
1971 Endif
1972
1973 Select(lnOldSelect)
1974 Return llRetVal
1975 Endproc
1976
1977 *-----------------------------------------------------------------------------------
1978
1979 *--- 39222 5/1/03 YIK
1980 *- If both upc and sku have been sent by edi and style/color/lbl/dim/size were resolved by CheckUPC()
1981 *- Confirm that the sku set up for this style/color/lbl/dim/size combo
1982 *- matches the sku sent in transmission.
1983
1984 *--- TechRec 1005163 17-May-2004 GS:
1985 *- Combined ConfirmUPC and ConfirmEAN
1986
1987 Procedure ConfirmSku
1988 Lparameters pceipoTH, pceipoTD, pceipoCR,;
1989 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
1990
1991 *--- TechRec 1060764 30-May-2012 TShenbagavalli added lcWarnmsg---
1992 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcWarnMsg, ;
1993 lcSku, lcErrs_Msg, llSLN
1994
1995 LOCAL lcAux_Sku && TR 1061151 2-MAY-12 Venuk
1996 llRetVal = .T.
1997 lcErrs_Msg= ""
1998
1999 *--- TR 1085322 24-Sep-2015 Goutam
2000 LOCAL llCustStyleDupeCheck, llCustStyleFound,lcStyle, lcColor, lcLabel
2001 *=== TR 1085322 24-Sep-2015 Goutam
2002
2003 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2004 lcWarnMsg = ""
2005 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2006
2007 lnOldSelect = Select()
2008
2009 .LogEntry("Confirm that the resolved sku matches the sku sent in transmission.")
2010
2011 *- Process only those with both upc ans sku sent and after BC style was resolved by CheckUPC()
2012 *- and won't be processed by CheckSKU(), i.e. ! (Empty(d.division) or Empty(d.style) or Empty(d.color_code))
2013 *- 1003788 2/25/04 YIK
2014 *- use d.division, not h.division which is still empty
2015
2016 *--- TechRec 1005163 17-May-2004 GS ---
2017 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
2018
2019 *--- TechRec 1024522 25-Sep-2007 GSternik --- Added Style_SLN_OK
2020 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2021 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2022 *--- TR 1078000 16-4-2014 VKK Added cust_size
2023 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
2024 sizebucket, upc, ean, pkey, size_desc, rng_style, Style_SLN_OK, aux_sku, subclass , cust_size ;
2025 from (pceipoTD) Into Cursor __eipoTD
2026
2027 If This.oHostProcess.lHaveSLN
2028 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2029 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2030 *--- TR 1078000 16-4-2014 VKK Added cust_size
2031 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
2032 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc, aux_sku, subclass , cust_size From (pceipoTS) Into Cursor __EiPOts
2033 Endif
2034 *--- TR 1022625 -- This change is for optimizing the WITH loop below.
2035 *--- NH - 08/10/07
2036 If Reccount(pceipoTD) = 0 or Reccount(pceipoCR) = 0
2037 Select(lnOldSelect)
2038 RETURN llRetVal
2039 ENDIF
2040 *=== TR 1022625
2041
2042 With This
2043 .cSQLTempTable = ""
2044 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
2045 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
2046 lceipoTD_tmp = .cSQLTempTable
2047 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
2048
2049 If This.oHostProcess.lHaveSLN
2050 .cSQLTempTable = ""
2051 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
2052 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
2053 lceipoTS_tmp = .cSQLTempTable
2054 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
2055 Endif
2056 lcSQL = .GetConfrimSkuSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
2057 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpCursR")
2058 .LogEntry("Create Sku temporary table " + Iif(llRetVal, "successful.","failed."))
2059 ENDWITH
2060
2061
2062 This.MakeCursorWritable("tmpCursR","tmpCurs")
2063 *=== TR 1019697 NH
2064 *=== TechRec 1005163 17-May-2004 GS ===
2065
2066 *-FH 1103931 - Grab sql from GetConfrimSkuSql, lets make a temp table from it.
2067 LOCAL lcTemptbl
2068 lcTemptbl = SQLTableFromQuery(lcSQL)
2069 *-FH 1103931
2070
2071 *--- TR 1085322 24-Sep-2015 Goutam
2072 * FH 1103931 - Let's use lcTemptbl, instead of lceipoTD_tmp( lceipoTD_tmp is all of DTL, lcTemptbl will only be confirm sku)
2073 *- - also add distinct
2074 IF llRetVal AND !EMPTY(lcTemptbl)
2075 lcSql = "select distinct b.cust_style, b.division, b.style, b.color_code, b.lbl_code, b.dimension, b.size_bk " +;
2076 " from " + lcTemptbl + " a join zzxcstdr b " +;
2077 " on a.sku = b.cust_style"
2078
2079 llRetVal = llRetVal And v_SqlExec(lcSQL, "tmpBCSKUCurs")
2080 IF llRetVal
2081 SELECT tmpBCSKUCurs
2082 INDEX on cust_style+division+style+color_code+lbl_code+dimension+STR(size_bk) TAG cust_style
2083 SET ORDER TO
2084 ENDIF
2085 ENDIF
2086 *=== TR 1085322 24-Sep-2015 Goutam
2087
2088 .LogEntry("Begin Sku Comparison") && TR 1040686 Aug-04-09 BR
2089 Select tmpCurs
2090 If This.lUserInterface
2091 * Init Thermometer
2092 This.UpdateThermoCaption("Comparing SKU(s)...")
2093 This.InitThermo(RecCount('tmpCurs'))
2094 l_nThermoCnt = 0
2095 Endif
2096 *--- TR 1019697 NH : Now, lbl_code is properly set from customer label
2097 *--- We need to create BC Sku right here before any prepack implosion or Range Style explosion
2098 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
2099 *=== TR 1019697 NH
2100
2101 *-1040686
2102 *=-=-=-=-=-=-=-=-=-=
2103 SELECT DISTINCT customer,division,Style, color_code, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistCustSku
2104 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
2105 IF llRetVal
2106 .PopulateSQLTempTable("tcDistCustSku")
2107 ENDIF
2108 llRetVal = llRetVal AND v_sqlexec(;
2109 "SELECT x.customer,x.division,x.Style, x.color_code, x.lbl_code,x.DIMENSION, x.sizebucket, d.cust_style "+;
2110 " , d.aux_sku, d.pkey " +;
2111 " FROM zzxcstdr d"+ ;
2112 " JOIN " + this.cSQLTempTable + " x " + ;
2113 " ON d.customer = x.customer " +;
2114 " AND d.division = x.division " + ;
2115 " AND d.style = x.style " + ;
2116 " AND d.color_code = x.color_code " + ;
2117 " AND d.lbl_code = x.lbl_code " + ;
2118 " AND d.dimension = x.dimension " + ;
2119 " AND d.size_bk = x.sizebucket ","tmpCstdr")
2120 SELECT tmpCstdr
2121 INDEX ON customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
2122
2123 INDEX on cust_style TAG custsty && TR 1085322 KISHORE 22-SEP-2015
2124 *=-=-=-=-=-=-=-=-=-=
2125
2126 * TR 1085322 KISHORE 12-MAR-2015
2127 llCustStyleDupeCheck = (goEnv.sv("CUST_STYLE_DUPE_CHECK","N") = "Y")
2128
2129 SELECT tmpCurs
2130 *- 1040686
2131
2132
2133 Local lnSizeBk
2134 lnSizeBk = 0
2135 Scan
2136 llCustStyleFound = false &&*--- TR 1085322 24-Sep-2015 Goutam
2137
2138 If This.lUserInterface
2139 * Advance progress bar, if we're using one.
2140 l_nThermoCnt = l_nThermoCnt + 1
2141 This.AdvanceThermo(l_nThermoCnt)
2142 Endif
2143 *--- TechRec 1005163 17-May-2004 GS, YK fix ---
2144 lcErrs_Msg = ""
2145 *=== TechRec 1005163 17-May-2004 GS, YK ===
2146
2147 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2148 lcWarnMsg = ""
2149 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2150
2151 *-1040686
2152 *=-=-=-=-=-=-=-=-=-
2153 *lcSku = This.GetSKU(@lcErrs_Msg, customer, division, Style, color_code, lbl_code, ;
2154 DIMENSION, sizebucket, "tmpCstdr")
2155 lcSku = ""
2156 IF SEEK(customer+division+Style+color_code+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
2157 lcSku = tmpCstdr.cust_style
2158 ELSE
2159 lcErrs_Msg = "Missing SKU code."
2160 ENDIF
2161 *=-=-=-=-=-=-=-=-=-
2162 *-1040686
2163
2164 *--- TR 1085322 24-Sep-2015 Goutam.
2165 *Note: Cust_sku must be unique in zzxcstdr if the system parameter CUST_STYLE_DUPE_CHECK = ‘Y’
2166 IF SEEK(tmpCurs.sku, "tmpBCSKUCurs", "cust_style")
2167 lcStyle = ALLTRIM(tmpBCSKUCurs.style)
2168 lcColor = ALLTRIM(tmpBCSKUCurs.color_code)
2169 lcLabel = ALLTRIM(tmpBCSKUCurs.lbl_code)
2170 IF llCustStyleDupeCheck AND !SEEK(tmpCurs.sku+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpBCSKUCurs", "cust_style")
2171 lcErrs_Msg = "Customer Style " + ALLTRIM(tmpCurs.sku) + " already exists for Style " + lcstyle + ", Color " + lcColor + " and label " + lcLabel
2172 llCustStyleFound = true
2173 ENDIF
2174 *--- TR 1095258 04/28/16 ATHIRUNAVU Added tmpcurs.customer
2175 *IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2176 IF !llCustStyleDupeCheck AND !SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.dimension+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku")
2177 Replace AddCustSKU With .T. In (tmpCurs.Src)
2178 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2179 llCustStyleFound = true
2180 ENDIF
2181 ENDIF
2182 *=== TR 1085322 24-Sep-2015 Goutam
2183
2184 lcAux_Sku = tmpCstdr.aux_sku && TR 1061151 2-MAY-12 Venuk.
2185 *--- TechRec 1005163 24-Jun-2004 GS --- No error if Customer SKU will be generated later :
2186
2187 IF !llCustStyleFound &&*--- TR 1085322 24-Sep-2015 Goutam
2188 If !(lcSku == tmpCurs.sku)
2189
2190 * TR 1085322 KISHORE 12-MAR-2015 added OR Upd_CustSku = 'Y'
2191 If (Empty(lcSku) And GenCustSKU = 'Y') OR Upd_CustSku = 'Y'
2192 = Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
2193 *--- TR 1085322 24-Sep-2015 Goutam
2194 IF Upd_CustSku = 'Y'
2195 IF SEEK(tmpCurs.customer+tmpCurs.division+tmpCurs.Style+tmpCurs.color_code+tmpCurs.lbl_code+tmpCurs.DIMENSION+STR(tmpCurs.sizebucket), "tmpCstdr", "cust_sku") ;
2196 AND (tmpCurs.SKU <> tmpCstdr.cust_style)
2197
2198 lcSQL = "Update zzxcstdr set cust_style = " + SQLFormatChar(tmpCurs.sku) + ;
2199 ", last_mod = " + SQLFormatTs(DATETIME()) + ", user_id = " + SQLFormatChar(EDI_USER) + ;
2200 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2201 llRetVal = llRetVal And v_SqlExec(lcSQL)
2202 ENDIF
2203 ELSE
2204 *=== TR 1085322 24-Sep-2015 Goutam
2205 Replace AddCustSKU With .T. In (tmpCurs.Src)
2206 Replace AddCustSKU With 'Y' In tmpCurs && TR 1019697 NH
2207
2208 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2209 lcErrs_Msg = ""
2210 Else
2211 If Confirm_SKU = 'Y'
2212 lcErrs_Msg = "Invalid or missing Sku in Customer Style reference." + CRLF
2213 Else
2214 lcErrs_Msg = "Customer Sku already defined in Customer Style reference for a different BC Style." +;
2215 CRLF + "Unable to generate new customer Sku." + CRLF
2216 Endif
2217 ENDIF
2218 *--- TR 1061151 2-MAY-12 Venuk.
2219 Else
2220 If empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku)
2221 lcSQL = "Update zzxcstdr set aux_sku = " + SQLFormatChar(tmpCurs.aux_sku) + ;
2222 " where pkey = " + SQLFormatNum(tmpCstdr.pkey)
2223 v_SqlExec(lcSQL)
2224 *--- TechRec 1060764 30-May-2012 TShenbagavalli ---
2225 ELSE
2226 IF !empty(lcaux_sku) AND !EMPTY(tmpCurs.aux_sku) AND (lcaux_sku <> tmpCurs.aux_sku)
2227 lcWarnMsg = "Aux sku already exist."
2228 ENDIF
2229 *=== TechRec 1060764 30-May-2012 TShenbagavalli ===
2230 ENDIF
2231 *=== TR 1061151 2-MAY-12 Venuk.
2232 Endif
2233
2234 ENDIF &&*--- TR 1085322 24-Sep-2015 Goutam
2235
2236 *--- TechRec 1005163 17-May-2004 GS ---
2237 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey") AND !Empty(lcErrs_Msg)
2238 * Replace ;
2239 * Errs_Msg_D With Alltrim(&pceipoTD..Errs_Msg_D) + lcErrs_Msg, ;
2240 * Errs_Flg_D With "Y" ;
2241 * In (pceipoTD)
2242
2243 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli added OR !EMPTY(lcWarnMsg) in condition ---
2244 If !Empty(lcErrs_Msg) OR !EMPTY(lcWarnMsg)
2245 llSLN = (tmpCurs.Src = pceipoTS)
2246 If llSLN
2247 Select (pceipoTS)
2248 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
2249 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2250 IF !EMPTY(lcErrs_Msg)
2251 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2252 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y' &&--- TR 1035223 NH
2253 Replace ;
2254 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
2255 Errs_Flg_S With "Y"
2256 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
2257 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
2258 Errs_Flg_D With 'Y' In (pceipoTD)
2259 Endif
2260 ENDIF
2261 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2262 ELSE
2263 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2264 Warn_Flg_D With "Y" In (pceipoTD)
2265 ENDIF
2266 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2267 Else
2268 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
2269 Select (pceipoTD)
2270 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2271 IF !EMPTY(lcErrs_Msg)
2272 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2273 Replace ;
2274 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
2275 Errs_Flg_D With "Y"
2276 *--- TechRec 1060764 19-Jul-2012 TShenbagavalli ---
2277 ELSE
2278 Replace Warn_Msg_D With Warn_Msg_D + lcWarnMsg + CRLF, ;
2279 Warn_Flg_D With "Y"
2280 ENDIF
2281 *=== TechRec 1060764 19-Jul-2012 TShenbagavalli ===
2282 Endif
2283 *=== TechRec 1005163 17-May-2004 GS ===
2284 Endif
2285 ENDSCAN
2286 .LogEntry("Sku Comparison. Complete") && TR 1040686 Aug-04-09 BR
2287 *--- TR 1019697 NH :
2288 llRetVal = llRetVal And .GenerateCustomerSkuFromCursor("tmpCurs")
2289 *=== TR 1019697 NH
2290 Use In tmpCurs
2291
2292 If This.lUserInterface
2293 * Reset Thermometer
2294 This.ResetThermo()
2295 Endif
2296
2297 If Used("tmpCstdr")
2298 Use In tmpCstdr
2299 ENDIF
2300
2301 *--- TR 1085322 24-Sep-2015 Goutam
2302 USE IN SELECT("tmpBCSKUCurs")
2303 *=== TR 1085322 24-Sep-2015 Goutam
2304
2305 USE IN SELECT("tcDistCustSku") && TR 1040686 Aug-04-09 BR
2306
2307 Select(lnOldSelect)
2308 Return llRetVal
2309 Endproc
2310
2311 *-----------------------------------------------------------------------------------
2312
2313 *--- TR 1019697 NH
2314 **************************************************************************************
2315 Procedure GetConfrimSkuSql
2316 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
2317 Local lcSQL, lcSqlSln, lnOldSelect
2318 lnOldSelect = Select()
2319
2320 *--- TechRec 1024522 20-Sep-2007 GS/YIK --- considered flag Style_SLN_OK
2321 *--- TR 1031442 17-Jun-2008 Goutam. Changed zzeipocr_expl from zzeipocr in the following sql
2322
2323 *- 1037868 04/01/09 FGCjr fix LEFT OUTER JOIN for zzxscolr, alias should be sc. for division
2324 *--- TechRec 1043592 22-Dec-2009 JK Added d.aux_sku ====
2325 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2326 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2327 *--- TR 1078000 16-4-2014 VKK Added cust_size
2328 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2329 lcSQL = ;
2330 "select d.customer"+;
2331 " , d.division"+;
2332 " , d.sku"+;
2333 " , d.STYLE"+;
2334 " , d.color_code"+;
2335 " , case"+;
2336 " when r.rng_style is null"+;
2337 " and d.lbl_code = ''"+;
2338 " and c.resv_label = 'Y' then c.lbl_code"+;
2339 " when r.rng_style is null"+;
2340 " and d.lbl_code = ''"+;
2341 " and c.resv_label = 'V'"+;
2342 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
2343 " else d.lbl_code"+;
2344 " end as lbl_code"+;
2345 " , d.lbl_code as lbl_codeOrig"+;
2346 " , c.resv_label"+;
2347 " , d.DIMENSION"+;
2348 " , d.Sizebucket"+;
2349 " , d.upc"+;
2350 " , d.pkey"+;
2351 " , C.GenCustSKU"+;
2352 " , C.Confirm_SKU"+;
2353 " , C.upd_custsku " + ;
2354 " , 'N' as AddCustSKU"+;
2355 " , d.size_desc"+;
2356 " , '" + Trim(pceipoTD) + "' as Src"+;
2357 " , d.aux_sku " + ;
2358 " , d.subclass " + ;
2359 " , d.cust_size " + ;
2360 " from " + pceipoTD_tmp + " d"+;
2361 " join " + This.c850Control + " C"+;
2362 " on d.customer = C.customer"+;
2363 " and d.division = C.division"+;
2364 " left join zzxrangh r"+;
2365 " on r.division = d.division"+;
2366 " and r.rng_style = d.style"+;
2367 " and r.rng_color = d.color_code"+;
2368 " and r.rng_lbl = d.lbl_code"+;
2369 " and r.rng_pack = d.dimension"+;
2370 " left join zzxscolr sc"+;
2371 " on sc.division = d.division"+;
2372 " and sc.style = d.style"+;
2373 " and sc.color_code = d.color_code"+;
2374 " and sc.lbl_code = c.lbl_code"+;
2375 " and sc.dimension = d.dimension"+;
2376 " where d.customer > ''"+;
2377 " and d.SKU > ''"+;
2378 " and (d.UPC > '' or d.EAN > '' or Style_SLN_OK = 'Y')"+;
2379 " and d.Division > ''"+;
2380 " and d.Style > ''"+;
2381 " and d.Color_Code > ''"+;
2382 " and (C.Confirm_SKU = 'Y' or C.GenCustSKU = 'Y')"+;
2383 " and d.Rng_Style = '' "
2384
2385 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
2386 *--- TechRec 1043592 22-Dec-2009 JK Added s.aux_sku ====
2387 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
2388 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
2389 *--- Used sc.Division instead of c.Division.
2390 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2391 *--- TR 1078000 16-4-2014 VKK Added cust_size
2392 * TR 1085322 KISHORE 12-MAR-2015 added upd_custsku
2393 lcSqlSln = ;
2394 "select d.Customer"+;
2395 " , d.Division"+;
2396 " , s.SLN_SKU as sku"+;
2397 " , s.STYLE"+;
2398 " , s.Color_Code"+;
2399 " , case when s.Lbl_Code = ''"+;
2400 " and c.Resv_Label = 'Y' then c.lbl_code"+;
2401 " when s.Lbl_Code = ''"+;
2402 " and c.Resv_Label = 'V'"+;
2403 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
2404 " else s.lbl_code"+;
2405 " end as lbl_code"+;
2406 " , s.lbl_code as lbl_codeOrig"+;
2407 " , c.resv_label"+;
2408 " , s.DIMENSION"+;
2409 " , s.Sizebucket"+;
2410 " , s.SLN_UPC as upc"+;
2411 " , s.pkey"+;
2412 " , C.GenCustSKU"+;
2413 " , C.Confirm_SKU"+;
2414 " , C.upd_custsku " + ;
2415 " , 'N' as AddCustSKU"+;
2416 " , s.size_desc"+;
2417 " , '" + Trim(pceipoTS) + "' as Src"+;
2418 " , s.aux_sku " + ;
2419 " , s.subclass " + ;
2420 " , s.cust_size " + ;
2421 " from " + pceipoTD_tmp + " d"+;
2422 " join " + pceipoTS_tmp + " s"+;
2423 " on s.fkey = d.pkey"+;
2424 " join " + This.c850Control + " C"+;
2425 " on d.customer = C.customer"+;
2426 " and d.division = C.division"+;
2427 " left join zzxscolr sc"+;
2428 " on sc.division = d.division"+;
2429 " and sc.style = s.style"+;
2430 " and sc.color_code = s.color_code"+;
2431 " and sc.lbl_code = c.lbl_code"+;
2432 " and sc.dimension = s.dimension"+;
2433 " where d.Customer > ''"+;
2434 " and s.SLN_SKU > ''"+;
2435 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
2436 " and d.Division > ''"+;
2437 " and s.Style > ''"+;
2438 " and s.Color_Code > ''"+;
2439 " and (c.Confirm_SKU = 'Y' or c.GenCustSKU = 'Y')"+;
2440 " and d.rng_style = '' " && TR 1038090 FEB-02-2009 BR - Changed to rng_style = '' - No Range_style value at this point.
2441 Endif
2442
2443 lcSQL = lcSQL + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
2444 Select(lnOldSelect)
2445 Return lcSQL
2446 Endproc
2447
2448 *-----------------------------------------------------------------------------------
2449
2450 Procedure CreateOurSkuFromTmpCurs
2451 If Not Used("TmpCurs")
2452 Return .F.
2453 Endif
2454 Local llRetVal, lnOldSelect, lcOurSKU,lcSKu
2455 llRetVal = .T.
2456 lnOldSelect = Select()
2457 With This
2458 Select tmpCurs
2459 .oLog.LogEntry("Creating Our Sku From TmpCurs") && TR 1040686 Aug-04-09 BR
2460
2461 LOCAL lcDistSku,lcExistingSku,lcCustLbl
2462 lcDistSku = Getuniquefilename()
2463 lcExistingSku = Getuniquefilename()
2464 lcCustLbl = Getuniquefilename()
2465
2466 *-FH 1066967 - need a temp cursor that will hold the added styles we added in this 850 run
2467 *- WE need to add this because below we are going to add customer to the distinct to lcDistSku
2468 *- We need this because cursor lcCustLbl has customer field.
2469 *- 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
2470 *- with auto_style = 'Y', we will add both auto_style twice.
2471
2472 *- The reason why we didn't have this issue before 1040686 optimization was because we call AuthorizeAutoCreateStyle for every record
2473 *- so for the case above after we added the first style for the first customer, calling AuthorizeAutoCreateStyle for the second time will fail
2474 *- because style exists in zzxscolr (we just addeded)
2475 *- when We optimized it we created lcExistingSku to find out which styles we have already have. This lcExistingSku doesn't get updated
2476 *- so we will add it twice by accident.
2477
2478 SELECT division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE 1=0 INTO CURSOR lcStyleAdded READWRITE
2479 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2480 *-FH 1066967
2481
2482
2483 *-FH 1066967 - added customer
2484 SELECT DISTINCT Customer, division,style,color_code,lbl_code,dimension FROM tmpCurs WHERE NOT EMPTY(lbl_code) INTO CURSOR(lcDistSku)
2485 llRetVal = llRetVal AND .GenerateSQLTempTable(lcDistSku)
2486 IF llRetVal
2487 .PopulateSQLTempTable(lcDistSku)
2488 ENDIF
2489
2490 llRetVal = llRetVal AND v_sqlexec(;
2491 "SELECT x.* "+;
2492 " FROM zzxscolr d"+ ;
2493 " JOIN " + this.cSQLTempTable + " x " + ;
2494 " ON d.division = x.division " +;
2495 " AND d.style = x.style " + ;
2496 " AND d.color_code = x.color_code " + ;
2497 " AND d.lbl_code = x.lbl_code " + ;
2498 " AND d.dimension = x.dimension " ,lcExistingSku )
2499 SELECT (lcExistingSku)
2500 INDEX on division+style+color_code+lbl_code+dimension TAG sku
2501
2502 IF llRetVal
2503 v_sqlexecnoerror("DROP TABLE " + this.cSQLTempTable)
2504 ENDIF
2505
2506 *-FH 1066967 prior to the change we only do it auto_style = 'Y'
2507 *llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr",lcCustLbl)
2508 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzxclblr where auto_style = 'Y'",lcCustLbl)
2509 SELECT(lcCustLbl)
2510 INDEX on customer + lbl_code TAG cust_lbl
2511
2512 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2513 SELECT (lcDistSku) && FH 1066967
2514 Scan
2515 lcOurSKU= &lcDistSku..division + "/" + &lcDistSku..Style + "/" + ;
2516 &lcDistSku..color_code + "/" + &lcDistSku..lbl_code+ "/" + &lcDistSku..Dimension
2517 lcSKu = &lcDistSku..division + &lcDistSku..Style + &lcDistSku..color_code + &lcDistSku..lbl_code + &lcDistSku..Dimension
2518*!* If .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
2519*!* tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
2520*!* If .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.Style, tmpCurs.color_code,;
2521*!* tmpCurs.lbl_code, tmpCurs.Dimension)
2522*!* .oLog.LogEntry("Created style: " + lcOurSKU )
2523*!* Else
2524*!* .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2525*!* Endif
2526*!* ENDIF
2527
2528 IF NOT EMPTY(&lcDistSku..lbl_code)
2529 IF NOT SEEK(lcSKu,lcExistingSku,"sku") AND NOT SEEK(lcSKu, "lcStyleAdded", "sku") &&FH 1066967 added check for already added styles
2530 IF SEEK(&lcDistSku..customer+&lcDistSku..lbl_code,lcCustLbl,"cust_lbl") OR SEEK(" " + &lcDistSku..lbl_code,lcCustLbl,"cust_lbl")
2531 If .oBPOSalesOrder.AutoCreateStyle(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2532 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2533
2534 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2535 Insert INTO lcStyleAdded Values(&lcDistSku..division, &lcDistSku..Style, &lcDistSku..color_code,;
2536 &lcDistSku..lbl_code, &lcDistSku..Dimension)
2537 *-FH 1066967 - add records into lcStyleAdded when we adde it.
2538
2539 .oLog.LogEntry("Created style: " + lcOurSKU )
2540 Else
2541 .oLog.LogWarning("Unable to create style: " + lcOurSKU )
2542 ENDIF
2543 ENDIF
2544 Endif
2545 ENDIF
2546
2547 ENDSCAN
2548 *-FH 1066967 - replace all tmpCurs to &lcDistSku..
2549
2550 USE IN SELECT(lcDistSku)
2551 USE IN SELECT(lcExistingSku)
2552 USE IN SELECT(lcCustLbl)
2553
2554 USE IN SELECT('lcStyleAdded') && FH 1066967
2555
2556 .oLog.LogEntry("Creating Our Sku From TmpCurs.Complete") && TR 1040686 Aug-04-09 BR
2557 Endwith
2558 Select (lnOldSelect)
2559 Return llRetVal
2560 Endproc
2561
2562 *-----------------------------------------------------------------------------------
2563
2564 Procedure GenerateCustomerSkuFromCursor
2565 Parameters tcSkuCursor
2566 Local lnOldSelect, llRetVal
2567 llRetVal = .T.
2568 lnOldSelect = Select()
2569
2570 Local lcOldOrder, lcSkuIpotd, lcPrevSkuIpotd
2571 lcPrevSkuIpotd = ""
2572 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2573 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2574 *--- TR 1078000 16-4-2014 VKK Added cust_size
2575 Select Distinct customer, division, Style, color_code, lbl_code, Dimension, sizebucket As size_bk, ;
2576 size_desc, sku As Cust_style, lbl_codeorig, Src, aux_sku, subclass, cust_size From (tcSkuCursor) ;
2577 WHERE AddCustSKU = 'Y' ORDER BY 1,2,3,4,5,6,7 Into Cursor tmpCurs1 && TR 1059834 FH - added Order by
2578 *WHERE AddCustSKU = .T. INTO CURSOR tmpCurs1
2579
2580 With This
2581 lnCount = Reccount("tmpCurs1")
2582
2583 If lnCount = 0
2584 Select (lnOldSelect)
2585 Return
2586 Endif
2587
2588 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2589 Select (lnOldSelect)
2590 Return
2591 Endif
2592
2593 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2594 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2595 lnCount = lnCount - 1
2596 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2597 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2598
2599 Select VZZXCSTHR
2600 Scatter Memvar Blank
2601 Select VZZXCSTDR
2602 Scatter Memvar Blank
2603
2604 m.Last_mod = Datetime()
2605 m.User_id = 'CGSADMIN'
2606 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2607
2608 * --- TR 1039603 4/6/09 CM
2609 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
2610 m.active_ok = 'Y'
2611 m.anti_theft = 'N'
2612 * === TR 1039603 4/6/09 CM
2613
2614 m.notes = ''
2615
2616 lcPrevSKU = ' '
2617
2618 Create Cursor tmpCursSrc ( Src C(20), oldOrder C(20))
2619 Insert Into tmpCursSrc Select Distinct Src, '' As oldOrder From tmpCurs1
2620 Select("tmpCursSrc")
2621 .oLog.LogEntry("Begin Old Order Scan") && TR 1040686 Aug-04-09 BR
2622 Scan
2623 Select (Alltrim(tmpCursSrc.Src))
2624 lcOldOrder = Order()
2625 Set Order To CstBcSku
2626 Replace oldOrder With lcOldOrder In tmpCursSrc
2627 ENDSCAN
2628 .oLog.LogEntry("Old Order Scan. Complete") && TR 1040686 Aug-04-09 BR
2629
2630 Select tmpCurs1
2631 .oLog.LogEntry("Begin Scan to Clear AddCutstSku for matching detail rows") && TR 1040686 Aug-04-09 BR
2632 Scan
2633 *--- TechRec 1043592 22-Dec-2009 JK Added aux_sku ====
2634 *--- TR 1053171 6-APR-11 VENUK Added subclass ===
2635 *--- TR 1078000 16-4-2014 VKK Added cust_size
2636 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2637 DIMENSION, size_bk, size_desc, Cust_style, lbl_codeorig, aux_sku, subclass , cust_size
2638 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2639 lcSkuIpotd = m.customer+ m.division+ m.style + m.color_code+ m.lbl_codeorig+ m.dimension+Str(m.size_bk)
2640 If lcPrevSKU # lcSku
2641 lcPrevSKU = lcSku
2642 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2643 If Empty(lnHDRpKey)
2644 lnHDRpKey = lnCstHrPkey
2645 Insert Into VZZXCSTHR From Memvar
2646 Replace pkey With lnHDRpKey In VZZXCSTHR
2647 Endif
2648 Endif
2649 *--- clear AddCustSKU for all matching rows in zzeipotd
2650 Select (tmpCurs1.Src)
2651 If lcPrevSkuIpotd # lcSkuIpotd And Seek(lcSkuIpotd,tmpCurs1.Src,"CstBcSku")
2652 Scan While customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) = lcSkuIpotd
2653 Replace AddCustSKU With .F. In (tmpCurs1.Src)
2654 Endscan
2655 lcPrevSkuIpotd = lcSkuIpotd
2656
2657 *-TR 1059834 FH -moved in IF statement
2658 Select tmpCurs1
2659 Insert Into VZZXCSTDR From Memvar
2660 Replace pkey With lnCstDrPkey, fkey With lnHDRpKey In VZZXCSTDR
2661 lnCstDrPkey = lnCstDrPkey +1
2662 lnCstHrPkey = lnCstHrPkey +1
2663 *-TR 1059834 FH -moved in IF statement
2664
2665 Endif
2666 ENDSCAN
2667 .oLog.LogEntry("Scan to Clear AddCutstSku for matching detail rows.Complete") && TR 1040686 Aug-04-09 BR
2668 Select("tmpCursSrc")
2669 .oLog.LogEntry("Begin Scan to restore Cursor Order") && TR 1040686 Aug-04-09 BR
2670 Scan
2671 Select (Alltrim(tmpCursSrc.Src))
2672 lcOldOrder = Alltrim(tmpCursSrc.oldOrder)
2673* If Not Empty(lcOldOrder)
2674 Set Order To (lcOldOrder)
2675* Endif
2676 ENDSCAN
2677 .oLog.LogEntry("Scan to restore Cursor Order.Complete") && TR 1040686 Aug-04-09 BR
2678 Use In tmpCursSrc
2679
2680 Dimension laTables[2]
2681 laTables[1]= "VZZXCSTHR"
2682 laTables[2]= "VZZXCSTDR"
2683
2684 llBeganTransaction = .BeginTransaction()
2685 llRetVal = .Tableupdate(@laTables)
2686
2687 If llRetVal
2688 If llBeganTransaction
2689 This.EndTransaction()
2690 Endif
2691 Else
2692 If llBeganTransaction
2693 This.RollbackTransaction()
2694 Endif
2695 Endif
2696 Endwith
2697 If Used("tmpCurs1")
2698 Use In tmpCurs1
2699 Endif
2700 Select(lnOldSelect)
2701 Return llRetVal
2702 Endproc
2703
2704 *-----------------------------------------------------------------------------------
2705 *--- TechRec 1019260 24-Oct-2006 vkrishnamurthy ---
2706
2707 Function GenerateRBACustSKU
2708 Lparameters pceipoTH,pceipoTD
2709
2710 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
2711 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey ,lcRBADivision
2712
2713
2714 llRetVal = True
2715 lnSelect = Select()
2716 lcRBADivision = 'TFG'
2717 With This
2718
2719 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
2720
2721 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
2722 *- 12/12/06 YIK
2723 *- No distinct since includes pkey. Change order.
2724 *-- SELECT DISTINCT ;
2725 *-- h.customer,;
2726 *-- lcRBADivision as division,;
2727 *-- d.pkey as dtlpkey ,;
2728 *-- .GetBCStyle(lcRBADivision,d.style) as style,;
2729 *-- d.color_code,;
2730 *-- .GetCustLabel(h.customer) as lbl_code,;
2731 *-- "" as DIMENSION,;
2732 *-- h.store as cust_store ,;
2733 *-- d.sku as cust_style ,;
2734 *-- d.price as cust_price , ;
2735 *-- d.size_desc, ;
2736 *-- 0 as size_bk ;
2737 *-- FROM (pceipoTH) h ;
2738 *-- JOIN (pceipoTD) d ;
2739 *-- ON d.fkey = h.pkey ;
2740 *-- INTO CURSOR __tmpCur ;
2741 *-- ORDER BY 1,2,3,4,5,6
2742
2743 *** Size_BK needs to be 00 and NOT 0
2744 Select ;
2745 h.customer,;
2746 lcRBADivision As division,;
2747 d.pkey As dtlpkey ,;
2748 d.Style As Style, ;
2749 d.color_code,;
2750 .GetCustLabel(h.customer) As lbl_code,;
2751 "" As Dimension,;
2752 h.Store As cust_store ,;
2753 d.sku As Cust_style ,;
2754 d.price As cust_price , ;
2755 d.size_desc, ;
2756 00 As size_bk ;
2757 FROM (pceipoTH) h ;
2758 JOIN (pceipoTD) d ;
2759 ON d.fkey = h.pkey ;
2760 WHERE h.Errs_flg_h < 'Y' And ;
2761 d.Errs_Flg_D < 'Y' ;
2762 INTO Cursor __tmpCur ;
2763 ORDER By 1,2,4,5,6,7, 11
2764 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
2765
2766 This.MakeCursorWritable("__tmpCur", "tmpCurs")
2767
2768 lnCount = Reccount("tmpCurs")
2769
2770 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
2771
2772 If lnCount = 0
2773 If Used("tmpCurs")
2774 Use In tmpCurs
2775 Endif
2776 Select (lnSelect)
2777 Return
2778 Endif
2779
2780 Select tmpCurs
2781 *
2782 * Make it a loop for safety
2783 *
2784 Scan
2785 *** .LogEntry("Original Style " + style)
2786 lcStyle = .GetBCStyle(lcRBADivision,Style)
2787 *** .LogEntry("Resolved Style " + lcStyle)
2788 lnSize_BK = .GetSizeBkt(division,,, lcStyle , color_code,lbl_code,'',size_desc)
2789 Replace Style With lcStyle , size_bk With lnSize_BK
2790 Endscan
2791 .LogEntry("Resolved Styles/Size_BK")
2792
2793 *- 12/12/06 YIK
2794 *- Index just in case somebody changes the SELECT above
2795 Select tmpCurs
2796 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
2797 TAG sku
2798
2799 .LogEntry("Load Customer Style.")
2800
2801 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
2802 If Used("tmpCurs")
2803 Use In tmpCurs
2804 Endif
2805 Select (lnSelect)
2806 Return
2807 Endif
2808
2809 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
2810 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
2811 lnCount = lnCount - 1
2812 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
2813 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
2814
2815 Select VZZXCSTHR
2816 Scatter Memvar Blank
2817 Select VZZXCSTDR
2818 Scatter Memvar Blank
2819
2820 m.Last_mod = Datetime()
2821 m.User_id = 'CGSADMIN'
2822 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
2823 m.notes = ''
2824
2825 lcPrevSKU = ' '
2826 lcPrevSkuSize = ''
2827
2828 *- 12/12/06 YIK
2829 *- inserted details counter
2830 Local lnInsertCount
2831 lnInsertCount = 0
2832
2833 Select tmpCurs
2834
2835 Scan
2836 .LogEntry("Loading Customer Style...")
2837 .LogEntry("Style :" + Style )
2838 .LogEntry("Color_code :" + color_code )
2839
2840 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(lcRBADivision, "", ,Style) Or Empty(size_bk)
2841 .LogEntry("Invalid Style or Color_code or Size_bk " )
2842 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
2843 FOR pkey = dtlpkey In (pceipoTD)
2844 Loop
2845 Endif
2846
2847 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
2848 DIMENSION, size_bk, size_desc, Cust_style,cust_price ,cust_store
2849 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ m.dimension
2850 If lcPrevSKU # lcSku
2851 lcPrevSKU = lcSku
2852 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
2853 .LogEntry("Customer :" + m.customer )
2854 .LogEntry("Division : " + m.division)
2855 .LogEntry("Style :" + Style )
2856 .LogEntry("Color_code :" + m.color_code )
2857 .LogEntry("Label code :" + m.lbl_code )
2858 .LogEntry("dimension : " + m.dimension)
2859 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
2860 lnHDRpKey = vl_CStyR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension)
2861 If Empty(lnHDRpKey)
2862 lnHDRpKey = lnCstHrPkey
2863 .LogEntry("Inserting into header..")
2864 Insert Into VZZXCSTHR From Memvar
2865 Replace pkey With lnHDRpKey In VZZXCSTHR
2866 Endif
2867 Endif
2868 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
2869 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
2870 lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
2871 If Empty(lnDtlKey)
2872 lnDtlpKey = lnCstDrPkey
2873 .LogEntry("Inserting into detail..")
2874 Insert Into VZZXCSTDR From Memvar
2875 Replace pkey With lnDtlpKey,fkey With lnHDRpKey In VZZXCSTDR
2876 *- 12/12/06 YIK
2877 lnInsertCount = lnInsertCount + 1
2878 Endif
2879 Endif
2880 lnCstDrPkey = lnCstDrPkey +1
2881 lnCstHrPkey = lnCstHrPkey +1
2882
2883 Endscan
2884
2885 Dimension laTables[2]
2886 laTables[1]= "VZZXCSTHR"
2887 laTables[2]= "VZZXCSTDR"
2888
2889 llBeganTransaction = .BeginTransaction()
2890 llRetVal = .Tableupdate(@laTables)
2891
2892 If llRetVal
2893 If llBeganTransaction
2894 This.EndTransaction()
2895 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
2896 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
2897 Endif
2898 Else
2899 If llBeganTransaction
2900 This.RollbackTransaction()
2901 .LogEntry("Table Update failed - Roll back Transaction " )
2902 Endif
2903 Endif
2904
2905 Endwith
2906
2907 If Used("tmpCurs")
2908 Use In tmpCurs
2909 Endif
2910
2911 Select (lnSelect)
2912 Return llRetVal
2913 Endfunc
2914
2915 *-----------------------------------------------------------------------------------
2916
2917 Function GetBCStyle
2918 Lparameters tcDivision, tcUDFStyle
2919 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
2920
2921 llRetVal = True
2922 lnSelect = Select()
2923 l_vRetVal = ''
2924
2925 lcCursor = GetUniqueFileName()
2926 l_cSQLString = "SELECT Style FROM zzxstylr WHERE Division = " + SQLFormatChar(tcDivision) + ;
2927 " AND UDFSTY3C = " + SQLFormatChar(tcUDFStyle)
2928
2929 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
2930
2931 If llRetVal
2932 Select(lcCursor)
2933 l_vRetVal = Alltrim(Style)
2934 Use In (lcCursor)
2935 Endif
2936
2937 Select (lnSelect)
2938 Return l_vRetVal
2939 Endfunc
2940
2941 *-----------------------------------------------------------------------------------
2942
2943 Function GetSizeBkt
2944 Lparameters p_cKeyField1, p_cGetField, p_cCursor, p_cKeyField2, p_cKeyField3,;
2945 p_cKeyField4, p_cKeyField5, p_cKeyField6
2946 Local l_cSQLString, l_vRetVal
2947
2948 l_nOldSele = Select()
2949 pnSizeBucket = 0
2950
2951 If Empty(p_cKeyField1) Or Empty(p_cKeyField2) Or Empty(p_cKeyField3)
2952 l_vRetVal = 0
2953 Return l_vRetVal
2954 Endif
2955
2956 l_cSize_code = vl_Stylr(p_cKeyField1, "size_code", "", ;
2957 p_cKeyField2)
2958 If vl_Sizer(p_cKeyField1, "", "TmpSizer", l_cSize_code)
2959 If vl_SAvlR(p_cKeyField1, "", "TmpSavlr", p_cKeyField2,;
2960 p_cKeyField3, p_cKeyField4, p_cKeyField5)
2961 Select TmpSavlr
2962 For l_n=1 To 24
2963 l_lAlwSz = (Eval("Call" + Trans(l_n, "@L 99")) = "Y")
2964 If l_lAlwSz
2965 l_cSize_Desc = Eval("TmpSizer.Size" + Trans(l_n, "@L 99"))
2966 If l_cSize_Desc = p_cKeyField6
2967 ***l_vRetVal = .T.
2968 pnSizeBucket = l_n
2969 Endif
2970 Endif
2971 Endfor
2972 Use In TmpSavlr
2973 Use In TmpSizer
2974 Endif
2975 Endif
2976
2977 l_vRetVal = pnSizeBucket
2978
2979 Select (l_nOldSele)
2980 Return l_vRetVal
2981
2982 Endfunc
2983
2984 *-----------------------------------------------------------------------------------
2985 * Validate SKU for all details
2986 * ONLY for !Empty(customer)- Using Trading Partner ID to get customer code
2987
2988 Procedure CheckSku
2989 *--- TR 1010097 07/27/05 TK Added parameter pceipoCR
2990 Lparameters pceipoTH, pceipoTD,;
2991 pceipoTS, pceipoCR
2992 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
2993 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
2994 lnSize_desc, llSLN
2995
2996 *--- TR 1013117 NH
2997 Local lcSku_resolv
2998 Dimension lasku_resolv[1]
2999 lcSku_resolv = ""
3000 lasku_resolv[1] = ""
3001 *=== TR 1013117 NH
3002
3003 * --- TR 1045305 2/3/10 CM
3004 LOCAL lnSkuPkey
3005 lnSkuPkey = 0
3006 * === TR 1045305 2/3/10 CM
3007
3008
3009 llRetVal = .T.
3010 lcErrs_Msg= ""
3011 lnOldSelect = Select()
3012
3013 * cannot check for SKU if customer is empty
3014 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
3015 * on Cust SKU or UPC.
3016 * ONLY Resolve ourSKU using SKU WHEN (Empty(d.style) or Empty(d.color_code))
3017
3018 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
3019 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
3020 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
3021
3022 *--- TechRec 1005163 17-May-2004 GS ---
3023 *Select h.customer, d.sku, d.pkey From (pceipoTH) h, (pceipoTD) d ;
3024 * Where !Empty(h.customer) and !Empty(d.sku) and h.pkey = d.fkey And ;
3025 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
3026 *Order by h.customer, d.sku Into Cursor tmpCurs
3027
3028 *---- TR 1024667 NSD 5/31/07
3029 * If sizebucket = 0 then re-resolve.
3030
3031 If This.oHostProcess.lHaveSLN
3032 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3033 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3034 *!* SELECT h.customer,;
3035 *!* c.sku_resolv, ;
3036 *!* JOIN (pceipoCR) C;
3037 *!* ON d.division= C.division ;
3038 *!* AND h.customer= C.customer ;
3039
3040 *!* c.sku_resolv, ; && after union
3041 *!* JOIN (pceipoCR) C;
3042 *!* ON d.division= C.division ;
3043 *!* AND h.customer= C.customer ;
3044
3045 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3046 Select h.customer,;
3047 h.department, ;
3048 h.Store, ;
3049 d.sku,;
3050 d.upc, ;
3051 d.pkey, ;
3052 (pceipoTD) As Src ;
3053 FROM (pceipoTD) d ;
3054 JOIN (pceipoTH) h ;
3055 ON h.pkey = d.fkey ;
3056 WHERE !Empty(h.customer) ;
3057 AND !Empty(d.sku) ;
3058 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
3059 UNION All ;
3060 SELECT h.customer,;
3061 h.department, ;
3062 h.Store, ;
3063 s.SLN_SKU As sku,;
3064 s.SLN_UPC As upc,;
3065 s.pkey, ;
3066 (pceipoTS) As Src ;
3067 FROM (pceipoTS) s ;
3068 JOIN (pceipoTD) d ;
3069 ON d.pkey = s.fkey ;
3070 JOIN (pceipoTH) h ;
3071 ON h.pkey = d.fkey ;
3072 WHERE !Empty(h.customer) ;
3073 AND !Empty(s.SLN_SKU) ;
3074 AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
3075 ORDER By 1, 2 ;
3076 INTO Cursor tmpCurs
3077 *=== TR 1010097 07/27/05 TK
3078 Else
3079 *--- TR 1010097 07/27/05 TK Added pceipoCR join, also added fields h.department, h.store in the select list
3080 *--- TR 1013117 NH 20050908 removed sku_resolv and join with control table pceipoCR
3081 *!* SELECT h.customer,;
3082 *!* c.sku_resolv, ;
3083 *!* JOIN (pceipoCR) C;
3084 *!* ON d.division= C.division ;
3085 *!* AND h.customer= C.customer ;
3086 *--- TechRec 1023488 11-Apr-2007 kpattabiraman added UPC---
3087 Select h.customer,;
3088 h.department, ;
3089 h.Store, ;
3090 d.sku,;
3091 d.upc, ;
3092 d.pkey, ;
3093 (pceipoTD) As Src ;
3094 FROM (pceipoTD) d ;
3095 JOIN (pceipoTH) h ;
3096 ON h.pkey = d.fkey ;
3097 WHERE !Empty(h.customer) ;
3098 AND !Empty(d.sku) ;
3099 AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ; && Only RESOLVE ONCE
3100 Order By h.customer, d.sku ;
3101 INTO Cursor tmpCurs
3102 *=== TR 1010097 07/27/05 TK
3103 Endif
3104 *=== TechRec 1005163 17-May-2004 GS ===
3105
3106*- 1040686
3107 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
3108 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
3109 IF llRetVal
3110 .PopulateSQLTempTable("tcDistCustSku")
3111 ENDIF
3112 llRetVal = llRetVal AND v_sqlexec(;
3113 "SELECT x.sku,d.* "+;
3114 " FROM zzxcstdr d"+ ;
3115 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
3116 " JOIN " + this.cSQLTempTable + " x " + ;
3117 " ON d.customer = x.customer " +;
3118 " AND d.cust_style = x.sku " + ;
3119 " WHERE h.IB_resolv = 'Y'" + ;
3120 " AND d.Size_Desc>'' " + ;
3121 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
3122 SELECT tmpCstdr_sku
3123 INDEX ON customer + cust_style TAG cust_sku
3124
3125 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
3126 UNION ;
3127 SELECT customer,sku FROM tmpCstdr_sku ;
3128 GROUP BY customer,sku ;
3129 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
3130 INDEX ON customer+sku TAG cust_sku
3131 *-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-
3132*- 1040686
3133
3134
3135 lcOldCust = ""
3136 lcOldItem = ""
3137 lcOldSku_resolv = ""
3138 Select tmpCurs
3139 If This.lUserInterface
3140 * Init Thermometer
3141 This.UpdateThermoCaption("Validating SKU(s)...")
3142 * TAN 31891 - JAZ - 5/20/02
3143 * This.InitThermo(RECC('tmpCurs'))
3144 This.InitThermo(RecCount('tmpCurs'))
3145 * End TAN 31891 - JAZ - 5/20/02
3146 l_nThermoCnt = 0
3147 Endif
3148 SCAN
3149 *--- TechRec 1023488 11-Apr-2007 kpattabiraman ---
3150 *-- Skip sku resolution
3151 IF This.oHostProcess.lUPCResolutionOnly AND NOT EMPTY(upc)
3152 LOOP
3153 ENDIF
3154 *=== TechRec 1023488 11-Apr-2007 kpattabiraman ===
3155
3156 If This.lUserInterface
3157 * Advance progress bar, if we're using one.
3158 l_nThermoCnt = l_nThermoCnt + 1
3159 This.AdvanceThermo(l_nThermoCnt)
3160 Endif
3161
3162 *--- TR 1010097 07/27/05 TK Added condition to check sku_resolv
3163 *IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
3164 *--- TR 1013117 NH 20050908
3165 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
3166 *!* IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem AND tmpCurs.sku_resolv == lcOldSku_resolv) && level break
3167 *=== TR 1013117 NH 20050908
3168 *=== TR 1010097 07/27/05 TK
3169
3170 *---TR 1037976 JAN-07-08 BR
3171 IF !(tmpCurs.customer == lcOldCust)
3172 lcCustomer = tmpCurs.customer
3173 IF SEEK(lcCustomer,pceipocr,"customer")
3174 lcSku_resolv = &pceipocr..sku_resolv
3175 ENDIF
3176 ENDIF
3177 *===TR 1037976 JAN-07-08 BR
3178
3179 lcErrs_Msg = ""
3180 lcOldCust = tmpCurs.customer
3181 lcOldItem = tmpCurs.sku
3182 *--- TR 1013117 NH
3183 *!* lcOldSku_resolv = tmpCurs.sku_resolv && TR 1010097
3184 *=== TR 1013117 NH
3185
3186 *--- TR 1010097 07/27/05 TK Added parameters tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store
3187
3188
3189
3190 *IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
3191 *--- TR 1013117 NH 20050908
3192 *!* IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3193 *!* tmpCurs.sku_resolv, tmpCurs.department, tmpCurs.store)
3194
3195 *- 1040686 - COMMENT
3196*!* If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
3197*!* lcSku_resolv, tmpCurs.department, tmpCurs.Store)
3198*!* *=== TR 1013117 NH 20050908
3199*!* *--- TR 1010097 07/27/05 TK
3200
3201*!* lcDivision = tmpCstdr.division
3202*!* lcStyle = tmpCstdr.Style
3203*!* lcColor_code = tmpCstdr.color_code
3204*!* lcLbl_code = tmpCstdr.lbl_code
3205*!* lcDimension = tmpCstdr.Dimension
3206*!* lnSizeBucket = tmpCstdr.size_bk
3207*!* lnSize_desc = tmpCstdr.size_desc
3208*!*
3209*!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3210*!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3211*!* If tmpCstdr.fkey > 0
3212*!* lnSkuPkey = tmpCstdr.fkey
3213*!* Endif
3214*!* * === TR 1045305 2/3/10 CM
3215*!*
3216*!*
3217*!* Else
3218*!* lcErrs_Msg = lcErrs_Msg + CRLF
3219*!* Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3220*!* Store 0 To lnSizeBucket
3221*!* Endif
3222
3223 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
3224 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
3225 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
3226 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3227 Store 0 To lnSizeBucket
3228 ELSE
3229 *- TR 1074276 FH - adding UPPER()
3230 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
3231 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
3232 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
3233 Store 0 To lnSizeBucket
3234 ELSE
3235 lcDivision = tmpCstdr_sku.division
3236 lcStyle = tmpCstdr_sku.Style
3237 lcColor_code = tmpCstdr_sku.color_code
3238 lcLbl_code = tmpCstdr_sku.lbl_code
3239 lcDimension = tmpCstdr_sku.Dimension
3240 lnSizeBucket = tmpCstdr_sku.size_bk
3241 lnSize_desc = tmpCstdr_sku.size_desc
3242
3243 *!* * --- TR 1045305 2/3/10 CM --- Now that we've found are customer sku, grabbing the pkey from
3244 *!* * Customer Style Reference to use later to ensure we obtain the correct price for our sku.
3245 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3246 If tmpCstdr_sku.fkey > 0
3247 lnSkuPkey = tmpCstdr_sku.fkey
3248 Endif
3249 *- TR 1062018/1064343 FH - change to tmpCstdr_sku
3250 *!* * === TR 1045305 2/3/10 CM
3251
3252 ENDIF
3253 ENDIF
3254*- 1040686 - COMMENT
3255
3256 Endif && level break
3257
3258 *--- TechRec 1005163 17-May-2004 GS ---
3259 *Select (pceipoTD)
3260 llSLN = (tmpCurs.Src = pceipoTS)
3261 If llSLN
3262 Select (pceipoTS)
3263 Else
3264 Select (pceipoTD)
3265 Endif
3266 *!* Locate For pkey = tmpCurs.pkey
3267 *If Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3268 If Seek(tmpCurs.pkey, Iif(llSLN, pceipoTS, pceipoTD), "PKey") ;
3269 AND IIF(llSLN, EVALUATE(pceipoTS + ".SkipSlnChk") <> 'Y',.t.) &&--- TR 1035223 NH - if skipslnchk is 'Y' do not set any error flag
3270 *=== TechRec 1005163 17-May-2004 GS ===
3271 Scatter Name loEiPOtd Memo
3272 If !Empty(lcErrs_Msg)
3273 *--- TechRec 1005163 17-May-2004 GS ---
3274 If llSLN
3275 *- 1008827 04/22/05 YIK
3276 *- correct a typo
3277 loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
3278
3279 loEiPOtd.Errs_Flg_S = "Y"
3280 Else
3281 *=== TechRec 1005163 17-May-2004 GS ===
3282 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
3283 loEiPOtd.Errs_Flg_D = "Y"
3284 Endif && *--- TechRec 1005163 17-May-2004 GS ---
3285 Endif
3286 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
3287 loEiPOtd.division = lcDivision
3288 loEiPOtd.Style = lcStyle
3289 loEiPOtd.color_code = lcColor_code
3290 loEiPOtd.lbl_code = lcLbl_code
3291 loEiPOtd.Dimension = lcDimension
3292 loEiPOtd.sizebucket = lnSizeBucket
3293 loEiPOtd.size_desc = lnSize_desc
3294
3295 * --- TR 1045305 2/3/10 CM
3296 loEiPOtd.sku_pkey = lnSkuPkey
3297 * === TR 1045305 2/3/10 CM
3298
3299 Endif
3300
3301 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
3302 * only replace our SKU when no range style explosion happen
3303 *--- TechRec 1005163 17-May-2004 GS ---
3304 *If empty(&pceipoTD..rng_style) or (Empty(&pceipoTD..style)) &&never have style='' with not rng_style=''
3305 * Replace division With loEiPOtd.division, ;
3306 * style With loEiPOtd.style, ;
3307 * color_code With loEiPOtd.color_code, ;
3308 * lbl_code With loEiPOtd.lbl_code, ;
3309 * dimension With loEiPOtd.dimension, ;
3310 * sizebucket With loEiPOtd.sizebucket, ;
3311 * size_desc With loEiPOtd.size_desc, ;
3312 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
3313 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
3314 * In (pceipoTD)
3315 *- 1009508 3/16/05 YIK
3316 *- IF llSLN OR EMPTY(&pceipoTD..rng_style) OR (EMPTY(&pceipoTD..STYLE))
3317 If llSLN Or Empty(Evaluate(pceipoTD + ".rng_style")) Or Empty(Evaluate(pceipoTD + ".STYLE"))
3318 Gather Name loEiPOtd Memo
3319 *=== TechRec 1005163 17-May-2004 GS ===
3320 Endif
3321
3322 *=== TechRec 1005163 17-May-2004 GS ===
3323 Endif
3324 Endscan
3325 Use In tmpCurs
3326
3327 If This.lUserInterface
3328 * Reset Thermometer
3329 This.ResetThermo()
3330 Endif
3331
3332 If Used("tmpCstdr")
3333 Use In tmpCstdr
3334 ENDIF
3335
3336 *-1040686
3337 USE IN SELECT("tcDistCustSku")
3338 USE IN SELECT("tmpCstdr_sku")
3339 USE IN SELECT("tcAmbigSku")
3340 *-1040686
3341
3342 Select(lnOldSelect)
3343 Return llRetVal
3344 Endproc
3345
3346 *-----------------------------------------------------------------------------------
3347 *--- TechRec 1034300 30-Jun-2008 T.Shenbagavalli ---
3348 PROCEDURE PopulateOrigLabel
3349 LPARAMETERS pceipoTH, pceipoTD, pceipoCR
3350 LOCAL llRetVal, lnOldSelect
3351 lnOldSelect = SELECT()
3352
3353 .PopRecordSet()
3354 SELECT (pceipoTD)
3355
3356 SELECT d.pkey ;
3357 FROM (pceipoCR) c, (pceipoTH) h, (pceipoTD) d ;
3358 WHERE c.accept_lbl = 'Y' and ;
3359 c.customer = h.customer and ;
3360 c.division = d.division and ;
3361 h.pkey = d.fkey and ;
3362 h.errs_flg_h <> 'Y' and ;
3363 d.errs_flg_d <> 'Y' ;
3364 ORDER BY d.pkey ;
3365 INTO CURSOR 'cursTmpTD'
3366
3367 Index On pkey Tag pkey
3368
3369 llRetVal= .SetRelation("cursTmpTD", "pkey", pceipoTD, "pkey")
3370
3371 goto top in "cursTmpTD"
3372
3373 If llRetVal AND !EOF('cursTmpTD')
3374 SELECT (pceipoTD)
3375 Replace All lbl_code with IIF(EMPTY(&pceipoTD..lbl_code), &pceipoTD..orig_lbl, &pceipoTD..lbl_code) ;
3376 In (pceipoTD)
3377 Endif
3378
3379 .PushRecordSet()
3380
3381 Set Relation to
3382 USE IN 'cursTmpTD'
3383 SELECT (lnOldSelect)
3384 RETURN llRetVal
3385 ENDPROC
3386 *=== TechRec 1034300 30-Jun-2008 T.Shenbagavalli ===
3387 *-----------------------------------------------------------------------------------
3388
3389 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
3390 Procedure ConfirmUPC
3391 Lparameters pceipoTH, pceipoTD, pceipoTS,pceipoCR && VKK modfied the order
3392
3393 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcErrs_Msg, ;
3394 lcUPC, lcErrs_Msg, llSLN
3395
3396 llRetVal = .T.
3397 lcErrs_Msg= ""
3398 lnOldSelect = Select()
3399
3400 .LogEntry("Confirm that the resolved UPC matches the UPC sent in transmission.")
3401
3402 Local lceipoTD_tmp, lceipoCR_tmp, lceipoTS_tmp
3403
3404 Select customer, division, sku, Style, color_code, lbl_code, Dimension, ;
3405 sizebucket, upc, ean, pkey, size_desc, rng_style ;
3406 from (pceipoTD) Into Cursor __eipoTD
3407
3408 If This.oHostProcess.lHaveSLN
3409 Select customer, division, SLN_SKU, Style, color_code, lbl_code,Dimension , ;
3410 sizebucket, SLN_UPC, SLN_EAN, pkey, fkey, size_desc From (pceipoTS) Into Cursor __EiPOts
3411 Endif
3412
3413 If Reccount(pceipoTD) = 0 Or Reccount(pceipoCR) = 0
3414 Select(lnOldSelect)
3415 Return llRetVal
3416 Endif
3417
3418 With This
3419 .cSQLTempTable = ""
3420 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTD")
3421 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTD")
3422 lceipoTD_tmp = .cSQLTempTable
3423 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3424
3425 If This.oHostProcess.lHaveSLN
3426 .cSQLTempTable = ""
3427 llRetVal = llRetVal And .GenerateSQLTempTable("__eipoTS")
3428 llRetVal = llRetVal And .PopulateSQLTempTable("__eipoTS")
3429 lceipoTS_tmp = .cSQLTempTable
3430 .LogEntry("Create zzeipots temporary table " + Iif(llRetVal, "successful.","failed."))
3431 Endif
3432 lcSql = .GetConfrimUPCSql(lceipoTD_tmp, lceipoTS_tmp, pceipoTD, pceipoTS)
3433 llRetVal = llRetVal And v_sqlexec(lcSql, "tmpCursR")
3434 .LogEntry("Create UPC temporary table " + Iif(llRetVal, "successful.","failed."))
3435 Endwith
3436
3437
3438 This.MakeCursorWritable("tmpCursR","tmpCurs")
3439
3440 Select tmpCurs
3441 If This.lUserInterface
3442 * Init Thermometer
3443 This.UpdateThermoCaption("Comparing UPC(s)...")
3444 This.InitThermo(This.CountTotalRecs ('tmpCurs'))
3445 l_nThermoCnt = 0
3446 Endif
3447
3448
3449*- 1040686
3450 *=-=-=-=-=-=-=-=-=-=
3451 SELECT DISTINCT division,Style, roll_color, lbl_code,DIMENSION, sizebucket FROM tmpCurs INTO CURSOR tcDistUpc
3452 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
3453 IF llRetVal
3454 .PopulateSQLTempTable("tcDistUpc")
3455 ENDIF
3456 llRetVal = llRetVal AND v_sqlexec(;
3457 "SELECT x.division,x.Style, x.roll_color, x.lbl_code,x.DIMENSION, x.sizebucket, d.upc_num,d.chk_digit "+;
3458 " FROM zveupcnr d"+ ;
3459 " JOIN " + this.cSQLTempTable + " x " + ;
3460 " ON d.division = x.division " + ;
3461 " AND d.style = x.style " + ;
3462 " AND d.color_code = x.roll_color " + ;
3463 " AND d.lbl_code = x.lbl_code " + ;
3464 " AND d.dimension = x.dimension " + ;
3465 " AND d.sizebucket = x.sizebucket ","tmpCstdr")
3466 SELECT tmpCstdr
3467 INDEX ON division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket) TAG cust_sku
3468 *=-=-=-=-=-=-=-=-=-=
3469 SELECT tmpCurs
3470
3471*- 1040686
3472 Local lnSizeBk
3473 lnSizeBk = 0
3474 Scan
3475 If This.lUserInterface
3476 * Advance progress bar, if we're using one.
3477 l_nThermoCnt = l_nThermoCnt + 1
3478 This.AdvanceThermo(l_nThermoCnt)
3479 Endif
3480
3481 lcErrs_Msg = ""
3482
3483 *- 1040686
3484 *--- TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3485 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, color_code, lbl_code, ;
3486 DIMENSION, sizebucket, "tmpCstdr")
3487 *lcUPC = This.GetUPC(@lcErrs_Msg, division, Style, roll_color, lbl_code, ;
3488 DIMENSION, sizebucket, "tmpCstdr")
3489
3490 lcUPC = ""
3491 IF NOT SEEK(division+Style+roll_color+lbl_code+DIMENSION+STR(sizebucket),"tmpCstdr","cust_sku")
3492 lcErrs_Msg = "Missing UPC number."
3493 ELSE
3494 lcUpc = tmpCstdr.upc_num + tmpCstdr.chk_digit
3495 ENDIF
3496
3497 *=== TR 1041098 NSD Pass in rolling color. It should be the same as regular color if rolling not in use.
3498 *-1040686
3499
3500 If !(lcUPC == tmpCurs.UPC)
3501 lcErrs_Msg = "Invalid or missing UPC in UPC reference." + CRLF
3502 Endif
3503
3504 If !Empty(lcErrs_Msg)
3505 llSLN = (tmpCurs.Src = pceipoTS)
3506 If llSLN
3507 Select (pceipoTS)
3508 = Seek(tmpCurs.pkey, pceipoTS, "Pkey")
3509 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
3510 Replace ;
3511 Errs_Msg_S With Trim(Errs_Msg_S) + lcErrs_Msg, ;
3512 Errs_Flg_S With "Y"
3513 If Seek(&pceipoTS..fkey, pceipoTD, "Pkey") And !"Has errors in SLNs."$&pceipoTD..Errs_Msg_D
3514 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs.", ;
3515 Errs_Flg_D With 'Y' In (pceipoTD)
3516 Endif
3517 ENDIF &&--- TR 1035223 NH
3518 Else
3519 = Seek(tmpCurs.pkey, pceipoTD, "Pkey")
3520 Select (pceipoTD)
3521 Replace ;
3522 Errs_Msg_D With Trim(Errs_Msg_D) + lcErrs_Msg, ;
3523 Errs_Flg_D With "Y"
3524 Endif
3525 Endif
3526 Endscan
3527
3528 Use In tmpCurs
3529
3530 If This.lUserInterface
3531 * Reset Thermometer
3532 This.ResetThermo()
3533 Endif
3534
3535 If Used("tmpCstdr")
3536 Use In tmpCstdr
3537 ENDIF
3538
3539 USE IN SELECT("tcDistUpc") &&1040686
3540
3541 Select(lnOldSelect)
3542 Return llRetVal
3543 ENDPROC
3544
3545 *-----------------------------------------------------------------------------------
3546
3547 Procedure GetConfrimUPCSql
3548 Lparameters pceipoTD_tmp, pceipoTS_tmp, pceipoTD, pceipoTS
3549 Local lcSql, lcSqlSln, lnOldSelect
3550 lnOldSelect = Select()
3551
3552 *- 1037868 04/01/09 FGCjr fix LEFT JOIN for zzxscolr, alias should be sc. for division
3553 *- 1041098 8/6/09 NSD - Added left outer join to zzxrupcd for rolling color. Since we are working off resolved colors,
3554 * this is a straight join and not a date resolution.
3555 lcSql = ;
3556 "select d.customer"+;
3557 " , d.division"+;
3558 " , d.sku"+;
3559 " , d.STYLE"+;
3560 " , d.color_code"+;
3561 " , case"+;
3562 " when r.rng_style is null"+;
3563 " and d.lbl_code = ''"+;
3564 " and c.resv_label = 'Y' then c.lbl_code"+;
3565 " when r.rng_style is null"+;
3566 " and d.lbl_code = ''"+;
3567 " and c.resv_label = 'V'"+;
3568 " and coalesce(sc.Active_ok, '') = 'Y' then c.lbl_code"+;
3569 " else d.lbl_code"+;
3570 " end as lbl_code"+;
3571 " , d.lbl_code as lbl_codeOrig"+;
3572 " , c.resv_label"+;
3573 " , d.DIMENSION"+;
3574 " , d.Sizebucket"+;
3575 " , d.upc"+;
3576 " , d.pkey"+;
3577 " , C.Confirm_UPC"+;
3578 " , d.size_desc"+;
3579 " , '" + Trim(pceipoTD) + "' as Src"+;
3580 " , COALESCE(rc.color_code,d.color_code) as roll_color " +;
3581 " from " + pceipoTD_tmp + " d"+;
3582 " join zzeipocr C"+;
3583 " on d.customer = C.customer"+;
3584 " and d.division = C.division"+;
3585 " left join zzxrangh r"+;
3586 " on r.division = d.division"+;
3587 " and r.rng_style = d.style"+;
3588 " and r.rng_color = d.color_code"+;
3589 " and r.rng_lbl = d.lbl_code"+;
3590 " and r.rng_pack = d.dimension"+;
3591 " left join zzxscolr sc"+;
3592 " on sc.division = d.division"+;
3593 " and sc.style = d.style"+;
3594 " and sc.color_code = d.color_code"+;
3595 " and sc.lbl_code = c.lbl_code"+;
3596 " and sc.dimension = d.dimension"+;
3597 " left join zzxrupcd rc " + ;
3598 " on rc.division = d.division"+;
3599 " and rc.style = d.style"+;
3600 " and rc.new_color = d.color_code"+;
3601 " and rc.lbl_code = d.lbl_code"+;
3602 " and rc.dimension = d.dimension"+;
3603 " where d.customer > ''"+;
3604 " and d.SKU > ''"+;
3605 " and (d.UPC > '' or d.EAN > '' )"+;
3606 " and d.Division > ''"+;
3607 " and d.Style > ''"+;
3608 " and d.Color_Code > ''"+;
3609 " and C.Confirm_UPC = 'Y' "+;
3610 " and d.Rng_Style = '' "
3611
3612 If This.oHostProcess.lHaveSLN And Reccount(pceipoTS) > 0
3613 *--- TR 1051927 24-Mar-2011 SK Changed join condition for zzxscolr.
3614 *--- Used sc.Division instead of c.Division.
3615 lcSqlSln = ;
3616 "select d.Customer"+;
3617 " , d.Division"+;
3618 " , s.SLN_SKU as sku"+;
3619 " , s.STYLE"+;
3620 " , s.Color_Code"+;
3621 " , case when s.Lbl_Code = ''"+;
3622 " and c.Resv_Label = 'Y' then c.lbl_code"+;
3623 " when s.Lbl_Code = ''"+;
3624 " and c.Resv_Label = 'V'"+;
3625 " and coalesce(sc.Active_ok, '') = 'Y' then c.Lbl_Code"+;
3626 " else s.lbl_code"+;
3627 " end as lbl_code"+;
3628 " , s.lbl_code as lbl_codeOrig"+;
3629 " , c.resv_label"+;
3630 " , s.DIMENSION"+;
3631 " , s.Sizebucket"+;
3632 " , s.SLN_UPC as upc"+;
3633 " , s.pkey"+;
3634 " , C.Confirm_UPC"+;
3635 " , s.size_desc"+;
3636 " , '" + Trim(pceipoTS) + "' as Src"+;
3637 " , COALESCE(rc.color_code,s.color_code) as roll_color " +;
3638 " from " + pceipoTD_tmp + " d"+;
3639 " join " + pceipoTS_tmp + " s"+;
3640 " on s.fkey = d.pkey"+;
3641 " join zzeipocr C"+;
3642 " on d.customer = C.customer"+;
3643 " and d.division = C.division"+;
3644 " left join zzxscolr sc"+;
3645 " on sc.division = d.division"+;
3646 " and sc.style = s.style"+;
3647 " and sc.color_code = s.color_code"+;
3648 " and sc.lbl_code = c.lbl_code"+;
3649 " and sc.dimension = s.dimension"+;
3650 " left join zzxrupcd rc " + ;
3651 " on rc.division = d.division"+;
3652 " and rc.style = s.style"+;
3653 " and rc.new_color = s.color_code"+;
3654 " and rc.lbl_code = c.lbl_code"+;
3655 " and rc.dimension = s.dimension"+;
3656 " where d.Customer > ''"+;
3657 " and s.SLN_SKU > ''"+;
3658 " and (s.SLN_UPC > '' or s.SLN_EAN > '')"+;
3659 " and d.Division > ''"+;
3660 " and s.Style > ''"+;
3661 " and s.Color_Code > ''"+;
3662 " and c.Confirm_UPC = 'Y'"+;
3663 " and d.Rng_Style > ''"
3664 Endif
3665
3666 lcSql = lcSql + Iif(Empty(lcSqlSln), "", " UNION ALL " + lcSqlSln)
3667 Select(lnOldSelect)
3668 Return lcSql
3669 Endproc
3670 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
3671
3672 *-----------------------------------------------------------------------------------
3673
3674 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3675 PROCEDURE MarkHeaderwithDetailOrSLNInError
3676 LPARAMETERS pceipoTH, pceipoTD, pcSLN
3677 * This is customized method from clsEDI
3678
3679 LOCAL llRetVal, lnOldSelect
3680 LOCAL lnBadOrderCount
3681 llRetVal = .T.
3682 lnOldSelect = SELECT()
3683
3684 IF VARTYPE(pcEW) <> "C" OR !INLIST(pcEW,"E","W")
3685 pcEW = "E"
3686 ENDIF
3687 .LogEntry("Marking Header Records with Error if Detail or SLN in Error")
3688 LOCAL lcErrorMsg, lcErrorMsgSLN
3689 lnBadOrderCount = 0
3690 IF pcEW = 'W'
3691 lcErrorMsg = "Has Warnings in Details."
3692 SELECT DISTINCT fkey FROM (pceipoTD) WHERE warn_flg_d = 'Y' INTO CURSOR tcBadOrders
3693 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3694 ELSE
3695 lcErrorMsg = "Has Errors in Details."
3696 SELECT DISTINCT fkey FROM (pceipoTD) WHERE Errs_Flg_D = 'Y' INTO CURSOR tcBadOrders
3697 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrders')
3698
3699 lcErrorMsgSLN = "Has Errors in SLN - SKU/UPC Unresolved"
3700 SELECT DISTINCT fkey FROM (pcSLN) WHERE Errs_Flg_S = 'Y' INTO CURSOR tcBadOrdersSLN
3701 lnBadOrderCount = lnBadOrderCount + RECC('tcBadOrdersSLN')
3702 ENDIF
3703
3704 SELECT tcBadOrders
3705 IF THIS.lUserInterface
3706 * Init Thermometer
3707 THIS.InitThermo(lnBadOrderCount)
3708 l_nThermoCnt = 0
3709 ENDIF
3710 SCAN
3711 IF THIS.lUserInterface
3712 * Advance progress bar, if we're using one.
3713 l_nThermoCnt = l_nThermoCnt + 1
3714 THIS.AdvanceThermo(l_nThermoCnt)
3715 ENDIF
3716 SELECT (pceipoTH)
3717 IF pcEW = 'W'
3718 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3719 IF NOT ATC(lcErrorMsg,warn_msg_h) > 0
3720 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsg + CRLF, warn_flg_h WITH "Y";
3721 IN (pceipoTH)
3722 ENDIF
3723 ENDIF
3724 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3725 IF NOT ATC(lcErrorMsgSLN,warn_msg_h) > 0
3726 REPLACE warn_msg_h WITH warn_msg_h + lcErrorMsgSLN + CRLF, warn_flg_h WITH "Y";
3727 IN (pceipoTH)
3728 ENDIF
3729 ENDIF
3730 ELSE
3731 IF SEEK(tcBadOrders.fkey,pceipoTH,"pkey")
3732 IF NOT ATC(lcErrorMsg,Errs_msg_H) > 0
3733
3734 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsg + CRLF, Errs_flg_h WITH "Y";
3735 IN (pceipoTH)
3736 ENDIF
3737 ENDIF
3738 IF SEEK(tcBadOrdersSLN.fkey,pceipoTH,"pkey")
3739 IF NOT ATC(lcErrorMsgSLN,Errs_msg_H) > 0
3740
3741 REPLACE Errs_msg_H WITH Errs_msg_H + lcErrorMsgSLN + CRLF, Errs_flg_h WITH "Y";
3742 IN (pceipoTH)
3743 ENDIF
3744 ENDIF
3745 ENDIF
3746 ENDSCAN
3747 USE IN tcBadOrders
3748 USE IN tcBadOrdersSLN
3749
3750 IF THIS.lUserInterface
3751 THIS.ResetThermo()
3752 ENDIF
3753 SELECT(lnOldSelect)
3754 RETURN llRetVal
3755 ENDPROC
3756 *--- TR 1033134 TT: Prevent ProcessOPR to cause OFORMRESIZER error to 850
3757
3758 *-----------------------------------------------------------------------------------
3759
3760 *--- TR 1013007 NH
3761 *--- checks if pceipoTH.req_855 is 'R'
3762 *--- if 850 control auto process is true (if zzeipocr.Auto_855 = 'Y' )
3763 *--- if default status value is not empty then set Send855 flag to true and return true
3764 *--- if default status value is empty then set Send855 flag to true and return false and
3765 *--- set error message 'Missing 855 status code'
3766 *--- if 850 control auto process is false (if zzeipocr.Auto_855 <> 'Y' )
3767 *--- then set Send855 flag to true and return false and
3768 *--- set error message 'Missing 855 status code'
3769
3770 *--- if pceipoTH.req_855 is not 'R' (if zzeipocr.Auto_855 = '' )
3771 *zzeipocr.Auto_855 = 'Y' and zzeipocr.def_855 is not empty then set this.lSend855 flag to .T. and return true
3772 *--- if zzeipocr.Auto_855 = 'Y' and zzeipocr.deft_855 is empty
3773 *--- then set this.llSend855 flag to .T. and return false and set err message on header ''
3774 *--- if pceipoth.req_855 is not 'R' then set this.llSend855 flag to .F. and return true
3775
3776
3777 Procedure Check855Required
3778 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR
3779
3780 Local lnOldSelect, llRetVal, loEiPOth, loeipoCR,lnOldOrder_TD, lcOldPO_num,lcPO_Status_855
3781 llRetVal = .T.
3782 lnOldSelect = Select()
3783 lcOldPO_num = ""
3784 lcPO_Status_855 = ""
3785 This.LogEntry("Starting procedure" + Program())
3786 This.LogEntry("pceipoTH has " + Str(Reccount(pceipoTH)))
3787
3788 *--- prepare detail zzeipotd for cascading status_855 code
3789 Select(pceipoTD)
3790 lnOldOrder_TD = Val(Sys(21)) && getting the current order
3791 Set Order To Tagno('FKEY') && settting order by 'fkey'
3792
3793 Select(pceipoTH)
3794 Scan For req_855 = 'R'
3795 Scatter Name loEiPOth Memo
3796 *--- when this.lSend855 flag is true then data will be sent to server
3797 This.lSend855 = .T.
3798
3799 *--- TR 1040432 MAY-20-2009 BR
3800 *If Empty(loEiPOth.status_855) And Seek(loEiPOth.VND_ID,pceipoCR,'vnd_id')
3801 If Empty(loEiPOth.status_855) And Seek(loEiPOth.division + loEiPOth.customer,pceipoCR,'divcust')
3802 *=== TR 1040432 MAY-20-2009 BR
3803 Select(pceipoCR)
3804 If Auto_855 = 'Y'
3805 If Not Empty(def_855)
3806 *--- set default value
3807 loEiPOth.status_855 = def_855
3808 *--- TR 1080293 KISHORE 26-AUG-2014
3809 IF NOT EMPTY(def_855dtl)
3810 lcDetail855Code = EVALUATE(pceipoCR + ".def_855dtl")
3811 REPLACE ALL status_855 WITH lcDetail855Code ;
3812 IN (pceipoTD) ;
3813 FOR fkey = loeipoTH.pkey AND EMPTY(EVALUATE(pceipoTD + ".status_855"))
3814 ELSE
3815 *=== TR 1080293 KISHORE 26-AUG-2014
3816 *--- we cascade 855 status acknowledgement code to detail(zzeipotd) only when it is auto 855 process
3817 *--- TechRec 1086723 15-May-2015 jjanand/BNarayanan ---
3818*!* llRetVal = llRetVal And This.Cascade855AckCode(loEiPOth, pceipoTD)
3819 *=== TechRec 1086723 15-May-2015 jjanand/BNarayanan ===
3820 ENDIF && TR 1080293 KISHORE 26-AUG-2014
3821 Else
3822 loEiPOth.Errs_flg_h = 'Y'
3823 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Missing Default 855 status code for 855 Auto process." + CRLF
3824 Endif
3825 Endif
3826 Endif
3827
3828 *--- status_855 code is still empty
3829 If Empty(loEiPOth.status_855)
3830 loEiPOth.Errs_flg_h = 'Y'
3831 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "855 outbound required. Please enter 855 Acknowledgement status codes." + CRLF
3832 Endif
3833
3834 *--- check if defferent status_855 code exists in orders with same po number
3835 If lcOldPO_num <> loEiPOth.po_num
3836 lcOldPO_num = loEiPOth.po_num
3837 lcPO_Status_855 = loEiPOth.status_855
3838 Else
3839 If lcPO_Status_855 <> loEiPOth.status_855
3840 loEiPOth.Errs_flg_h = 'Y'
3841 loEiPOth.Errs_msg_H = loEiPOth.Errs_msg_H + "Different status_855 code exists for same PO number." + CRLF
3842 Endif
3843 Endif
3844
3845 *--- all records will only be get updated. No insert is need here.
3846 Select(pceipoTH)
3847 Gather Name loEiPOth Memo
3848
3849 If Not llRetVal
3850 Exit
3851 Endif
3852 Endscan
3853 *--- set back to old order by
3854 Select(pceipoTD)
3855 Set Order To (lnOldOrder_TD)
3856 *-- when one order is flaged error then all order of PO will be make
3857 *--- TechRec 1048010 27-Jul-2010 jisingh Added parameter pceipoCR ===
3858 llRetVal = llRetVal And This.oHostProcess.MarkGoodOrders(pceipoTH,pceipoTD,pceipoCR)
3859 Select(lnOldSelect)
3860 Return llRetVal
3861
3862 ENDPROC
3863
3864 *-----------------------------------------------------------------------------------
3865
3866 *--- must set order by 'FKey' in pceipoTD
3867 Procedure Cascade855AckCode
3868 Lparameters poeipoTH, pceipoTD
3869
3870 Local llRetVal, lnOldSelect
3871 lnOldSelect = Select()
3872 llRetVal = .T.
3873
3874 If Not (Vartype(poeipoTH) == "O" And Vartype(poeipoTH.pkey) = "N")
3875 Return .F.
3876 Endif
3877 *- 1034481 10/06/08 YIK
3878 *- Cascade ALL status codes to details.
3879 *- The 855(o) process will eliminate details for 'RJ' (reject, no details) and 'AK' - accept, no details codes
3880 *- If poeipoTH.status_855 = "AC" Or poeipoTH.status_855 = "AD" Or poeipoTH.status_855 = "RD"
3881 Select(pceipoTD)
3882 If Seek(poeipoTH.pkey,pceipoTD, "fkey")
3883 Scan While fkey = poeipoTH.pkey
3884 Replace status_855 With poeipoTH.status_855 In (pceipoTD)
3885 Endscan
3886 ENDIF
3887 *- 1034481
3888 *- Endif
3889
3890 Select(lnOldSelect)
3891 Return llRetVal
3892 Endproc
3893
3894 *----------------------------------------------------------------------------------------
3895 *--- TR 1034481 NH
3896 PROCEDURE MarkHeaderForMissing855ControlRef
3897 LPARAMETERS pceipoTH
3898
3899 LOCAL llRetVal, lnOldSelect,lcZzeoprcr
3900
3901 llRetVal = .t.
3902 lnOldSelect = SELECT()
3903 lcZzeoprcr = "Oprcr" + SYS(2015)
3904 lcZzxlookp = "LOOKP" + SYS(2015) && TR 1083402 20-Jan-2015 Partha
3905
3906 *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
3907ASSERT .f.
3908 *--- TR 1083402 20-Jan-2015 Partha ---
3909*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
3910
3911 llRetVal = llRetVal and v_sqlexec("select customer, division, ack29_req from zzeoprcr", lcZzeoprcr)
3912 llRetVal = llRetVal and v_sqlexec("SELECT p.lk_code FROM zzxlookp p WHERE p.Lk_Type ='ACK29 Codes' ", lcZzxlookp)
3913 *=== TR 1083402 20-Jan-2015 Partha ===
3914
3915 IF USED(lcZzeoprcr)
3916
3917 SELECT (lcZzeoprcr) && TR 1083402 20-Jan-2015 Partha
3918
3919 INDEX on customer TAG customer
3920 INDEX on division TAG division
3921
3922 UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + '855 control reference missing.' + CRLF ;
3923 from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
3924 AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
3925
3926 *--- TR 1083402 20-Jan-2015 Partha ---
3927 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Valid ACK29 Code required.' + CRLF ;
3928 from (pceipoTH) th ;
3929 JOIN (pceipoTD) td ON th.pkey=td.fkey ;
3930 WHERE th.req_855 ='R' ;
3931 AND EXISTS ( select c.customer from (lcZzeoprcr) c ;
3932 WHERE c.customer = th.customer AND c.division = th.division AND c.ack29_req='Y') ;
3933 AND ( EMPTY(td.ack29) ;
3934 OR NOT EXISTS (SELECT 1 FROM (lcZzxlookp) p WHERE p.LK_CODE = td.ack29 ))
3935 *=== TR 1083402 20-Jan-2015 Partha ===
3936
3937 USE IN (lcZzeoprcr)
3938 USE IN (lcZzxlookp) && TR 1083402 20-Jan-2015 Partha
3939 ENDIF
3940
3941 SELECT(lnOldSelect)
3942 RETURN llRetVal
3943
3944 ENDPROC
3945 *=== TR 1034481 NH
3946 *----------------------------------------------------------------------------------------
3947
3948 Function UpdateServerData(pceipoTH, pceipoTD, pceipoTS)
3949
3950 Local laTables[4]
3951 laTables[1] = "VzzeiPOth_iPOproc"
3952 laTables[2] = "VzzeiPOtd_iPOproc"
3953 laTables[3] = "VzzeiPOts_iPOproc"
3954 * --- TR 1018184 RLN 1018184
3955 laTables[4] = "VzzeiPOtsac_iPOproc"
3956
3957 Local llRetVal, llBeganTransaction, loEiPOth
3958 Local lceipoTH_temp, lceipoTD_temp ,lceipoTS_temp, lcSQL_eipoTH
3959 Local loEiPOth,loEiPOtd,loeipoTS,loEiPOta, loEiPOtc
3960
3961 llRetVal = .T.
3962
3963 With This
3964 .LogEntry("Starting Program : " + Program())
3965 .LogEntry( pceipoTH + " has " + Str(Reccount(pceipoTH)) + " records.")
3966
3967 Select(pceipoTH)
3968 Scan
3969 Scatter Name loEiPOth Memo
3970 If Seek(loEiPOth.pkey,'VzzeiPOth_iPOproc','PKEY')
3971 Select('VzzeiPOth_iPOproc')
3972 Gather Name loEiPOth Memo
3973 Endif
3974 Endscan
3975
3976 Select(pceipoTD)
3977 Scan
3978 Scatter Name loEiPOtd Memo
3979 If Seek(loEiPOtd.pkey,'VzzeiPOtd_iPOproc','PKEY')
3980 Select('VzzeiPOtd_iPOproc')
3981 Gather Name loEiPOtd Memo
3982 Endif
3983 Endscan
3984
3985 Select(pceipoTS)
3986 Scan
3987 Scatter Name loeipoTS Memo
3988 If Seek(loeipoTS.pkey,'VzzeiPOts_iPOproc','PKEY')
3989 Select('VzzeiPOts_iPOproc')
3990 Gather Name loeipoTS Memo
3991 Endif
3992 Endscan
3993
3994 *--- can not use TableUpdateWithTransaction(), as it will call AfterTableUpdateBeforeCommitHook() which is not desired here.
3995 If This.BeginTransaction()
3996 llRetVal = This.Tableupdate(@laTables)
3997 If llRetVal
3998 This.EndTransaction()
3999 Else
4000 This.RollbackTransaction()
4001 Endif
4002 Endif
4003 *--- close views.
4004 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
4005 Endwith
4006
4007 Return llRetVal
4008
4009 Endfunc
4010
4011 *----------------------------------------------------------------------------------------
4012
4013 Procedure Run855Process
4014 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4015 Lparameters pceipoTH, pceipoTD, pczzeiPOtWhse
4016 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4017
4018 Local lnOldSelect, llRetVal, loStatusCur
4019 lnOldSelect = Select()
4020 llRetVal = .T.
4021 Local lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4022 Store "" To lceoprth,lceoprtd,lceoprtc,lceoprta,lceoprth_notes,lceoprtd_notes,lcOPRTH_IPOTH
4023 Local lcStatusCur, loStatus
4024 lcStatusCur = Sys(2015)
4025 With This
4026
4027 *--- TR 1044017 07-JAN-2010 HNISAR
4028*!* .LogMajorStage("Initiating Outbound 855 process from 850 process.")
4029 .LogMajorStage("Initiating Outbound 855 process from " + This.oHostProcess.cProcessNo +" process.")
4030 *=== TR 1044017 07-JAN-2010 HNISAR
4031
4032 .LogEntry("Starting program " + Program())
4033
4034 * --- TR 1048571 9/9/10 CM
4035 *llRetVal = llRetVal And .get855Status(lcStatusCur) And Used(lcStatusCur)
4036 llRetVal = llRetVal And .get855Status(lcStatusCur, pceipoTH) And Used(lcStatusCur)
4037 * === TR 1048571 9/9/10 CM
4038
4039 If llRetVal
4040 Select (lcStatusCur )
4041 Scatter Name loStatus
4042 Use In (lcStatusCur)
4043 ENDIF
4044 *- 1034481 10/03/08 YIK
4045 *- Check if there are no 855(o) to process
4046 llHas855ToSend = .T.
4047
4048 *--- req_855 must be more the status missing count
4049 If llRetVal And loStatus.Req_855_COUNT > loStatus.STATUS_855_MISSING
4050 *AND EVALUATE(lcStatusCur + ".Req_855_COUNT") > EVALUATE(lcStatusCur + ".STATUS_855_MISSING")
4051 *-- move 850 data to 855 transaction
4052 *-- It would be a good idea to move this method MoveTo855TempTransaction to a separate class.
4053
4054 *- 1034481 10/03/08 YIK
4055 *- Added parameter pceipoTH and llHas855ToSend
4056 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4057 llRetVal = llRetVal And .MoveTo855TempTransaction(@lcOPRTH_IPOTH, @lceoprth,@lceoprtd,@lceoprtc,;
4058 @lceoprta,@lceoprth_notes,@lceoprtd_notes, pceipoTH, @llHas855ToSend, pceipoTD)
4059
4060 *--- TR 1044017 07-JAN-2010 HNISAR
4061*!* .LogEntry("Moving 850 transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4062 .LogEntry("Moving " + This.oHostProcess.cProcessNo +" transaction data to 855 transaction " + Iif(llRetVal,"completed.","failed."))
4063 *===TR 1044017 07-JAN-2010 HNISAR
4064
4065 *- 1034481 10/03/08 YIK
4066 *- Check if there are no 855(o) to process
4067 IF llHas855ToSend
4068 *-- create flat files
4069 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4070 llRetVal = llRetVal And .Launch855Process(lceoprth,lceoprtd,lceoprtc,lceoprta,;
4071 lceoprth_notes,lceoprtd_notes,pczzeiPOtWhse)
4072 .LogEntry("Launching 855 process " + Iif(llRetVal,"completed.","failed."))
4073
4074 *--- update 855 flag of 850 tran header
4075 llRetVal = llRetVal And .Update855ProcFlag(lceoprth, pceipoTH, lcOPRTH_IPOTH)
4076
4077 *--- TR 1044017 07-JAN-2010 HNISAR
4078*!* .LogEntry("Updating PROC_855 flag of 850 process " + Iif(llRetVal,"completed.","failed."))
4079 .LogEntry("Updating PROC_855 flag of " + This.oHostProcess.cProcessNo +" process " + Iif(llRetVal,"completed.","failed."))
4080 *=== TR 1044017 07-JAN-2010 HNISAR
4081
4082 *--- drop temp tables
4083 *- 1030497 02/29/08 TT
4084 *!* .dropTempTable(lcOPRTH_IPOTH,.T.)
4085 *!* .dropTempTable(lceoprth,.T.)
4086 *!* .dropTempTable(lceoprtd,.T.)
4087 *!* .dropTempTable(lceoprtc,.T.)
4088 *!* .dropTempTable(lceoprta,.T.)
4089 *!* .dropTempTable(lceoprth_notes,.T.)
4090 *!* .dropTempTable(lceoprtd_notes,.T.)
4091 .oCopyUtil.dropTempTable(lcOPRTH_IPOTH,.T.)
4092 .oCopyUtil.dropTempTable(lceoprth,.T.)
4093 .oCopyUtil.dropTempTable(lceoprtd,.T.)
4094 .oCopyUtil.dropTempTable(lceoprtc,.T.)
4095 .oCopyUtil.dropTempTable(lceoprta,.T.)
4096 .oCopyUtil.dropTempTable(lceoprth_notes,.T.)
4097 .oCopyUtil.dropTempTable(lceoprtd_notes,.T.)
4098
4099 *- 1034481 10/03/08 YIK
4100 ELSE
4101 .LogEntry("No 855(o) transaction data to send.")
4102 ENDIF
4103 *= 1034481 *- 1030497 02/29/08 TT
4104 Endif
4105
4106 *- 1034481 10/03/08 YIK
4107 *- Added ..AND loStatus.STATUS_855_MISSING > 0
4108 If llRetVal And loStatus.Req_855_COUNT > 0 AND loStatus.STATUS_855_MISSING > 0
4109 .oHostProcess.c855Msg = Transform(loStatus.Req_855_COUNT) + " Orders Found." + CRLF + ;
4110 IIF(loStatus.STATUS_855_MISSING > 0, Transform(loStatus.STATUS_855_MISSING) + ;
4111 " Orders Require 855 Acknowledgement Status Code." + CRLF,"") + ;
4112 .oHostProcess.c855Msg
4113 Endif
4114 Release loStatus
4115 Endwith
4116
4117 Select(lnOldSelect)
4118 Return llRetVal
4119
4120 Endfunc
4121
4122 *----------------------------------------------------------------------------------------
4123
4124 Procedure get855Status
4125 * --- TR 1048571 9/9/10 CM --- Added pceipoTH
4126 Lparameters tcCursor, pceipoTH
4127
4128 * --- TR 1048571 9/9/10 CM
4129 *Local lcSQL, lnOldSelect,llRetVal
4130 LOCAL lcSQL, lnOldSelect,llRetVal, lceipoth
4131
4132 lceipoth = "#Ipoth" + SYS(2015)
4133 * === TR 1048571 9/9/10 CM
4134
4135 lnOldSelect = Select()
4136 llRetVal = .T.
4137
4138 * --- TR 1048571 9/9/10 CM
4139 With This
4140 .cSQLTempTable=""
4141 IF .GenerateSQLTempTable(pceipoTH)
4142 IF .PopulateSQLTempTable(pceipoTH)
4143 lcSQL = "SELECT * INTO " + lceipoth + " FROM " + .cSQLTempTable
4144 llRetVal = llRetVal And v_SqlExec(lcSQL)
4145 ENDIF
4146 ENDIF
4147 Endwith
4148 * === TR 1048571 9/9/10 CM
4149
4150 * --- TR 1048571 9/9/10 CM --- Changed zzeipoth to lceipoth
4151 lcSQL = " select sum(1) rec_count, " + ;
4152 " sum(case when errs_flg_h = 'Y' THEN 1 ELSE 0 END) ERR_COUNT, " + ;
4153 " sum(case when req_855 = 'R' AND status_855 = '' then 1 else 0 end) STATUS_855_MISSING, " + ;
4154 " sum(case when req_855 = 'R' then 1 else 0 end) Req_855_COUNT " + ;
4155 " from " + lceipoth + " h " + This.cFilterCriteria
4156
4157 llRetVal = llRetVal And v_SqlExec(lcSQL, tcCursor)
4158 Select(lnOldSelect)
4159 Return llRetVal
4160 Endproc
4161
4162 *----------------------------------------------------------------------------------------
4163
4164 Procedure MoveTo855TempTransaction
4165 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4166 Lparameters pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,;
4167 pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, plHas855ToSend, pceipoTD && 1034481 10/03/08 YIK added pceipoTH and plHas855ToSend
4168
4169 Local llRetVal, lnOldSelect
4170 lnOldSelect = Select()
4171 llRetVal = .T.
4172 With This
4173 *--- create temporary 855 transaction tables at server
4174 llRetVal = llRetVal And .CreateOPRTempTables(@pcRefeoprth,@pcRefeoprtd,;
4175 @pcRefeoprtc,@pcRefeoprta,@pcRefeoprth_notes,@pcRefeoprtd_notes)
4176
4177 *--- copy data from 850 trans table to 855 temp trans tables
4178 *- 1034481 10/03/08 YIK
4179 * --- TR 1048571 9/9/10 CM --- Added pceipoTD
4180 llRetVal = llRetVal And .IPODataToOPRTmpTable(pcRefeoprth,pcRefeoprtd,;
4181 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pceipoTH, @plHas855ToSend, pceipoTD)
4182
4183 *--- set pkey for 855 temp trans tables ( only need for sysnotes table)
4184 IF plHas855ToSend
4185 llRetVal = llRetVal And .ResetPkey_OPRTmpTable(@pcRefOPRTH_IPOTH,pcRefeoprth,pcRefeoprtd,;
4186 pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes)
4187
4188 *--- update header division from detail
4189 llRetVal = llRetVal And .UpdateOPRTempHDRDivisionFromDtl(pcRefeoprth,pcRefeoprtd)
4190 ENDIF
4191 *= 1034481
4192 Endwith
4193
4194 Select(lnOldSelect)
4195 Return llRetVal
4196
4197 Endproc
4198
4199 *----------------------------------------------------------------------------------------
4200
4201 Procedure CreateOPRTempTables
4202 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes
4203
4204 Local llRetVal, lnOldSelect, lcUnique
4205 lnOldSelect = Select()
4206 llRetVal = .T.
4207 llRetVal = (Vartype(pcRefeoprth) == "C" And Vartype(pcRefeoprtd) == "C" And Vartype(pcRefeoprtc) == "C" ;
4208 AND Vartype(pcRefeoprta) == "C" And Vartype(pcRefeoprth_notes) == "C" ;
4209 AND Vartype(pcRefeoprtd_notes) == "C" )
4210
4211 lcUnique = Sys(2015)
4212 With This
4213 .LogEntry("Starting " + Program())
4214 .LogEntry("Creating OPR Temp Tables.")
4215
4216 *--- zzeipoth
4217 pcRefeoprth = "#zzeoprth" + lcUnique
4218 lcSQL = "SELECT * into " + pcRefeoprth + " from zzeoprth where 1 = 2 "
4219 llRetVal = llRetVal And v_SqlExec(lcSQL)
4220
4221 *--- TR 1044208
4222 .oHostProcess.AddToTempTables(pcRefeoprth)
4223 *=== TR 1044208
4224
4225 .LogEntry("Creating OPRTH Temp Table " + Iif(llRetVal,"completed.","falied."))
4226 *--- zzeipotd
4227 pcRefeoprtd = "#zzeoprtd" + lcUnique
4228 lcSQL = "SELECT * into " + pcRefeoprtd + " from zzeoprtd where 1 = 2 "
4229 llRetVal = llRetVal And v_SqlExec(lcSQL)
4230 *--- TR 1044208
4231 .oHostProcess.AddToTempTables(pcRefeoprtd)
4232 *=== TR 1044208
4233 .LogEntry("Creating OPRTD Temp Table " + Iif(llRetVal,"completed.","falied."))
4234
4235 *--- zzeipotc
4236 pcRefeoprtc = "#zzeoprtc" + lcUnique
4237 lcSQL = "SELECT * into " + pcRefeoprtc + " from zzeoprtc where 1 = 2 "
4238 llRetVal = llRetVal And v_SqlExec(lcSQL)
4239 *--- TR 1044208
4240 .oHostProcess.AddToTempTables(pcRefeoprtc )
4241 *=== TR 1044208
4242 .LogEntry("Creating OPRTC Temp Table " + Iif(llRetVal,"completed.","falied."))
4243
4244 *--- zzeipota
4245 pcRefeoprta = "#zzeoprta" + lcUnique
4246 lcSQL = "SELECT * into " + pcRefeoprta + " from zzeoprta where 1 = 2 "
4247 llRetVal = llRetVal And v_SqlExec(lcSQL)
4248 *--- TR 1044208
4249 .oHostProcess.AddToTempTables(pcRefeoprta )
4250 *=== TR 1044208
4251 .LogEntry("Creating OPRTA Temp Table " + Iif(llRetVal,"completed.","falied."))
4252
4253 *---- sysnotes_oprth
4254 pcRefeoprth_notes = "#sysnotes_oprth" + lcUnique
4255 lcSQL = "SELECT * into " + pcRefeoprth_notes + " from sysnotes where 1 = 2 "
4256 llRetVal = llRetVal And v_SqlExec(lcSQL)
4257 *--- TR 1044208
4258 .oHostProcess.AddToTempTables(pcRefeoprth_notes )
4259 *=== TR 1044208
4260 .LogEntry("Creating OPRTH notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4261
4262 *---- sysnotes_oprtd
4263 pcRefeoprtd_notes = "#sysnotes_oprtd" + lcUnique
4264 lcSQL = "SELECT * into " + pcRefeoprtd_notes + " from sysnotes where 1 = 2 "
4265 llRetVal = llRetVal And v_SqlExec(lcSQL)
4266 *--- TR 1044208
4267 .oHostProcess.AddToTempTables(pcRefeoprtd_notes )
4268 *=== TR 1044208
4269 .LogEntry("Creating OPRTD notes Temp Table " + Iif(llRetVal,"completed.","falied."))
4270
4271 Endwith
4272
4273 Select(lnOldSelect)
4274 Return llRetVal
4275
4276 Endproc
4277
4278 *----------------------------------------------------------------------------------------
4279
4280 Procedure IPODataToOPRTmpTable
4281 Lparameters pceoprth,pceoprtd,pceoprtc,pceoprta,pceoprth_notes,pceoprtd_notes, pceipoTH, plHas855ToSend, ; &&1034481 10/03/08 YIK Added plHas855ToSend
4282 pceipoTD
4283 *--- TR 1077093 25-Mar-2014 SMeenraja Added variable lcFldsList, lcCmnd
4284 Local llRetVal, lnOldSelect, lcCommonFields, lcFilter, lcOPR_TMP, lcTempIPOTH, lcFldsList, lcCmnd
4285 *--- TR 1043191 23-Oct-2009 JK Added lcTempIPOTH ===
4286
4287 lcOPR_TMP = ""
4288 lnOldSelect = Select()
4289 llRetVal = .T.
4290 lcCommonFields = ""
4291 lcFilter = Iif(Empty(This.cFilterCriteria), " where 1 = 1 ", This.cFilterCriteria)
4292 Local lcLeftOnlyFields, lcLeftOnlyDefaults
4293 lcLeftOnlyDefaults = ""
4294 lcLeftOnlyFields = ""
4295 Local lcCalFldOPRH, lcFlds, lcValues, lcSQL && TR 1044604 DEC-29-2009 BR
4296
4297 lcipoth = "#Zzeipoth" + SYS(2015) && TR 1044604 DEC-29-2009 BR
4298
4299 * --- TR 1048571 9/9/10 CM
4300 lcipotd = "#Zzeipotd" + SYS(2015)
4301 * === TR 1048571 9/9/10 CM
4302
4303 lcTempIPOTH = GetUniqueFileName() && *--- TR 1043191 23-Oct-2009 JK ===
4304
4305 With This
4306 *-- TR 1044604 DEC-29-2009 BR
4307 .cSQLTempTable=""
4308 *--- TR 1043191 23-Oct-2009 JK last column must not be a memo ---
4309*!* IF .GenerateSQLTempTable(pceipoTH)
4310*!* IF .PopulateSQLTempTable(pceipoTH)
4311 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_pkey ===
4312 *--- TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query to avoid toomany columns issue
4313 lcFldsList = .GetFldsList("zzeipoth", "zzeoprth")
4314
4315 lcCmnd = "Select " + lcFldsList + ", th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)"
4316 &lcCmnd
4317
4318*!* Select th.*, th.pkey As ipo_pkey, Chr(1) As dummy From (pceipoTH) th Into Cursor (lcTempIPOTH)
4319 *=== TR 1077093 25-Mar-2014 SMeenraja Used only required fields list in query
4320 IF .GenerateSQLTempTable(lcTempIPOTH)
4321
4322 IF .PopulateSQLTempTable(lcTempIPOTH)
4323 Use In Select(lcTempIPOTH)
4324 *=== TR 1043191 23-Oct-2009 JK ===
4325 lcSQL = "SELECT * INTO " + lcipoth + " FROM " + .cSQLTempTable
4326 llRetVal = llRetVal And v_SqlExec(lcSQL)
4327 ENDIF
4328 ENDIF
4329 *== TR 1044604 DEC-29-2009 BR
4330
4331 * --- TR 1048571 9/9/10 CM
4332 *--- TechRec 1058716 17-Jan-2012 jisingh Added ipo_fkey ===
4333 *--- TR 1061877 08-09-2012 RKI ---* Customer added.
4334 lcSQL = "Select *, pkey As ipo_pkey ,SPACE(7) as customer from zzeipotd where 1=0"
4335 llRetVal = v_SqlExec(lcSQL, "tcTmpDtls")
4336 llRetVal = llRetVal And .MakeCursorWritable("tcTmpDtls", "tcIpoDtls")
4337 .CreateCursorStructure("tcIpoDtls", , "tcFinalDtls")
4338 *--- TechRec 1058716 17-Jan-2012 jisingh ---
4339 *.ScatterGather(pceipoTD, "tcIpoDtls")
4340 Select td.*, td.pkey As ipo_pkey From (pceipoTD) td Into Cursor __tceipoTD
4341 .ScatterGather("__tceipoTD", "tcIpoDtls")
4342 *=== TechRec 1058716 17-Jan-2012 jisingh ===
4343
4344 SELECT tcIpoDtls
4345 LOCATE
4346 SELECT * INTO CURSOR tcFinalDtls FROM tcIpoDtls
4347 .cSQLTempTable=""
4348 IF .GenerateSQLTempTable("tcFinalDtls")
4349 IF .PopulateSQLTempTable("tcFinalDtls")
4350 lcSQL = "SELECT * INTO " + lcipotd + " FROM " + .cSQLTempTable
4351 llRetVal = llRetVal And v_SqlExec(lcSQL)
4352 ENDIF
4353 ENDIF
4354 * === TR 1048571 9/9/10 CM
4355
4356 *--- IPOTH -> OPRTH
4357 *--- lcCalFldsOPR_SQL : fields need calculation or map or not to be taken in data copy - [each colum needs to be like 'term_type']
4358 *--- lcCalFldsOPR : fields need calculation or map or constant values
4359 *--- lcCalFldsOPR_val : values :- calculation or map field or constant values
4360
4361 *--- for example if term_type field data will go to terms_type field and blank term_type
4362 *!* lcCalFldsOPR_SQL = "'term_type','terms_type'"
4363 *!* lcCalFldsOPR = "term_type, terms_type"
4364 *!* lcCalFldsOPR_val = "' ',term_type"
4365 lcCalFldsOPR_SQL = "'PROC_855'"
4366 lcCalFldsOPR = "PROC_855"
4367 lcCalFldsOPR_val = "' '"
4368 lcFlds = ""
4369 lcValues = ""
4370
4371 lcOPR_TMP = pceoprth
4372 *- 1030497 02/29/08 TT
4373 *--llRetVal = llRetVal AND .GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', 'zzeipoth', ;
4374 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4375
4376 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4377 llRetVal = llRetVal AND .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprth', lcipoth, ;
4378 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4379 *- 1030497 02/29/08 TT
4380 *--- 1034481 set correct flag value 'P' for Proc_855
4381 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + ")" + ;
4382 " SELECT " + lcValues + " from " + lcipoth + " h " + lcFilter + ;
4383 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' "
4384 llRetVal = llRetVal And v_SqlExec(lcSQL)
4385
4386 *--- IPOTD -> OPRTD
4387 lcCalFldsOPR_SQL = ""
4388 lcCalFldsOPR = ""
4389 lcCalFldsOPR_val = ""
4390 lcFlds = ""
4391 lcValues = ""
4392
4393 lcOPR_TMP = pceoprtd
4394 *- 1030497 02/29/08 TT
4395 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', 'zzeipotd', ;
4396 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4397 * --- TR 1048571 9/9/10 --- Changed zzeipotd to lcipotd
4398 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtd', lcipotd, ;
4399 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4400 *- 1030497 02/29/08 TT
4401 *- 1034481 10/03/08 YIK
4402 *- Calculate if there are 855(o) to be sent and set up plHas855ToSend
4403 DECLARE la855Cnt[1]
4404 la855Cnt[1] = 0
4405 lcSQL = "select COUNT(*) from " + pceipoTH + " h " + ;
4406 " WHERE h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' " + ;
4407 " INTO ARRAY la855Cnt"
4408 &lcSQL
4409
4410 plHas855ToSend = (la855Cnt[1] > 0)
4411
4412 IF plHas855ToSend
4413 *--- 1034481 set correct flag value 'P' for Proc_855
4414 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4415 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4416 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4417 " SELECT " + lcValues + " from " + lcipotd + " d where exists " + ;
4418 " ( select * from " + lcipoth + " h " + lcFilter + ;
4419 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'Y' and h.pkey = d.fkey )"
4420
4421 llRetVal = llRetVal And v_SqlExec(lcSQL)
4422
4423 *--- price : if zzeipocr.price_flg = 'S' then zzoprsd.price needs to be replaced by zzoprsd.org_price
4424 lcSQL = "UPDATE d SET price = org_price from " + lcOPR_TMP + " d join " + pceoprth + " h " + ;
4425 " on d.fkey = h.pkey "
4426 llRetVal = llRetVal And v_SqlExec(lcSQL)
4427
4428 *--- IPOTC -> OPRTC
4429 lcOPR_TMP = pceoprtc
4430 lcCalFldsOPR_SQL = ""
4431 lcCalFldsOPR = ""
4432 lcCalFldsOPR_val = ""
4433 lcFlds = ""
4434 lcValues = ""
4435
4436 *- 1030497 02/29/08 TT
4437 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4438 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4439 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprtc', 'zzeipotc', ;
4440 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4441 *- 1030497 02/29/08 TT
4442 *--- 1034481 set correct flag value 'P' for Proc_855
4443 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4444 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4445 " SELECT " + lcValues + " from zzeipotc c where exists " + ;
4446 " (select * from " + lcipoth + " h " + lcFilter + ;
4447 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = c.fkey )"
4448
4449 llRetVal = llRetVal And v_SqlExec(lcSQL)
4450
4451 *--- IPOTA -> OPRTA
4452 lcOPR_TMP = pceoprta
4453 lcCalFldsOPR_SQL = ""
4454 lcCalFldsOPR = ""
4455 lcCalFldsOPR_val = ""
4456 lcFlds = ""
4457 lcValues = ""
4458
4459 *- 1030497 02/29/08 TT
4460 *--llRetVal = llRetVal And .GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4461 *-- lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4462 llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, 'zzeoprta', 'zzeipota', ;
4463 lcCalFldsOPR_SQL, lcCalFldsOPR, lcCalFldsOPR_val)
4464 *- 1030497 02/29/08 TT
4465 *--- 1034481 set correct flag value 'P' for Proc_855
4466
4467 *--- 1042063 10/12/09 CM
4468 *--- We're unconditionally going to remove characters greater than 25,
4469 * for 855 address1,address2 fields since max field size is 25.
4470 lcValues = STRTRAN(lcValues, "ADDRESS1", "SUBSTRING(ADDRESS1, 1, 25)")
4471 lcValues = STRTRAN(lcValues, "ADDRESS2", "SUBSTRING(ADDRESS2, 1, 25)")
4472 *=== 1042063 10/12/09 CM
4473
4474 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4475 lcSQL = "INSERT INTO " + lcOPR_TMP + " ( " + lcFlds + " ) " + ;
4476 " SELECT " + lcValues + " from zzeipota a where exists " + ;
4477 " (select * from " + lcipoth + " h " + lcFilter + ;
4478 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = a.fkey )"
4479
4480 llRetVal = llRetVal And v_SqlExec(lcSQL)
4481
4482 *--- sysnotes - zzeoprth
4483 lcOPR_TMP = pceoprth_notes
4484 *--- 1034481 set correct flag value 'P' for Proc_855
4485 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4486 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4487 " SELECT * from sysnotes n where table_name = 'zzeipoth' and exists " + ;
4488 " (select * from " + lcipoth + " h " + lcFilter + ;
4489 " AND h.Errs_flg_h <> 'Y' and h.Req_855 = 'R' and h.Proc_855 <> 'P' and h.pkey = n.fkey )"
4490
4491 llRetVal = llRetVal And v_SqlExec(lcSQL)
4492
4493 *--- sysnotes - zzeoprtd
4494 lcOPR_TMP = pceoprtd_notes
4495 *--- 1034481 set correct flag value 'P' for Proc_855
4496 *-- TR 1044604 DEC-29-2009 BR - CHANGED zzeipoth for lcipoth
4497 * --- TR 1048571 9/9/10 CM --- Changed zzeipotd to lcipotd
4498 lcSQL = "INSERT INTO " + lcOPR_TMP + ;
4499 " SELECT * from sysnotes n where table_name = 'zzeipotd' and exists " + ;
4500 " (select * from " + lcipoth + " h join " + lcipotd + " d on h.pkey = d.fkey" + lcFilter + ;
4501 " AND h.Errs_flg_h <> 'Y' and d.Errs_flg_d <> 'Y' and h.Req_855 = 'R' " + ;
4502 " and h.Proc_855 <> 'P' and d.pkey = n.fkey )"
4503
4504 llRetVal = llRetVal And v_SqlExec(lcSQL)
4505 *- 1034481 10/03/08 YIK
4506 ENDIF &&plHas855ToSend
4507
4508 *-- TR 1044604 DEC-29-2009 BR
4509 lcSQL = "DROP TABLE " + lcipoth
4510 v_SqlExec(lcSQL)
4511 *== TR 1044604 DEC-29-2009 BR
4512 Endwith
4513
4514 * --- TR 1048571 9/9/10 CM
4515 USE IN SELECT("tcIpoDtls")
4516 USE IN SELECT("tcFinalDtls")
4517 USE IN SELECT("tcTmpDtls")
4518 * === TR 1048571 9/9/10 CM
4519
4520 Select(lnOldSelect)
4521 Return llRetVal
4522 Endproc
4523
4524
4525 *----------------------------------------------------------------------------------------
4526
4527 Procedure ResetPkey_OPRTmpTable
4528 Lparameters pcRefOPRTH_IPOTH, pceoprth, pceoprtd, pceoprtc, pceoprta, pceoprth_notes, pceoprtd_notes
4529
4530 Local llRetVal, lnOldSelect, lnRecCount, lcSQL, lcOPR_TMP, lnMaxPkey, lnPKey, lcOPR_H_PKEY
4531 Local lcOPR_D_PKEY, lcOPR_C_PKEY, lcOPR_A_PKEY, lcOPR_HN_PKEY, lcNewPkeyCol_TH,lcNewPkeyCol_TD
4532
4533 lnOldSelect = Select()
4534 llRetVal = .T.
4535 lcOPR_TMP = pceoprth
4536 lnRecCount = 0
4537 lnMaxPkey = 0
4538 lcUnique = Sys(2015)
4539
4540 lcOPR_H_PKEY = "#IPO_H" + lcUnique
4541 lcOPR_D_PKEY = "#IPO_D" + lcUnique
4542 lcOPR_C_PKEY = "#IPO_C" + lcUnique
4543 lcOPR_A_PKEY = "#IPO_A" + lcUnique
4544 lcOPR_HN_PKEY = "#IPO_HN" + lcUnique
4545 lcOPR_DN_PKEY = "#IPO_DN" + lcUnique
4546 lcNewPkeyCol_TH = "PKEY_OPRTH"
4547 lcNewPkeyCol_TD = "PKEY_OPRTD"
4548 With This
4549 *-- lcOPR_H_PKEY value will be need when proc_855 flag will be updated.
4550 *-- This ipo.pkey and opr.pkey relationship is vital for easy update of flag zzeipoth.proc_855
4551 *--- Create temp table IPO_OPR_H (IPO_PKEY, OPR_PKEY)
4552 pcRefOPRTH_IPOTH = lcOPR_H_PKEY
4553 *- 1030497 02/29/08 TT
4554 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4555 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth, "sysnotes", lcOPR_H_PKEY, lcNewPkeyCol_TH)
4556 *- 1030497 02/29/08 TT
4557
4558 *--- fkey updates for all chield tables
4559 *--- ipotd -> oprtd : fkey
4560 lcOPR_TMP = pceoprtd
4561 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4562 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4563 llRetVal = llRetVal And v_SqlExec(lcSQL)
4564
4565 *--- ipota -> oprta : fkey
4566 lcOPR_TMP = pceoprta
4567 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4568 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4569
4570 llRetVal = llRetVal And v_SqlExec(lcSQL)
4571
4572 *--- ipotc -> oprtc : fkey
4573 lcOPR_TMP = pceoprtc
4574 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + " FROM " + lcOPR_TMP + " H JOIN " +;
4575 lcOPR_H_PKEY + " P ON H.fkey = P.pkey"
4576 llRetVal = llRetVal And v_SqlExec(lcSQL)
4577
4578 *-- sysnotes :
4579 *-- table_name
4580 lcOPR_TMP = pceoprth_notes
4581 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TH + ", table_name = 'ZZEOPRTH' FROM " + ;
4582 lcOPR_TMP + " H JOIN " + lcOPR_H_PKEY + " P ON H.fkey = P.pkey "
4583 llRetVal = llRetVal And v_SqlExec(lcSQL)
4584
4585 *-- update detail pkey
4586 *- 1030497 02/29/08 TT
4587 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4588 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd, "zzeoprtd",lcOPR_D_PKEY, lcNewPkeyCol_TD)
4589 *- 1030497 02/29/08 TT
4590
4591 *-- sysnotes : update table_name, fkey
4592 lcOPR_TMP = pceoprtd_notes
4593 lcSQL = "UPDATE H SET fkey = P." + lcNewPkeyCol_TD + ", table_name = 'ZZEOPRTD' FROM " + ;
4594 lcOPR_TMP + " H JOIN " + lcOPR_D_PKEY + " P ON H.fkey = P.pkey "
4595 llRetVal = llRetVal And v_SqlExec(lcSQL)
4596
4597 *--- update header notes pkey
4598 *- 1030497 02/29/08 TT
4599 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4600 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprth_notes, "sysnotes", lcOPR_HN_PKEY)
4601 *- 1030497 02/29/08 TT
4602 *--- update detail notes pkey
4603 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4604 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtd_notes, "sysnotes", lcOPR_DN_PKEY)
4605
4606 *-- update pkey
4607 *- 1030497 02/29/08 TT
4608 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4609 *--llRetVal = llRetVal And .MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4610
4611 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprtc, "zzeoprtc", lcOPR_C_PKEY)
4612 llRetVal = llRetVal And .oCopyUtil.MassPkeyUpdate(pceoprta, "zzeoprta", lcOPR_A_PKEY)
4613 *- 1030497 02/29/08 TT
4614
4615 *--- drop all temp tables
4616 *-- do not drop table lcOPR_H_PKEY we need this to update PROC_855 FLAG
4617 *- 1030497 02/29/08 TT
4618 *--.dropTempTable(lcOPR_D_PKEY,.T.)
4619 *--.dropTempTable(lcOPR_C_PKEY,.T.)
4620 *--.dropTempTable(lcOPR_A_PKEY,.T.)
4621 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4622 *--.dropTempTable(lcOPR_HN_PKEY,.T.)
4623
4624 .oCopyUtil.dropTempTable(lcOPR_D_PKEY,.T.)
4625 .oCopyUtil.dropTempTable(lcOPR_C_PKEY,.T.)
4626 .oCopyUtil.dropTempTable(lcOPR_A_PKEY,.T.)
4627 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4628 .oCopyUtil.dropTempTable(lcOPR_HN_PKEY,.T.)
4629 *- 1030497 02/29/08 TT
4630
4631 Endwith
4632
4633 Select(lnOldSelect)
4634 Return llRetVal
4635 Endproc
4636
4637 *----------------------------------------------------------------------------------------
4638
4639 Procedure UpdateOPRTempHDRDivisionFromDtl
4640 Lparameters pcRefeoprth,pcRefeoprtd
4641
4642 Local llRetVal, lnOldSelect
4643 llRetVal = .T.
4644 lnOldSelect = Select()
4645 lcSQL = "UPDATE h SET division = d.division FROM " + pcRefeoprth + " h JOIN " + pcRefeoprtd + " d on h.pkey = d.fkey "
4646 llRetVal = llRetVal And v_SqlExec(lcSQL)
4647 Select(lnOldSelect)
4648 Return llRetVal
4649
4650 Endproc
4651
4652 *----------------------------------------------------------------------------------------
4653
4654 Procedure Launch855Process
4655 Lparameters pcRefeoprth,pcRefeoprtd,pcRefeoprtc,pcRefeoprta,pcRefeoprth_notes,pcRefeoprtd_notes, pczzeiPOtWhse
4656 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4657 Local llRetVal, lnOldSelect
4658 lnOldSelect = Select()
4659 llRetVal = .T.
4660
4661 Local lo855
4662 Local lc855DataTbls, lc855Msg
4663 lcFilterCriteria = ""
4664 lo855 = Newobject("BPO855OProcess","clsoprpr.prg")
4665 llRetVal = (Vartype(lo855) = 'O')
4666 lc855Msg = ""
4667
4668 If llRetVal
4669 *--- TR 1037976 JAN-22-2008 BR
4670 *lo855 = This
4671 lo855.oLog = THIS.oLog
4672 *=== TR 1037976 JAN-22-2008 BR
4673 lo855.oFrmProgressBar = This.oFrmProgressBar
4674 Endif
4675 *--- TechRec 1058716 17-Jan-2012 jisingh Added pczzeiPOtWhse ===
4676 lc855DataTbls = pcRefeoprth + "," + pcRefeoprtd + "," + pcRefeoprtc + "," + ;
4677 pcRefeoprta + "," + pcRefeoprth_notes + "," + pcRefeoprtd_notes + "," + pczzeiPOtWhse
4678 llRetVal = llRetVal And lo855.ProcessoPR(lcFilterCriteria, @lc855Msg, lc855DataTbls, This.lUserInterface)
4679 This.oHostProcess.c855Msg = lc855Msg
4680 Select(lnOldSelect)
4681 Return llRetVal
4682
4683 Endproc
4684
4685 *----------------------------------------------------------------------------------------
4686
4687 Procedure Update855ProcFlag
4688 Lparameters pceoprth, pceipoTH, pcOPRTH_IPOTH
4689
4690 Local llRetVal, lnOldSelect, lcSQL, lcCursor, loCursor
4691 lnOldSelect = Select()
4692 llRetVal = .T.
4693 lcCursor = Sys(2015)
4694 *--- pcIPOTH_OPRTH has pkey of ipo pkey column is PKEY and OPR pkey column is PKEY_OPRTH, success
4695 *--- 1034481 set correct flag value 'P' for Proc_855
4696 *- 1034481 10/03/08 YIK
4697 *- Also populate error flag and error message from zzeoprth to the 850(i)
4698 *- otherwise 850(i) goes through while the 855(o) errors out.
4699 lcSQL = "Select t.pkey, o.proc_855, COALESCE(th.errs_flg_h, ' ') errs_flg_h, " ;
4700 + " COALESCE(th.errs_msg_h, '') errs_msg_h " ;
4701 + " from " + pceoprth + " o join " + pcOPRTH_IPOTH + ;
4702 " t on o.pkey = t.pkey_oprth" + ;
4703 " LEFT JOIN zzeoprth th " + ;
4704 " on th.pkey = t.pkey_oprth"
4705
4706 llRetVal = llRetVal And v_SqlExec(lcSQL, lcCursor)
4707 If llRetVal
4708 Select (lcCursor)
4709 SCAN
4710 Scatter Name loCursor Memo
4711 DO CASE
4712 CASE proc_855 = 'P'
4713 *- 1014298 12/02/05 YIK, NH
4714 *- it was ..proc_855 WITH 'Y'
4715 Replace proc_855 With 'P' For pkey = loCursor.pkey In (pceipoTH)
4716 CASE errs_flg_h = 'Y'
4717 REPLACE errs_flg_h WITH 'Y', ;
4718 errs_msg_h WITH errs_msg_h + ;
4719 " ---- 855(o) process ----" + CRLF + ;
4720 ALLTRIM(loCursor.errs_msg_h) + CRLF ;
4721 For pkey = loCursor.pkey In (pceipoTH)
4722 OTHERWISE
4723 ENDCASE
4724 Endscan
4725 Endif
4726 *= 1034481
4727 Select(lnOldSelect)
4728 Return llRetVal
4729
4730 Endproc
4731
4732 *----------------------------------------------------------------------------------------
4733
4734 *--- TechRec 1018193 03-Nov-2006 kpattabiraman ---
4735
4736 *!* 1. The 850 process resolves UPC/Cust SKU to BC SKU. Let's say our item (zzeipotd) is style '9040' color 'RED'.
4737 *!* In this case label must be with empty.
4738
4739 *!* 2. The 850 EDi Control must have setting "Resolve label" = 'Y' and a label entered (let's say label = 'WM')
4740
4741 *!* 3. If you find that the BC SKU exists in the multiUPC table for style '9040' color 'RED' (or search by the
4742 *!* UPC_NUM) and there is an active detail with label 'WM', it means that there is a corresponding range style for
4743 *!* style '9040' color 'RED' label 'WM'.
4744
4745 *!* 4. We already have the range style resolution functionality in the 850 process - see method RangeStyle(), but
4746 *!* to match the current item (style '9040' color 'RED') with the range style (style '9040' color 'RED' label 'WM')
4747 *!* we need to populate this label into zzeipotd. So thats all we have to do just populate the lable in zzeipotd.
4748
4749 Procedure CheckMultiUPC
4750 Lparameters tcEiPOth, tcEiPOtd
4751
4752 Local llRetVal, lnSelect, lcSQL, lcWorkAlias, lnPKey, lcLbl_code
4753
4754 llRetVal = True
4755 lnSelect = Select()
4756
4757 With This
4758
4759 lcWorkAlias = GetUniqueFileName()
4760
4761 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4762 *-- Change h.division to d.division
4763 SELECT d.pkey, ;
4764 h.customer, ;
4765 d.division, ;
4766 d.upc ;
4767 FROM tceipoth h ;
4768 JOIN tceipotd d ;
4769 ON h.pkey = d.fkey ;
4770 INTO ;
4771 CURSOR (lcworkAlias)
4772
4773 llRetVal = llRetVal And .GenerateSQLTempTable(lcWorkAlias)
4774 llRetVal = llRetVal And .PopulateSQLTempTable(lcWorkAlias)
4775 llRetVal = llRetVal And Not Empty(.cSQLTempTable)
4776 lcTempTbl = Iif(llRetVal, .cSQLTempTable, "")
4777
4778 If llRetVal
4779
4780 *--- TechRec 1021803 12-Feb-2007 kpattabiraman ---
4781 *-- Included 'V' in the condition of pocr.resv_label
4782 *--- TR 1031442 17-Jun-2008 Goutam. Changed to zzeipocr_expl from zzeipocr in the following sql.
4783 *--- TechRec 1030517 25-Aug-2010 jisingh Replaced zzeipocr_expl With This.c850Control ===
4784
4785 lcSql = " SELECT upcd.lbl_code, t.* " + ;
4786 " FROM " + lcTempTbl + " t " + ;
4787 " JOIN zzemupch upch " + ;
4788 " ON upch.upc_num+upch.chk_digit = t.upc " + ;
4789 " JOIN zzemupcd upcd " + ;
4790 " ON upch.pkey = upcd.fkey " + ;
4791 " AND upcd.active_ok = 'Y' " + ;
4792 " JOIN " + This.c850Control + " pocr " + ;
4793 " ON pocr.customer = t.customer " + ;
4794 " AND pocr.division = t.division " + ;
4795 " AND pocr.lbl_code = upcd.lbl_code " + ;
4796 " AND pocr.resv_label IN ('Y','V') "
4797
4798 lcWorkAlias = GetUniqueFileName()
4799
4800 llRetVal = llRetVal And v_SqlExec(lcSQL, lcWorkAlias)
4801
4802 If Reccount(lcWorkAlias) > 0
4803 Select (tcEiPOtd)
4804 Scan
4805 lnPKey = pkey
4806
4807 Select(lcWorkAlias)
4808 Locat For pkey = lnPKey
4809
4810 If Found()
4811 lcLbl_code = lbl_code
4812 Select (tcEiPOtd)
4813 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
4814 *REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH true
4815 REPLACE lbl_code WITH lcLbl_Code, MultiUPC WITH 'Y'
4816 *=== TechRec 1021803 09-Feb-2007 kpattabiraman ===
4817 Endif
4818
4819 Select (tcEiPOtd)
4820 Endscan
4821 Endif
4822
4823 Endif
4824
4825 .TableClose(lcWorkAlias)
4826
4827 Endwith
4828
4829 Select (lnSelect)
4830 Return llRetVal
4831 Endproc
4832 *=== TechRec 1018193 03-Nov-2006 kpattabiraman ===
4833
4834 *----------------------------------------------------------------------------------------
4835
4836 Procedure RangeStyle
4837 Lparameters pcTransHeader, pcTransDetail, tcTransSAC, pceipoCR &&, pcViewTransDetail
4838 Local llRetVal, lnOldSelect, lcErrs_Msg
4839 llRetVal = .T.
4840 lnOldSelect = Select()
4841
4842 *****************************************************************************
4843 * 1st Getting all range style (hdr/dtl) that relate to the
4844 * passing order line for this run
4845
4846 *--- TR 1038376 05-May-2009 Goutam
4847 LOCAL lctmpCursor
4848 lctmpCursor = GetUniqueFileName()
4849
4850 *--- TR 1040364 14-May-2009 Goutam. Deleted following line
4851 *replace rng_price WITH org_price FOR EMPTY(rng_style) AND EMPTY(rng_price) IN (pcTransDetail)
4852
4853 * TR 1048519 27-JUL-2011 KISHORE - added h.ord_type
4854 * TR 1059142 FH - adding h.ord_type to the group by clause
4855 *--- TR 1088126 2-JUL-2015 Venuk -- Added 'as price_code' else MAX(h.price_code) will be max_price_Code ===
4856 SELECT d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) as price_code, h.ord_type FROM (pcTransHeader) h ;
4857 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4858 WHERE d.errs_flg_d <> 'Y' ;
4859 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type;
4860 INTO CURSOR __TmpCursor
4861
4862 .cSQLTempTable=""
4863 If .GenerateSQLTempTable('__TmpCursor')
4864 If .PopulateSQLTempTable('__TmpCursor')
4865 If !Empty(.cSQLTempTable)
4866 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4867 lcSqlString = "Update " + .cSQLTempTable + ;
4868 " Set price_code = coalesce((Select Top 1 price_code " + ;
4869 " From zzxcslsr " + ;
4870 " Where Customer = h.customer " + ;
4871 " and (Store = h.store or Store = '') " + ;
4872 " and (Division = h.division or Division = '') " + ;
4873 " and (Department = h.department or Department = '') " + ;
4874 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4875 " and price_code <> '' " + ;
4876 " order by rank_seq),'') " + ;
4877 " From " + .cSQLTempTable + " h"
4878
4879 llRetVal = v_sqlExec(lcSqlString)
4880
4881 *- TR 1056061 FH 08/17/11 - if price_code is still empty, then we take it from zzocntrc
4882 lcSqlString = "UPDATE " + .cSQLTempTable + ;
4883 " Set price_code = c.price_code "+;
4884 " From " + .cSQLTempTable + " h "+;
4885 " , zzocntrc c "+;
4886 " Where h.division = c.division " +;
4887 " and h.price_code = '' "
4888 llRetVal = v_sqlExec(lcSqlString)
4889 *- TR 1056061 FH 08/17/11
4890
4891
4892 IF llRetVal
4893 lcSqlString = "Select * from " + .cSQLTempTable
4894 llRetVal = v_sqlExec(lcSqlString, lcTmpCursor)
4895
4896 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory.
4897 * TR 1048519 27-JUL-2011 KISHORE - added ord_type
4898*!* lcSqlString = "UPDATE h " + ;
4899*!* " SET price_code = c.price_code " + ;
4900*!* " From " + pcTransheader + " h join " + pcTransdetail + " d " + ;
4901*!* " on d.fkey=h.pkey join " + lcTmpCursor + " c " + ;
4902*!* " on d.division = c.division " + ;
4903*!* " And d.customer = c.customer " + ;
4904*!* " And h.Store = c.Store " + ;
4905*!* " And h.department = c.department " + ;
4906*!* " And h.ord_type = c.ord_type " + ;
4907*!* "Where d.errs_flg_d <> 'Y' "
4908
4909 lcSqlString = "UPDATE h " + ;
4910 " SET price_code = c.price_code " + ;
4911 " From " + pcTransheader + " h " + ;
4912 " join " + lcTmpCursor + " c " + ;
4913 " on h.division = c.division " + ;
4914 " And h.customer = c.customer " + ;
4915 " And h.Store = c.Store " + ;
4916 " And h.department = c.department " + ;
4917 " And h.ord_type = c.ord_type " + ;
4918 "Where h.division <> '' and h.errs_flg_h <> 'Y' "
4919
4920 *- TR 1057373 FH - took out join to detail, for large details we were runnining out of memory
4921
4922 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
4923 ENDIF
4924
4925 IF llRetVal
4926 *-1061331 FH - simpilifed update query
4927 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'"
4928 *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 ;
4929 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4930 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4931 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4932
4933 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 ;
4934 from (pcTransHeader) h WHERE EMPTY(h.price_code) AND h.errs_flg_h <> 'Y'
4935
4936 *-1061331 FH - Do we need to update detail?, Header already is marked with error, it'll just mark all Detail with error.
4937 * TR 1059142 FH - added to where clause "AND h.errs_flg_h <> 'Y'" and also changed error message again
4938 *- TR 1054873 FH - changed error message
4939 &&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 ;
4940 &&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 ;
4941 *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 ;
4942 from (pcTransHeader) h join (pcTransDetail) d on d.fkey = h.pkey ;
4943 join (lcTmpCursor) t on t.Customer = d.Customer AND t.Division = d.Division AND t.Store = h.Store AND t.Department = h.Department ;
4944 WHERE EMPTY(h.price_code) AND EMPTY(d.rng_style) AND h.errs_flg_h <> 'Y'
4945 ENDIF
4946
4947 endif
4948 endif
4949 ENDIF
4950
4951
4952 *--- TR 1088126 2-JUL-2015 Venuk
4953 IF This.oBPOSalesOrder.lRslv_pricecode_cssld
4954 SELECT CRS_pkey, d.pkey as dtlpkey, d.Customer, d.Division, h.Store, h.Department, MAX(h.price_code) price_code, h.ord_type, ;
4955 d.style, d.color_code, d.lbl_code, d.dimension ;
4956 FROM (pcTransHeader) h ;
4957 JOIN (pcTransDetail) d ON d.fkey = h.pkey ;
4958 WHERE d.errs_flg_d <> 'Y' ;
4959 GROUP BY d.Customer, d.Division, h.Store, h.Department , h.ord_type, d.pkey ;
4960 INTO CURSOR __TmpCursor
4961
4962 .cSQLTempTable=""
4963 If .GenerateSQLTempTable('__TmpCursor')
4964 If .PopulateSQLTempTable('__TmpCursor')
4965 If !Empty(.cSQLTempTable)
4966
4967 lcSqlString = "Update " + .cSQLTempTable + ;
4968 " Set CRS_pkey = coalesce((Select Top 1 pkey " + ;
4969 " From zzxcslsr " + ;
4970 " Where Customer = h.customer " + ;
4971 " and (Store = h.store or Store = '') " + ;
4972 " and (Division = h.division or Division = '') " + ;
4973 " and (Department = h.department or Department = '') " + ;
4974 " and (Ord_type = h.ord_type or Ord_type = '') " + ;
4975 " and price_code <> '' " + ;
4976 " order by rank_seq),'') " + ;
4977 " From " + .cSQLTempTable + " h"
4978 llRetVal = v_sqlExec(lcSqlString)
4979
4980 lcSqlString = ;
4981 " Select r.dtlpkey as dtlpkey, " + ;
4982 " case when Coalesce(d.price_code,'')='' then h.price_code else d.price_code end as price_Code " + ;
4983 " from zzxcslsr h " + ;
4984 " join "+ .cSQLTempTable + " r" + ;
4985 " on h.pkey = r.CRS_pkey " + ;
4986 " join zzxscolr c " + ;
4987 " on c.division = h.division " + ;
4988 " and c.style = r.style" + ;
4989 " and c.color_Code = r.color_Code " + ;
4990 " and c.lbl_Code = r.lbl_code " + ;
4991 " and c.dimension = r.dimension " + ;
4992 " join zzxcslsd d " + ;
4993 " on h.pkey = d.fkey " + ;
4994 " and h.group_Type = d.group_type " + ;
4995 " and d.group_code = " + ;
4996 " case when d.Group_type='A' then c.Group_Code1 " + ;
4997 " when h.Group_type='B' then c.Group_Code2 " + ;
4998 " when h.Group_type='C' then c.Group_Code3 " + ;
4999 " when h.Group_type='D' then c.Group_Code4 " + ;
5000 " when h.Group_type='E' then c.Group_Code5 " + ;
5001 " when h.Group_type='F' then c.Group_Code6 " + ;
5002 " when h.Group_type='G' then c.Group_Code7 " + ;
5003 " when h.Group_type='H' then c.Group_Code8 " + ;
5004 " when h.Group_type='I' then c.Group_Code9 " + ;
5005 " when h.Group_type='J' then c.Group_Code10 " + ;
5006 " when h.Group_type='K' then c.Group_Code11 " + ;
5007 " when h.Group_type='L' then c.Group_Code12 " + ;
5008 " when h.Group_type='M' then c.Group_Code13 end "
5009
5010 llRetVal = v_sqlExec(lcSqlString, "tcPriceCode")
5011
5012 If(USED("tcPriceCode"))
5013 SELECT tcPriceCode
5014 INDEX on dtlpkey TAG dtlpkey
5015 llRetval = .SetRelation("tcPriceCode", "dtlpkey", pcTransDetail,"pkey")
5016
5017 REPLACE ALL PRICE_CODE WITH tcPriceCode.price_Code IN (pcTransDetail)
5018
5019 Set Relation To
5020 USE IN tcPriceCode
5021 ENDIF
5022 UPDATE d SET d.errs_flg_d = 'Y', d.errs_msg_d = IIF(!EMPTY(d.errs_msg_d), d.errs_msg_d + CRLF + 'Invalid Price Code.','Invalid Price Code.') + CRLF ;
5023 from (pcTransDetail) d WHERE EMPTY(d.price_code) AND d.errs_flg_d <> 'Y'
5024
5025 ENDIF
5026 ENDIF
5027 ENDIF
5028 USE IN __TmpCursor
5029 ELSE
5030 UPDATE d SET price_code = h.price_code FROM (pcTransDetail) d inner join (pcTransHeader) h on h.pkey = d.fkey where d.price_code=''
5031 Endif
5032 *=== TR 1088126 2-JUL-2015 Venuk
5033
5034 .cSQLTempTable=""
5035
5036 *=== TR 1038376 05-May-2009 Goutam
5037
5038 * additional past for range style verification/explotion
5039 *-- TR 1023892 5-3-07 BR
5040 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5041 IF .lALLOW_RANGE_HDR_LABEL
5042 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5043 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5044 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 ;
5045 FROM (pcTransHeader) h, (pcTransDetail) d ;
5046 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5047 AND d.Errs_Flg_D= 'N' AND ;
5048 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5049 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5050 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5051 ELSE
5052 *=== TR 1023892 NH
5053 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5054 *--- TR 1038376 05-May-2009 Goutam Added , h.price_code, d.rng_price in the select list
5055 &&--- TechRec 1078967 11-Aug-2014 vkrishnamurthy === Added h.customer
5056 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5057 FROM (pcTransHeader) h, (pcTransDetail) d ;
5058 WHERE h.pkey = d.fkey ; && AND h.Errs_flg_h= "N" TR 1019697
5059 And d.Errs_Flg_D= "N" And ;
5060 Not EMPTY(h.price_code) AND ; && *--- TR 1038376 11-May-2009 Goutam
5061 d.rng_style= '' ; && none exploded range style (ONLY explode range style ONCE)
5062 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5063 ENDIF && TR 1023892 NH
5064
5065 With This
5066 .cSQLTempTable=""
5067 If .GenerateSQLTempTable('__TmpCursor')
5068 If .PopulateSQLTempTable('__TmpCursor')
5069 If !Empty(.cSQLTempTable)
5070
5071 .LogEntry("Exploding range style.")
5072 * Get range style header
5073 *- 1000984 9/11/03 YIK
5074 *- do not explode range styles type 'P'rint
5075 *- Added ..and h.rng_type <> 'P'
5076 *--- TR 1023892 5-3-07 NH - backend join zzeipocr, set customer label so that right component can be get.
5077 *-- TR 1040759 JUL-22-2009 BR CHANGED h.rng_lbl = t.cust_lbl to account for empty cust_lbl and populated lbl_code
5078 *- TR 1050589 12/13/10 FH - added check for zzxrangh.rng_bk = t.sizebucket to cursor __RangH
5079 IF .lALLOW_RANGE_HDR_LABEL
5080 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5081 "Where h.division= t.division and h.rng_style = t.style and "+;
5082 "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 "+;
5083 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5084 ELSE
5085 *=== TR 1023892 NH
5086 lcSQLString= "select h.* from zzxrangh h," + .cSQLTempTable + " t " +;
5087 "Where h.division= t.division and h.rng_style = t.style and "+;
5088 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5089 "h.rng_pack= t.dimension and h.rng_type <> 'P' and h.rng_bk = t.sizebucket"
5090 *= 1000984
5091 ENDIF && TR 1023892 NH
5092 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangH")
5093
5094 * TAN 31891 - JAZ - 5/20/02
5095 * llHaveRangeStyleToExplode= Recc("__RangH")>0
5096 llHaveRangeStyleToExplode= RecCount("__RangH")>0
5097 * End TAN 31891 - JAZ - 5/20/02
5098
5099 If llHaveRangeStyleToExplode
5100 * Get range style detail
5101 *- 1000984 9/11/03 YIK
5102 *- do not explode range styles type 'P'rint
5103 *- Added ..and h.rng_type <> 'P'
5104
5105 *--- TR 1038376 05-May-2009 Goutam
5106 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5107
5108 *- TR 1050589 12/13/10 FH - added t.sizebucket, and 'AND t.sizebucket = h.rng_bk'
5109 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
5110*!* lcSQLString= "Select d.*, t.org_price, t.sizebucket, " + ;
5111*!* " case t.price_code when 'A' then h.a_price " + ;
5112*!* " when 'B' then h.b_price " + ;
5113*!* " when 'C' then h.c_price " + ;
5114*!* " when 'D' then h.d_price " + ;
5115*!* " when 'E' then h.e_price " + ;
5116*!* " else h.a_price end rnghdr_Price " + ;
5117*!* "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5118*!* "join " + .cSQLTempTable + " t " +;
5119*!* "on h.division= t.division and h.rng_style = t.style and "+;
5120*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5121*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5122*!* " (case t.price_code when 'A' then h.a_price " + ;
5123*!* " when 'B' then h.b_price " + ;
5124*!* " when 'C' then h.c_price " + ;
5125*!* " when 'D' then h.d_price " + ;
5126*!* " when 'E' then h.e_price " + ;
5127*!* " else h.a_price end " + ;
5128*!* " <> t.org_price)" +;
5129*!* " AND t.sizebucket = h.rng_bk"
5130
5131 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5132 lcSqlString ="SELECT * FROM zzxrangd WHERE 1 = 0"
5133 llRetVal = llRetVal AND v_SqlExec(lcSQLString,"tcRngCursor")
5134 lcFieldList = UPPER(CreateFieldListFromCursor("tcRngCursor","D."))
5135 lcFieldList = STRTRAN(lcFieldList ,"D.A_PRICE"," coalesce(cs.a_price,d.a_price) as a_price ")
5136 lcFieldList = STRTRAN(lcFieldList ,"D.B_PRICE"," coalesce(cs.b_price,d.b_price) as b_price ")
5137 lcFieldList = STRTRAN(lcFieldList ,"D.C_PRICE"," coalesce(cs.c_price,d.c_price) as c_price ")
5138 lcFieldList = STRTRAN(lcFieldList ,"D.D_PRICE"," coalesce(cs.d_price,d.d_price) as d_price ")
5139 lcFieldList = STRTRAN(lcFieldList ,"D.E_PRICE"," coalesce(cs.e_price,d.e_price) as e_price ")
5140 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5141
5142 lcSQLString= "Select "+ lcFieldList + ", t.org_price, t.sizebucket, " + ;
5143 " case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5144 " when 'B' then coalesce(cs.b_price,h.b_price ) " + ;
5145 " when 'C' then coalesce(cs.c_price,h.c_price ) " + ;
5146 " when 'D' then coalesce(cs.d_price,h.d_price ) " + ;
5147 " when 'E' then coalesce(cs.e_price,h.e_price ) " + ;
5148 " else coalesce(cs.a_price,h.a_price) end rnghdr_Price " + ;
5149 "From zzxrangd d join zzxrangh h on d.fkey=h.pkey " +;
5150 " Left join zzxcsrgh cs "+ ;
5151 " on cs.hdrpkey = h.pkey "+ ;
5152 " and cs.dtlpkey = 0 " +;
5153 "join " + .cSQLTempTable + " t " +;
5154 "on h.division= t.division and h.rng_style = t.style and "+;
5155 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5156 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5157 " (case t.price_code when 'A' then coalesce(cs.a_price,h.a_price) " + ;
5158 " when 'B' then coalesce(cs.b_price,h.b_price) " + ;
5159 " when 'C' then coalesce(cs.c_price,h.c_price) " + ;
5160 " when 'D' then coalesce(cs.d_price,h.d_price) " + ;
5161 " when 'E' then coalesce(cs.e_price,h.e_price) " + ;
5162 " else coalesce(cs.a_price,h.a_price) end " + ;
5163 " <> t.org_price)" +;
5164 " AND t.sizebucket = h.rng_bk"+ ;
5165 " Where cs.customer = t.customer "
5166 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
5167 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangTmpD")
5168
5169 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5170 *- TR 1050589 12/13/10 FH - added check for r.sizebucket = d.sizebucket
5171 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) " + ;
5172 " from " +pcTransDetail + " d join " + pcTransHeader + " h on h.pkey = d.fkey join __RangTmpD r " + ;
5173 " on d.division= r.division and d.style = r.rng_style and " + ;
5174 "d.color_code = r.rng_color and d.lbl_code= r.Rng_lbl and d.org_price = r.org_price and " + ;
5175 " d.dimension= r.Rng_Pack " + ;
5176 " join zzeipocr c on c.division = d.division and h.customer = c.customer " + ;
5177 "where d.rng_type <> 'P' AND c.price_err = 'Y' AND r.sizebucket = d.sizebucket"
5178
5179 llRetVal = llRetVal and v_SqlExec(lcSQLString,,,.T.)
5180
5181 *- TR 1048790 FH 10/04/10
5182 * need a new updated __TmpCursor, because above we updated the errs_flag_d, errs_msg_d, now we need it in the cSQLTempTable.
5183 * took from above populates a SQLTempTable, if we udpated errs_flg_d above to Y, our new cSQLTempTable shouldn't have it.
5184 *- TR 1050589 12/13/10 FH - added d.sizebucket to cursor __TmpCursor
5185
5186 IF .lALLOW_RANGE_HDR_LABEL
5187 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 ;
5188 FROM (pcTransHeader) h, (pcTransDetail) d ;
5189 WHERE h.pkey = d.fkey ;
5190 AND d.Errs_Flg_D= 'N' AND ;
5191 Not EMPTY(h.price_code) AND ;
5192 d.rng_style= '' ;
5193 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5194 ELSE
5195 *--- TechRec 1084745 14-May-2015 jjanand === Added h.customer
5196 Select Distinct h.customer, d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, h.price_code, d.org_price, d.sizebucket ;
5197 FROM (pcTransHeader) h, (pcTransDetail) d ;
5198 WHERE h.pkey = d.fkey ;
5199 And d.Errs_Flg_D= "N" And ;
5200 Not EMPTY(h.price_code) AND ;
5201 d.rng_style= '' ;
5202 Order By 1,2,3,4,5 Into Cursor __TmpCursor
5203 ENDIF
5204
5205 .cSQLTempTable=""
5206 If .GenerateSQLTempTable('__TmpCursor')
5207 If .PopulateSQLTempTable('__TmpCursor')
5208 *- TR 1048790 FH 10/04/10
5209
5210 *--- TR 1040364 14-May-2009 Goutam. Replace rng_price with org_price
5211 *-- TR 1040759 JUN-29-2009 BR
5212 IF .lALLOW_RANGE_HDR_LABEL
5213 *- TR 1048790 FH 10/04/10 - removed price check
5214 *- TR 1050589 12/13/10 FH
5215 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5216*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5217*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5218*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5219*!* "h.rng_color= t.color_code and h.rng_lbl = (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5220*!* "h.rng_pack= t.dimension and h.rng_type <> 'P')"
5221 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5222*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " + ;
5223*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5224*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5225*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5226*!* "h.rng_color= t.color_code and h.rng_lbl = (CASE WHEN t.lbl_code <> '' THEN t.lbl_code ELSE t.cust_lbl END) and "+;
5227*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5228
5229 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " + ;
5230 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5231 "join " + .cSQLTempTable + " t " +;
5232 "on h.division= t.division and h.rng_style = t.style and "+;
5233 "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 "+;
5234 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5235 " t.sizebucket = h.rng_bk"+ ;
5236 " Left join zzxcsrgh cs "+ ;
5237 " on cs.hdrpkey = h.pkey "+ ;
5238 " and cs.dtlpkey = d.pkey " +;
5239 " and cs.customer = t.customer " + ;
5240 " where d.fkey in " +;
5241 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5242 "Where h.division= t.division and h.rng_style = t.style and "+;
5243 "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 "+;
5244 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5245 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5246 *- TR 1050589 12/13/10 FH
5247 ELSE
5248 *== TR 1040759 JUN-29-2009 BR
5249 *- TR 1048790 FH 10/04/10 - removed price check
5250 *- TR 1050589 12/13/10 FH
5251 * added check for t.sizebucket = h.rng_bk to cursor __RangD, also needed to join zzxrangh to get h.rng_bk
5252
5253*!* lcSQLString= "Select * From zzxrangd where fkey in " +;
5254*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5255*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5256*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5257*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' )"
5258*!*
5259 *--- TechRec 1078967 18-Aug-2014 vkrishnamurthy ---
5260*!* lcSQLString= "Select h.rng_bk, d.* From zzxrangd d " +;
5261*!* "Join zzxrangh h on d.fkey = h.pkey where fkey in " +;
5262*!* "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5263*!* "Where h.division= t.division and h.rng_style = t.style and "+;
5264*!* "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5265*!* "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5266
5267 lcSQLString= "Select h.rng_bk, "+ lcFieldList + " From zzxrangd d " +;
5268 "Join zzxrangh h on d.fkey = h.pkey "+ ;
5269 "join " + .cSQLTempTable + " t " +;
5270 "on h.division= t.division and h.rng_style = t.style and "+;
5271 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5272 "h.rng_pack= t.dimension and h.rng_type <> 'P' and " + ;
5273 " t.sizebucket = h.rng_bk"+ ;
5274 " Left join zzxcsrgh cs "+ ;
5275 " on cs.hdrpkey = h.pkey "+ ;
5276 " and cs.dtlpkey = d.pkey " +;
5277 " and cs.customer = t.customer " + ;
5278 " where fkey in " +;
5279 "(select h.pkey from zzxrangh h," + .cSQLTempTable + " t " +;
5280 "Where h.division= t.division and h.rng_style = t.style and "+;
5281 "h.rng_color= t.color_code and h.rng_lbl= t.lbl_code and "+;
5282 "h.rng_pack= t.dimension and h.rng_type <> 'P' AND t.sizebucket = h.rng_bk)"
5283 *=== TechRec 1078967 18-Aug-2014 vkrishnamurthy ===
5284 *- TR 1050589 12/13/10 FH
5285 ENDIF && TR 1040759 JUN-29-2009 BR
5286 *=== TR 1038376 05-May-2009 Goutam
5287 endif &&- TR 1048790 FH 10/04/10
5288 ENDIF &&- TR 1048790 FH 10/04/10
5289
5290 *= 1000984
5291 llRetVal = llRetVal and v_SqlExec(lcSQLString, "__RangD")
5292
5293 * turn Range detail to vertical (with sizebucket,size_desc)
5294 * have to explode in vertical format
5295 This.CreateCursorStructure("__TmpCursor", "__RangH", "__Range1")
5296 Select sizebucket, size_desc, total_qty From (pcTransDetail) ;
5297 WHERE 0=1 Into Cursor __Range2
5298 * tcRangeVer should have Rng_style,color,lbl,pack, rng_type
5299 * style,color_code,lbl_code,dimension, sizebucket, size_desc, total_qty
5300 This.CreateCursorStructure("__Range1", "__Range2", "tcRangeVer")
5301 If Used("__Range1")
5302 Use In __Range1
5303 Endif
5304 If Used("__Range2")
5305 Use In __Range2
5306 Endif
5307
5308 * Need to seek header for Rng_type, Rng_qty during ExplodeRangeRef
5309 Select __RangH
5310 Index On pkey Tag pkey
5311 Select __RangD
5312 Index On division+Style Tag DivStyle
5313 Select tcRangeVer
5314 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RangeSKU
5315 Set Order To RangeSKU
5316 This.ExplodeRangeRef("__RangH", "__RangD", "tcRangeVer")
5317
5318 *****************************************************************************
5319 * 2). Validate "Run"- type of range style. divisible by range header qty
5320 If llRetVal AND .ValidateRangeStyle("__RangH", pcTransDetail)
5321
5322 *****************************************************************************
5323 * 3). Explode range style only once good tran detail that have
5324 * matching range style. Vertical range style explosion
5325 *-- TR 1040759 JUN-29-2009 BR CHANGED: r.rng_lbl= d.lbl_code in the WHERE clause to account for cust_lbl
5326 *- TR 1050589 FH 12/14/10 - added r.sizebucket = d.sizebucket
5327 *- TR 1049244 FH 4/19/11 - added .lALLOW_RANGE_HDR_LABEL to determine if we should take cust_lbl or not
5328 Select Distinct d.pkey ;
5329 FROM __RangD r, (pcTransDetail) d ;
5330 WHERE d.Errs_Flg_D= "N" And ; &&no error
5331 d.rng_style= '' And ; &&never explode before
5332 r.division= d.division And r.rng_style = d.Style And ; && matching range
5333 r.rng_color= d.color_code And ;
5334 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
5335 r.rng_pack= d.Dimension AND r.rng_bk = d.sizebucket ;
5336 ORDER By r.division, r.Style, r.color_code, r.lbl_code, r.Dimension ;
5337 INTO Cursor __DtlExpl
5338 llRetVal= .ExplodeRangeStyleVertical("__DtlExpl", "tcRangeVer", pcTransDetail, tcTransSAC) &&, pcViewTransDetail
5339 Endif
5340 Endif
5341 Endif
5342 Endif
5343 Endif
5344 Endwith
5345
5346 If Used("__RangH")
5347 Use In __RangH
5348 Endif
5349 If Used("__RangD")
5350 Use In __RangD
5351 Endif
5352 If Used("tcRangeVer")
5353 Use In tcRangeVer
5354 Endif
5355 If Used("__DtlExpl")
5356 Use In __DtlExpl
5357 Endif
5358 If Used("__TmpCursor")
5359 Use In __TmpCursor
5360 Endif
5361
5362 *--- TR 1038376 05-May-2009 Goutam
5363 If Used("__RangTmpD")
5364 Use In __RangTmpD
5365 ENDIF
5366 this.TableClose(lcTmpCursor)
5367 *=== TR 1038376 05-May-2009 Goutam
5368
5369 Select(lnOldSelect)
5370 Return llRetVal
5371 Endproc
5372 *----------------------------------------------------------------------------------------
5373
5374 Procedure ExplodeRangeRef
5375 Lparameters pcRangeHeader, pcRangeDetail, pcRangeDetailTarget
5376 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
5377 lcDivStyle, lnSourceCnt, lnSofar, lnSizeQty, lnSizePosition
5378
5379 lnOldSele= Select()
5380 lcDivStyle= ""
5381 * TAN 31891 - JAZ - 5/20/02
5382 * lnSourceCnt= RECCOUNT(pcRangeDetail)
5383 lnSourceCnt= RecCount(pcRangeDetail)
5384 * End TAN 31891 - JAZ - 5/20/02
5385 llRetVal= .T.
5386 lnCurDtlFkey= 0
5387
5388 Select (pcRangeDetail)
5389 Set Order To DivStyle
5390 Scan
5391 *- 1009508 03/16/05 YIK
5392 *-- IF lnCurDtlFkey<> &pcRangeDetail..fkey
5393 *-- lnCurDtlFkey= &pcRangeDetail..fkey
5394 *-- IF SEEK(fkey, pcRangeHeader , "PKEY")
5395 *-- m.rng_type= &pcRangeHeader..rng_type
5396 *-- m.rng_qty= &pcRangeHeader..rng_qty
5397
5398 *-- * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5399 *-- m.coord_code= &pcRangeHeader..coord_code
5400 *-- m.rng_type= &pcRangeHeader..rng_type
5401 If lnCurDtlFkey<> fkey
5402 lnCurDtlFkey= fkey
5403 If Seek(fkey, pcRangeHeader , "PKEY")
5404 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5405 m.rng_qty = Evaluate(pcRangeHeader + " .rng_qty")
5406 m.coord_code = Evaluate(pcRangeHeader + ".coord_code")
5407 m.rng_type = Evaluate(pcRangeHeader + ".rng_type")
5408 *= 1009508 YIK
5409 Else
5410 llRetVal = .F.
5411 Exit
5412 Endif
5413 Endif
5414
5415 * only run once per Div + Style
5416 If !(lcDivStyle == division + Style)
5417 lcDivStyle = division + Style
5418 * Insert a record for each size bucket with a caption *
5419 If !v_GetSizeHeadings(division, Style, "__xSizer")
5420 llRetVal = .F.
5421 Exit
5422 Endif
5423 Endif
5424
5425 Select (pcRangeDetail)
5426 Scatter Memvar Memo
5427 For lnSizePosition = 1 To goEnv.MaxBuckets
5428 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
5429 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
5430 lnSizeQty = Eval(lcSizeBucket + "_qty") && zzoordrd bucket qtys
5431 m.sizebucket = lnSizePosition
5432 m.size_desc = lcSizeName
5433 m.total_qty = lnSizeQty
5434 If lnSizeQty > 0 && Only want buckets with activity!
5435 Insert Into (pcRangeDetailTarget) From Memvar
5436 Endif
5437 Endfor
5438
5439 Endscan
5440 This.TableClose("__xSizer")
5441 Select (pcRangeDetail)
5442 Select (lnOldSele)
5443 Return llRetVal
5444 Endproc
5445
5446 *----------------------------------------------------------------------------------------
5447
5448 Procedure ValidateRangeStyle
5449 Lparameters pcRangeStyle, pcTransDetail
5450 Local llRetVal, lnOldSelect, lcErrs_Msg
5451 llRetVal = .T.
5452 lnOldSelect = Select()
5453 lcErrs_Msg= "Total Units must be divisible by "
5454
5455 Select (pcRangeStyle)
5456 Index On division+rng_style+rng_color+rng_lbl+rng_pack Tag RngStyle
5457 llRetVal= .SetRelation(pcRangeStyle, "RngStyle", pcTransDetail, ;
5458 "division+style+color_code+lbl_code+dimension")
5459
5460 If llRetVal
5461 .LogEntry("Validating range style.")
5462 * Verify range style "R"un order in min multiple of rng_qty
5463 * no need for "S"et verification of range type --just explode to
5464 * range detail
5465 Scan For !Empty(__RangH.rng_style) And __RangH.rng_type="R"
5466 *- 1023438 04/06/07 YIK
5467 *- Added ..AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5468 *- to skip this check for range styles type R that will have their qty converted (ex. MultiUPC)
5469 If Mod(&pcTransDetail..total_qty, __RangH.rng_qty) > 0 AND EMPTY(EVALUATE(pcTransDetail + ".ppk_action"))
5470 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + Allt(Str(__RangH.rng_qty)) + CRLF, ;
5471 Errs_Flg_D With "Y" ;
5472 IN (pcTransDetail)
5473 Endif
5474 Endscan
5475 Endif
5476
5477 Set Relation To
5478 Select(lnOldSelect)
5479 Return llRetVal
5480 Endproc
5481
5482 *----------------------------------------------------------------------------------------
5483
5484 Procedure ExplodeRangeStyleVertical
5485 Lparameters pcDetailtoExplode, pcRangeDetailVert, pcTransDetail, tcTransSAC &&, pcViewTransDetail
5486 Local llRetVal, lnOldSelect, lcErrs_Msg
5487 llRetVal = .T.
5488 lnOldSelect = Select()
5489
5490 * --- TR 1034963 12/15/08 CM
5491 LOCAL lcSQLString, lcDetailNotes, llDtlRangeNotes, lnDetailPkey
5492 * === TR 1034963 12/15/08 CM
5493
5494 Select (pcDetailtoExplode)
5495 Scan
5496 * Find detail line that need range style exploding using PKEY
5497 If Seek(pkey, pcTransDetail, "Pkey")
5498 * Current working trans detail
5499 Select (pcTransDetail)
5500
5501
5502 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5503 *-- TR 1040759 JUN-29-2009 BR
5504*!* IF !EMPTY(lbl_code)
5505*!* lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5506*!* ELSE
5507*!* lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5508*!* ENDIF
5509 *== TR 1040759 JUN-29-2009 BR
5510 IF .lALLOW_RANGE_HDR_LABEL
5511
5512 IF !EMPTY(lbl_code)
5513 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5514
5515 else
5516 lcCurOurSKU= division+Style+color_code+cust_lbl+Dimension
5517 ENDIF
5518 else
5519
5520 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
5521
5522 endIF
5523 *- TR 1049244 FH - include lALLOW_RANGE_HDR_LABEL to determine if we use cust_lbl or not in our sku.
5524
5525 lnCurDtlTotal_qty= total_qty
5526
5527 * PL 05/07/02 31911 - JCPenny prepack ordering process (--using range Style)
5528 *- 1009508 3/16/05 YIK
5529 *- lnRangeBucket= &pcTransDetail..Sizebucket && need to record range bucket latter
5530 lnRangeBucket = sizebucket
5531
5532 Scatter Name loTransDetail Memo
5533
5534 *--- TR 1038376 16-Feb-2009 Goutam
5535 loTransDetail.Rng_Price = loTransDetail.org_price
5536 *--- TR 1038376 16-Feb-2009 Goutam
5537
5538 * delete current working trans detail already have image
5539 * in loTransDetail
5540 Delete In (pcTransDetail)
5541
5542 * --- TR 1034963 12/15/08 CM
5543 lnDetailPkey = loTransDetail.pkey
5544 * === TR 1034963 12/15/08 CM
5545
5546 * --- TR 1018184 RLN 01/10/07
5547 lnDetailPkey = loTransDetail.pkey
5548 Select * From (tcTransSAC) Where dfkey = lnDetailPkey Into Cursor tmpRngSacs
5549 * === TR 1018184
5550
5551 Select (pcRangeDetailVert)
5552 * Find 1st match of OURSKU
5553 If Seek(lcCurOurSKU, pcRangeDetailVert , "RangeSKU")
5554 * calculate lnMultiplier regardless of rng_type
5555 * --"R"un only divisible by rng_qty will get to this point
5556 * --otherwise will stay in errs_dtl_F/msg
5557
5558 *- 1009508 3/16/05 YIK
5559 *-- lnMultiplier= IIF(&pcRangeDetailVert..rng_type='S', lnCurDtlTotal_qty, ;
5560 *-- lnCurDtlTotal_qty/ &pcRangeDetailVert..rng_qty)
5561 lnMultiplier= Iif(rng_type='S', lnCurDtlTotal_qty, ;
5562 lnCurDtlTotal_qty/rng_qty)
5563
5564 Scan While llRetVal And !Eof(pcRangeDetailVert) And ;
5565 (lcCurOurSKU= division+ rng_style + rng_color + rng_lbl + rng_pack)
5566 * Exploding detail line
5567 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
5568 If !Empty(loTransDetail.pkey)
5569
5570 * --- TR 1034963 12/15/08 CM
5571 lcDetailNotes = GetUniqueFileName()
5572 lcSQLString = "Select * From Sysnotes Where fkey = " + SQLFormatNum(lnDetailPkey)
5573 llDtlRangeNotes = This.vSqlExec(lcSQLString,lcDetailNotes)
5574 * === TR 1034963 12/15/08 CM
5575
5576 *- 1009508 3/16/05 YIK
5577 Select (pcRangeDetailVert)
5578 Scatter Name loVert Memo
5579 *= 1009508
5580
5581 Select (pcTransDetail)
5582 Append Blank
5583 Gather Name loTransDetail Memo
5584
5585 * PL 07/18/00 4186 EDI - add Range Style price resolution (code A-E)
5586 * resolve proper a..e_price latter when have price_code(CustSalesResv)
5587 * only recording a..e_price to zzeipoth and resetting org_price
5588 *org_price with &pcRangeDetailVert..a_price,
5589
5590 *- 1009508 3/16/05 YIK
5591 *-- REPLACE rng_style WITH &pcRangeDetailVert..rng_style, ;
5592 *-- rng_color WITH &pcRangeDetailVert..rng_color, ;
5593 *-- rng_lbl WITH &pcRangeDetailVert..rng_lbl, ;
5594 *-- rng_pack WITH &pcRangeDetailVert..rng_pack, ;
5595 *-- rng_bk WITH lnRangeBucket, ; && PL 05/07/02 31911
5596 *-- rng_qty WITH &pcRangeDetailVert..rng_qty, ; && PL 05/07/02 31911
5597 *-- rng_type WITH &pcRangeDetailVert..rng_type, ; && PL 05/07/02 31911
5598 *-- coord_code WITH &pcRangeDetailVert..coord_code, ; && PL 05/07/02 31911
5599 *-- total_qty WITH lnMultiplier * &pcRangeDetailVert..total_qty, ;
5600 *-- Sizebucket WITH &pcRangeDetailVert..Sizebucket, ;
5601 *-- size_desc WITH &pcRangeDetailVert..size_desc, ;
5602 *-- division WITH &pcRangeDetailVert..division, ;
5603 *-- STYLE WITH &pcRangeDetailVert..STYLE, ;
5604 *-- color_code WITH &pcRangeDetailVert..color_code, ;
5605 *-- lbl_code WITH &pcRangeDetailVert..lbl_code, ;
5606 *-- DIMENSION WITH &pcRangeDetailVert..DIMENSION, ;
5607 *-- org_price WITH 0, ; && 4186- reset org_price when exploding range style
5608 *-- a_price WITH &pcRangeDetailVert..a_price,; && 4186- store a..e_price
5609 *-- b_price WITH &pcRangeDetailVert..b_price,; && from range style detail
5610 *-- c_price WITH &pcRangeDetailVert..c_price,; && to use latter when have
5611 *-- d_price WITH &pcRangeDetailVert..d_price,; && price_code
5612 *-- e_price WITH &pcRangeDetailVert..e_price ;
5613 *-- IN (pcTransDetail)
5614
5615 *- 1022149 03/06/07 YIK
5616 *- do not zero out org_price for MultiUPC
5617 Replace rng_style With loVert.rng_style, ;
5618 rng_color With loVert.rng_color, ;
5619 rng_lbl With loVert.rng_lbl, ;
5620 rng_pack With loVert.rng_pack, ;
5621 rng_bk With lnRangeBucket, ; && PL 05/07/02 31911
5622 rng_qty With loVert.rng_qty, ; && PL 05/07/02 31911
5623 rng_type With loVert.rng_type, ; && PL 05/07/02 31911
5624 coord_code With loVert.coord_code, ; && PL 05/07/02 31911
5625 total_qty With lnMultiplier * loVert.total_qty, ;
5626 sizebucket With loVert.sizebucket, ;
5627 size_desc With loVert.size_desc, ;
5628 division With loVert.division, ;
5629 STYLE With loVert.Style, ;
5630 color_code With loVert.color_code, ;
5631 lbl_code With loVert.lbl_code, ;
5632 DIMENSION With loVert.Dimension, ;
5633 org_price WITH IIF(loTransDetail.MultiUPC = 'Y', org_price, 0), ; && 4186- reset org_price when exploding range style
5634 upc With '', ; && TR 1019697 NH - clear UPC value as the range style has been exploded
5635 sku With '', ; && TR 1019697 NH - clear SKU value as the range style has been exploded
5636 a_price With loVert.a_price,; && 4186- store a..e_price
5637 b_price With loVert.b_price,; && from range style detail
5638 c_price With loVert.c_price,; && to use latter when have
5639 d_price With loVert.d_price,; && price_code
5640 e_price With loVert.e_price ;
5641 IN (pcTransDetail)
5642 *= 1009508 03/16/05 YIK
5643 * --- TR 1018184 RLN 01/10/07
5644 Select tmpRngSacs
5645 Scan
5646 Scatter Name loTmpSACs Memo
5647 loTmpSACs.pkey = v_nextPkey("ZZEIPOISAC")
5648 loTmpSACs.dfkey = loTransDetail.pkey
5649 Insert Into (tcTransSAC) From Name loTmpSACs
5650 Endscan
5651 * === TR 1018184
5652
5653 * --- TR 1034963 12/15/08 CM
5654 If llDtlRangeNotes
5655 Select (lcDetailNotes)
5656 Scan
5657 Scatter Name loTmpDetNotes Memo
5658
5659 * --- TR 1045865 3/8/10 CM
5660 *loTmpDetNotes.pkey = v_nextPkey("ZZEIPOID")
5661 loTmpDetNotes.pkey = v_nextPkey("SYSNOTES")
5662 * === TR 1045865 3/8/10 CM
5663
5664 loTmpDetNotes.fkey = loTransDetail.pkey
5665 SELECT('Vzzeipotd_notes_iPOproc')
5666 Append Blank
5667 Gather Name loTmpDetNotes Memo
5668 Endscan
5669 Endif
5670
5671 IF USED(lcDetailNotes)
5672 USE IN (lcDetailNotes)
5673 ENDIF
5674 * === TR 1034963 12/15/08 CM
5675
5676 Else
5677 llRetVal= .F. && Cannot get Pkey from bcsysnum
5678 Exit
5679 Endif
5680
5681 Select (pcRangeDetailVert)
5682 Endscan
5683 Else
5684 llRetVal= .F. && Should be in pcrangdetailvert
5685 Exit
5686 Endif
5687 Delete From (tcTransSAC) Where dfkey = lnDetailPkey
5688 Endif
5689
5690 If !llRetVal &&Get out of scan when have some problem
5691 Exit
5692 Endif
5693 Endscan
5694
5695 * --- TR 1034963 12/15/08 CM
5696 If llDtlRangeNotes
5697 This.UpdateSysNotes()
5698 Endif
5699 * === TR 1034963 12/15/08 CM
5700
5701 Select(lnOldSelect)
5702 Return llRetVal
5703 Endproc
5704
5705 *----------------------------------------------------------------------------------------
5706
5707 Procedure PrepackConversion
5708 * --- TR 1046519 7/26/10 CM --- Added 4th parameter pcSLN
5709 Lparameters pcTransHeader, pcTransDetail, pceipoCR, pcSLN &&, pcViewTransDetail
5710 *--- TechRec 1044487 18-Mar-2010 JK Added pceipoCR ===
5711 LOCAL llRetVal, lnOldSelect, lcErrs_Msg &&- 1025153 10/22/07 YIK ,lcKey
5712 llRetVal = .T.
5713 lnOldSelect = Select()
5714
5715 * --- TR 1046519 7/26/10 CM
5716 LOCAL lcSumSln, lcError, lcPPKAction, llSlnConvert, llConvertBySln, ;
5717 llHasSlns, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5718
5719 STORE "" To lcSumSln, lcError, lcPPKAction
5720 STORE .F. TO llSlnConvert, llHasSlns, llConvertBySln
5721 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
5722 * === TR 1046519 7/26/10 CM
5723
5724 *****************************************************************************
5725 * 1st Getting all prepack headers
5726 *--- 1001112 9/26/03 YIK
5727 *- process all.
5728 *!* Select distinct d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action ;
5729 *!* From (pcTransHeader) h, (pcTransDetail) d ;
5730 *!* Where h.pkey = d.fkey and h.Errs_flg_h= "N" and d.Errs_Flg_D= "N";
5731 *!* and d.rng_style= '' ; && none exploded range style
5732 *!* and d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5733 *!* Order by 1,2,3,4,5 Into Cursor __TmpCursor
5734
5735 *- 1013522 10/10/05 12/02/05 YIK
5736 *- Exclude range style P from the consideration
5737 *- Do not close this cursor. It is needed in CheckSLN()
5738 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
5739 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
5740
5741 *- 1025153 10/22/07 YIK - comment out
5742 * --- TR 1022896 NSD 05-10-07
5743*-- INDEX ON division + rng_style + rng_color + rng_lbl + rng_pack TAG sku
5744 * === TR 1022896 NSD 05-10-07
5745
5746 *- 1005499 07/06/04 YIK
5747 *- Change d.rng_style = '' to EMPTY(d.rng_style)
5748
5749 *- 1023438 04/05/07 YIK
5750 *- Allow to check Range Style type 'R'.
5751 *- Needed for MultiUPC and a good idea anyway.
5752 *- Replaced ..WHERE Empty(d.rng_style).. with ..(d.rng_type = ' ' OR d.rng_type = 'R')..
5753
5754 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy --- Changed d.ppk_action $ 'QPB' To d.ppk_action $ 'QPBO'
5755
5756*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5757*!* FROM (pcTransDetail) d ;
5758*!* WHERE Empty(d.rng_style) ; && none exploded range style
5759*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5760*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5761*!* AND d.ppk_action $ 'QPB' ; && prepack style that requires some conversion
5762*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5763
5764 *--- TechRec 1044487 18-Mar-2010 JK ---
5765*!* Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.ppk_action ;
5766*!* FROM (pcTransDetail) d ;
5767*!* WHERE (d.rng_type = ' ' OR d.rng_type = 'R') ;
5768*!* And d.division + d.Style + d.color_code + d.lbl_code + d.Dimension ;
5769*!* NOT In (Select division + rng_style + rng_color + rng_lbl + rng_pack From __RangeP) ;
5770*!* AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5771*!* Order By 1,2,3,4,5 Into Cursor __TmpCursor
5772
5773 * --- TR 1046519 7/26/10 CM
5774 IF RECCOUNT(pcSLN) > 0
5775 SELECT SUM(s.sln_qty) as sln_qty, s.fkey FROM (pcSLN) s ;
5776 JOIN (pcTransDetail) d ;
5777 ON s.fkey = d.pkey ;
5778 JOIN (pceipoCR) c ;
5779 ON d.division = c.division ;
5780 AND d.customer = c.customer ;
5781 WHERE s.sln_qty > 0 ;
5782 GROUP BY s.fkey ;
5783 INTO CURSOR __SumSlnQty
5784
5785 llConvertBySln = USED("__SumSlnQty") And RECCOUNT("__SumSlnQty") > 0
5786
5787 WITH THIS
5788 .cSQLTempTable=""
5789 IF .GenerateSQLTempTable('__SumSlnQty')
5790 IF .PopulateSQLTempTable('__SumSlnQty')
5791 lcSumSln = .cSQLTempTable
5792 IF !EMPTY(lcSumSln)
5793 lcError = "Cannot Convert Pre-Pack Qty Based on SLN Qty - Qty Not Divisible."
5794 ENDIF
5795 ENDIF
5796 ENDIF
5797 ENDWITH
5798 ENDIF
5799 * === TR 1046519 7/26/10 CM
5800
5801 *--- TechRec 1089737 21-Dec-2015 jisingh ---
5802 IF !EMPTY(This.cOverridePpkAction)
5803 REPLACE ALL ppk_action WITH This.cOverridePpkAction ;
5804 FOR EMPTY(ppk_action) OR ppk_action $ 'QPBO' IN (pcTransDetail)
5805 ENDIF
5806 *=== TechRec 1089737 21-Dec-2015 jisingh ===
5807
5808 * --- TR 1046519 7/26/10 CM --- Added field d.pkey, c.ppk_conv to AND condition
5809 *--- TechRec 1049646 01-Apr-2011 TShenbagavalli changed the condition c.rngp_conv = 'Y' to c.rngp_conv = 'P'---
5810 *--- TR 1063055 29-Aug-2012 BNarayanan added Errs_Flg_D <> 'Y' to the where clause.
5811 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
5812 FROM (pcTransDetail) d ;
5813 JOIN (pceipoCR) c ON c.customer = d.customer ;
5814 AND c.division = d.division ;
5815 WHERE (d.rng_type = ' ' OR d.rng_type = 'R') AND d.Errs_Flg_D <> 'Y';
5816 AND (c.rngp_conv = 'P' ;
5817 OR d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
5818 NOT IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP)) ;
5819 AND d.ppk_action $ 'QPBO' ; && prepack style that requires some conversion
5820 AND c.ppk_conv <> 'N' ;
5821 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
5822 *=== TechRec 1044487 18-Mar-2010 JK ===
5823
5824 *=== TechRec 1023308 09-Apr-2007 vkrishnamurthy ===
5825 *== 1023438
5826
5827 *=== 1013522
5828 *=== 1001112
5829 With This
5830 .cSQLTempTable=""
5831 If .GenerateSQLTempTable('__TmpCursor')
5832 If .PopulateSQLTempTable('__TmpCursor')
5833 If !Empty(.cSQLTempTable)
5834 *- TR 1025153 06/14/07 YIK
5835 *- Use the OUTER JOIN, then we have all details needed
5836 *- and can simply scan for !EOF() later on.
5837*-- lcSQLString= "Select t.*, ph.ppk_desc, ph.pack_qty, s.size_code " +;
5838*-- "from zzxppakh ph, zzxscolr s, " + .cSQLTempTable + " t " +;
5839*-- "Where s.ppack_ok= 'Y' and s.division= t.division and " +;
5840*-- "s.style= t.style and s.color_code= t.color_code and " +;
5841*-- "s.lbl_code = t.lbl_code and s.dimension = t.dimension and " + ;
5842*-- "s.division= ph.division and s.size_code= ph.size_code and "+;
5843*-- "s.dimension= ph.ppk_code"
5844 *--- TR 1026025 NH - use size_code from zzxstylr
5845 *--- TR 1046519 CM --- Modifed Sql to specifically handle ppk qty conversion
5846 * using sln_qty instead of ppk_qty
5847
5848 *--- TR 1046757 12-AUG-2010 MANI. Added condition ph.Active_ok = 'Y' ===
5849 *--- TR 1053017 11-3-2011 VKK moved ph.active_ok condition from where to Join
5850 lcSQLString= "Select t.*, ISNULL(ph.ppk_desc, '') AS ppk_desc " + ;
5851 " ,ISNULL(ph.pack_qty, 0) AS pack_qty " + ;
5852 " ,st.size_code " +; && 1026025
5853 IIF(llConvertBySln, ",ISNULL(sl.sln_qty, 0) AS sln_qty ","") + ; && TR 1046519 7/26/10 CM
5854 " from " + .cSQLTempTable + " t " +;
5855 " JOIN zzxscolr s " + ;
5856 " ON s.division= t.division and " +;
5857 " s.style= t.style and s.color_code= t.color_code and " +;
5858 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
5859 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ; && 1026025
5860 IIF(llConvertBySln, " LEFT OUTER JOIN " + lcSumSln + " sl on t.pkey = sl.fkey ", "") + ; && TR 1046519 7/26/10 CM
5861 " LEFT OUTER JOIN zzxppakh ph " + ;
5862 " ON s.division= ph.division and st.size_code= ph.size_code and "+; && 1026025
5863 " s.dimension= ph.ppk_code and ph.Active_ok = 'Y' " + ;
5864 " Where s.ppack_ok= 'Y' "
5865
5866 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
5867 If Used("_PPK_Qty")
5868 Select ("_PPK_Qty")
5869 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
5870 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
5871 "division+style+color_code+lbl_code+dimension")
5872 SELECT ("__TmpCursor")
5873
5874 If llRetVal
5875 .LogEntry("Validating prepack style.")
5876 lcErrs_Msg = "No valid prepack code found"
5877 Select (pcTransDetail)
5878 *- 1005499 07/06/04 YIK
5879 *- Replace ..Errs_Flg_D= "N") and rng_style=''
5880 *- with ..!(Errs_Flg_D= "Y") and EMPTY(rng_style), 'cause Errs_Flg_D can be empty
5881 *--- TechRec 1023308 09-Apr-2007 vkrishnamurthy ---
5882*!* Scan For !(Errs_Flg_D= "Y") And Empty(rng_style) And ppk_action $ 'QPB'
5883 *- TR 1025153 06/14/07 YIK
5884 *- Since we use the OUTER JOIN, can simply scan for !EOF()
5885 *-Scan For !(Errs_Flg_D= "Y") And (rng_type = ' ' OR rng_type = 'R') And ppk_action $ 'QPBO'
5886 SCAN FOR !EOF("_PPK_Qty") AND Errs_Flg_D < 'Y' && TR 1056390 FH - added ERRS_FLG_D check
5887
5888 If Empty(_PPK_Qty.pack_qty)
5889 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
5890 Errs_Flg_D With "Y" ;
5891 IN (pcTransDetail)
5892 Else
5893 Do Case
5894
5895 * --- TR 1040838 6/11/09 CM
5896 * --- Check prepack action based on Transaction detail
5897 * Removed _PPK_Qty Alias
5898 *Case _PPK_Qty.ppk_action = 'Q' && multiply qty
5899 Case ppk_action = 'Q' && multiply qty
5900 * === TR 1040838 6/11/09 CM
5901
5902 * --- TR 1046519 7/26/10 CM
5903 * At this point we know we have some slns to use for our alternate
5904 * conversion, lets just make sure that the conversion type is 'E'
5905 IF llConvertBySln
5906 lcPPKAction = ppk_action
5907 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5908 lnOrigQty = total_qty
5909 lnPpkQty = ppk_qty
5910 ENDIF
5911 * === TR 1046519 7/26/10 CM
5912
5913 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5914 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5915 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5916 total_qty*_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5917 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
5918 In (pcTransDetail)
5919
5920 * --- TR 1046519 7/26/10 CM
5921 IF llSlnConvert
5922 llRemain = MOD(total_qty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
5923 IF llRemain
5924 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
5925 Errs_Flg_D WITH "Y" , ;
5926 ppk_action WITH lcPPKAction , ;
5927 total_qty WITH lnOrigQty ;
5928 In (pcTransDetail)
5929 ENDIF
5930 ENDIF
5931 * ==== TR 1046519 7/26/10 CM
5932
5933 * --- TR 1040838 6/11/09 CM
5934 * Removed _PPK_Qty Alias
5935 *Case _PPK_Qty.ppk_action = 'P' && divide price
5936 Case ppk_action = 'P' && divide price
5937 * === TR 1040838 6/11/09 CM
5938
5939 * --- TR 1046519 7/26/10 CM
5940 * At this point we know we have some slns to use for our alternate
5941 * conversion, lets just make sure that the conversion type is 'E'
5942 IF llConvertBySln
5943 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5944 ENDIF
5945 * === TR 1046519 7/26/10 CM
5946
5947 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5948 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5949 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5950 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5951 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5952 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5953 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5954 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
5955 In (pcTransDetail)
5956 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
5957 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
5958 *- Range style price will be populated later from a_price..e_price
5959 *- not from org_price. Need to updated these prices here.
5960 IF rng_type = 'R'
5961 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
5962 b_price WITH b_price/_PPK_Qty.pack_qty, ;
5963 c_price WITH c_price/_PPK_Qty.pack_qty, ;
5964 d_price WITH d_price/_PPK_Qty.pack_qty, ;
5965 e_price WITH e_price/_PPK_Qty.pack_qty ;
5966 In (pcTransDetail)
5967 ENDIF
5968 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
5969
5970 * --- TR 1040838 6/11/09 CM
5971 * Removed _PPK_Qty Alias
5972 *Case _PPK_Qty.ppk_action = 'B' OR _PPK_Qty.ppk_action = 'O' && both multiply qty and divide price
5973 Case ppk_action = 'B' OR ppk_action = 'O' && both multiply qty and divide price
5974 * === TR 1040838 6/11/09 CM
5975
5976 * --- TR 1046519 7/26/10 CM
5977 IF llConvertBySln
5978 lcPPKAction = ppk_action
5979 llSlnConvert = (!EMPTY(_PPK_Qty.sln_qty) And _PPK_Qty.ppk_conv == 'E')
5980 lnOrigQty = total_qty
5981 lnPrice = org_price
5982 lnretail1 = retail1
5983 lnretail2 = retail2
5984 lnPpkQty = ppk_qty
5985 ENDIF
5986 * === TR 1046519 7/26/10 CM
5987
5988 *--- TR 1033848 TT Jul22 2008: Extend ppk action to retail1 AND retail2
5989 *--- TechRec 1051779 07-Apr-2011 jisingh Added IIF condition in ppk_qty With _PPK_Qty.pack_qty ===
5990 Replace ppk_qty With IIF(!llSlnConvert,_PPK_Qty.pack_qty,_PPK_Qty.sln_qty), ;
5991 org_price With IIF(!llSlnConvert, org_price/_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5992 org_price/_PPK_Qty.sln_qty), ; && TR 1046519 7/26/10 CM
5993 retail1 With retail1/_PPK_Qty.pack_qty, ; && 1033848
5994 retail2 With retail2/_PPK_Qty.pack_qty, ; && 1033848
5995 total_qty With IIF(!llSlnConvert, total_qty*_PPK_Qty.pack_qty, ; && TR 1046519 7/26/10 CM
5996 total_qty*_PPK_Qty.sln_qty) , ; && TR 1046519 7/26/10 CM
5997 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
5998 In (pcTransDetail)
5999
6000 * --- TR 1046519 7/26/10 CM
6001 IF llSlnConvert
6002 llRemain = MOD(lnOrigQty*_PPK_Qty.sln_qty, _PPK_Qty.pack_qty) > 0
6003 IF llRemain
6004 Replace Errs_Msg_D WITH Errs_Msg_D + lcError + CRLF, ;
6005 Errs_Flg_D WITH "Y", ;
6006 ppk_action WITH lcPPKAction , ;
6007 total_qty WITH lnOrigQty , ;
6008 org_price WITH lnPrice , ;
6009 retail1 WITH lnretail1 , ;
6010 retail2 WITH lnretail2 , ;
6011 ppk_qty WITH lnPpkQty ;
6012 In (pcTransDetail)
6013 ENDIF
6014 ENDIF
6015 * ==== TR 1046519 7/26/10 CM
6016
6017 *=== TR 1033848 TT: Extend ppk action to retail1 AND retail2
6018 *--- TechRec 1025153 24-Oct-2007 ykaganovsky ---
6019 IF rng_type = 'R'
6020 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
6021 b_price WITH b_price/_PPK_Qty.pack_qty, ;
6022 c_price WITH c_price/_PPK_Qty.pack_qty, ;
6023 d_price WITH d_price/_PPK_Qty.pack_qty, ;
6024 e_price WITH e_price/_PPK_Qty.pack_qty ;
6025 In (pcTransDetail)
6026 ENDIF
6027 *=== TechRec 1025153 24-Oct-2007 ykaganovsky ===
6028
6029 Otherwise
6030 Endcase
6031 Endif
6032 Endscan
6033 Endif
6034 Set Relation To
6035 Endif
6036 Endif
6037 Endif
6038 Endif
6039 Endwith
6040 If Used("__TmpCursor")
6041 Use In __TmpCursor
6042 Endif
6043 If Used("_PPK_Qty")
6044 Use In _PPK_Qty
6045 Endif
6046
6047 * --- TR 1046519 7/26/10 CM
6048 IF USED("__SumSlnQty")
6049 USE IN __SumSlnQty
6050 ENDIF
6051 * === TR 1046519 7/26/10 CM
6052
6053 Select(lnOldSelect)
6054 Return llRetVal
6055
6056 *----------------------------------------------------------------------------------------
6057 *- 1006607 09/02/04 YIK
6058 Function ResolveRangeP
6059 Lparameters pceipoTH, pceipoTD, pceipoCR
6060
6061 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added lcRngp_conv ---
6062 Local llRetVal, lnOldSelect, lcSQLString, lnResult, lcRngp_conv
6063 LOCAL lcErrorMsg && 1049007 08/24/10 YIK
6064 llRetVal = .T.
6065 lnOldSelect = Select()
6066
6067 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6068 lcRngp_conv = ""
6069 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6070
6071 With This
6072 .oLog.LogMajorStage("Range Style Implosion.")
6073 *- do we have any range styles 'P' in BC
6074 lcSQLString= "Select count(*) From zzxrangH where rng_type = 'P' "
6075 llRetVal= llRetVal And v_SqlExec(lcSQLString, "tcTemp")
6076 If !llRetVal Or Recc("tcTemp") = 0
6077 .oLog.LogEntry("No range styles for implosion")
6078 Return llRetVal
6079 Endif
6080
6081 *- 1007637 11/17/04 YIK
6082 *- Allow open stock: Rng_impl = 'O'
6083 *- Select c.Rng_impl , change c.Rng_impl = 'Y' to c.Rng_impl <> 'N'
6084 *- implode only orders that have not been range imploded (empty range style)
6085 *- and were not prepack imploded (implosion <> "Y")
6086 *!* select distinct fkey ;
6087 *!* from (pceipoTd) d ;
6088 *!* join (pceipoCR) c ;
6089 *!* on d.division = c.division and d.customer = c.customer ;
6090 *!* where c.Rng_impl = 'Y' and !EMPTY(d.style) ;
6091 *!* and !EMPTY(d.division) and !EMPTY(d.customer) ;
6092 *!* and empty(d.rng_style) and d.implosion <> "Y" ;
6093 *!* into cursor rng_det
6094
6095*- 1047842/1048069 07/01/10 YIK
6096*- Implode only orders with no detail errors
6097*-- Select Distinct fkey, C.Rng_impl ;
6098*-- FROM (pceipoTD) d ;
6099*-- JOIN (pceipoCR) C ;
6100*-- ON d.division = C.division And d.customer = C.customer ;
6101*-- WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6102*-- AND !Empty(d.division) And !Empty(d.customer) ;
6103*-- AND Empty(d.rng_style) And d.implosion <> "Y" ;
6104*-- INTO Cursor rng_det
6105
6106 *- TR 1058336 FH - added division to select, and group by
6107 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added c.Rngp_conv in select clause and in Group by ---
6108 Select d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6109 FROM (pceipoTD) d ;
6110 JOIN (pceipoCR) C ;
6111 ON d.division = C.division And d.customer = C.customer ;
6112 WHERE C.Rng_impl <> 'N' And !Empty(d.Style) ;
6113 AND !Empty(d.division) And !Empty(d.customer) ;
6114 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6115 GROUP BY d.division, fkey, C.Rng_impl, C.Rngp_conv ;
6116 HAVING MAX(errs_flg_d) = 'N' ;
6117 INTO Cursor rng_det
6118*===
6119
6120 *==
6121 *--- TR 1023892 NH
6122 IF .lALLOW_RANGE_HDR_LABEL
6123 &&- TR 1058336 FH - added qualifier for division
6124 *--- 1049817 Replacing Cust_lbl as lbl_code with IIF(Cust_lbl <> '',cust_lbl,lbl_code) as lbl_code
6125 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6126 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 ;
6127 FROM (pceipoTD) d ;
6128 JOIN rng_det r ON r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6129 WHERE !EMPTY(d.STYLE) ;
6130 AND !EMPTY(d.division) AND !EMPTY(d.customer) ;
6131 AND EMPTY(d.rng_style) AND d.implosion <> "Y" ;
6132 INTO CURSOR __TmpCurs
6133 ELSE
6134 &&- TR 1058336 FH - added qualifier for division
6135 *=== TR 1023892 NH
6136 *- 1047842/1048069 07/01/10 YIK
6137 *- Added d.pkey
6138 &&--- TechRec 1078967 12-Aug-2014 vkrishnamurthy === Added d.customer
6139 Select d.customer,d.division, Style, color_code, lbl_code, Dimension, sizebucket, total_qty, d.fkey, d.pkey ;
6140 FROM (pceipoTD) d ;
6141 JOIN rng_det r On r.fkey = d.fkey AND d.division = r.division ; &&- TR 1058336 FH - added division
6142 WHERE !Empty(d.Style) ;
6143 AND !Empty(d.division) And !Empty(d.customer) ;
6144 AND Empty(d.rng_style) And d.implosion <> "Y" ;
6145 INTO Cursor __tmpCurs
6146 ENDIF && TR 1023892 NH
6147 .cSQLTempTable=""
6148 If .GenerateSQLTempTable('__TmpCurs')
6149 If .PopulateSQLTempTable('__TmpCurs')
6150 If !Empty(.cSQLTempTable)
6151 Select rng_det
6152 Scan
6153 lnFKey = rng_det.fkey
6154 *- 1007637 11/17/04 YIK
6155 lcRng_Impl = rng_det.Rng_impl
6156
6157 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6158 lcRngp_conv = rng_det.Rngp_conv
6159 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6160
6161 lcDivision = rng_det.division &&- TR 1058336 FH
6162
6163 *- one order at a time. Select on the server side.
6164 lcSQLStr = "select * from " + .cSQLTempTable + " where FKey = " + SQLFormatNum(lnFKey) + " AND division = '" + lcDivision +" '" &&- TR 1058336 FH - added division
6165 dtl = SQLTableFromQuery(lcSQLStr )
6166 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added , ,lcRngp_conv in parameter list ---
6167
6168 *--- TR 1060800 24-May-2012 Goutam. Added lcRng_Impl in the parameter list
6169 lnResult = .RangeImplosion(lnFKey, dtl, pceipoTD, ,lcRngp_conv, lcRng_Impl)
6170
6171 Select (pceipoTD)
6172 Do Case
6173 Case lnResult = 0 && match not found
6174 *- 1007637 11/17/04 YIK
6175 If lcRng_Impl = 'Y'
6176
6177 Replace Errs_Msg_D With Errs_Msg_D + " Cannot find range style " + CRLF, ;
6178 Errs_Flg_D With "Y" ;
6179 FOR fkey = lnFKey And !Empty(Style) ;
6180 AND !Empty(division) And !Empty(customer) ;
6181 AND Empty(rng_style) And implosion <> "Y"
6182 Endif
6183 Case lnResult > 1 && ambiguous
6184 *- TR 1050754 NOV-15-2010 BR - Re-instating previous version of code.
6185 *- 1049007 08/24/10 YIK
6186 *- List all ambiguous Range Styles
6187 Replace Errs_Msg_D With Errs_Msg_D + " Ambiguous range style " + CRLF, ;
6188 Errs_Flg_D With "Y" ;
6189 FOR fkey = lnFKey And !Empty(Style) ;
6190 AND !Empty(division) And !Empty(customer) ;
6191 AND Empty(rng_style) And implosion <> "Y"
6192*!* lcErrorMsg = " Ambiguous range styles "
6193*!* IF USED("__tmp") AND RECCOUNT("__tmp")>1
6194*!* lcErrorMsg = lcErrorMsg + ": "
6195*!* SELECT __tmp
6196*!* SCAN
6197*!* lcErrorMsg = lcErrorMsg + TRIM(Rng_Style) + "/" + Trim(Rng_Color) ;
6198*!* + "/" + Trim(Rng_Lbl) + "/" + Trim(Rng_Pack) + " "
6199*!* EndScan
6200*!* SELECT(pceipoTD)
6201*!* ENDIF
6202*!*
6203*!* Replace Errs_Msg_D With Errs_Msg_D + lcErrorMsg + CRLF, ;
6204*!* Errs_Flg_D With "Y" ;
6205*!* FOR fkey = lnFKey And !Empty(Style) ;
6206*!* AND !Empty(division) And !Empty(customer) ;
6207*!* AND Empty(rng_style) And implosion <> "Y"
6208 *=== 1049007
6209 Endcase
6210 Endscan
6211 Endif
6212 Endif
6213 Endif
6214
6215 Endwith
6216 Select (lnOldSelect)
6217 Return llRetVal
6218 Endfunc
6219
6220 Function RangeImplosion
6221 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli added parameter pcRngp_conv ---
6222 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6223 Lparameters pnFkey, dtl, pceipoTD, tlNoConsol, pcRngp_conv, pcRng_Impl
6224
6225 Local llRetVal, lnOldSelect, lcSQLString, llSingleMatch, lnPPKCnt, llAmbig, lnCnt, ;
6226 lcFldStr, lcTopStr, lcBotStr ,lcMiddleStr, lcCoalStr_pkey, lcCoalRevStr_pkey, ;
6227 lcCoalStr_ratio, lcCoalRevStr_ratio, lcGroupFkeyStr, lcGroupStr, lnPrepacks
6228
6229 llRetVal = .T.
6230 lnOldSelect = Select()
6231 With This
6232
6233 *- select all range style details with the matching BCSku(style/color/lbl/dim) and
6234 *- turn them vertical into SQL-side temp table var. RangD
6235 *- TR 1050754 NOV-15-2010 BR - Modified Query to also exclude invalid range styles(ie partial range styles, or range styles with less qty)
6236 *--- TechRec 1078967 11-Aug-2014 vkrishnamurthy ---
6237*!* Changed "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " +;
6238*!* to "coalesce(cs.a_price,d.a_price) as a_price, "+;
6239*!* "coalesce(cs.b_price,d.b_price) as b_price, "+;
6240*!* "coalesce(cs.c_price,d.c_price) as c_price, "+;
6241*!* "coalesce(cs.d_price,d.d_price) as d_price, "+;
6242*!* "coalesce(cs.e_price,d.e_price) as e_price, "+
6243
6244*!* Added following join
6245*!* " join " + dtl + " td1 " +;
6246*!* " on d.style = td1.style " +;
6247*!* " and d.color_code = td1.color_code " +;
6248*!* " and d.lbl_code = td1.lbl_code " +;
6249*!* " and d.dimension = td1.dimension "
6250
6251 *=== TechRec 1078967 11-Aug-2014 vkrishnamurthy ===
6252
6253 *--- TR 1084825 20-Feb-2015 BNarayanan adding the join on division, sizebucket for the dtl table join ---
6254 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, " + ;
6255 "Size_Num as Size_Bk, d.PKey, d.FKey, " +;
6256 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6257 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6258 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6259 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6260 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6261 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6262 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6263 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6264 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6265 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6266 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6267 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " +;
6268 "coalesce(cs.a_price,d.a_price) as a_price, "+;
6269 "coalesce(cs.b_price,d.b_price) as b_price, "+;
6270 "coalesce(cs.c_price,d.c_price) as c_price, "+;
6271 "coalesce(cs.d_price,d.d_price) as d_price, "+;
6272 "coalesce(cs.e_price,d.e_price) as e_price "+;
6273 "from ( " +;
6274 " select dd.* from zzxrangd dd " +;
6275 " where fkey in ( " +;
6276 " select distinct ph.pkey " +;
6277 " from zzxrangh ph " +;
6278 " join zzxrangd pd " +;
6279 " on ph.Pkey = Pd.Fkey " +;
6280 " join " + dtl + " td1 " +;
6281 " on pd.division = td1.division " + ; && TR 1084825 03-Mar-2015 BNarayanan
6282 " and pd.style = td1.style " +;
6283 " and pd.color_code = td1.color_code " +;
6284 " and pd.lbl_code = td1.lbl_code " +;
6285 " and pd.dimension = td1.dimension " +;
6286 " where ph.rng_type = 'P' " +;
6287 " and not exists( " +;
6288 " select * " +;
6289 " from zzxrangd da " +;
6290 " left join " + dtl + " det " +;
6291 " on det.division= da.division" +; && TR 1084825 03-Mar-2015 BNarayanan
6292 " and det.style = da.style " +;
6293 " and det.color_code = da.color_code " +;
6294 " and det.lbl_code = da.lbl_code " +;
6295 " and det.dimension = da.dimension " +;
6296 " where da.Fkey = ph.pkey " +;
6297 " and (det.Pkey is null " +;
6298 " or case det.SizeBucket " +;
6299 " when 01 then Size01_Qty when 02 then Size02_Qty " +;
6300 " when 03 then Size03_Qty when 04 then Size04_Qty " +;
6301 " when 05 then Size05_Qty when 06 then Size06_Qty " +;
6302 " when 07 then Size07_Qty when 08 then Size08_Qty " +;
6303 " when 09 then Size09_Qty when 10 then Size10_Qty " +;
6304 " when 11 then Size11_Qty when 12 then Size12_Qty " +;
6305 " when 13 then Size13_Qty when 14 then Size14_Qty " +;
6306 " when 15 then Size15_Qty when 16 then Size16_Qty " +;
6307 " when 17 then Size17_Qty when 18 then Size18_Qty " +;
6308 " when 19 then Size19_Qty when 20 then Size20_Qty " +;
6309 " when 21 then Size21_Qty when 22 then Size22_Qty " +;
6310 " when 23 then Size23_Qty else Size24_Qty end > coalesce(det.Total_Qty, 0))) " +;
6311 " ) ) d " +;
6312 " join zzxbuckt b " +;
6313 " on d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " +;
6314 " d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " +;
6315 " d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " +;
6316 " d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " +;
6317 " d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " +;
6318 " d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " +;
6319 " d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " +;
6320 " d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " +;
6321 " d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " +;
6322 " d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " +;
6323 " d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " +;
6324 " d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 "+ ;
6325 " join " + dtl + " td1 " +;
6326 " on d.division = td1.division " +; && TR 1084825 20-Feb-2015 BNarayanan
6327 " and d.style = td1.style " +;
6328 " and d.color_code = td1.color_code " +;
6329 " and d.lbl_code = td1.lbl_code " +;
6330 " and d.dimension = td1.dimension "+;
6331 " and size_num = td1.sizebucket " +; && TR 1084825 20-Feb-2015 BNarayanan
6332 " Left join zzxcsrgh cs "+ ;
6333 " on cs.dtlpkey = d.pkey "+ ;
6334 " and cs.customer = td1.customer "
6335
6336
6337 RangD = SQLTableFromQuery(lcSQLString)
6338
6339 *- Cartesian join to create sets of detail UPCs (BCSku/sizebucket) and all
6340 *- possible combinations of RangD that cover them.
6341 *- Result is SQL-side temp table var. RangeSet
6342 *- 1047842/1048069 07/01/10 YIK
6343 *- Added td.pkey
6344 &&td.*,mtch.PKey as FKey, mtch.*, d.PKey +
6345 *--- 1049007 08/24/10 YIK
6346 *- Added .. "where not exists(..) " part and "..and td.total_qty > d.qty" at the end
6347 *- to check for components divisibility
6348 *--- TR 1050754 NOV-15-2010 BR - Removed "where not exists added in 1049007
6349 *--- TR 1084825 03-Mar-2015 BNarayanan added td.division in the select ---
6350 lcSQLString = ;
6351 'select td.division, td.style, td.color_code, td.lbl_code, td.dimension, td.sizebucket, mtch.PKey as FKey, d.PKey, ' + ;
6352 ' mtch.rng_style, mtch.rng_color, mtch.rng_lbl, mtch.rng_pack, mtch.rng_qty, ' + ;
6353 ' td.total_qty, d.qty, 1.0*td.total_qty/d.qty ratio ' + ;
6354 ',td.pkey as dtl_pkey ' + ;
6355 ' from ' + dtl + ' td ' + ;
6356 ' cross join ( ' + ;
6357 ' select * ' + ;
6358 ' from zzxrangh H ' + ;
6359 ' where exists ( ' + ;
6360 ' select * ' + ;
6361 ' from ' + RangD + ' dd ' + ;
6362 ' join ' + dtl + ' td1 ' + ;
6363 ' on dd.Division = td1.Division ' + ;
6364 ' and dd.style = td1.style ' + ;
6365 ' and dd.color_code = td1.color_code ' + ;
6366 ' and dd.lbl_code = td1.lbl_code ' + ;
6367 ' and dd.dimension = td1.dimension ' + ;
6368 ' and dd.size_bk = td1.sizebucket ' + ;
6369 ' where dd.FKey = H.PKey )) mtch ' + ;
6370 ' left join ' + RangD + ' D ' + ;
6371 ' on d.FKey = mtch.PKey ' + ;
6372 ' and d.Division = td.Division ' + ;
6373 ' and d.style = td.style ' + ;
6374 ' and d.color_code = td.color_code ' + ;
6375 ' and d.lbl_code = td.lbl_code ' + ;
6376 ' and d.dimension = td.dimension ' + ;
6377 ' and d.size_bk = td.sizebucket ' + ;
6378 ' and td.total_qty >= d.qty' &&and td.total_qty % d.qty = 0 ' && get qty divisible by range component qty
6379 *==104900708/24/10YIK
6380 RangeSet = SQLTableFromQuery(lcSQLString)
6381
6382 * --- TR 1048126 8/23/10 CM
6383 v_SqlExec(lcSQLString, "tcRangeSet")
6384
6385 *--- TR 1051390 23-Dec-2010 Goutam. Deleted the code below from here and moved down.
6386*!* IF USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6387*!*
6388*!* UPDATE d ;
6389*!* SET ppk_qty = -1 ;
6390*!* FROM (pceipoTD) d ;
6391*!* JOIN tcRangeSet r ;
6392*!* ON d.pkey = r.dtl_pkey ;
6393*!* WHERE d.ppk_action $ 'XM'
6394*!*
6395*!* ENDIF
6396 *=== TR 1051390 23-Dec-2010 Goutam
6397
6398 * === TR 1048126 8/23/10 CM
6399
6400 *- how many different range styles were found for this order
6401 *--- 1049007 08/24/10 YIK
6402 *- Modify logic to determine ambiguos Range Styles
6403*-- lcSQLString = ;
6404*-- ' select count(*) PPKCnt ' + ;
6405*-- ' from (select distinct fkey from ' + RangeSet + ') t'
6406
6407 lcSQLString = "select count(distinct fkey) PPKCnt from " + RangeSet
6408 *= 1049007
6409
6410 llRetVal = v_SqlExec(lcSQLString, "tmp_cnt")
6411 lnPPKCnt = tmp_cnt.PPKCnt
6412
6413 *--- TR 1065271 27-Nov-2012 BNarayanan Log the Possible Range Styles ---
6414 .LogEntry("Maximum number of Range Styles possible: " + ALLTRIM(STR(lnPPKCnt)))
6415 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6416
6417 *--- the result (Query #2):
6418 *- See if any single range style in the RangeSet fully matches DTL
6419 *- 1047842/1048069 07/01/10 YIK
6420 *- added t1dtl_pkey
6421 lcSQLString = ;
6422 ' select Count(*), t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6423 ', max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey ' + ;
6424 ' from ' + dtl + ' dtl ' + ;
6425 ' join ' + RangeSet + ' t1 ' + ;
6426 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6427 ' and dtl.style = t1.style ' + ;
6428 ' and dtl.color_code = t1.color_code ' + ;
6429 ' and dtl.lbl_code = t1.lbl_code ' + ;
6430 ' and dtl.dimension = t1.dimension ' + ;
6431 ' and dtl.sizebucket = t1.sizebucket ' + ;
6432 ' group by t1.Fkey, t1.rng_style, t1.rng_color, t1.rng_lbl, t1.rng_pack, t1.ratio ' + ;
6433 ' having count(*) = (select count(*) from ' + dtl + ') '
6434 llRetVal = v_SqlExec(lcSQLString, "__tmp")
6435 lnCnt = Reccount()
6436
6437 *- 1049007 08/24/10 YIK
6438 *- Exclude Range styles that are not divisible
6439 IF (lnCnt > 0)
6440 SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6441 lnCnt = _TALLY
6442 ENDIF
6443 *=
6444
6445 llSingleMatch = .F.
6446 llAmbig = .F.
6447 *- 1047842/1048069 07/01/10 YIK
6448 *- Added ValidDetail
6449 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6450 Create Cursor q_Result( ValidRange Memo, ValidRatio Memo, ValidDetail Memo)
6451 Do Case
6452 Case lnCnt > 1
6453 *- 1049007 08/24/10 YIK
6454 USE IN SELECT("__tmp")
6455 USE DBF("__implode_tmp") IN 0 AGAIN ALIAS __tmp
6456 *=
6457 llAmbig = .T. && ambiguos, give error message and do not continue
6458 Case lnCnt = 1
6459 llSingleMatch = .T.
6460 *- 1047842/1048069 07/01/10 YIK
6461 *- Added ValidDetail
6462 *- 1049007 08/26/10 YIK
6463 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6464* Insert Into q_Result (ValidRange, ValidRatio ,ValidDetail) Values( Alltr(Str(__tmp.fkey)), Trans(__tmp.ratio), Alltr(Str(__tmp.t1dtl_Pkey)))
6465 Insert Into q_Result (ValidRange, ValidRatio , ValidDetail) ;
6466 Values( Alltr(Str(__implode_tmp.fkey)), Trans(__implode_tmp.ratio), Alltr(Str(__implode_tmp.t1dtl_Pkey)))
6467
6468 Otherwise
6469 Endcase
6470 *- 1049007 08/24/10 YIK
6471 *- commented out. This method is not called with this parameter = .T.
6472*--- IF tlNoConsol
6473*--- SELECT * INTO CURSOR __implode_tmp FROM __tmp WHERE ratio > 0 AND MOD(ratio,1) = 0
6474*--- ENDIF
6475
6476 lnResult = lnCnt
6477
6478 If !llAmbig
6479 *- If none single range style in the RangeSet fully matches DTL,
6480 *- or even if a match was found
6481 *- start going through combinations of 2,3... - may be ambiguous
6482
6483 *- 1047842/1048069 07/01/10 YIK
6484 *- added t1dtl_pkey
6485 lcFldStr = ' select Count(*), t1.Fkey, max(case when t1.ratio = floor(t1.Ratio)then t1.dtl_Pkey else null end ) as t1dtl_Pkey '
6486
6487 lcTopStr = ;
6488 ' from ' + dtl + ' dtl ' + ;
6489 ' join ' + RangeSet + ' t1 ' + ;
6490 ' on dtl.division = t1.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6491 ' and dtl.style = t1.style ' + ;
6492 ' and dtl.color_code = t1.color_code ' + ;
6493 ' and dtl.lbl_code = t1.lbl_code ' + ;
6494 ' and dtl.dimension = t1.dimension ' + ;
6495 ' and dtl.sizebucket = t1.sizebucket '
6496
6497 lcBotStr = ' having count(*) = (select count(*) from ' + dtl + ') '
6498 lcMaxMinStr = ' and max(t1.ratio) = min(t1.ratio) ' && TR 1050754 NOV-15-2010 BR
6499 lcMiddleStr = ''
6500 lcCoalStr_pkey = 't1.pkey'
6501 lcCoalRevStr_pkey = 't1.pkey'
6502 lcCoalStr_ratio = 't1.ratio'
6503 lcCoalRevStr_ratio = 't1.ratio'
6504 lcGroupFkeyStr = ' t1.FKey'
6505 lcGroupStr = ''
6506
6507 *--- TR 1065271 27-Nov-2012 BNarayanan ---
6508 *lnPrepacks = Min(lnPPKCnt, 6)
6509 lnPrepacks = Min(lnPPKCnt, .nMaxStylesImplode)
6510 .Logentry("Maximum number of Range Styles considered: " + ALLTRIM(STR(lnPrepacks)))
6511 *=== TR 1065271 27-Nov-2012 BNarayanan ===
6512
6513 lcFldStr_ratio = ', max(' + lcCoalStr_ratio + ') as t1_ratio ' && TR 1049817 Oct-12-2010 BR
6514
6515 For j = 2 To lnPrepacks && 6 different range styles in a single order is enough?
6516 llFoundNext = .F.
6517
6518 lcnum = Trans(j, "9")
6519 lcPrevNum = Trans(j - 1, "9")
6520 lcCoalStr_pkey = lcCoalStr_pkey + ', t' + lcnum + '.Pkey'
6521 lcCoalRevStr_pkey = 't' + lcnum + '.Pkey, ' + lcCoalRevStr_pkey
6522
6523 lcMaxMinStr = lcMaxMinStr + ' and max(t'+ lcnum +'.ratio) = min(t'+ lcnum +'.ratio) ' && TR 1050754 NOV-15-2010 BR
6524
6525 *-- TR 1049817 Oct-12-2010 BR
6526 *lcCoalStr_ratio = lcCoalStr_ratio + ', t' + lcnum + '.ratio'
6527 *lcCoalRevStr_ratio = 't' + lcnum + '.ratio, ' + lcCoalRevStr_ratio
6528 lcCoalStr_ratio = 't' + lcnum + '.ratio'
6529 *== TR 1049817 Oct-12-2010 BR
6530
6531 lcGroupFkeyStr = lcGroupFkeyStr + ', t' + lcnum + '.Fkey '
6532
6533 *--- TR 1049817 Oct-12-2010 BR
6534 *lcGroupStr = lcGroupFkeyStr + ', coalesce(' + lcCoalStr_ratio + '), coalesce(' + lcCoalRevStr_ratio + ') '
6535 lcGroupStr = lcGroupFkeyStr
6536 *=== TR 1049817 Oct-12-2010 BR
6537
6538 lcFldStr = lcFldStr + ", t" + lcnum + '.Fkey AS t' + lcnum + '_Fkey'
6539 *- 06/30/10 YIK LOCAL ONLY
6540 *- Add dtl pkey (one of them that belongs to this range style) with ratio = integer, not fraction.
6541 *- MAX(case when t2.ratio = floor(t2.Ratio)then t2.dtl_Pkey else null end) as t2dtl_Pkey
6542 lcFldStr = lcFldStr + ", MAX(case when t" + lcnum + ".ratio = floor(t" + lcnum + ".ratio) " + ;
6543 " then t" + lcnum + ".dtl_Pkey else null end) AS t" + lcnum + 'dtl_Pkey'
6544
6545 lcMiddleStr = lcMiddleStr + ;
6546 "join " + RangeSet + " t" + lcnum + ;
6547 ' on dtl.division = t' + lcnum + '.division ' + ; && TR 1084825 03-Mar-2015 BNarayanan
6548 ' and dtl.style = t' + lcnum + '.style ' + ;
6549 ' and dtl.color_code = t' + lcnum + '.color_code ' + ;
6550 ' and dtl.lbl_code = t' + lcnum + '.lbl_code ' + ;
6551 ' and dtl.dimension = t' + lcnum + '.dimension ' + ;
6552 ' and dtl.sizebucket = t' + lcnum + '.sizebucket ' + ;
6553 ' and t' + lcnum + '.Fkey > t' + lcPrevNum + '.Fkey '
6554
6555 lcWhereStr = 'where coalesce(' + lcCoalStr_pkey + ') = coalesce(' + lcCoalRevStr_pkey + ') ' + ;
6556 ' Group by ' + lcGroupStr
6557
6558 *--- TR 1049817 Oct-12-2010 BR
6559 *lcFldStr_ratio = ', coalesce(' + lcCoalStr_ratio + ') ratio ' && get ratio
6560 lcFldStr_ratio = lcFldStr_ratio + ', max(' + lcCoalStr_ratio + ') as t' + lcnum + '_ratio ' && get ratio
6561 *=== TR 1049817 Oct-12-2010 BR
6562
6563 *--- TR 1050754 NOV-15-2010 BR
6564 *lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr
6565 lcSQLResultStr = lcFldStr + lcFldStr_ratio + lcTopStr + lcMiddleStr + lcWhereStr + lcBotStr + lcMaxMinStr
6566 *=== TR 1050754 NOV-15-2010 BR
6567
6568 llRetVal = v_SqlExec(lcSQLResultStr, "__tmp")
6569 lnCnt = Reccount()
6570 llFoundNext = (lnCnt = 1)
6571 *- ambig when either prev or this SQL returned more than 1 row or
6572 *- one match was found before AND one is found now - making it two.
6573 If lnCnt > 0
6574 Scan
6575 *- ADD CONDITION TO CHECK THAT THE RATIO IS INTEGER, i.e. detail qty is properly
6576 *- divisible by the number of items in the range style!!!
6577
6578 *---TR 1049817 Oct-12-2010 BR
6579 lcRatioCnt = EVALUATE('t'+lcnum+'_ratio')
6580 *If Mod(ratio, 1) <> 0 && not divisible, exclude
6581 If Mod(t1_ratio, 1) <> 0 OR Mod(lcRatioCnt, 1) <> 0 && not divisible, exclude
6582 *===TR 1049817 Oct-12-2010 BR
6583 Else
6584 lcInsertStr = Trans(fkey)
6585 *- 1047842 06/17/10 YIK
6586 lcInsertDtlStr = TRANSFORM(t1dtl_Pkey)
6587
6588 For lnCounter = 2 To j
6589
6590 *- TR 1055009 FH - added If statement
6591 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6592
6593 else
6594 *- 1047842 06/17/10 YIK
6595 *- lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + lcnum + '_Fkey ' ))
6596 lcInsertStr = lcInsertStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_Fkey ' ))
6597 *- 1047842/1048069 07/01/10 YIK LOCAL ONLY
6598 *- Added ValidDetail
6599 lcInsertDtlStr = lcInsertDtlStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + 'dtl_Pkey ' ))
6600 ENDIF
6601 *- TR 1055009 FH
6602
6603 Endfor
6604
6605 *---TR 1049817 Oct-12-2010 BR
6606 *lcInsertStr = lcInsertStr + ", " + Trans(ratio)
6607 lcInsertRatioStr = Trans(t1_ratio)
6608
6609 For lnCounter = 2 To j
6610 *- TR 1055009 FH - added If statement
6611 IF MOD(Eval("t" + Trans(lncounter, "9") + '_ratio '), 1) <> 0
6612
6613 ELSE
6614 lcInsertRatioStr = lcInsertRatioStr + ", " + Trans(Eval("t" + Trans(lncounter, "9") + '_ratio ' ))
6615 ENDIF
6616 *- TR 1055009 FH - added If statement
6617 ENDFOR
6618 *== =TR 1049817 Oct-12-2010 BR
6619
6620 *- 1047842/1048069 07/01/10 YIK
6621 *- Added ValidDetail
6622 *- TR 1049817 Oct-12-2010 BR - Adding ValidRatio
6623 Insert Into q_Result (ValidRange, ValidRatio, ValidDetail) Values(lcInsertStr, lcInsertRatioStr, lcInsertDtlStr)
6624
6625 Endif
6626 Endscan
6627 Endif
6628 lnResultCnt = Recc("q_Result")
6629 llAmbig = (lnResultCnt > 1)
6630 llSingleMatch = (lnResultCnt = 1)
6631 If llAmbig
6632 lnResult = lnResultCnt
6633 Exit
6634 Endif
6635 Endfor
6636 If llSingleMatch
6637 lnResult = 1
6638 IF NOT tlNoConsol
6639 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6640
6641 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6642 .ConsolidateRangeP(pceipoTD, "q_Result", pnFkey, pcRngp_conv, pcRng_Impl)
6643 ENDIF
6644 Endif
6645 Else && ambiguous
6646 lnResult = lnCnt
6647 Endif
6648
6649 *--- TR 1051390 23-Dec-2010 Goutam
6650 IF lnResult = 1 AND USED("tcRangeSet") AND RECCOUNT("tcRangeSet") > 0
6651 UPDATE d ;
6652 SET ppk_qty = -1 ;
6653 FROM (pceipoTD) d ;
6654 JOIN tcRangeSet r ;
6655 ON d.pkey = r.dtl_pkey ;
6656 WHERE d.ppk_action $ 'XM'
6657 ENDIF
6658 *=== TR 1051390 23-Dec-2010 Goutam
6659
6660 Endwith
6661 Return lnResult
6662
6663 Procedure ConsolidateRangeP
6664 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli added pcRngp_conv in parameter list ---
6665 *--- TR 1060800 24-May-2012 Goutam. Added pcRng_Impl in the parameter list
6666 Lparameters pceipoTD, q_Result, pnFkey, pcRngp_conv, pcRng_Impl
6667
6668 Local llRetVal, lnOldSelect, lcSQLString, lcSizeBucket, lnLen, lnRatio, oDtl
6669
6670 LOCAL lcDvision && 1058336 FH
6671
6672 *--- TechRec 1049646 08-Mar-2011 TShenbagavalli ---
6673 LOCAL lnOrgPrice
6674 IF EMPTY(pcRngp_conv )
6675 pcRngp_conv = "N"
6676 ENDIF
6677 *=== TechRec 1049646 08-Mar-2011 TShenbagavalli ===
6678
6679 llRetVal = .T.
6680 lnOldSelect = Select()
6681
6682 *- insert range styles that match zzxrangd.fkey from q_result
6683 *- into pceipotd.
6684 *- parse the string from cursor q_result to get the list of fkeys
6685 *- 1047842/1048069 07/01/10 YIK
6686 *- Moved Locate down
6687*-- Select (pceipoTD)
6688*-- Locate For fkey = pnFkey
6689*-- Scatter Name oDtl Memo
6690
6691 Declare aRange[1]
6692 aRange = ''
6693 Select q_Result
6694 Scatter Memvar Memo
6695 *- 1030497 02/29/08 TT
6696 *--StringToArray(m.ValidRange, @aRange, ",")
6697
6698 *--TR 1040854 Jun-11-09 BR
6699 *-3rd parameter in StringToArray is pn_columns, 4th is delimeter..
6700 *.oCopyUtil.StringToArray(m.ValidRange, @aRange, ",")
6701 .oCopyUtil.StringToArray(m.ValidRange, @aRange,, ",")
6702 *==TR 1040854 Jun-11-09 BR
6703
6704 *- 1030497 02/29/08 TT
6705 *-- TR 1049817 Oct-12-2010 BR
6706 *lnLen = Alen(aRange) - 1 && the last element is ratio
6707 lnLen = Alen(aRange)
6708 *lnRatio = Val( aRange[lnLen + EVAL(pnNum)] )
6709 *== TR 1049817 Oct-12-2010 BR
6710
6711 *- 1047842/1048069 07/01/10 YIK
6712 Declare aDetail[1]
6713 aDetail = ''
6714 .oCopyUtil.StringToArray(m.ValidDetail, @aDetail,, ",") && 1049687 FH 10/08/10(added as part of 1049817)
6715 *= 1047842/1048069
6716
6717 *-- TR 1049817 Oct-12-2010 BR
6718 DECLARE aRatios[1]
6719 aRatios = ''
6720 .oCopyUtil.StringToArray(m.ValidRatio, @aRatios,, ",")
6721 *== TR 1049817 Oct-12-2010 BR
6722
6723 For j = 1 To lnLen
6724 lcFkey = aRange[j]
6725 *- 1047842/1048069 07/01/10 YIK
6726 lnDtl_Pkey = EVALUATE(aDetail[j])
6727 lnRatio = EVALUATE(aRatios[j]) && TR 1049817 Oct-12-2010 BR
6728
6729 Select (pceipoTD)
6730 Locate For pkey = lnDtl_Pkey
6731 Scatter Name oDtl Memo
6732 *= 1047842/1048069
6733 *--- TechRec 1078967 28-Aug-2014 vkrishnamurthy ---
6734*!* v_SqlExec("select * from zzxrangh where pkey = " + lcFkey, "__RangH")
6735 *--- TR 1084825 20-Feb-2015 BNarayanan removed the column h.RNG_PACK_001, which is not available in zzxrangh table and where clause ---
6736 lcSQL = " Select h.DIVISION,h.RNG_LBL,h.SEASON,h.COORD_CODE,h.SELL_PRICE,h.RNG_QTY, "+ ;
6737 " coalesce(cs.a_price,h.a_price) as a_price, "+;
6738 " coalesce(cs.b_price,h.b_price) as b_price, "+;
6739 " coalesce(cs.c_price,h.c_price) as c_price, "+;
6740 " coalesce(cs.d_price,h.d_price) as d_price, "+;
6741 " coalesce(cs.e_price,h.e_price) as e_price, "+;
6742 " h.PKEY,h.RNG_TYPE,h.RNG_BK,h.MULTIUPC_OK, " + ;
6743 " h.SOURCETYPE,h.RNG_PACK,h.RNG_STYLE,h.RNG_COLOR " + ;
6744 " From zzxrangh h " + ;
6745 " Left Join zzxcsrgh cs "+ ;
6746 " on cs.hdrpkey = h.pkey and cs.dtlpkey = 0 "+ ;
6747 " and cs.customer = "+ SQLFormatChar(oDtl.Customer) + ;
6748 " where h.pkey = " + lcFkey && 1084825
6749 v_SqlExec(lcSQL ,"__RangH")
6750 *=== TechRec 1078967 28-Aug-2014 vkrishnamurthy ===
6751 lcDvision = __RangH.division && 1058336 FH
6752
6753 oDtl.Style = __RangH.rng_style
6754 oDtl.color_code = __RangH.rng_color
6755 oDtl.lbl_code = __RangH.rng_lbl
6756 oDtl.Dimension = __RangH.rng_pack
6757 oDtl.rng_style = __RangH.rng_style
6758 oDtl.rng_color = __RangH.rng_color
6759 oDtl.rng_lbl = __RangH.rng_lbl
6760 oDtl.rng_pack = __RangH.rng_pack
6761 oDtl.rng_qty = __RangH.rng_qty
6762 oDtl.rng_type = __RangH.rng_type
6763 *- don't have to have upc or sku for the imploded range style
6764 oDtl.upc = ''
6765 oDtl.sku = ''
6766 oDtl.coord_code = __RangH.coord_code
6767 oDtl.a_price = __RangH.a_price
6768 oDtl.b_price = __RangH.b_price
6769 oDtl.c_price = __RangH.c_price
6770 oDtl.d_price = __RangH.d_price
6771 oDtl.e_price = __RangH.e_price
6772 *- clear err msg and err flag which may have error after unsuccessful implosion
6773 oDtl.Errs_Msg_D = ""
6774
6775 *- 1009211 03/09/05 YIK
6776 *- Initializ3e errs_flg_d to N, not blank
6777 *- oDtl.Errs_Flg_D = " "
6778 oDtl.Errs_Flg_D = "N"
6779 *- org_price is based on zzocntrc (cust sales) price_code
6780 *- we'll get the proper price_code in ValidOrderControl()
6781 *- and the org_price will be updated in ResolvePriceFromRangeStyle()
6782
6783 *- 1009211 02/24/05 YIK
6784 *- Keep quantity in cases and use price per case.
6785 *- and zero out orig price which will be resolved.
6786 *- oDtl.total_qty = __RangH.rng_qty*lnRatio
6787
6788 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6789 lnOrgPrice = oDtl.org_price
6790 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6791
6792 oDtl.total_qty = lnRatio
6793 oDtl.org_price = 0
6794
6795 *--- TR 1060800 24-May-2012 Goutam.
6796 oDtl.Rng_Impl = pcRng_Impl
6797 oDtl.Rngp_conv = pcRngp_conv
6798 *=== TR 1060800 24-May-2012 Goutam.
6799
6800 *--- TechRec 1049646 07-Mar-2011 TShenbagavalli ---
6801 IF pcRngp_conv = "R"
6802 *--- TechRec 1057383 15-Dec-2011 jisingh ---
6803*!* oDtl.ppk_qty = __RangH.rng_qty
6804*!* oDtl.org_price = lnOrgPrice / __RangH.rng_qty
6805*!* oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6806*!* oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6807*!* oDtl.total_qty = oDtl.total_qty * __RangH.rng_qty
6808*!* oDtl.ppk_action = 'X'
6809
6810 IF EMPTY(oDtl.ppk_action)
6811 oDtl.org_price = lnOrgPrice
6812 oDtl.total_qty = __RangH.rng_qty*lnRatio &&*--- TR 1059965 6-Mar-12 Venuk
6813 ENDIF
6814
6815 IF oDtl.ppk_action = "B"
6816 oDtl.org_price = lnOrgPrice
6817 oDtl.ppk_qty = __RangH.rng_qty
6818 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6819 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6820 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6821 oDtl.ppk_action = 'X'
6822 ENDIF
6823
6824 IF oDtl.ppk_action = "Q" && Qty conversion only
6825 oDtl.org_price = lnOrgPrice
6826 oDtl.ppk_qty = __RangH.rng_qty
6827 oDtl.retail1 = oDtl.retail1
6828 oDtl.retail2 = oDtl.retail2
6829 oDtl.total_qty = oDtl.total_qty *__RangH.rng_qty
6830 oDtl.ppk_action = 'M'
6831 ENDIF
6832
6833 IF oDtl.ppk_action = "P" && Price conversion only
6834 oDtl.org_price = lnOrgPrice
6835 oDtl.ppk_qty = __RangH.rng_qty
6836 oDtl.retail1 = oDtl.retail1 / __RangH.rng_qty
6837 oDtl.retail2 = oDtl.retail2 / __RangH.rng_qty
6838 oDtl.total_qty = oDtl.total_qty
6839 oDtl.ppk_action = 'D'
6840 ENDIF
6841 *=== TechRec 1057383 15-Dec-2011 jisingh ===
6842 ENDIF
6843 *=== TechRec 1049646 07-Mar-2011 TShenbagavalli ===
6844
6845 *= 1009211
6846 *- 1047842/1048069 07/01/10 YIK
6847 *- Clear po1_upc and po1_sku as they get populated on the way out
6848 oDtl.po1_upc = ''
6849 oDtl.po1_sku = ''
6850
6851
6852 *- Per JR, put into the 1st available size bucket
6853 llRetVal = vl_scold(oDtl.division, , "__tmp", ;
6854 oDtl.rng_style, oDtl.rng_color, oDtl.rng_lbl, oDtl.rng_pack)
6855 If !llRetVal
6856 Exit
6857 Else
6858 *-- TR 1049817 Oct-12-2010 BR
6859 *oDtl.sizebucket = At("Y", __tmp.sizes)
6860 oDtl.sizebucket = __RangH.rng_bk
6861 oDtl.rng_bk = oDtl.sizebucket
6862 lcSzStr = __tmp.sizes
6863 llValidRngBk = IIF(SUBSTR(lcSzStr,oDtl.rng_bk,1) = 'Y', .T.,.F.)
6864 *== TR 1049817 Oct-12-2010 BR
6865 Endif
6866 *-- TR 1049817 Oct-12-2010 BR
6867 IF !llValidRngBk
6868 oDtl.errs_msg_d = oDtl.errs_msg_d + CRLF + "Invalid Range Bucket" + CRLF
6869 oDtl.errs_flg_d = 'Y'
6870 ELSE
6871 *== TR 1049817 Oct-12-2010 BR
6872 If !v_GetSizeHeadings(oDtl.division, oDtl.Style, "__xSizer")
6873 llRetVal = .F.
6874 Exit
6875 Endif
6876 lcSizeBucket = "Size" + Trans(oDtl.sizebucket, "@L 99") && zzxsizer bucket field names
6877 oDtl.size_desc = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
6878
6879 *--- TR 1059965 6-Mar-12 Venuk
6880 *oDtl.pkey = v_nextPkey("ZZEIPOID")
6881 * ENDIF
6882 ENDIF
6883 oDtl.pkey = v_nextPkey("ZZEIPOID")
6884 *=== TR 1059965 6-Mar-12 Venuk
6885
6886 Select (pceipoTD)
6887 Append Blank
6888
6889 *--- TR 1065271 11-Jan-2013 BNarayanan update the memo columns also ---
6890 *Gather Name oDtl
6891 Gather Name oDtl memo
6892 *=== TR 1065271 11-Jan-2013 BNarayanan ===
6893
6894 Endfor
6895 If llRetVal
6896 *- delete components
6897 Delete For fkey = pnFkey And !Empty(Style) ;
6898 AND !Empty(division) And !Empty(customer) ;
6899 AND Empty(rng_style) And implosion <> "Y" ;
6900 AND division = lcDvision ; && 1058336 FH - we can have different Division with the same fkey. don't want to delete it.
6901 IN (pceipoTD)
6902 Endif
6903 Select (lnOldSelect)
6904 Return llRetVal
6905 *========== 1006607 09/02/04 YIK
6906
6907 *----------------------------------------------------------------------------------------
6908
6909 *--- TechRec 1005163 17-May-2004 GS ---
6910 *-- Validating SLN vs. Prepack
6911 Procedure CheckSLN
6912 Parameters pceipoTH, pceipoTD, pceipoTS
6913 Local lnOldDtlPKey, lnPPK_SLN_Diff, lcPPackError, lcDtlError, llDtlHasError, ;
6914 lcColor_code, lcLbl_code, lcDimension, lnSLN_Qty, lnSizeBucket, llRangeStyle, lcDtl_Color, lcStyle, ; &&*- TR 1064758 FH && new &&--- TechRec 1061416 17-May-2012 jjanand ===
6915 lcDtl_lbl_code && *-TR 1075660 SK
6916
6917 lnOldDtlPKey = -1
6918 llDtlHasError = .T. && To prevent This.CheckSlnSet() call on the first Scan pass.
6919 *--- TR 1023892 NH
6920 lnOldSelect = SELECT()
6921 llRetVal = .t.
6922 *=== TR 1023892 NH
6923 Select (pceipoTS)
6924 Set Order To Tag fkey
6925
6926 SCAN
6927 *--- TR 1035223 NH : When SkipSlnChk is 'Y' just skip the record
6928 IF SkipSlnChk = "Y"
6929 LOOP
6930 ENDIF
6931 *=== TR 1035223 NH
6932
6933 If lnOldDtlPKey != fkey
6934 If !llDtlHasError And !llRangeStyle && Previous Detail was OK 1010975 YIK & NH
6935 *-- this checks that there is no more records left in BC PrePack info
6936 *-- after all matching to SLNs deleted. Made as a separate routine
6937 *-- because it must be called when detail key changed and when scan is finished.
6938 *-- Error info applied to Detail.
6939 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
6940 Endif
6941 lnOldDtlPKey = fkey
6942 lcPPackError = ""
6943 lcDtlError = ""
6944 Select (pceipoTD)
6945 *- 1008909 01/18/05 YIK
6946 *- For range styles the seek will fail because the original detail which has pkey matching SLNs pkey
6947 *- has been deleted and replaced with components. Now none pceipoTD.pkey matches fkey from SLNs.
6948 *- Therefore if SEEK() fails - don't error out, just loop. This is a range style.
6949 llRangeStyle = !Seek(lnOldDtlPKey, pceipoTD, "PKey")
6950 lcDtl_Color = IIF(llRangeStyle, NULL, color_code) && from tceipotd &&--- TechRec 1061416 17-May-2012 jjanand ===
6951 lcDtl_lbl_code = IIF(llRangeStyle, NULL, lbl_code) && from tceipotd *--- TR 1075660 03-Jan-2014 SK ===
6952
6953 *- 1013522 10/17/05 12/02/05 YIK
6954 *- Check for the range style type P. For it there's no explosion to components and the range
6955 *- style info is not written into detail table, but it is still a range style and we should skip it.
6956 Local Array laRangP[1]
6957 laRangP[1] = 0
6958 *--- TR 1023892 NH
6959 IF .lALLOW_RANGE_HDR_LABEL
6960 *llRangeStyle = llRangeStyle OR (USED(lceipoTD_Rng) and SEEK(lnOldDtlPKey, lceipoTD_Rng,"Pkey"))
6961 SELECT COUNT(*) ;
6962 FROM __RangeP r JOIN (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6963 ON d.division = r.division ;
6964 AND d.STYLE = r.rng_style ;
6965 AND d.color_code = r.rng_color ;
6966 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
6967 AND d.DIMENSION = r.rng_pack ;
6968 WHERE d.pkey = lnOldDtlPKey ; && TR 1023892 NH
6969 INTO ARRAY laRangP
6970 ELSE
6971 *=== TR 1023892 NH
6972 Select Count(*) ;
6973 FROM __RangeP r Join (pceipoTD) d ; && the cursor of range P from zzxrangH, created in PrepackConversion()
6974 On d.division = r.division ;
6975 AND d.Style = r.rng_style ;
6976 AND d.color_code = r.rng_color ;
6977 AND d.lbl_code = r.rng_lbl ;
6978 AND d.Dimension = r.rng_pack ;
6979 INTO Array laRangP
6980 ENDIF && TR 1023892 NH
6981 llRangeStyle = llRangeStyle Or laRangP[1] > 0
6982 *= 1013522 YIK
6983
6984 llDtlHasError = (Errs_Flg_D = 'Y')
6985 *- 1008909 01/18/05 YIK
6986 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
6987 If llDtlHasError Or llRangeStyle
6988 *= 1008909
6989 Loop && For unresolved Details do not even bother...
6990 Endif
6991
6992 *-- This SQL returns VERTICAL PrePack breakdown with Color_Code and Lbl_Code
6993 *-- set to NULL if any C and/or L can be used for the PrePack:
6994 *- 08/25/04 YIK
6995 *- fixed typo : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.color_Code end ) as Lbl_Code,"
6996 *- to : NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code,"
6997 lcSQL = ;
6998 "select h.Active_Ok,h.Pack_Qty,h.Size_Code, d.Division,d.PPK_Code, c.style," +; && *- TR 1064758 FH - added style
6999 " NullIf(d.Color_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Color_Code end ) as Color_Code," +;
7000 " NullIf(d.Lbl_Code, case h.MulClLb_Ok when 'Y' then 'ALL' else d.Lbl_Code end ) as Lbl_Code," +;
7001 " d.Dimension, Pack_Total," +;
7002 " Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7003 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7004 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7005 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7006 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7007 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 as Qty," +;
7008 " Size_Num as Sizebucket" +;
7009 " from zzxscolr c" +;
7010 " join zzxstylr st"+;
7011 " on st.pkey = c.fkey "+;
7012 " join zzxppakh h" +;
7013 " on h.Division = c.Division" +;
7014 " and h.PPK_CODE = c.Dimension" +;
7015 " and h.Size_Code = st.Size_Code" +; && TR 1026025
7016 " join zzxppakd d" +;
7017 " on d.Fkey = h.PKey" +;
7018 " cross join zzxbuckt" +;
7019 " where c.Division = " + SQLFormatChar(division ) + ;
7020 " and c.Style = " + SQLFormatChar(Style ) + ;
7021 " and c.Color_Code= " + SQLFormatChar(color_code) + ;
7022 " and c.Lbl_Code = " + SQLFormatChar(lbl_code ) + ;
7023 " and c.Dimension = " + SQLFormatChar(Dimension ) + ;
7024 " and c.PPack_Ok = 'Y'" +;
7025 " and Pack01_Qty*sz01+Pack02_Qty*sz02+Pack03_Qty*sz03+Pack04_Qty*sz04+" +;
7026 " Pack05_Qty*sz05+Pack06_Qty*sz06+Pack07_Qty*sz07+Pack08_Qty*sz08+" +;
7027 " Pack09_Qty*sz09+Pack10_Qty*sz10+Pack11_Qty*sz11+Pack12_Qty*sz12+" +;
7028 " Pack13_Qty*sz13+Pack14_Qty*sz14+Pack15_Qty*sz15+Pack16_Qty*sz16+" +;
7029 " Pack17_Qty*sz17+Pack18_Qty*sz18+Pack19_Qty*sz19+Pack20_Qty*sz20+" +;
7030 " Pack21_Qty*sz21+Pack22_Qty*sz22+Pack23_Qty*sz23+Pack24_Qty*sz24 > 0" +;
7031 " and h.Active_ok = 'Y' " &&*--- TR 1046757 12-AUG-2010 MANI. Added condtion h.Active_ok = 'Y' ===
7032
7033 v_SqlExec(lcSQL, "tcPPK")
7034 If Reccount("tcPPK") > 0
7035 lnPPK_SLN_Diff = pack_qty
7036 Else
7037 lnPPK_SLN_Diff = 0
7038 Endif
7039 Endif
7040 *- 1008909 01/18/05 YIK
7041 *- Added ..OR llRangeStyle to check SLNs only for empty range style.
7042 If llDtlHasError Or llRangeStyle
7043 Loop && For unresolved Details do not even bother...
7044 Endif
7045
7046 Select (pceipoTS)
7047
7048 If Reccount("tcPPK") = 0
7049 lcPPackError = "Unable to find a Prepack for this SKU." && this error applied to all SLNs and SO Detail
7050 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7051 Loop
7052 Endif
7053
7054 If tcPPK.active_ok = 'N'
7055 lcPPackError = "Prepack is not Enabled." && this error applied to all SLNs and SO Detail
7056 Replace Errs_Flg_S With 'Y', Errs_Msg_S With lcPPackError
7057 Loop
7058 Endif
7059
7060 If Errs_Flg_S = 'Y'
7061 lcDtlError = lcDtlError + Errs_Msg_S + CRLF
7062 Loop && UPC/EAN/SKU is unesolved.
7063 Endif
7064
7065 lcStyle = style && *- TR 1064758 FH
7066 lcColor_code = color_code
7067 lcLbl_code = lbl_code
7068 lcDimension = Dimension
7069 lnSLN_Qty = SLN_Qty
7070 lnSizeBucket = sizebucket
7071
7072 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack......", vcLogName)
7073 Select tcPPK
7074
7075 *-*- TR 1064758 FH - added style, what if DTL style doesn't match SLN style
7076 Locate For style = lcStyle AND Dimension = lcDimension And Qty = lnSLN_Qty And sizebucket = lnSizeBucket ;
7077 AND Nvl(color_code, NVL(lcDTL_Color, lcColor_code)) = lcColor_code ; &&--- TechRec 1061416 17-May-2012 jjanand ===
7078 AND Nvl(lbl_code, NVL(lcDtl_lbl_code, lcLbl_code)) = lcLbl_code && *--- TR 1075660 03-Jan-2014 SK ===
7079
7080 If Found()
7081 Delete && in PrePack info leave only unresolved ones.
7082 Else
7083 Replace Errs_Flg_S With 'Y', Errs_Msg_S With "Invalid Prepack Component." In (pceipoTS)
7084 *lcDtlError = lcDtlError + "Invalid Prepack Component" + ;
7085 * " Color:"+Trim(lcColor_Code)+"; Lbl:"+Trim(lcLbl_Code)+;
7086 * "; Dim:" + Trim(lcDimension)+"; Size:" + Trim(&pceipoTS..Size_Desc) +;
7087 * "(Bkt# "+Transform(lnSizebucket)+"); Qty:"+Transform(lnSLN_Qty) + CRLF
7088 If !"Has errors in SLNs."$lcDtlError
7089 lcDtlError = lcDtlError + "Has errors in SLNs."+CRLF
7090 Endif
7091 Endif
7092
7093 *lnPPK_SLN_Diff = lnPPK_SLN_Diff - Qty
7094 *if lnPPK_SLN_Diff < 0
7095 *endif
7096 Endscan
7097 .AdvanceThermoTotalWithCaptionPlus("Validating SLN vs. Prepack.........", vcLogName)
7098
7099 *- 1008909 01/18/05 YIK
7100 *- Added ..AND !llRangeStyle to check SLNs only for empty range style.
7101 If !llDtlHasError And !llRangeStyle && Detail was OK and is not a range style
7102 This.CheckSlnSet(lnOldDtlPKey, @pceipoTD, @pceipoTS, @lcPPackError, @lcDtlError)
7103 Endif
7104 *- 1013522 10/17/05 12/02/05 YIK
7105 If Used("__RangeP")
7106 Use In __RangeP
7107 Endif
7108 *=
7109 *--- TR 1023892 NH
7110 SELECT(lnOldSelect)
7111 RETURN llRetVal
7112 *== TR 1023892 NH
7113
7114 Endproc
7115
7116 *----------------------------------------------------------------------------------------
7117 *-- Checks that SLN set is the same as Prepack. tnQty_Diff is Total_PPK_qty - Total_SLN_Qty
7118 *-- Populates Detail Error with SLN error -- TechRec 1005163 17-May-2004 GS ---
7119 Procedure CheckSlnSet
7120 Parameters tnDtlPKey, tcEiPOtd, tcEiPOts, tcPPKError, tcDtlError
7121
7122 Local lnOldSelect
7123
7124 lnOldSelect = Select()
7125
7126 If !Empty(tcPPKError)
7127 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7128 Replace Errs_Msg_D With tcPPKError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7129 Return
7130 Endif
7131
7132 Select tcPPK
7133 Scan
7134 tcDtlError = tcDtlError +;
7135 "Missing Prepack Component" + ;
7136 IIF(Isnull(color_code),"", " Color:"+Trim(color_code)+";")+;
7137 IIF(Isnull(lbl_code),"", " Lbl:"+Trim(lbl_code)+";")+;
7138 " Dim:" + Trim(Dimension)+"; SizeBucket#:"+Transform(sizebucket)+;
7139 "; Qty:"+Transform(Qty) + CRLF
7140 Endscan
7141
7142 If !Empty(tcDtlError)
7143 *=Seek(tnDtlPKey, tcEipoTD, "PKey")
7144 Local lcErr
7145 lcErr = Trim(Evaluate(tcEiPOtd+".Errs_Msg_D"))
7146 If !Empty(lcErr)
7147 tcDtlError = CRLF + tcDtlError
7148 Endif
7149 Replace Errs_Msg_D With lcErr + tcDtlError, Errs_Flg_D With 'Y' In (tcEiPOtd)
7150 Endif
7151
7152 Select (lnOldSelect)
7153
7154 Endproc
7155
7156 *----------------------------------------------------------------------------------------
7157
7158 ************************************************************************************
7159 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7160 * 1. Try to substitute lbl_code with customer label when have the following conditions:
7161 * Header: customer
7162 * Detail: division,style,color_code
7163 * 850(i) control: resv_label= 'Y' using header.customer,detail.division (--not yet
7164 * resolve all detail division into header )
7165 ************************************************************************************
7166 Procedure ResolveCustomerLabel
7167 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7168 pceipoTS && *--- TechRec 1005163 18-May-2004 GS ---
7169 Local llRetVal, lnOldSelect
7170 llRetVal = .T.
7171 lnOldSelect = Select()
7172 With This
7173 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
7174 *--- TechRec 1048667 03-May-2011 GSternik ---
7175 *-- Not needed, already done in the calling CheckDetail
7176 *.LogEntry("Cascading Customer To Detail.")
7177 *llRetVal= llRetVal And .CascadingCustomerToDetail(pceipoTH, pceipoTD)
7178 *=== TechRec 1048667 03-May-2011 GSternik ===
7179 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
7180 .LogEntry("Substituding customer label.")
7181 llRetVal= llRetVal And .SubstitudeValidLabel(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7182 .AdvanceThermoTotalWithCaptionPlus("Auto creating style.", vcLogName)
7183 .LogEntry("Auto creating style.")
7184 llRetVal= llRetVal And .CreateOurSKU(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7185 .AdvanceThermoTotalWithCaptionPlus("Auto creating customer style.", vcLogName)
7186 * PL 08/22/01 27847 Auto-create Customer SKU
7187 .LogEntry("Auto creating customer style.")
7188 *--- TechRec 1005163 18-May-2004 GS ---
7189 *llRetVal= llRetVal and .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr)
7190 llRetVal= llRetVal And .CreateCustomerStyle(pceipoTH, pceipoTD, pceipoCR, pcxclblr, pceipoTS)
7191 *=== TechRec 1005163 18-May-2004 GS ===
7192
7193 Endwith
7194 Select(lnOldSelect)
7195 Return llRetVal
7196 Endproc
7197
7198
7199 *----------------------------------------------------------------------------------------
7200 ************************************************************************************
7201 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7202 ************************************************************************************
7203 Procedure CascadingCustomerToDetail
7204 Lparameters pceipoTH, pceipoTD
7205 Local llRetVal, lnOldSelect
7206 llRetVal = .T.
7207 lnOldSelect = Select()
7208 With This
7209 * set header/detail Relation
7210 llRetVal= llRetVal And .SetRelation(pceipoTH, "Pkey", pceipoTD, "Fkey")
7211 * --- TR 1019358 RLN 10/30/06
7212 *REPLACE ALL customer WITH &pceipoTH..customer IN (pceipoTD)
7213 Replace All customer With &pceipoTH..customer, ;
7214 department With &pceipoTH..department ;
7215 IN (pceipoTD)
7216 * === TR 1019358
7217 Set Relation To
7218 Endwith
7219 Select(lnOldSelect)
7220 Return llRetVal
7221 Endproc
7222
7223 *----------------------------------------------------------------------------------------
7224 *---- TR 1019697 NH
7225 Procedure CascadingCustomerToSLN
7226 Lparameters pceipoTD, pceipoTS
7227 Local llRetVal, lnOldSelect
7228 llRetVal = .T.
7229 lnOldSelect = Select()
7230 With This
7231 * set detail/SLN Relation
7232 llRetVal= llRetVal And .SetRelation(pceipoTD, "Pkey", pceipoTS, "Fkey")
7233 Replace All customer With &pceipoTD..customer In (pceipoTS)
7234 Set Relation To
7235 Endwith
7236 Select(lnOldSelect)
7237 Return llRetVal
7238 Endproc
7239 *==== TR 1019697 NH
7240
7241 *----------------------------------------------------------------------------------------
7242 ************************************************************************************
7243 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7244 ************************************************************************************
7245 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
7246 * regardless of auto_create of style flag set in Customer Label Ref.
7247 Procedure SubstitudeValidLabel
7248 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7249 Local llRetVal, lnOldSelect
7250 llRetVal = .T.
7251 lnOldSelect = Select()
7252 With This
7253 *- 1010285 05/18/05 YIK
7254 *- Also process when resv_label= 'V' (Validate). In this case populate label only
7255 *- if the SKU with the label is valid and active in the style master.
7256 *-- SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION ; &&Use SubCust lbl_code
7257 *-- FROM (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7258 *-- WHERE h.pkey= d.fkey AND ;
7259 *-- d.division= C.division AND h.customer= C.customer AND ;
7260 *-- C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
7261 *-- EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
7262 *-- h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
7263 *-- INTO CURSOR tmpCurs
7264
7265 *--- TR 1018193 18-NOV-2006 VKK Added the condition NOT Multi UPC
7266 *--- TechRec 1021803 09-Feb-2007 kpattabiraman ---
7267 *-- MultiUPC has been changed to Char(1) Y/N so changed it accordingly.
7268 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension, C.resv_label ; &&Use SubCust lbl_code
7269 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C ;
7270 WHERE h.pkey= d.fkey And ;
7271 d.division= C.division And h.customer= C.customer And ;
7272 (C.resv_label= 'Y' Or C.resv_label= 'V') And d.lbl_code= '' And ; && Only Blank label and flag set for resv_label
7273 Not (MultiUPC = 'Y') And ;
7274 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7275 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7276 INTO Cursor tmpCurs
7277 *==
7278
7279 Index On customer+division+Style+color_code+Dimension Tag OurSkuNoLb
7280 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipoTD, ;
7281 "customer+division+style+color_code+dimension")
7282 If llRetVal
7283 *- 1010285 05/18/05 YIK
7284 *- 1004785 05/04/04 YIK
7285 *- Added .. AND Empty(Errs_Msg_D)
7286 *-- REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipoTD);
7287 *-- FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
7288 Select (pceipoTD)
7289 Scan For !Empty(tmpCurs.Style) And Empty(Errs_Msg_D)
7290 If tmpCurs.resv_label = "Y" Or ;
7291 ( vl_scold(tmpCurs.division,,"tmpscolr",tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension) ;
7292 AND tmpscolr.active_ok = "Y" )
7293 Replace lbl_code With tmpCurs.lbl_code In (pceipoTD)
7294 Endif
7295 Endscan
7296 *= 1010285
7297 Set Relation To
7298 Endif
7299 .TableClose('tmpCurs')
7300 Endwith
7301 Select(lnOldSelect)
7302 Return llRetVal
7303 Endproc
7304
7305 *----------------------------------------------------------------------------------------
7306 ************************************************************************************
7307 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7308 ************************************************************************************
7309 * encounter for both set up in customer label ref:
7310 * 1. empty label apply to all customer
7311 * 2. none empty customer will be specificly create only for that customer
7312 * either 1 or 2 exists but never both
7313 *
7314 * Get a list of distinct ourSKU to server side to join zzxcolr
7315 Procedure CreateOurSKU
7316 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr
7317 Local llRetVal, lnOldSelect
7318 llRetVal = .T.
7319 lnOldSelect = Select()
7320 With This
7321 Select Distinct C.customer,d.division,d.Style,d.color_code,C.lbl_code,d.Dimension ; &&Use SubCust lbl_code
7322 From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7323 WHERE h.pkey= d.fkey And ;
7324 d.division= C.division And h.customer= C.customer And ;
7325 C.lbl_code= l.lbl_code And ; && could have blank customer and c.customer= l.customer
7326 l.auto_style= 'Y' And ;
7327 C.resv_label= 'Y' And ;
7328 EMPTY(d.Errs_Msg_D) And ; && Valid detail SKU, UPC OK
7329 h.customer<>'' And d.division<>'' And d.Style<>'' And d.color_code<>'' ;
7330 INTO Cursor tmpCurs
7331 *--- TR 1019697 NH
7332 *!* SCAN
7333 *!* lcOurSKU= tmpCurs.division + "/" + tmpCurs.STYLE + "/" + ;
7334 *!* tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.DIMENSION
7335 *!* IF .oBPOSalesOrder.AuthorizeAutoCreateStyle(tmpCurs.customer, tmpCurs.division, ;
7336 *!* tmpCurs.STYLE, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.DIMENSION)
7337 *!* IF .oBPOSalesOrder.AutoCreateStyle(tmpCurs.division, tmpCurs.STYLE, tmpCurs.color_code,;
7338 *!* tmpCurs.lbl_code, tmpCurs.DIMENSION)
7339 *!* *UdateLog(vcLogName, "Created style: " + lcOurSKU )
7340 *!* .LogEntry("Created style: " + lcOurSKU )
7341 *!* ELSE
7342 *!* *UdateLog(vcLogName, "Unable to create style: " + lcOurSKU )
7343 *!* .LogWarning("Unable to create style: " + lcOurSKU )
7344 *!* ENDIF
7345 *!* ENDIF
7346 *!* ENDSCAN
7347 llRetVal = llRetVal And .CreateOurSkuFromTmpCurs()
7348 *=== TR 1019697 NH
7349 Endwith
7350 Select(lnOldSelect)
7351 Return llRetVal
7352 Endproc
7353
7354 *----------------------------------------------------------------------------------------
7355
7356 Procedure CreateCustomerStyle
7357 Lparameters pceipoTH, pceipoTD, pceipoCR, pcxclblr,;
7358 pceipoTS && *--- TechRec 1005163 17-May-2004 GS ---
7359 Local llRetVal, lnOldSelect
7360 llRetVal = .T.
7361 lnOldSelect = Select()
7362 With This
7363 *--- TechRec 1005164 18-May-2004 GS ---
7364 *Select distinct C.customer,d.division,d.style,d.color_code,C.lbl_code,d.dimension ;
7365 * From (pceipoTH) h, (pceipoTD) d, (pceipoCR) C, (pcxclblr) l ;
7366 * Where h.pkey= d.fkey and ;
7367 * d.division= C.division and h.customer= C.customer and ;
7368 * C.lbl_code= l.lbl_code and ; && could have blank customer and c.customer= l.customer
7369 *l.auto_style= 'Y' and C.resv_label= 'Y' and C.AutoCustSKU= 'Y' and ; &&
7370 *Empty(d.Errs_Msg_D) and ; && Valid detail SKU, UPC OK
7371 *h.customer<>'' and d.division<>'' and d.style<>'' and d.color_code<>'' ;
7372 * Into Cursor tmpCurs
7373 If This.oHostProcess.lHaveSLN
7374 Select Distinct C.customer,;
7375 d.division,;
7376 d.Style,;
7377 d.color_code,;
7378 C.lbl_code,;
7379 d.Dimension ;
7380 FROM (pceipoTD) d ;
7381 JOIN (pceipoTH) h ;
7382 ON h.pkey = d.fkey ;
7383 JOIN (pceipoCR) C;
7384 ON d.division= C.division ;
7385 AND h.customer= C.customer ;
7386 JOIN (pcxclblr) l ;
7387 ON C.lbl_code= l.lbl_code ;
7388 WHERE l.auto_style= 'Y' ;
7389 AND C.resv_label= 'Y' ;
7390 AND C.AutoCustSKU= 'Y' ;
7391 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7392 And h.customer > ' ' ;
7393 AND d.division > ' ' ;
7394 AND d.Style > ' ' ;
7395 AND d.color_code > ' ';
7396 UNION ;
7397 SELECT Distinct C.customer,;
7398 d.division,;
7399 d.Style,;
7400 s.color_code,;
7401 C.lbl_code,;
7402 s.Dimension ;
7403 FROM (pceipoTS) s ;
7404 JOIN (pceipoTD) d ;
7405 ON d.pkey = s.fkey ;
7406 JOIN (pceipoTH) h ;
7407 ON h.pkey = d.fkey ;
7408 JOIN (pceipoCR) C ;
7409 ON d.division= C.division ;
7410 AND h.customer= C.customer ;
7411 JOIN (pcxclblr) l ;
7412 ON C.lbl_code= l.lbl_code ;
7413 WHERE l.auto_style= 'Y' ;
7414 AND C.resv_label= 'Y' ;
7415 AND C.AutoCustSKU= 'Y' ;
7416 AND Empty(s.Errs_Msg_S) ; && Valid detail SKU, UPC OK
7417 And h.customer > ' ' ;
7418 AND d.division > ' ' ;
7419 AND d.Style > ' ' ;
7420 AND s.color_code > ' ';
7421 INTO Cursor tmpCurs
7422
7423 Else
7424
7425 Select Distinct C.customer,;
7426 d.division,;
7427 d.Style,;
7428 d.color_code,;
7429 C.lbl_code,;
7430 d.Dimension ;
7431 FROM (pceipoTD) d ;
7432 JOIN (pceipoTH) h ;
7433 ON h.pkey = d.fkey ;
7434 JOIN (pceipoCR) C ;
7435 ON d.division= C.division ;
7436 AND h.customer= C.customer ;
7437 JOIN (pcxclblr) l ;
7438 ON C.lbl_code= l.lbl_code ;
7439 WHERE l.auto_style= 'Y' ;
7440 AND C.resv_label= 'Y' ;
7441 AND C.AutoCustSKU= 'Y' ;
7442 AND Empty(d.Errs_Msg_D) ; && Valid detail SKU, UPC OK
7443 And h.customer > ' ' ;
7444 AND d.division > ' ' ;
7445 AND d.Style > ' ' ;
7446 AND d.color_code > ' ';
7447 INTO Cursor tmpCurs
7448
7449 Endif
7450 *=== TechRec 1005164 18-May-2004 GS ===
7451 Scan
7452 lcCustSKU= tmpCurs.customer + "/" + tmpCurs.division + "/" + tmpCurs.Style + "/" + ;
7453 tmpCurs.color_code + "/" + tmpCurs.lbl_code+ "/" + tmpCurs.Dimension
7454 If .oBPOSalesOrder.AuthorizeAutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7455 tmpCurs.Style, tmpCurs.color_code, tmpCurs.lbl_code, tmpCurs.Dimension)
7456 If .oBPOSalesOrder.AutoCreateCustomerStyle(tmpCurs.customer, tmpCurs.division, ;
7457 tmpCurs.Style, tmpCurs.color_code,tmpCurs.lbl_code, tmpCurs.Dimension)
7458 *UdateLog(vcLogName, "Created customer style: " + lcCustSKU )
7459 .LogEntry("Created customer style: " + lcCustSKU )
7460 Else
7461 *UdateLog(vcLogName, "Unable to create customer style: " + lcCustSKU )
7462 .LogWarning("Unable to create customer style: " + lcCustSKU )
7463 Endif
7464 Endif
7465 Endscan
7466 Endwith
7467 Select(lnOldSelect)
7468 Return llRetVal
7469 Endproc
7470
7471 *----------------------------------------------------------------------------------------
7472 ************************************************************************************
7473 * Validate UPC for all details
7474 ************************************************************************************
7475 *--- TR 1088986 31-Jul-2015 BNarayanan Method name changed to avoid duplication. This method is obsolete ---
7476 *Procedure CheckUpc
7477 Procedure CheckUpc_obsolete
7478 *=== TR 1088986 31-Jul-2015 BNarayanan ===
7479 Lparameters pceipoTH, pceipoTD,;
7480 pceipoTS, plClearRngStyleInfo , pceipocr && TR 1019697 NH && *--- TechRec 1005163 17-May-2004 GS ---
7481
7482 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7483 * Added Parameter pceipocr
7484 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7485
7486 Local llRetVal, lnOldSelect, loEiPOth, loEiPOtd, lcMssg, lcOldCust, lcOldItem, ;
7487 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
7488 lnSize_desc, llSLN
7489
7490 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7491 LOCAL lcIs_upcsku
7492 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7493
7494 llRetVal = .T.
7495 lcErrs_Msg= ""
7496 lnOldSelect = Select()
7497
7498 * cannot check for UPC if customer is empty
7499 * PL 08/21/01 27849 - 850 Process will no longer "re-resolve" valid D/S/C/L/DMPK/S based
7500 * on Cust SKU or UPC.
7501 * ONLY Resolve ourSKU using UPC WHEN (Empty(d.style) or Empty(d.color_code))
7502
7503 * PL 10/03/01 28972 - When GENTRAN Maps in Style, Color, Size system will no longer "Re-Resolve"
7504 * our SKU base on CustSKU or UPC. (--In conflict with TAN 27849)
7505 * Will Unconditionally Re-Resolve when either Style or Color or Division still Empty
7506
7507 *--- TechRec 1005163 17-May-2004 GS ---
7508 *Select h.customer, d.upc, d.pkey From (pceipoTH) h, (pceipoTD) d ;
7509 * Where !Empty(d.upc) and h.pkey = d.fkey And !Empty(h.customer) And ;
7510 * (Empty(d.division) or Empty(d.style) or Empty(d.color_code)) ; && Only RESOLVE ONCE
7511 *Order by h.customer, d.upc Into Cursor tmpCurs
7512
7513 *---- TR 1024667 NSD 5/31/07
7514 * If sizebucket = 0 then re-resolve.
7515
7516 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7517 *-- SLNs Already resolved in the ResolveStyleFromSLN method (above)
7518*!* If This.lHaveSLN
7519*!* Select h.customer,;
7520*!* d.upc,;
7521*!* d.pkey,;
7522*!* (pceipoTD) As Src;
7523*!* FROM (pceipoTH) h ;
7524*!* JOIN (pceipoTD) d ;
7525*!* ON h.pkey = d.fkey ;
7526*!* WHERE !Empty(d.upc) ;
7527*!* AND !Empty(h.customer) ;
7528*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7529*!* UNION All ;
7530*!* SELECT h.customer,;
7531*!* s.SLN_UPC As upc,;
7532*!* s.pkey,;
7533*!* (pceipoTS) As Src ;
7534*!* FROM (pceipoTH) h ;
7535*!* JOIN (pceipoTD) d ;
7536*!* ON d.fkey = h.pkey ;
7537*!* JOIN (pceipoTS) s ;
7538*!* ON s.fkey = d.pkey ;
7539*!* WHERE !Empty(s.SLN_UPC) ;
7540*!* AND !Empty(h.customer) ;
7541*!* AND (Empty(s.division) Or Empty(s.Style) Or Empty(s.color_code) OR s.sizebucket = 0) ;
7542*!* ORDER By 1, 2 ;
7543*!* INTO Cursor tmpCurs
7544*!* Else
7545*!* Select h.Customer,;
7546*!* d.UPC,;
7547*!* d.PKey,;
7548*!* (pceipoTD) As Src;
7549*!* FROM (pceipoTH) h ;
7550*!* JOIN (pceipoTD) d ;
7551*!* ON h.pkey = d.fkey ;
7552*!* WHERE !Empty(d.upc) ;
7553*!* AND !Empty(h.customer) ;
7554*!* AND (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0) ;
7555*!* ORDER By 1, 2;
7556*!* INTO Cursor tmpCurs
7557*!* Endif
7558 *=== TechRec 1005163 17-May-2004 GS ===
7559
7560 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7561 SELECT customer, MAX(ResvCustSKU) as ResvCustSKU ;
7562 FROM (pceipocr) ;
7563 GROUP BY customer ;
7564 INTO CURSOR __ResvCustSKU
7565 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7566
7567 *--- TechRec 1029436 24-Jan-2008 vkrishnamurthy ---
7568*!* select h.Customer;
7569*!* , d.UPC;
7570*!* , d.PKey;
7571*!* from (pceipoTH) h;
7572*!* join (pceipoTD) d;
7573*!* on h.PKey = d.FKey;
7574*!* where !Empty(d.UPC);
7575*!* and !Empty(h.Customer);
7576*!* and (Empty(d.Division) or Empty(d.Style) or Empty(d.Color_Code) or d.SizeBucket = 0);
7577*!* order by 1, 2;
7578*!* into Cursor tmpCurs ReadWrite
7579
7580 Select h.customer;
7581 , d.upc;
7582 , d.pkey,;
7583 (pceipoTD) AS Src;
7584 from (pceipoTH) h;
7585 join (pceipoTD) d;
7586 on h.pkey = d.fkey;
7587 JOIN __ResvCustSKU r ;
7588 ON r.Customer = H.Customer ;
7589 where !Empty(d.upc);
7590 and !Empty(h.customer);
7591 and (Empty(d.division) Or Empty(d.Style) Or Empty(d.color_code) OR d.sizebucket = 0 );
7592 AND (EMPTY(d.sku) OR r.ResvCustSKU < 'Y') ;
7593 order By 1, 2;
7594 into Cursor tmpCurs Readwrite
7595 *=== TechRec 1029436 24-Jan-2008 vkrishnamurthy ===
7596
7597*=== TechRec 1024522 25-Sep-2007 GSternik ===
7598
7599 lcOldCust = ""
7600 lcOldItem = ""
7601 Select tmpCurs
7602 If This.lUserInterface
7603 * Init Thermometer
7604 This.UpdateThermoCaption("Validating UPC(s)...")
7605 * TAN 31891 - JAZ - 5/20/02
7606 * This.InitThermo(RECC('tmpCurs'))
7607 This.InitThermo(RecCount('tmpCurs'))
7608 * End TAN 31891 - JAZ - 5/20/02
7609 l_nThermoCnt = 0
7610 EndIf
7611
7612 Scan
7613 If This.lUserInterface
7614 * Advance progress bar, if we're using one.
7615 l_nThermoCnt = l_nThermoCnt + 1
7616 This.AdvanceThermo(l_nThermoCnt)
7617 Endif
7618 If !(tmpCurs.customer == lcOldCust And tmpCurs.upc == lcOldItem)
7619 lcErrs_Msg = ""
7620 lcOldCust = tmpCurs.customer
7621 lcOldItem = tmpCurs.upc
7622 * add by pass flag to control to skip ValidCustomerUPC go directly to ValidUPC
7623 * MichaelXu ? tcEiPOcr.Cust_UPC = "Y" And
7624
7625 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7626 lcIs_upcsku = ' '
7627 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7628
7629 If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
7630 lcDivision = tmpCstdr.division
7631 lcStyle = tmpCstdr.Style
7632 lcColor_code = tmpCstdr.color_code
7633 lcLbl_code = tmpCstdr.lbl_code
7634 lcDimension = tmpCstdr.Dimension
7635 lnSizeBucket = tmpCstdr.size_bk
7636 lnSize_desc = tmpCstdr.size_desc
7637
7638 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7639 lcIs_upcsku = 'C' && new code for Is_upcsku. It means the 850 found UPC in the zzxcstdr.
7640 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7641
7642 Else
7643 lcErrs_Msg = ""
7644 If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
7645 lcDivision = tmpUpcnr.division
7646 lcStyle = tmpUpcnr.Style
7647 lcColor_code = tmpUpcnr.color_code
7648 lcLbl_code = tmpUpcnr.lbl_code
7649 lcDimension = tmpUpcnr.Dimension
7650 lnSizeBucket = tmpUpcnr.sizebucket
7651 lnSize_desc = tmpUpcnr.size_desc
7652 Else
7653 lcErrs_Msg = lcErrs_Msg + CRLF
7654 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
7655 Store 0 To lnSizeBucket
7656 Endif
7657 Endif
7658 Endif && level break
7659
7660 *--- TechRec 1005163 17-May-2004 GS ---
7661 *Select (pceipoTD)
7662*!* llSLN = (tmpCurs.Src = pceipoTS)
7663*!* If llSLN
7664*!* Select (pceipoTS)
7665*!* Else
7666 Select (pceipoTD)
7667*!* Endif
7668 *=== TechRec 1005163 17-May-2004 GS ===
7669 *- 1010682 04/25/05 YIK
7670 *- Locate For pkey = tmpCurs.pkey
7671 lnWorkArea = Select()
7672 =Seek(tmpCurs.pkey, lnWorkArea, "pkey")
7673 Scatter Name loEiPOtd Memo
7674 If !Empty(lcErrs_Msg)
7675*!* *--- TechRec 1005163 17-May-2004 GS ---
7676*!* If llSLN
7677*!* loEiPOtd.Errs_Msg_S = Alltrim(loEiPOtd.Errs_Msg_S) + lcErrs_Msg
7678*!* loEiPOtd.Errs_Flg_S = "Y"
7679*!* Else
7680*!* *=== TechRec 1005163 17-May-2004 GS ===
7681 loEiPOtd.Errs_Msg_D = Alltrim(loEiPOtd.Errs_Msg_D) + lcErrs_Msg
7682 loEiPOtd.Errs_Flg_D = "Y"
7683*!* Endif
7684 Endif
7685 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
7686 loEiPOtd.Division = lcDivision
7687 loEiPOtd.Style = lcStyle
7688 loEiPOtd.Color_Code = lcColor_code
7689 loEiPOtd.Lbl_Code = lcLbl_code
7690 loEiPOtd.Dimension = lcDimension
7691 loEiPOtd.SizeBucket = lnSizeBucket
7692 loEiPOtd.Size_Desc = lnSize_desc
7693
7694 *--- TechRec 1029436 25-Mar-2008 vkrishnamurthy ---
7695 IF !EMPTY(lcIs_upcsku)
7696 loEiPOtd.Is_upcsku = lcIs_upcsku
7697 ENDIF
7698 *=== TechRec 1029436 25-Mar-2008 vkrishnamurthy ===
7699
7700 *--- TR 1019697 NH : clear rang style when bc style is set
7701 If plClearRngStyleInfo And Vartype(loEiPOtd.rng_style) = "C"
7702 loEiPOtd.rng_style = ''
7703 loEiPOtd.rng_color = ''
7704 loEiPOtd.rng_lbl = ''
7705 loEiPOtd.rng_pack = ''
7706 Endif
7707 *=== TR 1019697 NH
7708 Endif
7709
7710 * PL 06/05/00 3974- EDI - add range style explosion to 850(i) process
7711 * only replace our SKU when no range style explosion happen
7712 *--- TechRec 1005163 17-May-2004 GS ---
7713 *If empty(&pceipoTD..rng_style)
7714 * Replace division With loEiPOtd.division, ;
7715 * style With loEiPOtd.style, ;
7716 * color_code With loEiPOtd.color_code, ;
7717 * lbl_code With loEiPOtd.lbl_code, ;
7718 * dimension With loEiPOtd.dimension, ;
7719 * sizebucket With loEiPOtd.sizebucket, ;
7720 * size_desc With loEiPOtd.size_desc, ;
7721 * Errs_Msg_D With loEiPOtd.Errs_Msg_D, ;
7722 * Errs_Flg_D With loEiPOtd.Errs_Flg_D ;
7723 * In (pceipoTD)
7724 *Endif
7725 *- 1009508 3/16/05 YIK
7726 *- IF llSLN OR EMPTY(&pceipoTD..rng_style)
7727 *--- TechRec 1024522 25-Sep-2007 GSternik ---
7728 *If llSLN Or plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7729 If plClearRngStyleInfo Or Empty(Evaluate(pceipoTD + ".rng_style")) && TR 1019697 NH
7730 *=== TechRec 1024522 25-Sep-2007 GSternik ===
7731
7732 Gather Name loEiPOtd Memo
7733 Endif
7734 *=== TechRec 1005163 17-May-2004 GS ===
7735 Endscan
7736 Use In tmpCurs
7737
7738 If This.lUserInterface
7739 * Reset Thermometer
7740 This.ResetThermo()
7741 Endif
7742
7743 If Used("tmpCstdr")
7744 Use In tmpCstdr
7745 Endif
7746 If Used("tmpUpcnr")
7747 Use In tmpUpcnr
7748 Endif
7749
7750 Select(lnOldSelect)
7751 Return llRetVal
7752 Endproc
7753
7754 *----------------------------------------------------------------------------------------
7755 ************************************************************************************
7756 * PL 01/19/01 4972 JSSI Shared UPC - EDI 850(i) Process - Resolve share UPC
7757 ************************************************************************************
7758 Procedure ValidateOurSKU
7759 Lparameters pceipoTH, pceipoTD, pceipoTS
7760 Local llRetVal, lnOldSelect, lcScolrSQL
7761 Local llStyle_OK, llLabel_OK, lnFKey, lcErrs_Msg, lcCnt &&--- TechRec 1016817 04-May-2006 GS ---
7762
7763 *--- TechRec 1022705 21-Jun-2007 jjanand ---
7764 LOCAL llActiveCheck
7765 *=== TechRec 1022705 21-Jun-2007 jjanand ===
7766
7767 *--- TR 1017598 14-Sep-2006 SS
7768 Local llAllowedSize_OK, llErrUnavail, lcbk_unavl_sku, lcErrs_Allowed_Msg
7769
7770 LOCAL llSKU_changed && TR 1034769 JUL-21-2008 BR
7771
7772 LOCAL llUnAvlBkCheck && TR 1040614 MAY-29-2009 BR
7773
7774 *--- TR 1018193 18-NOV-2006 VKK
7775 lcErrs_Allowed_Msg = ""
7776 *=== TR 1018193 18-NOV-2006 VKK
7777
7778 *=== TR 1017598 14-Sep-2006 SS
7779
7780 * --- TR 1039400 3/31/09 CM
7781 LOCAL lcCurrentSku
7782 lcCurrentSku = ""
7783 * === TR 1039400 3/31/09 CM
7784
7785 llRetVal = .T.
7786 lnOldSelect = Select()
7787
7788 *--- TechRec 1016817 04-May-2006 GS --- Optimized.
7789 *--- See VSS for Changes.
7790
7791 * for anything that resove to None blank h.customer, d.div/sty/col-
7792 * attempt to validate zzxstylr/zzxscolr/zzxsavlr.
7793 *- TAN 27166
7794 *- 1010682 04/25/05 YIK
7795 *- Added .. WHERE d.rng_style = ' '
7796
7797 *- 1017363 06/02/06 YIK
7798 *- Changed ", d.Division" to ", s.Division" in the SLN part of the select
7799
7800 *--- TR 1058045 11-29-2011 RKI d.sizebucket >0 and s.sizebucket > 0 Removed
7801 Select h.customer;
7802 , d.division;
7803 , d.Style;
7804 , d.color_code;
7805 , d.lbl_code;
7806 , d.Dimension;
7807 , d.sizebucket;
7808 , d.size_desc; && TR 1058045 11-29-2011 RKI
7809 , d.upc; && TR 1058045 11-29-2011 RKI
7810 , d.sku; && TR 1058045 11-29-2011 RKI
7811 , d.ean; && TR 1058045 11-29-2011 RKI
7812 , d.pkey;
7813 , (pceipoTD) As Src ;
7814 from (pceipoTH) h;
7815 join (pceipoTD) d ;
7816 on h.pkey = d.fkey ;
7817 where h.customer >' ' ;
7818 and d.division >' ' ;
7819 and d.Style >' ' ;
7820 and d.color_code >' ' ;
7821 UNION All;
7822 select h.customer;
7823 , s.division;
7824 , s.Style;
7825 , s.color_code;
7826 , s.lbl_code;
7827 , s.Dimension;
7828 , s.sizebucket;
7829 , s.size_desc; && TR 1058045 11-29-2011 RKI
7830 , s.sln_upc as upc; && TR 1058045 11-29-2011 RKI
7831 , s.sln_sku as sku; && TR 1058045 11-29-2011 RKI
7832 , s.sln_ean as ean; && TR 1058045 11-29-2011 RKI
7833 , s.pkey;
7834 , (pceipoTS) As Src ;
7835 from (pceipoTS) s;
7836 join (pceipoTD) d ;
7837 on d.pkey = s.fkey;
7838 join (pceipoTH) h ;
7839 on h.pkey = d.fkey ;
7840 and h.customer > ' ' ;
7841 and s.division > ' ' ;
7842 and s.Style > ' ' ;
7843 and s.color_code > ' ' ;
7844 where d.rng_style = ' ' ;
7845 order By 2, 3, 4, 5, 6, 7, 1 ;
7846 into Cursor tmpCurs READWRITE && TR 1058045 11-29-2011 RKI
7847
7848 *-- Order by SKU + Bucket + Customer !!!
7849 *-- Assumtion is that different customers usually don't order the same SKU at the same time.
7850
7851 lcCnt = Reccount("tmpCurs")
7852 This.LogEntry("Finished query without Order type validation. Selected " + Str(lcCnt) + "records.")
7853
7854 *--- This cursor will be used to cache Customer-Label Validations:
7855 Create Cursor curCustLbl (customer C(7), lbl_code C(7), is_Valid l)
7856 Index On customer + lbl_code Tag CustLbl
7857
7858 lcErrs_Msg = ''
7859 Select tmpCurs
7860 Scatter Memo Name oTmpCurs Blank
7861 * --- TR 1014834 RLN 08/10/06
7862
7863 *--- TR 1017598 14-Sep-2006 SS
7864 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7865
7866 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7867 llBookUnavail = (lcbk_unavl_sku = 'Y')
7868 llErrUnavail = (lcbk_unavl_sku = 'E')
7869 *=== TR 1017598 14-Sep-2006 SS
7870
7871 With oTmpCurs
7872 llSize_OK = .T.
7873 Scan
7874 llSKU_changed = .F. && TR 1034769 JUL-21-2008 BR
7875 * --- TR 1027498 NSD 10/3/07
7876 * Clear error message after every line, not just every sku.
7877 * lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR REMOVED.
7878 * === TR 1027498 NSD 10/3/07
7879
7880 * --- TR 1014834 RLN 08/10/06
7881 *-TR 1067995 FH 11/11/13 - uncomment llSize_OK
7882 llSize_OK = .T.
7883 If division # .division ;
7884 or Style # .Style ;
7885 or color_code # .color_code ;
7886 or lbl_code # .lbl_code ;
7887 or Dimension # .Dimension
7888 *-- SKU Changed... Let's make sure it is valid:
7889
7890 llSKU_changed = .T. && TR 1034769 JUL-21-2008 BR
7891 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
7892
7893 * --- TR 1039400 3/31/09 CM
7894 lcCurrentSku = division + Style + color_code + lbl_code + Dimension
7895 * === TR 1039400 3/31/09 CM
7896
7897 * --- TR 1014834 RLN 08/10/06
7898 If division <> .division
7899 *--- TR 1017598 14-Sep-2006 SS
7900 * llBookUnavail = vl_ocntr(division, "book_unavlbl_sku") = 'Y'
7901
7902 lcbk_unavl_sku = vl_ocntr(division, "book_unavlbl_sku")
7903 llBookUnavail = (lcbk_unavl_sku = 'Y')
7904 llErrUnavail = (lcbk_unavl_sku = 'E')
7905 *=== TR 1017598 14-Sep-2006 SS
7906 Endif
7907 * === TR 1014834
7908 lcErrs_Msg = ""
7909 .division = division
7910 .Style = Style
7911 .color_code = color_code
7912 .Dimension = Dimension
7913 .lbl_code = lbl_code && TR 1057867 FH
7914 *- Check Savlr instead of scolr for SKU, we'll need it later anyway.
7915 * --- TR 1014834 RLN 08/09/06
7916 lnSelect = Select()
7917 * Available sizes stored in Scolr
7918 *--- TR: 1021620 BR/NH
7919 IF vl_Scold(.Division, "", "tcTmpScolr", .Style, .Color_Code, ;
7920 Lbl_Code, .Dimension)
7921
7922
7923*!* lcScolrSQL = "SELECT * FROM zzxscolr WHERE " + ;
7924*!* "division = " + SQLFormatChar(division) + " AND " + ;
7925*!* "style = " + SQLFormatChar(Style) + " AND " + ;
7926*!* "color_code = " + SQLFormatChar(color_code) + " AND " + ;
7927*!* "lbl_code = " + SQLFormatChar(lbl_code) + " AND " + ;
7928*!* "dimension = " + SQLFormatChar(Dimension)
7929
7930*!* v_SqlExec(lcScolrSQL, "tcTmpScolr")
7931*!* Select (lnSelect)
7932*!* * === TR 1014834
7933*!* If vl_SAvlR(.division, "", "__Savlr", .Style, .color_code, ;
7934*!* lbl_code, .Dimension) && Lbl, (not .Lbl) as it is taken from table!!!
7935
7936 *--- TechRec 1022705 20-Jun-2007 jjanand ---
7937 *!* IF tcTmpScolr.active_ok = 'N'
7938 llActiveCheck = This.lAllowInactiveStyleColors
7939 llActiveCheck = llActiveCheck AND SEEK(tmpCurs.Division + tmpCurs.Customer, "zzeipccr", "divcust") && check that the 860 EDI Control exists.
7940 llActiveCheck = NOT(llActiveCheck) AND USED('tcTmpScolr') AND tcTmpScolr.active_ok = 'N'
7941 IF llActiveCheck
7942 *=== TechRec 1022705 20-Jun-2007 jjanand ===
7943
7944 lcErrs_Msg = "Inactive Style/Color"
7945 llStyle_OK = .F.
7946 ELSE
7947 lcErrs_Msg = ""
7948 llStyle_OK = .T.
7949 ENDIF
7950
7951 *--- TR 1040614 MAY-29-2009 BR
7952 llUnAvlBkCheck = .T.
7953 llUnAvlBkCheck = llUnAvlBkCheck AND (llBookUnavail Or llErrUnavail)
7954 llUnAvlBkCheck = NOT(llUnAvlBkCheck) AND USED('tcTmpScolr') AND tcTmpScolr.color_avlbl = 'N'
7955
7956 *- 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
7957 IF llStyle_OK
7958 IF llUnAvlBkCheck
7959 lcErrs_Msg = "Style/Color combination is unavailable"
7960 llStyle_OK = .F.
7961 ELSE
7962 lcErrs_Msg = ""
7963 llStyle_OK = .T.
7964 ENDIF
7965 ENDIF
7966 *- TR 1062018 FH 06/08/12
7967 *=== TR 1040614 MAY-29-2009 BR
7968 ELSE
7969 *=== TR 1021620
7970 llStyle_OK = .F.
7971 This.GetStyleError(@lcErrs_Msg)
7972 Endif
7973 Endif && SKU Changed
7974
7975 *TR 1057867 FH - added check for llSKU_changed, we're clearing lcErrs_msg per different sku, need to revalidate for new sku
7976 *- took out (customer # .customer Or .lbl_code # lbl_code)
7977 If llStyle_OK AND llSKU_changed
7978*!* If llStyle_OK And (;
7979*!* customer # .customer Or .lbl_code # lbl_code)
7980 .lbl_code = lbl_code
7981 .customer = customer
7982 llLabel_OK = .T.
7983 If !Empty(.lbl_code)
7984 If !Seek(.customer+.lbl_code, "curCustLbl")
7985 *- populate cursor of cached Customer/Lbl
7986 *- vl_clblr2() returns .F. if lbl is invalid for the customer
7987 Insert Into curCustLbl Values(;
7988 .customer, .lbl_code,;
7989 vl_clblr2(.lbl_code, "", , .customer))
7990 Endif
7991
7992 If !curCustLbl.is_Valid && always check from the cached table.
7993 lcErrs_Msg = "Invalid Label code for this Customer." + CRLF
7994 llLabel_OK = .F.
7995 Endif
7996 Endif
7997 Endif && Style OK
7998
7999 *--- TR 1058045 11-29-2011 RKI ---*
8000 lnPkey = Pkey
8001 IF EMPTY(UPC) AND EMPTY(SKU) AND EMPTY(EAN)
8002 lnSize_BK = This.GetSizeBkt(division,,, Style , color_code,lbl_code,dimension,size_desc)
8003 replace sizebucket WITH lnSize_BK
8004 IF Seek(lnPkey, tmpCurs.Src, "Pkey")
8005 DO CASE
8006 CASE tmpCurs.Src = (pceipoTD)
8007 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8008 CASE tempcurs.Src = (pceipoTS)
8009 replace sizebucket WITH lnSize_bk IN (pceipoTD)
8010 Endcase
8011 ENDIF
8012 ENDIF
8013 SELECT tmpCurs
8014 *=== TR 1058045 11-29-2011 RKI ===*
8015
8016 * --- TR 1018184
8017 llAllowedSize_OK = .T.
8018 If llStyle_OK And llLabel_OK
8019 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
8020 .sizebucket = sizebucket
8021 lcErrs_Msg = "" && TR 1042408 AUG-31-2009 BR
8022
8023 *- that's why we used Savlr
8024 * --- TR 1014834 RLN 08/09/06
8025 * I guess we really do not need Savlr...
8026 *llSize_OK = Evaluate("__Savlr.allow"
8027 *--- TR 1058045 11-29-2011 RKI ---*
8028 IF BETWEEN(.sizebucket,1,24)
8029 *=== TR 1058045 11-29-2011 RKI ===*
8030 llSize_OK = Evaluate("tcTmpScolr.allow" + ;
8031 Transform(.sizebucket, "@L 99")) = 'Y'
8032
8033 *--- TR 1017598 14-Sep-2006 SS && Used CALL01.. instead of ALLOW01
8034 *if !llSize_OK
8035 llAllowedSize_OK = Evaluate("tcTmpScolr.call" + ;
8036 Transform(.sizebucket, "@L 99")) = 'Y'
8037 *--- TR 1058045 11-29-2011 RKI ---*
8038 ELSE
8039 llAllowedSize_OK = .F.
8040 ENDIF
8041 *=== TR 1058045 11-29-2011 RKI ===*
8042
8043 If !llAllowedSize_OK
8044 *--TR 1034769 JUL-21-2008 BR
8045 *lcErrs_Allowed_Msg = "Invalid Allowed Sizes."
8046 lcErrs_Msg = "Invalid Available Sizes."
8047 *==TR 1034769 JUL-21-2008 BR
8048 Else
8049 If !llSize_OK And ( llBookUnavail Or llErrUnavail ) && size is not available
8050 lcErrs_Msg = "Invalid Available Sizes."
8051 Endif
8052 Endif
8053
8054 *=== TR 1017598 14-Sep-2006 SS
8055 Endif
8056 Endif
8057 *=== TechRec 1016817 04-May-2006 GS === Optimized part end.
8058
8059 * for each detail line replace detail error msg if have one
8060 *--- TechRec 1005163 21-Jun-2004 GS ---
8061 *If !Empty(lcErrs_Msg) AND Seek(tmpCurs.pkey, pceipoTD, "Pkey")
8062 * Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, ;
8063 * Errs_Flg_D with 'Y' in (pceipoTD)
8064 If !Empty(lcErrs_Msg) And Seek(tmpCurs.pkey, tmpCurs.Src, "Pkey")
8065 If tmpCurs.Src = (pceipoTD)
8066 *--- TR 1017598 14-Sep-2006 SS
8067 If Not llAllowedSize_OK && if size is not allowed - error out always
8068 *--- TR 1018193 18-NOV-2006 VKK
8069 *!* REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Allowed_Msg, ;
8070 *!* Errs_Flg_D WITH 'Y' IN (pceipoTD)
8071 Replace Errs_Msg_D With Errs_Msg_D + Iif(Empty(lcErrs_Allowed_Msg), lcErrs_Msg, lcErrs_Allowed_Msg), ;
8072 Errs_Flg_D With 'Y' In (pceipoTD)
8073 *=== TR 1018193 18-NOV-2006 VKK
8074 Else
8075 *=== TR 1017598 14-Sep-2006 SS
8076
8077 * --- TR 1014834 RLN 08/08/06
8078 If !llSize_OK
8079 If llBookUnavail
8080 Replace UnAvailSize With .T. In (pceipoTD)
8081 Else
8082 *--- TR 1017598 14-Sep-2006 SS , Added IF llErrUnavail
8083 If llErrUnavail && error as invalid available sizes.
8084 * === TR 1014834
8085 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, ;
8086 Errs_Flg_D With 'Y' In (pceipoTD)
8087 Endif
8088 *=== TR 1017598 14-Sep-2006 SS
8089 ENDIF
8090 *--- TR 1021620 NH 04/12/07
8091 ELSE
8092
8093
8094 *--TR 1057867 FH - the Scan below is scanning all same sku with the same error.
8095 *- we are marking duplicate errors, if there are alot of detail with same sku, we will run out of memory.
8096 IF llSKU_changed
8097 * --- TR 1039400 3/31/09 CM
8098 * Commented out and added seek/scan while to determine how many particular style/color
8099 * combinations should be flagged as inactive
8100 *Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8101 Select(pceipoTD)
8102 Index on division + Style + color_code + lbl_code + Dimension TAG skucombo
8103 If Seek(lcCurrentSku)
8104 Scan While division + Style + color_code + lbl_code + Dimension = lcCurrentSku
8105 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With 'Y' In (pceipoTD)
8106 Endscan
8107 Endif
8108 * === TR 1039400 3/31/09 CM
8109 endif
8110 *--TR 1057867 FH
8111
8112 *=== TR 1021620 NH 04/12/07
8113 Endif && TR 1014834
8114 Endif && TR 1017598
8115 ELSE
8116 IF EVALUATE(pceipoTS + ".SkipSlnChk") <> "Y" &&--- TR 1035223 NH
8117 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg, ;
8118 Errs_Flg_S With 'Y' In (pceipoTS)
8119
8120 *- 1010682 04/25/05 YIK
8121 *- if Seek(&pceipoTS..Fkey, pceipoTD, "Pkey") and !"Has errors in SLNs."$Errs_Msg_D
8122 *--- TechRec 1016817 04-May-2006 GS --- No Macro!
8123 *IF SEEK(&pceipoTS..fkey, pceipoTD, "Pkey") AND !"Has errors in SLNs."$EVALUATE(pceipoTD + ".Errs_Msg_D")
8124 Select(pceipoTS)
8125 lnFKey = fkey
8126 Select(pceipoTD)
8127 If Seek(lnFKey, pceipoTD, "Pkey") And !"Has errors in SLNs."$Errs_Msg_D
8128 *=== TechRec 1016817 04-May-2006 GS ===
8129 Replace Errs_Msg_D With Errs_Msg_D + "Has errors in SLNs." + CRLF, ;
8130 Errs_Flg_D With 'Y' In (pceipoTD)
8131 ENDIF
8132 ENDIF
8133 Endif
8134 *=== TechRec 1005163 21-Jun-2004 GS ===
8135 Endif
8136 Endscan
8137 Endwith
8138
8139 Use In Select("curCustLbl")
8140
8141 Select(lnOldSelect)
8142 Return llRetVal
8143 Endproc
8144
8145 *----------------------------------------------------------------------------------------
8146
8147 Function GetCustLabel
8148 Lparameters pcCust
8149 Local llRetVal, lnSelect ,l_cSQLString, l_vRetVal ,lcCursor
8150
8151 llRetVal = True
8152 lnSelect = Select()
8153 l_vRetVal = ''
8154 lcCursor = GetUniqueFileName()
8155
8156 l_cSQLString = "SELECT TOP 1 ISNULL(lbl_code,'') lbl_code FROM zzxclblr WHERE customer = " + SQLFormatChar(pcCust)
8157
8158 llRetVal = v_SqlExec(l_cSQLString,lcCursor)
8159
8160 If llRetVal
8161 Select(lcCursor)
8162 l_vRetVal = Alltrim(lbl_code )
8163
8164 Use In (lcCursor)
8165 Endif
8166
8167 Select (lnSelect)
8168 Return l_vRetVal
8169 Endfunc
8170
8171 *----------------------------------------------------------------------------------------
8172 Function ResolveMultiPrepacks
8173 Lparameters pcTransHeader, pcTransDetail, pcMppk
8174 Local llRetVal, lnOldSelect, lcErrs_Msg, llMultPpkToExplode
8175
8176 llRetVal = True
8177 lnOldSelect = Select()
8178
8179
8180
8181 Select Distinct h.customer,d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8182 FROM (pcTransHeader) h, (pcTransDetail) d ;
8183 WHERE h.pkey = d.fkey And h.Errs_flg_h= "N" And d.Errs_Flg_D= "N" ;
8184 AND d.implosion = 'Y'; && TR 1011644 VSS 27-09-2005
8185 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8186
8187 *!* SELECT DISTINCT h.customer,d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
8188 *!* FROM (pcTransHeader) h, (pcTransDetail) d ;
8189 *!* WHERE h.pkey = d.fkey AND h.Errs_flg_h= "N" AND d.Errs_Flg_D= "N" AND ;
8190 *!* d.rng_style= '' ;
8191 *!* ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
8192
8193 With This
8194 .cSQLTempTable=""
8195
8196 If .GenerateSQLTempTable('__TmpCursor')
8197 If .PopulateSQLTempTable('__TmpCursor')
8198 If !Empty(.cSQLTempTable)
8199
8200 .LogEntry("Exploding MultiPack.")
8201
8202 *AND h.mpack_code = t.dimension
8203 lcSQLString= "select h.*,t.* from zzemppkh h," + .cSQLTempTable + " t " +;
8204 "Where h.customer = t.customer and h.mpack_code = t.dimension and h.active_ok = 'Y' " && TR 1033017 May-02-2008 BR
8205
8206 llRetVal = v_SqlExec(lcSQLString, "__MppkH")
8207
8208 llMultPpkToExplode = This.CountTotalRecs ("__MppkH")>0
8209
8210 If llMultPpkToExplode
8211
8212 lcSQLString = "Select d.*, t.* From zzemppkd d, zzemppkh h," + .cSQLTempTable + " t " +;
8213 "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
8214
8215 llRetVal = v_SqlExec(lcSQLString, "__MppkD")
8216
8217
8218 *THIS.CreateCursorStructure("__TmpCursor", "__MppkH", "__ppk1") TR 1011644 VSS 27-09-2005
8219
8220 Select sizebucket, size_desc, total_qty, ppk_qty , Space(5) As ppk_code, 00000 As multQty From (pcTransDetail) ;
8221 WHERE 0=1 Into Cursor __ppk2
8222
8223
8224 *THIS.CreateCursorStructure("__ppk1", "__ppk2", "tcMppkVer") TR 1011644 VSS 27-09-2005
8225 This.CreateCursorStructure("__MppkH", "__ppk2", "tcMppkVer") && TR 1011644 VSS 27-09-2005m
8226
8227
8228 If Used("__ppk1")
8229 Use In __ppk1
8230 Endif
8231
8232 If Used("__ppk2")
8233 Use In __ppk2
8234 Endif
8235
8236 Select __MppkH
8237 Index On pkey Tag pkey
8238 Select __MppkD
8239 Index On division+Style Tag DivStyle
8240 Select tcMppkVer
8241 Index On division+Style+color_code+lbl_code+Dimension Tag MpackRef
8242 Set Order To MpackRef
8243 This.ExplodeMultPackRef("__MppkH", "__MppkD", pcTransDetail, "tcMppkVer")
8244
8245 *****************************************************************************
8246 *!* SELECT DISTINCT pkey FROM __MppkD ;
8247 *!* ORDER BY division, STYLE, color_code, lbl_code, DIMENSION ;
8248 *!* INTO CURSOR __DtlExpl
8249
8250
8251 *!* SELECT DISTINCT d.pkey ; VSS 27-09-2005
8252 *!* FROM __MppkD m, (pcTransDetail) d ;
8253 *!* WHERE d.Errs_Flg_D= "N" ; &&no error
8254 *!* INTO CURSOR __DtlExpl
8255
8256 && TR 1011644 VSS 27-09-2005
8257
8258 Select Distinct d.pkey ;
8259 FROM __MppkD mp, (pcTransDetail) d ;
8260 WHERE d.Errs_Flg_D= "N" ; &&no error
8261 And mp.Style = d.Style ;
8262 AND mp.color_code = d.color_code ;
8263 AND mp.lbl_code = d.lbl_code ;
8264 AND mp.Dimension = d.Dimension;
8265 AND d.implosion = 'Y';
8266 INTO Cursor __DtlExpl
8267
8268 llRetVal= .ExplodeMultiPackVertical("__DtlExpl", "tcMppkVer", pcTransDetail) &&, pcViewTransDetail
8269
8270 Endif
8271 Endif
8272 Endif
8273 Endif
8274 Endwith
8275
8276 If Used("__MppkH")
8277 Use In __MppkH
8278 Endif
8279 If Used("__MppkD")
8280 Use In __MppkD
8281 Endif
8282 If Used("tcMppkVer")
8283 Use In tcMppkVer
8284 Endif
8285 If Used("__DtlExpl")
8286 Use In __DtlExpl
8287 Endif
8288 If Used("__TmpCursor")
8289 Use In __TmpCursor
8290 Endif
8291
8292 Select(lnOldSelect)
8293 Return llRetVal
8294
8295 Endfunc
8296
8297 *----------------------------------------------------------------------------------------
8298 Procedure ExplodeMultiPackVertical
8299 Lparameters pcDetailtoExplode, pcMultDetailVert, pcTransDetail &&, pcViewTransDetail
8300 Local llRetVal, lnOldSelect, lcErrs_Msg, lnMultiplier
8301 llRetVal = .T.
8302 lnOldSelect = Select()
8303
8304 .LogEntry("Exploding multi pack details into vertical cursor.")
8305 Select (pcDetailtoExplode)
8306
8307 Scan
8308
8309 If Seek(pkey, pcTransDetail, "Pkey")
8310
8311 * Current working trans detail
8312 Select (pcTransDetail)
8313 lcCurOurSKU= division+Style+color_code+lbl_code+Dimension
8314 lnCurDtlTotal_qty= total_qty
8315
8316
8317 Scatter Name loTransDetail Memo
8318 * delete current working trans detail already have image
8319 * in loTransDetail
8320 Delete In (pcTransDetail)
8321
8322
8323 Select (pcMultDetailVert)
8324 * Find 1st match of OURSKU
8325 If Seek(lcCurOurSKU, pcMultDetailVert, "MpackRef")
8326 lnMultiplier = lnCurDtlTotal_qty / multQty &&Need to divide by ..
8327
8328
8329 Scan While llRetVal And !Eof(pcMultDetailVert) And ;
8330 (lcCurOurSKU= division+ Style + color_code + lbl_code + Dimension)
8331 * Exploding detail line
8332 loTransDetail.pkey = v_nextPkey("ZZEIPOID") && Never reassign Pkey in TD
8333 If !Empty(loTransDetail.pkey)
8334
8335 Select (pcMultDetailVert)
8336 Scatter Name loVert Memo
8337
8338 Select (pcTransDetail)
8339 Append Blank
8340 Gather Name loTransDetail Memo
8341
8342 Replace total_qty With loVert.total_qty * lnMultiplier , ;
8343 sizebucket With loVert.sizebucket, ;
8344 size_desc With loVert.size_desc, ;
8345 division With loVert.division, ;
8346 STYLE With loVert.Style, ;
8347 color_code With loVert.color_code, ;
8348 lbl_code With loVert.lbl_code, ;
8349 DIMENSION With loVert.ppk_code In (pcTransDetail)
8350 Else
8351 .LogEntry("Pkey cannot be empty.")
8352 llRetVal= .F. && Cannot get Pkey from bcsysnum
8353 Exit
8354 Endif
8355
8356 Select (pcMultDetailVert)
8357 Endscan
8358 Else
8359 .LogEntry(" Seek Failed Not able to find SKU. "+ lcCurOurSKU) && 1058596 FH- changed to lcCurOurSKU
8360 llRetVal= .F. && Should be in pcMultDetailVert
8361 Exit
8362 Endif
8363 Endif
8364
8365 If !llRetVal &&Get out of scan when have some problem
8366 Exit
8367 Endif
8368 Endscan
8369
8370 Select(lnOldSelect)
8371 Return llRetVal
8372 Endproc
8373 *=== TR 1011644 23-AUG-2005 KA
8374
8375 *----------------------------------------------------------------------------------------
8376 Procedure ExplodeMultPackRef
8377 Lparameters pcMultPackHeader, pcMultPackDetail, pcTransDetail, pcMultPackTarget
8378 Local llRetVal, lnOldSele, lcSizeBucket, lcSizeName, ;
8379 lcDivStyle, lnSourceCnt, lnSizeQty, lnSizePosition, lnMultiplyQty
8380
8381 lnOldSele = Select()
8382 lcDivStyle = ""
8383 lnSourceCnt = This.CountTotalRecs (pcMultPackDetail)
8384
8385 llRetVal= .T.
8386 lnCurDtlFkey= 0
8387 lnMultiplyQty = 0
8388
8389 .LogEntry("Exploding multi pack details.")
8390
8391 Select (pcMultPackDetail)
8392 Set Order To DivStyle
8393 Scan
8394
8395 If lnCurDtlFkey<> fkey
8396 lnCurDtlFkey = fkey
8397 If Seek(fkey, pcMultPackHeader , "PKEY")
8398 lnMultiplyQty = Evaluate(pcMultPackHeader + " .total_qty")
8399 Else
8400 llRetVal = .F.
8401 Exit
8402 Endif
8403 Endif
8404
8405
8406 * only run once per Div + Style
8407 If !(lcDivStyle == division + Style)
8408 lcDivStyle = division + Style
8409 * Insert a record for each size bucket with a caption *
8410 If !v_GetSizeHeadings(division, Style, "__xSizer")
8411 llRetVal = .F.
8412 Exit
8413 Endif
8414 Endif
8415
8416
8417 lnSizeQty = 1
8418 Select (pcMultPackDetail)
8419 Scatter Memvar Memo
8420
8421 lnSizePosition = 1
8422 lcSizeBucket = "Size" + Trans(lnSizePosition, "@L 99") && zzxsizer bucket field names
8423 lcSizeName = Trim(Eval("__xSizer." + lcSizeBucket)) && zzxsizer bucket Names
8424 lnSizeQty = ppk_qty
8425
8426 m.sizebucket = lnSizePosition
8427 m.size_desc = lcSizeName
8428 m.total_qty = lnSizeQty
8429 m.multQty = lnMultiplyQty
8430
8431 If lnSizeQty > 0 && Only want buckets with activity!
8432 Insert Into (pcMultPackTarget) From Memvar
8433 Endif
8434 Select (pcMultPackDetail)
8435
8436 Endscan
8437
8438 This.TableClose("__xSizer")
8439 Select (pcMultPackDetail)
8440 Select (lnOldSele)
8441 Return llRetVal
8442 Endproc
8443
8444 *----------------------------------------------------------------------------------------
8445 *--- TechRec 1016817 04-May-2006 GS ---
8446 *- If BC SKU is not found in zzxsavlr - this procedure populates the error msg.
8447 Procedure GetStyleError
8448
8449 Lparameter tcErrorMsg, toTmpCurs
8450
8451 Do Case
8452 Case vl_scolr(division,,, Style, color_code, lbl_code)
8453 tcErrorMsg = "Invalid Dimen/Pack code." + CRLF
8454
8455 Case !Empty(color_code) And vl_scolc(division,,, Style, color_code)
8456 tcErrorMsg = "Invalid Label code." + CRLF
8457
8458 Case !Empty(Style) And vl_Stylr(division,,, Style)
8459 tcErrorMsg = "Invalid Color code." + CRLF
8460
8461 Otherwise
8462 tcErrorMsg = "Invalid Style." + CRLF
8463 Endcase
8464 Endproc
8465
8466 *----------------------------------------------------------------------------------------
8467
8468 **********************************************************************************
8469 * PL 27631 850(i) implement UOM conversion from trading partner to system UOM
8470 **********************************************************************************
8471 Procedure PopulateInboundUOM
8472 Lparameters pceipoTH, pceipoTD, pceipoCR
8473 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8474 llRetVal = .T.
8475 lnOldSelect = Select()
8476
8477 With This
8478
8479 *****************************************************************************
8480 * unconditionally reset all base_uom and uom_factor
8481 Replace base_uom With "", uom_factor With 0 For !Empty(base_uom) In (pceipoTD)
8482
8483 *****************************************************************************
8484 * Get distinct list of div,sty,col,lbl,dim for UOM conversion check
8485 * Server-side join previous list to get cursor of scolr to populate base_uom
8486 Select Distinct d.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
8487 FROM (pceipoTH) h, (pceipoTD) d ;
8488 WHERE h.pkey = d.fkey And h.customer<>'' And d.division<>'' And d.Style<>'' ;
8489 AND d.color_code<>'' ; && resolve customer and pass SKU/UPC validation/lookup
8490 Order By 1,2,3,4,5 Into Cursor __TmpCursor
8491 * TAN 31891 - JAZ - 5/20/02 @@@
8492 * If Recc("__TmpCursor")> 0
8493 If Reccount("__TmpCursor")> 0
8494 * End TAN 31891 - JAZ - 5/20/02
8495 .cSQLTempTable=""
8496 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8497 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8498 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
8499 "Where s.division= t.division and s.style= t.style and "+;
8500 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
8501 "s.dimension= t.dimension"
8502 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOM")
8503 * Populate style UOM
8504 llRetVal= llRetVal And .PopulateBaseUOM(pceipoTD, "tcUOM")
8505 Endif
8506 .TableClose("tcUOM")
8507 .TableClose("__TmpCursor")
8508
8509 *****************************************************************************
8510 * Get distinct list of Inbound UOM and style UOM
8511 * Server-side join previous list to populate UOM conversion factor
8512 Select Distinct ib_uom, base_uom From (pceipoTD) ;
8513 WHERE ib_uom<>'' And base_uom<>'' ;
8514 INTO Cursor __TmpCursor
8515 * TAN 31891 - JAZ - 5/20/02
8516 * If Recc("__TmpCursor")> 0
8517 If Reccount("__TmpCursor")> 0
8518 * End TAN 31891 - JAZ - 5/20/02
8519 .cSQLTempTable=""
8520 llRetVal= llRetVal And .GenerateSQLTempTable('__TmpCursor')
8521 llRetVal= llRetVal And .PopulateSQLTempTable('__TmpCursor') And !Empty(.cSQLTempTable)
8522 lcSQLString= "select u.* from zzxsuomd u," + .cSQLTempTable + " t " +;
8523 "Where u.uom= t.ib_uom and u.uom_convert= t.base_uom "
8524 llRetVal= llRetVal And v_sqlExec(lcSQLString, "tcUOMFactor")
8525 * Populate style UOM
8526 llRetVal= llRetVal And .PopulateUOMFactor(pceipoTD, "tcUOMFactor")
8527 Endif
8528 .TableClose("tcUOMFactor")
8529 .TableClose("__TmpCursor")
8530
8531 Endwith
8532 Select(lnOldSelect)
8533 Return llRetVal
8534 Endproc
8535
8536 *----------------------------------------------------------------------------------------
8537
8538 Procedure PopulateBaseUOM
8539 Lparameters pceipoTD, pcUOM
8540 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8541 llRetVal = .T.
8542 lnOldSelect = Select()
8543
8544 With This
8545 Select (pcUOM)
8546 Index On division+Style+color_code+lbl_code+Dimension Tag OurSku
8547 llRetVal= .SetRelation(pcUOM, "OurSku", pceipoTD, ;
8548 "division+style+color_code+lbl_code+dimension")
8549 Select (pceipoTD)
8550 If llRetVal
8551 Replace All base_uom With &pcUOM..uom In (pceipoTD);
8552 FOR !Empty(&pcUOM..uom)
8553 Endif
8554 Set Relation To
8555 Endwith
8556 Select(lnOldSelect)
8557 Return llRetVal
8558 Endproc
8559
8560 *----------------------------------------------------------------------------------------
8561
8562 Procedure PopulateUOMFactor
8563 Lparameters pceipoTD, pcUOMFactor
8564 Local llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
8565 llRetVal = .T.
8566 lnOldSelect = Select()
8567
8568 With This
8569 Select (pcUOMFactor)
8570 Index On uom+uom_convert Tag IB_BaseUOM
8571 llRetVal= .SetRelation(pcUOMFactor, "IB_BaseUOM", pceipoTD, ;
8572 "ib_uom+base_uom")
8573 Select (pceipoTD)
8574 If llRetVal
8575 Replace All uom_factor With &pcUOMFactor..uom_factor In (pceipoTD);
8576 FOR !Empty(&pcUOMFactor..uom_factor)
8577 Endif
8578 Set Relation To
8579 Endwith
8580 Select(lnOldSelect)
8581 Return llRetVal
8582 Endproc
8583
8584 *----------------------------------------------------------------------------------------
8585
8586 Procedure ResolvePrepack
8587 Lparameters pceipoTH, pceipoTD, pceipoCR
8588
8589 LOCAL llRetVal
8590 llRetVal = .t.
8591 IF VARTYPE(This.oResolvePrepack) <> "O"
8592 This.oResolvePrepack = NEWOBJECT("clsipopr_ResolvePrepack","clsipopr_ResolvePrepack.fxp","",this,this.oHostProcess)
8593 ENDIF
8594
8595 llRetVal = llRetVal and VARTYPE(This.oResolvePrepack) = "O"
8596
8597 IF NOT llRetVal
8598 this.LogEntry("ResolvePrepack object creation in clsIpopr_PreValidation... failed.")
8599 RETURN llRetVal
8600 ENDIF
8601
8602 *This.oResolvePrepack.lALLOW_RANGE_HDR_LABEL = (goEnv.SV("ALLOW_RANGE_HDR_LABEL","N") = 'Y')
8603 this.oResolvePrepack.cLogName = this.cLogName
8604
8605 *--- TechRec 1030517 25-Aug-2010 jisingh ---
8606 This.oResolvePrepack.c850Control = This.c850Control
8607 *=== TechRec 1030517 25-Aug-2010 jisingh ===
8608
8609 llRetVal = llRetVal and this.oResolvePrepack.ResolvePrepack(pceipoTH, pceipoTD, pceipoCR)
8610
8611 RETURN llRetVal
8612
8613 ENDPROC
8614
8615 *------------------------------------------------------------------------
8616
8617 *--- TechRec 1028745 05-Feb-2008 GSternik ---
8618 Procedure ValidateCharges
8619 Parameters tcEiPOtd, tcEiPOTR, tcEipoTH && * --- TR 1041118 14-Aug-2009 Surinder Singh : Added tcEipoTH
8620
8621 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added lcSeason---
8622 Local lcChrg_Type, lnFKey, lcErrorMsg1, lcErrorMsg2, lcDtlError,;
8623 lcDivision, lcCustomer, lnFKey, lnDefaultKey, lcSeason
8624 lcErrorMsg1 = "Invalid Charge Type." + CRLF
8625 lcErrorMsg2 = "Invalid Charge Flag." + CRLF
8626 lcErrorMsg3 = "Inactive Charge Used." + CRLF
8627 lcDtlError = "Has errors in Charges." + CRLF
8628 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8629 LOCAL lntcEipoTHrec, lnFkeyEipoTD, lcStore, lcCenter_Code
8630 SELECT (tcEipoTH)
8631 lntcEipoTHrec = RECNO()
8632 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8633
8634 &&--- TechRec 1064560 04-Mar-2013 vkrishnamurthy === Added ,d.chrg_formula,d.chrg_expr,d.percentage
8635 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added d.round_to ===
8636 v_sqlExec(;
8637 "select d.FKey"+;
8638 " , d.Chrg_Type"+;
8639 " , d.Chrg_Flag"+;
8640 " , d.Active_Ok"+;
8641 " , d.Chrg_Cost,d.chrg_formula,d.chrg_expr,d.percentage,d.round_to"+;
8642 " from zzxChrgD d"+;
8643 " join zzxChrTR t"+;
8644 " on t.Chrg_Type = d.Chrg_Type"+;
8645 " where t.Chrg_HdrDtl = 'D'", "qChrgD")
8646 Select qChrgD
8647 Index On Str(fkey,10) + Chrg_Type Tag FKey_Chrg
8648 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in the below query ===
8649 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli Added season in the blow query select list ---
8650 v_sqlExec(;
8651 "select Customer"+;
8652 " , Division"+;
8653 " , Store"+;
8654 " , Center_Code"+;
8655 " , Season"+;
8656 " , PKey"+;
8657 " , Rank_Seq"+;
8658 " from zzxchrgh", "qChrgH")
8659 Select qChrgH
8660 * --- TR 1041118 14-Aug-2009 Surinder Singh : Added store and center_code in below index ===
8661 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli added season in below index ---
8662 Index On division+customer+Store+Center_Code+Season Tag divcust
8663 If division = ' ' And customer = ' '
8664 lnDefaultKey = pkey
8665 Endif
8666
8667 Select (tcEiPOTR)
8668 .SetRelation(tcEiPOtd, "PKey", tcEiPOTR, "FKey")
8669 Scan
8670 lcChrg_Type = Chrg_Type
8671 Select (tcEiPOtd)
8672 lcDivision = division
8673 lcCustomer = customer
8674 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8675 lnFkeyEipoTD = fkey
8676 IF SEEK(lnFkeyEipoTD ,tcEipoTH,"pkey")
8677 lcCenter_Code = &tcEipoTH..center_Code
8678 lcStore = &tcEipoTH..Store
8679 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8680 lcSeason = &tcEipoTH..Season
8681 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8682 ELSE
8683 lcCenter_Code = ""
8684 lcStore = ""
8685 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8686 lcSeason = ""
8687 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8688 ENDIF
8689 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8690
8691 Select qChrgH
8692 Do Case
8693 * --- TR 1041118 14-Aug-2009 Surinder Singh : Commented the below original code as replaced by new code ===
8694*!* Case Seek(lcDivision+lcCustomer)
8695*!* lnFKey = pkey
8696*!* Case Seek(' '+lcCustomer, "qChrgH")
8697*!* lnFKey = pkey
8698*!* *Case Seek(Space(Len(lcCustomer))+lcDivision, "qChrgH", "CustDiv")
8699*!* Case Seek(lcDivision+' ')
8700*!* lnFKey = pkey
8701*!* Otherwise
8702*!* lnFKey = lnDefaultKey
8703 *--- TechRec 1064560 08-Feb-2013 TShenbagavalli ---
8704*!* Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code)
8705*!* lnFKey = pkey
8706*!*
8707*!* Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5))
8708*!* lnFKey = pkey
8709*!*
8710*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code)
8711*!* lnFKey = pkey
8712*!*
8713*!* Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5))
8714*!* lnFKey = pkey
8715
8716*!* Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5))
8717*!* lnFKey = pkey
8718*!*
8719*!* Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) )
8720*!* lnFKey = pkey
8721
8722 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+lcSeason)
8723 lnFKey = pkey
8724
8725 Case Seek(lcDivision+lcCustomer+lcStore+lcCenter_Code+SPACE(5))
8726 lnFKey = pkey
8727
8728 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+lcSeason)
8729 lnFKey = pkey
8730
8731 Case Seek(lcDivision+lcCustomer+lcStore+SPACE(5)+SPACE(5))
8732 lnFKey = pkey
8733
8734 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+lcSeason)
8735 lnFKey = pkey
8736
8737 Case Seek(lcDivision+lcCustomer+SPACE(9)+lcCenter_Code+SPACE(5))
8738 lnFKey = pkey
8739
8740 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+lcSeason)
8741 lnFKey = pkey
8742
8743 Case Seek(lcDivision+lcCustomer+SPACE(9)+SPACE(5)+SPACE(5))
8744 lnFKey = pkey
8745
8746 Case Seek(' '+lcCustomer+SPACE(9)+ SPACE(5) + SPACE(5))
8747 lnFKey = pkey
8748
8749 Case Seek(lcDivision+' ' + SPACE(9)+ SPACE(5) + SPACE(5))
8750 lnFKey = pkey
8751 *=== TechRec 1064560 08-Feb-2013 TShenbagavalli ===
8752
8753 Otherwise
8754 lnFKey = lnDefaultKey
8755 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8756 Endcase
8757 Select (tcEiPOTR)
8758 If Empty(lnFKey)
8759 Replace Errs_Flg_R With "Y",;
8760 Errs_Msg_R With "No Charges set up for "+;
8761 Trim(lcDivision)+'/'+Trim(lcCustomer)
8762 Else
8763 If Seek(Str(lnFKey) + lcChrg_Type, "qChrgD")
8764 lcResolved_Chrg_Flag = qChrgD.Chrg_Flag
8765
8766 *--- Check if the Charge still active:
8767 If qChrgD.Active_Ok # 'Y'
8768 Replace Errs_Flg_R With "Y",;
8769 Errs_Msg_R With lcErrorMsg3
8770 Endif
8771
8772 If Empty(Chrg_Flag)
8773 *-- Set Charge Type from Resolution if success
8774 If Errs_Flg_R # "Y"
8775 Replace Chrg_Flag With lcResolved_Chrg_Flag
8776 Endif
8777 Else
8778 If Chrg_Flag # lcResolved_Chrg_Flag
8779 Replace Errs_Flg_R With "Y",;
8780 Errs_Msg_R With lcErrorMsg2 + Errs_Msg_R
8781 Endif
8782 Endif
8783 Else
8784 Replace Errs_Flg_R With "Y",;
8785 Errs_Msg_R With lcErrorMsg1
8786 lnFKey = fkey
8787 lcResolved_Chrg_Flag = ""
8788 Endif
8789 Endif
8790
8791 If Errs_Flg_R = "Y"
8792 Select(tcEiPOtd)
8793 If !lcDtlError$Errs_Msg_D
8794 Replace Errs_Msg_D With Errs_Msg_D + lcDtlError, ;
8795 Errs_Flg_D With 'Y'
8796 Endif
8797 ELSE
8798 *--- TechRec 1064560 04-Mar-2013 vkrishnamurthy --- as of now treat chrg amt column as same for bot % and C/F type
8799* Replace Chrg_Cost With qChrgD.Chrg_Cost
8800 &&--- TechRec 1064560 13-Mar-2013 TShenbagavalli added round_to with qChrgD.round_to ===
8801 Replace Chrg_Cost With qChrgD.Chrg_Cost,chrg_formula WITH qChrgD.chrg_formula, round_to WITH qChrgD.round_to, ;
8802 percentage WITH IIF(chrg_flag <> 'P' , 0, IIF(EMPTY(percentage),chrg_amt,percentage)), ;
8803 chrg_amt WITH IIF(chrg_flag = 'P', 0, chrg_amt )
8804 *=== TechRec 1064560 04-Mar-2013 vkrishnamurthy ===
8805 Endif
8806 Endscan
8807
8808 Set Relation To
8809 Use In Select("qChrgH")
8810 Use In Select("qChrgD")
8811 * --- TR 1041118 14-Aug-2009 Surinder Singh ---
8812 IF lntcEipoTHrec > 0 AND lntcEipoTHrec <= RECCOUNT(tcEipoTH)
8813 GO lntcEipoTHrec IN (tcEipoTH)
8814 ENDIF
8815 * === TR 1041118 14-Aug-2009 Surinder Singh ===
8816
8817 Endproc
8818 *=== TechRec 1028745 05-Feb-2008 GSternik ===
8819
8820 *------------------------------------------------------------------------
8821
8822 *--- TR 1083402 20-Jan-2015 Partha ---
8823 * ROFL - This proc is duplicate :)
8824*!* *----------------------------------------------------------------------------------------
8825*!* *--- TR 1034481 NH
8826*!* PROCEDURE MarkHeaderForMissing855ControlRef
8827*!* LPARAMETERS pceipoTH
8828*!*
8829*!* LOCAL llRetVal, lnOldSelect,lcZzeoprcr
8830*!*
8831*!* llRetVal = .t.
8832*!* lnOldSelect = SELECT()
8833*!* lcZzeoprcr = "Oprcr" + SYS(2015)
8834*!* *--- cache 855 control ref - oVnd_key is optional match so, only matching customer, and division
8835*!* llRetVal = llRetVal and v_sqlexec("select customer, division from zzeoprcr", lcZzeoprcr)
8836*!*
8837*!* IF USED(lcZzeoprcr)
8838*!* INDEX on customer TAG customer
8839*!* INDEX on division TAG division
8840*!*
8841*!* UPDATE th SET errs_flg_h = 'Y', errs_msg_h = errs_msg_h + 'Corresponding 855 control reference not found.' + CRLF ;
8842*!* from (pceipoTH) th WHERE th.req_855 ='R' AND th.errs_flg_h <> 'Y' ;
8843*!* AND NOT exists ( select c.customer from (lcZzeoprcr) c WHERE c.customer = th.customer AND c.division = th.division)
8844
8845*!* USE IN (lcZzeoprcr)
8846*!* ENDIF
8847*!*
8848*!* SELECT(lnOldSelect)
8849*!* RETURN llRetVal
8850*!*
8851*!* ENDPROC
8852*!* *=== TR 1034481 NH
8853
8854 *=== TR 1083402 20-Jan-2015 Partha ===
8855
8856 *----------------------------------------------------------------------------------------
8857
8858 *--- TR 1035491 4-Nov-2008 Goutam
8859 ************************************************************************************
8860 * Move SLN to Detail.
8861 ************************************************************************************
8862 Procedure MoveSLNToDTLs
8863 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
8864 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
8865 *Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
8866 *--- TR 1036614 8-Jun-2009 Goutam. Removed pcTmpCursor from above parameter.
8867
8868 Local llRetVal, lnOldSelect, lnPSFkey, lnSkipedPSFkey, lnCoor_Code, lnStartPkey, lnDetailPrice, ;
8869 lnLine_Seq
8870
8871 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
8872 LOCAL lcSQL ,loIPOtdn
8873 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
8874
8875 LOCAL lnTotSLNQty && TR 1049029 24-Aug-2010 Partha
8876
8877 llRetVal = true
8878 lnOldSelect = Select()
8879 lnDetailPrice = 0
8880
8881 *--- TR 1036614 8-Jun-2009 Goutam
8882 *--- This function is splited and taken following sql in different function called CreateCursorSLNToDtl
8883
8884*!* select t.Customer ;
8885*!* , t.FKey ;
8886*!* , t.PKey ;
8887*!* , c.price_flg ;
8888*!* from (pcTmpCursor) t ;
8889*!* join zzeipocr c ;
8890*!* on c.division = t.division ;
8891*!* and c.customer = t.customer ;
8892*!* join (pceipoTD) d ;
8893*!* on d.pkey = t.dtlPkey ;
8894*!* where c.slntodtl = 'Y' ;
8895*!* and d.slntodtl <> 'Y' ;
8896*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
8897*!* into Cursor __tmpipots ;
8898*!* order by t.fkey, t.Customer, t.PKey
8899
8900 *=== TR 1036614 8-Jun-2009 Goutam
8901
8902 *-- #1 Create detail record from pceipoTS
8903 SELECT __tmpipots
8904 lnStartPkey = v_nextPkey("ZZEIPOID", RECCOUNT("__tmpipots")) - RECCOUNT("__tmpipots")
8905 GO top
8906 lnSkipedPSFkey = 0
8907 lnPSFkey = 0
8908 lnCoor_Code = 1
8909 lnLine_Seq = 0
8910 lnTotSLNQty = 0 && TR 1049029 24-Aug-2010 Partha
8911
8912 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8913 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
8914 ENDIF
8915 DO WHILE NOT EOF()
8916 lnPSFkey = Fkey
8917
8918 *--- TR 1049029 24-Aug-2010 Partha ---
8919 IF lnPSFkey <> lnSkipedPSFkey
8920 lnTotSLNQty = This.GetTotSLNQty(lnPSFkey, pceipoTS)
8921 lnSkipedPSFkey = Fkey && TR 1062018/1064343 FH - moved to up here.
8922 ENDIF
8923 *=== TR 1049029 24-Aug-2010 Partha ===
8924
8925 lnStartPkey = lnStartPkey + 1
8926 IF SEEK(lnPSFkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
8927 lnLine_Seq = lnLine_Seq + 1
8928 SELECT (pceipoTD)
8929 SCATTER NAME loIPOtd MEMO
8930 loIPOtd.pkey = lnStartPkey
8931 loIPOtd.Line_Seq = lnLine_Seq
8932
8933 *-FH 1077588 - detail's header pkey
8934 lnHfkey = fkey
8935
8936 *--- TechRec 1056973 06-Dec-2011 jisingh ---
8937 IF SEEK(STR(&pceipoTS..doc_num)+&pceipoTS..sln_line+&pceipoTS..sln01, pczzeiPOtWhse, "SLN_Line")
8938 *- 1060291 04/02/2012 YIK/FH
8939*!* REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8940*!* dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse)
8941 SELECT (pczzeiPOtWhse)
8942 lnDocNum = doc_num
8943 lnEdiLine = edi_line
8944 lnSlnLine = sln_line
8945
8946 REPLACE line_seq WITH loIPOtd.line_seq, sizebucket WITH &pceipoTS..sizebucket, ;
8947 dfkey WITH loIPOtd.pkey, sfkey WITH &pceipoTS..pkey IN (pczzeiPOtWhse) ;
8948 FOR doc_num = lnDocNum AND edi_line = lnEdiLine AND sln_line = lnSlnLine AND hfkey = lnHfkey &&FH 1077588
8949
8950 SELECT (pceipoTD)
8951 *= 1060291
8952 ENDIF
8953 *=== TechRec 1056973 06-Dec-2011 jisingh ===
8954
8955 *--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ---
8956*!* loIPOtd.slntodtl = 'Y'
8957
8958 *--- TR 1045922 05-MAR-2010 HNISAR
8959 *- 1060291 03/30/2012 YIK
8960 *- If there's a DTL with only one SLN - we move the SLN to DTL, so we need mark it with slntodtl = 'I'
8961*-- loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8962*-- IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030' AND __tmpipots.slntodtl = 'Y', 'I', __tmpipots.slntodtl))
8963 loIPOtd.slntodtl = IIF(__tmpipots.Template = 'HIBBETTS' , 'O', ;
8964 IIF(__tmpipots.Template = 'CHARMING SHOPPES 4030', 'I', __tmpipots.slntodtl))
8965 *=== TechRec 1056973 09-Nov-2011 jisingh ===
8966 *=== TR 1045922 05-MAR-2010 HNISAR
8967
8968
8969
8970 *- TR 1062810 FH - separate into 2 IF statement, for scenario where assortment is populated but not assort_qty
8971 *--- TechRec 1063327 16-Aug-2012 jjanand ---
8972 *--- TechRec 1049029 06-Sep-2010 vkrishnamurthy ---
8973*!* IF EMPTY(loIPOtd.Assortment) AND EMPTY(loIPOtd.assort_qty)
8974*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) +"@"+ ALLTRIM(loIPOtd.SKU) +"@"+ ALLTRIM(loIPOtd.po1_line)
8975*!* loIPOtd.assort_qty = loIPOtd.total_qty
8976*!* ENDIF
8977 *=== TechRec 1049029 06-Sep-2010 vkrishnamurthy ===
8978*!* IF EMPTY(loIPOtd.Assortment)
8979*!* loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8980*!* IF loIPOtd.assort_qty = 0
8981*!* loIPOtd.assort_qty = loIPOtd.total_qty
8982*!* ENDIF
8983*!* ENDIF
8984
8985 IF EMPTY(loIPOtd.Assortment)
8986 loIPOtd.Assortment = ALLTRIM(loIPOtd.UPC) + "@" + ALLTRIM(loIPOtd.SKU) + "@" + ALLTRIM(loIPOtd.po1_line)
8987 ENDIF
8988 IF EMPTY(loIPOtd.assort_qty)
8989 loIPOtd.assort_qty = loIPOtd.total_qty
8990 ENDIF
8991 *=== TechRec 1063327 16-Aug-2012 jjanand ===
8992 *- TR 1062810 FH
8993
8994 *=== TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
8995 loIPOtd.PO1_UPC = loIPOtd.UPC
8996 loIPOtd.PO1_SKU = loIPOtd.SKU
8997 loIPOtd.po1_price = loIPOtd.org_price
8998 loIPOtd.Division = &pceipoTS..Division
8999 loIPOtd.Style = &pceipoTS..Style
9000 loIPOtd.Color_code = &pceipoTS..Color_code
9001 loIPOtd.Lbl_Code = &pceipoTS..Lbl_Code
9002 loIPOtd.Dimension = &pceipoTS..Dimension
9003 loIPOtd.SizeBucket = &pceipoTS..SizeBucket
9004 loIPOtd.Size_Desc = &pceipoTS..Size_Desc
9005 loIPOtd.UPC = &pceipoTS..SLN_UPC
9006 *- 03/19/09 1038539, 1039344 YIK
9007 loIPOtd.SKU = &pceipoTS..SLN_SKU
9008 *- TR 1051757 FH 04/19/11
9009 loIPOtd.aux_sku = &pceipoTS..aux_sku
9010
9011 *--- TechRec 1056973 07-Dec-2011 jisingh ---
9012 loIPOtd.sln01 = &pceipoTS..sln01
9013 *=== TechRec 1056973 07-Dec-2011 jisingh ===
9014
9015 *--- TR 1049029 30-Aug-2010 Partha ---
9016
9017*!* *--- TR 1047912 23-Jun-2010 Partha ---
9018*!* IF INLIST(loIPOtd.ppk_action, 'B', 'Q')
9019*!* *=== TR 1047912 23-Jun-2010 Partha ===
9020*!*
9021*!* loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9022*!*
9023*!* *=== TR 1047912 23-Jun-2010 Partha ===
9024*!* ENDIF
9025*!* *=== TR 1047912 23-Jun-2010 Partha ===
9026*!*
9027*!* *--- TR 1047912 23-Jun-2010 Partha ---
9028*!* IF INLIST(loIPOtd.ppk_action, 'B', 'P')
9029*!* lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9030*!* ELSE
9031*!* lnDetailPrice = &pceipoTD..Org_Price
9032*!* ENDIF
9033*!* *=== TR 1047912 23-Jun-2010 Partha ===
9034
9035 DO CASE
9036 CASE loIPOtd.ppk_action = 'B'
9037 *- 02/18/11 1052584 YIK
9038 *- Moved calculation of ppk_qty here
9039 loIPOtd.ppk_qty = lnTotSLNQty
9040
9041 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9042
9043 *-TR 1053023 FH 03/09/11 - set ppk_action to 'S'
9044 *loIPOtd.ppk_action = 'X'
9045 loIPOtd.ppk_action = 'S'
9046 lnDetailPrice = loIPOtd.Org_Price/ lnTotSLNQty
9047 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9048 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9049 *- 02/18/11 YIK 1052584
9050 *- moved calculation of ppk_qty higher
9051 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9052
9053 CASE loIPOtd.ppk_action = 'Q' OR __tmpipots.template = 'GAP 4010'
9054 *- 02/18/11 YIK 1052584
9055 *- Moved calculation of ppk_qty here
9056 loIPOtd.ppk_qty = lnTotSLNQty
9057
9058 loIPOtd.total_qty = &pceipoTS..SLN_Qty * loIPOtd.total_qty
9059
9060 IF loIPOtd.ppk_action = 'Q'
9061 loIPOtd.ppk_action = 'M'
9062 ENDIF
9063
9064 *- 02/18/11 YIK 1052584
9065 *- moved calculation of ppk_qty higher
9066 *-loIPOtd.ppk_qty = loIPOtd.total_qty
9067
9068 lnDetailPrice = &pceipoTD..Org_Price
9069
9070 CASE loIPOtd.ppk_action = 'P'
9071 *-TR 1062018/1064343 FH - moved up
9072 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9073 *- TR 1062018/1064343 FH - moved up
9074 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9075 loIPOtd.ppk_action = 'D'
9076 lnDetailPrice = loIPOtd. Org_Price/ lnTotSLNQty
9077 loIPOtd.Retail1 = loIPOtd.retail1 / lnTotSLNQty
9078 loIPOtd.Retail2 = loIPOtd.retail2 / lnTotSLNQty
9079
9080
9081 OTHERWISE
9082 *-TR 1062018/1064343 FH - moved up
9083 loIPOtd.assort_qty = loIPOtd.total_qty/lnTotSLNQty &&--- TechRec 1063327 20-Aug-2012 jjanand ===
9084 *- TR 1062018/1064343 FH - moved up
9085 loIPOtd.total_qty = (loIPOtd.total_qty/lnTotSLNQty) * &pceipoTS..SLN_Qty
9086 lnDetailPrice = &pceipoTD..Org_Price
9087 loIPOtd.ppk_qty = lnTotSLNQty
9088
9089 ENDCASE
9090 *=== TR 1049029 30-Aug-2010 Partha ===
9091
9092 loIPOtd.coord_code = IIF(EMPTY(coord_code),Trans(lnCoor_Code, "@L 999"), coord_code)
9093 IF __tmpipots.price_flg = "E"
9094 loIPOtd.org_price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9095 ELSE
9096 loIPOtd.Price = IIF(&pceipoTS..SLN_Price=0, lnDetailPrice, NVL(&pceipoTS..SLN_Price,0))
9097 ENDIF
9098
9099 *--- TR 1038353 NH - need to clear error flg for details, those are created from SLN
9100 loIPOtd.Errs_flg_d = "N"
9101 loIPOtd.Errs_msg_d = ""
9102 *=== TR 1038353 NH
9103
9104 APPEND BLANK
9105 GATHER NAME loIPOtd MEMO
9106
9107 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9108
9109 *--- TechRec 1040233 08-May-2009 vkrishnamurthy ---
9110 lcSQL = " SELECT * FROM Vzzeipotd_notes_iPOproc " + ;
9111 " into Cursor _tmpipodnt WHERE fkey = " + SQLFormatNum(__tmpipots.Fkey)
9112
9113 &lcSQL
9114 SELECT _tmpipodnt
9115 SCAN
9116 IF SEEK(_tmpipodnt.Pkey ,"Vzzeipotd_notes_iPOproc" , "Pkey")
9117 SELECT "Vzzeipotd_notes_iPOproc"
9118 SCATTER NAME loIPOtdn MEMO
9119
9120 APPEND BLANK
9121 loIPOtdn.Fkey = lnStartPkey
9122 loIPOtdn.Pkey = v_nextPkey("SysNotes")
9123
9124 GATHER NAME loIPOtdn MEMO
9125 ENDIF
9126
9127 ENDSCAN
9128 *=== TechRec 1040233 08-May-2009 vkrishnamurthy ===
9129
9130 ENDIF && TR 1043037 OCT-06-2009 BR
9131 ENDIF
9132 SELECT __tmpipots
9133 SKIP IN __tmpipots
9134 *lnSkipedPSFkey = Fkey && - TR 1062018/1064343 FH - moved up
9135
9136 *- TR 1062018/1064343 FH
9137 *IF (lnPSFkey <> lnSkipedPSFkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9138 IF (lnPSFkey <> Fkey) AND SEEK(lnPSFkey, pceipoTD, "PKey")
9139 *- TR 1062018/1064343 FH
9140 DELETE IN (pceipoTD)
9141
9142 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9143
9144 *--- TechRec 1040233 12-May-2009 vkrishnamurthy ---
9145 DELETE IN "Vzzeipotd_notes_iPOproc" FOR Fkey = lnPSFkey
9146 *=== TechRec 1040233 12-May-2009 vkrishnamurthy ===
9147
9148 ENDIF && TR 1043037 OCT-06-2009 BR
9149
9150 lnCoor_Code = lnCoor_Code + 1
9151 IF SEEK(__tmpipots.Fkey, pceipoTD, "PKey") AND Seek(__tmpipots.PKey, pceipoTS, "PKey")
9152 lnDetailPrice = .getPriceFromIPOts(pceipoTS, &pceipoTD..Org_Price)
9153 ENDIF
9154 lnLine_Seq = 0
9155 ENDIF
9156 ENDDO
9157 USE IN __tmpipots
9158
9159 IF USED("Vzzeipotd_notes_iPOproc") AND RECCOUNT("Vzzeipotd_notes_iPOproc") > 0 && TR 1043037 OCT-06-2009 BR
9160
9161 *--- TechRec 1040233 13-May-2009 vkrishnamurthy ---
9162 This.Tableupdate("Vzzeipotd_notes_iPOproc")
9163 *=== TechRec 1040233 13-May-2009 vkrishnamurthy ===
9164
9165 ENDIF && TR 1043037 OCT-06-2009 BR
9166
9167 SELECT (lnOldSelect)
9168 RETURN llRetVal
9169 ENDPROC
9170
9171*=======================================================================
9172
9173 *---- get total sln qty for a detail line
9174 FUNCTION getPriceFromIPOts
9175 LPARAMETERS pceipoTS, pnPrice
9176 LOCAL lnOldSelect, lnSLNQty, lnSLNTotalQty, lnUnitPrice, lnFkey
9177 lnUnitPrice = 0
9178 IF pnPrice > 0
9179 lnOldSelect = SELECT()
9180
9181 SELECT (pceipoTS)
9182 lnFkey = Fkey
9183 lnSLNQty = SLN_Qty
9184 .PushRecordSet()
9185 SUM SLN_Qty FOR fkey = lnFkey TO lnSLNTotalQty
9186 lnUnitPrice = pnPrice/lnSLNTotalQty
9187 .PopRecordSet()
9188
9189 SELECT (lnOldSelect)
9190 ENDIF
9191
9192 RETURN lnUnitPrice
9193 ENDFUNC
9194
9195 ************************************************************************************
9196 * Resolve BC SKU from SLN records and create customer style data.
9197 *--- This is splitted 1st part from function ResolveStyleFromSLN
9198 ************************************************************************************
9199 Procedure ResolveBCSkuFromSLN
9200 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse
9201 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9202 *--- TechRec 1052378 10-Feb-2011 jjanand === Added lnSelect
9203 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9204 lcDivision, lcStyle, lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS, lcErrs_Msg, ;
9205 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lnSelect
9206
9207 lnOldSelect = Select()
9208 llRetVal = .T. && 1040686
9209 *--- TR 1036614 3-Mar-2010 Goutam
9210 lcErrs_Msg = ""
9211 lcDivision = ""
9212 *=== TR 1036614 3-Mar-2010 Goutam
9213
9214 *-- #1 Resolve SLN SKUs
9215 *--- TR 1035491 11-Nov-2008 Goutam. Added d.Pkey as dtlPkey in the following select list.
9216 *- 03/19/09 TR ? Retrofit TR1038539 YIK
9217 *- added SLN_SKU
9218 *- Removed WHERE ...and !Empty(s.SLN_UPC)
9219
9220 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
9221 * Added , s.sln_qty
9222 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
9223
9224 select h.Customer;
9225 , s.FKey;
9226 , s.SLN_UPC as UPC;
9227 , s.SLN_SKU as SKU ;
9228 , h.department ;
9229 , h.store ;
9230 , s.PKey;
9231 , .F. as SLN_Error;
9232 , Empty(d.SizeBucket) as Unresolved;
9233 , s.Division;
9234 , s.Style;
9235 , s.Color_Code;
9236 , s.SizeBucket;
9237 , d.Pkey as dtlPkey;
9238 , 'N' as IsPPK;
9239 , SPACE(5) as ppk_code;
9240 , d.assortment as assortment; && TechRec 1052378 10-Feb-2011 jjanand ---
9241 , s.sln_qty ;
9242 from (pceipoTH) h;
9243 join (pceipoTD) d ;
9244 on d.FKey = h.PKey;
9245 join (pceipoTS) s ;
9246 on s.FKey = d.PKey ;
9247 where !Empty(h.Customer) ;
9248 order by 1, 2;
9249 into Cursor tmpCurs ReadWrite
9250
9251* , s.Lbl_Code;
9252* , s.Dimension;
9253
9254*- 1040686
9255
9256 *=-=-=-=-=-=-=-=-=-=-=-=-==-
9257 SELECT DISTINCT customer,upc FROM tmpCurs INTO CURSOR tcCustUpc
9258 llRetVal = llRetVal AND .GenerateSQLTempTable("tcCustUpc")
9259 IF llRetVal
9260 .PopulateSQLTempTable("tcCustUpc")
9261 ENDIF
9262
9263 llRetVal = llRetVal AND v_sqlexec(;
9264 "SELECT x.upc,d.* "+;
9265 " FROM zzxcstdr d"+ ;
9266 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9267 " JOIN " + this.cSQLTempTable + " x " + ;
9268 " ON d.customer = x.customer " +;
9269 " AND d.cust_style = x.upc " + ;
9270 " WHERE h.IB_resolv = 'Y'" + ;
9271 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_upc")
9272 SELECT tmpCstdr_upc
9273 INDEX on customer + upc TAG cust_upc
9274
9275
9276 SELECT distinct upc,LEFT(upc,11) as upc_num FROM tmpCurs INTO CURSOR tcDistUpc
9277 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistUpc")
9278 IF llRetVal
9279 .PopulateSQLTempTable("tcDistUpc")
9280 ENDIF
9281
9282 llRetVal = llRetVal AND v_sqlexec(;
9283 "SELECT x.upc,d.* "+;
9284 " FROM zzeupcnr d"+ ;
9285 " JOIN " + this.cSQLTempTable + " x " + ;
9286 " ON d.upc_num = x.upc_num ","tmpUpcnr")
9287 SELECT tmpUpcnr
9288 INDEX on upc TAG upc
9289
9290
9291 SELECT distinct customer, sku FROM tmpCurs INTO CURSOR tcDistCustSku
9292 llRetVal = llRetVal AND .GenerateSQLTempTable("tcDistCustSku")
9293 IF llRetVal
9294 .PopulateSQLTempTable("tcDistCustSku")
9295 ENDIF
9296 llRetVal = llRetVal AND v_sqlexec(;
9297 "SELECT x.sku,d.* "+;
9298 " FROM zzxcstdr d"+ ;
9299 " JOIN zzxcsthr h ON d.fkey = h.pkey " + ;
9300 " JOIN " + this.cSQLTempTable + " x " + ;
9301 " ON d.customer = x.customer " +;
9302 " AND d.cust_style = x.sku " + ;
9303 " WHERE h.IB_resolv = 'Y'" + ;
9304 " AND d.Size_Desc>'' " + ;
9305 " ORDER BY d.customer,d.cust_style,d.lbl_code DESC","tmpCstdr_sku")
9306 SELECT tmpCstdr_sku
9307 INDEX ON customer + cust_style TAG cust_sku
9308
9309 SELECT customer,sku FROM tmpCstdr_sku GROUP BY customer,sku HAVING COUNT(*) > 2 INTO CURSOR tcAmbigSku ;
9310 UNION ;
9311 SELECT customer,sku FROM tmpCstdr_sku ;
9312 GROUP BY customer,sku ;
9313 HAVING COUNT(*) = 2 AND !(NOT EMPTY(MAX(lbl_code)) AND EMPTY(MIN(lbl_code)))
9314 INDEX ON customer+sku TAG cust_sku
9315 *=-===-=-=-=-=-=-=-
9316
9317*- 1040686
9318
9319 Select tmpCurs
9320 If This.lUserInterface
9321 This.UpdateThermoCaption("Validating SLN UPC(s)...")
9322 This.InitThermo(RecCount())
9323 EndIf
9324
9325 lcOldCust = ""
9326 lcOldUPC = ""
9327 *- 03/19/09 1038539 YIK
9328 lcOldItem = ''
9329 Local lcSku_resolv, lcOldSku_resolv
9330 lcSku_resolv = ""
9331 *=
9332
9333 Scan for (Empty(Division) or Empty(Style) or Empty(Color_Code) or SizeBucket = 0)
9334 If This.lUserInterface
9335 * Advance progress bar, if we're using one.
9336 This.AdvanceThermo(RecNo())
9337 EndIf
9338 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9339 IF !EMPTY(tmpCurs.UPC)
9340
9341 If !(tmpCurs.Customer == lcOldCust And tmpCurs.UPC == lcOldUPC)
9342 lcErrs_Msg = ""
9343 lcOldCust = tmpCurs.Customer
9344 lcOldUPC = tmpCurs.UPC
9345
9346 *If This.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, lcOldCust, lcOldUPC, "tmpCstdr")
9347 IF SEEK(tmpCurs.Customer+tmpCurs.UPC,"tmpCstdr_upc","cust_upc") &&1040686
9348*- 1040686
9349*!* lcDivision = tmpCstdr.division
9350*!* lcStyle = tmpCstdr.Style
9351*!* lcColor_Code = tmpCstdr.Color_Code
9352*!* lcLbl_Code = tmpCstdr.Lbl_Code
9353*!* lcDimension = tmpCstdr.Dimension
9354*!* lnSizeBucket = tmpCstdr.Size_Bk
9355*!* lnSize_Desc = tmpCstdr.Size_Desc
9356 lcDivision = tmpCstdr_upc.division
9357 lcStyle = tmpCstdr_upc.Style
9358 lcColor_Code = tmpCstdr_upc.Color_Code
9359 lcLbl_Code = tmpCstdr_upc.Lbl_Code
9360 lcDimension = tmpCstdr_upc.Dimension
9361 lnSizeBucket = tmpCstdr_upc.Size_Bk
9362 lnSize_Desc = tmpCstdr_upc.Size_Desc
9363*- 1040686
9364 Else
9365 lcErrs_Msg = ""
9366 *If This.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
9367 IF SEEK(tmpCurs.upc,"tmpUpcnr","upc") &&1040686
9368 lcDivision = tmpUpcnr.Division
9369 lcStyle = tmpUpcnr.Style
9370 lcColor_Code = tmpUpcnr.Color_Code
9371 lcLbl_Code = tmpUpcnr.Lbl_Code
9372 lcDimension = tmpUpcnr.Dimension
9373 lnSizeBucket = tmpUpcnr.SizeBucket
9374 lnSize_Desc = tmpUpcnr.Size_Desc
9375 ELSE
9376 *-&&1040686
9377 *lcErrs_Msg = lcErrs_Msg + CRLF
9378 lcErrs_Msg = lcErrs_Msg + "Invalid UPC code." + CRLF
9379 *-&&1040686
9380 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9381 lnSizeBucket = 0
9382 Endif
9383 Endif
9384 Endif && level break
9385 *- 03/01/09 TR 1038977 Retrofit TR1038539 YIK
9386 *- Added resolution on SKU
9387 ENDIF && TmpCurs.UPC
9388 *- 03/17/09 TR 1038539 YIK
9389 *- Resolve based on SKU if only SKU is sent or both UPC and SKU are sent,
9390 *- but UPC resolution failed.
9391 *- IF !EMPTY(tmpCurs.SKU) AND EMPTY(lcStyle)
9392 IF !EMPTY(tmpCurs.SKU) AND ( EMPTY(tmpCurs.UPC) OR EMPTY(lcStyle) )
9393
9394 If !(tmpCurs.customer == lcOldCust And tmpCurs.sku == lcOldItem )
9395 lcErrs_Msg = ""
9396 lcOldCust = tmpCurs.customer
9397 lcOldItem = tmpCurs.sku
9398
9399 *- 1040686
9400 *If This.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr", ;
9401 lcSku_resolv, tmpCurs.department, tmpCurs.Store)
9402 *- TR 1074276 FH - adding UPPER() for cases when SKU in 850 FF isn't all CAPITALIZED.
9403 IF NOT SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tmpCstdr_sku","cust_sku")
9404 lcErrs_Msg = lcErrs_Msg + "Invalid SKU code. " + CRLF
9405 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9406 Store 0 To lnSizeBucket
9407 ELSE
9408 *- TR 1074276 FH - adding UPPER()
9409 IF SEEK(UPPER(tmpCurs.customer+tmpCurs.sku),"tcAmbigSku","cust_sku")
9410 lcErrs_Msg = lcErrs_Msg + "Ambiguous Customer SKU. " + CRLF
9411 Store "" To lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
9412 Store 0 To lnSizeBucket
9413 ELSE
9414*!* lcDivision = tmpCstdr.division
9415*!* lcStyle = tmpCstdr.Style
9416*!* lcColor_code = tmpCstdr.color_code
9417*!* lcLbl_code = tmpCstdr.lbl_code
9418*!* lcDimension = tmpCstdr.Dimension
9419*!* lnSizeBucket = tmpCstdr.size_bk
9420*!* lnSize_desc = tmpCstdr.size_desc
9421 lcDivision = tmpCstdr_sku.division
9422 lcStyle = tmpCstdr_sku.Style
9423 lcColor_code = tmpCstdr_sku.color_code
9424 lcLbl_code = tmpCstdr_sku.lbl_code
9425 lcDimension = tmpCstdr_sku.Dimension
9426 lnSizeBucket = tmpCstdr_sku.size_bk
9427 lnSize_desc = tmpCstdr_sku.size_desc
9428 ENDIF
9429 ENDIF
9430 *- 1040686
9431 ENDIF
9432 ENDIF
9433 *== 1038539 Resolution on SKU
9434
9435 Select (pceipoTS)
9436 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9437
9438 Scatter Name loEiPOTS Memo
9439 If !Empty(lcErrs_Msg)
9440 loEiPOTS.Errs_Msg_S = Alltrim(loEiPOTS.Errs_Msg_S) + lcErrs_Msg
9441 loEiPOTS.Errs_Flg_S = "Y"
9442 replace Sln_Error with .T. in tmpCurs
9443 Else
9444 replace Division with lcDivision in tmpCurs
9445 Endif
9446
9447 If !Empty(lcDivision) && update w/ style if found, no matter good or bad
9448 loEiPOTS.Division = lcDivision
9449 loEiPOTS.Style = lcStyle
9450 loEiPOTS.Color_Code = lcColor_code
9451 loEiPOTS.Lbl_Code = lcLbl_code
9452 loEiPOTS.Dimension = lcDimension
9453 loEiPOTS.SizeBucket = lnSizeBucket
9454 loEiPOTS.Size_Desc = lnSize_Desc
9455 Endif
9456
9457 Gather Name loEiPOTS Memo
9458
9459 EndScan
9460
9461*- 1060291 07/02/12 YIK
9462*- The code below makes no sense. It takes the first prepack found for the SLN.
9463*- So if a UPC is a part of several possible prepacks - the first one is always chosen.
9464 *--- TR 1036614 17-Mar-2010 Goutam
9465*-- SELECT tmpCurs
9466*-- SCAN FOR IsPPK = 'N'
9467*-- Select (pceipoTS)
9468*-- =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9469*-- Scatter Name loEiPOTS Memo
9470*--
9471*-- IF NOT EMPTY(loEiPOTS.Dimension)
9472*-- lcppk_code = vl_ppakh(loEiPOTS.Division,'PPK_CODE',, vl_stylr(loEiPOTS.Division,'size_code',,loEiPOTS.Style), loEiPOTS.Dimension)
9473*-- IF !EMPTY(lcppk_code)
9474*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9475*-- ENDIF
9476*-- ENDIF
9477*-- *-=-=-=- TR 1048297 FH - added loEiPOTS.Errs_Flg_S != 'Y'
9478*-- *--- TR 1053820 17-Aug-2011 Goutam. Added AND USED('__tmpDimCurs')
9479*-- 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')
9480*-- SELECT __tmpDimCurs
9481*-- LOCATE FOR ppack_ok = 'Y' AND !EMPTY(dimension)
9482*-- lcppk_code = dimension
9483*-- USE IN SELECT('__tmpDimCurs')
9484*-- *- TR 1050260 Added loEiPOTS.Dimension to vl_ppakd
9485*-- 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)
9486*-- SELECT __tmpDimCurs
9487*-- IF RECCOUNT('__tmpDimCurs') = 1 AND loEiPOTS.SizeBucket > 0 AND EVALUATE("pack" + PADL(loEiPOTS.SizeBucket, 2, '0') + "_qty") > 0
9488*-- replace IsPPK WITH 'Y', ppk_code WITH lcppk_code IN tmpCurs
9489*-- ENDIF
9490*-- USE IN SELECT('__tmpDimCurs')
9491*-- ENDIF
9492*-- ENDIF
9493*-- ENDSCAN
9494 *--- TR 1036614 17-Mar-2010 Goutam
9495
9496 *--- TR 1038353 NH - error out dtl line for SLN error
9497 UPDATE td SET Style_SLN_OK = 'N' ;
9498 FROM (pceipoTD) td INNER JOIN (pceipoTS) ts on td.pkey = ts.fkey ;
9499 WHERE ts.errs_flg_s ='Y'
9500 *=== TR 1038353 NH
9501
9502 If This.lUserInterface
9503 * Reset Thermometer
9504 This.ResetThermo()
9505 EndIf
9506
9507 *--- TR 1036614 8-Jun-2009 Goutam
9508 *llRetVal= This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9509 *llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9510
9511 *--- TechRec 1052378 10-Feb-2011 jjanand ---
9512 lnSelect = SELECT()
9513
9514 *- TR 1075974 FH - if good and bad sln's both have empty assortment, we are setting good sln's with sln_error = .T.
9515 Select Distinct assortment From tmpCurs Where sln_error = .T. AND assortment <> '' Into Cursor tmpErrSlnLines
9516
9517 Select tmpErrSlnLines
9518 Scan
9519 Replace All sln_error With .T. For assortment = tmpErrSlnLines.Assortment in tmpCurs
9520 Endscan
9521
9522 This.TableClose("tmpErrSlnLines")
9523
9524 Select (lnSelect )
9525 *=== TechRec 1052378 10-Feb-2011 jjanand ===
9526
9527 llRetVal = This.CreateCursorSLNToDtl(pceipoTD, pceipoCR, "tmpCurs")
9528 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9529 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9530 llRetVal = llRetVal AND This.ResolvePPKSkuAndUpdateDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9531 llRetVal = llRetVal AND This.ResolveSingleSLNDetail(pceipoTH, pceipoTD, pceipoTS, pceipoCR, "tmpCurs")
9532 llRetVal = llRetVal AND This.CreateSingleSLNCursor("tmpCurs")
9533 *--- TechRec 1056973 06-Dec-2011 jisingh Added pczzeiPOtWhse ===
9534 llRetVal = llRetVal AND This.MoveSLNToDTLs(pceipoTH, pceipoTD, pceipoTS, pceipoCR, pczzeiPOtWhse)
9535
9536 This.TableClose("tmpCurs")
9537
9538 *=== TR 1036614 8-Jun-2009 Goutam
9539
9540 *-1040686
9541 USE IN SELECT("tcCustUpc")
9542 USE IN SELECT("tmpCstdr_upc")
9543 USE IN SELECT("tcDistUpc")
9544 USE IN SELECT("tmpUpcnr")
9545 USE IN SELECT("tcDistCustSku")
9546 USE IN SELECT("tmpCstdr_sku")
9547 USE IN SELECT("tcAmbigSku")
9548 *-1040686
9549
9550 Select(lnOldSelect)
9551 Return llRetVal
9552 Endproc
9553
9554
9555 *--------------------------------------------
9556 *--- TechRec 1048667 29-Apr-2011 GSternik ===
9557 *--------------------------------------------
9558 Procedure GetImplodeSQL
9559 *-- Populates cImplodeSQL
9560 SET TextMerge OFF NoShow
9561*--- TechRec 1073664 20-Sep-2013 GSternik --- Added Style and SizeBucket to the output fields for the Range Style implosion compatibility.
9562 Text to this.cImplodeSQL flags 1
9563--* TR-1067132, made it as sql comment -- TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9564declare @Division char(3), @Style varChar(50), @Customer char(7),
9565 @CR_Lbl char(7), @ResolveRule char(1), @Sln_Lbl char(7)
9566
9567set @Customer = ?cCustomer
9568set @Division = ?cDivision
9569set @Style = ?cStyle
9570
9571-- If @ResolveRule in ('Y', 'V') the @CR_Lbl value is used instead of the resolved BLANK label
9572select @CR_Lbl = Lbl_Code, @ResolveRule = Resv_Label
9573 from zzeipocr_expl
9574 where Customer = @Customer
9575 and Division = @Division
9576
9577select @Sln_Lbl = Max(Lbl_code) from #ImplodeSLN
9578
9579--select @ResolveRule as ResRule, @CR_Lbl as Ctrl_Lbl, @Sln_Lbl as SLN_Label
9580
9581-- Output Values:
9582--* TR-1067132, made it as sql comment TR 1065971 02/04/13 JIJO - Increased style/color_code field width to 50 (Automated)
9583declare @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10)
9584
9585-- first SQL:
9586if @CR_Lbl > ''
9587select top 1 @Color_Code = c.Color_Code
9588 , @Lbl_Code = case when @ResolveRule = 'Y' then @CR_Lbl else c.Lbl_Code end
9589 , @Dimension = c.Dimension
9590 , @Size = Min(z.Size01)
9591-- , c.Lbl_Code as SColR_Lbl
9592 from zzxSColR c
9593 join zzxStylR st
9594 on st.PKey = c.FKey
9595 join zzxPPakH ph
9596 on ph.Division = c.Division
9597 and ph.Size_Code = st.Size_Code
9598 and ph.Ppk_Code = c.Dimension
9599 and c.Color_Code = case
9600 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color <> '' then ph.Ppk_Color
9601 else c.Color_Code end
9602 join zzxPPakD pd
9603 on pd.FKey = ph.PKey
9604 join zzxSizer z
9605 on z.Division = c.Division
9606 and z.Size_Code = st.Size_Code
9607 cross join zzxBuckt b
9608 left join #ImplodeSLN i
9609 on i.Color_Code = case
9610 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9611 else pd.Color_Code end
9612 and (i.Lbl_Code = case
9613 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9614 else pd.Lbl_Code end or pd.Lbl_Code = @SLN_Lbl)
9615 and i.Dimension = pd.Dimension
9616 and i.SizeBucket = b.Size_Num
9617 where c.Style = @Style
9618 and c.Division = @Division
9619 and c.PPack_OK = 'Y'
9620 and c.Active_OK = 'Y'
9621 and ph.Active_OK = 'Y'
9622 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9623 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9624 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9625 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9626 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9627 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9628 and (c.Lbl_Code = case
9629 when @SLN_Lbl > ''
9630 then @SLN_Lbl
9631 else @CR_Lbl end or (@SLN_Lbl = '' and c.Lbl_Code = ''))
9632 group by c.PKey, ph.Pack_qty
9633 , c.Color_code, c.Lbl_Code, c.Dimension
9634having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9635 and sum(i.Qty) = ph.Pack_qty
9636 order by case when @SLN_Lbl > '' and Max(pd.Lbl_Code) = @SLN_Lbl then 0 else 1 end,
9637 case when @CR_Lbl = c.Lbl_Code then 0 else 1 end
9638
9639IF @CR_Lbl > '' and @@ROWCOUNT > 0
9640 select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9641ELSE BEGIN
9642
9643select top 1 @Color_Code = c.Color_Code
9644 , @Lbl_Code = c.Lbl_Code
9645 , @Dimension = c.Dimension
9646 , @Size = Min(z.Size01)
9647 from zzxSColR c
9648 join zzxStylR st
9649 on st.PKey = c.FKey
9650 join zzxPPakH ph
9651 on ph.Division = c.Division
9652 and ph.Size_Code = st.Size_Code
9653 and ph.Ppk_Code = c.Dimension
9654 and c.Color_Code = case
9655 when ph.MulClLb_Ok = 'Y' and ph.Ppk_Color > '' then ph.Ppk_Color
9656 else c.Color_Code end
9657 join zzxPPakD pd
9658 on pd.FKey = ph.PKey
9659 join zzxSizer z
9660 on z.Division = c.Division
9661 and z.Size_Code = st.Size_Code
9662 cross join zzxBuckt b
9663 left join #ImplodeSLN i
9664 on i.Color_Code = case
9665 when pd.Color_Code = 'ALL' or pd.Color_Code = '' then c.Color_Code
9666 else pd.Color_Code end
9667 and (i.Lbl_Code = case
9668 when ph.MulClLb_Ok < 'Y' or pd.Lbl_Code = 'ALL' then i.Lbl_Code
9669 else pd.Lbl_Code end or pd.Lbl_Code = @CR_Lbl)
9670 and i.Dimension = pd.Dimension
9671 and i.SizeBucket = b.Size_Num
9672 where c.Style = @Style
9673 and c.Division = @Division
9674 and c.PPack_OK = 'Y'
9675 and c.Active_OK = 'Y'
9676 and ph.Active_OK = 'Y'
9677 and Sz01*Pack01_Qty+Sz02*Pack02_Qty+Sz03*Pack03_Qty+Sz04*Pack04_Qty+
9678 Sz05*Pack05_Qty+Sz06*Pack06_Qty+Sz07*Pack07_Qty+Sz08*Pack08_Qty+
9679 Sz09*Pack09_Qty+Sz10*Pack10_Qty+Sz11*Pack11_Qty+Sz12*Pack12_Qty+
9680 Sz13*Pack13_Qty+Sz14*Pack14_Qty+Sz15*Pack15_Qty+Sz16*Pack16_Qty+
9681 Sz17*Pack17_Qty+Sz18*Pack18_Qty+Sz19*Pack19_Qty+Sz20*Pack20_Qty+
9682 Sz21*Pack21_Qty+Sz22*Pack22_Qty+Sz23*Pack23_Qty+ Sz24*Pack24_Qty = i.Qty
9683 and ((@ResolveRule = 'Y' and c.Lbl_Code in (@CR_Lbl, ' '))
9684 or (@ResolveRule = 'V' and c.Lbl_Code = @CR_Lbl)
9685 or (@ResolveRule < 'V') or c.Lbl_Code = '')
9686 group by c.PKey, ph.Pack_qty
9687 , c.Color_code, c.Lbl_Code, c.Dimension
9688having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9689 and sum(i.Qty) = ph.Pack_qty
9690 order by case when Max(pd.Lbl_Code) = Max(i.Lbl_Code) then 0 else 1 end
9691 , case when c.Lbl_Code = Max(i.Lbl_Code) then 0 else 1 end -- If matches the EDI Contol ref Lbl - higher priority.
9692 , c.Lbl_code -- blank one goes first if there is no match
9693
9694select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, 1 as SizeBucket
9695 where @Color_Code is not null
9696END
9697EndText
9698
9699*--- TechRec 1073664 20-Sep-2013 GSternik ---
9700 Text to this.cImplodeRangeSQL flags 1
9701declare @Division char(3)
9702set @Division = ?cDivision
9703
9704-- Output Values:
9705declare @Style varChar(50), @Color_Code varChar(50), @Lbl_Code char(7), @Dimension char(5), @Size char(10), @SizeBucket int
9706
9707select @Style = rh.Rng_Style
9708 , @Color_Code = rh.Rng_Color
9709 , @Lbl_Code = rh.Rng_Lbl
9710 , @Dimension = rh.Rng_Pack
9711 , @SizeBucket = rng_bk
9712 from zzxRangH rh with (NoLock)
9713 join zzxRangD rd with (NoLock)
9714 on rd.FKey = rh.PKey
9715 --join zzxSColR c
9716 -- on c.Division = rh.Division
9717 -- and c.Style = rh.Rng_Style
9718 -- and c.Color_Code = rh.Rng_Color
9719 -- and c.Lbl_Code = rh.Rng_Lbl
9720 -- and c.Dimension = rh.Rng_Pack
9721 join zzxBuckt b with (NoLock)
9722 on rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9723 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9724 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9725 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9726 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9727 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24>0
9728 left join #ImplodeSLN i
9729 on i.Style = rd.Style
9730 and i.Color_Code = rd.Color_Code
9731 and i.Lbl_Code = rd.Lbl_Code
9732 and i.Dimension = rd.Dimension
9733 and i.SizeBucket = b.Size_Num
9734 and i.Division = rd.Division
9735 and i.Qty = rd.Size01_Qty*b.Sz01+rd.Size02_Qty*b.Sz02+rd.Size03_Qty*b.Sz03+rd.Size04_Qty*b.Sz04+
9736 rd.Size05_Qty*b.Sz05+rd.Size06_Qty*b.Sz06+rd.Size07_Qty*b.Sz07+rd.Size08_Qty*b.Sz08+
9737 rd.Size09_Qty*b.Sz09+rd.Size10_Qty*b.Sz10+rd.Size11_Qty*b.Sz11+rd.Size12_Qty*b.Sz12+
9738 rd.Size13_Qty*b.Sz13+rd.Size14_Qty*b.Sz14+rd.Size15_Qty*b.Sz15+rd.Size16_Qty*b.Sz16+
9739 rd.Size17_Qty*b.Sz17+rd.Size18_Qty*b.Sz18+rd.Size19_Qty*b.Sz19+rd.Size20_Qty*b.Sz20+
9740 rd.Size21_Qty*b.Sz21+rd.Size22_Qty*b.Sz22+rd.Size23_Qty*b.Sz23+rd.Size24_Qty*b.Sz24
9741 where rh.Rng_Type = 'P'
9742 and rh.Division = @Division
9743-- and c.Active_OK = 'Y'
9744 group by rh.Rng_Style
9745 , rh.Rng_Color
9746 , rh.Rng_Lbl
9747 , rh.Rng_Pack
9748 , rng_bk
9749having sum(i.Qty) = (select Sum(Qty) from #ImplodeSLN) -- exclude PPks with no SKUs/Buckets or extra SKUs/Buckets
9750 and sum(i.Qty) = Max(rh.Rng_Qty)
9751
9752if @Style is not null -- @@RowCount > 0
9753select @Size = case @SizeBucket
9754 when 01 then z.Size01 when 02 then z.Size02 when 03 then z.Size03 when 04 then z.Size04
9755 when 05 then z.Size05 when 06 then z.Size06 when 07 then z.Size07 when 08 then z.Size08
9756 when 09 then z.Size09 when 10 then z.Size10 when 11 then z.Size11 when 12 then z.Size12
9757 when 13 then z.Size13 when 14 then z.Size14 when 15 then z.Size15 when 16 then z.Size16
9758 when 17 then z.Size17 when 18 then z.Size18 when 19 then z.Size19 when 20 then z.Size20
9759 when 21 then z.Size21 when 22 then z.Size22 when 23 then z.Size23 else z.Size24 end
9760 from zzxStylR s with (NoLock)
9761 join zzxSizeR z with (NoLock)
9762 on z.Division = s.Division
9763 and z.Size_Code = s.Size_Code
9764 where s.Division = @Division
9765 and s.Style = @Style
9766
9767select @Style as Style, @Color_Code as Color_Code, @Lbl_Code as Lbl_Code, @Dimension as Dimension, @Size as Size01, @SizeBucket as SizeBucket
9768 where @Style is not null
9769EndText
9770*=== TechRec 1073664 20-Sep-2013 GSternik ===
9771
9772 EndProc
9773
9774 *---------------------------------
9775 *--- This function will generate PPK SKU and updates detail with it.
9776 *--- This is splitted 2nd part from function ResolveStyleFromSLN
9777 *--- TechRec 1048667 29-Apr-2011 GSternik --- Re-Designed the Resolution SQL. See above.
9778 *---------------------------------
9779 Procedure ResolvePPKSkuAndUpdateDetail
9780 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, tmpCurs
9781 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9782 Local llRetVal, lnOldSelect, lcSql, i, lnPackTotal,;
9783 lcColor_Code, lcLbl_Code, lcDimension, loEiPOTS,;
9784 lcOldCust, lcOldUPC, lcOldSKU, lnFKey, llDeleteSLN, lcOldOrder, llImplodeOK, llProcess, lcOldAssortment
9785 Private cCustomer, cDivision, cStyle && these used as SQL parameters, so they must be Private
9786
9787 llRetVal = .T.
9788 lnOldSelect = Select()
9789
9790 *--- TR 1051927 24-Mar-11 SK Declaring array with dimention
9791 Dimension laBuckets(goEnv.MaxBuckets)
9792
9793 *-- Remove SLN Records which should not be used for Detail Prepack resolution:
9794 Select tmpCurs
9795 lnFKey = 0
9796
9797 Dimension laBuckets(goEnv.MaxBuckets) && TR 1037976 JAN-22-2008
9798
9799 *-- Remove SLNs where exists error for the same FKey, or Resolve PPK from SLN not required:
9800 Scan
9801 If FKey # lnFKey
9802 lnFKey = FKey
9803
9804 If SLN_Error or !Unresolved
9805 llDeleteSLN = .T.
9806 Else
9807 llDeleteSLN = !Seek(Division+Customer, pceipoCR, "DivCust")
9808
9809 If !llDeleteSLN
9810 Select (pceipoCR)
9811 *llDeleteSLN = (Type("StyleFromSLN")= 'C' and StyleFromSLN < "Y") && Debugging Trick!!!!
9812
9813 *--- TR 1036614 10-Jun-2009 Goutam
9814 *llDeleteSLN = StyleFromSLN < "Y"
9815 llDeleteSLN = StyleFromSLN < "O"
9816 *=== TR 1036614 10-Jun-2009 Goutam
9817
9818 Select tmpCurs
9819 EndIf
9820 EndIf
9821
9822 If !llDeleteSLN
9823 lnRecNo = RecNo()
9824
9825 Scan while FKey = lnFKey
9826 If SLN_Error
9827 *-- One SLN with error exists.
9828 llDeleteSLN = .T.
9829 Exit
9830 EndIf
9831 EndScan
9832
9833 Go lnRecNo
9834 EndIf
9835 EndIf
9836
9837 If llDeleteSLN
9838 Delete
9839 EndIf
9840 EndScan
9841
9842
9843 *-- #3 -- Updating Details with PPK BC SKU:
9844 lcOldCust = ""
9845 lcOldSKU = ""
9846 lnFKey = 0
9847 lnRecNo = This.CountTotalRecs('tmpCurs')
9848
9849 If lnRecNo > 0
9850 *-- Need for optimization:
9851
9852 If This.lUserInterface
9853 This.UpdateThermoCaption("Resolving Style From SLN...")
9854 This.InitThermo(lnRecNo + 1)
9855 lnRecNo = 1
9856 Endif
9857 v_SQLExec("IF OBJECT_ID('tempdb..#ImplodeSLN') IS NOT NULL drop table #ImplodeSLN")
9858
9859 *- 1041704 07/30/09 YIK
9860 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9861 *-- Let's rely on the field types in the UPC table:
9862 *v_SQLExec("create table #ImplodeSLN " + ;
9863 * "( 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)
9864 * " Size_Desc Char(10), Qty Int, PKey Int)")
9865 v_SQLExec("select Division, Style, Color_Code, Lbl_Code, Dimension, SizeBucket, Size_Desc, cast(0 as int) as Qty, PKey"+;
9866 " into #ImplodeSLN from zzeupcnr where PKey = -9999998 and 1=2")
9867 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9868
9869 Select (pceipoTD)
9870 lcOldOrder = Order()
9871
9872 *- 03/23/09 YIK
9873 *- Index on Customer+SKU tag CustSKU && Index set to Customer+SKU
9874 *--- TechRec 1067132 18-Feb-2013 jjanand === Added +Assortment
9875 Index on Customer+SKU+UPC+Assortment tag CustSKU
9876 lcOldUPC = ''
9877 *==
9878
9879 If This.lUserInterface
9880 This.AdvanceThermo(lnRecNo)
9881 EndIf
9882
9883 Select tmpCurs
9884 Locate
9885 cCustomer = Customer
9886
9887 Do while .T. && Scan replacement
9888 if FKey # lnFKey && Will trigger @ EOF :o)
9889 If llProcess
9890 If llImplodeOK
9891 v_SQLExec(this.cImplodeSQL, "qPPK") && MAIN SQL
9892
9893 *--- TechRec 1073664 20-Sep-2013 GSternik ---
9894 *-- Let's check if they belong to the Range Style 'P'
9895 If Reccount("qPPK") = 0 && Prepack not found
9896 v_SQLExec(this.cImplodeRangeSQL, "qPPK")
9897 EndIf
9898 *=== TechRec 1073664 20-Sep-2013 GSternik ===
9899
9900 v_SQLExec("TRUNCATE TABLE #ImplodeSLN")
9901 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9902 Select (pceipoTS)
9903 *- insert into #implodeSLN
9904 *--- TechRec 1073664 20-Sep-2013 GSternik --- added Div/Style
9905 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9906 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9907 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9908 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9909 ", " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
9910 Endif
9911 EndIf && llImplodeOK
9912 *========= 1041704 07/30/09 YIK
9913
9914 select (pceipoTD)
9915 =Seek(lnFKey, pceipoTD, "PKey") && lnFKey contains the Previous Dtl PKey
9916 lcOldAssortment = Assortment &&--- TR 1067132 18-Feb-2013 jjanand === Added lcOldAssortment
9917 lcOldCust = Customer
9918 lcOldSKU = SKU
9919
9920 *- 03/23/09 YIK
9921 *-- Update all records with the same CustSKU
9922 *- =Seek(lcOldCust+lcOldSKU) && First matching record
9923 lcOldUPC = UPC
9924 =Seek(lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment) &&--- TR 1067132 18-Feb-13 jjanand === Added lcOldAssortment
9925
9926 *==
9927 If llImplodeOK and RecCount("qPPK") > 0 && the query can return more than 1 record, but only the first one is correct.
9928 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9929 *--- TechRec 1073664 20-Sep-2013 GSternik --- used Style, SizeBucket, SizeDesc from qPPK
9930 replace Division with cDivision, ;
9931 Style with qPPK.Style, ;
9932 Color_Code with qPPK.Color_Code, ;
9933 Lbl_Code with qPPK.Lbl_Code, ;
9934 Dimension with qPPK.Dimension,;
9935 SizeBucket with qPPK.SizeBucket;
9936 Size_Desc with qPPk.Size01;
9937 Style_SLN_OK with 'Y' ;
9938 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9939 Else
9940
9941 *--- TR 1056329 02-Nov-11 SK Passing field name ("StyleFromSLN") as string
9942 *--- TR 1036614 12-Jun-2009 Goutam
9943 IF Seek(Division+Customer, pceipoCR, "DivCust") AND (SysGetFieldValue(pceipoCR, "StyleFromSLN") <> "O")
9944 *=== TR 1036614 12-Jun-2009 Goutam
9945 *--- TR 1056329 02-Nov-11 SK
9946 *--- TechRec 1067132 18-Feb-2013 jjanand === Added lcOldAssortment to where clause
9947 replace Style_SLN_OK with 'N' ;
9948 while Customer + SKU + UPC + Assortment = lcOldCust+lcOldSKU+lcOldUPC+lcOldAssortment
9949 *--- TR 1036614 12-Jun-2009 Goutam
9950 ENDIF
9951 *=== TR 1036614 12-Jun-2009 Goutam
9952
9953 ENDIF
9954 Else && llProcess flag is not set
9955 If Seek(tmpCurs.PKey, pceipoTS, "PKey")
9956 Select (pceipoTS)
9957 *- insert into #implodeSLN
9958 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
9959 v_SQLExec("insert into #ImplodeSLN values ('" + Division + "', " +;
9960 SqlFormatChar(Style) + ", " + SqlFormatChar(Color_Code) + ", " +;
9961 SqlFormatChar(Lbl_Code) + ", " + SqlFormatChar(Dimension) + ", " +;
9962 Transform(SizeBucket, '99') + ", " + SqlFormatChar(Size_Desc) + ;
9963 ", " + Str(SLN_Qty) + ", " + Str(tmpCurs.PKey) + ")")
9964 *=== 1041704
9965 EndIf
9966 EndIf && Process Detail
9967
9968 Select tmpCurs
9969 if Eof()
9970 Exit
9971 EndIf
9972
9973 lnFKey = FKey
9974 cCustomer = Customer
9975 Select (pceipoTD)
9976 =Seek(lnFKey, pceipoTD, "PKey")
9977
9978 llProcess = (Style_SLN_OK = ' ') && Detail Was Not Updated yet.
9979
9980 llImplodeOK = llProcess
9981
9982 If llImplodeOK
9983 store 0 to laBuckets
9984 lnPackTotal = 0
9985
9986 *-- Get BC SKU from SLN cursor (not from tmpCurs, because it does not have this data)
9987 Select (pceipoTS)
9988 =Seek(tmpCurs.PKey, pceipoTS, "PKey")
9989
9990 cDivision = Division
9991 cStyle = Style
9992 lcColor_Code = Color_Code
9993 lcLbl_Code = Lbl_Code
9994 lcDimension = Dimension
9995 EndIf
9996
9997 Else && The same FKey
9998 If llImplodeOK and Seek(tmpCurs.PKey, pceipoTS, "PKey")
9999 Select (pceipoTS)
10000 if Division # cDivision;
10001 or Style # cStyle
10002 *- 1041704 YIK 07/29/09
10003 *- Allow multicolor prepacks
10004 *-- or Color_Code # lcColor_Code;
10005 *-- or Lbl_Code # lcLbl_Code;
10006 *-- or Dimension # lcDimension
10007
10008 llImplodeOK = .F.
10009 ELSE
10010 *- insert into #implodeSLN
10011 *--- TechRec 1073664 20-Sep-2013 GSternik --- Added Div/Style
10012 v_SQLExec("insert into #ImplodeSLN values ('"+;
10013 Division + "', '" + Style + "', '" + Color_Code + "', '" + Lbl_Code + "', '" + Dimension + "', " +;
10014 TRANSFORM(SizeBucket, '99') + ", '" + Size_Desc + ;
10015 "', " + STR(SLN_Qty) + ", " + STR(tmpCurs.PKey) + ")")
10016 *=== 1041704
10017 EndIf
10018 EndIf
10019 EndIf && FKey Changed
10020
10021 if llImplodeOK
10022 *-- (pceipoTS) is selected!
10023 laBuckets[SizeBucket] = Sln_Qty
10024 lnPackTotal = lnPackTotal + Sln_Qty
10025 EndIf
10026
10027 Select tmpCurs
10028 Skip
10029
10030 If This.lUserInterface
10031 lnRecNo = lnRecNo + 1
10032 This.AdvanceThermo(lnRecNo)
10033 Endif
10034 EndDo && Endscan
10035
10036 Select (pceipoTD)
10037 Set Order to (lcOldOrder)
10038 *- 1041704 07/29/09 YIK -- GS: nade this before the call:
10039 *v_SQLExec("DROP table #ImplodeSLN ")
10040 EndIf && Have data to Implode
10041
10042 *--- TR 1036614 11-Jun-2009 Goutam
10043 *Use In tmpCurs
10044 *=== TR 1036614 11-Jun-2009 Goutam
10045
10046 If This.lUserInterface
10047 * Reset Thermometer
10048 This.ResetThermo()
10049 Endif
10050
10051 Select(lnOldSelect)
10052 Return llRetVal
10053 Endproc
10054 *=== TR 1035491 4-Nov-2008 Goutam
10055
10056*--- TechRec 1036195 08-Jan-2009 vkrishnamurthy ---
10057*!*
10058* TR 1037925 - As per Krishna/Shenba
10059* Moved to clsipopr_PostValidation as division gets populated to header in post validations only
10060* This is getting moved in TR 1037925
10061
10062*!* *--- TechRec 1036964 17-Dec-2008 T.Shenbagavalli ---
10063*!* *===========================================================================================
10064*!* Function ResolveCustShipper
10065*!* Lparameters pceipoTH, pceipoCR
10066*!* LOCAL lnSelect, llRetVal
10067
10068*!* lnSelect = SELECT()
10069
10070*!* WITH This
10071*!*
10072*!* SELECT distinct h.customer, h.division, ;
10073*!* h.cust_shipper ;
10074*!* FROM (pceipoTH) h, (pceipoCR) r ;
10075*!* WHERE r.resv_cust_ship = 'Y' and ;
10076*!* h.customer = r.customer and ;
10077*!* h.division = r.division ;
10078*!* INTO CURSOR '_tmpCustShipper'
10079*!*
10080*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10081*!*
10082*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10083*!*
10084*!* IF llRetVal and RECCOUNT('_tmpCustShipper') > 0
10085*!* REPLACE ALL shipper WITH '' In (pceipoTH)
10086*!* SET RELATION TO
10087*!* ENDIF
10088*!*
10089*!* SELECT '_tmpCustShipper'
10090
10091*!* .cSQLTempTable = ""
10092*!*
10093*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10094*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10095*!* IF !EMPTY(.cSQLTempTable)
10096*!*
10097*!* *---- Matching with customer, cust_shipper, division
10098*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10099*!* "s.shipper " + ;
10100*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10101*!* "Where s.customer = t.customer and " + ;
10102*!* "s.division = t.division and " + ;
10103*!* "s.cust_shipper = t.cust_shipper "
10104*!*
10105*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10106*!*
10107*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10108*!* SELECT _custShipper
10109*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10110*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10111*!* IF llRetVal
10112*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10113*!* SET RELATION TO
10114*!* ENDIF
10115*!* ENDIF
10116*!* ENDIF
10117*!* ENDIF
10118*!* ENDIF
10119*!*
10120*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10121*!* FROM (pceipoTH) h, (pceipoCR) r ;
10122*!* WHERE r.resv_cust_ship = 'Y' and ;
10123*!* h.customer = r.customer and ;
10124*!* h.division = r.division and ;
10125*!* EMPTY(h.shipper) ;
10126*!* INTO CURSOR '_tmpCustShipper'
10127*!*
10128*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10129*!*
10130*!* SELECT '_tmpCustShipper'
10131
10132*!* .cSQLTempTable = ""
10133*!*
10134*!* IF .GenerateSQLTempTable('_tmpCustShipper')
10135*!* IF .PopulateSQLTempTable('_tmpCustShipper')
10136*!* IF !EMPTY(.cSQLTempTable)
10137*!*
10138*!* *---- Matching with customer, cust shipper, and division = ''
10139*!* lcSQLString= "Select t.customer, t.division, t.cust_shipper, " + ;
10140*!* "s.shipper " + ;
10141*!* "from zzecshpd s, " + .cSQLTempTable + " t " +;
10142*!* "Where s.customer = t.customer and " + ;
10143*!* "s.division = '' and " + ;
10144*!* "s.cust_shipper = t.cust_shipper "
10145*!*
10146*!* llRetVal = v_SqlExec(lcSQLString, "_custShipper")
10147*!*
10148*!* IF llRetVal and RECCOUNT('_custShipper') > 0
10149*!* SELECT _custShipper
10150*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10151*!* llRetVal= .SetRelation("_custShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10152*!*
10153*!* IF llRetVal
10154*!* Replace All shipper with _custShipper.shipper In (pceipoTH)
10155*!* SET RELATION TO
10156*!* ENDIF
10157*!*
10158*!* ENDIF
10159*!* ENDIF
10160*!* ENDIF
10161*!* ENDIF
10162
10163*!* USE in '_tmpCustShipper'
10164*!*
10165*!* SELECT distinct h.customer, h.division, h.cust_shipper ;
10166*!* FROM (pceipoTH) h, (pceipoCR) r ;
10167*!* WHERE r.resv_cust_ship = 'Y' and ;
10168*!* h.customer = r.customer and ;
10169*!* h.division = r.division and ;
10170*!* EMPTY(h.shipper) ;
10171*!* INTO CURSOR '_tmpCustShipper'
10172*!*
10173*!* INDEX ON customer + division + cust_shipper TAG 'cust_ship'
10174*!*
10175*!* IF RECCOUNT('_tmpCustShipper') > 0
10176*!* llRetVal= .SetRelation("_tmpCustShipper", "cust_ship", pceipoTH, "customer + division + cust_shipper")
10177*!*
10178*!* IF llRetVal
10179*!* Replace ALL Errs_msg_H WITH Errs_msg_H + "Missing or Invalid Shipper." + CRLF, ;
10180*!* Errs_flg_h WITH "Y" ;
10181*!* FOR customer = _tmpCustShipper.customer and ;
10182*!* division = _tmpCustShipper.division and ;
10183*!* cust_shipper = _tmpCustShipper.cust_shipper and EMPTY(Shipper) In (pceipoTH)
10184*!*
10185*!* SET RELATION TO
10186*!* ENDIF
10187*!*
10188*!* ENDIF
10189*!*
10190*!* ENDWITH
10191*!*
10192*!* USE in '_tmpCustShipper'
10193*!* USE in '_custShipper'
10194*!* SELECT(lnSelect)
10195*!*
10196*!* RETURN llRetVal
10197*!* ENDFUNC
10198*!* *===========================================================================================
10199*!* *=== TechRec 1036964 17-Dec-2008 T.Shenbagavalli ===
10200*=== TechRec 1036195 08-Jan-2009 vkrishnamurthy ===
10201
10202*--- TechRec 1036195 29-Dec-2008 vkrishnamurthy ---
10203*============================================================
10204 FUNCTION CalculateSLNs
10205 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10206 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10207 lnTotal_qty
10208
10209 llRetVal = true
10210 lnSelect = SELECT()
10211
10212 lcCursor = GetUniqueFileName()
10213 WITH This
10214
10215 *--- TR 1047450 28-May-2010 Partha ---
10216 * removed c.Template = 'GAP'
10217 * from where clause of following qry
10218
10219*!* lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10220*!* " FROM (pceipoTD) d " + ;
10221*!* " JOIN (pceipoTH) H " + ;
10222*!* " ON H.pkey = d.fkey " + ;
10223*!* " JOIN (pceipoCR) C " + ;
10224*!* " ON D.division = C.Division " + ;
10225*!* " AND H.Customer = C.Customer " + ;
10226*!* " WHERE c.Template = 'GAP' AND NOT (d.Gap_ok = 'Y') "
10227
10228 lcSQLString = " SELECT d.pkey, d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
10229 " FROM (pceipoTD) d " + ;
10230 " JOIN (pceipoTH) H " + ;
10231 " ON H.pkey = d.fkey " + ;
10232 " JOIN (pceipoCR) C " + ;
10233 " ON D.division = C.Division " + ;
10234 " AND H.Customer = C.Customer " + ;
10235 " WHERE NOT (d.Gap_ok = 'Y') "
10236 *=== TR 1047450 28-May-2010 Partha ===
10237
10238 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor,,.T.)
10239
10240 IF USED(lcCursor) AND RECCOUNT(lcCursor) > 0
10241 llRetVal = .GenerateSQLTempTable(lcCursor) AND .PopulateSQLTempTable(lcCursor)
10242 lcDeatil = .cSQLTempTable
10243
10244 lcSQLString = " Select ISNULL(ph.pack_qty, 0) AS pack_qty , t.* " + ;
10245 " FROM " + lcDeatil + " t " + ;
10246 " JOIN zzxscolr s " + ;
10247 " ON s.division= t.division and " +;
10248 " s.style= t.style and s.color_code= t.color_code and " +;
10249 " s.lbl_code = t.lbl_code and s.dimension = t.dimension " + ;
10250 " INNER JOIN zzxstylr st on st.pkey = s.fkey " + ;
10251 " LEFT OUTER JOIN zzxppakh ph " + ;
10252 " ON s.division= ph.division and st.size_code= ph.size_code and "+;
10253 " s.dimension= ph.ppk_code " + ;
10254 " Where s.ppack_ok= 'Y' "
10255
10256 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,lcCursor ) AND USED(lcCursor)
10257
10258 IF llRetVal
10259 *--- TR 1038394 YIK 01/29/09
10260 *- Select(lcCursor)
10261 *--INDEX on Pkey TAG Pkey
10262 *--.SetRelation(lcCursor, "pkey", pceipoTD, "pkey")
10263 .SetRelation(pceipoTD, "pkey", lcCursor, "pkey")
10264
10265 lnPrePack = 0
10266 SELECT(lcCursor)
10267 SCAN
10268 lnPkey = Pkey
10269 lnpack_qty = pack_qty
10270
10271 lnTotal_qty = &pceipoTD..Total_qty
10272
10273 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty) > 0
10274 lcErrs_Msg = " Can not Calculate number of prepacks. "
10275
10276 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + "Total SLN qunatity -" + STR(lnTotal_qty) + ;
10277 " , Prepack Quantity -" + STR(lnpack_qty)+ CRLF, ;
10278 Errs_Flg_D With "Y" ;
10279 IN (pceipoTD)
10280 LOOP
10281 ELSE
10282 IF (&pceipoTD..ppk_action = 'X') OR (&pceipoTD..ppk_action = 'M')
10283 IF lnpack_qty >0
10284 lnTotal_qty = lnTotal_qty /lnpack_qty
10285 ENDIF
10286 ENDIF
10287 Endif
10288
10289 IF lnpack_qty > 0 AND MOD(lnTotal_qty,lnpack_qty)= 0
10290 lnPrePack = (lnTotal_qty/lnpack_qty)
10291 SELECT(pceipoTS)
10292 count FOR MOD(sln_qty,lnPrePack) >0 AND Fkey = lnPkey TO lnSlnqty
10293
10294 IF lnSlnqty >0
10295 lcErrs_Msg = " Can not Calculate SLN Quantity per prepack. "
10296 SELECT(pceipoTS)
10297 SCAN FOR Fkey = lnPkey
10298 IF MOD(sln_qty,lnPrePack) >0
10299 Replace Errs_Msg_S With Errs_Msg_S + lcErrs_Msg + " SLN qunatity -" + STR(SLN_Qty) + ;
10300 " , Prepack Quantity -" + STR(lnPrePack)+ CRLF, ;
10301 Errs_Flg_S With "Y"
10302 ENDIF
10303 ENDSCAN
10304 LOOP
10305 ELSE
10306 Replace SLN_qty WITH (sln_qty/lnPrePack) IN (pceipoTS) FOR Fkey = lnPkey AND SLN_qty >0
10307*!* Replace Total_qty WITH (Total_qty/lnpack_qty),Gap_Ok WITH 'Y' IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10308 Replace Gap_Ok WITH 'Y' , Total_qty WITH lnTotal_qty IN (pceipoTD) FOR pkey = lnPkey AND Total_qty >0
10309 ENDIF
10310
10311 ENDIF
10312 ENDSCAN
10313
10314 ENDIF
10315 ENDIF
10316 .TableClose(lcCursor)
10317 ENDWITH
10318
10319 SELECT (lnSelect)
10320 RETURN llRetVal
10321 ENDFUNC
10322*============================================================
10323
10324*=== TechRec 1036195 29-Dec-2008 vkrishnamurthy ===
10325
10326
10327*--- TR 1036917 04-Feb-2009 Partha ---
10328
10329*============================================================
10330 FUNCTION ChangeColor
10331 LPARAMETERS pceipoTH,pceipoTD, pceipoTS ,pceipoCR
10332 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
10333 lnTotal_qty
10334
10335 llRetVal = true
10336 lnSelect = SELECT()
10337
10338 WITH This
10339 *--- TR 1039262 NSD - Use current system date, not PO date.
10340 *--- TR 1044885 13-JAN-2010 BR Added d.cust_lbl as part of the select
10341 If This.oHostProcess.lHaveSLN
10342 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.
10343 " 'D' AS Source " + ;
10344 " FROM (pceipoTD) d " + ;
10345 " JOIN (pceipoTH) H " + ;
10346 " ON H.pkey = d.fkey " + ;
10347 " WHERE d.Errs_flg_d <> 'Y' " + ;
10348 " AND d.org_color = ' ' " +;
10349 " UNION ALL " + ;
10350 " SELECT s.pkey,DATE() as po_date,s.division,s.style,s.color_code,s.lbl_code,s.dimension,d.cust_lbl, " + ;
10351 " 'S' AS Source " + ;
10352 " FROM (pceipoTD) d " + ;
10353 " JOIN (pceipoTH) H " + ;
10354 " ON H.pkey = d.fkey " + ;
10355 " JOIN (pceipoTS) S " + ;
10356 " ON D.pkey = s.fkey " + ;
10357 " WHERE s.Errs_flg_s <> 'Y' " + ;
10358 " AND s.org_color = ' ' "
10359 ELSE
10360 lcSQLString = " SELECT d.pkey,DATE() as po_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension,d.cust_lbl, " + ;
10361 " 'D' AS Source " + ;
10362 " FROM (pceipoTD) d " + ;
10363 " JOIN (pceipoTH) H " + ;
10364 " ON H.pkey = d.fkey " + ;
10365 " WHERE d.Errs_flg_d <> 'Y' " + ;
10366 " AND d.org_color = ' ' "
10367 ENDIF
10368
10369 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
10370
10371 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
10372 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
10373 lcDeatil = .cSQLTempTable
10374 *--- 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)
10375 *--- TR 1044885 13-JAN-2010 BR -CHANGING h.lbl_code = t.lbl_code to h.lbl_code = t.cust_lbl
10376 lcSQLString = " Select t.*, d.new_color, t.color_code AS tempcolr " + ;
10377 " FROM " + lcDeatil + " t " + ;
10378 " JOIN zzxrupch h " + ;
10379 " ON h.division= t.division " + ;
10380 " and h.style= t.style " + ;
10381 " and h.color_code= t.color_code " + ;
10382 " and h.lbl_code = (CASE WHEN t.cust_lbl <> '' THEN t.cust_lbl ELSE t.lbl_code END) " + ;
10383 " and h.dimension = t.dimension " + ;
10384 " JOIN zzxrupcd d on h.pkey = d.fkey " + ;
10385 " WHERE h.active_ok = 'Y' " + ;
10386 " AND d.active_color = 'Y' " + ;
10387 " AND d.effect_Date = " + ;
10388 " (SELECT TOP 1 effect_date FROM zzxrupcd d1 " + ;
10389 " WHERE d1.fkey = d.fkey AND d1.active_color = 'Y' and d1.effect_date <= t.po_Date" + ;
10390 " ORDER BY d1.effect_date DESC ) "
10391
10392 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
10393
10394 IF llRetVal
10395 Select("__RollingUpc")
10396 INDEX on Pkey TAG Pkey
10397 .SetRelation("__RollingUpc", "pkey", pceipoTD, "pkey")
10398
10399 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10400 org_Color WITH __RollingUpc.TempColr ;
10401 FOR NOT EOF("__RollingUpc") ;
10402 AND __RollingUpc.Source = "D" IN (pceipoTD)
10403
10404 Set Relation To
10405
10406 If This.oHostProcess.lHaveSLN
10407 .SetRelation("__RollingUpc", "pkey", pceipoTS, "pkey")
10408 REPLACE ALL color_Code WITH __RollingUpc.New_Color, ;
10409 org_Color WITH __RollingUpc.TempColr ;
10410 FOR NOT EOF("__RollingUpc") ;
10411 AND __RollingUpc.Source = "S" IN (pceipoTS)
10412 Set Relation To
10413 ENDIF
10414
10415 ENDIF
10416
10417 .TableClose("__RollingUpc")
10418
10419 ENDIF
10420 ENDWITH
10421
10422 SELECT (lnSelect)
10423 RETURN true
10424 ENDFUNC
10425*============================================================
10426
10427*=== TR 1036917 04-Feb-2009 Partha ===
10428
10429**************************************************************************************
10430
10431 * --- TR 1034963 12/15/08 CM
10432 * This procedure will write back to sysnotes exploded components of Range Styles
10433
10434 Procedure UpdateSysNotes
10435
10436 Local laTables[1]
10437 laTables[1] = "Vzzeipotd_notes_iPOproc"
10438
10439 Local llRetVal, llBeganTransaction
10440
10441 llRetVal = .T.
10442
10443 If This.BeginTransaction()
10444 llRetVal = This.Tableupdate(@laTables)
10445 If llRetVal
10446 This.EndTransaction()
10447 Else
10448 This.RollbackTransaction()
10449 Endif
10450 Endif
10451
10452 llRetVal = llRetVal And This.TableClose(@laTables, .T.)
10453
10454 Endproc
10455 * --- TR 1034963 12/15/08 CM
10456
10457**************************************************************************************
10458
10459 *--------------------------------------------------
10460 *--- TR 1041542 NSD 7/22/09
10461 * Register Number can be assigned by a sort now.
10462 PROCEDURE ResolveRegisterNumber
10463 LPARAMETERS pceipoTH
10464
10465 LOCAL llRetVal,lnSelect,lcAllSortFields,lcColList,lcAllTmp,lcCustTmp,lcSQL,lcGrouping,laGroupFields[1],lcGroupFieldsFilter,lnRegNum
10466 llRetVal = .T.
10467 lnSelect = SELECT()
10468
10469 WITH THIS
10470
10471 * Retrieve all possible sort columns from table. Push only these columns plus customer and pkey to server.
10472 llRetVal = llRetVal AND v_sqlexec("SELECT objid FROM zzxsfxrf where objname = 'EDIREGNUM' AND shelltype = 'S'","tcAllCols")
10473 lcColList = "pkey,customer,reg_num"
10474 SELECT tcAllCols
10475 SCAN
10476 lcColList = lcColList + "," + ALLTRIM(tcAllCols.objid)
10477 ENDSCAN
10478
10479 * Retrieve just the columns we need
10480 lcSQL = "SELECT " + lcColList + " FROM " + pcEipoth + " WHERE customer > '' AND reg_num = 0 INTO CURSOR tcRegNum_All "
10481 &lcSQL
10482
10483 IF llRetVal AND RECCOUNT("tcRegNum_All") > 0
10484 * Push records to server to work with.
10485 llRetVal = llRetVal AND .GenerateSQLTempTable("tcRegNum_All")
10486 llRetVal = llRetVal AND .PopulateSQLTempTable("tcRegNum_All")
10487 lcAllTmp = .cSQLTempTable
10488
10489 * Find distinct customer
10490 SELECT DISTINCT customer FROM tcRegNum_All INTO CURSOR tcRegNum_cust
10491 SELECT tcRegNum_cust
10492 SCAN
10493 * Process 1 customer
10494
10495 * Get the grouping
10496 lcCustTmp = "#" + GetUniqueFileName()
10497 lcSQL = "SELECT top 1 * FROM zzxparmr WHERe parm_code = 'EDIREGNUM' " + ;
10498 " AND (customer = '' OR customer = " + SQLFormatChar(tcRegNum_cust.customer) + ") ORDER BY customer desc "
10499 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcRegNum_Sort")
10500 IF llRetVal
10501 IF RECCOUNT("tcRegNum_Sort") = 0 OR EMPTY(tcRegNum_Sort.parm_value)
10502 lcGrouping = "CUSTOMER,PO_NUM"
10503 ELSE
10504 lcGrouping = "CUSTOMER," + ALLTRIM(tcRegNum_Sort.parm_value)
10505 ENDIF
10506
10507 * Need to have a SQL Filter for the groupings
10508 STRINGTOARRAY(lcGrouping,@laGroupFields)
10509 lcGroupFieldsFilter = ""
10510 FOR x = 1 TO ALEN(laGroupFields,1)
10511 lcGroupFieldsFilter = lcGroupFieldsFilter + " h." + laGroupFields[x] + " = x." + laGroupFields[x] + " AND"
10512 ENDFOR
10513 lcGroupFieldsFilter = LEFT(lcGroupFieldsFilter,LEN(lcGroupFieldsFilter)-3)
10514
10515 * Create temp table of unique reg nums
10516 lcSQL = "SELECT " + lcGrouping + ",0 as reg_num,IDENTITY(int) as pkey_i INTO " + ;
10517 lcCustTmp + " FROM " + lcAllTmp + " WHERE customer = " + SQLFOrmatChar(tcRegNum_cust.customer) + ;
10518 " GROUP BY " + lcGrouping
10519 llRetVal = llRetVal AND v_sqlexec(lcSQL)
10520
10521 * Count distinct records and generate enough reg_nums
10522 llRetVal = llRetVal AND v_sqlexec("SELECT COUNT(*) as cnt FROM " + lcCustTmp,"tcRegNum_cnt")
10523 lnRegNum = v_NextID('ZZXCOMPR', "REG_NUM", tcRegNum_cnt.cnt) - tcRegNum_cnt.cnt
10524
10525 * Calculate New reg_nums
10526 llRetVal = llRetVal AND v_sqlexec("UPDATE " + lcCustTmp + " SET reg_num = pkey_i + " + SQLFormatNum(lnRegNum))
10527
10528 * Write back to table
10529 llRetVal = llRetVal AND v_sqlexec(;
10530 "UPDATE h SET reg_num = x.reg_num FROM " + lcAllTmp + " h JOIN " + lcCustTmp + " x ON " + ;
10531 lcGroupFieldsFilter )
10532
10533 ENDIF
10534
10535 USE IN SELECT("tcRegNum_Sort")
10536 USE IN SELECT("tcRegNum_cnt")
10537 v_sqlexecnoerror("DROP TABLE " + lcCustTmp)
10538 ENDSCAN
10539
10540 * Get all records back from Temp table. Loop through and apply to main cursor
10541 llRetVal = llRetVal AND v_sqlexec("SELECT pkey,reg_num FROM " + lcAllTmp,"tcRegNum_res")
10542 IF llRetVal
10543 SELECT tcRegNum_res
10544 SCAN
10545 IF SEEK(tcRegNum_res.pkey,pceipoTH,"pkey")
10546 SELECT (pceipoTH)
10547 REPLACE reg_num WITH tcRegNum_res.reg_num
10548 ENDIF
10549 ENDSCAN
10550
10551 ENDIF
10552
10553 v_sqlexecNoError("DROP TABLE " + lcAllTmp)
10554 ENDIF
10555
10556
10557 USE IN SELECT("tcRegNum_res")
10558 USE IN SELECT("tcAllCols")
10559 USE IN SELECT("tcRegNum_All")
10560 USE IN SELECT("tcRegNum_cust")
10561
10562 ENDWITH
10563
10564 SELECT(lnSelect)
10565 RETURN llRetVal
10566 ENDPROC
10567 *=== TR 1041542 NSD 7/22/09
10568
10569*===============================================================
10570
10571 *--- TR 1036614 8-Jun-2009 Goutam
10572 Procedure CreateSingleSLNCursor
10573 Lparameters pcTmpCursor
10574
10575 Local llRetVal, lnOldSelect, lcSQLString
10576
10577 llRetVal = true
10578 lnOldSelect = Select()
10579
10580 *---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.
10581
10582 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10583
10584 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10585*!* select t.Customer ;
10586*!* , t.FKey ;
10587*!* , t.PKey ;
10588*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10589*!* , c.template ; && TR 1050793
10590*!* , c.slntodtl ; && TR 1050793
10591*!* from (pcTmpCursor) t ;
10592*!* join zzeipocr c ;
10593*!* on c.division = t.division ;
10594*!* and c.customer = t.customer ;
10595*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10596*!* on s.division = t.division ;
10597*!* and s.customer = t.customer ;
10598*!* and s.store = t.store ;
10599*!* where c.slntodtl = 'N' ;
10600*!* and (c.stylefromsln = 'O' ;
10601*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10602*!* into Cursor __tmpipots ;
10603*!* order by t.fkey, t.Customer, t.PKey
10604
10605 select t.Customer ;
10606 , t.FKey ;
10607 , t.PKey ;
10608 , NVL(s.price_flg, c.price_flg) as price_flg ;
10609 , c.template ; && TR 1050793
10610 , c.slntodtl ; && TR 1050793
10611 from (pcTmpCursor) t ;
10612 join zzeipocr c ;
10613 on c.division = t.division ;
10614 and c.customer = t.customer ;
10615 left join (this.oHostProcess.cCustomerStoreTable) s ;
10616 on s.division = t.division ;
10617 and s.customer = t.customer ;
10618 and s.store = t.store ;
10619 where c.slntodtl = 'N' ;
10620 and (c.stylefromsln = 'O' ;
10621 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10622 JOIN zzeipocr c ;
10623 on c.division = t.division ;
10624 and c.customer = t.customer ;
10625 group by t.fkey having (count(t.pkey)=1) and ;
10626 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'N')) ;
10627 into Cursor __tmpipots ;
10628 order by t.fkey, t.Customer, t.PKey
10629 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10630
10631 Select(lnOldSelect)
10632 Return llRetVal
10633 Endproc
10634 *=== TR 1036614 8-Jun-2009 Goutam
10635
10636 *--- TR 1036614 8-Jun-2009 Goutam
10637 *--- This is the splited function from MoveSLNToDTLs
10638 PROCEDURE CreateCursorSLNToDtl
10639 LPARAMETERS pceipoTD, pceipoCR, pcTmpCursor
10640
10641 LOCAL llRetVal, lnOldSelect
10642 lnOldSelect = SELECT()
10643 llRetVal = true
10644
10645 *--- TechRec 1045603 01-Jun-2010 vkrishnamurthy ---
10646*!* select t.Customer ;
10647*!* , t.FKey ;
10648*!* , t.PKey ;
10649*!* , c.price_flg ;
10650*!* from (pcTmpCursor) t ;
10651*!* join zzeipocr c ;
10652*!* on c.division = t.division ;
10653*!* and c.customer = t.customer ;
10654*!* join (pceipoTD) d ;
10655*!* on d.pkey = t.dtlPkey ;
10656*!* where c.slntodtl = 'Y' ;
10657*!* and d.slntodtl <> 'Y' ;
10658*!* AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10659*!* into Cursor __tmpipots ;
10660*!* order by t.fkey, t.Customer, t.PKey
10661
10662 *--- TR 1045922 05-MAR-2010 HNISAR
10663 * Added 'I' to Inlis in below statements
10664*!* where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ;
10665*!* and !INLIST(d.slntodtl,'Y','O','I') ;
10666 *=== TR 1045922 05-MAR-2010 HNISAR
10667
10668 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10669 select t.Customer ;
10670 , t.FKey ;
10671 , t.PKey ;
10672 , NVL(s.price_flg, c.price_flg) as price_flg ;
10673 , c.template ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10674 , c.slntodtl ; &&--- TR 1045922 05-MAR-2010 HNISAR
10675 from (pcTmpCursor) t ;
10676 join zzeipocr c ;
10677 on c.division = t.division ;
10678 and c.customer = t.customer ;
10679 left join (this.oHostProcess.cCustomerStoreTable) s ;
10680 on s.division = t.division ;
10681 and s.customer = t.customer ;
10682 and s.store = t.store ;
10683 join (pceipoTD) d ;
10684 on d.pkey = t.dtlPkey ;
10685 where (INLIST(c.slntodtl,'Y','I') OR c.Template = 'HIBBETTS') ; &&--- TechRec 1045603 10-Mar-2010 vkrishnamurthy ( Added OR c.Template = 'HIBBETTS')===
10686 and !INLIST(d.slntodtl,'Y','O','I') ; &&--- TechRec 1045603 04-Mar-2010 vkrishnamurthy ===
10687 AND d.Style_SLN_OK <> 'N' ; &&--- TR 1038353 NH
10688 and t.sln_error = .F. ; && TechRec 1052378 10-Feb-2011 jjanand ---
10689 into Cursor __tmpipots ;
10690 order by t.fkey, t.Customer, t.PKey
10691 *=== TechRec 1045603 01-Jun-2010 vkrishnamurthy ===
10692
10693 SELECT(lnOldSelect)
10694 RETURN llRetVal
10695
10696 ENDPROC
10697
10698 Procedure ResolveSingleSLNDetail
10699 Lparameters pceipoTH, pceipoTD, pceipoTS, pceipoCR, pcTmpCursor
10700
10701 Local llRetVal, lnOldSelect, lcSQLString, lnFKey, lcDivision, lcStyle, lcColor_Code, lcDimension, lcSize_Desc
10702
10703 llRetVal = true
10704 lnOldSelect = Select()
10705
10706 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10707 * Added SUM(sln_qty) = 1 for template = CHARMING SHOPPES 4030
10708 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10709 *--- TechRec 1073110 21-Aug-2013 vkrishnamurthy ---
10710
10711 *--- TR 1070506 23-Apr-2013 Goutam. Added .oHostProcess.cCustomerStoreTable. Changed price_flg field selection
10712*!* select t.Customer ;
10713*!* , t.FKey ;
10714*!* , t.PKey ;
10715*!* , NVL(s.price_flg, c.price_flg) as price_flg ;
10716*!* , t.ppk_code ;
10717*!* from (pcTmpCursor) t ;
10718*!* join zzeipocr c ;
10719*!* on c.division = t.division ;
10720*!* and c.customer = t.customer ;
10721*!* left join (this.oHostProcess.cCustomerStoreTable) s ;
10722*!* on s.division = t.division ;
10723*!* and s.customer = t.customer ;
10724*!* and s.store = t.store ;
10725*!* where c.slntodtl = 'N' ;
10726*!* AND ((c.stylefromsln in ('Y','O') ;
10727*!* and t.pkey in (select pkey from (pcTmpCursor) group by fkey having (count(pkey)=1) and not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10728*!* into Cursor __tmpipots ;
10729*!* order by t.fkey, t.Customer, t.PKey
10730
10731 select t.Customer ;
10732 , t.FKey ;
10733 , t.PKey ;
10734 , NVL(s.price_flg, c.price_flg) as price_flg ;
10735 , t.ppk_code ;
10736 from (pcTmpCursor) t ;
10737 join zzeipocr c ;
10738 on c.division = t.division ;
10739 and c.customer = t.customer ;
10740 left join (this.oHostProcess.cCustomerStoreTable) s ;
10741 on s.division = t.division ;
10742 and s.customer = t.customer ;
10743 and s.store = t.store ;
10744 where c.slntodtl = 'N' ;
10745 AND ((c.stylefromsln in ('Y','O') ;
10746 and t.pkey in (select t.pkey from (pcTmpCursor) t ;
10747 JOIN zzeipocr c ;
10748 on c.division = t.division ;
10749 and c.customer = t.customer ;
10750 group by t.fkey having (count(t.pkey)=1) and ;
10751 ( c.template <> 'CHARMING SHOPPES 4030' OR SUM(sln_qty) = 1 ) AND not SLN_Error and UnResolved AND IsPPK = 'Y'))) ;
10752 into Cursor __tmpipots ;
10753 order by t.fkey, t.Customer, t.PKey
10754 *=== TechRec 1073110 21-Aug-2013 vkrishnamurthy ===
10755
10756 SELECT __tmpipots
10757 SCAN
10758 lnFKey = Fkey
10759
10760 Select (pceipoTS)
10761 IF SEEK(__tmpipots.PKey, pceipoTS, "PKey")
10762
10763 lcDivision = Division
10764 lcStyle = Style
10765 lcColor_Code = Color_Code
10766 lcLbl_Code = Lbl_Code
10767 lcDimension = __tmpipots.PPK_Code
10768 lcSize_Desc = Size_Desc
10769
10770 select (pceipoTD)
10771 IF SEEK(lnFKey, pceipoTD, "PKey") AND !(Style_SLN_OK = 'Y')
10772
10773 replace Division with lcDivision, ;
10774 Style with lcStyle, ;
10775 Color_Code with lcColor_Code, ;
10776 Lbl_Code with lcLbl_Code, ;
10777 Dimension with lcDimension,;
10778 SizeBucket with 1;
10779 Size_Desc with lcSize_Desc;
10780 Style_SLN_OK with 'Y' ;
10781 IN (pceipoTD)
10782 ENDIF
10783 ENDIF
10784 ENDSCAN
10785
10786 IF USED("__tmpipots")
10787 USE IN __tmpipots
10788 ENDIF
10789
10790 Select(lnOldSelect)
10791 Return llRetVal
10792 Endproc
10793
10794 *=== TR 1036614 8-Jun-2009 Goutam
10795
10796 *- 1044723 05/20/10 YIK
10797 *- Moved this method from postvalidation()
10798 PROCEDURE ResolveNewStoreOrd_type
10799 LPARAMETERS pcEipoTH
10800 LOCAL llRetVal, lnOldSelect
10801 llRetVal = .t.
10802 lnOldSelect = SELECT()
10803 *--- In this new method need to update zzeipoth.Ord_Type with Order Type from Order Type Reference (zzotyper.ord_type)
10804 *--- where NS_Ord_Type = 'Y' and zzxcustr.Use_NS_OrdTp = 'Y' and pceipoth.NewStore = 'Y'.
10805
10806 LOCAL lcSql, lcEipoTh, lcSQLTempTable
10807 lcEipoTh = SYS(2015)
10808 SELECT pkey, customer, ord_type FROM (pcEipoTH) WHERE EMPTY(ord_type) AND NewStore = 'Y' INTO CURSOR (lcEipoTh)
10809
10810 IF RECCOUNT(lcEipoTh) = 0
10811 USE IN (lcEipoTh)
10812 SELECT(lnOldSelect)
10813 RETURN llRetVal
10814 ENDIF
10815
10816 LOCAL lcOrd_typeResult
10817 lcOrd_typeResult = SYS(2015)
10818 WITH this
10819 .cSQLTempTable=""
10820 llRetVal = llRetVal and .GenerateSQLTempTable(lcEipoTh)
10821 llRetVal = llRetVal and .PopulateSQLTempTable(lcEipoTh)
10822 lcSQLTempTable = .cSQLTempTable
10823
10824 lcSql = "select h.pkey, r.ord_type from " + lcSQLTempTable + " h " + ;
10825 " inner join zzxcustr c on c.customer = h.customer and c.ns_ord_type = 'Y' " + ;
10826 " inner join zzotyper r on r.ns_ord_type = 'Y'"
10827 llRetVal = llRetVal and v_sqlexec(lcSql,lcOrd_typeResult)
10828 IF llRetVal
10829 UPDATE h SET ord_type = r.ord_type from (pcEipoTH) h INNER JOIN (lcOrd_typeResult) r on h.pkey = r.pkey
10830 ENDIF
10831 ENDWITH
10832
10833 IF USED(lcEipoTh)
10834 USE IN (lcEipoTh)
10835 ENDIF
10836 IF USED(lcOrd_typeResult)
10837 USE IN (lcOrd_typeResult)
10838 ENDIF
10839
10840 Select(lnOldSelect)
10841 Return llRetVal
10842 Endproc
10843 *=== TR 1035678 NH
10844
10845 *--- TR 1049029 24-Aug-2010 Partha ---
10846 * lnTotSLNQty = .GetTotSLNQty(lnPSFkey, pceipoTS)
10847 FUNCTION GetTotSLNQty
10848 LPARAMETERS tnPSFkey, pceipoTS
10849
10850 LOCAL lnTotSlnQty, lnOldSelect
10851 LOCAL ARRAY laTotSlnQty[1]
10852
10853 lnOldSelect = SELECT()
10854 lnTotSlnQty = 0
10855
10856 SELECT SUM(sln_qty) FROM (pceipoTS) WHERE fkey = tnPSFkey INTO ARRAY laTotSlnQty
10857 lnTotSlnQty = laTotSlnQty[1]
10858
10859 Select(lnOldSelect)
10860 Return lnTotSlnQty
10861 ENDFUNC
10862
10863 *=== TR 1049029 24-Aug-2010 Partha ===
10864
10865 *--- TechRec 1048792 17-Dec-2010 jisingh ---
10866 FUNCTION ClearSkus
10867 LPARAMETERS pcEipoTH, pcEipoTD, pcEipoTS, pcEipoCR
10868 LOCAL llRetVal, lnSelect, lcSqlString
10869
10870 llRetVal = true
10871 lnSelect = SELECT()
10872
10873 *-- Populate new flag from Control in Transaction Maintenance
10874 lcSqlString = " UPDATE h SET " + ;
10875 " ReResvStyle = c.ReResvStyle " + ;
10876 " FROM (pcEipoTH) h " + ;
10877 " JOIN (pcEipoCR) c " + ;
10878 " ON h.division = c.division " + ;
10879 " AND h.customer = c.customer " + ;
10880 " WHERE h.ReResvStyle = '' "
10881
10882 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10883
10884 *-- Make SKUs blank in Transaction Maintenance detail
10885 lcSqlString = " UPDATE d SET " + ;
10886 " Style = '', " + ;
10887 " Color_Code = '', " + ;
10888 " Lbl_Code = '', " + ;
10889 " Dimension = '', " + ;
10890 " SizeBucket = 0, " + ;
10891 " Size_Desc = '' " + ;
10892 " FROM (pcEipoTD) d " + ;
10893 " JOIN (pcEipoTH) h " + ;
10894 " ON h.pkey = d.fkey " + ;
10895 " WHERE h.ReResvStyle = 'Y' " + ;
10896 " AND (d.upc > '' OR d.sku > '') "
10897
10898 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10899
10900 *-- Make SKUs blank in SLN
10901 lcSqlString = " UPDATE s SET " + ;
10902 " Style = '', " + ;
10903 " Color_Code = '', " + ;
10904 " Lbl_Code = '', " + ;
10905 " Dimension = '', " + ;
10906 " SizeBucket = 0, " + ;
10907 " Size_Desc = '' " + ;
10908 " FROM (pcEipoTD) d " + ;
10909 " JOIN (pcEipoTH) h " + ;
10910 " ON h.pkey = d.fkey " + ;
10911 " JOIN (pcEipoTS) s " + ;
10912 " ON s.fkey = d.pkey " + ;
10913 " WHERE h.ReResvStyle = 'Y' " + ;
10914 " AND (s.sln_upc > '' OR s.sln_sku > '') "
10915
10916 llRetVal = llRetVal AND v_SQLExec(lcSqlString,,,true)
10917
10918 SELECT (lnSelect)
10919 RETURN llRetVal
10920 ENDFUNC
10921 *=== TechRec 1048792 17-Dec-2010 jisingh ===
10922
10923 *--- TR 1053820 25-May-2011 Goutam
10924 Function GenerateCustomerSKU_Style_ColorSize
10925 Lparameters pceipoTH,pceipoTD
10926
10927 Local llRetVal, lnSelect ,lcErrs_Msg ,lccustomer ,lcpo_type ,lcDepartment ,lcCursor ,lnCount ,;
10928 lcPrevSkuSize,lcPrevSKU ,lnCount,lnCstDrPkey,lnCstHrPkey
10929
10930 llRetVal = True
10931 lnSelect = Select()
10932 With This
10933
10934 * Select the distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR
10935
10936 .LogEntry("Selecting distinct records which needs to be inserted in to ZZXCSTHR,ZZXCSTDR...")
10937
10938 *** Size_BK needs to be 00 and NOT 0
10939 *--- TR 1057011 7-10-2011 VKK Removed "h.Store As cust_store ,;" from select
10940 Select ;
10941 h.customer,;
10942 d.division,;
10943 d.pkey As dtlpkey ,;
10944 d.Style As Style, ;
10945 d.color_code,;
10946 d.lbl_code,;
10947 d.Dimension,;
10948 h.Store As cust_store ,;
10949 d.price As cust_price , ;
10950 d.size_desc, ;
10951 d.sizebucket as size_bk, ;
10952 ALLTRIM(d.Style) + "-" + ALLTRIM(d.color_code) + ALLTRIM(d.size_desc) As Cust_style, ;
10953 d.aux_sku ;
10954 from (pceipoTH) h ;
10955 join (pceipoTD) d ;
10956 on d.fkey = h.pkey ;
10957 join zzeipocr c ;
10958 on c.division = d.division ;
10959 and c.customer = h.customer ;
10960 where c.GenCustSKU = 'Y' ;
10961 and d.sku = '' ;
10962 and h.Errs_flg_h < 'Y' ;
10963 and d.Errs_Flg_D < 'Y' ;
10964 into cursor tmpCurs ;
10965 order by 1,2,4,5,6,7, 11
10966 *- customer+ division+ style + color_code+ lbl_code+ dimension+ size_desc
10967
10968 lnCount = Reccount("tmpCurs")
10969
10970 .LogEntry("Total Number of Customer SKUs Records Found :" + Alltrim(Str(lnCount)) )
10971
10972 If lnCount = 0
10973 If Used("tmpCurs")
10974 Use In tmpCurs
10975 Endif
10976 Select (lnSelect)
10977 Return
10978 Endif
10979
10980 *- Index just in case somebody changes the SELECT above
10981 Select tmpCurs
10982 Index On customer + division + Style + color_code+ lbl_code+ Dimension + size_desc ;
10983 TAG sku
10984
10985 .LogEntry("Load Customer Style.")
10986
10987 If !.OpenTable("VZZXCSTHR") Or !.OpenTable("VZZXCSTDR")
10988 If Used("tmpCurs")
10989 Use In tmpCurs
10990 Endif
10991 Select (lnSelect)
10992 Return
10993 Endif
10994
10995 lnCstHrPkey = v_nextPkey("ZZXCSTHR", lnCount)
10996 lnCstDrPkey = v_nextPkey("ZZXCSTDR", lnCount)
10997 lnCount = lnCount - 1
10998 lnCstDrPkey = lnCstDrPkey - lnCount && Starting pKey
10999 lnCstHrPkey = lnCstHrPkey - lnCount && Starting pKey
11000
11001 Select VZZXCSTHR
11002 Scatter Memvar Blank
11003 Select VZZXCSTDR
11004 Scatter Memvar Blank
11005
11006 m.Last_mod = Datetime()
11007 m.User_id = 'CGSADMIN'
11008 m.IB_Resolv = 'Y' && This field should be ="Y" in this case according to YIK
11009 m.notes = ''
11010
11011 *--- TR 1057011 7-10-2011 VKK
11012 * Setting defaults for flds. active_ok and anti_theft in Customer Style Reference
11013 m.active_ok = 'Y'
11014 m.anti_theft = 'N'
11015 *=== TR 1057011 7-10-2011 VKK
11016
11017 lcPrevSKU = ' '
11018 lcPrevSkuSize = ''
11019
11020 *- inserted details counter
11021 Local lnInsertCount
11022 lnInsertCount = 0
11023
11024 Select tmpCurs
11025
11026 Scan
11027 .LogEntry("Loading Customer Style...")
11028 .LogEntry("Style :" + Style )
11029 .LogEntry("Color_code :" + color_code )
11030
11031 If Empty(Style) Or Empty(color_code) Or !vl_Stylr(Division, "", ,Style) Or Empty(size_bk)
11032 .LogEntry("Invalid Style or Color_code or Size_bk " )
11033 Replace Errs_Msg_D With Errs_Msg_D + " Resolved SKU Invalid" , Errs_Flg_D With "Y" ;
11034 FOR pkey = dtlpkey In (pceipoTD)
11035 Loop
11036 Endif
11037
11038 *--- TR 1057011 7-10-2011 VKK Comemnted here becuase in client version we need to remove cust_store(SOFFE)
11039 Scatter Memvar Fields customer,division,Style,color_code,lbl_code,;
11040 DIMENSION, size_bk, size_desc, Cust_style,cust_price, aux_sku
11041
11042 *--- Client Soffe wants to display size description in dimension's place if it is empty
11043 lcSku = m.customer+ m.division+ m.style + m.color_code+ m.lbl_code+ IIF(EMPTY(m.dimension), m.size_desc, m.dimension)
11044 If lcPrevSKU # lcSku
11045 lcPrevSKU = lcSku
11046 *- style, color_code, lbl_code, dimension, customer, division, cust_store, udf_dept
11047 .LogEntry("Customer :" + m.customer )
11048 .LogEntry("Division : " + m.division)
11049 .LogEntry("Style :" + Style )
11050 .LogEntry("Color_code :" + m.color_code )
11051 .LogEntry("Label code :" + m.lbl_code )
11052 .LogEntry("dimension : " + m.dimension)
11053 .LogEntry("size bucket : " + Transform(m.size_bk, "99"))
11054 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))
11055 If Empty(lnHDRpKey)
11056 lnHDRpKey = lnCstHrPkey
11057 .LogEntry("Inserting into header..")
11058 Insert Into VZZXCSTHR From Memvar
11059 Replace pkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) ;
11060 In VZZXCSTHR
11061 Endif
11062 Endif
11063 If lcPrevSkuSize # lcSku + Alltrim(Str(m.size_bk))
11064 lcPrevSkuSize = lcSku + Alltrim(Str(m.size_bk))
11065 *- TR 1071542 FH - added check for if dimension is empty, use size_desc.
11066 *- 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)
11067 *lnDtlKey = vl_CStDR(m.customer, "PKey", , m.division, m.style, m.color_code, m.lbl_code, m.dimension,m.size_bk)
11068 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)
11069
11070 If Empty(lnDtlKey)
11071 lnDtlpKey = lnCstDrPkey
11072 .LogEntry("Inserting into detail..")
11073 Insert Into VZZXCSTDR From Memvar
11074 *- TR 1071542 FH- need to add replace for dimension here as well
11075 Replace pkey With lnDtlpKey,fkey With lnHDRpKey, dimension WITH IIF(EMPTY(m.dimension), m.size_desc, m.dimension) In VZZXCSTDR
11076 lnInsertCount = lnInsertCount + 1
11077 Endif
11078 Endif
11079 lnCstDrPkey = lnCstDrPkey +1
11080 lnCstHrPkey = lnCstHrPkey +1
11081
11082 Endscan
11083
11084 Dimension laTables[2]
11085 laTables[1]= "VZZXCSTHR"
11086 laTables[2]= "VZZXCSTDR"
11087
11088 llBeganTransaction = .BeginTransaction()
11089 llRetVal = .Tableupdate(@laTables)
11090
11091 If llRetVal
11092 If llBeganTransaction
11093 This.EndTransaction()
11094 .LogEntry("Processed " + Alltrim(Str(lnCount)) + " items. Inserted " + ;
11095 ALLTRIM(Str(lnInsertCount)) + " customer styles.")
11096 Endif
11097 Else
11098 If llBeganTransaction
11099 This.RollbackTransaction()
11100 .LogEntry("Table Update failed - Roll back Transaction " )
11101 Endif
11102 Endif
11103
11104 Endwith
11105
11106 If Used("tmpCurs")
11107 Use In tmpCurs
11108 Endif
11109
11110 Select (lnSelect)
11111 Return llRetVal
11112 Endfunc
11113
11114 *=== TR 1053820 25-May-2011 Goutam
11115
11116*--- TechRec 1049646 01-Apr-2011 TShenbagavalli ---
11117 *============================================================
11118 Procedure RangePConversion
11119 Lparameters pcTransHeader, pcTransDetail, pceipoCR &&, pcViewTransDetail
11120 LOCAL llRetVal, lnOldSelect, lcErrs_Msg
11121 llRetVal = .T.
11122 lnOldSelect = Select()
11123
11124 LOCAL lcError, lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11125
11126 STORE 0 TO lnOrigQty, lnPrice, lnretail1, lnretail2, lnPpkQty
11127 * 1st Getting all range headers
11128 *- process all.
11129 *- Exclude range style P from the consideration
11130 lcSQLString = "Select * from zzxrangh where rng_type = 'P'"
11131 llRangeP = v_SqlExec(lcSQLString, "__RangeP")
11132
11133 SELECT DISTINCT d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.ppk_action, d.pkey, c.ppk_conv ;
11134 FROM (pcTransDetail) d ;
11135 JOIN (pceipoCR) c ON c.customer = d.customer ;
11136 AND c.division = d.division ;
11137 WHERE ((d.rng_type = 'P' OR ;
11138 (d.division + d.style + d.color_code + d.lbl_code + d.dimension ;
11139 IN (SELECT division + rng_style + rng_color + rng_lbl + rng_pack FROM __RangeP )) ;
11140 )AND c.rngp_conv = 'R') ; && requires Range P conversion
11141 AND d.ppk_action $ 'QPBO' ;
11142 ORDER BY 1,2,3,4,5 INTO CURSOR __TmpCursor
11143
11144 With This
11145 .cSQLTempTable=""
11146 If .GenerateSQLTempTable('__TmpCursor')
11147 If .PopulateSQLTempTable('__TmpCursor')
11148 If !Empty(.cSQLTempTable)
11149
11150 lcSQLString= " SELECT t.*, ISNULL(rh.rng_qty, 0) AS pack_qty, " + ;
11151 " st.size_code " +;
11152 " FROM " + .cSQLTempTable + " t " +;
11153 " JOIN zzxscolr s " + ;
11154 " ON s.division = t.division " +;
11155 " AND s.style = t.style " + ;
11156 " AND s.color_code = t.color_code " + ;
11157 " AND s.lbl_code = t.lbl_code " + ;
11158 " AND s.dimension = t.dimension " + ;
11159 " INNER JOIN zzxstylr st " + ;
11160 " ON st.pkey = s.fkey " + ;
11161 " JOIN zzxrangh rh " + ;
11162 " ON rh.division = t.division " + ;
11163 " AND rh.rng_Style = t.style " + ;
11164 " AND rh.rng_color = t.color_Code " + ;
11165 " AND rh.rng_lbl = t.lbl_Code " + ;
11166 " AND rh.rng_pack = t.dimension "
11167
11168 llRetVal= llRetVal And v_SqlExec(lcSQLString, "_PPK_Qty")
11169
11170 If Used("_PPK_Qty")
11171 Select ("_PPK_Qty")
11172 Index On division+Style+color_code+lbl_code+Dimension Tag Ppk
11173 llRetVal= .SetRelation("_PPK_Qty", "Ppk", pcTransDetail, ;
11174 "division+style+color_code+lbl_code+dimension")
11175 SELECT ("__TmpCursor")
11176
11177 If llRetVal
11178 .LogEntry("Validating Range style.")
11179 lcErrs_Msg = "No valid Range Style found"
11180 Select (pcTransDetail)
11181 SCAN FOR !EOF("_PPK_Qty")
11182
11183 If Empty(_PPK_Qty.pack_qty)
11184 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + CRLF, ;
11185 Errs_Flg_D With "Y" ;
11186 IN (pcTransDetail)
11187 Else
11188 Do Case
11189
11190 Case ppk_action = 'Q' && multiply qty
11191
11192 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11193 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11194 ppk_action With 'M' ; && 'M'ultiplied. Don't do it again.
11195 In (pcTransDetail)
11196
11197 Case ppk_action = 'P' && divide price
11198
11199 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11200 org_price With org_price/_PPK_Qty.pack_qty, ;
11201 retail1 With retail1/_PPK_Qty.pack_qty, ;
11202 retail2 With retail2/_PPK_Qty.pack_qty, ;
11203 ppk_action With 'D' ; && 'D'ivided. Don't do it again.
11204 In (pcTransDetail)
11205
11206 *- Range style price will be populated later from a_price..e_price
11207 *- not from org_price. Need to updated these prices here.
11208 IF rng_type = 'R'
11209 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11210 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11211 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11212 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11213 e_price WITH e_price/_PPK_Qty.pack_qty ;
11214 In (pcTransDetail)
11215 ENDIF
11216
11217 Case ppk_action = 'B' OR ppk_action = 'O'
11218
11219 Replace ppk_qty With _PPK_Qty.pack_qty, ;
11220 org_price With org_price/_PPK_Qty.pack_qty, ;
11221 retail1 With retail1/_PPK_Qty.pack_qty, ;
11222 retail2 With retail2/_PPK_Qty.pack_qty, ;
11223 total_qty With total_qty*_PPK_Qty.pack_qty, ;
11224 ppk_action With 'X' ; && Divided and Multiplied. Don't do it again.
11225 In (pcTransDetail)
11226
11227 IF rng_type = 'R'
11228 REPLACE a_price WITH a_price/_PPK_Qty.pack_qty, ;
11229 b_price WITH b_price/_PPK_Qty.pack_qty, ;
11230 c_price WITH c_price/_PPK_Qty.pack_qty, ;
11231 d_price WITH d_price/_PPK_Qty.pack_qty, ;
11232 e_price WITH e_price/_PPK_Qty.pack_qty ;
11233 In (pcTransDetail)
11234 ENDIF
11235
11236 Otherwise
11237 Endcase
11238 Endif
11239 Endscan
11240 Endif
11241 Set Relation To
11242 Endif
11243 Endif
11244 Endif
11245 Endif
11246
11247 Endwith
11248
11249 If Used("__TmpCursor")
11250 Use In __TmpCursor
11251 Endif
11252
11253 If Used("_PPK_Qty")
11254 Use In _PPK_Qty
11255 Endif
11256
11257 If Used("__RangeP")
11258 Use In __RangeP
11259 Endif
11260
11261 Select(lnOldSelect)
11262 Return llRetVal
11263 *============================================================
11264 *=== TechRec 1049646 01-Apr-2011 TShenbagavalli ===
11265
11266 *--- TechRec 1056904 24-Oct-2011 jisingh ---
11267 PROCEDURE PopulateIs860
11268 LPARAMETERS pceipoTH, pceipoCR
11269 LOCAL llRetVal, lnSelect, lcUpdate
11270
11271 llRetVal = true
11272 lnSelect = SELECT()
11273
11274 *--- TR 1065396 22-Nov-2012 Goutam. Added template COSTCO 860
11275
11276 *--- TR 1070268 26-Jun-2013 Goutam
11277 *lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11278 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11279 " WHERE NVL(th.is860, '') = '' AND INLIST(th.po_purp,'03','05') AND (cr.template = 'CHARMING SHOPPES 4030' or cr.template = 'COSTCO 860')"
11280
11281 lcUpdate = " UPDATE th SET is860 = 'Y' FROM (pceipoTH) th " + ;
11282 " JOIN (pceipoCR) cr ON cr.customer = th.customer AND cr.division = th.division " + ;
11283 " 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')))"
11284
11285 *=== TR 1070268 26-Jun-2013 Goutam
11286
11287 &lcUpdate
11288
11289 SELECT (lnSelect)
11290 RETURN llRetVal
11291 ENDPROC
11292
11293 *============================================================
11294
11295 PROCEDURE Create860TM
11296 *--- TechRec 1082601 12-Dec-2014 jisingh Added pceipoTD ===
11297 LPARAMETERS pceipoTH, pceipoTD
11298 *--- TechRec 1082601 15-Dec-2014 jisingh Added loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp ===
11299 LOCAL llRetVal, lnSelect, lcInsert, loEiPOth, lnRecNo, lcAlias, tcCRPkey, lcSql, loEiPOtd, lcInsertDtl, lnLineSeq, lcPocPurp
11300
11301 llRetVal = true
11302 lnSelect = SELECT()
11303 lcAlias = GetUniqueFileName()
11304 lcInsert = BuildInsertString("zzeipcth", "voEiPcth")
11305 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11306 lcInsertDtl = BuildInsertString("zzeipctd", "voEiPctd")
11307 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11308
11309 WITH This
11310 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11311 *IF !EMPTY(lcInsert)
11312 SELECT DISTINCT h.division, h.customer, h.po_num, h.store, h.is860 ;
11313 FROM (pceipoTH) h WHERE h.is860 = "Y" ;
11314 ORDER By h.division, h.customer INTO CURSOR tcOrders
11315
11316 .cSQLTempTable = ""
11317 llRetVal = llRetVal AND .GenerateSQLTempTable("tcOrders")
11318 llRetVal = llRetVal AND .PopulateSQLTempTable("tcOrders")
11319 llRetVal = llRetVal AND !EMPTY(.cSQLTempTable)
11320
11321 lcSql = " SELECT DISTINCT rh.customer, rh.division, rh.po_num, rh.store, rh.ord_status " + ;
11322 " FROM zzoordrh rh " + ;
11323 " JOIN " + .cSQLTempTable + " t " + ;
11324 " ON t.customer = rh.customer " + ;
11325 " AND t.division = rh.division " + ;
11326 " AND t.po_num = rh.po_num " + ;
11327 " AND t.store = rh.store " + ;
11328 " WHERE t.is860 = 'Y' "
11329
11330 llRetVal = llRetVal AND v_SQLExec(lcSql, "tcOrders")
11331
11332 IF llRetVal AND USED("tcOrders") AND !EMPTY(lcInsert)
11333 SELECT tcOrders
11334 INDEX ON customer+division+po_num+store+ord_status TAG cdpo
11335 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11336 .vSqlExec("SELECT * FROM zzeipcth WHERE 1 = 2", lcAlias)
11337 SELECT (lcAlias)
11338 SCATTER NAME voEiPcth MEMO
11339
11340 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11341 .vSqlExec("SELECT * FROM zzeipctd WHERE 1 = 2", lcAlias)
11342 SELECT (lcAlias)
11343 SCATTER NAME voEiPctd MEMO
11344 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11345
11346 .vSqlExec("SELECT customer, division, pkey FROM zzeipccr", "tcCRPkey")
11347 SELECT tcCRPkey
11348 INDEX ON customer+division TAG cudiv
11349
11350 SELECT (pceipoTH)
11351 COUNT TO lnRecNo FOR Is860 = 'Y'
11352
11353 IF .lUserInterface
11354 .AdvanceThermo(lnRecNo)
11355 ENDIF
11356
11357 SELECT (pceipoTH)
11358 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11359 *SCAN FOR Is860 = 'Y'
11360 SCAN FOR Is860 = 'Y' AND SEEK(customer+division+po_num+store+"O", "tcOrders", "cdpo")
11361 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11362 SCATTER NAME loEiPOth MEMO
11363
11364 lcSql = "Select 1 from zzeipcth where po_num = " + SqlFormatChar(loEiPOth.po_num) + " and division = " + SqlFormatChar(loEiPOth.division) + ;
11365 " and Customer = " + SqlFormatChar(loEiPOth.customer) + " and edi_store = " + SqlFormatChar(loEiPOth.edi_store)
11366
11367 llRetVal = llRetVal AND .vSqlExec(lcSql, "__tcipcth")
11368
11369 IF RECCOUNT("__tcipcth") > 0
11370 REPLACE Is860 WITH 'X' IN (pceipoTH)
11371 USE IN SELECT("__tcipcth")
11372 LOOP
11373 ENDIF
11374
11375 *--- TechRec 1082601 08-Jan-2015 jisingh ---
11376 lcPocPurp = "01"
11377 SELECT (pceipoTD)
11378 IF SEEK(loEiPOth.pkey, pceipoTD, "fkey")
11379 SCAN WHILE fkey = loEiPOth.pkey
11380 IF !EMPTY(qual_860)
11381 lcPocPurp = "04"
11382 EXIT
11383 ENDIF
11384 ENDSCAN
11385 ENDIF
11386 SELECT (pceipoTH)
11387 *=== TechRec 1082601 08-Jan-2015 jisingh ===
11388
11389 WITH voEiPcth
11390 voEiPcth.Pkey = v_NextPkey("zzeipcth")
11391 voEiPcth.CR_Pkey = IIF(SEEK(loEiPOth.customer+loEiPOth.division,"tcCRPkey","cudiv"),tcCRPkey.Pkey,0)
11392 *--- TechRec 1082601 25-Dec-2014 jisingh ---
11393 *voEiPcth.poc_purp = "01"
11394 voEiPcth.poc_purp = lcPocPurp
11395 *=== TechRec 1082601 25-Dec-2014 jisingh ===
11396 voEiPcth.customer = loEiPOth.customer
11397 voEiPcth.division = loEiPOth.division
11398 voEiPcth.doc_num = loEiPOth.doc_num
11399 voEiPcth.edi_store = loEiPOth.edi_store
11400 voEiPcth.store = loEiPOth.store
11401 voEiPcth.isa_num = loEiPOth.isa_num
11402 voEiPcth.our_id = loEiPOth.our_id
11403 voEiPcth.our_qual = loEiPOth.our_qual
11404 voEiPcth.po_num = loEiPOth.po_num
11405 voEiPcth.vnd_id = loEiPOth.vnd_id
11406 voEiPcth.vnd_qual = loEiPOth.vnd_qual
11407 voEiPcth.po_purp = loEiPOth.po_purp && have to confirm
11408 voEiPcth.po_type = loEiPOth.po_type
11409 voEiPcth.vnd_key = loEiPOth.vnd_key
11410 ENDWITH
11411
11412 llRetVal = llRetVal AND .vSqlExec(lcInsert)
11413
11414 REPLACE Is860 WITH 'X' IN (pceipoTH)
11415
11416 *--- TechRec 1082601 15-Dec-2014 jisingh ---
11417 IF llRetVal AND !EMPTY(lcInsertDtl) AND voEiPcth.pkey > 0
11418 lnLineSeq = 1
11419
11420 SELECT (pceipoTD)
11421 SCAN FOR fkey = loEiPOth.pkey AND !EMPTY(qual_860)
11422 SCATTER NAME loEiPOtd MEMO
11423
11424 WITH voEiPctd
11425 voEiPctd.pkey = v_NextPkey("zzeipctd")
11426 voEiPctd.line_seq = lnLineSeq
11427 voEiPctd.fkey = voEiPcth.pkey
11428 voEiPctd.qualifier = loEiPOtd.qual_860
11429 voEiPctd.upc = loEiPOtd.upc
11430 voEiPctd.sku = loEiPOtd.sku
11431 voEiPctd.aux_sku = loEiPOtd.aux_sku
11432 voEiPctd.division = loEiPOtd.division
11433 voEiPctd.style = loEiPOtd.style
11434 voEiPctd.color_code = loEiPOtd.color_code
11435 voEiPctd.lbl_code = loEiPOtd.lbl_code
11436 voEiPctd.dimension = loEiPOtd.dimension
11437 voEiPctd.size_desc = loEiPOtd.size_desc
11438 voEiPctd.sizebucket = loEiPOtd.sizebucket
11439 voEiPctd.ean = loEiPOtd.ean
11440 voEiPctd.udfoordd1c = loEiPOtd.udfoordd1c
11441 voEiPctd.udfoordd2c = loEiPOtd.udfoordd2c
11442 voEiPctd.start_date = loEiPOtd.start_date
11443 voEiPctd.end_date = loEiPOtd.end_date
11444 voEiPctd.delv_code = loEiPOtd.delv_code
11445 voEiPctd.qty_change = loEiPOtd.total_qty
11446 voEiPctd.total_qty = loEiPOtd.total_qty
11447 voEiPctd.poc_cost = loEiPOtd.price
11448 voEiPctd.poc_price = loEiPOtd.retail1
11449 voEiPctd.poc_retail2 = loEiPOtd.retail2
11450 ENDWITH
11451
11452 llRetVal = llRetVal AND .vSqlExec(lcInsertDtl)
11453 lnLineSeq = lnLineSeq + 1
11454 ENDSCAN
11455 ENDIF
11456 *=== TechRec 1082601 15-Dec-2014 jisingh ===
11457
11458 IF .lUserInterface
11459 lnRecNo = lnRecNo + 1
11460 .AdvanceThermo(lnRecNo)
11461 ENDIF
11462 USE IN SELECT("__tcipcth")
11463 ENDSCAN
11464 ENDIF
11465 .TableClose(lcAlias)
11466 .TableClose("tcCRPkey")
11467 *--- TechRec 1060072 27-Apr-2012 jisingh ---
11468 .TableClose("tcOrders")
11469 *=== TechRec 1060072 27-Apr-2012 jisingh ===
11470 ENDWITH
11471
11472 RELEASE voEiPcth
11473 SELECT (lnSelect)
11474 RETURN llRetVal
11475 ENDPROC
11476 *=== TechRec 1056904 24-Oct-2011 jisingh ===
11477
11478 *--- TechRec 1066487 05-Feb-2013 MANI. ---
11479 PROCEDURE ValidateLocation
11480 LPARAMETERS pcHeader
11481
11482 LOCAL llRetVal, lnOldSelect
11483
11484 llRetVal= true
11485 lnOldSelect= Select()
11486
11487 SELECT Distinct Location FROM (pcHeader) ;
11488 WHERE NOT EMPTY(Location) INTO CURSOR __tmpLocation
11489
11490 SELECT __tmpLocation
11491 WITH This
11492 .cSQLTempTable=""
11493 IF .GenerateSQLTempTable('__tmpLocation')
11494 IF .PopulateSQLTempTable('__tmpLocation')
11495 IF !EMPTY(.cSQLTempTable)
11496 lcSQLString= "SELECT l.Location FROM zzxlocar l, " + .cSQLTempTable + " t " +;
11497 "WHERE l.Location = t.Location AND Loc_type = 'W' "
11498 llRetVal = v_SqlExec(lcSQLString, "_Location")
11499 IF llRetVal
11500 SELECT _Location
11501 INDEX On Location TAG Location
11502 llRetVal= .SetRelation("_Location", "Location", pcHeader, "Location")
11503 IF llRetVal
11504 SELECT (pcHeader)
11505 Replace Errs_msg_H WITH Errs_msg_H + "Invalid Location." + CRLF , ;
11506 Errs_flg_h WITH "Y" FOR EOF("_Location") AND NOT EMPTY(Location) In (pcHeader)
11507 SET RELATION TO
11508 ENDIF
11509 ENDIF
11510 ENDIF
11511 ENDIF
11512 ENDIF
11513 ENDWITH
11514
11515 IF USED("__tmpLocation")
11516 USE IN __tmpLocation
11517 ENDIF
11518 IF USED("_Location")
11519 USE IN _Location
11520 ENDIF
11521
11522 Select(lnOldSelect)
11523 Return llRetVal
11524 ENDPROC
11525 *=== TechRec 1066487 05-Feb-2013 MANI. ===
11526
11527 *--- TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11528 PROCEDURE GetFldsList
11529 LPARAMETERS lcpceipoTH, lczzeoprth
11530
11531 LOCAL lcFldsList, lcSQLString, lnOldSelect, lcFld
11532
11533 lnOldSelect= Select()
11534
11535 *- get common fields from both aliases
11536 lcFldsList = UPPER(getcommonfieldlistwithalias("", lcpceipoTH, lczzeoprth))
11537
11538 *- get fields from source table to validate 850 filter bros
11539 lcFields = UPPER(GetSortedFieldList(lcpceipoTH)) && get fields
11540
11541 *- Retrieve all 850 filter bros
11542 lcSQLString = "Select OBJID from zzxsfxrf " +;
11543 "Where objname ='zzeipopr' AND parambro <> 'Y'"
11544
11545 llRetVal = v_SqlExec(lcSQLString, "_Filter")
11546
11547 SELECT _Filter
11548
11549 SCAN
11550 lcFld = UPPER(TRIM(objid))
11551 *- Check filter bros and add them in required fields list if valid
11552 IF lcFld $ lcFields AND NOT lcFld $ lcFldsList
11553 lcFldsList = lcFldsList + ", " + lcFld
11554 ENDIF
11555 ENDSCAN
11556
11557 *- Adding additional fields used in 850 filter string and insert sql in calling method
11558 IF NOT "IS940I" $ UPPER(lcFldsList)
11559 lcFldsList = lcFldsList + ", IS940I"
11560 ENDIF
11561
11562 IF NOT "ERRS_FLG_H" $ UPPER(lcFldsList)
11563 lcFldsList = lcFldsList + ", ERRS_FLG_H"
11564 ENDIF
11565
11566 IF NOT "REQ_855" $ UPPER(lcFldsList)
11567 lcFldsList = lcFldsList + ", REQ_855"
11568 ENDIF
11569
11570 IF NOT "PROC_855" $ UPPER(lcFldsList)
11571 lcFldsList = lcFldsList + ", PROC_855"
11572 ENDIF
11573
11574 IF USED("_Filter")
11575 USE IN _Filter
11576 ENDIF
11577
11578 Select(lnOldSelect)
11579
11580 Return lcFldsList
11581
11582 ENDPROC
11583 *=== TR 1077093 25-Mar-2014 SMeenraja Retrieved required fields list to avoid toomany columns issue
11584
11585 *============================================================
11586
11587 *--- TechRec 1082601 24-Dec-2014 jisingh ---
11588 PROCEDURE Validate860Qual
11589 LPARAMETERS pcHeader, pcDetail
11590 LOCAL llRetVal, lnSelect
11591
11592 lnSelect = SELECT()
11593 llRetVal = .SetRelation(pcHeader, "pkey", pcDetail, "fkey")
11594
11595 REPLACE ALL errs_msg_d WITH errs_msg_d + "Item has 860 change code (" + ALLTRIM(qual_860) + ")" + CRLF, ;
11596 errs_flg_d WITH "Y" FOR !EMPTY(qual_860) AND &pcHeader..po_purp = "05" IN (pcDetail)
11597 SET RELATION TO
11598
11599 SELECT (lnSelect)
11600 RETURN llRetVal
11601 ENDPROC
11602 *=== TechRec 1082601 24-Dec-2014 jisingh ===
11603
11604Enddefine