· 7 years ago · Oct 10, 2018, 03:06 PM
1**********************************************************************************************
2* Program....: CLSIPCPR.PRG
3* Version....: 1.0
4* Author.....: Chris Brancke/Yuri Kaganovsky
5* Date.......: April, 2005
6* Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
7* Techreq....: 1010307
8* Compiler...: Visual FoxPro 08.00.0000.3117
9* Abstract...: EDI 860 Inbound Process Business Object Class
10* Cmd Line...: g_oApp.m_append("clsproc","clsproc",-1,.F.,"ZZEIPCPR")
11* Changes....:
12***********************************************************************************************
13
14#Include SYSTEM.h
15#Include EDI.h
16#DEFINE EDI_BULK_ORDER "BK"
17#DEFINE EDI_BLANKET_ORDER "BL"
18
19*--- TR 1016560 NH
20#DEFINE NOT_YET_PROCESS "Not yet process."
21#DEFINE NO_PREPACK "Unable to determine Prepack code."
22*=== TR 1016560 NH
23DEFINE CLASS BPOiPCProcess AS BPOEDIBase
24 NAME = "BPOiPCProcess"
25 lErrorState = .F.
26 lUserInterface = .F.
27 cFilterCriteria = ""
28 oFrmOutput = NULL && Object handle for print dialog form
29 oMainForm = NULL
30 oBPOSalesOrder = NULL
31 oBPOEDIBase = NULL
32 oBPOiPOProcess = NULL
33 niPCOrderHeader = 0
34 niPCOrderDetail = 0
35 lHaveComment = .F.
36
37 nToProcess = 0
38 nProcessed = 0
39 cJobID = "EDI860"
40 cLogFile = "EDI860I.log"
41 cDescription = "EDI 860 inbound process"
42 lNoDataFound = false
43 cMessage = ''
44 lScheduled = false
45 lUpdateSalesOrder = false
46 lUpdate860Records = false
47 lDelete860Records = false
48 lOneDetailLineBad = false
49 lUpdateCancelViews = false
50 lCreatedRatioCursor = false
51
52 *--- TR 1016559 NH
53 lPrepackConversion = .f.
54 *- 1014475 12/28/05 YIK
55 lUpdateRatioCursor = .F.
56
57 oBPOCancel = NULL
58
59 *- 1014475 12/02/05 YIK
60 nMaxSizes = 24
61 *--- TR 1015983 NH
62 Tie_setup = .F.
63 *=== TR 1015983 NH
64 *--- TR 1016904 NH
65 cStore_ALL = "ALL"
66
67 *=== TR 1016904 NH
68 *--- TR 1017210 NH
69 DIME aDuplicateFields[27]
70 *=== TR 1017210 NH
71
72 *---- TR 1032030 NH
73 lResolveRangeStyle = .F.
74 *====
75
76 * --- TR 1047609 7/7/10 CM
77 cTmpSLNTable = ""
78 * === TR 1047609 7/7/10 CM
79
80 *--- TR 1016560
81 DIMENSION aPrepacks[1]
82 DIMENSION aSizeStr[MAX_BUCKETS_STRU] && 30854 3/25/02
83 DIMENSION aPackStr[MAX_BUCKETS_STRU] && 30854 3/25/02
84
85 cMPPK = "tcMPPK"
86 cPPK_color = ""
87 cQualPPKSkus = "tcQPPKSKU"
88 aPrepackRecno = 0
89 lMultipack = .F.
90 lMultiPrepackAny = .F.
91 lAmbiguousPrepack = .F.
92 lSinglePrepackAny = .F.
93 lSingleColorMultiPrepack = .F.
94 lPrepackImplosionOk = .f.
95 SaleOrderControlRef = "zzocntrc_" + SYS(2015) && cache
96 *=== TR 1016560
97
98 *--- TR 1019356 NH
99 oTrCheck = .F.
100 lResl_Delv = .f.
101 *=== TR 1019356 NH
102
103 *--- TR 1021052 20-AUG-2007 HNISAR & Goutam
104 lNewOrder = false
105 lOrderExist = false
106 lOrderHdrFound = false
107 *=== TR 1021052 20-AUG-2007 HNISAR & Goutam
108
109 *--- TR 1027127 NH
110 lOptimizedPOChange = .f.
111 oApplyPoChange = NULL
112 *=== TR 1027127
113
114 *--- TR 1028744 19-FEB-2008 VKK
115 c860SODetailAddMatchCriteria = ""
116 *=== TR 1028744 19-FEB-2008 VKK
117
118 * --- TR 1047609 7/7/10 CM
119 lHaveSLN = .F.
120 * === TR 1047609 7/7/10 CM
121
122 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
123 lHaveWhse = False
124 lHaveAddress = False
125 lHaveOneTimeShippingAddress = False
126 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
127
128 *--- TR 1039757 27-Aug-2009 Goutam.
129 cNZLocalCursor = ""
130 *=== TR 1039757 27-Aug-2009 Goutam.
131
132 *--- TR 1048865 13-Apr-2011 Goutam
133 oGenStr = Null
134 cHBCKeySet = ""
135 nH_FirstPkey = 0
136 *=== TR 1048865 13-Apr-2011 Goutam
137
138 *--- TR 1066871 10-May-2013 Goutam
139 c850RefCursor = ""
140 cNoErrorCursor = ""
141 *=== TR 1066871 10-May-2013 Goutam
142
143 *--- TechRec 1073148 06-Aug-2014 asharma ---
144 lOptmizedExplodeSDQ = .F.
145 *=== TechRec 1073148 06-Aug-2014 asharma ===
146 lRslv_pricecode_cssld = .F. &&TR 1088126 3-JUL-Venuk
147
148 PROCEDURE ResetCounter
149 WITH THIS
150 .niPCOrderHeader= 0
151 .niPCOrderDetail=0
152 .cMessage= ""
153 .lHaveComment= .F.
154
155 .cFilterCriteria = ""
156 ENDWITH
157 ENDPROC
158
159 ************************************************************************************
160 * Init
161 ************************************************************************************
162 PROCEDURE INIT
163 LPARAMETERS plUserInterface
164 THIS.lUserInterface = plUserInterface
165 THIS.lScheduled= !plUserInterface
166 LOCAL llRetVal
167 llRetVal= .T.
168
169 IF !("CLSBUSIN" $ UPPER(SET("Procedure")))
170 SET PROCEDURE TO clsBusin ADDITIVE
171 ENDIF
172 IF !("CLSNIBLR" $ UPPER(SET("Procedure")))
173 SET PROCEDURE TO clsNiblr ADDITIVE
174 ENDIF
175 IF !("CLSSLSOP" $ UPPER(SET("Procedure")))
176 SET PROCEDURE TO clsSlsOP ADDITIVE
177 ENDIF
178 IF !("CLSSLSDF" $ UPPER(SET("Procedure")))
179 SET PROCEDURE TO clsSlsDF ADDITIVE
180 ENDIF
181 THIS.oBPOSalesOrder = CREATEOBJECT('BOSOPDefault')
182 IF !(TYPE('This.oBPOSalesOrder') = "O" AND !ISNULL(THIS.oBPOSalesOrder ))
183 llRetVal = .F.
184 ENDIF
185
186 IF !("CLSEDI" $ UPPER(SET("Procedure")))
187 SET PROCEDURE TO clsEDI ADDITIVE
188 ENDIF
189
190 THIS.oBPOEDIBase= CREATEOBJECT('BPOEDIBase')
191 IF !(TYPE('This.oBPOEDIBase') = "O" AND !ISNULL(THIS.oBPOEDIBase))
192 llRetVal = .F.
193 ENDIF
194
195 *- 1014475 12/21/05 YIK
196 *-SET PROCEDURE TO clsiccpr ADDITIVE
197 SET PROCEDURE TO clscancl ADDITIVE
198 SET PROCEDURE TO clsratio ADDITIVE
199
200 *- 1014475 12/21/05 YIK
201 THIS.oBPOCancel = CREATEOBJECT('BPOicProcess_860')
202 IF !(TYPE('This.oBPOCancel') = "O" AND !ISNULL(THIS.oBPOCancel))
203 llRetVal = .F.
204 ENDIF
205
206 *-- IF !("CLSIPOPR" $ UPPER(SET("Procedure")))
207 *-- SET PROCEDURE TO clsiPOPr ADDITIVE
208 *-- ENDIF
209 *-- THIS.oBPOiPOProcess = CREATEOBJECT('BPOiPOProcess')
210 *-- IF !(TYPE('This.oBPOiPOProcess') = "O" AND !ISNULL(THIS.oBPOiPOProcess ))
211 *-- llRetVal = .F.
212 *-- ENDIF
213
214 *--- TR 1015983 NH
215 This.Tie_setup = (goEnv.sv("TIE_SETUP","N") = 'Y')
216 *=== tr 1015983 NH
217 *--- TR 1017210 NH
218 WITH THIS
219 .aDuplicateFields[1]= "start_date"
220 .aDuplicateFields[2]= "end_date"
221 .aDuplicateFields[3]= "pri_date"
222 .aDuplicateFields[4]= "priority"
223 .aDuplicateFields[5]= "comm1"
224 .aDuplicateFields[6]= "comm2"
225 .aDuplicateFields[7]= "hold_code"
226 .aDuplicateFields[8]= "hold_rsn"
227 .aDuplicateFields[9]= "factor"
228 .aDuplicateFields[10]= "factor_ok"
229 .aDuplicateFields[11]= "ftran_date"
230 .aDuplicateFields[12]= "appv_num"
231 .aDuplicateFields[13]= "decl_rsn"
232 .aDuplicateFields[14]= "fact_status"
233 .aDuplicateFields[15]= "location"
234 .aDuplicateFields[16]= "discount"
235 .aDuplicateFields[17]= "comm3"
236 .aDuplicateFields[18]= "comm4"
237 .aDuplicateFields[19]= "slsperson1"
238 .aDuplicateFields[20]= "slsperson2"
239 .aDuplicateFields[21]= "slsperson3"
240 .aDuplicateFields[22]= "slsperson4"
241 .aDuplicateFields[23]= "facexpir_basis"
242 .aDuplicateFields[24]= "facexpir_days"
243 .aDuplicateFields[25]= "division"
244 .aDuplicateFields[26]= "Ord_Num"
245 .aDuplicateFields[27]= "Pick_Num"
246 ENDWITH
247 *=== TR 1017210 NH
248 *--- TR 1016559 NH
249 THIS.lPrepackConversion = this.PrepackConversionAllowed()
250 *=== TR 1016559 NH
251 *--- TR016560
252 THIS.lPrepackImplosionOk = THIS.TrOk('1016560') && TR 1016560 NH
253 *--- TR 1080606 18-8-2014 VKK
254* FOR lnxx = 1 TO goEnv.sv("MAXBUCKET", 24)
255 FOR lnxx = 1 TO INT(goEnv.sv("SYSMAXBUCKETS",24))
256 *=== TR 1080606 18-8-2014 VKK
257 lcBucket = PADL(lnxx, 2, "0")
258 THIS.aSizeStr[lnxx] = "size" + lcBucket + "_qty"
259 THIS.aPackStr[lnxx] = "pack" + lcBucket + "_qty"
260 ENDFOR
261
262 *--- Cache Sales Order Control Reference table
263 llRetVal = llRetVal and v_sqlexec("select * from zzocntrc", this.SaleOrderControlRef + "_Read")
264 this.MakeCursorWritable(this.SaleOrderControlRef + "_read", this.SaleOrderControlRef)
265 SELECT(this.SaleOrderControlRef)
266 INDEX ON DIVISION TAG div
267 *=== TR 1016560 NH
268 *--- TR 1019356 NH
269*!* IF USED("DelvCodeOk")
270*!* USE IN DelvCodeOk
271*!* ENDIF
272 *--- TR 1082498 6-NOV-14 Venuk. added vl_Compr(, "Resl_Delv"))) == "S" ===
273 THIS.lResl_Delv = (ALLTRIM(UPPER(vl_Compr(, "Resl_Delv"))) == "Y") OR (ALLTRIM(UPPER(vl_Compr(, "Resl_Delv"))) == "S")
274 This.lResl_Delv = THIS.lResl_Delv and This.TrOk('1019356')
275 *--- TR 1027127 NH
276 *IF THIS.lResl_Delv
277 IF This.TrOk('1019356')
278 *=== TR 1027127 NH
279 * Pull down the season, style, and delivery code tables:
280 LOCAL lcSQLString
281 lcSQLString = "SELECT * FROM zzxseasr"
282 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcSeasr')
283 IF llRetVal AND USED("tcSeasr")
284 SELECT tcSeasr
285 INDEX ON Division + Season TAG DivSea
286 SET ORDER TO TAG DivSea
287 ENDIF
288
289 lcSQLString = "SELECT * FROM zzxstylr"
290 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcStylr')
291 IF llRetVal AND USED("tcStylr")
292 SELECT tcStylr
293 INDEX ON Division + Style TAG DivSty
294 SET ORDER TO TAG DivSty
295 ENDIF
296
297 lcSQLString = ;
298 "SELECT DISTINCT Delv_Code, Ear_SDate, Lat_SDate, d.Season " + ;
299 " FROM zzodlvcd d " + ;
300 " JOIN zzxseasr s ON s.Season = d.Season " + ;
301 " WHERE s.Skip_Delv <> 'Y'"
302 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcDlvCd')
303
304 IF llRetVal AND USED("tcDlvCd")
305 SELECT tcDlvCd
306 INDEX ON DTOS(Ear_SDate) TAG Ear_SDate
307 INDEX ON Season TAG season
308 INDEX ON Season + DTOS(Ear_SDate) TAG SEarAsc
309 INDEX ON Season + DTOS(Ear_SDate) DESCENDING TAG SEarDesc
310 ENDIF
311
312 lcSQLString = "SELECT PKey, Division, Style, Color_Code, Lbl_Code, Dimension, Active_ok FROM zzxscolr"
313 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcScolr')
314 IF llRetVal AND USED("tcScolr")
315 SELECT tcScolr
316 INDEX ON Division + Style + Color_Code + Lbl_Code + Dimension TAG SKU
317 SET ORDER TO TAG SKU
318 ENDIF
319
320 lcSQLString = "SELECT * FROM zzxscdlv"
321 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcScdlv')
322 IF llRetVal AND USED("tcScdlv")
323 SELECT tcScDlv
324 INDEX ON FKey TAG FKey
325 SET ORDER TO TAG FKey
326 ENDIF
327 ENDIF
328
329 *=== TR 1019356 NH
330
331 This.lRslv_pricecode_cssld = (goEnv.SV("RESOLVE_PRICECODE_FROM_CUSTOMER_SALES_DETAIL","N") = 'Y') && TR 1088126 8-JUL-Venuk
332 *--- TR 1027127 nh
333 this.lOptimizedPOChange = (goEnv.SV("OPTIMIZED_860_POCHANGE","N") = "Y")
334
335 *--- TR 1028909 15-Jul-2008 Goutam. Due to folowing code process allways goes to optimized code. Removed this code.
336 this.lOptimizedPOChange = .t. && temp setup &&--- TechRec 1056904 12-Dec-2011 jisingh Uncommented, Existing Issue ===
337 *=== TR 1028909 15-Jul-2008 Goutam.
338
339 IF this.lOptimizedPOChange
340 this.oApplyPoChange = NEWOBJECT("clsipcpr_applyPoChange","clsipcpr_applyPoChange.prg")
341 ENDIF
342 *=== 1027127 NH
343
344 *--- TR 1022705 06-Dec-2007 Goutam
345 IF PEMSTATUS(THIS.oBPOSalesOrder,"lAllowInactiveStyleColors",5) &&--- TR 1036066 NH - in case
346 THIS.oBPOSalesOrder.lAllowInactiveStyleColors = (goEnv.SV('EDI_ALLOW_INACTIVE_STYLE_COLORS','N') = 'Y')
347 ENDIF
348 *=== TR 1022705 06-Dec-2007 Goutam
349
350 *--- TR 1028744 19-FEB-2008 VKK
351 This.c860SODetailAddMatchCriteria = goEnv.SV("860_SODETAIL_ADD_MATCH_CRITERIA", "")
352 *=== TR 1028744 19-FEB-2008 VKK
353
354 *--- TR 1048865 13-Apr-2011 Goutam
355 *--- Base class to prepare inser SQL
356 IF llRetVal
357 this.oGenStr = NEWOBJECT("SQLStringBuilder", "clsgnstr.prg")
358 llRetVal = llRetVal AND IsObject(this.oGenStr, true)
359 IF !llRetVal
360 this.cMessage = "Failed to create class to generate sql for preparing data. See History Log."
361 ENDIF
362 ENDIF
363 *=== TR 1048865 13-Apr-2011 Goutam
364
365 *--- TechRec 1073148 06-Aug-2014 asharma ---
366 this.lOptmizedExplodeSDQ = (goEnv.SV("OPTIMIZED_860_EXPLODESDQ","N") = "Y")
367 *=== TechRec 1073148 06-Aug-2014 asharma ===
368
369 RETURN llRetVal
370 ENDPROC
371
372 *--- TR 1048865 13-Apr-2011 Goutam
373 FUNCTION DESTROY
374 WITH THIS
375 IF IsObject(.oGenStr, true)
376 .oGenStr.Destroy()
377 .oGenStr = NULL
378 ENDIF
379 DoDefault()
380 ENDWITH
381 ENDFUNC
382 *=== TR 1048865 13-Apr-2011 Goutam
383
384 *---- TR 1016559 NH
385 PROCEDURE PrepackConversionAllowed
386 LOCAL llRetVal, lnOldSelect
387 *--- if ppk_action field present then it is prepack Convertion allowed
388 LOCAL lcSQL
389 lcSQL = "SELECT c.name from sysobjects t join syscolumns c on t.id = c.id where t.name = 'zzeipctd' and c.name = 'ppk_action'"
390 llRetVal = v_sqlexec(lcSQL, "PrepackConvertAllowed") and USED("PrepackConvertAllowed") and RECCOUNT("PrepackConvertAllowed")> 0
391 IF USED("PrepackConvertAllowed")
392 USE IN ("PrepackConvertAllowed")
393 ENDIF
394 RETURN llRetVal
395 ENDPROC
396 *==== TR 1016559 NH
397
398 *--- TR 1016560 NH
399 *******************************************************************************************
400
401 PROCEDURE TrOk
402 LPARAMETERS pcTR
403 LOCAL llRetVal, lnOldSelect
404 LOCAL lcDependOnTr
405 llRetVal = .t.
406 lnOldSelect = SELECT()
407 *--- TR 1019356 NH
408 LOCAL lcPath
409 IF NOT VARTYPE(this.oTrCheck) = "O"
410 lcPath = CURDIR() + "clsTrCheck.fxp"
411 IF FILE(lcPath)
412 this.oTrCheck = NEWOBJECT("clsTrCheck","clsTrCheck.prg")
413 ELSE
414 RETURN .f.
415 ENDIF
416 ENDIF
417 llRetVal = this.oTrCheck.TrOk(pcTR)
418 *=== TR 1019356 NH
419 SELECT(lnOldSelect)
420 RETURN llRetVal
421 ENDPROC
422
423 *=== TR 1016560 NH
424
425 ************************************************************************************
426 * Clenup
427 ************************************************************************************
428 PROCEDURE Cleanup
429 *--- TR 1016589 05/08/06 NH add notes views
430*!* LOCAL laTables[4], llRetVal
431
432 * --- TR 1047609 7/7/10 CM --- Changed dimension from laTables[6] to laTables[7]
433 *LOCAL laTables[6], llRetVal
434 &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli changed dimension from 7 to 8 ===
435 LOCAL laTables[8], llRetVal
436 * === TR 1047609 7/7/10 CM
437
438 laTables[1] = "VzzeiPCth_iPCproc"
439 laTables[2] = "VzzeiPCtd_iPCproc"
440 laTables[3] = "VzzeiPCta_iPCproc"
441 laTables[4] = "VzzeiPCtc_iPCproc"
442 laTables[5] = "Vnotes_IPCH_iPCproc"
443 laTables[6] = "VNotes_IPCD_iPCproc"
444
445 * --- TR 1047609 7/7/10 CM
446 laTables[7] = "VzzeiPCts_iPCproc"
447 * === TR 1047609 7/7/10 CM
448
449 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
450 laTables[8] = "VzzeipctWhse_iPCproc"
451 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
452
453 llRetVal = .TableClose(@laTables, .T.) && close and delete all temp views
454
455 IF llRetVal
456 llRetVal = .TableClose("Vzzoordsp") && close and DO NOT delete Perm.view
457 ENDIF
458
459 *--- TR 1066871 13-May-2013 Goutam
460 IF !EMPTY(this.c850RefCursor)
461 llRetVal = llRetVal AND this.TableClose(this.c850RefCursor)
462 ENDIF
463 IF !EMPTY(this.cNoErrorCursor)
464 llRetVal = llRetVal AND this.TableClose(this.cNoErrorCursor)
465 ENDIF
466 *=== TR 1066871 13-May-2013 Goutam
467
468 RETURN llRetVal
469 ENDPROC
470
471
472 PROCEDURE ProcessiPC
473 LPARAMETERS pcFilterCriteria
474 LOCAL llOKToContinue, lnOldSelect, ;
475 lnStartSeconds, lcFRX_Name, lcFilterCriteria, llBeganTransaction,;
476 lcMessageStr, lcEDIPath, lcSQL && TR 1042514 DEC-4-2009 BR ADDED lcSQL
477 llOKToContinue = .T.
478
479 WITH THIS
480 * Is there another 860 process running?
481 lcSyslockTablePath = ADDBS(goEnv.envLoginTablePath.VALUE)
482 IF !v_SysLock( lcSyslockTablePath+"SYSLOCK", "EDIIPCPROCESS", goEnv.EnvLogin.cCompany)
483 THIS.lProcessLocked = .T.
484 RETURN .F.
485 ENDIF
486 *
487 .ResetCounter()
488 lnOldSelect = SELECT()
489
490 PRIVATE vcLogName
491 vcLogName= lcSyslockTablePath+ "860.log"
492 .oLog.OpenLog("EDIIPCPROCESS", I("EDIIPCPROCESS"), .lScheduled)
493 .oLog.LogProgram("clsipcpr.prg")
494 .oLog.LogEntry("Filter Criteria: " + pcFilterCriteria)
495
496 .oLog.LogMajorStage("Preparing work tables and parameters for 860(i) process.")
497 .lNoDataFound = .F.
498 .CreateFrmProgressBar(43,"Selecting EDI 860 records to process...",;
499 "Total EDI 860 inbound process.")
500 *--- TR 1016904 NH
501 LOCAL llRetVal
502 llRetVal = .t.
503 *=== TR 1016904 NH
504
505 *--- TR 1066871 13-May-2013 Goutam
506 .c850RefCursor = GetUniqueFilename()
507 .cNoErrorCursor = GetUniqueFilename()
508 CREATE CURSOR (.c850RefCursor) (doc_num INT(4), Proc_850 C(1))
509 *=== TR 1066871 13-May-2013 Goutam
510
511 IF llOKToContinue
512 IF !EMPTY(pcFilterCriteria)
513 THIS.cFilterCriteria = IIF(!EMPTY(pcFilterCriteria), " Where " + pcFilterCriteria,"")
514 ENDIF
515
516 * Record Filter criterias in log
517 *--- TR 1015747 02/24/06 NH : load data from Transaction after we move data from flat file to transaction.
518 *!* .AdvanceThermoTotalWithCaptionPlus("Open transaction views with filter...", ;
519 *!* vcLogName)
520 *!* IF .QueryTransaction(THIS.cFilterCriteria)
521 *=== TR 1015747 02/24/06 NH
522
523 .AdvanceThermoTotalWithCaptionPlus("Creating all views...", vcLogName)
524 llRetVal = llRetVal and .CreateiPCViews()
525 .LogEntry("Creating all views " + IIF(llRetVal,"sucessful.", "failed."))
526
527 llRetVal = llRetVal and .LoadFromFlatfileToTransaction()
528 .LogEntry("Loading flatfile to transaction tables " + IIF(llRetVal,"sucessful.", "failed."))
529
530 *--- TR 1034532
531 *--- TR 1036066 NH : Rem out
532 *llRetVal = llRetVal and .RemoveValueALLFromEdiStoreForQualifier()
533 *=== TR 1034532
534
535 *--- TR 1039757 18-Aug-2009 Goutam.
536 llRetVal = llRetVal and this.MoveNZtoRZ()
537 *=== TR 1039757 18-Aug-2009 Goutam.
538
539 *--- TR 1027724 NH 11/05/07
540 *--- mark ForAllStore flag
541 llRetVal = llRetVal and this.MarkForAllStoreFlag()
542
543 *--- expode orders with no dtl and no sdq
544 llRetval = llRetVal and this.ExplodeOrderForAllStore()
545 *=== TR 1027724 NH 11/05/07
546
547 *--- TR 1062197 7-Sep-2012 Goutam
548 *--- expode orders for poc_purp = '04' and poc_store not blank. Populate this with edi_store
549 llRetval = llRetVal and this.ExplodeOrderForPOCStore()
550 *=== TR 1062197 7-Sep-2012 Goutam
551
552 llRetVal = llRetVal and .QueryTransaction(THIS.cFilterCriteria)
553 .LogEntry("Creating and open transaction views " + IIF(llRetVal,"sucessful.", "failed."))
554
555 *--- TechRec 1022169 28-Jun-2007 jjanand ---
556*!* IF THIS.CountTotalRecs ("tceipcTH") > 0
557 IF llRetVal and THIS.CountTotalRecs ("tceipcTH") > 0
558 *--- TechRec 1022169 28-Jun-2007 jjanand ---
559
560 * --- TR 1047609 7/7/10 CM --- Added tceipcTS
561 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added ,"tceipctWHSE" ===
562 llRetVal = llRetVal and .PreValidation("tceipcTH", "tceipcTD", "zzeipcCR", "tceipcTS", ,"tceipctWHSE")
563 .LogEntry("Validating transactions " + IIF(llRetVal,"sucessful.", "failed."))
564
565 *--- TR 1039757 18-Aug-2009 Goutam.
566 IF NOT llRetVal
567 .RevertFromRZtoNZ()
568 ENDIF
569 llRetVal = llRetVal and this.AddNewOrderForNZ()
570 .LogEntry("Created new record for NZ qualifier " + IIF(llRetVal,"sucessful.", "failed."))
571 *=== TR 1039757 18-Aug-2009 Goutam.
572
573 *--- TR 1050485 17-Dec-2011 Goutam.
574 llRetVal = llRetVal and this.MoveRZtoAI()
575 *=== TR 1050485 17-Dec-2011 Goutam
576
577 *--- TR 1022465 NH/BR : - we have division populated for normal orders, but orders with no detail have no division value.
578 *--- need to join with zzoordrh on po_num + customer only find the division from zzoordrh and stamp it in zzeipcth.division field
579 *llRetVal = llRetVal and .SetDivisionForOrderWithoutDetail("tceipcTH")
580
581 *--- TR 1050827 18-NOV-2010 HNISAR && Passing new parameter "tceipcTS"
582*!* llRetVal = llRetVal and .PopulateActualStoreForALLStore("tceipcTH", "tceipcTD", "zzeipcCR")
583 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tceipcTWHSE ===
584 llRetVal = llRetVal and .PopulateActualStoreForALLStore("tceipcTH", "tceipcTD", "zzeipcCR",,, "tceipcTS", "tceipcTWHSE")
585 *=== TR 1050827 18-NOV-2010 HNISAR && Passing new parameter "tceipcTS"
586
587 .LogEntry("Adding actual SDQ orders for ALL stores for 'DI' qualifier " + IIF(llRetVal,"sucessful.", "failed."))
588
589 llRetVal = llRetVal and .PopulateActualStoreForEmptyStoreOnHdrCancel("tceipcTH")
590 .LogEntry("Adding actual SDQ orders for ALL stores for entire order cancellation " + IIF(llRetVal,"sucessful.", "failed."))
591
592 *--- TR 1025576 NH
593 llRetVal = llRetVal and .CheckForPartialPickInvoice_Hdrlevel("tceipcTH")
594 *=== TR 1025576 NH
595
596 *- 1056230 FH - comment out
597 *--- TR 1027127 NH
598 *llRetVal = llRetVal and .CheckForEmptyStore("tceipcTH")
599 *=== TR 1027127 NH
600 *- 1056230 FH - comment out
601
602 .AdvanceThermoTotalWithCaptionPlus("Updating all transaction header(s) with detail in error stage...", vcLogName)
603 llRetVal = llRetVal and .UpdateAutoProcFlag("tceipcTH","zzeipcCR")
604 llRetVal = llRetVal AND .MarkHeaderForDetailWithError("tcEiPCth", "tcEiPCtd")
605 *--- TR 1034532 NH : moving this stamping of error for auto process flag after all validations.
606 *llRetVal = llRetVal AND .MarkHeaderForAutoProcFlag("tcEiPCth")
607 *=== TR 1034532 NH
608
609 *--- TR 1062197 7-Sep-2012 Goutam
610 llRetVal = llRetVal and .UpdatePOCShiptoWithConsolCode("tceipcTH")
611 *=== TR 1062197 7-Sep-2012 Goutam
612
613 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added ,tceipcTWHSE ===
614 llRetVal = llRetVal AND .TableUpdateTransaction("tcEiPCth", "tcEiPCtd", "tcEiPCtC", ;
615 "Vnotes_IPCH_iPCproc", "Vnotes_IPCD_iPCproc", ,"tceipcTWHSE")
616 llRetVal = llRetVal and .CloseIPCViews()
617 *--- TR 1027127 NH
618 *--- TR 1034532 NH - retire ApplyPoChange() procedure from clsipcpr.prg
619 *IF .lOptimizedPOChange
620 llRetVal = llRetVal and this.oApplyPoChange.ApplyPoChange(this)
621 *ELSE
622 *llRetVal = llRetVal and .ApplyPOChanges()
623 *ENDIF
624 *=== TR 1034532 NH
625 *=== TR 1027127 NH
626
627 * -- TR 1042514 DEC-4-2009 BR
628 lcSQL = " UPDATE zzeipcth set pending_flg = 'N' WHERE pending_flg = 'Y' AND Errs_Msg_h Not Like 'Not yet process%'"
629 llRetVal = llRetVal and v_sqlexec(lcSQL)
630 * == TR 1042514 DEC-4-2009 BR
631
632 *--- TR 1019356 NH
633 .cMessage = allTRIM(STR(.nToProcess)) + " EDI 860 Order(s) Found " + CRLF
634 .cMessage = .cMessage + ALLTRIM(STR(.nProcessed)) + " EDI 860 Order(s) processed." + CRLF
635 .cMessage = .cMessage + ALLTRIM(STR(.nToProcess - .nProcessed)) + " 860 Order(s) failed processing."
636 *=== TR 1019356 NH
637
638 *--- TR 1066871 13-May-2013 Goutam
639 IF USED(.cNoErrorCursor) AND RECCOUNT(.cNoErrorCursor) > 0
640 .cMessage = .cMessage + CRLF + CRLF + "850(i) flat file created for this transaction. See history log for detail."
641 ENDIF
642 *=== TR 1066871 13-May-2013 Goutam
643
644 *--- TR 1023134 ND
645 .oLog.LogEntry(ALLTRIM(STR(.nToProcess)) + " EDI 860 Order(s) Found ")
646 .oLog.LogEntry(ALLTRIM(STR(.nProcessed)) + " EDI 860 Order(s) processed.")
647 .oLog.LogEntry(ALLTRIM(STR(.nToProcess - .nProcessed)) + " 860 Order(s) failed processing.")
648 *=== TR 1023134 ND
649
650 *--- TR 1066871 13-May-2013 Goutam
651 IF USED(.cNoErrorCursor) AND RECCOUNT(.cNoErrorCursor) > 0
652 SELECT (.cNoErrorCursor)
653 SCAN
654 .oLog.LogEntry("EDI 850(i) flat file created for Document Number : " + ALLTRIM(STR(doc_num)) + "; PO Number " + ALLTRIM(po_num))
655 ENDSCAN
656 .oLog.LogEntry("Please run EDI 850(i) process to create above transaction.")
657 ENDIF
658 *=== TR 1066871 13-May-2013 Goutam
659
660 ELSE
661 .cMessage= "There are no EDI orders to process."
662 .lNoDataFound = .T.
663
664 *--- TR 1023134 ND
665 .oLog.LogEntry("There are no EDI orders to process.")
666 *=== TR 1023134 ND
667
668 ENDIF
669
670 IF NOT llRetVal
671 .cMessage = "860 Process Failed."
672
673 *--- TR 1023134 ND
674 .oLog.LogEntry("860 Process Failed.")
675 *=== TR 1023134 ND
676
677 ENDIF
678 ENDIF
679 *=== TR 1016560 NH
680
681 lcLogMsg= STRTRAN(.cMessage, CRLF, "")
682 IF THIS.lUserInterface
683 THIS.m_close()
684 ENDIF
685
686 * Close and remove all transaction and interface views
687 *-TR 1049958 FH 10/06/10 - replaced llOKToContinue with llRetVal
688 .oLog.LogResult(llRetVal)
689 .oLog.CloseLog()
690 .Cleanup()
691 v_SysUnLock( lcSyslockTablePath+"SYSLOCK", "EDIIPCPROCESS", goEnv.EnvLogin.cCompany)
692 ENDWITH
693 SELECT(lnOldSelect)
694 RETURN llOKToContinue
695 ENDPROC
696
697 **********************************************************************************************
698
699 *--- TR 1034532 NH
700 *--- TR 1036066 NH
701*!* PROCEDURE RemoveValueALLFromEdiStoreForQualifier
702*!*
703*!* LOCAL llRetVal, lnOldSelect, lcSql
704*!* lnOldSelect = SELECT()
705*!* llRetVal = .t.
706*!* lcFilter = IIF(EMPTY(THIS.cFilterCriteria)," where 1=1 ",THIS.cFilterCriteria)
707*!* lcSql = "Update h Set edi_store = '' From zzeipcth h " + lcFilter + ;
708*!* " and exists (select d.pkey from zzeipctd d where d.fkey = h.pkey and d.qualifier not in ('PC','DI')) " + ;
709*!* " and h.edi_store = 'ALL' "
710*!* llRetVal = llRetVal and v_Sqlexec(lcSql)
711*!* SELECT(lnOldSelect)
712*!* RETURN llRetVal
713*!*
714*!* ENDPROC
715 *=== TR 1036066 NH
716 *=== TR 1034532 NH
717 **********************************************************************************************
718
719 *--- TR 1015980 NH
720 **********************************************************************************************
721 PROCEDURE MarkHeaderForAutoProcFlag
722 LPARAMETERS pceIPCth
723 LOCAL llRetVal, lnOldSelect
724 lnOldSelect = SELECT()
725 llRetVal = .t.
726
727 SELECT (pceIPCth)
728 SCAN FOR errs_flg_h <> "Y"
729 *division+customer TAG divcust
730 *--- TR 1017209 NH : need to update auto_proc flag much earlier
731*!* IF EMPTY(auto_proc) AND SEEK(division+customer,'zzeipccr','divcust')
732*!* replace auto_proc with zzeipccr.auto_proc IN (pceIPCth)
733*!* ENDIF
734 *=== TR 1017209 NH
735 IF auto_proc <> "Y"
736 Replace Errs_Msg_H With Errs_Msg_H + EDI_AUTOPROCESS_MSG + CRLF, Errs_Flg_H WITH 'Y' In (pceIPCth)
737 ENDIF
738 ENDSCAN
739
740 RETURN llRetVal
741
742 ENDPROC
743 **********************************************************************************************
744 *=== TR 1015980 NH
745
746 *--- TR 1027127 NH
747 **********************************************************************************************
748 *--- following procedure must call before ExplodeOrderForAllStore(), and PopulateActualStoreForALLStore() function call
749 PROCEDURE MarkForAllStoreFlag
750
751 LOCAL llRetVal, lnOldSelect, lcSQL
752 llRetVal = .t.
753 lnOldSelect = SELECT()
754 LOCAL lcFilter
755 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
756 lcFilter = STRTRAN(lcFilter,"Where","")
757
758 *--- stamp ForAllStore with 'Y' when edi_store is empty and ( either detail has qualifier 'DI' or 'PC' Or no detail at all)
759 lcSQL = "Update h SET ForAllStore = 'Y' FROM zzeipcth h " + ;
760 " WHERE (edi_store = '" + this.cStore_ALL + "'" + ;
761 " OR (store = '' and edi_store = '')) " + ;
762 IIF(EMPTY(lcFilter),""," and " + lcFilter) + ;
763 " and ( exists (select td.pkey from zzeipctd td where h.pkey = td.fkey and td.qualifier in ('DI','PC')) " + ;
764 " or not exists (select td.pkey from zzeipctd td where h.pkey = td.fkey)) " + ;
765 " AND h.ForAllStore <> 'P'"
766
767 llRetVal = llRetVal and v_sqlexec(lcSQL)
768
769 *--- TR 1035409 NH 08/22/08
770 *--- TR 1034532 NH - just cascade from header flag
771*!* lcSQL = "Update d SET ForAllStore = 'Y' FROM zzeipcth h inner join zzeipctd d on h.pkey = d.fkey " + ;
772*!* " WHERE (edi_store = '" + this.cStore_ALL + "'" + ;
773*!* " OR (store = '' and edi_store = ''))" + IIF(EMPTY(lcFilter),""," and " + lcFilter)
774
775*!* lcSQL = "Update d SET ForAllStore = h.forAllStore FROM zzeipcth h inner join zzeipctd d on h.pkey = d.fkey " + ;
776*!* " WHERE d.qualifier in ('DI','PC') " + IIF(EMPTY(lcFilter),""," and " + lcFilter)
777 lcSQL = "Update d SET ForAllStore = h.forAllStore FROM zzeipcth h inner join zzeipctd d on h.pkey = d.fkey " + ;
778 " WHERE h.ForAllStore = 'Y' " + IIF(EMPTY(lcFilter),""," and " + lcFilter)
779
780 *=== TR 1034532 NH
781 llRetVal = llRetVal and v_sqlexec(lcSQL)
782 *=== TR 1035409 NH 08/22/08
783 SELECT(lnOldSelect)
784 RETURN llRetVal
785 ENDPROC
786
787 **********************************************************************************************
788 *=== TR 1027127 NH
789
790 PROCEDURE QueryTransaction
791 PARAMETERS pcFilterCriteria
792 LOCAL llRetVal, lcSQLSelect, lcSQLOrder
793 llRetVal = .T.
794 lnOldSelect = SELECT()
795
796 LOCAL l_nThermoCnt
797 l_nThermoCnt = 0
798 WITH THIS
799 .oLog.LogEntry("Creating transaction views.")
800 THIS.InitThermoWithCaption(@l_nThermoCnt, 5, "Creating and open transaction views...")
801
802 * create EDIiPC work table views
803 lcSQLOrder = " customer, isa_num, po_num, store "
804 lcSQLSelect = "select h.* from zzeiPCth h " + pcFilterCriteria
805 THIS.CreateSQLView("VzzeiPCth_iPCproc", lcSQLSelect,, lcSQLOrder)
806 THIS.AdvanceThermoPlus(@l_nThermoCnt)
807
808 lcSQLOrder = " sku, upc, ean "
809 lcSQLSelect = "select * from zzeiPCtd where fkey in (select h.pkey from zzeiPCth h " +;
810 pcFilterCriteria + ")"
811 THIS.CreateSQLView("VzzeiPCtd_iPCproc", lcSQLSelect,, lcSQLOrder)
812 THIS.AdvanceThermoPlus(@l_nThermoCnt)
813
814 *---TR 1041527 08/11/09 CM --- This fix was originally done in TR 1040105
815 lcSQLOrder = ""
816 *===TR 1041527 08/11/09 CM
817
818 lcSQLSelect = "select * from zzeiPCtc where fkey in (select h.pkey from zzeiPCth h " +;
819 pcFilterCriteria + ")"
820 THIS.CreateSQLView("VzzeiPCtc_iPCproc", lcSQLSelect,, lcSQLOrder)
821 THIS.AdvanceThermoPlus(@l_nThermoCnt)
822
823 *--- TR 1016589 05/08/06 NH
824 lcSQLSelect = "select * from sysnotes where table_name = 'ZZEIPCTH' " + ;
825 " AND fkey in (select h.pkey from zzeiPCth h " +;
826 pcFilterCriteria + ")"
827 THIS.CreateSQLView("Vnotes_IPCH_iPCproc", lcSQLSelect)
828 THIS.AdvanceThermoPlus(@l_nThermoCnt)
829
830 lcSQLSelect = "select * from sysnotes where table_name = 'ZZEIPCTD' " + ;
831 " AND fkey in (select d.pkey from zzeiPCtd d inner join zzeiPCth h on h.pkey = d.fkey " +;
832 pcFilterCriteria + ")"
833 THIS.CreateSQLView("Vnotes_IPCD_iPCproc", lcSQLSelect)
834 THIS.AdvanceThermoPlus(@l_nThermoCnt)
835
836 *=== TR 1016589 NH
837
838 * --- TR 1047609 7/7/10 CM
839 lcSQLSelect = "select * from zzeiPCts where fkey in (select d.Pkey from zzeiPCth h " +;
840 "join zzeiPCtd d on d.Fkey = h.Pkey "+ pcFilterCriteria + ")"
841 This.CreateSQLView("VzzeiPCts_iPCproc", lcSQLSelect)
842 This.AdvanceThermoPlus(@l_nThermoCnt)
843 * === TR 1047609 7/7/10 CM
844
845 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
846 lcSQLSelect = "select * from zzeiPCta where fkey in (select h.pkey from zzeiPCth h " +;
847 pcFilterCriteria + ")"
848 This.CreateSQLView("VzzeiPCta_iPCproc", lcSQLSelect)
849 This.AdvanceThermoPlus(@l_nThermoCnt)
850
851 lcSQLSelect = "select * from zzeiPCtWhse where Hfkey in (select H.Pkey from zzeiPCth h " +;
852 "join zzeiPCtd d on d.Fkey = h.Pkey " + pcFilterCriteria + ")"
853 This.CreateSQLView("VzzeipctWhse_iPCproc", lcSQLSelect,,"NoOrderBy")
854 This.AdvanceThermoPlus(@l_nThermoCnt)
855
856 *.CreateSQLView("Vzzedatawhse_iPCproc","Select * from zzedatawhse where 0=1","zzedatawhse","NoOrderBy")
857 This.AdvanceThermoPlus(@l_nThermoCnt)
858 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
859
860 .oLog.LogEntry("Opening transaction views.")
861 lnCursorBuffer = DB_BUFOPTRECORD
862
863 *--- TR 1016589 NH : ADD notes table to opentable
864 IF !(THIS.OPENTABLE("VzzeiPCth_iPCproc",, .T.,,lnCursorBuffer) AND ;
865 THIS.OPENTABLE("VzzeiPCtd_iPCproc",, .T.,,lnCursorBuffer) AND ;
866 THIS.OPENTABLE("VzzeiPCtc_iPCproc",, .T.,,lnCursorBuffer) AND ;
867 THIS.OPENTABLE("Vnotes_IPCH_iPCproc",, .T.,,lnCursorBuffer) AND ;
868 THIS.OPENTABLE("VzzeiPCts_iPCproc",, .T.,,lnCursorBuffer) AND ; && TechRec 1047609 7/7/10 CM
869 THIS.OPENTABLE("Vnotes_iPCD_iPCproc",, .T.,,lnCursorBuffer) AND ;
870 THIS.OPENTABLE("VzzeiPCta_iPCproc",, .T.,,lnCursorBuffer) AND ; &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
871 THIS.OPENTABLE("VzzeipctWhse_iPCproc",, .T.,,lnCursorBuffer)) &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
872 llRetVal = .F.
873 ELSE
874 .oLog.LogEntry("Indexing transaction views.")
875 THIS.AdvanceThermoPlus(@l_nThermoCnt)
876 * create index for optimizing
877 SELECT VzzeiPCth_iPCproc
878 INDEX ON pkey TAG pkey
879 INDEX ON doc_num TAG doc_num
880 INDEX ON Errs_flg_h TAG ErrsFlgH
881
882
883 SELECT VzzeiPCtd_iPCproc
884 INDEX ON ALLTRIM(STR(doc_num))+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) TAG Ckey
885 INDEX ON pkey TAG pkey
886 INDEX ON fkey TAG fkey
887 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
888 INDEX ON doc_num TAG doc_num
889
890 * --- TR 1047609 7/7/10 CM
891 *--- TR 1101352 17-JAN-2017 HGORE - commented & added to replace 'poc_line' instead of 'PO1_Line' ---
892 *INDEX ON STR(doc_num)+PO1_Line TAG PO1_Line
893 INDEX ON STR(doc_num)+POC_Line TAG PO1_Line
894 * === TR 1047609 7/7/10 CM
895
896 SET ORDER TO TAG doc_num
897
898 SELECT VzzeiPCtc_iPCproc
899 INDEX ON pkey TAG pkey
900 INDEX ON fkey TAG fkey
901 INDEX ON doc_num TAG doc_num
902
903
904 *--- TR 1016589 NH
905 SELECT Vnotes_IPCH_iPCproc
906 INDEX ON pkey TAG pkey
907 INDEX ON fkey TAG fkey
908
909
910 SELECT Vnotes_IPCD_iPCproc
911 INDEX ON pkey TAG pkey
912 INDEX ON fkey TAG fkey
913 INDEX ON STR(fkey) + Note_type TAg fkeyNtTpy
914
915 *=== TR 1016589 NH
916
917 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
918 Select VzzeiPCta_iPCproc
919 Index On pkey Tag pkey
920 Index On fkey Tag fkey
921 Index On doc_num Tag doc_num
922
923 .SetBufferMode("VzzeiPCta_iPCproc", DB_BufOptTable)
924
925 .SetBufferMode("VzzeiPCtWhse_iPCproc", DB_BUFOPTRECORD)
926 Select VzzeiPCtWhse_iPCproc
927 Index On pkey Tag pkey
928 Index On hfkey Tag hfkey
929 Index On dfkey Tag dfkey
930 Index On sfkey Tag sfkey
931 Index On doc_num Tag doc_num
932 Index On Str(doc_num) + edi_line Tag Whse_Line && PO1_Line
933 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
934 Index On Alltrim(Str(hfkey)) + Alltrim(Str(dfkey)) Tag h_dfkey
935 .SetBufferMode("VzzeiPCtWhse_iPCproc", DB_BufOptTable)
936 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
937
938 * set table buffer to 5
939 .SetBufferMode("VzzeiPCth_iPCproc", DB_BUFOPTTABLE)
940 .SetBufferMode("VzzeiPCtd_iPCproc", DB_BUFOPTTABLE)
941 .SetBufferMode("VzzeiPCtc_iPCproc", DB_BUFOPTTABLE)
942 *--- TR 1016589 NH
943 .SetBufferMode("Vnotes_IPCH_iPCproc", DB_BUFOPTTABLE)
944 .SetBufferMode("Vnotes_IPCD_iPCproc", DB_BUFOPTTABLE)
945 *=== TR 1016589 NH
946
947 * --- TR 1047609 7/7/10 CM
948 .SetBufferMode("VzzeiPCts_iPCproc", DB_BUFOPTRECORD)
949 Select VzzeiPCts_iPCproc
950 Index On doc_num Tag doc_num
951 Index On Str(doc_num)+SLN_Line Tag SLN_Line && PO1_Line
952 INDEX on pkey Tag pkey
953 Index On fkey Tag fkey
954 .SetBufferMode("VzzeiPCts_iPCproc", DB_BufOptTable)
955 * === TR 1047609 7/7/10 CM
956
957 ENDIF
958
959 * Query for all control locally (--need to join with
960 * local cursor lots to get flags/parameters for the process)
961 .oLog.LogEntry("Retrieving 860(i) Control References.")
962 lcSQLString = "SELECT * FROM zzeipcCR"
963 *--- TR 1019356 NH
964 *llRetVal = v_SqlPrep(lcSQLString, "zzeipccr")
965 llRetVal = llRetVal and v_SqlExec(lcSQLString, "zzeipccr")
966 *=== TR 1019356 NH
967 IF llRetVal
968 SELECT zzeipccr
969
970 *--- TR 1048865 24-Dec-2010 Goutam
971 INDEX on pkey TAG pkey
972 *=== TR 1048865 24-Dec-2010 Goutam
973
974 INDEX ON customer TAG customer
975 INDEX ON division TAG division
976 INDEX ON division+customer TAG divcust
977 ENDIF
978
979 .oLog.LogEntry("Retrieving Customer Label References.")
980 lcSQLString = "SELECT * FROM zzxclblr"
981 *--- TR 1019356 NH
982 *llHaveRec = v_SqlPrep(lcSQLString, "zzxclblr")
983 *IF llHaveRec
984 llRetVal = llRetVal and v_SqlExec(lcSQLString, "zzxclblr")
985 IF llRetVal
986 llHaveRec = RECCOUNT("zzxclblr")
987 *=== TR 1019356 NH
988 SELECT zzxclblr
989 INDEX ON customer TAG customer
990 INDEX ON lbl_code TAG lbl_code
991 ENDIF
992
993 *--- TR 1015747 02/24/06 NH
994 * create transaction R/W cursor from views
995 IF llRetVal &&continue it successfully table update Inter. and Trans. views
996
997 .oLog.LogEntry("Creating transaction header cursors from views.")
998 .AdvanceThermoTotalWithCaptionPlus("Creating temporary transaction cursors...", ;
999 vcLogName)
1000
1001 *--- TR 1062197 13-Sep-2012 Goutam. Added consol_code
1002 *--- TR 1085815 27-Mar-2015 BNarayanan added SPACE(3) as ord_type, ---
1003 SELECT SPACE(3) as ord_type, SPACE(5) as consol_code, * FROM VzzeiPCth_iPCproc INTO CURSOR __EiPCth
1004 THIS.MakeCursorWritable("__EiPCth", "tcEiPCth")
1005 SELECT tcEiPCth
1006 .niPCOrderHeader= THIS.CountTotalRecs ("tcEiPCth")
1007 INDEX ON impl_ok TAG ImplOK FOR impl_ok = '' && TR 1041492 JUL-20-2009 BR
1008 INDEX ON customer+po_num TAG custpo && TR 1023071
1009 INDEX ON pkey TAG pkey
1010
1011 .oLog.LogEntry("Creating transaction detail cursors from views.")
1012 * --- TR 1047609 7/7/10 CM --- Added Style_SLN_OK
1013 SELECT SPACE(7) AS customer, " " AS Style_SLN_OK, * FROM VzzeiPCtd_iPCproc INTO CURSOR __eipcTD
1014
1015 THIS.MakeCursorWritable("__eiPCtd", "tcEiPCtd")
1016 .TableClose('__eipCTD')
1017
1018 SELECT tcEiPCtd
1019 .niPCOrderDetail= THIS.CountTotalRecs ("tcEiPCtd")
1020 INDEX ON pkey TAG pkey
1021 INDEX ON fkey TAG fkey
1022 INDEX ON qualifier TAG qualifier && TR 1019356 NH
1023 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1024
1025 *--- TechRec 1073591 31-Oct-2013 TShenbagavalli ---
1026 *--- TR 1101352 17-JAN-2017 HGORE - commented & added to replace 'poc_line' instead of 'PO1_Line' ---
1027 *Index On Str(doc_num)+PO1_Line Tag PO1_Line
1028 Index On Str(doc_num)+POC_Line Tag PO1_Line
1029 *=== TechRec 1073591 31-Oct-2013 TShenbagavalli ===
1030
1031
1032 SELECT * FROM VzzeiPCtc_iPCproc INTO CURSOR __EiPCtc
1033 THIS.MakeCursorWritable("__EiPCtc", "tcEiPCtc")
1034 SELECT tcEiPCtc
1035 INDEX ON fkey TAG fkey
1036 .lHaveComment= (THIS.CountTotalRecs ("tcEiPCtc")> 0)
1037
1038 * --- TR 1047609 7/7/10 CM
1039 Select *, ' ' As customer From VzzeiPCts_iPCproc Into Cursor __EiPCts
1040 This.MakeCursorWritable("__EiPCts", "tcEiPCts")
1041 Select tcEiPCts
1042 Index On pkey Tag pkey
1043 Index On fkey Tag fkey
1044 Index On customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) Tag CstBcSku
1045 .lHaveSLN = Reccount('tcEiPCts') > 0
1046 * === TR 1047609 7/7/10 CM
1047
1048 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1049 Select * From VzzeiPCta_iPCproc Into Cursor __EiPCta
1050 This.MakeCursorWritable("__EiPCta", "tcEiPCta")
1051 Select tcEiPCta
1052 .lHaveAddress= (This.CountTotalRecs ("tcEiPCta")> 0)
1053 Select Count(*) ;
1054 FROM tcEiPCta ;
1055 WHERE addr_type = 'OT' ; &&One Time
1056 Into Array laCnt
1057
1058 .lHaveOneTimeShippingAddress= (laCnt[1] > 0)
1059
1060 SELECT * FROM VzzeiPCtwhse_iPCproc INTO CURSOR __EiPCtwhse
1061 THIS.MakeCursorWritable("__EiPCtwhse", "tcEiPCtwhse")
1062 SELECT tcEiPCtwhse
1063 Index On hfkey Tag hfkey
1064 Index On dfkey Tag dfkey
1065 Index On sfkey Tag sfkey
1066 Index On doc_num Tag doc_num
1067 Index On Str(doc_num) + edi_line Tag Whse_Line && PO1_Line
1068 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
1069 Index On Alltrim(Str(hfkey)) + Alltrim(Str(dfkey)) Tag h_dfkey
1070 .lHaveWhse = (THIS.CountTotalRecs ("tcEiPCtwhse")> 0)
1071 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1072
1073 ENDIF
1074 *=== TR 1015747 02/24/06 NH
1075
1076 THIS.ResetThermoPlus()
1077 ENDWITH
1078 SELECT(lnOldSelect)
1079 RETURN llRetVal
1080 ENDPROC
1081
1082 *- If we decide to create Interface views - it has to be done here.
1083 PROCEDURE CreateiPCViews
1084 LOCAL llRetVal, lcSQLSelect, lcSQLOrder
1085 llRetVal = .T.
1086 lnOldSelect = SELECT()
1087
1088 LOCAL l_nThermoCnt
1089 l_nThermoCnt = 0
1090 *--- TR 1015747 02/24/06 NH
1091 WITH THIS
1092*!* .oLog.LogEntry("Creating views.")
1093*!* THIS.InitThermoWithCaption(@l_nThermoCnt, 5, "Creating and open transaction, history views...")
1094
1095 .oLog.LogEntry("Creating IPC views.")
1096 *--- added thermo counter
1097 THIS.InitThermoWithCaption(@l_nThermoCnt, 7, "Creating and open transaction views...")
1098
1099 * create EDIiPC work table views
1100 lcSQLOrder = " customer, isa_num, po_num, store "
1101 lcSQLSelect = "select h.* from zzeiPCth h WHERE 1 = 0"
1102 THIS.CreateSQLView("VzzeiPCth_iPCproc", lcSQLSelect,, lcSQLOrder)
1103 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1104
1105 lcSQLOrder = " sku, upc, ean "
1106 lcSQLSelect = "select * from zzeiPCtd where 1 = 0"
1107 THIS.CreateSQLView("VzzeiPCtd_iPCproc", lcSQLSelect,, lcSQLOrder)
1108 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1109
1110 lcSQLOrder = "" && TR 1016560 NH
1111 lcSQLSelect = "select * from zzeiPCtc where 1 = 0"
1112 THIS.CreateSQLView("VzzeiPCtc_iPCproc", lcSQLSelect,, lcSQLOrder)
1113 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1114
1115 *--- TR 1016589 05/08/06 NH
1116 lcSQLSelect = "select * from sysnotes where 1 = 0 "
1117 THIS.CreateSQLView("Vnotes_ipch_iPCproc", lcSQLSelect)
1118 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1119
1120 lcSQLSelect = "select * from sysnotes where 1 = 0 "
1121 THIS.CreateSQLView("Vnotes_ipcd_iPCproc", lcSQLSelect)
1122 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1123 *=== TR 1016589 05/08/06 NH
1124
1125 * --- TR 1047609 7/7/10 CM
1126 lcSQLSelect = "select * from zzeipcts where 1 = 0 "
1127 THIS.CreateSQLView("Vzzeipcts_iPCproc", lcSQLSelect,,"NoOrderBy")
1128 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1129 * === TR 1047609 7/7/10 CM
1130
1131 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1132 lcSQLSelect = "select * from zzeipcta where 1 = 0 "
1133 THIS.CreateSQLView("VzzeiPCta_iPCproc", lcSQLSelect,,"NoOrderBy")
1134 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1135
1136 lcSQLSelect = "select * from zzeipctwhse where 1 = 0 "
1137 THIS.CreateSQLView("Vzzeipctwhse_iPCproc", lcSQLSelect,,"NoOrderBy")
1138 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1139 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1140
1141 .oLog.LogEntry("Opening transaction views.")
1142 lnCursorBuffer = DB_BUFOPTRECORD
1143
1144 *--- TR 1016589 nh : added notes cursor in opentable condition
1145 IF !(THIS.OPENTABLE("VzzeiPCth_iPCproc",, .T.,,lnCursorBuffer) AND ;
1146 THIS.OPENTABLE("VzzeiPCtd_iPCproc",, .T.,,lnCursorBuffer) AND ;
1147 THIS.OPENTABLE("VzzeiPCtc_iPCproc",, .T.,,lnCursorBuffer) AND ;
1148 THIS.OPENTABLE("Vnotes_ipch_iPCproc",, .T.,,lnCursorBuffer) AND ;
1149 THIS.OPENTABLE("Vnotes_ipcd_iPCproc",, .T.,,lnCursorBuffer) AND ;
1150 THIS.OPENTABLE("VzzeiPCts_iPCproc",, .T.,,lnCursorBuffer) AND ; && TR 1047609 7/7/10 CM
1151 THIS.OPENTABLE("VzzeiPCta_iPCproc",, .T.,,lnCursorBuffer) AND ; &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1152 THIS.OPENTABLE("VzzeiPCtwhse_iPCproc",, .T.,,lnCursorBuffer)) &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1153
1154 llRetVal = .F.
1155 ELSE
1156 .oLog.LogEntry("Indexing transaction views.")
1157 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1158 * create index for optimizing
1159 SELECT VzzeiPCth_iPCproc
1160 INDEX ON pkey TAG pkey
1161 INDEX ON doc_num TAG doc_num
1162 INDEX ON Errs_flg_h TAG ErrsFlgH
1163 *--- TR 1036066 NH
1164 INDEX ON edi_store TAG edi_store
1165 *=== TR 1036066 NH
1166
1167 SELECT VzzeiPCtd_iPCproc
1168 INDEX ON ALLTRIM(STR(doc_num))+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) TAG Ckey
1169 INDEX ON pkey TAG pkey
1170 INDEX ON fkey TAG fkey
1171 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1172 * --- TR 1047609 7/7/10 CM
1173 *--- TR 1101352 17-JAN-2017 HGORE - commented & added to replace 'poc_line' instead of 'PO1_Line' ---
1174 *INDEX ON STR(doc_num)+PO1_Line TAG PO1_Line
1175 INDEX ON STR(doc_num)+POC_Line TAG PO1_Line
1176 *=== TR 1101352 17-JAN-2017 HGORE ===
1177 * === TR 1047609 7/7/10 CM
1178 INDEX ON doc_num TAG doc_num
1179
1180 *--- TR 1101352 14-MAR-2017 HGORE Added '+po1_line' ===
1181 INDEX on STR(fkey)+upc+sku+line_id+po1_line DESCENDING TAG dupdele &&--- TechRec 1073148 06-Aug-2014 asharma ===
1182
1183 SET ORDER TO TAG doc_num
1184
1185 SELECT VzzeiPCtc_iPCproc
1186 INDEX ON pkey TAG pkey
1187 INDEX ON fkey TAG fkey
1188 INDEX ON doc_num TAG doc_num
1189
1190 *--- TR 1016589 NH
1191 SELECT Vnotes_IPCH_iPCproc
1192 INDEX ON pkey TAG pkey
1193 INDEX ON fkey TAG fkey
1194
1195 SELECT Vnotes_IPCD_iPCproc
1196 INDEX ON pkey TAG pkey
1197 INDEX ON fkey TAG fkey
1198 *=== TR 1016589 NH
1199
1200 * --- TR 1047609 7/7/10 CM
1201 SELECT VzzeiPCts_iPCproc
1202 Index On doc_num Tag doc_num
1203 Index On Str(doc_num)+SLN_Line Tag SLN_Line && PO1_Line
1204 Index On fkey Tag fkey
1205 * === TR 1047609 7/7/10 CM
1206
1207 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1208 Select VzzeiPCta_iPCproc
1209 Index On pkey Tag pkey
1210 Index On fkey Tag fkey
1211 Index On doc_num Tag doc_num
1212 .SetBufferMode("VzzeiPCta_iPCproc", DB_BufOptTable)
1213
1214 SELECT VzzeiPCtwhse_iPCproc
1215 Index On pkey Tag pkey
1216 Index On hfkey Tag hfkey
1217 Index On dfkey Tag dfkey
1218 Index On doc_num Tag doc_num
1219 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
1220 .SetBufferMode("VzzeiPCtwhse_iPCproc", DB_BUFOPTTABLE)
1221 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1222
1223 * set table buffer to 5
1224 .SetBufferMode("VzzeiPCth_iPCproc", DB_BUFOPTTABLE)
1225 .SetBufferMode("VzzeiPCtd_iPCproc", DB_BUFOPTTABLE)
1226 .SetBufferMode("VzzeiPCtc_iPCproc", DB_BUFOPTTABLE)
1227 .SetBufferMode("Vnotes_IPCH_iPCproc", DB_BUFOPTTABLE)
1228 .SetBufferMode("Vnotes_IPCD_iPCproc", DB_BUFOPTTABLE)
1229 * --- TR 1047609 7/7/10 CM --- Setting table buffering at this point
1230 .SetBufferMode("VzzeiPCts_iPCproc", DB_BUFOPTTABLE)
1231 * === TR 1047609 7/7/10 CM
1232
1233
1234 ENDIF
1235 ENDWITH
1236 *=== TR 1015747 02/24/06 NH
1237 THIS.ResetThermoPlus()
1238 SELECT(lnOldSelect)
1239 RETURN llRetVal
1240 ENDPROC
1241
1242 PROCEDURE LoadFromFlatfileToTransaction
1243 LOCAL llRetVal
1244 llRetVal = .T.
1245 * --- TR 1047609 7/7/10 CM --- Added lciPCSLNFlatFile
1246 LOCAL lnCurrentHeaderPkey, lnCurrentHeaderDoc_num, lnPriorHeaderPkey, lnCurrentDetailDoc_num,;
1247 lnLine_seq, lciPCHNTFlatFile, lciPCDNTFlatFile, lciPCSLNFlatFile
1248
1249 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1250 LOCAL lciPCAddrFlatFile, lciPCEDIHFlatFile, lciPCEDIDFlatFile, lciPCEDISFlatFile, lciPCAddrFlatFilepri, lciPCEDIHFlatFilePri, lciPCEDIDFlatFilePri, ;
1251 lciPCEDISFlatFilePri
1252 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1253
1254 lnCurrentHeaderPkey= 0
1255 lnCurrentHeaderDoc_num= 0
1256 lnCurrentDetailDoc_num=0
1257 lnLine_seq= 0
1258 lnCurrentHeaderStore=""
1259 lnOldSelect = SELECT()
1260
1261 WITH THIS
1262 .LogMajorStage("Loading flatfile to transaction tables.") && TR 1016560 NH
1263 * 1. Load from flatfile into transaction tables directlty
1264 .AdvanceThermoTotalWithCaptionPlus("Loading data from flatfile to transaction tables...", ;
1265 vcLogName)
1266 *--- TR 1015983 NH
1267
1268 IF .TIE_Setup
1269 .oLog.LogEntry("Splitting 860(i) flat file.")
1270 IF .SplitFlatFile("860.dat") && splits into 850hdr.dat, 850dtl.dat etc., renames 850.dat to .pri
1271 IF !.RenFileDat("860.pri") && timestamps 850.pri
1272 .oLog.LogEntry("Timestamping 860(i) flat file - FAILED.")
1273 ENDIF
1274 ELSE
1275 .oLog.LogEntry("Splitting 860(i) flat file - FAILED.")
1276 ENDIF
1277 ENDIF
1278
1279 *=== TR 1015983 NH
1280
1281 lcEDIPath = THIS.GetEDIFlatFileDirectory("Inbound")
1282 lciPCHeaderFlatFile = UPPER(lcEDIPath + "860hdr.dat")
1283 lciPCDetailFlatFile = UPPER(lcEDIPath + "860dtl.dat")
1284 lciPCSDQFlatFile = UPPER(lcEDIPath + "860sdq.dat")
1285 lciPCHNTFlatFile = UPPER(lcEDIPath + "860hnt.dat")
1286 lciPCDNTFlatFile = UPPER(lcEDIPath + "860dnt.dat")
1287 lciPCCommentFlatFile = UPPER(lcEDIPath + "860cmt.dat")
1288
1289 * --- TR 1047609 7/7/10 CM
1290 lciPCSLNFlatFile = UPPER(lcEDIPath + "860sln.dat")
1291 * === TR 1047609 7/7/10 CM
1292
1293 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
1294 lciPCEDIHFlatFile = UPPER(lcEDIPath + "860edih.dat")
1295 lciPCEDIDFlatFile = UPPER(lcEDIPath + "860edid.dat")
1296 lciPCEDISFlatFile = UPPER(lcEDIPath + "860edis.dat")
1297 lciPCAddrFlatFile = UPPER(lcEDIPath + "860adr.dat")
1298 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
1299
1300 .oLog.LogEntry("Loading 860(i) flatfiles.")
1301 *--- TR 1016589 NH 05/08/06 - added two param "Vnotes_IPCH_iPCproc", "VzzeiPCtd_notes_iPCproc"
1302 * --- TR 1047609 7/7/10 CM --- Added lciPCSLNFlatFile, "ZZEIPCTS", VzzeiPCts_iPCproc
1303 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli added lciPCAddressFlatFile, VzzeiPCta_iPCproc, ZZEIPCTA ===
1304 llRetVal= .LoadFromFlatFile("IPC", lciPCHeaderFlatFile, lciPCDetailFlatFile, lciPCCommentFlatFile, ;
1305 lciPCSDQFlatFile, lciPCHNTFlatFile, lciPCDNTFlatFile, lciPCSLNFlatFile, ;
1306 "VzzeiPCth_iPCproc", "VzzeiPCtd_iPCproc", "VzzeiPCtc_iPCproc", "VzzeiPCts_iPCproc", ;
1307 "ZZEIPCTH", "ZZEIPCTD", "ZZEIPCTC", "ZZEIPCTS", "Vnotes_IPCH_iPCproc", "Vnotes_IPCD_iPCproc", ;
1308 lciPCAddrFlatFile, "VzzeiPCta_iPCproc", "ZZEIPCTA" )
1309 * .nTranHeader, .nTranDetail
1310
1311 .oLog.LogEntry("Replace all error message with not yet process.")
1312 REPLACE ALL Errs_flg_h WITH "Y", Errs_msg_H WITH Errs_msg_H + " Not yet processed. " ;
1313 IN VzzeiPCth_iPCproc
1314
1315 * -- TR 1042514 DEC-4-2009 BR
1316 REPLACE ALL Pending_flg WITH 'Y' FOR Pending_flg <> 'N' IN VzzeiPCth_iPCproc
1317 * == TR 1042514 DEC-4-2009 BR
1318
1319 *--- TR 1036066 NH : remove ALL key word from edi_store field
1320 LOCAL lcPrevOrderBy
1321 SELECT VzzeiPCth_iPCproc
1322 lcPrevOrderBy = ORDER()
1323 SET ORDER TO edi_store
1324 *--- TR 1044959 BR
1325*!* IF SEEK(THIS.cStore_ALL,"VzzeiPCth_iPCproc","edi_store")
1326*!* SCAN WHILE edi_store = THIS.cStore_ALL
1327*!* replace edi_store WITH " " IN VzzeiPCth_iPCproc
1328*!* ENDSCAN
1329*!* ENDIF
1330 DO WHILE SEEK(THIS.cStore_ALL,"VzzeiPCth_iPCproc","edi_store")
1331 replace edi_store WITH " " IN VzzeiPCth_iPCproc
1332 ENDDO
1333
1334 *--- TR 1066871 13-May-2013 Goutam
1335 IF llRetVal AND USED(this.c850RefCursor) AND RECCOUNT(this.c850RefCursor) > 0
1336 llRetVal = .SetRelation("VzzeiPCth_iPCproc", "DOC_NUM", this.c850RefCursor, "DOC_NUM")
1337 IF llRetVal
1338 Select VzzeiPCth_iPCproc
1339 Replace All PROC_850 With 'Y' FOR !EOF(this.c850RefCursor)
1340 ENDIF
1341 Set Relation To
1342 ENDIF
1343 *=== TR 1066871 13-May-2013 Goutam
1344
1345 *=== TR 1044959 BR
1346 SET ORDER TO lcPrevOrderBy
1347 *=== TR 1036066 NH
1348
1349 *--- TechRec 1022169 28-Jun-2007 jjanand ---
1350 llRetVal= llRetVal And .RemoveDuplicatePOC()
1351 *=== TechRec 1022169 28-Jun-2007 jjanand ===
1352
1353 * 3. Tableupdate trans. views before rename DAT to PRI
1354 IF llRetVal
1355 .oLog.LogEntry("Sending transaction tables to server.")
1356 .AdvanceThermoTotalWithCaptionPlus("Sending transaction tables to server...", ;
1357 vcLogName)
1358 *--- TR 1016589 NH : added Notes tables to update
1359 *LOCAL laTables[2], llBeganTransaction
1360
1361 * --- TR 1047609 7/7/10 CM
1362 *LOCAL laTables[5], llBeganTransaction
1363 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli changed from 6 to 8 ===
1364 &&--- TechRec 1078492 05-Jun-2014 TSV changed from 8 to 9 ===
1365 LOCAL laTables[9], llBeganTransaction
1366 * === TR 1047609 7/7/10 CM
1367
1368 laTables[1] = "VzzeiPCth_iPCproc"
1369 laTables[2] = "VzzeiPCtd_iPCproc"
1370 laTables[3] = "VzzeiPCtc_iPCproc"
1371 laTables[4] = "Vnotes_IPCH_iPCproc"
1372 laTables[5] = "Vnotes_IPCD_iPCproc"
1373
1374 * --- TR 1047609 7/7/10 CM
1375 laTables[6] = "VzzeiPCts_iPCproc"
1376 * === TR 1047609 7/7/10 CM
1377
1378 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1379 laTables[7] = "VzzeiPCtwhse_iPCproc"
1380 laTables[8] = "VzzeiPCta_iPCproc"
1381 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1382
1383 *--- TechRec 1078492 05-Jun-2014 TSV---
1384 laTables[9] = "VzzeiPCts_iPCproc"
1385 *=== TechRec 1078492 05-Jun-2014 TSV===
1386
1387 llBeganTransaction = THIS.BeginTransaction()
1388 llRetVal = IIF(!THIS.TABLEUPDATE(@laTables), .F., .T.)
1389 IF llRetVal
1390 IF llBeganTransaction
1391 THIS.EndTransaction()
1392 ENDIF
1393 ELSE
1394 IF llBeganTransaction
1395 THIS.RollbackTransaction()
1396 ENDIF
1397 ENDIF
1398
1399 *--- TR 1027724 NH
1400 *--- TR 1022465 NH 03/12/07
1401*!* IF llRetVal AND llBeganTransaction
1402*!* *--- expode orders with no dtl and no sdq
1403*!* llRetval = llRetVal and this.ExplodeOrderForAllStore("VzzeiPCth_iPCproc")
1404*!* ENDIF
1405 *=== TR 1022465 NH 03/12/07
1406 *=== TR 1027724 NH
1407 *--- TR 1016589 NH : Rem out: in case following table update fails than we will have a header with no deatil scenario
1408*!* llBeganTransaction = THIS.BeginTransaction()
1409*!* llRetVal = IIF(!THIS.TABLEUPDATE("VzzeiPCtd_iPCproc"), .F., .T.)
1410*!* IF llRetVal
1411*!* IF llBeganTransaction
1412*!* THIS.EndTransaction()
1413*!* ENDIF
1414*!* ELSE
1415*!* IF llBeganTransaction
1416*!* THIS.RollbackTransaction()
1417*!* ENDIF
1418*!* ENDIF
1419
1420 *--- GS Notes: It would be better to use ForceExt(<lcFileName>, "PRI") here instead of StrTran(<lcFileName>, ".DAT", ".PRI")
1421 IF llRetVal && COMMIT successful
1422 * Delete *.pri and rename from *.dat to *.pri
1423 lciPCHeaderFlatFilePri= STRTRAN(lciPCHeaderFlatFile, ".DAT", ".PRI") && ".pri"
1424 lciPCDetailFlatFilePri= STRTRAN(lciPCDetailFlatFile, ".DAT", ".PRI") && ".pri"
1425 lciPCSDQFlatFilePri= STRTRAN(lciPCSDQFlatFile, ".DAT", ".PRI")
1426 lciPCHNTFlatFilePri= STRTRAN(lciPCHNTFlatFile, ".DAT", ".PRI")
1427 lciPCDNTFlatFilePri= STRTRAN(lciPCDNTFlatFile, ".DAT", ".PRI")
1428 lciPCCommentFlatFilePri= STRTRAN(lciPCCommentFlatFile, ".DAT", ".PRI")
1429
1430 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1431 lciPCAddrFlatFilePri= Strtran(lciPCAddrFlatFile, ".DAT", ".PRI")
1432 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1433
1434 * --- TR 1047609 7/7/10 CM
1435 lciPCSLNFlatFilePri= STRTRAN(lciPCSLNFlatFile, ".DAT", ".PRI")
1436 * === TR 1047609 7/7/10 CM
1437
1438 .oLog.LogEntry("Renaming 860(i) flatfiles.")
1439 IF FILE(lciPCHeaderFlatFile)
1440 .oLog.LogEntry("Renaming 860(i) header : " + lciPCHeaderFlatFilePri )
1441 COPY FILE (lciPCHeaderFlatFile) TO (lciPCHeaderFlatFilePri)
1442 DELETE FILE (lciPCHeaderFlatFile)
1443 ENDIF
1444
1445 IF FILE(lciPCDetailFlatFile)
1446 .oLog.LogEntry("Renaming 860(i) detail : " + lciPCDetailFlatFilePri )
1447 COPY FILE (lciPCDetailFlatFile) TO (lciPCDetailFlatFilePri)
1448 DELETE FILE (lciPCDetailFlatFile)
1449 ENDIF
1450
1451 IF FILE(lciPCSDQFlatFile)
1452 .oLog.LogEntry("Renaming 860(i) SDQ : " + lciPCSDQFlatFilePri)
1453 COPY FILE (lciPCSDQFlatFile) TO (lciPCSDQFlatFilePri)
1454 DELETE FILE (lciPCSDQFlatFile)
1455 ENDIF
1456
1457 IF FILE(lciPCHNTFlatFile)
1458 .oLog.LogEntry("Renaming 860(i) header notes: " + lciPCHNTFlatFilePri)
1459 COPY FILE (lciPCHNTFlatFile) TO (lciPCHNTFlatFilePri)
1460 DELETE FILE (lciPCHNTFlatFile)
1461 ENDIF
1462
1463 IF FILE(lciPCDNTFlatFile)
1464 .oLog.LogEntry("Renaming 860(i) detail notes: " + lciPCDNTFlatFilePri)
1465 COPY FILE (lciPCDNTFlatFile) TO (lciPCDNTFlatFilePri)
1466 DELETE FILE (lciPCDNTFlatFile)
1467 ENDIF
1468
1469 IF FILE(lciPCCommentFlatFile)
1470 .oLog.LogEntry("Renaming 860(i) comment: " + lciPCCommentFlatFilePri)
1471 COPY FILE (lciPCCommentFlatFile) TO (lciPCCommentFlatFilePri)
1472 DELETE FILE (lciPCCommentFlatFile)
1473 ENDIF
1474
1475 * --- TR 1047609 7/7/10 CM
1476 IF FILE(lciPCSLNFlatFile)
1477 .oLog.LogEntry("Renaming 860(i) SLN : " + lciPCSLNFlatFilePri)
1478 COPY FILE (lciPCSLNFlatFile) TO (lciPCSLNFlatFilePri)
1479 DELETE FILE (lciPCSLNFlatFile)
1480 ENDIF
1481 * === TR 1047609 7/7/10 CM
1482
1483 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1484 If File(lciPCAddrFlatFile)
1485 .oLog.LogEntry("Renaming 860(i)address: " + lciPCAddrFlatFilepri)
1486 Copy File (lciPCAddrFlatFile) To (lciPCAddrFlatFilepri)
1487 Delete File (lciPCAddrFlatFile)
1488 Endif
1489
1490 lciPCEDIHFlatFilePri = Strtran(lciPCEDIHFlatFile, ".DAT", ".PRI")
1491 lciPCEDIDFlatFilePri = Strtran(lciPCEDIDFlatFile, ".DAT", ".PRI")
1492 lciPCEDISFlatFilePri = Strtran(lciPCEDISFlatFile, ".DAT", ".PRI")
1493
1494 IF File(lciPCEDIHFlatFile)
1495 .oLog.LogEntry("Renaming 860(i) EDI Header : " + lciPCEDIHFlatFilePri)
1496 Copy File (lciPCEDIHFlatFile) To (lciPCEDIHFlatFilePri)
1497 Delete File (lciPCEDIHFlatFile)
1498 ENDIF
1499
1500 IF File(lciPCEDIDFlatFile)
1501 .oLog.LogEntry("Renaming 860(i) EDI Detail: " + lciPCEDIDFlatFilePri)
1502 Copy File (lciPCEDIDFlatFile) To (lciPCEDIDFlatFilePri)
1503 Delete File (lciPCEDIDFlatFile)
1504 ENDIF
1505
1506 IF File(lciPCEDISFlatFile)
1507 .oLog.LogEntry("Renaming 860(i) EDI Detail: " + lciPCEDISFlatFilePri)
1508 Copy File (lciPCEDISFlatFile) To (lciPCEDISFlatFilePri)
1509 Delete File (lciPCEDISFlatFile)
1510 ENDIF
1511 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1512
1513 ENDIF
1514 ENDIF
1515
1516 .AdvanceThermoTotalWithCaptionPlus("Refresh transaction base on filter criterias...", ;
1517 vcLogName)
1518 *--- TR 1015747 02/24/06 NH
1519*!* IF llRetVal
1520*!* .oLog.LogEntry("Refresh transaction base on filter criterias.")
1521*!* IF (REQUERY("VzzeipcTH_ipcproc")> 0) AND ;
1522*!* (REQUERY("VzzeipcTD_ipcproc")> 0) AND ;
1523*!* (REQUERY("VzzeipcTC_ipcproc")> 0)
1524*!* ELSE
1525*!* llRetVal= .F.
1526*!* .oLog.LogWarning("Failed to refresh transaction views.")
1527*!* ENDIF
1528*!* ENDIF
1529
1530*!* * 4. create transaction R/W cursor from views
1531*!* IF llRetVal &&continue it successfully table update Inter. and Trans. views
1532
1533*!* .oLog.LogEntry("Creating transaction header cursors from views.")
1534*!* .AdvanceThermoTotalWithCaptionPlus("Creating temporary transaction cursors...", ;
1535*!* vcLogName)
1536
1537*!* SELECT * FROM VzzeiPCth_iPCproc INTO CURSOR __EiPCth
1538*!* THIS.MakeCursorWritable("__EiPCth", "tcEiPCth")
1539*!* SELECT tcEiPCth
1540*!* .niPCOrderHeader= THIS.CountTotalRecs ("tcEiPCth")
1541*!* INDEX ON pkey TAG pkey
1542
1543*!* .oLog.LogEntry("Creating transaction detail cursors from views.")
1544*!* SELECT SPACE(7) AS customer, * FROM VzzeiPCtd_iPCproc INTO CURSOR __eipcTD
1545*!* THIS.MakeCursorWritable("__eiPCtd", "tcEiPCtd")
1546*!* .TableClose('__eipCTD')
1547
1548*!* SELECT tcEiPCtd
1549*!* .niPCOrderDetail= THIS.CountTotalRecs ("tcEiPCtd")
1550*!* INDEX ON pkey TAG pkey
1551*!* INDEX ON fkey TAG fkey
1552*!* INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1553
1554*!* SELECT * FROM VzzeiPCtc_iPCproc INTO CURSOR __EiPCtc
1555*!* THIS.MakeCursorWritable("__EiPCtc", "tcEiPCtc")
1556*!* SELECT tcEiPCtc
1557*!* INDEX ON fkey TAG fkey
1558*!* .lHaveComment= (THIS.CountTotalRecs ("tcEiPCtc")> 0)
1559
1560*!* ENDIF
1561 *- 1014475 12/04/05 YIK
1562 *- Close all views later
1563 * Close all views
1564 *--- TR 1015747 02/24/06 NH : need to close these views because they will be recreated later in QueryTransaction()
1565 IF llRetVal
1566 *--- TR 1016589 NH
1567 *LOCAL laTables[3]
1568 * --- TR 1047609 7/7/10 --- Changed array from 5 to 6
1569 &&--- TechRec 1073591 06-Feb-2014 TShenbagavalli changed array dimension from 6 to 8 ===
1570 LOCAL laTables[8]
1571 laTables[1] = "VzzeiPCth_iPcproc"
1572 laTables[2] = "VzzeiPCtd_iPCproc"
1573 laTables[3] = "VzzeiPCtc_iPCproc"
1574 laTables[4] = "Vnotes_IPCH_iPCproc"
1575 laTables[5] = "Vnotes_IPCD_iPCproc"
1576
1577 * --- TR 1047609 7/7/10 CM
1578 laTables[6] = "Vzzeipcts_iPCproc"
1579 * === TR 1047609 7/7/10 CM
1580
1581 *--- TechRec 1073591 06-Feb-2014 TShenbagavalli ---
1582 laTables[7] = "VzzeipctWhse_iPCproc"
1583 laTables[8] = "Vzzeipcta_iPCproc"
1584 *=== TechRec 1073591 06-Feb-2014 TShenbagavalli ===
1585
1586 .oLog.LogEntry("Close all transaction views.")
1587 llRetVal = THIS.TableClose(@laTables, True) && close and delete all temp views
1588 IF NOT llRetVal
1589 .oLog.LogWarning("Failed to close all transaction views.")
1590 ENDIF
1591 ENDIF
1592 ENDWITH
1593 *=== TR 1015747 02/24/06 NH
1594 SELECT(lnOldSelect)
1595 RETURN llRetVal
1596 ENDPROC
1597 ******************************************************************************
1598 *--- TechRec 1022169 28-Jun-2007 jjanand ---
1599 ** To remove the first occurence (with smaller poc_line) of a duplicate detail
1600 ** in VzzeiPCtd_iPCproc that has the same fkey and upc and keep only the 2nd.
1601 ** The reason is that the 2nd occurence of POC does have the price and qualifier.
1602 PROCEDURE RemoveDuplicatePOC
1603 *--- TR 1101352 14-MAR-2017 HGORE Added ', lcpo1_line' ===
1604 LOCAL llRetVal,lnRecCount,lcsql,tcCheckPoc,lcTmpDuplIPCtdCursor,lcPocKEY,lcUPC,lcFKEY , lcpo1_line
1605
1606 LOCAL lnCountTotalRecs, lcDupKey, lnDuplRecordsRemoved,lcKey &&--- TechRec 1073148 06-Aug-2014 asharma ===
1607
1608 llRetVal = .T.
1609
1610 WITH THIS
1611
1612 .PushRecordSet()
1613
1614 .oLog.LogEntry("Removing Smallest POC Line")
1615
1616 IF USED('VzzeiPCtd_iPCproc')
1617
1618 *--- TechRec 1073148 06-Aug-2014 asharma ---
1619 * CountTotalRecs was killing time with deleted records on large table rec > 100000
1620*!* IF .CountTotalRecs('VzzeiPCtd_iPCproc') > 1
1621
1622*!* .oLog.LogEntry( "Transaction records : " + LTRIM(STR(THIS.CountTotalRecs('VzzeiPCtd_iPCproc'))))
1623 SELECT ('VzzeiPCtd_iPCproc')
1624 tcCheckPoc = GetUniqueFilename()
1625 COPY TO (tcCheckPoc)
1626 USE (tcCheckPoc) IN 0
1627 SELECT (tcCheckPoc)
1628 COUNT TO lnCountTotalRecs
1629 USE IN (tcCheckPoc)
1630 SELECT ('VzzeiPCtd_iPCproc')
1631
1632 IF lnCountTotalRecs > 1
1633
1634 .oLog.LogEntry( "Transaction records : " + LTRIM(STR(lnCountTotalRecs )))
1635
1636 tcCheckPoc = GetUniqueFilename()
1637
1638 IF .lOptmizedExplodeSDQ
1639
1640 .oLog.LogEntry("Removing Smallest POC Line")
1641
1642 SELECT ('VzzeiPCtd_iPCproc')
1643
1644 SET ORDER TO dupdele IN VzzeiPCtd_iPCproc
1645
1646 LOCATE
1647
1648 lcDupKey = '*'
1649 lnDuplRecordsRemoved = 0
1650
1651 SCAN
1652 *--- TR 1101352 14-MAR-2017 HGORE Added '+po1_line' ===
1653 lcKey = STR(fkey)+upc+sku+line_id+po1_line
1654
1655 IF lcKey = lcDupKey
1656 DELETE
1657 lnDuplRecordsRemoved = lnDuplRecordsRemoved + 1
1658 ELSE
1659 lcDupKey = lcKey
1660 ENDIF
1661
1662 ENDSCAN
1663
1664 .oLog.LogEntry( "No. of Smallest POC Line Removed : " + LTRIM(STR(lnDuplRecordsRemoved)))
1665
1666 ELSE
1667
1668 *=== TechRec 1073148 06-Aug-2014 asharma ===
1669
1670
1671 lcTmpDuplIPCtdCursor = GetUniqueFilename()
1672
1673 .RetrieveBufferedDataToCursor('VzzeiPCtd_iPCproc',lcTmpDuplIPCtdCursor)
1674 *--- TR 1101352 14-MAR-2017 HGORE Added ', po1_line' in select list & group by list also ===
1675 lcSql = " SELECT MAX(pkey) " + ;
1676 " AS PocKEY, COUNT(*) " + ;
1677 " AS Line_count,FKEY,UPC,SKU,line_id, po1_line " + ; &&--- TR 1027127 - include SKU
1678 " FROM " + lcTmpDuplIPCtdCursor + ;
1679 " GROUP BY Fkey,UPC,SKU,line_id, po1_line " + ; &&--- TR 1027127
1680 " having Line_count > 1 "
1681
1682 tcCheckPoc = GetUniqueFilename()
1683
1684 llRetval = V_SqlExec(lcSql,tcCheckPoc,,.T.)
1685
1686 IF llRetval
1687
1688 SELECT (tcCheckPoc)
1689
1690 GO TOP
1691 DO WHILE !EOF()
1692 lcUPC = UPC
1693 lcSKU = SKU &&--- TR 1027127
1694 lcline_id = line_id
1695 *--- TR 1101352 14-MAR-2017 HGORE ---
1696 lcpo1_line = po1_line
1697 *=== TR 1101352 14-MAR-2017 HGORE ===
1698 lcFKEY = FKEY
1699 lcPocKEY = PocKEY
1700
1701 DELETE IN VzzeiPCtd_iPCproc ;
1702 FOR VzzeiPCtd_iPCproc.pkey <> lcPocKEY;
1703 AND UPC = lcUPC ;
1704 AND SKU = lcSKU ; &&--- TR 1027127
1705 and line_id = lcline_id ;
1706 and po1_line = lcpo1_line ; && *--- TR 1101352 14-MAR-2017 HGORE ===
1707 AND FKEY = lcFKEY
1708
1709 SKIP
1710 ENDDO
1711 .oLog.LogEntry( "No. of Smallest POC Line Removed : " + LTRIM(STR(THIS.CountTotalRecs(tcCheckPoc,'line_count > 1'))))
1712 .TableClose(tcCheckPoc)
1713 ENDIF
1714 .TableClose(lcTmpDuplIPCtdCursor)
1715
1716 ENDIF && --- TechRec 1073148 06-Aug-2014 asharma ===
1717
1718 ELSE
1719 *--- TechRec 1073148 06-Aug-2014 asharma ---
1720 *.oLog.LogEntry( "Transaction records : " + LTRIM(STR(THIS.CountTotalRecs('VzzeiPCtd_iPCproc'))))
1721 .oLog.LogEntry( "Transaction records : " + LTRIM(STR(lnCountTotalRecs )))
1722 *=== TechRec 1073148 06-Aug-2014 asharma ===
1723 ENDIF
1724 ELSE
1725 .oLog.LogEntry( "Could not Open the Transaction Table")
1726 ENDIF
1727 .oLog.LogEntry( "Removing Smallest POC Line " + IIF(llRetVal,"sucessful.", "failed."))
1728 .PopRecordSet()
1729 ENDWITH
1730
1731 RETURN llRetVal
1732
1733 ENDPROC
1734 *=== TechRec 1022169 28-Jun-2007 jjanand ===
1735 ******************************************************************************
1736
1737 PROCEDURE LoadFromFlatFile
1738 * --- TR 1047609 7/7/10 CM --- Added tcSLNFlatFile,tcTransSLN,tcSLNPkeyTag
1739 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcAddressFlatFile, tcTransAddress, tcAddressPkeyTag ===
1740 LPARAMETERS tcProcess, tcHeaderFlatFile, tcDetailFlatFile, tcCommentFlatFile, tcSDQFlatFile, ;
1741 tcHNTFlatFile, tcDNTFlatFile, tcSLNFlatFile, ;
1742 tcTransHeader, tcTransDetail, tcTransComment, tcTransSLN, ;
1743 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, tcSLNPkeyTag, ;
1744 tcTransHdrNotes, tcTransDtlNotes, tcAddressFlatFile, tcTransAddress, tcAddressPkeyTag
1745
1746 LOCAL llRetVal, lcSQLString, lnLine_seq
1747 *--- TR 1016589 NH
1748 LOCAL lcDocCount
1749 lcDocCount = ""
1750 *=== TR 1016589 NH
1751
1752 * --- TR 1047609 7/7/10 CM
1753 Local llSLN
1754 llSLN = !Empty(tcSLNFlatFile) And File(tcSLNFlatFile)
1755 * === TR 1047609 7/7/10 CM
1756
1757 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1758 Local lcEDIPath, lcEDIHFlatFile, lcEDIDFlatFile, lcEDISFlatFile, lcTransWhse, lcWHSEPkeyTag
1759
1760 lcEDIPath = THIS.GetEDIFlatFileDirectory("Inbound")
1761
1762 lcEDIHFlatFile = lcEDIPath + "860edih.dat"
1763 lcEDIDFlatFile = lcEDIPath + "860edid.dat"
1764 lcEDISFlatFile = lcEDIPath + "860edis.dat"
1765
1766 lcTransWhse = "VzzeiPCtWhse_ipcproc"
1767 lcWHSEPkeyTag = "ZZEIPCTWHSE"
1768 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1769
1770 llRetVal= .T.
1771 WITH THIS
1772 * get Metadata for a process
1773 .oLog.LogEntry("Retrieving EDI Metadata definitions.")
1774 IF .GetTranslationDefinition(tcProcess, "tcEmData")
1775
1776 .oLog.LogEntry("Creating work cursors from EDI Metadata.")
1777 * Create Metadata work tables
1778 IF !EMPTY(tcHeaderFlatFile)
1779 .CreateMetaDataWorkTable("tcEmData", "HEADER", "tcALLmwH")
1780 ENDIF
1781 IF !EMPTY(tcDetailFlatFile)
1782 .CreateMetaDataWorkTable("tcEmData", "DETAIL", "tcALLmwD")
1783 ENDIF
1784 IF !EMPTY(tcCommentFlatFile)
1785 .CreateMetaDataWorkTable("tcEmData", "COMMENT", "tcALLmwC")
1786 ENDIF
1787
1788 IF !EMPTY(tcSDQFlatFile)
1789 .CreateMetaDataWorkTable("tcEmData", "SDQ", "tcALLmwS")
1790 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli added edi_center C(13) ---
1791 CREATE CURSOR tcStore (STORE C(13), pkey I(4), edi_center C(13))
1792 .CreateCursorStructure("tcALLmwD", "tcStore" , "tcSDQWrk")
1793 ENDIF
1794
1795 IF !EMPTY(tcHNTFlatFile)
1796 IF .CreateMetaDataWorkTable("tcEmData", "HDRNOTES", "tcHdrNotes")
1797 .PopulateDataToInterfaceTable(tcHNTFlatFile, "tcHdrNotes")
1798 ENDIF
1799 ENDIF
1800 IF !EMPTY(tcDNTFlatFile)
1801 IF .CreateMetaDataWorkTable("tcEmData", "DTLNOTES", "tcDtlNotes")
1802 .PopulateDataToInterfaceTable(tcDNTFlatFile, "tcDtlNotes")
1803 ENDIF
1804 ENDIF
1805
1806 * --- TR 1047609 7/7/10 CM
1807 IF llSLN
1808 .CreateMetaDataWorkTable("tcEmData", "SLN", "tcALLmwL")
1809 ENDIF
1810 * === TR 1047609 7/7/10 CM
1811
1812 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1813 IF !EMPTY(tcAddressFlatFile)
1814 .CreateMetaDataWorkTable("tcEmData", "ADDRESS", "tcALLmwA")
1815 ENDIF
1816
1817 IF (!Empty(lcEDIHFlatFile) And File(lcEDIHFlatFile)) Or (!Empty(lcEDIDFlatFile) And File(lcEDIDFlatFile))
1818 .CreateMetaDataWorkTable("tcEmData", "EDIH", "tcEDIH")
1819 .CreateMetaDataWorkTable("tcEmData", "EDID", "tcEDID")
1820 ENDIF
1821
1822 IF !EMPTY(lcEDISFlatFile) And FILE(lcEDISFlatFile)
1823 .CreateMetaDataWorkTable("tcEmData", "EDIS", "tcEDIS")
1824 ENDIF
1825 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1826
1827 IF !EMPTY(tcHeaderFlatFile)
1828 llRetVal = llRetVal and .PopulateDataToInterfaceTable(tcHeaderFlatFile, "tcALLmwH", tcTransHeader,,"DOC_NUM") && TR 1024757 NH - check for unique value in "DOC_NUM" field
1829 ENDIF
1830 *--- TR 1024757 NH - Process fails when there is duplicate in doc_num field
1831 IF NOT llRetVal
1832 RETURN llRetVal
1833 ENDIF
1834 *===TR 1024757 NH
1835 IF !EMPTY(tcDetailFlatFile)
1836 .PopulateDataToInterfaceTable(tcDetailFlatFile, "tcALLmwD", tcTransDetail)
1837 ENDIF
1838 IF !EMPTY(tcCommentFlatFile)
1839 .PopulateDataToInterfaceTable(tcCommentFlatFile, "tcALLmwC", tcTransComment)
1840 ENDIF
1841
1842 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1843 If !Empty(tcAddressFlatFile)
1844 .PopulateDataToInterfaceTable(tcAddressFlatFile, "tcALLmwA", tcTransAddress)
1845 ENDIF
1846 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1847
1848 IF THIS.CountTotalRecs (tcTransHeader)> 0
1849 .oLog.LogEntry( "Transaction header records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransHeader))))
1850 ELSE
1851 .oLog.LogEntry( "No 860(i) flatfiles to load.")
1852 ENDIF
1853 IF THIS.CountTotalRecs (tcTransDetail)> 0
1854 .oLog.LogEntry( "Transaction detail records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransDetail))))
1855 ENDIF
1856 IF THIS.CountTotalRecs (tcTransComment)> 0 AND THIS.CountTotalRecs (tcTransHeader)> 0
1857 .oLog.LogEntry( "Transaction comment records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransComment))))
1858 ENDIF
1859
1860 * Assign pkeys for all interface tables
1861 .oLog.LogEntry("Assigning primary keys.")
1862 IF !EMPTY(tcHeaderFlatFile)
1863 .GetPkeyForAllRecordsInBatch(tcTransHeader, tcHeaderPkeyTag, THIS.CountTotalRecs ("tcALLmwH"))
1864 ENDIF
1865 IF !EMPTY(tcDetailFlatFile)
1866 .GetPkeyForAllRecordsInBatch(tcTransDetail, tcDetailPkeyTag, THIS.CountTotalRecs ("tcALLmwD"))
1867 ENDIF
1868 IF !EMPTY(tcCommentFlatFile)
1869 .GetPkeyForAllRecordsInBatch(tcTransComment, tcCommentPkeyTag, THIS.CountTotalRecs ("tcALLmwC"))
1870 ENDIF
1871
1872 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1873 If !Empty(tcAddressFlatFile)
1874 .GetPkeyForAllRecordsInBatch(tcTransAddress, tcAddressPkeyTag, THIS.CountTotalRecs("tcALLmwA"))
1875 Endif
1876 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1877
1878 * Sync header Pkey to all child tables Fkey using doc_num
1879 * could just be header only.
1880 .oLog.LogEntry("Assigning parent keys.")
1881 LOCAL lnOldDoc_num, lnLine_seq
1882 lnOldDoc_num= 0
1883 llRetVal= .SetRelation(tcTransHeader, "doc_num", tcTransDetail, "doc_num")
1884 IF llRetVal
1885 SELECT (tcTransDetail)
1886 SCAN
1887 IF ! lnOldDoc_num = doc_num
1888 lnOldDoc_num= doc_num
1889 lnLine_seq= 0
1890 ENDIF
1891 IF line_seq=0
1892 lnLine_seq= lnLine_seq + 1
1893 REPLACE line_seq WITH lnLine_seq
1894 ENDIF
1895 REPLACE fkey WITH EVALUATE(tcTransHeader + ".pkey")
1896
1897 ENDSCAN
1898 ENDIF
1899 SET RELATION TO
1900
1901 lcEnt_user= EDI_USER
1902 ltLast_mod= DATETIME()
1903
1904 * --- TR 1047609 7/7/10 CM
1905 IF llSLN
1906 .oLog.LogEntry("Populating SLN Data.")
1907 .PopulateDataToInterfaceTable(tcSLNFlatFile, "tcALLmwL", tcTransSLN)
1908 .GetPkeyForAllRecordsInBatch(tcTransSLN, tcSLNPkeyTag, This.CountTotalRecs("tcALLmwL"))
1909
1910 llRetVal= .SetRelation(tcTransDetail, "PO1_Line", tcTransSLN, "Str(Doc_Num)+SLN_Line")
1911 Select (tcTransSLN)
1912 Replace All fkey With Evaluate(tcTransDetail + ".pkey"), ;
1913 User_id With lcEnt_user, Last_mod With ltLast_mod
1914 Set Relation To
1915 ENDIF
1916 * === TR 1047609 7/7/10 CM
1917
1918 llRetVal= .SetRelation(tcTransHeader, "doc_num", tcTransComment, "doc_num")
1919 IF llRetVal
1920 IF THIS.CountTotalRecs (tcTransComment)>0
1921 SELECT (tcTransComment)
1922 lnOldDoc_num= 0
1923
1924 SCAN
1925 IF ! lnOldDoc_num = doc_num
1926 lnOldDoc_num= doc_num
1927 lnLine_num= 0
1928 ENDIF
1929 IF line_num=0
1930 lnLine_num= lnLine_num + 1
1931 REPLACE line_num WITH lnLine_num
1932 ENDIF
1933 REPLACE fkey WITH EVALUATE(tcTransHeader + ".pkey"), ;
1934 User_id WITH lcEnt_user, Last_mod WITH ltLast_mod
1935
1936 ENDSCAN
1937
1938 ENDIF
1939 ENDIF
1940 SET RELATION TO
1941
1942 * Explode SDQ segments
1943 IF !EMPTY(tcSDQFlatFile)
1944 *
1945 * get flatfile SDQ data into work tables
1946 .PopulateDataToInterfaceTable(tcSDQFlatFile, "tcALLmwS")
1947 *
1948 *--- TR 1016904 NH
1949 this.AddALLStoreToFlatFileData("tcALLmwH","tcALLmwD","tcALLmwS")
1950 *=== TR 1016904 NH
1951 * have some SDQ to explode
1952 IF THIS.CountTotalRecs ("tcALLmwS")>0
1953 .oLog.LogEntry("Preparing cursor for exploding multiple store orders (SDQ).")
1954
1955 *--- TR 1021052 20-AUG-2007 HNISAR/Goutam
1956 *--- Added AND IIF(EMPTY(s.sdq_line), .T. , s.sdq_line = d.poc_line)
1957 *SELECT d.*, s.store_01,s.qty_01,s.store_02,s.qty_02,s.store_03,s.qty_03,;
1958 s.store_04,s.qty_04,s.store_05,s.qty_05,s.store_06,s.qty_06,s.store_07,s.qty_07,;
1959 s.store_08,s.qty_08,s.store_09,s.qty_09,s.store_10,s.qty_10 ;
1960 FROM tcALLmwD d, tcALLmwS s ;
1961 WHERE s.doc_num= d.doc_num ;
1962 AND s.upc= d.upc AND s.sku= d.sku AND s.ean= d.ean ;
1963 INTO CURSOR __SDQDet ;
1964 ORDER BY s.doc_num, s.upc, s.sku, s.ean
1965
1966 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli added s.edi_center in the select list ---
1967 SELECT d.*, s.store_01,s.qty_01,s.store_02,s.qty_02,s.store_03,s.qty_03,;
1968 s.store_04,s.qty_04,s.store_05,s.qty_05,s.store_06,s.qty_06,s.store_07,s.qty_07,;
1969 s.store_08,s.qty_08,s.store_09,s.qty_09,s.store_10,s.qty_10, s.edi_center ;
1970 FROM tcALLmwD d, tcALLmwS s ;
1971 WHERE s.doc_num= d.doc_num ;
1972 AND s.upc= d.upc AND s.sku= d.sku AND s.ean= d.ean ;
1973 AND IIF(EMPTY(s.sdq_line), .T. , s.sdq_line = d.poc_line) ;
1974 INTO CURSOR __SDQDet ;
1975 ORDER BY s.doc_num, s.upc, s.sku, s.ean
1976 *=== TR 1021052 20-AUG-2007 HNISAR/Goutam
1977
1978 * turn 10 pairs of SDQ store,qty from horizontal to vertical
1979 IF USED("__SDQDet")
1980 .PreExplodeSQDOrders("__SDQDet", "tcSDQWrk")
1981 ENDIF
1982 * should alway have something here to explode
1983 IF THIS.CountTotalRecs ("tcSDQWrk")>0
1984 SELECT * FROM tcSDQWrk INTO CURSOR _SDQDet ORDER BY doc_num, STORE, upc, sku, ean
1985 *--- TR 1016589 05/05/06 NH
1986 .CreateDocStoreCursor("_SDQDet", "tcDoc_Count")
1987 lcDocCount = "tcDoc_Count"
1988 *=== TR 1016589 05/05/06 NH
1989 .MakeCursorWritable("_SDQDet", "tcSDQDet")
1990 SELECT tcSDQDet
1991 INDEX ON pkey TAG pkey
1992 INDEX ON doc_num TAG doc_num
1993 *
1994 * Explode orders into Transaction tables all will have same doc_num
1995 * already, adjust clsIPCpr to handle dulication in doc_num when
1996 * sync Pkey/fkey in transaction table
1997 .oLog.LogEntry("Exploding multiple store orders (SDQ).")
1998 * --- TR 1047609 7/7/10 CM --- Added tcTransSLN, tcSLNPkeyTag
1999 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcTransaddress, "tcALLmwA", tcAddressPkeyTag ===
2000 .ExplodeSDQOrders("tcSDQDet", tcTransHeader, tcTransDetail, tcTransComment, ;
2001 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, ;
2002 "tcALLmwH", "tcALLmwD", "tcALLmwC",IIF(llSLN, tcTransSLN, ""), IIF(llSLN, tcSLNPkeyTag, ""),;
2003 tcTransaddress, "tcALLmwA", tcAddressPkeyTag )
2004 ENDIF
2005 ENDIF
2006 ENDIF
2007
2008 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
2009 IF (!Empty(lcEDIHFlatFile) And File(lcEDIHFlatFile)) Or (!Empty(lcEDIDFlatFile) And File(lcEDIDFlatFile))
2010 .oLog.LogEntry("Populating EDI Data.")
2011 .PopulateDataToInterfaceTable(lcEDIDFlatFile, "tcEDID", lcTransWhse)
2012 .oLog.LogEntry("Getting Pkey for EDI detail datawhse")
2013 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, This.CountTotalRecs("tcEDID"))
2014
2015 .oLog.LogEntry("Populating EDI header datawhse")
2016 .PopulateDataToInterfaceTable(lcEDIHFlatFile, "tcEDIH", lcTransWhse)
2017 .oLog.LogEntry("Populating pkey for EDI header datawhse")
2018 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, This.CountTotalRecs("tcEDIH"))
2019 .oLog.LogEntry("Populating all keys for EDI datawhse")
2020 Select (lcTransWhse)
2021 SCAN
2022 IF SEEK(Str(Doc_Num)+ edi_line, "vzzeipctd_ipcproc", "PO1_Line")
2023 Replace dfkey With vzzeipctd_ipcproc.pkey, ;
2024 line_seq With vzzeipctd_ipcproc.line_seq
2025 IF vzzeipctd_ipcproc.pkey > 0
2026 Replace table_name WITH "ZZOORDRD"
2027 ENDIF
2028 ENDIF
2029 IF SEEK(Doc_Num, "vzzeipcth_ipcproc", "Doc_Num")
2030 Replace hfkey With vzzeipcth_ipcproc.pkey, ;
2031 User_id With lcEnt_user, ;
2032 Last_mod With ltLast_mod
2033 IF dfkey = 0
2034 Replace table_name WITH "ZZOORDRH"
2035 ENDIF
2036 ENDIF
2037 ENDSCAN
2038 .oLog.LogEntry("Populating all keys for EDI datawhse completed.")
2039 ENDIF
2040
2041 IF !EMPTY(lcEDISFlatFile) And FILE(lcEDISFlatFile)
2042 .oLog.LogEntry("Populating EDIS Data.")
2043
2044 .PopulateDataToInterfaceTable(lcEDISFlatFile, "tcEDIS", lcTransWhse)
2045 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, .CountTotalRecs("tcEDIS"))
2046
2047 llRetVal = .SetRelation(tcTransDetail, "PO1_Line", lcTransWhse, "Str(Doc_Num)+ edi_line")
2048 IF llRetVal
2049 SELECT (lcTransWhse)
2050 REPLACE ALL dfkey WITH EVALUATE(tcTransDetail + ".pkey"), ;
2051 line_seq WITH EVALUATE(tcTransDetail + ".line_seq")
2052 ENDIF
2053 SET RELATION TO
2054
2055 llRetVal = .SetRelation(tcTransHeader, "Doc_Num", lcTransWhse, "Doc_Num")
2056 IF llRetVal
2057 SELECT (lcTransWhse)
2058 REPLACE ALL hfkey WITH EVALUATE(tcTransHeader + ".pkey")
2059 ENDIF
2060 SET RELATION TO
2061
2062 llRetVal = .SetRelation(tcTransSLN, "SLN_Line", lcTransWhse, "Str(Doc_Num)+SLN_Line")
2063 If llRetVal
2064 SELECT (lcTransWhse)
2065 REPLACE ALL sfkey WITH EVALUATE(tcTransSLN+ ".pkey"), ;
2066 user_id WITH lcEnt_User, ;
2067 last_mod WITH ltLast_Mod
2068
2069 Replace ALL table_name WITH "ZZEIPOHS" FOR sfkey > 0
2070
2071 ENDIF
2072 SET RELATION TO
2073 ENDIF
2074 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
2075
2076 .oLog.LogEntry("loading 850(i) header and detail notes.")
2077 *--- TR 1016589 05/05/06 NH Bring notes just as IPO process.
2078*!* .LoadHeaderDetailNotes("tcHdrNotes", "tcDtlNotes", ;
2079*!* tcTransHeader, tcTransDetail)
2080 .LoadHeaderDetailNotes("tcHdrNotes", "tcDtlNotes", ;
2081 tcTransHeader, tcTransDetail, tcTransHdrNotes, tcTransDtlNotes, lcDocCount)
2082 *=== TR 1016589 05/05/06 NH
2083 ELSE
2084 llRetVal=.F.
2085 ENDIF
2086 ENDWITH
2087
2088 * --- TR 1047609 7/7/10 CM
2089 *LOCAL laTables[7]
2090 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli changed from 8 to 12 ===
2091 LOCAL laTables[12]
2092 * === TR 1047609 7/7/10 CM
2093
2094 laTables[1] = "tcALLmwH"
2095 laTables[2] = "tcALLmwD"
2096 laTables[3] = "tcEmdata"
2097 laTables[4] = "__SDQDet"
2098 laTables[5] = "tcSDQDet"
2099 laTables[6] = "tcSDQWrk"
2100 laTables[7]= "tcStore"
2101
2102 * --- TR 1047609 7/7/10 CM
2103 laTables[8] = "tcALLmwL"
2104 * === TR 1047609 7/7/10 CM
2105
2106 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
2107 laTables[9] = "tcEDIH"
2108 laTables[10] = "tcEDID"
2109 laTables[11] = "tcEDIS"
2110 laTables[12] = "tcALLmwA"
2111 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
2112
2113 .TableClose(@laTables)
2114
2115 RETURN llRetVal
2116 ENDPROC
2117 ******************************************************************************
2118 *--- TR 1022465 NH 03/13/07
2119 ******************************************************************************
2120 *--- expode orders with no dtl and no sdq
2121 *--- TR 1027724 NH 11/05/07
2122 PROCEDURE ExplodeOrderForAllStore
2123 *LPARAMETERS tcTransHeader
2124
2125 LOCAL llRetVal, lcipcth_key, lcSql, loIpcth, lcipcth_New,lcipcth_Update
2126 llRetVal = .t.
2127 lnOldSelect = SELECT()
2128 *--- TR 1027724 NH : use .cFilterCriteria to get the transaction records that need to be worked on.
2129*!* lcipcth_key = "#ipoth_key" + SYS(2015)
2130*!* lcSql = "SELECT pkey INTO " + lcipcth_key + " FROM zzeipcth where 1 = 2"
2131*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2132*!*
2133*!* lcSql = "INSERT INTO " + lcipcth_key + " VALUES (loIpcth.pkey)"
2134*!* SELECT ("VzzeiPCth_iPCproc")
2135*!* SCAN
2136*!* SCATTER NAME loIpcth
2137*!* *IF loIpcth.Errs_flg_h <> 'Y'
2138*!* IF loIpcth.store = '' AND loIpcth.edi_store = ''
2139*!* lcSqlInsert = STRTRAN(lcSql,"loIpcth.pkey",SqlFormatNum(loIpcth.pkey))
2140*!* llRetVal = llRetVal and v_sqlexec(lcSqlInsert)
2141*!* ENDIF
2142*!* ENDSCAN
2143 *=== TR 1027724 NH
2144
2145 lcipcth_New = "#Zzeipcth_new" + SYS(2015)
2146 lcipcth_Update = "#Zzeipcth_update" + SYS(2015)
2147 *--- now, we have list of orders to explode
2148
2149 loCopyUtil = NEWOBJECT("CopyUtil","CopyUtil.prg")
2150 IF VARTYPE(loCopyUtil) <> "O"
2151 SELECT(lnOldSelect)
2152 RETURN llRetVal
2153 ENDIF
2154
2155 *--- In 860 transaction header has one record per PO. We will update store, edi_store information.
2156 *--- First, move this (Update) records into another table for future update.
2157 *--- Second, delete (remove) these records from exploded order list using customer, po_num, and edi_store
2158 *--- Thrid, prepare new order table for insert (pkey)
2159 *--- Fourth, Open transaction
2160 *--- Fifth, Update 860 trans header.
2161 *--- Sixth, Insert 860 trans header.
2162 *--- TR 1027724 NH
2163*!*
2164*!* lcSql = "select th.* into #zzeipcth_update from #zzeipcth_main th inner join #zzeipcth_pkey k on th.pkey = k.pkey"
2165*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2166*!* lcSql = STRTRAN(lcSql,"#zzeipcth_main","zzeipcth")
2167*!* lcSql = STRTRAN(lcSql,"#zzeipcth_pkey",lcipcth_key)
2168*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2169 LOCAL lcFilter
2170 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
2171 lcFilter = STRTRAN(lcFilter,"H.","TH.")
2172 lcFilter = STRTRAN(lcFilter,"Where","")
2173
2174 *--- TR 1035409 NH
2175 lcSQL = "SELECT * into " + lcipcth_Update + " FROM zzeipcth th where 1 = 1 " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2176 llRetVal = llRetVal and v_sqlexec(lcSQL)
2177
2178 *--- TR 1072834 20-Aug-2013 Goutam
2179 *lcSQL = "UPDATE h SET errs_flg_h = 'N', errs_msg_h = '' FROM " + lcipcth_Update + " h"
2180 lcSQL = "UPDATE h SET errs_flg_h = 'N', warn_flg_h = 'N', errs_msg_h = '', warn_msg_h = '' FROM " + lcipcth_Update + " h"
2181 *=== TR 1072834 20-Aug-2013 Goutam
2182
2183 llRetVal = llRetVal and v_sqlexec(lcSQL)
2184
2185 *--- TR 1048865 10-Feb-2011 Goutam. added ,,"CR_Pkey" at the end of the parameter
2186 llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcipcth_Update, "zzeipccr","customer","errs_flg_h","errs_msg_h",,"CR_Pkey")
2187
2188 *--- TR 1048865 10-Feb-2011 Goutam. added "CR_Pkey" for updation
2189 *--- TR 1072834 20-Aug-2013 Goutam. Added warn_flg_h, warn_msg_h
2190 lcSQL = "UPDATE th set customer = h.customer, CR_Pkey = h.CR_Pkey, errs_flg_h = case when h.errs_flg_h = 'Y' then 'Y' else th.errs_flg_h end " + ;
2191 " , errs_msg_h = case when h.errs_flg_h = 'Y' then h.errs_msg_h else th.errs_msg_h end " + ;
2192 " , warn_flg_h = case when h.warn_flg_h = 'Y' then 'Y' else th.warn_flg_h end " + ;
2193 " , warn_msg_h = case when h.warn_flg_h = 'Y' then h.warn_msg_h else th.warn_msg_h end " + ;
2194 " from zzeipcth th inner join " + lcipcth_Update + " h on th.pkey = h.pkey "
2195 llRetVal = llRetVal and v_sqlexec(lcSQL)
2196 v_sqlexec("drop table " + lcipcth_Update)
2197 *=== TR 1035409 NH
2198 *--- TR 1036066 NH
2199 llRetVal = llRetVal and this.PopulateStoreForSingleStorePO_AtServer()
2200 *=== TR 1036066 NH
2201 *--- get all trans header record to explode for empty store and edi_store
2202 *--- TR 1034532 NH : take header that has no details for lcipcth_Update table
2203 *--- TR 1036066 NH : Added - ForAllStore = 'Y'
2204 lcSQL = "SELECT th.* into " + lcipcth_Update + " from zzeipcth th " + ;
2205 " WHERE th.store = '' and th.edi_store = '' and th.customer > '' " +; && TR 1035409
2206 " and th.ForAllStore = 'Y' " + ;
2207 " and not exists ( select * from zzeipctd td where td.fkey = th.pkey) " + ; && TR 1034532 NH
2208 IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2209 *=== TR 1036066 NH
2210 llRetVal = llRetVal and v_SQLexec(lcSQL)
2211
2212 *--- TR 1035409 NH : added condition to add trans header for date change.
2213 *--- date change is for accross PO, so we need to add
2214
2215 *--- TR 1036066 NH
2216 *--- create new trans headers for each SO orders.
2217 *--- do not create copy of details. because it is only header change.
2218 *--- If there are details with this trans header leave the original trans header with empty edi_store, empty store, and ForAllStore = 'Y'
2219 *--- If detail has qualifier 'DI' or 'PC' then in later steps it will be exploded for all stores of the PO.
2220 *--- If detail has qualifier 'AI', 'QI', 'QD', 'RZ' then it will be handled in later steps.
2221 *=== TR 1036066 NH
2222
2223 LOCAL lcipcth_Update_tmp
2224 lcipcth_Update_tmp = "#Zzeipcth_update_tmp" + SYS(2015)
2225
2226 lcSql = " select th.* into " + lcipcth_Update_tmp + " from zzeipcth th where exists ( " + ;
2227 " select h.customer, h.po_num from zzeipcth h " + ;
2228 " where (h.start_date > {ts '1900-01-01 12:00:00.000'} " + ;
2229 " or h.End_date > {ts '1900-01-01 12:00:00.000'}) " + ;
2230 " group by h.customer, h.po_num having MIN(h.pkey) = th.pkey ) " + ;
2231 " AND th.customer > '' " + ;
2232 IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2233
2234 llRetVal = llRetVal and v_SQLexec(lcSQL)
2235
2236 *--- TR 1072834 20-Aug-2013 Goutam. Added warn_flg_h, warn_msg_h
2237 lcSql = " update th set store = '', edi_store = '', errs_flg_h = 'N', errs_msg_h = '', warn_flg_h = 'N', warn_msg_h = '' from " + lcipcth_Update_tmp + " th "
2238 llRetVal = llRetVal and v_SQLexec(lcSQL)
2239
2240 *=== TR 1035409 NH
2241 *=== TR 1027724
2242
2243 *--- TR 1026113 08/15/2007 NH
2244 *--- get store, and edi_store information from sales order and customer store ref
2245*!* TEXT TO lcSql NOSHOW
2246*!* SELECT u.*, oh.store as ord_store, s.edi_store as Ord_edi_store into #Zzeipcth_new
2247*!* FROM #Zzeipcth_update u inner join zzeipccr cr ON u.vnd_id = cr.vnd_id and u.vnd_qual = cr.vnd_qual
2248*!* inner join zzoordrh oh WITH (nolock) ON u.po_num = oh.po_num and cr.customer = oh.customer and oh.ord_status = 'O'
2249*!* inner join zzxstorr s with (nolock) on s.store = oh.store and s.customer = oh.customer
2250*!* WHERE not EXISTS (SELECT * FROM zzeipctd d WHERE d.fkey = u.pkey)
2251*!* ENDTEXT
2252 *--- update ipc with customer from ipc control reference
2253 *--- TR 1027724 NH
2254*!* lcSql = "UPDATE u SET customer = cr.customer from " + lcipcth_Update + " u inner join zzeipccr cr on u.vnd_id = cr.vnd_id and u.vnd_qual = cr.vnd_qual"
2255*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2256 *--- clear errors
2257 *--- TR 1035409 NH : no need this here
2258*!* lcSQL = "UPDATE h SET errs_flg_h = '', errs_msg_h = '' FROM " + lcipcth_Update + " h"
2259*!* llRetVal = llRetVal and v_sqlexec(lcSQL)
2260*!* llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcipcth_Update, "zzeipccr","customer","errs_flg_h","errs_msg_h")
2261 *=== TR 1035409 NH
2262 *--- TR 1035409 NH : resolve customer before insert into lcipcth_Update. Need customer for the join - h.customer = tmp.customer
2263 *--- update customer information in zzeipcth - customer is need to delete record later on
2264 lcSql = " insert into " + lcipcth_Update + " select * from " + lcipcth_Update_tmp + " tmp " + ;
2265 " where not exists (select h.pkey from " + lcipcth_Update + " h " + ;
2266 " where h.po_num = tmp.po_num and h.customer = tmp.customer ) " +;
2267 " AND tmp.errs_flg_h <> 'Y'"
2268 llRetVal = llRetVal and v_SQLexec(lcSQL)
2269 *--- drop temp table
2270 v_sqlexec("drop table " + lcipcth_Update_tmp )
2271 *=== TR 1035409 NH
2272
2273 *--- update 860 transaction table if any validation error occured in customer resolution
2274
2275
2276 *--- Added condition and u.customer > '' to eliminate the ones with customer not resolved.
2277 *--- TR 1035409 NH
2278 *not EXISTS (SELECT * FROM zzeipctd d WHERE d.fkey = u.pkey) and
2279 *--- exclude headers which are already in the trans main.
2280 *--- TR 1089812 14-Sep-2015 BNarayanan removed and oh.ord_status = 'O' from inner join ---
2281 TEXT TO lcSql NOSHOW
2282 SELECT u.*, oh.store as ord_store, s.edi_store as Ord_edi_store into #Zzeipcth_new
2283 FROM #Zzeipcth_update u inner join zzoordrh oh WITH (nolock) ON u.po_num = oh.po_num and u.customer = oh.customer
2284 inner join zzxstorr s with (nolock) on s.store = oh.store and s.customer = oh.customer
2285 WHERE u.customer > ''
2286 and not exists (select th.pkey from zzeipcth th where th.po_num = u.po_num and th.customer = u.customer and th.edi_store = s.edi_store)
2287 ENDTEXT
2288
2289 *=== TR 1027724 NH
2290 *=== TR 1026113 NH
2291 *u.errs_flg_h <> 'Y' AND
2292
2293 lcSql = STRTRAN(lcSql,"#Zzeipcth_new",lcipcth_New)
2294 lcSql = STRTRAN(lcSql,"#Zzeipcth_update",lcipcth_Update)
2295 *lcSql = STRTRAN(lcSql,"CHR(13)","cr") && TR 1026113 08/15/2007 NH
2296 llRetVal = llRetVal and v_sqlexec(lcSql)
2297
2298 *--- TR 1036066 NH
2299 *--- update store, and edi_store information for temp columns ord_store, ord_edi_store
2300 *lcSql = "update th SET store = ord_store, edi_store = ord_edi_store from #zzeipcth_New th"
2301 lcSql = "update th SET store = ord_store, edi_store = ord_edi_store " + ;
2302 " , ForAllStore = case when th.ForAllStore = 'Y' then 'P' ELSE th.ForAllStore end " + ;
2303 " from #zzeipcth_New th"
2304 *=== TR 1036006 NH
2305 lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2306 llRetVal = llRetVal and v_sqlexec(lcSql)
2307
2308 *--- to preserver one record per PO for update only
2309 *--- TR 1035409 NH : Rem out - no need now
2310 *thn.pkey, thn.store, thn.edi_store, thn.customer, thn.po_num
2311*!* lcSql = "update u SET store = thn.store, edi_store = thn.edi_store FROM #zzeipcth_update u " + ;
2312*!* "INNER JOIN #zzeipcth_New thn on thn.customer = u.customer and thn.po_num = u.po_num " + ;
2313*!* "and u.Customer > '' " && TR 1027724 added u.Customer > ''
2314
2315*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2316*!* lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2317*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2318
2319 *--- remove preservered po records from insert table.
2320*!* TEXT TO lcSql NOSHOW
2321*!* delete thn FROM #zzeipcth_New thn inner join #zzeipcth_update u
2322*!* on thn.customer = u.customer and thn.po_num = u.po_num and thn.edi_store = u.edi_store
2323*!* ENDTEXT
2324*!* lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2325*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2326*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2327 *=== TR 1035409 NH
2328 llRetVal = llRetVal and loCopyUtil.DropColumn(lcipcth_New, "ord_store")
2329 llRetVal = llRetVal and loCopyUtil.DropColumn(lcipcth_New, "Ord_edi_store")
2330
2331 *--- lcipcth_Update has trans header records to update
2332 *--- lcIpcth_New has trans header records to insert
2333 *--- set pkey of trans header
2334 lcSql = "select COUNT(*) Rec_count from #zzeipcth_New"
2335 lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2336 llRetVal = llRetVal and v_sqlexec(lcSql,"RowAffected")
2337
2338
2339 *--- TR 1034532 - add trans detail for new trans header
2340 *--- TR 106066 NH
2341*!* LOCAL lcipctd_New
2342*!* lcipctd_New = "#Zzeipctd_new" + SYS(2015)
2343*!* lcSql = "select td.* into " + lcipctd_New + " from zzeipctd td inner join " + lcipcth_New + " th on th.pkey = td.fkey"
2344*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2345 *=== TR 1036066 NH
2346 *=== TR 1034532 NH
2347 IF llRetVal AND RowAffected.Rec_Count > 0
2348 lnMaxNumber = v_nextPkey("zzeipcth",RowAffected.Rec_Count)
2349 *--- TR 1034532 NH - set pkey for trans header and fkey for trans detail
2350 *--- TR 1036066 NH
2351 llRetVal = llRetVal and loCopyUtil.KeyFldUpdate(lcipcth_New, "pkey", lnMaxNumber, RowAffected.Rec_Count, "pkey_I")
2352
2353*!* DECLARE ladtlTmp[1,4]
2354*!* ladtlTmp[1,1] = lcipctd_New
2355*!* ladtlTmp[1,2] = 'fkey'
2356*!* ladtlTmp[1,3] = 'fkey'
2357*!* ladtlTmp[1,4] = 'pkey'
2358*!* loCopyUtil.HdrDtlNumKeyFldUpdate(lcipcth_New,"pkey",@ladtlTmp, lnMaxNumber,RowAffected.Rec_Count,"pkey_I")
2359 *=== TR 1036066 NH
2360 *=== TR 1034532 NH
2361 ENDIF
2362
2363 *--- Prepare 860 transaction update, insert SQL
2364 *--- TR 1027724 NH : added update fields , errs_msg_h = u.errs_msg_h, errs_flg_h = u.errs_flg_h
2365 *--- TR 1035409 NH : no need to update here
2366*!* TEXT TO lcSqlUpdate NOSHOW
2367*!* update th SET store = u.store, edi_store = u.edi_store, errs_msg_h = u.errs_msg_h,
2368*!* errs_flg_h = u.errs_flg_h FROM #zzeipcth_main th inner join #zzeipcth_update u on u.pkey = th.pkey
2369*!* ENDTEXT
2370*!* lcSqlUpdate = STRTRAN(lcSqlUpdate, "#zzeipcth_main","zzeipcth")
2371*!* lcSqlUpdate = STRTRAN(lcSqlUpdate, "#zzeipcth_update",lcipcth_Update)
2372 *=== TR 1035409 NH
2373 TEXT TO lcSQlInsert NOSHOW
2374 insert into #zzeipcth_main select * from #zzeipcth_New
2375 ENDTEXT
2376 lcSQlInsert = STRTRAN(lcSQlInsert, "#zzeipcth_main","zzeipcth")
2377 lcSQlInsert = STRTRAN(lcSQlInsert, "#zzeipcth_New",lcipcth_New)
2378
2379 *--- TR 1035409 NH
2380 *--- remove empty store, edi_store
2381 *--- preserve the trans header if there is any detail attached with it.
2382 LOCAL lcSqlDelete
2383 lcSqlDelete = "delete th from zzeipcth th inner join " + lcipcth_New + " tn on th.po_num = tn.po_num " + ;
2384 " and th.customer = tn.customer and th.doc_num = tn.doc_num " + ;
2385 " where th.edi_store = '' and th.store = '' " + ;
2386 " AND th.ForAllStore = 'Y' and not exists (select td.pkey from zzeipctd td where td.fkey = th.pkey)"
2387
2388 *=== TR 1035409 NH
2389
2390 *--- TR 1034532 NH - update detail fkey
2391 *--- TR 1036066 NH
2392*!* LOCAL lcSqlDtlUpdate
2393*!* lcSqlDtlUpdate = "update td set fkey = d.fkey from zzeipctd td inner join " + lcipctd_New + " d on td.pkey = d.pkey "
2394 *=== TR 1036066 NH
2395 *=== TR 1034532 NH
2396 IF NOT llRetVal
2397 SELECT(lnOldSelect)
2398 RETURN llRetVal
2399 ENDIF
2400
2401 llBeganTransaction = THIS.BeginTransaction()
2402 IF llBeganTransaction
2403 *--- TR 1035409 NH : no need to update any more -> delete + insert
2404 *llRetVal = llRetVal and v_sqlexec(lcSqlUpdate)
2405 llRetVal = llRetVal and v_sqlexec(lcSqlDelete)
2406 *=== TR 1035409 NH
2407 llRetVal = llRetVal and v_sqlexec(lcSqlInsert)
2408 *--- TR 1036066 NH
2409 *llRetVal = llRetVal and v_sqlexec(lcSqlDtlUpdate) &&--- TR 1034532 NH
2410 *=== TR 1036066 NH
2411 IF llRetVal
2412 THIS.EndTransaction()
2413 ELSE
2414 THIS.RollbackTransaction()
2415 ENDIF
2416 ENDIF
2417
2418 SELECT(lnOldSelect)
2419 RETURN llRetVal
2420 ENDPROC
2421 *=== TR 1022465 NH 03/13/07
2422
2423
2424 ******************************************************************************
2425 *--- TR 1016904 NH
2426 ******************************************************************************
2427 PROCEDURE AddALLStoreToFlatFileData
2428 LPARAMETERS pcALLmwH, pcALLmwD, pcALLmwS
2429 LOCAL llRetVal, lnOldSelect, loALLmwS, loALLmwD_noSDQ
2430 llRetVal = .t.
2431 lnOldSelect = SELECT()
2432 lnSdqCount = 0
2433
2434
2435 this.LogEntry("Starting procedure " + PROGRAM())
2436 *--- ALL store candidate : detail records has qualifier 'DI' and there is no related SDQ and
2437 *--- header does not have any store in it.
2438 *--- TR 1022465 NH Added: OR d.qualifier = 'PC'
2439 *--- TR 1034532 NH : removed - (d.qualifier = 'DI' OR d.qualifier = 'PC')
2440 *--- first use ALL in edi_store for empty edi_store to bring detail to transaction
2441
2442*- TR 1072151 FH - added for scenario when we have bulk order with both DI and AI, but only AI have store.
2443*- We are loosing the DI records because we don't have SDQ associated with it.
2444
2445*!* SELECT * FROM (pcALLmwD)d WHERE 1=1 ;
2446*!* AND NOT EXISTS (SELECT * FROM (pcALLmwS) s WHERE s.doc_num = d.DOC_NUM ;
2447*!* AND s.upc = d.UPC AND s.sku = d.sku AND s.ean = d.ean AND s.sdq_line = d.poc_line) ; && TR 1034409 NH 06/30/08
2448*!* AND exists (select * from (pcALLmwH) h WHERE h.edi_store = "" AND h.doc_num = d.doc_num ; && 1021200 : Removed brace ')'
2449*!* AND NOT (po_type = 'BK' OR po_type ='BL' OR po_type = 'KC')) ; && TR 1021200 : when po_type BK or BL or KC it is a bulk order and no need to set ALL for Edi_store
2450*!* into cursor _tcALLmwD_noSDQ
2451
2452 select * ;
2453 from (pcALLmwD)d ;
2454 where 1=1 ;
2455 and not exists ( ;
2456 select * ;
2457 from (pcALLmwS) s ;
2458 where s.doc_num = d.DOC_NUM ;
2459 and s.upc = d.UPC ;
2460 and s.sku = d.sku ;
2461 and s.ean = d.ean ;
2462 and s.sdq_line = d.poc_line) ;
2463 and exists ( ;
2464 select * ;
2465 from (pcALLmwH) h ;
2466 where h.edi_store = "" ;
2467 and h.doc_num = d.doc_num ;
2468 and ( not (po_type = 'BK' or po_type ='BL' or po_type = 'KC') ;
2469 OR EXISTS ( SELECT * FROM (pcALLmwS) s WHERE s.doc_num = h.DOC_NUM) ) ; && TR 1072151 FH - added.
2470 ) ;
2471 into cursor _tcALLmwD_noSDQ
2472*- TR 1072151 FH
2473
2474
2475 this.LogEntry("Numbers of SDQ record will be added are " + TRANSFORM(RECCOUNT("_tcALLmwD_noSDQ")))
2476
2477 SELECT _tcALLmwD_noSDQ
2478 SCAN
2479 SCATTER NAME loALLmwD_noSDQ
2480 SELECT (pcALLmwS)
2481 SCATTER NAME loALLmwS BLANK
2482 loALLmwS.SDQ_TAG = 'SDQ'
2483 loALLmwS.DOC_NUM = loALLmwD_noSDQ.doc_num
2484 loALLmwS.upc = loALLmwD_noSDQ.upc
2485 loALLmwS.sku = loALLmwD_noSDQ.sku
2486 loALLmwS.ean = loALLmwD_noSDQ.ean
2487 loALLmwS.store_01 = this.cStore_ALL
2488 loALLmwS.qty_01 = IIF(INLIST(loALLmwD_noSDQ.qualifier, 'DI','PC'), "0" ,loALLmwD_noSDQ.qty_change) && all values are character including numeric ones
2489 *loALLmwS.ForAllStore = 'Y' && TR 1027127 NH
2490 loALLmwS.sdq_line = loALLmwD_noSDQ.poc_line
2491 APPEND BLANK
2492 GATHER NAME loAllmwS
2493 lnSdqCount = lnSdqCount + 1
2494 ENDSCAN
2495 this.LogEntry("Numbers of SDQ records have be added are " + TRANSFORM(lnSdqCount))
2496
2497 IF USED("_tcALLmwD_noSDQ")
2498 USE IN ("_tcALLmwD_noSDQ")
2499 ENDIF
2500
2501 SELECT(lnOldSelect)
2502 RETURN llRetVal
2503 ENDPROC
2504 ******************************************************************************
2505 *=== TR 1016904 NH
2506
2507 PROCEDURE PreExplodeSQDOrders
2508 PARAMETER tcSDQWorkTable, tcSDQDetailTable
2509 LOCAL lnOldSele, llRetVal, lcSQLString, lnSDQCount
2510 llRetVal= .T.
2511 lnOldSele= SELECT()
2512 SELECT (tcSDQWorkTable)
2513 SCAN
2514 SCATT MEMVAR
2515 FOR lnSDQCount = 1 TO MAX_SDQ_COUNT
2516 lcSDQCount= TRANS(lnSDQCount , "@L 99")
2517 m.Store=EVAL( "store_" + lcSDQCount)
2518 *- 1014475 01/18/06 YIK
2519 *- We did not populate SDQ quantities!
2520 m.Qty_change = EVAL( "qty_" + lcSDQCount)
2521 IF !EMPTY(m.Store)
2522 INSERT INTO (tcSDQDetailTable) FROM MEMVAR
2523 ENDIF
2524 ENDFOR
2525 ENDSCAN
2526 * Each SDQDetail records need ALL pkey (recno())
2527 REPLACE ALL pkey WITH RECNO() IN (tcSDQDetailTable)
2528 RETURN llRetVal
2529 ENDPROC
2530
2531 PROCEDURE ExplodeSDQOrders
2532 * --- TR 1047609 7/7/10 CM --- Added tcTransSLN, tcSLNPkeyTag
2533 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcTransaddress, tcMetaWorkAddress, tcAddressPkeyTag ===
2534 PARAMETER tcSDQDetailTable, tcTransHeader, tcTransDetail, tcTransComment,;
2535 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, ;
2536 tcMetaWorkHeader, tcMetaWorkDetail, tcMetaWorkComment, tcTransSLN, tcSLNPkeyTag,;
2537 tcTransaddress, tcMetaWorkAddress, tcAddressPkeyTag
2538
2539 LOCAL lnOldSele, llRetVal, lcSQLString, lnSDQCount,lnCurrentDoc_num, lcCurrentDoc_num, ;
2540 lnOrdersHeaderToExplode,lnOrdersLineToExplode, lcDBFName, lnCurrentStart_date
2541
2542 LOCAL lnCurrentEnd_Date, lnOldDtlPKey, lnNewDtlPKey, I, lnCnt, lcDoc_Num
2543
2544 * --- TR 1047609 7/7/10 CM
2545 LOCAL lnNewDtlPKey, lcPO1_Line, lcDoc_Num, lnOldDtlPKey, lnOldHdrPKey
2546 * === TR 1047609 7/7/10 CM
2547
2548 llRetVal= .T.
2549 lnOldSele= SELECT()
2550
2551 * create temporary cursor to hold exploded orders before append to interface tables
2552 * should have same layout as interface tables
2553 SELECT (tcTransHeader)
2554 AFIELDS(laWorkHeader)
2555 * Walmart - Store truncate to 9 position for
2556 * SDQ orders when expand EDI store to 13 position
2557 lnRow =ASUB(laWorkHeader, ASCAN(laWorkHeader, 'STORE'), 1)
2558 laWorkHeader[lnRow, 3]= 13 && expand store to 13 pos in SQD work header
2559 CREATE CURSOR TargetWH FROM ARRAY laWorkHeader
2560 SELECT (tcTransDetail)
2561 AFIELDS(laWorkDetail)
2562 CREATE CURSOR TargetWD FROM ARRAY laWorkDetail
2563 SELECT (tcTransComment)
2564 AFIELDS(laWorkComment)
2565 CREATE CURSOR TargetWC FROM ARRAY laWorkComment
2566
2567 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2568 Select (tcTransAddress)
2569 Afields(laWorkAddress)
2570 Create Cursor TargetWA From Array laWorkAddress
2571 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2572
2573 * --- TR 1047609 7/7/10 CM
2574 llSLN = !Empty(tcTransSLN) And Used(tcTransSLN) And Reccount(tcTransSLN) > 0
2575 If llSLN
2576 Select (tcTransSLN)
2577 Afields(laWorkSLN)
2578 Create Cursor TargetSLN From Array laWorkSLN
2579 Endif
2580 * === TR 1047609 7/7/10 CM
2581
2582 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
2583 LOCAL llWhsData
2584 lcTransWhse = "vzzeiPCtWhse_iPCproc"
2585 If Used(lcTransWhse) and RecCount(lcTransWhse) > 0
2586 llWhsData = .T.
2587 Select (lcTransWhse)
2588 =AFields(laWorkWHSE)
2589 Create Cursor TargetWhse from array laWorkWHSE
2590 EndIf
2591 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
2592
2593 WITH THIS
2594
2595 *--- TechRec 1073148 06-Aug-2014 asharma ---
2596
2597 IF .lOptmizedExplodeSDQ
2598
2599 SELECT distinct h.*, 000000000 as pkey, d.store as store, d.edi_center as dedi_center ;
2600 FROM (tcMetaWorkHeader) h, (tcSDQDetailTable) d ;
2601 WHERE h.doc_num = d.doc_num ;
2602 INTO CURSOR _WrkHdr READWRITE
2603
2604 SELECT distinct h.*, 000000000 as pkey, 000000000 as fkey, d.store ;
2605 FROM (tcMetaWorkComment) h, (tcSDQDetailTable) d ;
2606 WHERE h.doc_num = d.doc_num ;
2607 INTO CURSOR _WrkCmt READWRITE
2608
2609 SELECT d.*, d.pkey as oldPkey, d.pkey as fkey ;
2610 FROM (tcSDQDetailTable) d ;
2611 INTO CURSOR _WrkDtl READWRITE
2612
2613 lnHdrRecords = RECCOUNT("_WrkHdr")
2614 lnCmtRecords = RECCOUNT("_WrkCmt")
2615 lnDtlRecords = RECCOUNT("_WrkDtl")
2616
2617 lnLastHeaderPkey = v_NextPkey(tcHeaderPkeyTag, lnHdrRecords )
2618 lnLastCommentPkey = v_NextPkey(tcCommentPkeyTag, lnCmtRecords )
2619 lnLastDetailPkey = v_NextPkey(tcDetailPkeyTag, lnDtlRecords )
2620
2621 REPLACE ALL EDI_Store WITH STORE ;
2622 , store WITH "" ;
2623 , EDI_Center With Iif(!Empty(dedi_center), dedi_center,edi_center) ;
2624 , Pkey with (lnLastHeaderPkey - lnHdrRecords ) + RECNO() ;
2625 IN _WrkHdr
2626
2627 REPLACE ALL pkey WITH (lnLastDetailPkey - lnDtlRecords ) + RECNO();
2628 in _WrkDtl
2629
2630 REPLACE ALL pkey WITH (lnLastCommentPkey - lnCmtRecords ) + RECNO();
2631 IN _WrkCmt
2632
2633 SELECT _WrkHdr
2634 INDEX on Doc_Num+edi_store TAG docNoStore
2635 INDEX on Doc_Num TAG docNum
2636
2637 SELECT _WrkDtl
2638 INDEX on doc_num+store TAG docNostore
2639 SET ORDER TO 0
2640 SET ORDER TO docNoStore IN _WrkHdr
2641 SET RELATION OFF INTO _WrkHdr
2642 SET RELATION TO Doc_Num+store INTO _WrkHdr
2643 REPLACE ALL fkey WITH _WrkHdr.Pkey
2644 SET RELATION OFF INTO _WrkHdr
2645
2646 SELECT _WrkCmt
2647 SET ORDER TO docNoStore IN _WrkHdr
2648 SET RELATION OFF INTO _WrkHdr
2649 SET RELATION TO Doc_Num+store INTO _WrkHdr
2650 REPLACE ALL fkey WITH _WrkHdr.Pkey
2651 SET RELATION OFF INTO _WrkHdr
2652
2653 SELECT doc_num, store, COUNT(store) as scount, MAX(oldpkey) as mRecNO ;
2654 FROM _WrkDtl ;
2655 ORDER BY 1 ,2 ;
2656 GROUP BY 1 ,2 ;
2657 INTO CURSOR _WrkDtlH
2658
2659 SELECT _WrkDtlH
2660 SET ORDER TO docNostore IN _WrkDtl
2661 SCAN
2662 IF SEEK(_WrkDtlH.Doc_Num + _WrkDtlH.store,"_WrkDtl","docNostore")
2663 SELECT _WrkDtl
2664 REPLACE line_seq WITH str(_WrkDtlH.scount - _WrkDtlH.mRecNO + RECNO()) WHILE doc_num + store = _WrkDtlH.Doc_Num + _WrkDtlH.store
2665 ENDIF
2666 SELECT _WrkDtlH
2667 ENDSCAN
2668 SET ORDER TO 0 IN _WrkDtl
2669
2670 IF llSLN
2671
2672 SELECT s.*, s.fkey as oldFkey ;
2673 FROM (tcTransSLN) s ;
2674 INTO CURSOR _WrkSLN READWRITE
2675
2676 lnSlnRecords = RECCOUNT("_WrkSLN")
2677 lnLastSLNPkey = v_NextPkey(tcSLNPkeyTag, lnSlnRecords )
2678
2679 SELECT _WrkDtl
2680 INDEX on oldPkey TAG oldpkey
2681 SET ORDER TO oldpkey
2682
2683 SELECT _WrkSLN
2684 SET RELATION OFF INTO _WrkDtl
2685 SET RELATION TO oldfkey INTO _WrkDtl
2686
2687 REPLACE ALL pkey WITH (lnLastSLNPkey - lnSlnRecords ) + RECNO(),;
2688 fkey WITH _WrkDtl.Pkey ;
2689 IN _WrkSLN
2690
2691 SELECT Doc_Num, PO1_Line ;
2692 FROM _WrkDtl ;
2693 WHERE Doc_Num+PO1_Line NOT IN (SELECT STR(Doc_Num)+PO1_Line from (tcTransDetail) WITH (buff = .t.)) ;
2694 INTO CURSOR _msngDP
2695
2696 SELECT _msngDP
2697 SCAN
2698 .logEntry("No DOC_NUM, PO1_Line found for: " + Doc_Num + " | " + PO1_Line)
2699 ENDSCAN
2700
2701 ENDIF
2702
2703 SELECT _WrkHdr
2704
2705 SCAN
2706
2707 lnCurrentDoc_num = VAL(Doc_Num)
2708
2709 SELECT (tcTransHeader)
2710 If Seek(lnCurrentDoc_num,tcTransHeader,"doc_num")
2711 lcOrder = Set("Order")
2712 Set Order To Doc_Num
2713 Delete While Doc_Num = lnCurrentDoc_num
2714 set order to &lcOrder
2715 Endif
2716
2717 SELECT (tcTransComment)
2718 If Seek(lnCurrentDoc_num,tcTransComment,"doc_num")
2719 lcOrder = Set("Order")
2720 Set Order To Doc_Num
2721 Delete While Doc_Num = lnCurrentDoc_num
2722 set order to &lcOrder
2723 Endif
2724
2725 SELECT (tcTransDetail)
2726 If Seek(lnCurrentDoc_num,tcTransDetail,"doc_num")
2727 lcOrder = Set("Order")
2728 Set Order To Doc_Num
2729 Delete While Doc_Num = lnCurrentDoc_num
2730 set order to &lcOrder
2731 Endif
2732
2733 IF llSLN
2734 SELECT (tcTransSLN)
2735 If Seek(lnCurrentDoc_num,tcTransSLN,"doc_num")
2736 lcOrder = Set("Order")
2737 Set Order To Doc_Num
2738 Delete While Doc_Num = lnCurrentDoc_num
2739 set order to &lcOrder
2740 ENDIF
2741 ENDIF
2742
2743 SELECT _WrkHdr
2744
2745 ENDSCAN
2746
2747 SET ORDER TO 0 IN _WrkHdr
2748 SET ORDER TO 0 IN _WrkDtl
2749
2750 SELECT _WrkHdr
2751 lcDBFName = DBF()
2752 SELECT (tcTransHeader)
2753 APPEND FROM (lcDBFName)
2754
2755 SELECT _WrkCmt
2756 lcDBFName = DBF()
2757 SELECT (tcTransComment)
2758 APPEND FROM (lcDBFName)
2759
2760 SELECT _WrkDtl
2761 lcDBFName = DBF()
2762 SELECT (tcTransDetail)
2763 APPEND FROM (lcDBFName)
2764
2765 IF llSLN
2766 SELECT _WrkSLN
2767 lcDBFName = DBF()
2768 SELECT (tcTransSLN)
2769 APPEND FROM (lcDBFName)
2770 ENDIF
2771
2772 IF llSLN
2773 LOCAL laTables[6]
2774 laTables[6] = "_WrkSLN"
2775 ELSE
2776 LOCAL laTables[5]
2777 ENDIF
2778 laTables[1] = "_WrkHdr"
2779 laTables[2] = "_WrkDtl"
2780 laTables[3] = "_WrkCmt"
2781 laTables[4] = "_WrkDtlH"
2782 laTables[5] = "_msngDP"
2783 .TableClose(@laTables)
2784
2785 ELSE
2786
2787 *=== TechRec 1073148 06-Aug-2014 asharma ===
2788
2789 * number of SDQ Orders (by doc_num) to explode
2790 SELECT doc_num, pkey FROM (tcSDQDetailTable) INTO CURSOR tcSDQOrds GROUP BY doc_num
2791
2792 SELECT tcSDQOrds
2793 SCAN && group of SDQ orders (doc_num)
2794
2795 * The following _Wrk### will hold template orders to be expode to multiple base
2796 * on group by store,UPC,SKU in detail SDQ work table
2797 lcCurrentDoc_num= tcSDQOrds.doc_num
2798 SELECT * FROM (tcMetaWorkHeader) INTO CURSOR _WrkHdr WHERE doc_num= lcCurrentDoc_num
2799 SELECT * FROM (tcMetaWorkComment) INTO CURSOR _WrkCmt WHERE doc_num= lcCurrentDoc_num
2800
2801 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2802 Select * From (tcMetaWorkAddress) Into Cursor _WrkAdr Where doc_num= lcCurrentDoc_num
2803 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2804
2805 SELECT * FROM (tcSDQDetailTable) INTO CURSOR _WrkDtl WHERE doc_num= lcCurrentDoc_num ;
2806 ORDER BY STORE, upc, sku, ean
2807
2808 * Get current header image into Memvar (only one per doc_num)
2809 SELECT _WrkHdr
2810 SCATT MEMVAR MEMO
2811 lnCurrentStart_date= m.start_date
2812 lnCurrentEnd_Date= m.end_date
2813
2814 * Get pkey for ALL headers (ZZEIPCTH- tag)
2815 SELECT STORE FROM _WrkDtl GROUP BY STORE INTO CURSOR tcHdrCnt
2816 lnOrdersHeaderToExplode = RECC("tcHdrCnt")
2817 USE IN tcHdrCnt
2818 lnLastHeaderPkey = v_NextPkey(tcHeaderPkeyTag, lnOrdersHeaderToExplode)
2819
2820 * Get pkey for ALL detail we're about to create (ZZEIPCID- tag)
2821 lnOrdersLineToExplode = RECC("_WrkDtl")
2822 lnLastDetailPkey = v_NextPkey(tcDetailPkeyTag, lnOrdersLineToExplode)
2823
2824 * Get pkey for ALL order comments we're about to create (ZZEIPOID- tag)
2825 lnTotalCommentLines = RECC("_WrkCmt")
2826 IF lnTotalCommentLines>0
2827 lnLastCommentPkey = v_NextPkey(tcCommentPkeyTag, lnOrdersHeaderToExplode * lnTotalCommentLines)
2828 lnCurrentCommentLines = 0
2829 ENDIF
2830
2831 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2832 lnTotalAddressLines = Recc("_WrkAdr")
2833 If lnTotalAddressLines>0
2834 lnLastAddressPkey = v_NextPkey(tcAddressPkeyTag, lnOrdersHeaderToExplode * lnTotalAddressLines)
2835 lnCurrentAddressLines = 0
2836 Endif
2837 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2838
2839 lnHdrCnt = 0
2840 lnDtlCnt = 0
2841 lnOrd_qty = 0
2842 lcPreviousStore = ""
2843 SELECT _WrkDtl
2844
2845 SCAN
2846 * restore header start/end_date back (SDQ explotion order all start/end-date same
2847 * as the template header
2848 m.start_date= lnCurrentStart_date
2849 m.end_date= lnCurrentEnd_Date
2850
2851 * start of store level break*********************************************************
2852 * Each time store change create order header
2853 IF !(STORE == lcPreviousStore)
2854 lnHdrCnt = lnHdrCnt + 1
2855 *
2856 * Calc next pkey b/c we got all of them at once
2857 lnCurrentHeaderPkey = (lnLastHeaderPkey - lnOrdersHeaderToExplode) + lnHdrCnt
2858 m.pkey = lnCurrentHeaderPkey && header pkey
2859 m.Store = _WrkDtl.STORE && assign header store with explode store
2860
2861 lnLine_seq = 0 && reset lnLine_seq
2862 * replace ord_qty for current order header
2863 * before insert a new order header
2864 * For order header does not need to accumulate as in Multi-store
2865 * will be recalculate before stuff to live tables
2866 SELECT TargetWH
2867 APPEND BLANK
2868 GATHER MEMVAR MEMO
2869
2870 * Exchange store with EDI_Store
2871 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli ---
2872 *REPLACE EDI_Store WITH STORE, STORE WITH "" IN TargetWH
2873 REPLACE EDI_Store WITH STORE, ;
2874 STORE WITH "", ;
2875 EDI_Center With Iif(!Empty(_WrkDtl.edi_center), _WrkDtl.edi_center,_WrkHdr.edi_center) ;
2876 IN TargetWH
2877 *=== TechRec 1061414 01-Oct-2012 TShenbagavalli ===
2878
2879 IF lnTotalCommentLines>0
2880 * use current comment lines for pkey calculation smallest pkey 1st
2881 SELECT _WrkCmt
2882 SCAN
2883 SCATT MEMVAR MEMO
2884 lnCurrentCommentLines = lnCurrentCommentLines + 1
2885 m.pkey = (lnLastCommentPkey - (lnOrdersHeaderToExplode * lnTotalCommentLines)) + ;
2886 lnCurrentCommentLines
2887 m.fkey = lnCurrentHeaderPkey
2888 SELECT TargetWC
2889 APPEND BLANK
2890 GATHER MEMVAR MEMO
2891 ENDSCAN
2892 ENDIF
2893
2894 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2895 If lnTotalAddressLines>0
2896 * use current Address lines for pkey calculation smallest pkey 1st
2897 Select _WrkAdr
2898 Scan
2899 Scatt Memvar Memo
2900 lnCurrentAddressLines = lnCurrentAddressLines + 1
2901 m.Pkey = (lnLastAddressPkey - (lnOrdersHeaderToExplode * lnTotalAddressLines)) + ;
2902 lnCurrentAddressLines
2903 m.Fkey = lnCurrentHeaderPkey
2904 Select TargetWA
2905 Append Blank
2906 Gather Memvar Memo
2907 Endscan
2908 Endif
2909 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2910
2911 * keep track of Previous Store
2912 lcPreviousStore = m.Store
2913 ENDIF && End of store level break****************************************************
2914
2915 *Create order detail using template _WrkDtl (combine of DTL+SDQ)
2916 SELECT _WrkDtl
2917 lnDtlCnt = lnDtlCnt + 1
2918 SCATTER MEMVAR MEMO
2919
2920 m.fkey = lnCurrentHeaderPkey && Sync detail fkey with header pkey
2921 m.pkey = (lnLastDetailPkey - lnOrdersLineToExplode) + lnDtlCnt && Detail pkey
2922
2923 lnLine_seq = lnLine_seq + 1 && incr. lnLine_seq
2924 m.line_seq = lnLine_seq && next line_seq
2925 SELECT TargetWD
2926 APPEND BLANK
2927 GATHER MEMVAR MEMO
2928
2929 * --- TR 1047609 7/7/10 CM
2930 If llSLN
2931 lnNewDtlPKey = m.pkey
2932 lcPO1_Line = PO1_Line
2933 lcDoc_Num = Doc_Num
2934 Select (tcTransDetail)
2935 If Not Seek(Str(lcDoc_Num) + lcPO1_Line,tcTransDetail,"PO1_Line")
2936 .logEntry("No DOC_NUM, PO1_Line found for: " + Transform(lcDoc_Num) + " | " + lcPO1_Line)
2937 Endif
2938 lnOldDtlPKey = Pkey
2939 lnOldHdrPKey = Fkey
2940
2941 If llSLN
2942 Select (tcTransSLN)
2943 lnCnt = 0
2944 If Seek(lnOldDtlPKey,tcTransSLN,"fkey")
2945 lcOrder = Set("Order")
2946 Set Order To Tag Fkey
2947 Scan While Fkey = lnOldDtlPKey
2948 Scatter Memvar Memo
2949 Select TargetSLN
2950 Append Blank
2951 Gather Memvar Memo
2952 lnCnt = lnCnt + 1
2953 Replace Fkey With lnNewDtlPKey
2954 Endscan
2955 Set Order To &lcOrder
2956 Endif
2957 If lnCnt > 0
2958 m.Pkey = v_NextPkey(tcSLNPkeyTag, lnCnt) + 1
2959 Select TargetSLN
2960 For i = 1 To lnCnt
2961 Replace Pkey With m.Pkey - i
2962 Skip -1
2963 Endfor
2964 Endif
2965 EndIf
2966 Endif
2967 * === TR 1047609 7/7/10 CM
2968
2969 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
2970 If llWhsData
2971 Select (lcTransWhse)
2972 lnCnt = 0
2973 If Seek(lnOldDtlPKey,lcTransWhse,"dFKey")
2974 lcOrder = Set("Order")
2975 Set Order To Tag dfkey
2976 Scan While dfkey = lnOldDtlPKey
2977 lnOldHdrPKey = hfkey
2978 Scatter Memvar Memo
2979 m.store = _WrkDtl.Store
2980 Select TargetWhse
2981 Append Blank
2982 Gather Memvar Memo
2983 lnCnt = lnCnt + 1
2984 Replace dfkey With lnNewDtlPKey, ;
2985 hfkey With lnCurrentHeaderPkey
2986 Endscan
2987 Set Order To &lcOrder
2988 ENDIF
2989
2990 IF llFirstDetail
2991 lcSeek = Alltrim(Str(lnOldHdrPKey)) + "0"
2992 If SEEK(lcSeek, lcTransWhse, "h_dfkey")
2993 lcOrder = SET("Order")
2994 SET ORDER TO TAG hfkey
2995 SCAN WHILE hfkey = lnOldHdrPKey And dfkey = 0
2996 SCATTER MEMVAR MEMO
2997 SELECT TargetWhse
2998 APPEND BLANK
2999 GATHER MEMVAR MEMO
3000 lnCnt = lnCnt + 1
3001 REPLACE dfkey WITH 0, ;
3002 hfkey WITH lnCurrentHeaderPkey
3003 ENDSCAN
3004 SET ORDER TO &lcOrder
3005 ENDIF
3006 ENDIF
3007 llFirstDetail = False
3008
3009 If lnCnt > 0
3010 m.PKey = v_NextPkey("ZZEIPCTWHSE", lnCnt) + 1
3011 Select TargetWhse
3012 For i = 1 To lnCnt
3013 Replace PKey With m.PKey - i
3014 Skip -1
3015 EndFor
3016 Endif
3017 ENDIF
3018 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3019
3020 ENDSCAN
3021
3022 * Delete Template order
3023 lnCurrentDoc_num=VAL(lcCurrentDoc_num)
3024 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransHeader)
3025 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransDetail)
3026 *- 1015091 01/13/06 YIK
3027 *-Delete For doc_num=lnCurrentDoc_num In (tcInterfaceComment)
3028 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransComment)
3029
3030 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3031 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransAddress)
3032 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3033
3034 * --- TR 1047609 7/7/10 CM
3035 If llSLN
3036 Select (tcTransSLN)
3037 If Seek(lnCurrentDoc_num,tcTransSLN,"doc_num")
3038 lcOrder = Set("Order")
3039 Set Order To Doc_Num
3040 Delete While Doc_Num = lnCurrentDoc_num
3041 set order to &lcOrder
3042 Endif
3043 Endif
3044 * === TR 1047609 7/7/10 CM
3045
3046 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3047 IF llWhsData
3048 Select (lcTransWhse)
3049 If Seek(lnCurrentDoc_num,lcTransWhse,"doc_num")
3050 lcOrder = Set("Order")
3051 Set Order To doc_num
3052 Delete While doc_num = lnCurrentDoc_num
3053 set order to &lcOrder
3054 Endif
3055
3056 ENDIF
3057 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3058
3059 ENDSCAN && all doc_num,store,upc,sku
3060
3061 * Append all exploded orders into Interfact tables
3062 SELECT TargetWH
3063 lcDBFName = DBF()
3064 SELECT (tcTransHeader)
3065 APPEND FROM (lcDBFName)
3066 SELECT TargetWD
3067 lcDBFName = DBF()
3068 SELECT (tcTransDetail)
3069 APPEND FROM (lcDBFName)
3070 SELECT TargetWC
3071 lcDBFName = DBF()
3072 SELECT (tcTransComment)
3073 APPEND FROM (lcDBFName)
3074
3075 * --- TR 1047609 7/7/10 CM
3076 IF llSLN
3077 Select (tcTransSLN)
3078 Append From Dbf("TargetSLN")
3079 Endif
3080 * === TR 1047609 7/7/10 CM
3081
3082 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3083 Select TargetWA
3084 lcDBFName = Dbf()
3085 Select (tcTransAddress)
3086 Append From (lcDBFName)
3087
3088 If llWhsData
3089 Select (lcTransWhse)
3090 Append From (Dbf("TargetWhse"))
3091 ENDIF
3092 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3093
3094 SELECT _WrkHdr
3095 SCATT MEMVAR MEMO BLANK
3096 SELECT _WrkDtl
3097 SCATT MEMVAR MEMO BLANK
3098 SELECT _WrkCmt
3099 SCATT MEMVAR MEMO BLANK
3100
3101 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
3102 Select _WrkAdr
3103 Scatter Memvar Memo Blank
3104 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
3105
3106 * cleanup temp tables
3107 * --- TR 1047609 7/7/10
3108 * Changed dimension from 6 to 7
3109 &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli changed dimension from 7 to 10 ===
3110 LOCAL laTables[10]
3111 laTables[1] = "TargetWH"
3112 laTables[2] = "TargetWD"
3113 laTables[3] = "_WrkHdr"
3114 laTables[4] = "_WrkDtl"
3115 laTables[5] = "TargetWC"
3116 laTables[6] = "_WrkCmt"
3117
3118 * --- TR 1047609 7/7/10 CM
3119 laTables[7] = "TargetSLN"
3120 * === TR 1047609 7/7/10 CM
3121
3122 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3123 laTables[8] = "TargetWA"
3124 laTables[9] = "_WrkAdr"
3125 laTables[10]= "TargetWhse"
3126 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3127
3128 .TableClose(@laTables)
3129
3130 ENDIF &&--- TechRec 1073148 06-Aug-2014 asharma ===
3131
3132 ENDWITH
3133
3134 SELECT (lnOldSele)
3135 RETURN llRetVal
3136 ENDPROC
3137
3138 PROCEDURE LoadHeaderDetailNotes
3139 *--- TR 1016589 05/05/06 NH adding parameter tcTransHdrNotes, tcTransDtlNotes, tcDocCount
3140 PARAMETER tcHNTFlatFile, tcDNTFlatFile, tcTransHeader, tcTransDetail, tcTransHdrNotes, tcTransDtlNotes, tcDocCount
3141 LOCAL llRetVal, lnOldSelect, lcNotes, llHaveNotes, lcCurrDoc_num, lcCurrNote_type
3142 llRetVal = .T.
3143 lnOldSelect = SELECT()
3144 *--- TR 1016589 NH 05/05/06 NH
3145 LOCAL llRetVal, lnOldSelect, lcNotes, llHaveNotes, lcCurrDoc_num, lcCurrNote_type, lcUser_ID, ltLast_mod, lnSeq
3146 lcUser_ID = EDI_USER
3147 ltLast_mod = DATETIME()
3148 lnSeq = 0
3149 *==== TR 1016589 NH
3150
3151 WITH THIS
3152 * Accumulate all notes per doc_num and write them in proper
3153 * Header notes record
3154 IF THIS.CountTotalRecs (tcHNTFlatFile)>0
3155 .oLog.LogEntry("Loading header notes.")
3156 lcNotes= ""
3157 lcCurrDoc_num= ""
3158 lcCurrNote_type = ""
3159
3160 llHaveNotes= .F.
3161 SELECT (tcHNTFlatFile)
3162 INDEX ON doc_num + note_type TAG doc_num
3163 SCAN
3164 IF lcCurrDoc_num= doc_num AND lcCurrNote_type = note_type
3165 IF !EMPTY(notes)
3166 *--- TR 1016589 NH : Use all trim to remove empty space
3167 lcNotes= lcNotes + ALLTRIM(notes) + CRLF && Accumulate all notes lines
3168 llHaveNotes= .T.
3169 ENDIF
3170 ELSE
3171 IF llHaveNotes
3172 *--- TR 1016589 NH
3173 lnSeq = lnSeq + 1
3174 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3175*!* .WriteNotes(lcCurrDoc_num, tcTransHeader, "doc_num", lcNotes , ;
3176*!* "allt((str(doc_num))) = '" + ALLT(lcCurrDoc_num) + "'")
3177 .WriteHdrSysNotes(lcCurrDoc_num, VAL(ALLT(lcCurrDoc_num)), ;
3178 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
3179 tcTransHdrNotes, tcTransHeader, lnDoc_count)
3180 *=== TR 1016589 NH
3181 ENDIF
3182 *--- TR 1016589 NH
3183 IF NOT lcCurrDoc_num = doc_num
3184 lnSeq = 0
3185 ENDIF
3186 *=== TR 101689 NH
3187 lcCurrDoc_num= doc_num
3188 lcCurrNote_type = note_type
3189
3190 IF !EMPTY(notes)
3191 *---- TR 1016589 NH
3192*!* SELECT COUNT(*) FROM &tcHNTFlatFile ;
3193*!* WHERE !EMPTY(note_type) AND doc_num = lcCurrDoc_num ;
3194*!* INTO ARRAY laNT
3195*!* llHasNoteType = (laNT[1] > 0)
3196*!* IF llHasNoteType
3197*!* lcNotes = IIF(!EMPTY(lcNotes), "|", "") + ;
3198*!* IIF(EMPTY(lcCurrNote_type), "EDI", lcCurrNote_type) + "|" + notes + CRLF
3199*!* ELSE
3200*!* lcNotes= notes + CRLF && Accumulate all notes lines
3201*!* ENDIF
3202 *=
3203 lcNotes = ALLTRIM(notes) + CRLF && Accumulate all notes lines
3204 *=== TR 1016589 NH
3205 llHaveNotes= .T.
3206 ELSE
3207 llHaveNotes= .F.
3208 ENDIF
3209 ENDIF
3210 ENDSCAN
3211 IF llHaveNotes
3212 *--- TR 1016589 NH
3213 lnSeq = lnSeq + 1
3214*!* .WriteNotes(lcCurrDoc_num, tcTransHeader, "doc_num", lcNotes, ;
3215*!* "allt((str(doc_num))) = '" + ALLT(lcCurrDoc_num) + "'" ) && 29656
3216 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3217 .WriteHdrSysNotes(lcCurrDoc_num, VAL(ALLT(lcCurrDoc_num)) , ;
3218 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
3219 tcTransHdrNotes, tcTransHeader, lnDoc_count)
3220
3221 *=== TR 1016589 NH
3222 ENDIF
3223 ENDIF
3224
3225 IF THIS.CountTotalRecs (tcDNTFlatFile)>0
3226 .oLog.LogEntry("Loading detail notes.")
3227 lcNotes= ""
3228 lcCurrCkey= ""
3229 *--- TR 1016589 NH
3230 lcCurrNote_type = ""
3231 lcCurrDoc_num = ""
3232 *=== TR 1016589 NH
3233 llHaveNotes= .F.
3234 SELECT (tcDNTFlatFile)
3235 INDEX ON ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) TAG Ckey
3236 SCAN
3237 *--- TR 1016589 NH Added condition : lcCurrNote_type = note_type
3238 IF lcCurrCkey= ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) AND lcCurrNote_type = note_type
3239 IF !EMPTY(notes)
3240 *--- TR 1016589 NH : Remove space
3241 lcNotes= lcNotes + ALLTRIM(notes) + CRLF && Accumulate all notes lines
3242 llHaveNotes= .T.
3243 ENDIF
3244 ELSE
3245 IF llHaveNotes
3246 *--- TR 1016589 NH
3247 lnSeq = lnSeq + 1
3248*!* .WriteNotes(lcCurrCkey, tcTransDetail, "CKey", lcNotes, ;
3249*!* "allt(str(doc_num))+allt(upc)+allt(sku)+allt(ean) = '" + ALLT(lcCurrCkey) + "'")
3250 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3251 .WriteDtlSysNotes(ALLT(lcCurrCkey),;
3252 "Ckey",lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod,lnSeq,;
3253 tcTransDtlNotes, tcTransDetail, lnDoc_count)
3254 *=== TR 1016589 NH
3255 ENDIF
3256 *--- TR 1016589 NH
3257 IF NOT lcCurrCkey = ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean)
3258 lnSeq = 0
3259 ENDIF
3260 lcCurrDoc_num = ALLTRIM(doc_num)
3261 *=== TR 1016589 NH
3262 lcCurrCkey= ALLTRIM(STR(VAL(doc_num)))+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean)
3263 IF !EMPTY(notes)
3264 *--- TR 1016589 NH : Removing space
3265 lcNotes= ALLTRIM(notes) + CRLF && Accumulate all notes lines
3266 llHaveNotes= .T.
3267 ELSE
3268 llHaveNotes= .F.
3269 ENDIF
3270 ENDIF
3271 ENDSCAN
3272
3273 IF llHaveNotes
3274 *--- TR 1016589 NH
3275*!* .WriteNotes(lcCurrCkey, tcTransDetail, "CKey", lcNotes, ;
3276*!* "allt(str(doc_num))+allt(upc)+allt(sku)+allt(ean) = '" + ALLT(lcCurrCkey) + "'")
3277 lnSeq = lnSeq + 1
3278 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3279 .WriteDtlSysNotes(ALLT(lcCurrCkey),;
3280 "Ckey", lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod,lnSeq,;
3281 tcTransDtlNotes, tcTransDetail, lnDoc_count)
3282 *=== TR 1016589 NH
3283 ENDIF
3284 ENDIF
3285
3286 ENDWITH
3287 SELECT(lnOldSelect)
3288 RETURN llRetVal
3289 ENDPROC
3290
3291 ************************************************************************************
3292
3293 PROCEDURE WriteNotes
3294 PARAMETER tcCurrKey, tcTransTable , tcTag, tcNotes, tcSameKeys
3295 LOCAL llRetVal, lnOldSelect
3296 lnOldSelect= SELECT()
3297 llRetVal= .T.
3298 SELECT (tcTransTable)
3299 SET ORDER TO tcTag
3300 IF SEEK(tcCurrKey, tcTransTable, tcTag)
3301 SCAN WHILE &tcSameKeys
3302 REPLACE notes WITH ALLTRIM(notes) + tcNotes ;
3303 IN (tcTransTable)
3304 ENDSCAN
3305 SET ORDER TO
3306 ENDIF
3307 SELECT(lnOldSelect)
3308 RETURN llRetVal
3309 ENDPROC
3310
3311 *--- TR 1016589 NH 05/05/06
3312 ************************************************************************************
3313
3314 PROCEDURE GetDocNumCount
3315 LPARAMETERS tcDocCount, tcDoc_num
3316
3317 LOCAL lnDoc_count, lnOldSelect
3318 lnOldSelect = SELECT()
3319 lnDoc_count = 1
3320 IF NOT EMPTY(tcDocCount) && if there is SDQ (multi orders with same doc_num)
3321 SELECT (tcDocCount)
3322 IF SEEK(tcDoc_num)
3323 lnDoc_count = Doc_count
3324 ENDIF
3325 ENDIF
3326
3327 SELECT(lnOldSelect)
3328 RETURN lnDoc_count
3329 ENDPROC
3330
3331 ***********************************************************************************
3332
3333 PROCEDURE CreateDocStoreCursor
3334 LPARAMETERS tcDtl_SDQ, tcDocCount
3335 LOCAL lnOldSelect, llRetVal
3336
3337 llRetVal = .t.
3338 lnOldSelect = SELECT()
3339 lcDocCountTmp = tcDocCount + "_TMP"
3340 *--- narrow down to doc_num and store
3341 SELECT DISTINCT doc_num, store FROM (tcDTl_SDQ) INTO CURSOR (lcDocCountTmp)
3342 *--- find the number of stores for each doc_num this will be used to create Notes pkey
3343 SELECT doc_num, count(*) as Doc_count FROM (lcDocCountTmp) GROUP BY doc_num INTO CURSOR (tcDocCount)
3344 INDEX ON doc_num TAG doc_num
3345 IF USED(lcDocCountTmp)
3346 USE IN (lcDocCountTmp)
3347 ENDIF
3348 SELECT(lnOldSelect)
3349 RETURN llRetVal
3350 ENDPROC
3351
3352 ***********************************************************************************
3353
3354 PROCEDURE WriteHdrSysNotes
3355 LPARAMETERS tcDoc_num, tcExpr, tcNote_type, tcNotes, tcuser_id, ttLast_mod, tnSeq, tcInterfaceHdrNotes, tcInterfaceHdr, tnDocCount)
3356 LOCAL lnOldSelect, llRetVal, lcHdrPkey, lcExpr, lnPkey
3357 LOCAL lnMaxPkey
3358 lnOldSelect = SELECT()
3359 llRetVal = .T.
3360 lcExpr = tcExpr
3361
3362 SELECT (tcInterfaceHdr)
3363 SET ORDER TO TAG doc_num
3364 lnMaxPkey = v_nextPkey('sysnotes', tnDocCount)
3365 lnPkey = lnMaxPkey - tnDocCount
3366 SELECT (tcInterfaceHdr)
3367 IF SEEK (lcExpr)
3368 SCAN WHILE doc_num = tcExpr
3369 lcHdrPkey = pkey
3370 lnPkey = lnPkey + 1
3371 IF lnPkey > lnMaxPkey
3372 *--- It should not come to this point. But in case it does, pkey will not over lap.
3373 lnPkey = v_nextPkey('sysnotes')
3374 ENDIF
3375 SELECT(tcInterfaceHdrNotes)
3376 APPEND BLANK
3377 SCATTER NAME loHdrNotes MEMO BLANK
3378 loHdrNotes.table_Name = "ZZEIPCTH"
3379 loHdrNotes.fkey = lcHdrPkey
3380 loHdrNotes.note_type = IIF(EMPTY(tcNote_type),"EDI",tcNote_type)
3381 loHdrNotes.notes = tcNotes
3382 loHdrNotes.Last_mod = ttLast_mod
3383 loHdrNotes.User_id = tcuser_id
3384 loHdrNotes.Seq = tnSeq
3385 loHdrNotes.pkey = lnPkey
3386 loHdrNotes.CascadeNote = 'N'
3387 loHdrNotes.COMMENT = "DEFAULT"
3388 loHdrNotes.note_date = ttLast_mod
3389 GATHER NAME loHdrNotes MEMO
3390 ENDSCAN
3391 ENDIF
3392 SELECT(lnOldSelect)
3393 RETURN llRetVal
3394 ENDPROC
3395
3396 ***********************************************************************************
3397
3398 PROCEDURE WriteDtlSysNotes
3399 LPARAMETERS tcExpr, tcOrderby, tcNote_type, tcNotes, tcuser_id,;
3400 ttLast_mod, tnSeq, tcInterfaceDtlNotes, tcInterfaceDtl, tnDoc_count)
3401
3402 LOCAL lnOldSelect, llRetVal, lcDtlPkey, lcHdrPkey, lcExpr, lnPkey, lnLine_seq
3403 lnOldSelect = SELECT()
3404 llRetVal = .T.
3405 lcExpr = tcExpr
3406 lnLine_seq = 0
3407 *--- collect pkey form tcInterfaceHdr
3408 SELECT (tcInterfaceDtl)
3409 SET ORDER TO (tcOrderby)
3410 IF SEEK (lcExpr)
3411 LOCAL lcFlds
3412 lcFlds = SYS(14,VAL(SYS(21)))
3413 lnMaxPkey = v_nextPkey('sysnotes', tnDoc_count)
3414 lnPkey = lnMaxPkey - tnDoc_count
3415 SCAN WHILE &lcFlds == tcExpr
3416 lnPkey = lnPkey + 1
3417 *--- this is only when flat file has multiple UPCs for same doc_num
3418 *--- also, when same store is used multiple times at SDQ
3419 IF lnPkey > lnMaxPkey
3420 lnPkey = v_nextPkey('sysnotes')
3421 ENDIF
3422 lcHdrPkey = fkey
3423 lcDtlPkey = pkey
3424 lnLine_seq = line_seq
3425 SELECT(tcInterfaceDtlNotes)
3426 APPEND BLANK
3427 SCATTER NAME loDtlNotes MEMO BLANK
3428 loDtlNotes.table_Name = "ZZEIPCTD"
3429 loDtlNotes.fkey = lcDtlPkey
3430 loDtlNotes.parentkey = lcHdrPkey
3431 loDtlNotes.note_type = IIF(EMPTY(tcNote_type),"EDI",tcNote_type)
3432 loDtlNotes.notes = tcNotes
3433 loDtlNotes.Last_mod = ttLast_mod
3434 loDtlNotes.User_id = tcuser_id
3435 loDtlNotes.Seq = tnSeq
3436 loDtlNotes.pkey = lnPkey
3437 loDtlNotes.CascadeNote = 'N'
3438 loDtlNotes.COMMENT = "DEFAULT"
3439 loDtlNotes.line_seq = lnLine_seq
3440 loDtlNotes.note_date = ttLast_mod
3441 GATHER NAME loDtlNotes MEMO
3442 ENDSCAN
3443 ENDIF
3444
3445 SELECT(lnOldSelect)
3446 RETURN llRetVal
3447 ENDPROC
3448
3449 ***********************************************************************************
3450 *=== TR 1016589 NH 05/05/06
3451
3452 PROCEDURE PreValidation
3453 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3454 *--- TR 1050827 24-NOV-2010 HNISAR && Added plSkipSLNUpdate
3455 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
3456 PARAMETERS pceipcTH, pceipcTD, pceipcCR, pceipcTS,plSkipSLNUpdate, pceipcTWHSE
3457 LOCAL llRetVal, lcSQLSelect, lcSQLOrder
3458 llRetVal = .T.
3459 WITH THIS
3460 .LogMajorStage("Validating transactions.") && TR 1016560 NH
3461 .oLog.LogEntry("Resetting all error messages in transaction tables.")
3462 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
3463 vcLogName)
3464
3465 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3466 *llRetVal= llRetVal AND .ClearErrors(pceipcTH, pceipcTD)
3467 llRetVal= llRetVal AND .ClearErrors(pceipcTH, pceipcTD, pceipcTS)
3468 * === TR 1047609 7/7/10 CM
3469
3470 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
3471 vcLogName)
3472 llRetVal= llRetVal AND .CheckHeader(pceipcTH, pceipcCR, pceipcTD) &&--- TR 1036066 NH
3473 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU...", ;
3474 vcLogName)
3475
3476 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3477 *llRetVal= llRetVal AND .CheckDetail(pceipcTH, pceipcTD, pceipcCR)
3478 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceiPCTWhse ===
3479 llRetVal= llRetVal AND .CheckDetail(pceipcTH, pceipcTD, pceipcCR, pceipcTS, pceiPCTWhse)
3480 * === TR 1047609 7/7/10 CM
3481
3482 .AdvanceThermoTotalWithCaptionPlus("Updating header division from detail...", ;
3483 vcLogName)
3484 llRetVal= llRetVal AND .UpdtHeaderDivs(pceipcTH, pceipcTD)
3485
3486 *--- TR 1023071 04/03/07 NH
3487 *--- TR 1048865 23-Mar-2011 Goutam. Deleted following and moved to CheckHeader
3488*!* .LogEntry("Populating division for transaction header with no detail.")
3489*!* llRetVal = llRetVal and .CheckPoAndPopulateHdrDivision(pceipcTH)
3490*!* .LogEntry("Populating division for transaction header with no detail " + IIF(llRetVal,"completed.","failed."))
3491 *=== TR 1048865 23-Mar-2011 Goutam
3492
3493 *=== 1023071 04/03/07 NH
3494
3495 .AdvanceThermoTotalWithCaptionPlus("Populating implosion flag to transaction header.")
3496 .LogEntry("Populating implosion flag to transaction header.")
3497 llRetVal = llRetVal AND .PopulatingImplosionFlag(pceipcTH, pceipcCR)
3498
3499 *--- TR 1016560 NH
3500 *--- TR 1047609 7/7/10 CM --- Added tcEiPCts
3501 *llRetVal = llRetVal and .TableUpdateTransaction("tcEiPCth", "tcEiPCtd", "tcEiPCtC")
3502 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tceipcTWHSE ===
3503 llRetVal = llRetVal and .TableUpdateTransaction("tcEiPCth", "tcEiPCtd", "tcEiPCtC", "", "", "tcEiPCts",plSkipSLNUpdate,"tceipcTWHSE")
3504 *=== TR 1016560 NH
3505
3506 ENDWITH
3507 RETURN llRetVal
3508 ENDPROC
3509
3510
3511 *--- TR 1017209 NH
3512 ********************************************************************************
3513 PROCEDURE UpdateAutoProcFlag
3514 LPARAMETERS pceIPCth, pceIPCcr
3515 LOCAL llRetVal, lnOldSelect
3516 llRetVal = .t.
3517 lnOldSelect = SELECT()
3518 SELECT(pceIPCth)
3519 SCAN
3520
3521 *--- TR 1072834 22-Aug-2013 Goutam
3522*!* *--- TR 1048865 27-Dec-2010 Goutam
3523*!* *IF EMPTY(auto_proc) AND SEEK(division+customer,pceIPCcr,'divcust')
3524*!* IF EMPTY(auto_proc) AND SEEK(cr_pkey,pceIPCcr,'pkey')
3525*!* *=== TR 1048865 27-Dec-2010 Goutam
3526
3527*!* replace auto_proc with zzeipccr.auto_proc IN (pceIPCth)
3528*!* ENDIF
3529
3530 IF SEEK(cr_pkey, pceIPCcr, 'pkey')
3531 IF EMPTY(auto_proc)
3532 replace auto_proc with zzeipccr.auto_proc IN (pceIPCth)
3533 ENDIF
3534 IF EMPTY(ignore_warn)
3535 replace ignore_warn with zzeipccr.ignore_warn IN (pceIPCth)
3536 ENDIF
3537 ENDIF
3538 *=== TR 1072834 22-Aug-2013 Goutam
3539
3540 ENDSCAN
3541
3542 SELECT(lnOldSelect)
3543 RETURN llRetVal
3544 ENDPROC
3545 **********************************************************************************
3546 *=== TR 1017209 NH
3547
3548 ************************************************************************************
3549 * Clear all previous errors
3550 ************************************************************************************
3551 PROCEDURE ClearErrors
3552 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3553 LPARAMETERS pceipcTH, pceipcTD, pceipcTS
3554 LOCAL llRetVal, lnOldSelect, laTables[2]
3555 llRetVal = .T.
3556 lnOldSelect = SELECT()
3557
3558 REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipcTH)
3559 REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipcTD)
3560 REPLACE Errs_Msg_D WITH "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D WITH "Y" ;
3561 FOR EMPTY(sku) AND EMPTY(upc) AND EMPTY(ean) AND EMPTY(size_desc) IN (pceipcTD)
3562
3563 * --- TR 1047609 7/7/10 CM
3564 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipcTS)
3565 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
3566 For Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipcTS)
3567 * === TR 1047609 7/7/10 CM
3568
3569 *--- TR 1072834 20-Aug-2013 Goutam
3570 REPLACE ALL warn_msg_H WITH "", warn_flg_h WITH "N" IN (pceipcTH)
3571 REPLACE ALL warn_Msg_D WITH "", warn_Flg_D WITH "N" IN (pceipcTD)
3572 *=== TR 1072834 20-Aug-2013 Goutam
3573
3574 SELECT(lnOldSelect)
3575 RETURN llRetVal
3576 ENDPROC
3577
3578 ************************************************************************************
3579 * Error check EDI headers
3580 ************************************************************************************
3581 PROCEDURE CheckHeader
3582 LPARAMETERS pceipcTH, pceipcCR,pceipcTD
3583 LOCAL llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
3584 llRetVal = .T.
3585 lnOldSelect = SELECT()
3586 WITH THIS
3587 .oLog.LogEntry("Getting customer code using trading partner ID/Qualifier.")
3588 *--- TR 1027724 NH
3589 *llRetVal= .FindCustomerUsingTradingPartnerID(pceipcTH,"IPC") && TR 1016904 - send ipc as second param
3590 llRetVal = llRetVal AND this.UpdateCustomerUsingTrandingPartnerID(pceipcTH)
3591 *=== TR 1027724 NH
3592 IF llRetVal
3593
3594 .oLog.LogEntry("Validating Customer.")
3595 llRetVal= .CheckCustomer(pceipcTH)
3596 IF llRetVal
3597
3598 *--- TR 1048865 23-Mar-2011 Goutam
3599 .LogEntry("Populating division for transaction header with no detail.")
3600 llRetVal = .CheckPoAndPopulateHdrDivision(pceipcTH, pceipcTD, pceipcCR)
3601 .LogEntry("Populating division for transaction header with no detail " + IIF(llRetVal,"completed.","failed."))
3602
3603 .oLog.LogEntry("Validating EDI store.")
3604
3605 *--- TR 1048865 23-Mar-2011 Goutam
3606 *llRetVal= .CheckStore(pceipcTH, pceipcCR)
3607 llRetVal= llRetVal and .CheckStore(pceipcTH, pceipcCR)
3608 *=== TR 1048865 23-Mar-2011 Goutam
3609
3610 IF llRetVal
3611 *- We are not doing it
3612
3613 *--- TR 1062197 7-Sep-2012 Goutam. Uncommented below portion of code
3614 .oLog.LogEntry("Validating EDI center.")
3615 llRetVal= .CheckDistribution(pceipcTH)
3616 *=== TR 1062197 7-Sep-2012 Goutam
3617
3618 ENDIF
3619 ENDIF
3620
3621 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
3622 IF llRetVal
3623 .LogEntry("Validating shipper code.")
3624 llRetVal = .CheckShipper(pceipcTH)
3625 ENDIF
3626 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
3627
3628 ENDIF
3629
3630 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3631 IF llRetVal
3632 .LogEntry("Resolving Customer Shipper.")
3633 llRetVal = .ResolveCustShipper(pceipcTH, pceipcCR)
3634 ENDIF
3635 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3636
3637 *--- TR 1034532 NH
3638 llRetVal = llRetVal and this.PopulateStoreForSingleStorePO(pceipcTH)
3639 llRetVal = llRetVal and this.SetDivisionForOrderWithoutDetail(pceipcTH) &&--- TR 1036066
3640 llRetVal = llRetVal and this.PopulateOrderNumber(pceipcTH,pceipcTD)
3641 *=== TR 1034532 NH
3642
3643 *--- TechRec 1056904 24-Oct-2011 jisingh ---
3644 .LogEntry("Checking 850 transaction maintenance.")
3645 llRetVal = llRetVal AND .Check850TM(pceipcTH, pceipcCR)
3646 *=== TechRec 1056904 24-Oct-2011 jisingh ===
3647
3648 ENDWITH
3649 SELECT(lnOldSelect)
3650 RETURN llRetVal
3651 ENDPROC
3652
3653 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
3654***********************************************************************************
3655 Procedure CheckShipper
3656 LPARAMETERS pcHeader
3657 Local llRetVal, lnOldSelect, lcSQL
3658 llRetVal= true
3659 lnOldSelect= Select()
3660
3661 lcSQL = " SELECT Distinct shipper FROM " + pcHeader + ;
3662 " WHERE NOT EMPTY(shipper) "
3663
3664 llRetVal = v_SqlExec(lcSQL, "__tmpShipper",,.T.)
3665
3666 SELECT __tmpShipper
3667 WITH This
3668 .cSQLTempTable=""
3669 IF .GenerateSQLTempTable('__tmpShipper')
3670 IF .PopulateSQLTempTable('__tmpShipper')
3671 IF !EMPTY(.cSQLTempTable)
3672 lcSQLString= "Select s.shipper from " +;
3673 " zzxshipr s, " + .cSQLTempTable + " t " +;
3674 "Where s.shipper= t.shipper"
3675 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
3676 IF llRetVal
3677 SELECT _Shiper
3678 INDEX On shipper TAG Shipper
3679 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
3680 IF llRetVal
3681 SELECT (pcHeader)
3682 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
3683 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
3684 SET RELATION TO
3685 ENDIF
3686 ENDIF
3687 ENDIF
3688 ENDIF
3689 ENDIF
3690 ENDWITH
3691
3692 IF USED("__tmpShipper")
3693 USE IN __tmpShipper
3694 ENDIF
3695 IF USED("_Shiper")
3696 USE IN _Shiper
3697 ENDIF
3698
3699 Select(lnOldSelect)
3700 Return llRetVal
3701 ENDPROC
3702 ***********************************************************************************
3703 PROCEDURE PopulateAuxsku
3704 LPARAMETERS pceipcTH, pceipcTD
3705
3706 Local llRetVal, lnOldSelect, lcSQL
3707
3708 llRetVal = .T.
3709 lnOldSelect = Select()
3710
3711 WITH THIS
3712
3713 IF RECCOUNT(pceipcTD) > 0
3714
3715 lcSQL = " Select DISTINCT customer, division, Style, color_code, lbl_code, " + ;
3716 " Dimension, sizebucket, aux_sku " + ;
3717 " from " + pceipcTD + ;
3718 " Where !EMPTY(aux_sku) "
3719
3720 llRetVal = v_SqlExec(lcSQL, "__eipcTD",,.T.)
3721
3722 IF RECCOUNT("__eipcTD") > 0
3723
3724 .cSQLTempTable = ""
3725 llRetVal = llRetVal And .GenerateSQLTempTable("__eipcTD")
3726 llRetVal = llRetVal And .PopulateSQLTempTable("__eipcTD")
3727 lceipcTD_tmp = .cSQLTempTable
3728
3729 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3730
3731 IF llRetVal
3732
3733 lcSQL = " UPDATE d set d.aux_sku = x.aux_sku " + ;
3734 " FROM zzxcstdr d JOIN " + lceipcTD_tmp + " x " + ;
3735 " ON d.customer = x.customer " + ;
3736 " AND d.division = x.division " + ;
3737 " AND d.style = x.style " + ;
3738 " AND d.color_code = x.color_code " + ;
3739 " AND d.lbl_code = x.lbl_code " + ;
3740 " AND d.dimension = x.dimension " + ;
3741 " AND d.size_bk = x.sizebucket " + ;
3742 " WHERE x.aux_sku > '' "
3743
3744 v_SqlExec(lcSQL)
3745 ENDIF
3746
3747 IF Used("tmpCstdr")
3748 Use In tmpCstdr
3749 ENDIF
3750 ENDIF
3751
3752 ENDIF
3753
3754 ENDWITH
3755
3756 Select(lnOldSelect)
3757 Return llRetVal
3758 ENDPROC
3759 ***********************************************************************************
3760 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
3761
3762 ***********************************************************************************
3763 *--- TR 1034532 NH
3764 *--- populate transaction records with store when only one store exists per PO in Sales Order.
3765
3766 PROCEDURE PopulateStoreForSingleStorePO
3767 LPARAMETERS pceipcTH
3768
3769 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
3770 llRetVal = .t.
3771 lnOldSelect = SELECT()
3772 lcTmpTbl = ""
3773 lcEipcTh = SYS(2015)
3774
3775 *--- get
3776 *--- TR 1048865 27-May-2011 Goutam. Added division
3777 *--- TR 1053720 23-May-2011 Goutam. Added cr_pkey in the list
3778 SELECT pkey, po_num, customer, store, division, cr_pkey FROM (pceipcTH) th ;
3779 WHERE th.customer > '' AND store = '' AND edi_store = '' AND po_num > '' ;
3780 INTO CURSOR (lcEipcTh)
3781
3782 IF RECCOUNT(lcEipcTh) = 0
3783 *--- no need to do any thing when customer is populated for all records
3784 SELECT(lnOldSelect)
3785 RETURN llRetVal
3786 ENDIF
3787
3788 WITH this
3789 .cSQLTempTable = ""
3790 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
3791 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
3792 lcTmpTbl = .cSQLTempTable
3793 USE IN (lcEipcTh)
3794 *--- store
3795
3796 *--- TR 1048865 27-May-2011 Goutam. Added condition ih.division = th.division
3797 *--- TR 1053720 23-May-2011 Goutam.
3798 *lcSql = " select th.pkey, th.po_num, th.customer, oh.store, r.edi_store " + ;
3799 " From " + lcTmpTbl + " th inner join zzoordrh oh (nolock) on th.po_num = oh.po_num and th.customer = oh.customer " + ;
3800 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3801 " Where exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3802 " where ih.ord_status = 'O' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3803 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3804 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) "
3805
3806 *--- TR 1089812 07-Sep-2015 BNarayanan removed ih.ord_status = 'O' and from where ih.ord_status = 'O' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ---
3807 lcSql = " select th.pkey, th.po_num, th.customer, oh.store, r.edi_store " + ;
3808 " From " + lcTmpTbl + " th inner join zzoordrh oh (nolock) on th.po_num = oh.po_num and th.customer = oh.customer " + ;
3809 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store inner join zzeipccr c on c.pkey = th.cr_pkey " + ;
3810 " Where exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3811 " where ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3812 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3813 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3814 " or " + ;
3815 " exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3816 " where ih.ord_status = 'C' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3817 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3818 " and (exists(select 1 from zzeipctd where fkey = th.pkey and (qualifier = 'AI' or (qualifier = 'RZ' and qty_change > 0))) and c.new_order = 'Y') " + ;
3819 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3820 " group by th.pkey, th.po_num, th.customer, oh.store, r.edi_store "
3821
3822 *--- TR 1053720 23-May-2011 Goutam.
3823
3824 lcOrderStore = "tcOrderStore" + SYS(2015)
3825 llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderStore)
3826 IF llRetVal
3827 SELECT (lcOrderStore)
3828 INDEX on pkey TAG pkey
3829 *--- TR 1036066 NH : added ForAllStore = 'P'
3830 UPDATE th SET store = oh.store, edi_store = oh.edi_store, ForAllStore = 'P' from (pceipcTH) th inner join (lcOrderStore) oh on oh.pkey = th.pkey
3831 *=== TR 1036066 NH
3832 ENDIF
3833 ENDWITH
3834
3835 IF USED(lcOrderStore)
3836 USE IN (lcOrderStore)
3837 ENDIF
3838 SELECT(lnOldSelect)
3839 RETURN llRetVal
3840 ENDPROC
3841
3842 ***********************************************************************************
3843
3844 PROCEDURE PopulateStoreForSingleStorePO_AtServer
3845
3846 LOCAL llRetVal, lnOldSelect
3847 llRetVal = .t.
3848 lnOldSelect = SELECT()
3849
3850 LOCAL lcFilter
3851 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
3852 lcFilter = STRTRAN(lcFilter,"Where","")
3853
3854 *--- populate trans header with store, and edi_store value when PO has only one store order in OPEN order
3855 LOCAL lcSql
3856
3857 *-- TR 1047337 MAY-19-2010 BR
3858 *lcSql = " Update h Set store = oh.store, edi_store = r.edi_store " + ;
3859 " , ForAllStore = CASE h.ForAllStore WHEN 'Y' then 'P' ELSE h.ForAllStore End " + ;
3860 " From zzeipcth h inner join zzoordrh oh (nolock) on h.po_num = oh.po_num and h.customer = oh.customer " + ;
3861 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3862 " Where h.ForAllStore = 'Y' AND exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3863 " where ih.ord_status = 'O' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3864 " and ih.customer = h.customer and ih.po_num = h.po_num " + ;
3865 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3866 IIF(EMPTY(lcFilter),""," and " + lcFilter)
3867 lcSql = " Update h Set store = oh.store, edi_store = CASE oh.store WHEN '' THEN '' ELSE r.edi_store END " + ;
3868 " , ForAllStore = CASE h.ForAllStore WHEN 'Y' then 'P' ELSE h.ForAllStore End " + ;
3869 " From zzeipcth h inner join zzoordrh oh (nolock) on h.po_num = oh.po_num and h.customer = oh.customer " + ;
3870 " left outer join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3871 " Where h.ForAllStore = 'Y' AND exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3872 " where ih.ord_status = 'O' and ih.store > = '' and ih.customer > '' and ih.po_num > '' " + ;
3873 " and ih.customer = h.customer and ih.po_num = h.po_num " + ;
3874 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3875 IIF(EMPTY(lcFilter),""," and " + lcFilter)
3876 *== TR 1047337 MAY-19-2010 BR
3877
3878 llRetVal = llRetVal and v_sqlexec(lcSql)
3879
3880 SELECT(lnOldSelect)
3881 RETURN llRetVal
3882 ENDPROC
3883
3884 ***********************************************************************************
3885
3886 PROCEDURE PopulateOrderNumber
3887 LPARAMETERS pceipcTH,pceipcTD
3888
3889 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
3890 llRetVal = .t.
3891 lnOldSelect = SELECT()
3892 lcTmpTbl = ""
3893 lcEipcTh = SYS(2015)
3894 *--- TR 1036066 NH
3895 lcTmpTbl_D = ""
3896 lceipcTD = SYS(2015)
3897 *=== TR 1036066 NH
3898
3899 *--- get trans records which has proper customer, po_num, and store
3900 *--- TR 1048865 27-Dec-2010 Goutam. Added cr_pkey in the following sql list
3901 *- TR 1056230 FH - Took out check for store, our store can be empty.
3902 *--- TR 1062197 10-Sep-2012 Goutam. Added poc_purp, poc_store
3903
3904 *--- TR 1086404 18-May-2015 BNarayanan added condition AND ForAllStore < 'Y' to avoid updating the order number for all store record ---
3905 SELECT th.pkey, th.division, th.customer, th.po_num, th.store, th.edi_store, th.errs_flg_h, th.errs_msg_h, cr_pkey, poc_purp, poc_store ;
3906 FROM (pcEipcTh) th WHERE th.customer > '' AND th.po_num > '' AND ord_num = 0 AND ForAllStore < 'Y' ;
3907 INTO CURSOR (lcEipcTh)
3908 *=== TR 1086404 18-May-2015 BNarayanan ===
3909
3910 *--- TR 1036066 NH :
3911 SELECT td.pkey, td.fkey, td.qualifier, td.qty_change FROM (pceipcTD) td INNER JOIN (lcEipcTh) th ;
3912 ON th.pkey = td.fkey INTO CURSOR (lceipcTD)
3913 *=== TR 1036066 NH
3914
3915
3916 IF RECCOUNT(lcEipcTh) = 0
3917 *--- no need to do any thing when customer is populated for all records
3918 SELECT(lnOldSelect)
3919 RETURN llRetVal
3920 ENDIF
3921
3922 WITH this
3923 .cSQLTempTable = ""
3924 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
3925 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
3926 lcTmpTbl = .cSQLTempTable
3927 *--- TR 1036066 NH
3928 .cSQLTempTable = ""
3929 llRetVal = llRetVal AND .GenerateSQLTempTable(lceipcTD)
3930 IF RECCOUNT(lceipcTD) > 0
3931 llRetVal = llRetVal AND .PopulateSQLTempTable(lceipcTD) and not EMPTY(.cSQLTempTable)
3932 ENDIF
3933 lcTmpTbl_D = .cSQLTempTable
3934 *=== TR 1036066 NH
3935
3936 USE IN (lcEipcTh)
3937
3938 *--- TR 1048865 27-Dec-2010 Goutam
3939 *-- Changed from inner join zzeipccr r on r.customer = th.customer and r.division = th.division to ;
3940 inner join zzeipccr r on r.pkey = th.cr_pkey ;
3941 Also added condition and ith.division = h.division before where h.ord_status = 'O'
3942
3943 *--- TR 1053720 23-May-2011 Goutam. Added condition after h.ord_status = 'O' and before group by for considering order number from cancel order and ;
3944 join the same subquery with table #zzeipctd and zzeipccr. Changed count(*) as ord_count to count(distinct ord_num) as ord_count
3945 *--- TR 1062197 10-Sep-2012 Goutam. Changed ith.store = h.store to (ith.store = case when (poc_purp = '04' and poc_store > '') then ith.store else h.store end)
3946 *--- TR 1085815 27-Mar-2015 BNarayanan , coalesce(oh.ord_type,'') ord_type & min(h.ord_type) as ord_type,added ---
3947 TEXT TO lcSql noshow
3948 select th.pkey, th.customer, th.po_num, th.store
3949 , coalesce(oh.ord_num,0) ord_num
3950 , case when oh.ord_num is null and td.pkey is null then 'Y'
3951 when oh.ord_num is null and not ((td.qualifier in ('AI', 'QI') or (td.qualifier = 'RZ' and td.qty_change > 0)) and r.new_order = 'Y') then 'Y'
3952 when coalesce(ord_count,0) > 1 then 'Y'
3953 else '' end errs_flg_h
3954 , case when oh.ord_num is null and td.pkey is null then 'Order not found.'
3955 when oh.ord_num is null and not ((td.qualifier in ('AI', 'QI') or (td.qualifier = 'RZ' and td.qty_change > 0)) and r.new_order = 'Y') then 'Order not found.'
3956 when coalesce(ord_count,0) > 1 then 'More than one order found.'
3957 else '' end errs_msg_h
3958 , coalesce(oh.ord_type,'') ord_type
3959 from #zzeipcth th
3960 inner join zzeipccr r on r.pkey = th.cr_pkey
3961 LEFT OUTER join #zzeipctd td on th.pkey = td.fkey
3962 left outer join
3963 (select ith.pkey, ith.customer, ith.po_num, ith.store, min(h.ord_type) as ord_type,
3964 min(h.ord_num) as ord_num, count(distinct ord_num) as ord_count
3965 from zzoordrh h inner join #zzeipcth ith
3966 on ith.po_num = h.po_num and ith.customer = h.customer
3967 and (ith.store = case when (poc_purp = '04' and poc_store > '') then ith.store else h.store end)
3968 and ith.division = h.division
3969 join zzeipccr c on ith.cr_pkey = c.pkey
3970 left join #zzeipctd itd on itd.fkey = ith.pkey
3971 where (h.ord_status = 'O' or ((itd.qualifier = 'AI' or (itd.qualifier = 'RZ'
3972 and itd.qty_change > 0))
3973 and c.new_order = 'Y')
3974 and not exists(select 1 from zzoordrh where po_num = ith.po_num and customer = ith.customer and store = ith.store and (ord_status = 'O' or ord_status = 'C')))
3975 group by ith.pkey, ith.customer, ith.po_num, ith.store) oh
3976 on oh.pkey = th.pkey
3977 ENDTEXT
3978
3979 lcSql = STRTRAN(lcSql,"#zzeipcth",lcTmpTbl)
3980 lcSql = STRTRAN(lcSql,"#zzeipctd",lcTmpTbl_D)
3981 lcOrderNumbers = "tcOrderNumbers" + SYS(2015)
3982 llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderNumbers)
3983 IF llRetVal
3984 SELECT (lcOrderNumbers)
3985 INDEX on pkey TAG pkey
3986 *--- TR 1085815 27-Mar-2015 BNarayanan , ord_type = u.ord_type added ---
3987 UPDATE th SET ord_num = u.ord_num, ord_type = u.ord_type ;
3988 , errs_flg_h = IIF(u.errs_flg_h = 'Y',u.errs_flg_h, th.errs_flg_h) ;
3989 , errs_msg_h = th.errs_msg_h + IIF(!EMPTY(u.errs_msg_h), u.errs_msg_h + CRLF, "") ;
3990 from (pcEipcTh) th inner join (lcOrderNumbers) u on th.PKEY = u.PKEY
3991 ENDIF
3992
3993 IF USED(lcOrderNumbers)
3994 USE IN (lcOrderNumbers)
3995 ENDIF
3996 IF USED(lcEipcTh)
3997 USE IN (lcEipcTh)
3998 ENDIF
3999 ENDWITH
4000
4001 SELECT(lnOldSelect)
4002 RETURN llRetVal
4003 ENDPROC
4004
4005 *=== TR 1034532 NH
4006 ***********************************************************************************
4007
4008 *--- TR 1027724 NH
4009 PROCEDURE UpdateCustomerUsingTrandingPartnerID
4010 LPARAMETERS pcEipcTh
4011
4012 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
4013 llRetVal = .t.
4014 lnOldSelect = SELECT()
4015 lcTmpTbl = ""
4016 lcEipcTh = SYS(2015)
4017
4018 SELECT * FROM (pcEipcTh) th WHERE th.customer = '' INTO CURSOR (lcEipcTh)
4019
4020
4021 IF RECCOUNT(lcEipcTh) = 0
4022 *--- no need to do any thing when customer is populated for all records
4023 RETURN llRetVal
4024 ENDIF
4025
4026 WITH this
4027 .cSQLTempTable = ""
4028 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
4029 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
4030 lcTmpTbl = .cSQLTempTable
4031 USE IN (lcEipcTh)
4032
4033 *--- 1048865 24-Dec-2010 Goutam. Added CR_Pkey in the following parameter
4034 llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcTmpTbl, "zzeipccr","customer","errs_flg_h","errs_msg_h",,"CR_Pkey")
4035 llRetVal = llRetVal and v_sqlexec("select * from " + lcTmpTbl,lcEipcTh)
4036
4037 *--- 1048865 24-Dec-2010 Goutam. Added CR_Pkey = u.CR_Pkey in the following sql
4038 UPDATE th SET customer = u.customer, CR_Pkey = u.CR_Pkey, errs_flg_h = u.errs_flg_h, errs_msg_h = u.errs_msg_h ;
4039 from (pcEipcTh) th inner join (lcEipcTh) u on th.PKEY = u.PKEY
4040
4041 ENDWITH
4042
4043 SELECT(lnOldSelect)
4044 RETURN llRetVal
4045 ENDPROC
4046
4047 ***********************************************************************************
4048 *=== TR 1027724 NH
4049 PROCEDURE CheckStore
4050 LPARAMETERS pcHeader, pcControl
4051 LOCAL llRetVal, lnOldSelect
4052 llRetVal= .T.
4053 lnOldSelect= SELECT()
4054
4055 * 1st - group get store using cust,edi_store but not overwrite existing store
4056 * users could change store in Trans Maint.
4057 SELECT DISTINCT customer, EDI_Store, STORE FROM (pcHeader) ;
4058 WHERE !EMPTY(customer) AND !EMPTY(EDI_Store) AND EMPTY(STORE) ;
4059 INTO CURSOR __TmpCursor
4060
4061 SELECT __TmpCursor
4062 WITH THIS
4063 .cSQLTempTable=""
4064 IF .GenerateSQLTempTable('__TmpCursor')
4065 IF .PopulateSQLTempTable('__TmpCursor')
4066 IF !EMPTY(.cSQLTempTable)
4067 *- 850 resolves consolidate/ distribution center from store if not empty
4068 *- also, populates center_code, consol_code if empty.
4069 *- We don't do that in the 860, assuming that the store does not change.
4070 *- We need the resolution just to find the original order.
4071 lcSQLString= "Select s.customer, s.store, s.edi_store " +;
4072 " from zzxstorr s, " + .cSQLTempTable + " t " +;
4073 "Where s.customer= t.customer and s.edi_store= t.edi_store"
4074 llRetVal = v_SQLExec(lcSQLString, "_Storr")
4075 IF llRetVal
4076 SELECT _Storr
4077 INDEX ON customer+EDI_Store TAG CustStore
4078 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
4079 "customer+edi_store")
4080 IF llRetVal
4081 SELECT (pcHeader)
4082 *--- TR 1018294 02-Aug-2006 BR ---
4083 SCAN FOR !EMPTY(EDI_Store) AND EMPTY(Store)
4084
4085 *=== TR 1018294 02-Aug-2006 BR ===
4086 IF EMPTY(_Storr.customer)
4087 *--- TR 1062197 7-Sep-2012 Goutam
4088 *REPLACE Errs_msg_H WITH Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
4089 Errs_flg_h WITH "Y" IN (pcHeader)
4090
4091 REPLACE Errs_msg_H WITH Errs_msg_H + IIF(poc_purp = '04' AND !EMPTY(poc_store), "Invalid EDI Store code in POC_STORE column.", "Invalid EDI Store code.") +CRLF ,;
4092 Errs_flg_h WITH "Y" IN (pcHeader)
4093 *=== TR 1062197 7-Sep-2012 Goutam
4094
4095 ELSE
4096 IF EMPTY(STORE) && don't want to overwrite previous data
4097 REPLACE STORE WITH _Storr.STORE
4098 ENDIF
4099 ENDIF
4100 ENDSCAN
4101 SET RELATION TO
4102 USE IN _Storr
4103 ENDIF
4104 ENDIF
4105 ENDIF
4106 ENDIF
4107 ENDIF
4108 ENDWITH
4109 IF USED("__TmpCursor")
4110 USE IN __TmpCursor
4111 ENDIF
4112
4113 * 2nd - validate store by cust,store
4114 SELECT DISTINCT customer, STORE FROM (pcHeader) ;
4115 WHERE !EMPTY(customer) AND !EMPTY(STORE) INTO CURSOR __TmpCursor
4116 SELECT __TmpCursor
4117 WITH THIS
4118 .cSQLTempTable=""
4119 IF .GenerateSQLTempTable('__TmpCursor')
4120 IF .PopulateSQLTempTable('__TmpCursor')
4121 IF !EMPTY(.cSQLTempTable)
4122 lcSQLString= "Select s.customer, s.store " +;
4123 " from zzxstorr s, " + .cSQLTempTable + " t " +;
4124 "Where s.customer= t.customer and s.store= t.store"
4125 llRetVal = v_SQLExec(lcSQLString, "_Storr")
4126 IF llRetVal
4127 SELECT _Storr
4128 INDEX ON customer+STORE TAG CustStore
4129 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
4130 "customer+store")
4131 IF llRetVal
4132 SELECT (pcHeader)
4133 SCAN FOR !EMPTY(EDI_Store)
4134 IF EMPTY(_Storr.customer)
4135 REPLACE Errs_msg_H WITH Errs_msg_H + "Invalid Store code." +CRLF ,;
4136 Errs_flg_h WITH "Y" IN (pcHeader)
4137 ENDIF
4138 ENDSCAN
4139 SET RELATION TO
4140 USE IN _Storr
4141 ENDIF
4142 ENDIF
4143 ENDIF
4144 ENDIF
4145 ENDIF
4146 ENDWITH
4147 IF USED("__TmpCursor")
4148 USE IN __TmpCursor
4149 ENDIF
4150
4151 IF USED("_Storr")
4152 USE IN _Storr
4153 ENDIF
4154
4155 SELECT(lnOldSelect)
4156 RETURN llRetVal
4157 ENDPROC
4158
4159 PROCEDURE CheckDetail
4160 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
4161 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
4162 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pceipcTS, pceipcTWHSE
4163 LOCAL llRetVal, lnOldSelect
4164 llRetVal = .T.
4165 lnOldSelect = SELECT()
4166 WITH THIS
4167
4168 .oLog.LogEntry("Resolving style using UPC.")
4169 *--- TR 1031588 17-APR-2008 VKK Added pceipccr
4170
4171
4172 * --- TR 1047609 7/7/10 CM
4173 If .lHaveSLN
4174 .LogEntry("Resolving SLNs.")
4175 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
4176 llRetVal= llRetVal AND .ResolveBCSkuFromSLN(pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE )
4177 Endif
4178 * === TR 1047609 7/7/10 CM
4179
4180 llRetVal= llRetVal AND .CheckUpc(pceipcTH, pceipcTD, pceipcCR)
4181
4182 .oLog.LogEntry("Resolving style using EAN.")
4183 llRetVal= llRetVal AND .CheckEAN(pceipcTH, pceipcTD)
4184
4185 .oLog.LogEntry("Resolving style using SKU.")
4186 llRetVal= llRetVal AND .CheckSku(pceipcTH, pceipcTD)
4187
4188 *- Advanced resolution. Out of the scope. For future use.
4189 *-- .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
4190 *-- vcLogName)
4191 *-- .oLog.LogEntry("Resolving range style.")
4192 *-- llRetVal= llRetVal AND .RangeStyle(pceipoTH, pceipoTD) && "Vzzeipotd_IPOProc"
4193 *-- .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
4194 *-- vcLogName)
4195 *-- .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
4196 *-- vcLogName)
4197 *-- llRetVal= llRetVal AND .PrepackConversion(pceipoTH, pceipoTD)
4198
4199 *-- .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
4200 *-- vcLogName)
4201 *-- llRetVal= llRetVal AND .ResolvePrepack(pceipoTH, pceipoTD, pceipcCR)
4202
4203 llRetVal= llRetVal AND .UpdtHeaderDivs(pceipcTH, pceipcTD)
4204 .AdvanceThermoTotalWithCaptionPlus("Populating implosion flag to transaction header.")
4205
4206 *--- TR 1022465 NH/BR : - we have division populated for normal orders, but orders with no detail have no division value.
4207 *--- need to join with zzoordrh on po_num + customer only find the division from zzoordrh and stamp it in zzeipcth.division field
4208 .oLog.LogEntry("Setting Division for order without detail.")&&TR 1041492 JUL-20-2009 BR
4209 llRetVal = llRetVal and .SetDivisionForOrderWithoutDetail(pceipcTH)
4210
4211 *- TR 1054193 FH 5/13/11
4212 llRetVal = llRetVal and .ValidateIfControlReferenceExist(pceipcTH, "zzeipccr")
4213 *- TR 1054193 FH 5/13/11
4214
4215 .LogEntry("Populating implosion flag to transaction header.")
4216 llRetVal = llRetVal AND .PopulatingImplosionFlag(pceipcTH, pceipcCR)
4217
4218 *--- TR 1032030 NH
4219 .oLog.LogEntry("Setting Values from customer sales ref.") &&TR 1041492 JUL-20-2009 BR
4220 *---TR 1088126 2-JUL-2015 Venuk. Added param pceipcTD ===
4221 llRetVal = llRetVal and .SetValuesFromCustomerSalesRef(pceipcTH, pceipcTD)
4222
4223 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", vcLogName)
4224 llRetVal= llRetVal AND .RangeStyle(pceipcTH, pceipcTD, pceipcCR)
4225 .oLog.LogEntry("Prepack Quantity Conversion " + IIF(llRetVal,"successful.","failed."))
4226
4227 .oLog.LogEntry("Resolving Price From Range Style.") &&TR 1041492 JUL-20-2009 BR
4228 llRetVal= llRetVal AND .ResolvePriceFromRangeStyle(pceipcTH, pceipcTD)
4229 *=== TR 1032030 NH
4230
4231 *--- TR 1016559 NH
4232 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", vcLogName)
4233 llRetVal= llRetVal AND .PrepackConversion(pceipcTD)
4234 .oLog.LogEntry("Prepack Quantity Conversion " + IIF(llRetVal,"successful.","failed."))
4235 *=== TR 1016559 NH
4236
4237 *--- TR 1016560 NH
4238 IF .lPrepackImplosionOk
4239 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
4240 vcLogName)
4241 llRetVal= llRetVal AND .Resolve860Prepack(pceipcTH, pceipcTD, pceipcCR)
4242 .LogEntry("Resolving Single Prepack " + IIF(llRetVal," sucessful.","failed."))
4243 ENDIF
4244 *=== TR 1016560 NH
4245
4246 .oLog.LogMajorStage("Resolving and getting default fields.")
4247 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
4248 .oLog.LogEntry("Resolving customer label.")
4249
4250 llRetVal= llRetVal AND .ResolveCustomerLabel(pceipcTH, pceipcTD, pceipcCR)
4251
4252 *--- TechRec 1073591 14-Feb-2014 TShenbagavalli ---
4253 .LogEntry("Populating Auxsku")
4254 llRetVal = llRetVal and this.PopulateAuxsku(pceipcTH, pceipcTD)
4255 *=== TechRec 1073591 14-Feb-2014 TShenbagavalli ===
4256
4257 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
4258 vcLogName)
4259
4260 .oLog.LogEntry("Validating style.")
4261 llRetVal= llRetVal AND .ValidateOurSKU(pceipcTH, pceipcTD)
4262
4263 .AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
4264 vcLogName)
4265
4266 .oLog.LogEntry("Validating MinMultiple.")
4267 llRetVal= llRetVal AND .ValidateMinMultiple(pceipcTH, pceipcTD)
4268
4269 *--- TR 1034532 NH
4270 .oLog.LogEntry("Validating Qualifier.")&&TR 1041492 JUL-20-2009 BR
4271 llRetVal = llRetVal and this.ValidateQualifier(pceipcTD)
4272 *=== TR 1034532 NH
4273
4274 ENDWITH
4275
4276 SELECT(lnOldSelect)
4277 RETURN llRetVal
4278 ENDPROC
4279
4280 *-----------------------------------------------------------------------------------------
4281 *--- TR 1034532 NH
4282 PROCEDURE ValidateQualifier(pceipcTD)
4283
4284 LOCAL llRetVal, lnOldSelect
4285 lnOldSelect = SELECT()
4286 llRetVal = .t.
4287
4288 *--- TR 1039757 18-Aug-2009 Goutam. Added NZ in where list.
4289 *--- TechRec 1052780 17-Mar-2011 MANI. Added NC in Where list ===
4290 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Invalid PO change Action code' + CRLF ;
4291 from (pceipcTD) td WHERE td.qualifier NOT in ('AI','DI','QI','QD','RZ','PC','CT','DB','NZ','NC') AND td.errs_flg_d <> 'Y'
4292
4293 Select(lnOldSelect)
4294 Return llRetVal
4295 Endproc
4296 *=== TR 1034532 NH
4297
4298 * TR 1022465 BR/NH 5/10/07
4299 **********************************************************************************************
4300 PROCEDURE SetDivisionForOrderWithoutDetail
4301 LPARAMETERS pceipcTH
4302 LOCAL llRetVal, lcOldOrder, lnOldSelect, lcPo_Cust
4303 llRetVal = .t.
4304 lnOldSelect = SELECT()
4305 lcEmptyDiv = SYS(2015)
4306 lcDivFound = SYS(2015)
4307 *--- find empty divisions
4308 SELECT po_num, customer FROM (pceipcTH) WHERE EMPTY(division) INTO CURSOR (lcEmptyDiv)
4309 *--- zzoordrh
4310 IF reccount(lcEmptyDiv) > 0
4311 .cSQLTempTable=""
4312 llRetval = llRetVal and .GenerateSQLTempTable(lcEmptyDiv)
4313 llRetval = llRetVal and .PopulateSQLTempTable(lcEmptyDiv) and !EMPTY(.cSQLTempTable)
4314
4315 lcSql = "SELECT distinct th.po_num, th.customer, h.division from " + .cSQLTempTable + " th " + ;
4316 " INNER JOIN zzoordrh h (nolock) on th.po_num = h.po_num and th.customer = h.customer "
4317
4318 llRetVal = llRetVal and v_sqlexec(lcSql,lcDivFound)
4319
4320 SELECT(pceipcTH)
4321 lcOldOrder = ORDER()
4322 INDEX on po_num + customer TAG po_cust
4323
4324 SELECT (lcDivFound)
4325 SCAN
4326 SCATTER NAME loDivFound
4327 lcPo_Cust = po_num+customer
4328 IF SEEK(po_num+customer, pceipcTH, "po_cust")
4329 SELECT (pceipcTH)
4330 SCAN WHILE lcPo_Cust == po_num+customer
4331 replace division WITH loDivFound.division in (pceipcTH)
4332 ENDSCAN
4333 ENDIF
4334 ENDSCAN
4335 SELECT (pceipcTH)
4336 SET ORDER TO (lcOldOrder)
4337
4338 ENDIF
4339
4340 SELECT(lnOldSelect)
4341 RETURN llRetval
4342 ENDPROC
4343 **********************************************************************************************
4344 * TR 1022465 BR/NH 5/10/07
4345 **********************************************************************************************
4346
4347 PROCEDURE CheckUpc
4348 *--- TR 1031588 17-APR-2008 VKK Added pceipccr
4349 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4350 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcMssg, lcOldCust, lcOldItem, ;
4351 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
4352 lnSize_desc
4353
4354 llRetVal = .T.
4355 lcErrs_Msg= ""
4356 lnOldSelect = SELECT()
4357
4358 *--- TR 1031588 17-APR-2008 VKK ignore upc resoltion
4359
4360*!* SELECT h.customer, d.upc, d.pkey ;
4361*!* FROM (pceipcTH) h, (pceipcTD) d ;
4362*!* WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4363*!* (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4364*!* ORDER BY h.customer, d.upc ;
4365*!* INTO CURSOR tmpCurs
4366
4367 *--- TR 1048865 23-Mar-2011 Goutam. Deleted following line of code
4368*!* SELECT customer, MAX (ResvCustSKU) as ResvCustSKU ;
4369*!* FROM (pceipccr) ;
4370*!* GROUP BY customer ;
4371*!* INTO CURSOR __ResvCustSKU
4372 *=== TR 1048865 23-Mar-2011 Goutam
4373
4374 && TR 1031588 22-Apr-2008 T.Shenbagavalli added (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') condition instead of c.ResvCustSKU <> 'Y'
4375
4376 *--- TR 1048865 23-Mar-2011 Goutam
4377*!* SELECT h.customer, d.upc, d.pkey ;
4378*!* FROM (pceipcTH) h, (pceipcTD) d, __ResvCustSKU C ;
4379*!* WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4380*!* c.customer = h.customer AND (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') AND ;
4381*!* (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4382*!* ORDER BY h.customer, d.upc ;
4383*!* INTO CURSOR tmpCurs
4384
4385 SELECT h.customer, d.upc, d.pkey ;
4386 FROM (pceipcTH) h, (pceipcTD) d, (pceipccr) c ;
4387 WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4388 c.pkey = h.cr_pkey AND (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') AND ;
4389 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4390 ORDER BY h.customer, d.upc ;
4391 INTO CURSOR tmpCurs
4392 *=== TR 1048865 23-Mar-2011 Goutam
4393
4394 *=== TR 1031588 17-APR-2008 VKK
4395
4396 lcOldCust = ""
4397 lcOldItem = ""
4398 SELECT tmpCurs
4399 IF THIS.lUserInterface
4400 * Init Thermometer
4401 THIS.UpdateThermoCaption("Validating UPC(s)...")
4402 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4403 l_nThermoCnt = 0
4404 ENDIF
4405 SCAN
4406 IF THIS.lUserInterface
4407 * Advance progress bar, if we're using one.
4408 l_nThermoCnt = l_nThermoCnt + 1
4409 THIS.AdvanceThermo(l_nThermoCnt)
4410 ENDIF
4411 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.upc == lcOldItem)
4412 lcErrs_Msg = ""
4413 lcOldCust = tmpCurs.customer
4414 lcOldItem = tmpCurs.upc
4415
4416 IF THIS.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
4417 lcDivision = tmpCstdr.division
4418 lcStyle = tmpCstdr.STYLE
4419 lcColor_code = tmpCstdr.color_code
4420 lcLbl_code = tmpCstdr.lbl_code
4421 lcDimension = tmpCstdr.DIMENSION
4422 lnSizeBucket = tmpCstdr.size_bk
4423 lnSize_desc = tmpCstdr.size_desc
4424 ELSE
4425 lcErrs_Msg = ""
4426 IF THIS.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
4427 lcDivision = tmpUpcnr.division
4428 lcStyle = tmpUpcnr.STYLE
4429 lcColor_code = tmpUpcnr.color_code
4430 lcLbl_code = tmpUpcnr.lbl_code
4431 lcDimension = tmpUpcnr.DIMENSION
4432 lnSizeBucket = tmpUpcnr.Sizebucket
4433 lnSize_desc = tmpUpcnr.size_desc
4434 ELSE
4435 lcErrs_Msg = lcErrs_Msg + CRLF
4436 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4437 STORE 0 TO lnSizeBucket
4438 ENDIF
4439 ENDIF
4440 ENDIF && level break
4441
4442 SELECT (pceipcTD)
4443 lnWorkArea = SELECT()
4444 =SEEK(tmpCurs.pkey, lnWorkArea, "pkey")
4445 SCATTER NAME loEiPCtd MEMO
4446 IF !EMPTY(lcErrs_Msg)
4447 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4448 loEiPCtd.Errs_Flg_D = "Y"
4449 ENDIF
4450 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4451 loEiPCtd.division = lcDivision
4452 loEiPCtd.STYLE = lcStyle
4453 loEiPCtd.color_code = lcColor_code
4454 loEiPCtd.lbl_code = lcLbl_code
4455 loEiPCtd.DIMENSION = lcDimension
4456 loEiPCtd.Sizebucket = lnSizeBucket
4457 loEiPCtd.size_desc = lnSize_desc
4458 ENDIF
4459
4460 *- check for future possibility of a range style
4461 *- If there's no field "rng_style" or there is, but it is empty - Ok.
4462 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4463 GATHER NAME loEiPCtd MEMO
4464 ENDIF
4465 ENDSCAN
4466 USE IN tmpCurs
4467
4468 IF THIS.lUserInterface
4469 * Reset Thermometer
4470 THIS.ResetThermo()
4471 ENDIF
4472
4473 IF USED("tmpCstdr")
4474 USE IN tmpCstdr
4475 ENDIF
4476 IF USED("tmpUpcnr")
4477 USE IN tmpUpcnr
4478 ENDIF
4479
4480 SELECT(lnOldSelect)
4481 RETURN llRetVal
4482 ENDPROC
4483
4484 PROCEDURE CheckEAN
4485 LPARAMETERS pceipcTH, pceipcTD
4486 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcMssg, lcOldCust, lcOldItem, ;
4487 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
4488 lnSize_desc
4489 llRetVal = .T.
4490 lcErrs_Msg= ""
4491 lnOldSelect = SELECT()
4492
4493 SELECT h.customer, d.ean, d.pkey ;
4494 FROM (pceipcTH) h, (pceipcTD) d ;
4495 WHERE !EMPTY(d.ean) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4496 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4497 ORDER BY h.customer, d.ean ;
4498 INTO CURSOR tmpCurs
4499
4500 lcOldCust = ""
4501 lcOldItem = ""
4502 SELECT tmpCurs
4503 IF THIS.lUserInterface
4504 * Init Thermometer
4505 THIS.UpdateThermoCaption("Validating EAN(s)...")
4506 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4507 l_nThermoCnt = 0
4508 ENDIF
4509 SCAN
4510 IF THIS.lUserInterface
4511 * Advance progress bar, if we're using one.
4512 l_nThermoCnt = l_nThermoCnt + 1
4513 THIS.AdvanceThermo(l_nThermoCnt)
4514 ENDIF
4515 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.ean == lcOldItem)
4516 lcErrs_Msg = ""
4517 lcOldCust = tmpCurs.customer
4518 lcOldItem = tmpCurs.ean
4519
4520 IF THIS.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
4521 lcDivision = tmpCstdr.division
4522 lcStyle = tmpCstdr.STYLE
4523 lcColor_code = tmpCstdr.color_code
4524 lcLbl_code = tmpCstdr.lbl_code
4525 lcDimension = tmpCstdr.DIMENSION
4526 lnSizeBucket = tmpCstdr.size_bk
4527 lnSize_desc = tmpCstdr.size_desc
4528 ELSE
4529 lcErrs_Msg = ""
4530 IF THIS.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
4531 lcDivision = tmpUpcnr.division
4532 lcStyle = tmpUpcnr.STYLE
4533 lcColor_code = tmpUpcnr.color_code
4534 lcLbl_code = tmpUpcnr.lbl_code
4535 lcDimension = tmpUpcnr.DIMENSION
4536 lnSizeBucket = tmpUpcnr.Sizebucket
4537 lnSize_desc = tmpUpcnr.size_desc
4538 ELSE
4539 lcErrs_Msg = lcErrs_Msg + CRLF
4540 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4541 STORE 0 TO lnSizeBucket
4542 ENDIF
4543 ENDIF
4544 ENDIF && level break
4545
4546 SELECT (pceipcTD)
4547
4548 lnWorkArea = SELECT()
4549 =SEEK(tmpCurs.pkey, lnWorkArea, "pkey")
4550 SCATTER NAME loEiPCtd MEMO
4551 IF !EMPTY(lcErrs_Msg)
4552 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4553 loEiPCtd.Errs_Flg_D = "Y"
4554 ENDIF
4555 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4556 loEiPCtd.division = lcDivision
4557 loEiPCtd.STYLE = lcStyle
4558 loEiPCtd.color_code = lcColor_code
4559 loEiPCtd.lbl_code = lcLbl_code
4560 loEiPCtd.DIMENSION = lcDimension
4561 loEiPCtd.Sizebucket = lnSizeBucket
4562 loEiPCtd.size_desc = lnSize_desc
4563 ENDIF
4564
4565 * only replace our SKU when no range style explosion happen
4566 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4567 GATHER NAME loEiPCtd MEMO
4568 ENDIF
4569 ENDSCAN
4570 USE IN tmpCurs
4571
4572 IF THIS.lUserInterface
4573 * Reset Thermometer
4574 THIS.ResetThermo()
4575 ENDIF
4576
4577 IF USED("tmpCstdr")
4578 USE IN tmpCstdr
4579 ENDIF
4580 IF USED("tmpUpcnr")
4581 USE IN tmpUpcnr
4582 ENDIF
4583
4584 SELECT(lnOldSelect)
4585 RETURN llRetVal
4586 ENDPROC
4587
4588 PROCEDURE CheckSku
4589 LPARAMETERS pceipcTH, pceipcTD
4590 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
4591 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
4592 lnSize_desc, llSLN
4593
4594 llRetVal = .T.
4595 lcErrs_Msg= ""
4596 lnOldSelect = SELECT()
4597
4598 SELECT h.customer, d.sku, d.pkey ;
4599 FROM (pceipcTH) h, (pceipcTD) d ;
4600 WHERE !EMPTY(h.customer) AND !EMPTY(d.sku) AND h.pkey = d.fkey AND ;
4601 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4602 ORDER BY h.customer, d.sku ;
4603 INTO CURSOR tmpCurs
4604
4605 lcOldCust = ""
4606 lcOldItem = ""
4607 SELECT tmpCurs
4608 IF THIS.lUserInterface
4609 * Init Thermometer
4610 THIS.UpdateThermoCaption("Validating SKU(s)...")
4611 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4612 l_nThermoCnt = 0
4613 ENDIF
4614 SCAN
4615 IF THIS.lUserInterface
4616 l_nThermoCnt = l_nThermoCnt + 1
4617 THIS.AdvanceThermo(l_nThermoCnt)
4618 ENDIF
4619 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
4620 lcErrs_Msg = ""
4621 lcOldCust = tmpCurs.customer
4622 lcOldItem = tmpCurs.sku
4623 IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
4624 lcDivision = tmpCstdr.division
4625 lcStyle = tmpCstdr.STYLE
4626 lcColor_code = tmpCstdr.color_code
4627 lcLbl_code = tmpCstdr.lbl_code
4628 lcDimension = tmpCstdr.DIMENSION
4629 lnSizeBucket = tmpCstdr.size_bk
4630 lnSize_desc = tmpCstdr.size_desc
4631 ELSE
4632 lcErrs_Msg = lcErrs_Msg + CRLF
4633 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4634 STORE 0 TO lnSizeBucket
4635 ENDIF
4636 ENDIF && level break
4637
4638 SELECT (pceipcTD)
4639 IF SEEK(tmpCurs.pkey, pceipcTD, "PKey")
4640 SCATTER NAME loEiPCtd MEMO
4641 IF !EMPTY(lcErrs_Msg)
4642 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4643 loEiPCtd.Errs_Flg_D = "Y"
4644 ENDIF
4645 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4646 loEiPCtd.division = lcDivision
4647 loEiPCtd.STYLE = lcStyle
4648 loEiPCtd.color_code = lcColor_code
4649 loEiPCtd.lbl_code = lcLbl_code
4650 loEiPCtd.DIMENSION = lcDimension
4651 loEiPCtd.Sizebucket = lnSizeBucket
4652 loEiPCtd.size_desc = lnSize_desc
4653 ENDIF
4654
4655 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4656 GATHER NAME loEiPCtd MEMO
4657 ENDIF
4658
4659 ENDIF
4660 ENDSCAN
4661 USE IN tmpCurs
4662
4663 IF THIS.lUserInterface
4664 * Reset Thermometer
4665 THIS.ResetThermo()
4666 ENDIF
4667
4668 IF USED("tmpCstdr")
4669 USE IN tmpCstdr
4670 ENDIF
4671
4672 SELECT(lnOldSelect)
4673 RETURN llRetVal
4674 ENDPROC
4675
4676 PROCEDURE ResolveCustomerLabel
4677 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4678 LOCAL llRetVal, lnOldSelect
4679 llRetVal = .T.
4680 lnOldSelect = SELECT()
4681 WITH THIS
4682 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
4683 .oLog.LogEntry("Cascading Customer To Detail.")
4684 llRetVal= llRetVal AND .CascadingCustomerToDetail(pceipcTH, pceipcTD)
4685 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
4686 .oLog.LogEntry("Substituding customer label.")
4687 llRetVal= llRetVal AND .SubstitudeValidLabel(pceipcTH, pceipcTD, pceipcCR)
4688 ENDWITH
4689 SELECT(lnOldSelect)
4690 RETURN llRetVal
4691 ENDPROC
4692
4693 ************************************************************************************
4694 * Resolve shared UPC
4695 ************************************************************************************
4696 PROCEDURE CascadingCustomerToDetail
4697 LPARAMETERS pceipcTH, pceipcTD
4698 LOCAL llRetVal, lnOldSelect
4699 llRetVal = .T.
4700 lnOldSelect = SELECT()
4701 WITH THIS
4702 * set header/detail Relation
4703 llRetVal= llRetVal AND .SetRelation(pceipcTH, "Pkey", pceipcTD, "Fkey")
4704 REPLACE ALL customer WITH &pceipcTH..customer IN (pceipcTD)
4705 SET RELATION TO
4706 ENDWITH
4707 SELECT(lnOldSelect)
4708 RETURN llRetVal
4709 ENDPROC
4710
4711 ************************************************************************************
4712 * Resolve shared UPC
4713 ************************************************************************************
4714 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
4715 * regardless of auto_create of style flag set in Customer Label Ref.
4716 PROCEDURE SubstitudeValidLabel
4717 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4718 LOCAL llRetVal, lnOldSelect
4719 llRetVal = .T.
4720 lnOldSelect = SELECT()
4721 LOCAL lcOrder_ipcTD && TR 1019356
4722 lcOrder_ipcTD = "" && TR 1019356
4723 WITH THIS
4724 *-- TR 1019356 NH 01/05/07
4725 LOCAL lcBcSku
4726 lcBcSku = ""
4727 *- Also process when resv_label= 'V' (Validate). In this case populate label only
4728 *- if the SKU with the label is valid and active in the style master.
4729 *--- TR 1027127 NH
4730 *IF .lResl_delv
4731 IF TYPE(pceipcCR + ".resv_label") == "C"
4732 *=== TR 1027127 NH
4733 *--- TR 1048865 27-Dec-2010 Goutam
4734 *--- Changed from d.division= C.division AND h.customer= C.customer to ;
4735 h.cr_pkey = c.pkey in the following sql
4736 SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION, C.resv_label ; &&Use SubCust lbl_code
4737 FROM (pceipcTH) h, (pceipcTD) d, (pceipcCR) C ;
4738 WHERE h.pkey= d.fkey AND ;
4739 h.cr_pkey = c.pkey AND ;
4740 (C.resv_label= 'Y' OR C.resv_label= 'V') AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
4741 EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
4742 h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4743 INTO CURSOR tmpCurs
4744 ELSE
4745 *--- TR 1048865 27-Dec-2010 Goutam
4746 *--- Changed from d.division= C.division AND h.customer= C.customer to ;
4747 h.cr_pkey = c.pkey in the following sql
4748 SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION, '' resv_label ; &&Use SubCust lbl_code - 1027127
4749 FROM (pceipcTH) h, (pceipcTD) d, (pceipcCR) C ;
4750 WHERE h.pkey= d.fkey AND ;
4751 h.cr_pkey = c.pkey AND ;
4752 C.resv_label= 'Y' AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
4753 EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
4754 h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4755 INTO CURSOR tmpCurs
4756 ENDIF
4757 *=== TR 1019356 NH
4758 INDEX ON customer+division+STYLE+color_code+DIMENSION TAG OurSkuNoLb
4759 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipcTD, ;
4760 "customer+division+style+color_code+dimension")
4761 IF llRetVal
4762 *--- 1019356 NH 01/05/07
4763*!* REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipcTD);
4764*!* FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
4765 SELECT (pceipcTD)
4766 *--- remove the order of pceipcTD, otherwise replace moves the record pointer to the end of the match.
4767 lcOrder_ipcTD = ORDER()
4768 SET ORDER TO
4769 SCAN FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
4770 lcBcSku = tmpCurs.division + tmpCurs.style + tmpCurs.color_code + tmpCurs.lbl_code + tmpCurs.dimension
4771 *--- update label value only when Resv_label flag is 'Y' or
4772 *--- Resv_label flag is 'V' and blue cherry sku exists with matching label and active
4773 IF tmpCurs.Resv_label = "Y" OR ;
4774 (tmpCurs.Resv_label = "V" AND SEEK(lcBcSku,"tcScolr","SKU") AND tcScolr.active_ok = "Y")
4775 REPLACE lbl_code WITH tmpCurs.lbl_code IN (pceipcTD)
4776 ENDIF
4777 ENDSCAN
4778 SELECT (pceipcTD)
4779 SET ORDER TO (lcOrder_ipcTD)
4780 *=== TR 1019356 NH
4781 SET RELATION TO
4782 ENDIF
4783 .TableClose('tmpCurs')
4784 ENDWITH
4785 SELECT(lnOldSelect)
4786 RETURN llRetVal
4787 ENDPROC
4788
4789 PROCEDURE ValidateOurSKU
4790 LPARAMETERS pceipcTH, pceipcTD, plValidateStyleOrderType
4791 LOCAL llRetVal, lnOldSelect
4792 llRetVal = .T.
4793 lnOldSelect = SELECT()
4794
4795 IF NOT plValidateStyleOrderType
4796 SELECT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code,;
4797 d.DIMENSION, d.Sizebucket, d.pkey, '' AS ord_type ;
4798 FROM (pceipcTH) h, (pceipcTD) d ;
4799 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' ;
4800 AND d.STYLE<>'' AND d.color_code<>'' ;
4801 ORDER BY h.customer,d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4802 INTO CURSOR tmpCurs
4803
4804 *- For range styles need to add
4805 *- WHERE d.rng_style = ' '
4806
4807 ELSE
4808 lcSQLSelect = "select * from zzotyper"
4809 llRetVal= THIS.vsqlexec(lcSQLSelect, "tcotyper")
4810 IF llRetVal
4811 SELECT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code,;
4812 d.DIMENSION, d.Sizebucket, d.pkey, h.ord_type ;
4813 FROM (pceipcTH) h, (pceipcTD) d, tcotyper o ;
4814 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' ;
4815 AND d.STYLE<>'' AND d.color_code<>'' AND ;
4816 (h.ord_type<>'' AND h.ord_type=o.ord_type AND o.val_styl_ord='Y') ;
4817 ORDER BY h.customer,d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4818 INTO CURSOR tmpCurs
4819
4820 ELSE
4821 RETURN llRetVal
4822 ENDIF
4823 ENDIF
4824
4825 lcErrs_Msg = ''
4826 SCATTER MEMO NAME oTmpCurs BLANK
4827
4828 THIS.oLog.LogEntry("Begin Available Size Validation")&&TR 1041492 JUL-20-2009 BR
4829
4830 WITH oTmpCurs
4831 SCAN
4832 IF !(tmpCurs.customer == .customer ;
4833 AND tmpCurs.division == .division ;
4834 AND tmpCurs.STYLE == .STYLE ;
4835 AND tmpCurs.color_code == .color_code ;
4836 AND tmpCurs.lbl_code == .lbl_code ;
4837 AND tmpCurs.DIMENSION == .DIMENSION ;
4838 AND tmpCurs.Sizebucket == .Sizebucket)
4839 lcErrs_Msg = ''
4840
4841 SCATTER MEMO NAME oTmpCurs
4842 IF NOT THIS.oBPOSalesOrder.ValidAvailableSize(@lcErrs_Msg,oTmpCurs)
4843 lcErrs_Msg= lcErrs_Msg + CRLF
4844 ENDIF
4845 ENDIF
4846 * for each detail line replace detail error msg if have one
4847 IF !EMPTY(lcErrs_Msg) AND SEEK(tmpCurs.pkey, pceipcTD, "Pkey")
4848 REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Msg, ;
4849 Errs_Flg_D WITH 'Y' IN (pceipcTD)
4850 ENDIF
4851 ENDSCAN
4852 ENDWITH
4853 THIS.oLog.LogEntry("Available Size Validation...Complete")&&TR 1041492 JUL-20-2009 BR
4854 THIS.TableClose("tcotyper")
4855
4856 SELECT(lnOldSelect)
4857 RETURN llRetVal
4858 ENDPROC
4859
4860 ****************************************************************************
4861 PROCEDURE ValidateMinMultiple
4862 LPARAMETERS pceipcTH, pceipcTD
4863 LOCAL llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
4864 llRetVal = .T.
4865 lnOldSelect = SELECT()
4866
4867 WITH THIS
4868 * 1st Get distinct list of div,sty,col,lbl,dim for min_multiple check
4869 SELECT DISTINCT d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
4870 FROM (pceipcTH) h, (pceipcTD) d ;
4871 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4872 ORDER BY 1,2,3,4,5 ;
4873 INTO CURSOR __TmpCursor
4874 * 2nd. Server-side join previous list to get cursor of scolr
4875 * that have ONLY min_multiple> 1
4876 .cSQLTempTable=""
4877 IF .GenerateSQLTempTable('__TmpCursor')
4878 IF .PopulateSQLTempTable('__TmpCursor')
4879 IF !EMPTY(.cSQLTempTable)
4880 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
4881 "Where s.division= t.division and s.style= t.style and "+;
4882 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
4883 "s.dimension= t.dimension and s.min_multiple> 1"
4884 llRetVal = v_SQLExec(lcSQLString, "_Scolr")
4885
4886 *--- TR 1085815 27-Mar-2015 BNarayanan ---
4887 llRetVal = v_SQLExec("select * from zzotyper" , "_OrdTyp")
4888 *=== TR 1085815 27-Mar-2015 BNarayanan ===
4889
4890 * 3rd. Per order sum all total_qty to verify not break Min_multiple
4891 * Fkey (OrderbyOrder),PO1_SKU,PO1_UPC,price,org_price,div,style,col,lbl,dim
4892 *--- TR 1085815 27-Mar-2015 BNarayanan skip validation for order types having skip Min multiplier option ---
4893 SELECT h.customer, d.fkey, d.division, d.STYLE, d.color_code,d.lbl_code,;
4894 d.DIMENSION, SUM(d.Qty_change) AS line_qty, s.min_multiple ;
4895 FROM (pceipcTH) h, (pceipcTD) d, _Scolr s ;
4896 WHERE h.pkey = d.fkey AND h.customer<>'' AND ;
4897 d.division= s.division AND d.STYLE= s.STYLE AND ;
4898 d.color_code= s.color_code AND d.lbl_code= s.lbl_code AND ;
4899 d.DIMENSION= s.DIMENSION AND ;
4900 d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4901 AND NOT exists (select * FROM _OrdTyp o WHERE o.ord_type = h.ord_type AND o.skip_mmult = 'Y') ; && 1085815
4902 ORDER BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4903 GROUP BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4904 INTO CURSOR tmpCurs
4905
4906 l_nThermoCnt = 0
4907 .InitThermoWithCaption(@l_nThermoCnt, THIS.CountTotalRecs ("tmpCurs"), ;
4908 "Checking Minimum/Multiple for all orders...")
4909 SCAN
4910 .AdvanceThermoPlus(@l_nThermoCnt)
4911 lcCurrKeys= STR(fkey)+STYLE+color_code+lbl_code+DIMENSION
4912
4913 lcErrs_Msg = ''
4914 IF NOT vl_min_mult(line_qty, division, STYLE, color_code, lbl_code, DIMENSION, ;
4915 @lcErrs_Msg, .T.) && Don't display Errorbox()
4916 REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Msg + CRLF, Errs_Flg_D WITH "Y" ;
4917 FOR STR(fkey)+STYLE+color_code+lbl_code+DIMENSION = lcCurrKeys ;
4918 IN (pceipcTD)
4919 ENDIF
4920 ENDSCAN
4921 .ResetThermoPlus()
4922 .TableClose("_Scolr")
4923 .TableClose("__TmpCursor")
4924 *--- TR 1085815 27-Mar-2015 BNarayanan ---
4925 .TableClose("_OrdTyp")
4926 *=== TR 1085815 27-Mar-2015 BNarayanan ===
4927 ENDIF
4928 ENDIF
4929 ENDIF
4930
4931 ENDWITH
4932 SELECT(lnOldSelect)
4933 RETURN llRetVal
4934 ENDPROC
4935
4936 PROCEDURE UpdtHeaderDivs
4937 LPARAMETERS pceipcTH, pceipcTD
4938 LOCAL llRetVal, lnOldSelect, llUpdate
4939 llRetVal = .T.
4940 lnOldSelect = SELECT()
4941
4942 .oLog.LogEntry("Resolving header division.")
4943 SELECT DISTINCT fkey, division FROM (pceipcTD) ;
4944 WHERE !EMPTY(division) INTO CURSOR tmpCurs
4945 SELECT tmpCurs
4946 IF THIS.lUserInterface
4947 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4948 l_nThermoCnt = 0
4949 ENDIF
4950 SCAN
4951 IF THIS.lUserInterface
4952 l_nThermoCnt = l_nThermoCnt + 1
4953 THIS.AdvanceThermo(l_nThermoCnt)
4954 ENDIF
4955 SELECT (pceipcTH)
4956 *--- TR 1041492 JUL-20-2009 BR
4957 IF SEEK(tmpCurs.fkey,pceipcTH,"pkey")
4958*!* LOCATE FOR pkey = tmpCurs.fkey
4959*!* IF FOUND()
4960 *=== TR 1041492 JUL-20-2009 BR
4961 REPLACE division WITH tmpCurs.division IN (pceipcTH)
4962 ENDIF
4963 ENDSCAN
4964 USE IN tmpCurs
4965
4966 IF THIS.lUserInterface
4967 THIS.ResetThermo()
4968 ENDIF
4969 SELECT(lnOldSelect)
4970 RETURN llRetVal
4971 ENDPROC
4972
4973 FUNCTION ApplyPOChanges
4974 * LPARAMETER pcSQLFilterString, plNoScreenUI
4975 LOCAL llRetVal, lnSelect, lcMsg, lcSyslockTablePath, lnPKey
4976 LOCAL laRatioViews(1)
4977 PRIVATE pcCustomer, pcDivision, pnPO_Num, pcStore
4978 *--- TR 1017210 NH
4979 LOCAL lnMaxLine_seq
4980 lnMaxLine_seq = 0
4981 *=== TR 1017210 NH
4982
4983 *--- TR 1021052 18-SEP-2007 Goutam
4984 LOCAL lcSqlString, lcWorkAlias
4985
4986 *--- TR 1028744 19-FEB-2008 VKK
4987 LOCAL llValidOrder
4988
4989 llRetVal = true
4990 lnSelect = SELECT()
4991 pcCustomer = ""
4992 pcDivision = ""
4993 pnPO_Num = 0
4994 pcStore = ""
4995 *--- TR 1017210 NH
4996 DECLARE laDuplicateFields[1]
4997 ACOPY(THIS.aDuplicateFields, laDuplicateFields)
4998 *=== TR 1017210 NH
4999 *!* lcSyslockTablePath = AddBS(goEnv.envLoginTablePath.VALUE)
5000 *!* IF NOT v_SysLock(lcSyslockTablePath+"SYSLOCK", "EDI860INBOUND", goEnv.cCompany)
5001 *!* This.lProcessLocked = .T.
5002 *!* RETURN false
5003 *!* ENDIF
5004
5005 WITH THIS
5006 * Initialize object properties
5007 .lNoDataFound = false
5008 .cMessage = ''
5009 * .lScheduled = plNoScreenUI
5010
5011 * Retrieve records to process
5012 * .CreateFormProgressBar(.lScheduled)
5013 *!* * .UpdateThermoCaption("Selecting 860 inbound records to process...")
5014 *!* .InitProgressBarTotal(2, "Total 860 Inbound Process.")
5015 *!* .InitThermo(2)
5016 *!* INKEY(0.2)
5017
5018 *!* lcLogFile = AddBS(goEnv.SystemParm(SP_PATH_LOGS)) + ;
5019 *!* goEnv.SystemParm(SP_COMP_CODE) + "_" + .cLogFile
5020 *!* DELETE FILE &lcLogFile
5021
5022 *!* THIS.lIncludeLog = .T.
5023 *!* .InstantiateLogging()
5024
5025 *!* * .oLog.OpenLog(.cJobID, i(.cJobID), .lScheduled, .cLogFile)
5026 *!* .oLog.LogProgram("clsIPCPR.prg")
5027 *!* * .oLog.LogEntry("Filter Criteria: " + IIF(EMPTY(pcSQLFilterString), " - None - ", pcSQLFilterString))
5028
5029 IF NOT .CreateSOViews()
5030 .lErrorState = true
5031 llRetVal = false
5032 .cMessage = MSG_FILTER_ERROR + CRLF + MSG_TRY_AGAIN_NOW
5033
5034 .oLog.LogEntry(.cMessage)
5035 .oLog.LogEntry("")
5036 * .oLog.CloseLog()
5037 .m_close()
5038 ELSE
5039 .AdvanceThermoTotal(1)
5040 .AdvanceThermo(2)
5041 INKEY(0.2)
5042
5043 .nToProcess = RECCOUNT("tceipcth")
5044 .nProcessed = 0
5045
5046 IF .nToProcess = 0
5047 .lNoDataFound = true
5048 .cMessage = 'There are no 860 records to process.'
5049
5050 .oLog.LogEntry(.cMessage)
5051 ELSE
5052 lcMsg = ALLTRIM(STR(.nToProcess)) + " 860 inbound record(s) were found." + CRLF + ;
5053 "Are you sure you want to process them?"
5054
5055 IF .lScheduled OR AskBox(lcMsg,,,true) && Default second
5056 * Calculate proration
5057 .UpdateThermoCaption("Processing 860 inbound records...")
5058 .InitThermo(2)
5059 INKEY(0.2)
5060
5061 *!* Could have used something like the following to create sales order views. This is more set-based,
5062 *!* but if one record in the tableupdate fails, they all fail, and the process is doomed.
5063 *!* Per Yuriah, use the one record at a time logic.
5064
5065 *!* .UpdateThermoCaption("Pulling down Header, Detail, Cost, and BOM views...")
5066 *!* .InitThermo(2) && 2 = The number of tables to pull
5067 *!* lcSQLString = "SELECT * FROM ZZCORDRD WHERE Prod_num IN (" + lcProd_Nums + ") " + ;
5068 *!* " AND EXISTS(SELECT * FROM zzccostd WHERE FKey = zzcordrd.PKey) " + ;
5069 *!* " ORDER BY Prod_Num, Open_Seq"
5070 *!* llRetVal = .CreateSQLView("Vzzcordrd_Tree", lcSQLString, , 'prod_num, open_seq, stage_num')
5071 *!* llRetVal = llRetVal AND .OpenTable("Vzzcordrd_Tree",,true,,3)
5072 *!* .AdvanceThermo(1)
5073
5074 *!* lcSQLString = "..."
5075 *!* .AdvanceThermo(2)
5076
5077 *!* IF llRetVal
5078 *!* .IndexSalesOrder()
5079 *!* ENDIF
5080
5081 *!* llRetVal = llRetVal AND CURSORSETPROP("BUFFER", 5, "Vzzoordrh_860I")
5082 *!* llRetVal = llRetVal AND CURSORSETPROP("BUFFER", 5, "Vzzoordrd_860I")
5083 *!* .InitThermo(2)
5084 *- 1014475 12/02/05 YIK
5085
5086 *--- TR 1021052 18-SEP-2007 Goutam
5087 lcWorkAlias = GetUniqueFileName()
5088
5089 SELECT h.pkey as HPKey, ;
5090 d.pkey as DPKey, ;
5091 h.Customer, ;
5092 h.Division, ;
5093 h.Po_Num, ;
5094 d.Style, ;
5095 d.Color_code, ;
5096 d.lbl_code, ;
5097 d.Dimension ;
5098 FROM ;
5099 tcEiPCth h ;
5100 INNER JOIN ;
5101 tcEiPCtd d ;
5102 ON d.fkey = h.pkey ;
5103 INTO Cursor (lcWorkAlias)
5104
5105 llRetVal = llRetVal AND .GenerateSQLTempTable(lcWorkAlias)
5106
5107 *---TR 1028239 11/7/07 BR
5108 *llRetVal = llRetVal AND .PopulateSQLTempTable(lcWorkAlias)
5109 IF llRetVal and RECCOUNT(lcWorkAlias) > 0
5110 llRetVal = llRetVal AND .PopulateSQLTempTable(lcWorkAlias)
5111 ENDIF
5112 *===TR 1028239 11/7/07 BR
5113
5114 llRetVal = llRetVal AND NOT EMPTY(.cSQLTempTable)
5115 .TableClose(lcWorkAlias)
5116 *=== TR 1021052 18-SEP-2007 Goutam
5117
5118 THIS.nMaxSizes = vl_compr("", "max_bucket")
5119
5120 SELECT tcEiPCtd
5121 SET ORDER TO TAG fkey
5122
5123 SELECT tcEiPCtc
5124 SET ORDER TO TAG fkey
5125
5126 *--- TR 1021052 18-SEP-2007 Goutam. Deleted following line
5127 *llRetVal = .T.
5128
5129 SELECT tcEiPCth
5130 SCAN
5131
5132 *--- TR 1021052 18-SEP-2007 Goutam
5133 IF NOT llRetVal
5134 EXIT
5135 ENDIF
5136 *=== TR 1021052 18-SEP-2007 Goutam
5137
5138 IF tcEiPCth.Errs_flg_h = "Y" AND tcEiPCth.Auto_proc = "Y" && TR 1019356
5139 LOOP
5140 ENDIF
5141 *- 1015584 02/14/06 YIK
5142 lnPKey = tcEiPCth.pkey
5143
5144 ACOPY(.oBPOCancel.aRatioViews, laRatioViews) && Need for each iteration, might get changed.
5145 .lOneDetailLineBad = .F.
5146 .lUpdateCancelViews = .F.
5147 .lCreatedRatioCursor = .F.
5148
5149 pcCustomer = tcEiPCth.customer
5150 pcDivision = tcEiPCth.division
5151 pnPO_Num = tcEiPCth.PO_Num
5152 pcStore = tcEiPCth.STORE
5153
5154 *--- TR 1021052 20-AUG-2007 HNISAR & Goutam
5155 .lNewOrder = false
5156
5157 *--- TR 1048865 27-Dec-2010 Goutam
5158 *IF SEEK(pcDivision+pcCustomer, 'zzeipccr', 'divcust')
5159 IF SEEK(tcEiPCth.cr_pkey, 'zzeipccr', 'pkey')
5160 *=== TR 1048865 27-Dec-2010 Goutam
5161 .lNewOrder = (zzeipccr.new_order=='Y')
5162 ENDIF
5163 *=== TR 1021052 20-AUG-2007 HNISAR & Goutam
5164
5165 *- 1014475 01/16/06 YIK
5166 *- change RECCOUNT("Vzzoordrh_860I") > 0 to RECCOUNT("Vzzoordrh_860I") = 1
5167 *- if we get 2 or more records, it means the order is partially picked.
5168 *--- TR 1016589 NH : just requery header and detail notes, there may not be any notes at all so,
5169 *---- no need for reccount() for notes.
5170*!* IF ( (REQUERY("Vzzoordrh_860I") > 0 AND RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5171*!* (REQUERY("Vzzoordrd_860I") > 0 AND RECCOUNT("Vzzoordrd_860I") > 0) )
5172
5173 *--- TR 1021052 20-AUG-2007 HNISAR
5174 *IF llRetVAl AND ((REQUERY("Vzzoordrh_860I") > 0 AND RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5175 (REQUERY("Vzzoordrd_860I") > 0 AND RECCOUNT("Vzzoordrd_860I") > 0) AND ;
5176 REQUERY("Vnotes_zzoordrh_860I") > 0 AND REQUERY("Vnotes_zzoordrd_860I") > 0 )
5177
5178 .lOrderExist = (REQUERY("Vzzoordrh_860I") > 0) AND ;
5179 (REQUERY("Vzzoordrd_860I") > 0) AND ;
5180 (REQUERY("Vnotes_zzoordrh_860I")) > 0 AND ;
5181 (REQUERY("Vnotes_zzoordrd_860I") > 0) AND ;
5182 (RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5183 (RECCOUNT("Vzzoordrd_860I") > 0)
5184
5185 IF .lOrderExist OR (Not .lOrderExist AND .lNewOrder)
5186 *=== TR 1021052 20-AUG-2007 HNISAR
5187
5188 *---
5189 *=== TR 1016589 NH
5190 IF tcEiPCth.POC_Purp = "01"
5191 IF tcEiPCth.Auto_proc = 'Y' && TR 1019356 - do cancel only when Auto_proc flag is true
5192 * Header level change:
5193 * Cancel entire sales odor:
5194 *--- TR 1019356 - does not make sence for two vl calls for two values of same record.
5195 *--- zzeipccr is already cached so.. why not use that!
5196*!* lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
5197*!* lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
5198
5199 *--- TR 1048865 27-Dec-2010 Goutam
5200 *IF SEEK(Vzzoordrh_860I.division + Vzzoordrh_860I.customer , "zzeipccr","divCust")
5201 IF SEEK(Vzzoordrh_860I.cr_pkey, "zzeipccr","pkey")
5202 *=== TR 1048865 27-Dec-2010 Goutam
5203
5204 lcCncl_Rsn = zzeipccr.Cncl_Rsn
5205 lcCncl_Type = zzeipccr.Cncl_Type
5206 ELSE
5207 lcCncl_Rsn = ""
5208 lcCncl_Type = ""
5209 ENDIF
5210 *=== TR 1019356
5211 WITH THIS.oBPOCancel
5212 .CreateRatioCursor()
5213 .cCncl_Rsn = lcCncl_Rsn
5214 .cCncl_Type = lcCncl_Type
5215 ENDWITH
5216
5217 .CancelSO(lcCncl_Rsn, lcCncl_Type)
5218 ENDIF
5219 ELSE
5220
5221 * Detail level change:
5222 lnPKey = tcEiPCth.pkey
5223 SELECT tcEiPCtd
5224
5225 .lUpdateSalesOrder = .F.
5226 .lUpdate860Records = .F.
5227 .lDelete860Records = .F.
5228 *--- TR 1017210 NH
5229 SELECT MAX(line_seq) as maxLine_seq FROM Vzzoordrd_860I INTO CURSOR tcOrdrd_MaxLine_seq
5230 lnMaxLine_seq = tcOrdrd_MaxLine_seq.maxLine_seq
5231 USE IN tcOrdrd_MaxLine_seq
5232 SELECT tcEiPCtd
5233 *=== TR 1017210 NH
5234
5235 *--- TR 1028744 19-FEB-2008 VKK
5236 llValidOrder = .CheckHardLink(Vzzoordrh_860I.Ord_Num)
5237 *=== TR 1028744 19-FEB-2008 VKK
5238
5239 *--- TR 1021052 17-SEP-2007 Goutam
5240 .lOrderHdrFound = false
5241 *=== TR 1021052 17-SEP-2007 Goutam
5242
5243 SEEK lnPKey
5244 *--- TR 1028744 19-FEB-2008 VKK Aded llvalidorder
5245 SCAN WHILE fkey = lnPKey AND llValidOrder
5246 *--- TR 1017210 NH
5247 *.ValidateDetail()
5248 .ValidateDetail(@lnMaxLine_seq, @laDuplicateFields)
5249 *=== TR 1017210 NH
5250 ENDSCAN
5251
5252 * Date change - Start_Date and/or End_Date will be populated:
5253 *--- TR 1015747 NH :
5254 *IF tcEiPCth.start_date <> {01/01/1900}
5255 IF NOT EMPTY(tcEiPCth.start_date) and tcEiPCth.start_date <> {01/01/1900}
5256 *=== TR 1015747 NH
5257 *- 1014475 12/21/05 YIK
5258 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
5259 *- and Vzzoordrd_860I
5260 REPLACE ;
5261 start_date WITH tcEiPCth.start_date, ;
5262 User_id WITH goEnv.cUser ;
5263 IN Vzzoordrh_860I
5264 REPLACE ALL ;
5265 start_date WITH tcEiPCth.start_date, ;
5266 end_date WITH IIF(end_date < tcEiPCth.start_date, ;
5267 tcEiPCth.start_date, end_date), ;
5268 User_id WITH goEnv.cUser ;
5269 IN Vzzoordrd_860I
5270
5271 .lUpdateSalesOrder = .T.
5272 .lDelete860Records = .T.
5273 ENDIF
5274 *- 1014475 12/21/05 YIK
5275 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
5276 *- and Vzzoordrd_860I
5277 *--- TR 1015747 NH :
5278 *IF tcEiPCth.end_date <> {01/01/1900}
5279 IF NOT EMPTY(tcEiPCth.end_date) AND tcEiPCth.end_date <> {01/01/1900}
5280 *==== TR 1015747 NH
5281 REPLACE ;
5282 end_date WITH tcEiPCth.end_date, ;
5283 User_id WITH goEnv.cUser ;
5284 IN Vzzoordrh_860I
5285 REPLACE ALL ;
5286 end_date WITH tcEiPCth.end_date, ;
5287 User_id WITH goEnv.cUser ;
5288 IN Vzzoordrd_860I
5289 .lUpdateSalesOrder = .T.
5290 .lDelete860Records = .T.
5291 ENDIF
5292
5293 *--- TR 1028909 6-Dec-2007 Goutam
5294 IF NOT EMPTY(tcEiPCth.altpo)
5295 REPLACE ;
5296 altpo WITH tcEiPCth.altpo, ;
5297 User_id WITH goEnv.cUser ;
5298 IN Vzzoordrh_860I
5299 .lUpdateSalesOrder = .T.
5300 .lDelete860Records = .T.
5301 ENDIF
5302 IF NOT EMPTY(tcEiPCth.po_desc)
5303 REPLACE ;
5304 po_desc WITH tcEiPCth.po_desc, ;
5305 User_id WITH goEnv.cUser ;
5306 IN Vzzoordrh_860I
5307 .lUpdateSalesOrder = .T.
5308 .lDelete860Records = .T.
5309 ENDIF
5310 *=== TR 1028909 6-Dec-2007 Goutam
5311
5312 *--- TR 1028744 19-FEB-2008 VKK
5313 IF NOT EMPTY(tcEiPCth.UDFORD7C)
5314 REPLACE ;
5315 UDFORD7C WITH tcEiPCth.UDFORD7C, ;
5316 User_id WITH goEnv.cUser ;
5317 IN Vzzoordrh_860I
5318
5319 .lUpdateSalesOrder = .T.
5320 .lDelete860Records = .T.
5321 ENDIF
5322
5323 IF NOT EMPTY(tcEiPCth.pri_date) AND tcEiPCth.pri_date <> {01/01/1900}
5324 REPLACE ;
5325 pri_date WITH tcEiPCth.pri_date, ;
5326 User_id WITH goEnv.cUser ;
5327 IN Vzzoordrh_860I
5328 REPLACE ALL ;
5329 pri_date WITH tcEiPCth.pri_date, ;
5330 User_id WITH goEnv.cUser ;
5331 IN Vzzoordrd_860I
5332
5333 .lUpdateSalesOrder = .T.
5334 .lDelete860Records = .T.
5335 ENDIF
5336 *=== TR 1028744 19-FEB-2008 VKK
5337
5338 *--- TR 1016589 NH
5339 IF .lUpdateSalesOrder
5340 llRetVal = llRetVal ;
5341 and .AddHdrNotes("tcEiPCth","Vnotes_ipch_iPCproc", "Vnotes_zzoordrh_860I",;
5342 "Vzzoordrh_860I")
5343 llRetVal = llRetVal ;
5344 and .AddDtlNotes("tcEiPCth", "tcEiPCtd", "Vnotes_ipcd_iPCproc", ;
5345 "Vnotes_zzoordrd_860I","Vzzoordrd_860I" )
5346 ENDIF
5347 *=== TR 1016589 NH
5348 ENDIF
5349
5350 .UpdateThermoCaption("Sending data back to server...")
5351 .InitThermo(5)
5352 *--- TR 1019356 NH - when Auto_proc flag is not set then only update the transactions tables.
5353 IF tcEiPCth.Auto_proc <> "Y"
5354 .lUpdate860Records = .T.
5355 .lUpdateSalesOrder = .F.
5356 .lDelete860Records = .F.
5357 .lOneDetailLineBad = .T.
5358 .lDelete860Records = .f.
5359 .lUpdateCancelViews = .f.
5360 ENDIF
5361 *=== TR 1019356 NH
5362
5363
5364 * Only update if something happened:
5365 IF .lUpdateSalesOrder OR .lUpdate860Records OR (.lDelete860Records AND NOT .lOneDetailLineBad)
5366 IF .lCreatedRatioCursor AND NOT .lOneDetailLineBad
5367 * This batch involved some cancellations. oBPOCancel.ProcessCancelByOrder()
5368 * finalizes these by taking the data in the Ratio Cursor and performing
5369 * some magic to create the cancel and header records:
5370 llRetVal = .oBPOCancel.ProcessCancelByOrder(Vzzoordrh_860I.pkey)
5371 IF llRetVal
5372 .lUpdateCancelViews = true
5373 * Check to see if Vzzoordrh/d_860I is supposed to be updated. Since
5374 * the cancel cursors are to be updated already, instead of doing two
5375 * updates to the backend, move any potentially changed fields on SO
5376 * views back to the Ratio Sales Order Views, and do the tableupdate
5377 * on them instead of normal SO views:
5378 IF .lUpdateSalesOrder
5379 * A header record becomes two header records, one with Cncl_Num filled in.
5380 * A detail record keeps its PKey, but gets a few fields like FKey, Line_Type, Cncl_Date changed.
5381
5382 *--- TR 1028909 15-Jul-2008 Goutam Added altpo, po_desc in the following replace statement.
5383
5384 REPLACE ALL ;
5385 start_date WITH Vzzoordrh_860I.start_date, ;
5386 end_date WITH Vzzoordrh_860I.end_date, ;
5387 altpo WITH Vzzoordrh_860I.altpo, ;
5388 po_desc WITH Vzzoordrh_860I.po_desc, ;
5389 User_id WITH Vzzoordrh_860I.User_id, ;
5390 Last_mod WITH Vzzoordrh_860I.Last_mod ;
5391 IN Vzzoordrh_Ratio_Confirm
5392
5393 SELECT Vzzoordrd_860I
5394 SCAN
5395 SELECT Vzzoordrd_Ratio_Confirm
5396 LOCATE FOR pkey = Vzzoordrd_860I.pkey
5397 IF FOUND()
5398 REPLACE ;
5399 start_date WITH Vzzoordrd_860I.start_date, ;
5400 end_date WITH Vzzoordrd_860I.end_date, ;
5401 Price WITH Vzzoordrd_860I.Price, ;
5402 Retail1 WITH Vzzoordrd_860I.Retail1, ;
5403 Retail2 WITH Vzzoordrd_860I.Retail2, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
5404 User_id WITH Vzzoordrd_860I.User_id, ;
5405 Last_mod WITH Vzzoordrd_860I.Last_mod ;
5406 IN Vzzoordrd_Ratio_Confirm
5407 ENDIF
5408 ENDSCAN
5409
5410 .lUpdateSalesOrder = false
5411 = .TABLEREVERT("Vzzoordrh_860I")
5412 = .TABLEREVERT("Vzzoordrd_860I")
5413
5414 ENDIF
5415
5416 ELSE
5417 .RecordError("Could not perform cancellation.")
5418 .lUpdate860Records = true
5419 .lUpdateCancelViews = false
5420 ENDIF
5421 ENDIF
5422
5423 llBeganTransaction = .BeginTransaction()
5424
5425 IF .lUpdateSalesOrder AND NOT .lOneDetailLineBad
5426 llRetVal = llRetVal AND .TABLEUPDATE("Vzzoordrh_860I")
5427 .AdvanceThermo(1)
5428
5429 llRetVal = llRetVal AND .TABLEUPDATE("Vzzoordrd_860I")
5430 IF llRetVal
5431 .nProcessed = .nProcessed + 1
5432 ENDIF
5433 ENDIF
5434
5435 * Probably not the best place for this, but...
5436 * If any comments exist in comments table (zzeipctc),
5437 * shoot em to the backend:
5438 *!* SELECT tceipctc
5439 *!* SEEK lnPKey
5440 *!* SCAN WHILE FKey = lnPKey
5441 *!* lcSQLString = "INSERT INTO zzoordcd " + CHR(13) + ;
5442 *!* " (Ord_Num, Line_Num, Cmt_Code, Cmmnt, Notes, User_ID, Last_Mod, PKey, FKey)" + CHR(13) + ;
5443 *!* "VALUES " + CHR(13) + ;
5444 *!* " (" + ;
5445 *!* SQLFormatNum(tceipctc.Ord_Num) + ", " + ;
5446 *!* SQLFormatNum(tceipctc.Line_Num) + ", " + ;
5447 *!* SQLFormatChar(tceipctc.Cmt_Code) + ", " + ;
5448 *!* SQLFormatChar(tceipctc.Cmmnt) + ", " + ;
5449 *!* "'', " + ;
5450 *!* SQLFormatChar(goEnv.cUser) + ;
5451 *!* ", " + SQLFormatTS(DATETIME()) + ", " + ;
5452 *!* SQLFormatNum(v_NextPKey("zzoordcd")) + ", " + ;
5453 *!* SQLFormatNum(Vzzoordrh_860I.PKey) + " )"
5454
5455 *!* llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5456 *!* ENDSCAN
5457
5458 IF .lUpdate860Records
5459 lcSQLString = ;
5460 "UPDATE zzeipcth SET " + ;
5461 " Errs_Msg_H = " + SQLFormatChar(tcEiPCth.Errs_msg_H) + ;
5462 ", Errs_Flg_H = " + SQLFormatChar(tcEiPCth.Errs_flg_h) + ;
5463 ", Last_Mod = " + SQLFormatTS(DATETIME()) + ;
5464 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5465 ", Store = " + SQLFormatChar(tcEiPCth.STORE) + ;
5466 ", Customer = " + SQLFormatChar(tcEiPCth.customer) + ;
5467 ", Ord_Num = " + SQLFormatNum (tcEiPCth.Ord_Num) + ;
5468 ", Season = " + SQLFormatChar(tcEiPCth.Season) + ;
5469 ", Pick_Num = " + SQLFormatNum (tcEiPCth.Pick_Num) + ;
5470 ", Center_Code = " + SQLFormatChar(tcEiPCth.Center_Code) + ;
5471 ", PO_Type = " + SQLFormatChar(tcEiPCth.PO_Type) + ;
5472 ", PO_Date = " + SQLFormatTS (tcEiPCth.PO_Date) + ;
5473 ", PO_Purp = " + SQLFormatChar(tcEiPCth.PO_Purp) + ;
5474 ", Auto_Proc = " + SQLFormatChar(tcEiPCth.Auto_Proc) + ;
5475 ", Resv_Label = " + SQLFormatChar(tcEiPCth.resv_label) + ;
5476 " WHERE PKey = " + SQLFormatNum(lnPKey)
5477 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5478
5479 lnPKey = tcEiPCth.pkey
5480 SELECT tcEiPCtd
5481
5482 SEEK lnPKey
5483 SCAN WHILE fkey = lnPKey
5484 lcSQLString = ;
5485 "UPDATE zzeipctd SET " + ;
5486 " Division = " + SQLFormatChar(tcEiPCtd.division) + ;
5487 ", Errs_Msg_D = " + SQLFormatChar(tcEiPCtd.Errs_Msg_D) + ;
5488 ", Style = " + SQLFormatChar(tcEiPCtd.STYLE) + ;
5489 ", Color_Code = " + SQLFormatChar(tcEiPCtd.color_code) + ;
5490 ", Lbl_Code = " + SQLFormatChar(tcEiPCtd.lbl_code) + ;
5491 ", Dimension = " + SQLFormatChar(tcEiPCtd.DIMENSION) + ;
5492 ", SizeBucket = " + SQLFormatNum (tcEiPCtd.Sizebucket) + ;
5493 ", Errs_Flg_D = " + SQLFormatChar(tcEiPCtd.Errs_Flg_D) + ;
5494 ", Last_Mod = " + SQLFormatTS (DATETIME()) + ;
5495 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5496 IIF(this.lResl_delv,", Delv_code = " + SQLFormatChar(tcEiPCtd.Delv_code),"") + ; && TR 1019356 NH
5497 " WHERE PKey = " + SQLFormatNum (tcEiPCtd.pkey)
5498 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5499 ENDSCAN
5500 ENDIF
5501
5502 IF .lDelete860Records AND NOT .lOneDetailLineBad
5503 * This done via a trigger on zzeipctd (the last detail line to be deleted wipes out the header:
5504 * llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipcth where PKey = " + SQLFormatNum(lnPKey))
5505 * If no records exist on detail, trigger will never fire, thus:
5506 * Trigger not working correctly. Since it's all or nothing anyway, just perform
5507 * delete on both tables:
5508 * IF RECCOUNT("tceipctd") > 0
5509 llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipctd where FKey = " + SQLFormatNum(tcEiPCth.pkey))
5510 * ELSE
5511 llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipcth where PKey = " + SQLFormatNum(tcEiPCth.pkey))
5512 * ENDIF
5513 *--- TR 1016589 NH
5514 *--- send view to server
5515 llRetVal = llRetVal and .TABLEUPDATE('Vnotes_ipch_iPCproc')
5516 llRetVal = llRetVal and .TABLEUPDATE('Vnotes_ipcd_iPCproc')
5517 *=== TR 1016589 NH
5518 ENDIF
5519
5520 IF .lUpdateCancelViews AND NOT .lOneDetailLineBad
5521 llRetVal = llRetVal AND .TABLEUPDATE(@laRatioViews)
5522 *--- TR 1016589 NH
5523 llRetVal = llRetVal and .TABLEUPDATE("Vnotes_zzoordrh_860I")
5524 llRetVal = llRetVal and .TABLEUPDATE("Vnotes_zzoordrd_860I")
5525 *=== TR 1016589 NH
5526
5527 IF llRetVal
5528 .nProcessed = .nProcessed + 1
5529 ENDIF
5530 ENDIF
5531
5532 IF llBeganTransaction
5533 IF llRetVal
5534 .EndTransaction()
5535 ELSE
5536 .RollbackTransaction()
5537 llRetVal = .F.
5538 ENDIF
5539 ENDIF
5540 ENDIF && .lUpdateSalesOrder OR .lUpdate860Records OR (.lDelete860Records AND NOT .lOneDetailLineBad)
5541
5542 IF .lOneDetailLineBad
5543 llRetVal = llRetVal AND .TABLEREVERT("Vzzoordrh_860I")
5544 llRetVal = llRetVal AND .TABLEREVERT("Vzzoordrd_860I")
5545 ENDIF
5546
5547 ELSE
5548 *--- requery failed
5549
5550 *--- TR 1021052 24-Aug-2007 Goutam
5551 IF Not .lNewOrder AND RECCOUNT("Vzzoordrh_860I") > 0
5552 .RecordHeaderError("Flag to create new sales order is set to N.")
5553 ENDIF
5554 *=== TR 1021052 24-Aug-2007 Goutam
5555
5556 *- 1014475 01/16/06 YIK
5557 *- either order not found or it is partially picked.
5558 IF RECCOUNT("Vzzoordrh_860I") = 0
5559 * Corresponding Sales Odor not found:
5560 *- 1015584 02/14/06 YIK
5561 *- .RecordError("Corresponding sales order not found.")
5562
5563 *--- TR 1021052 20-Sep-2007 Goutam
5564 *.RecordHeaderError("Corresponding sales order not found.")
5565 .RecordHeaderError("Corresponding sales order not found/Flag to create new sales order is set to N.")
5566 *=== TR 1021052 20-Sep-2007 Goutam
5567 ELSE
5568 *- more than 1 header - partially picked
5569 *- 1015584 02/14/06 YIK
5570 *- .RecordError("Corresponding sales order is partially picked. Cannot process.")
5571 .RecordHeaderError("Corresponding sales order is partially picked. Cannot process.")
5572 ENDIF
5573
5574 *= 1014475
5575 llBeganTransaction = .BeginTransaction()
5576 lcSQLString = ;
5577 "UPDATE zzeipcth SET " + ;
5578 " Errs_Msg_H = " + SQLFormatChar(tcEiPCth.Errs_msg_H) + ;
5579 ", Errs_Flg_H = " + SQLFormatChar(tcEiPCth.Errs_flg_h) + ;
5580 ", Last_Mod = " + SQLFormatTS(DATETIME()) + ;
5581 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5582 ", Store = " + SQLFormatChar(tcEiPCth.STORE) + ;
5583 ", Customer = " + SQLFormatChar(tcEiPCth.customer) + ;
5584 ", Ord_Num = " + SQLFormatNum (tcEiPCth.Ord_Num) + ;
5585 ", Season = " + SQLFormatChar(tcEiPCth.Season) + ;
5586 ", Pick_Num = " + SQLFormatNum (tcEiPCth.Pick_Num) + ;
5587 ", Center_Code = " + SQLFormatChar(tcEiPCth.Center_Code) + ;
5588 ", PO_Type = " + SQLFormatChar(tcEiPCth.PO_Type) + ;
5589 ", PO_Date = " + SQLFormatTS (tcEiPCth.PO_Date) + ;
5590 ", PO_Purp = " + SQLFormatChar(tcEiPCth.PO_Purp) + ;
5591 ", Auto_Proc = " + SQLFormatChar(tcEiPCth.Auto_Proc) + ;
5592 ", Resv_Label = " + SQLFormatChar(tcEiPCth.resv_label) + ;
5593 " WHERE PKey = " + SQLFormatNum(lnPKey)
5594 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5595
5596 lcSQLString = ;
5597 "UPDATE zzeipctd SET " + ;
5598 " Division = " + SQLFormatChar(tcEiPCtd.division) + ;
5599 ", Errs_Msg_D = " + SQLFormatChar(tcEiPCtd.Errs_Msg_D) + ;
5600 ", Style = " + SQLFormatChar(tcEiPCtd.STYLE) + ;
5601 ", Color_Code = " + SQLFormatChar(tcEiPCtd.color_code) + ;
5602 ", Lbl_Code = " + SQLFormatChar(tcEiPCtd.lbl_code) + ;
5603 ", Dimension = " + SQLFormatChar(tcEiPCtd.DIMENSION) + ;
5604 ", SizeBucket = " + SQLFormatNum (tcEiPCtd.Sizebucket) + ;
5605 ", Errs_Flg_D = " + SQLFormatChar(tcEiPCtd.Errs_Flg_D) + ;
5606 ", Last_Mod = " + SQLFormatTS (DATETIME()) + ;
5607 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5608 " WHERE PKey = " + SQLFormatNum (tcEiPCtd.pkey)
5609 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5610
5611 IF llBeganTransaction
5612 IF llRetVal
5613 .EndTransaction()
5614 ELSE
5615 .RollbackTransaction()
5616 llRetVal = .F.
5617 ENDIF
5618 ENDIF
5619 ENDIF && Requery
5620 *--- TR 1016589 NH
5621 llRetVal = llRetVal AND .TABLEREVERT("Vnotes_zzoordrh_860I")
5622 llRetVal = llRetVal AND .TABLEREVERT("Vnotes_zzoordrd_860I")
5623 *=== TR 1016589 NH
5624
5625 .AdvanceThermo(2*RECNO("tceipcth")/.nToProcess)
5626
5627 IF NOT llRetVal
5628 * Connectivity or other DB probs - exit out of scan.
5629 EXIT
5630 ENDIF
5631
5632 ENDSCAN && 860 Header
5633
5634 .cMessage = ALLTRIM(STR(.nProcessed)) + " 860 inbound record(s) were successfully processed."
5635 IF .nProcessed < .nToProcess
5636 .cMessage = .cMessage + CRLF + ALLTRIM(STR(.nToProcess - .nProcessed)) + " 860 inbound record(s) failed processing."
5637 ENDIF
5638
5639 .oLog.LogEntry(.cMessage)
5640
5641 .AdvanceThermo(2)
5642 .AdvanceThermoTotal(2)
5643 INKEY(0.2)
5644
5645 IF .lScheduled
5646 .cMessage = MSG_DONT_PRINT && Don't print msg on exitM
5647 ENDIF
5648
5649 ENDIF && .lScheduled OR AskBox(lcMsg,,,true)
5650 ENDIF && .nToProcess = 0
5651
5652 .oLog.LogEntry("")
5653 * .oLog.CloseLog()
5654 ENDIF && CreateSOViews()
5655
5656 * Clean up -
5657
5658 * Close cursors:
5659 .AdvanceThermo(5)
5660 .UpdateThermoCaption("Cleaning up...")
5661
5662 .TableClose("tceipcth")
5663 .TableClose("tceipctd")
5664
5665 *!* * Get rid of the progress bar:
5666 *!* IF IsObject(.oFrmProgressBar) AND NOT IsNull(.oFrmProgressBar)
5667 *!* .m_Close()
5668 *!* ENDIF
5669
5670 * Destroy private variables:
5671 RELEASE pcCustomer, pcDivision, pnPO_Num, pcStore
5672
5673 *--- TR 1021052 18-SEP-2007 Goutam
5674 .cSQLTempTable = ""
5675
5676 ENDWITH
5677
5678 * v_SysUnLock(lcSyslockTablePath+"SYSLOCK", "EDI860INBOUND", goEnv.cCompany)
5679 SELECT (lnSelect)
5680 RETURN llRetVal
5681 ENDFUNC
5682
5683 *--- TR 1016589 NH
5684 **************************************************************************************
5685
5686 PROCEDURE AddHdrNotes
5687 LPARAMETERS pcEiPCth, pVzzeipcth_notes_860I, pVnotes_zzoordrh_860I, pVzzoordrh_860I
5688 LOCAL llRetVal, lnOldSelect, lnOrd_num, lcOrd_NTtyp, lnSeq, lcNotes_ipcd_pkeys
5689
5690 llRetVal = .t.
5691 lnOldselect = SELECT()
5692 lcNotes_ipcd_pkeys = ""
5693 *--- scan tran header notes
5694 *--- find same so header notes
5695 *--- add trans header notes to so header default note type
5696 SELECT (pVzzeipcth_notes_860I)
5697 SET ORDER TO "Fkey"
5698 *--- pVzzeipcth_notes_860I has notes for many trans header. first locate the current trans header notes
5699 IF SEEK(EVALUATE(pcEiPCth + ".PKEY"),pVzzeipcth_notes_860I,"fkey")
5700 SCAN WHILE FKEY = EVALUATE(pcEiPCth + ".PKEY")
5701 SCATTER NAME loHdrTransNotes memo
5702 *--- get ([customer + division + po_num + store] or order number) + note_type from tran header
5703 lcOrd_NTtyp = ALLTRIM(STR(EVALUATE(pVzzoordrh_860I + ".Ord_num"))) + loHdrTransNotes.note_type
5704 SELECT(pVnotes_zzoordrh_860I)
5705 *--- find the OrdHdrNotes for same notes type of transaction notes
5706 IF SEEK(lcOrd_NTtyp,pVnotes_zzoordrh_860I,"Ord_NTtyp")
5707
5708 *--- SO header notes exists then append to notes field
5709 replace notes WITH notes + loHdrTransNotes.notes IN (pVnotes_zzoordrh_860I)
5710
5711 ELSE
5712 *--- no SO header notes then create new notes
5713 *--- Trans hdr notes and SO hdr notes are all in samme sysnotes table.
5714 *--- get the max seq number
5715 lnOrd_num = EVALUATE(pVzzoordrh_860I + ".Ord_num")
5716 loHdrTransNotes.pkey = v_nextPkey('sysnotes')
5717 loHdrTransNotes.fkey = EVALUATE(pVzzoordrh_860I + ".PKEY")
5718 loHdrTransNotes.table_name = 'ZZOORDRH'
5719 loHdrTransNotes.Ord_num = lnOrd_num
5720 loHdrTransNotes.Seq = this.GetHdrNotesMaxSeq(lnOrd_num, pVnotes_zzoordrh_860I)
5721 SELECT (pVnotes_zzoordrh_860I)
5722 APPEND BLANK
5723 GATHER NAME loHdrTransNotes memo
5724 *--- update order header notes exists flag
5725 replace hasnotes WITH 'Y' IN (pVzzoordrh_860I)
5726 ENDIF
5727 DELETE IN (pVzzeipcth_notes_860I)
5728 ENDSCAN
5729 ENDIF
5730
5731 SELECT(lnOldSelect)
5732 RETURN llREtVal
5733 ENDPROC
5734
5735 **************************************************************************************
5736
5737 PROCEDURE AddDtlNotes
5738 LPARAMETERS pceIPCth, pcEiPCtd, pVnotes_IPCD_860I, pVnotes_zzoordrd_860I, pVzzoordrd_860I
5739
5740 LOCAL llRetVal, lnOldSelect, loDtlTransNotes, lczzoordrd_KEY
5741 LOCAL loPrevDtlTransNotes
5742 LOCAL lcNotes
5743
5744 llREtVal = .t.
5745 llContinue = .t.
5746 lcNote_type = ""
5747 lnOldSelect = SELECT()
5748 lcNotes = ""
5749
5750 *--- creating sysnotes cursor with group by detail sku
5751 LOCAL loSysnotes, lcSKU, lcSKU_NoteType, lcPrevSKU_NoteType
5752 STORE "" TO lcSKU, lcSKU_NoteType, lcPrevSKU_NoteType
5753 *--- get distinct BC_SKU, Note_type, Notes
5754 lcSQL = "Select d.division, d.style, d.color_code, d.lbl_code, d.dimension, n.note_type, " + ;
5755 " n.COMMENT, cast(n.Notes as varchar(2000)) as NOTES, 'N' as updated" + ;
5756 " from sysnotes n inner join zzeipctd d on d.pkey = n.fkey AND n.Table_name = 'ZZEIPCTD' " + ;
5757 " inner join zzeipcth h on h.pkey = d.fkey where h.customer = '" + pcCustomer + "' " + ;
5758 " and h.division = '" + pcDivision + "' and h.po_num = '" + pnPO_Num + "'" + ;
5759 " and h.store = '" + pcStore + "'" + ;
5760 " group by d.division, d.style, d.color_code, d.lbl_code, d.dimension, n.note_type, n.COMMENT, cast(n.Notes as varchar(2000)) " + ;
5761 " ORDER BY d.division, d.style, d.color_code, d.lbl_code, d.dimension, n.note_type, n.COMMENT, cast(n.Notes as varchar(2000)) "
5762
5763 llRetVal = llRetVal and v_SQLExec(lcSQL, "SKU_SysNotesRO") and USED("SKU_SysNotesRO")
5764 IF llRetVal
5765 *--- get writeable cursor and also aggregate Notes base on SKU and Note_Type
5766 .CreateRWCursorFromROCursor("SKU_SysNotesRO","SKU_SysNotes")
5767 SELECT SKU_SysNotesRO
5768 SCAN
5769 SCATTER NAME loSysnotes memo
5770 lcSKU_NoteType = loSysNotes.division + loSysNotes.style + loSysNotes.color_code + ;
5771 loSysNotes.lbl_code + loSysNotes.dimension + loSysNotes.Note_Type
5772
5773 IF lcPrevSKU_NoteType = lcSKU_NoteType
5774 *--- same notes type of same detail line do not add new record
5775 IF NOT (loSysnotes.Notes $ SKU_SysNotes.Notes)
5776 Replace Notes WITH Notes + ALLTRIM(loSysnotes.Notes) IN SKU_SysNotes
5777 ENDIF
5778 ELSE
5779 *--- add new record
5780 SELECT SKU_SysNotes
5781 APPEND BLANK
5782 GATHER NAME loSysNotes memo
5783 *--- clear lcNotes which has notes data of previous Note_type
5784 ENDIF
5785 lcPrevSKU_NoteType = lcSKU_NoteType
5786 ENDSCAN
5787 Release loSysnotes
5788
5789 *--- Update Order detail Notes with Trans detail Notes
5790 SELECT ("SKU_SysNotes")
5791 SCAN
5792 SCATTER NAME loSysNotes memo
5793 lcSKU = loSysNotes.division + loSysNotes.style + loSysNotes.color_code + ;
5794 loSysNotes.lbl_code + loSysNotes.dimension
5795
5796 IF SEEK(lcSKU, pVzzoordrd_860I,"OUR_SKU")
5797 lcFkeyNoteType = ALLTRIM(STR(EVALUATE(pVzzoordrd_860I + ".PKEY"))) + loSysNotes.Note_type
5798 IF SEEK(lcFkeyNoteType, pVnotes_zzoordrd_860I, "FkeyNT")
5799 *--- already Notes of this Note_type exists for this order detail
5800 *--- just append to the notes
5801 replace Notes WITH ALLTRIM(Notes) + IIF(EMPTY(Notes),"",CRLF) + ALLTRIM(loSysNotes.Notes) IN (pVnotes_zzoordrd_860I)
5802 ELSE
5803 SELECT (pVnotes_zzoordrd_860I)
5804 SCATTER NAME loOrdd_Notes MEMO BLANK
5805 loOrdd_Notes.ord_num = EVALUATE(pVzzoordrd_860I + ".Ord_num")
5806 loOrdd_Notes.FKEY = EVALUATE(pVzzoordrd_860I + ".PKEY")
5807 loOrdd_Notes.LINE_SEQ = EVALUATE(pVzzoordrd_860I + ".LINE_SEQ")
5808 loOrdd_Notes.SEQ = .GetMaxDTLNoteSEQ(pVnotes_zzoordrd_860I, EVALUATE(pVzzoordrd_860I + ".Pkey"))
5809 loOrdd_Notes.TABLE_NAME = "ZZOORDRD"
5810 loOrdd_Notes.Pkey = v_nextPkey('sysnotes')
5811 loOrdd_Notes.Notes = loSysNotes.Notes
5812 loOrdd_Notes.Note_type = loSysNotes.Note_type
5813 loOrdd_Notes.Comment = loSysNotes.Comment
5814 loOrdd_Notes.CascadeNote = 'N'
5815 loOrdd_Notes.User_id = goEnv.cUser
5816 loOrdd_Notes.last_mod = DATETIME()
5817
5818 SELECT (pVnotes_zzoordrd_860I)
5819 APPEND BLANK
5820 GATHER NAME loOrdd_Notes memo
5821 *--- set order detail notes exists flag
5822 REPLACE hasnotes WITH 'Y' IN (pVzzoordrd_860I)
5823 ENDIF
5824 *--- record which has been updated.
5825 replace Updated WITH 'Y' IN SKU_SysNotes
5826 ELSE
5827 ASSERT .f. message "Orphan order detail Notes!!"
5828 ENDIF
5829 ENDSCAN
5830
5831 *--- update transaction detail notes view
5832 *--- fine matching transaction detail records for division, style, color_code, lbl_code, dimension
5833 *--- this trans detail view has been created for a single order
5834 LOCAL loSKU, lcIPCH_Pkey
5835 lcIPCH_Pkey = EVALUATE(pcEiPcth + ".pkey")
5836 SELECT ("SKU_SysNotes")
5837 SCAN FOR Updated = "Y"
5838 lcSKU = division + style + color_code + lbl_code + dimension
5839 *--- go to detail of current header
5840 IF SEEK(lcIPCH_Pkey,pcEiPCtd,"FKEY")
5841 SELECT (pcEiPCtd)
5842 *--- travers through detail to find out matching sku
5843 SCAN WHILE fkey = lcIPCH_Pkey
5844 IF division + style + color_code + lbl_code + dimension = lcSKU
5845 *--- matching detail found for the SKU
5846 *--- now find the notes of this detail
5847 IF SEEK(EVALUATE(pcEiPCtd + ".pkey"),pVnotes_IPCD_860I,"fkey")
5848 *--- notes found now delete this notes from the view
5849 SELECT(pVnotes_IPCD_860I)
5850 SCAN WHILE fkey = EVALUATE(pcEiPCtd + ".pkey")
5851 DELETE IN (pVnotes_IPCD_860I)
5852 ENDSCAN
5853 ENDIF
5854 ENDIF
5855 ENDSCAN
5856 ENDIF
5857 ENDSCAN
5858
5859 IF USED("SKU_SysNotesRO")
5860 USE IN SKU_SysNotesRO
5861 ENDIF
5862 IF USED("SKU_SysNotes")
5863 USE IN SKU_SysNotes
5864 ENDIF
5865 ENDIF
5866
5867 SELECT(lnOldSelect)
5868 return llRetVal
5869 ENDPROC
5870
5871 **************************************************************************************
5872
5873 PROCEDURE GetHdrNotesMaxSeq
5874 LPARAMETERS pnOrd_num, pVnotes_zzoordrh_860I
5875
5876 LOCAL lnSeq, lnOldSelect
5877 lnOldSelect = SELECT()
5878 SELECT (pVnotes_zzoordrh_860I)
5879 lnSeq = 0
5880 SCAN FOR ord_num = pnOrd_num
5881 IF lnSeq < EVALUATE(pVnotes_zzoordrh_860I + ".SEQ")
5882 lnSeq = EVALUATE(pVnotes_zzoordrh_860I + ".SEQ")
5883 ENDIF
5884 ENDSCAN
5885 lnSeq = lnSeq + 1
5886 SELECT(lnOldSelect)
5887 RETURN lnSeq
5888 ENDPROC
5889
5890 **************************************************************************************
5891
5892 PROCEDURE GetMaxDTLNoteSEQ
5893 LPARAMETERS pVnotes_zzoordrd_860I, pnPkey
5894 LOCAL lnSeq, lnOldSelect
5895 lnOldSelect = SELECT()
5896 SELECT (pVnotes_zzoordrd_860I)
5897 lnSeq = 0
5898 SCAN FOR fkey = pnPkey
5899 IF lnSeq < EVALUATE(pVnotes_zzoordrd_860I + ".SEQ")
5900 lnSeq = EVALUATE(pVnotes_zzoordrd_860I + ".SEQ")
5901 ENDIF
5902 ENDSCAN
5903 lnSeq = lnSeq + 1
5904 SELECT(lnOldSelect)
5905 RETURN lnSeq
5906 ENDPROC
5907
5908
5909 **************************************************************************************
5910 *=== TR 1016589 NH
5911
5912 *=================================================
5913 *--- This routine is called inside a scan loop of detail : that for each detail this routine is called once
5914 *--- TR 1017210 NH
5915 FUNCTION ValidateDetail
5916 LPARAMETERS tnMaxOrdrdLine_seq, taDuplicateFields
5917 LOCAL lcQualifier, llRetVal, lcDivision, lnPO_Num, lcStore, lcCustomer, lnSizeBucket, lnQty_Change, ;
5918 llLineExists, llPicked, llInvoiced, llCartonized, llOrdud, lcCncl_Rsn, lcCncl_Type, lnCoeff && 1014475 12/27/05 YIK
5919
5920 *--- TR 1021052 24-Aug-2007 Goutam
5921 LOCAL llNewOrderExists
5922
5923 *--- TR 1028744 19-FEB-2008 VKK Added lcLineFilter
5924 LOCAL lcLineFilter
5925 lcLineFilter = ""
5926 *=== TR 1028744 19-FEB-2008 VKK Added lcLineFilter
5927
5928 llRetVal = .T.
5929 lcCustomer = tcEiPCth.customer
5930 lcDivision = tcEiPCth.division
5931 lnPO_Num = tcEiPCth.PO_Num
5932 lcStore = tcEiPCth.STORE
5933 lcQualifier = tcEiPCtd.Qualifier
5934 lnSizeBucket = tcEiPCtd.Sizebucket
5935 lnQty_Change = tcEiPCtd.Qty_change
5936 llPicked = .F.
5937 llInvoiced = .F.
5938 llCartonized = .F.
5939 llOrdud = .F.
5940 llWasDelete = .F.
5941
5942 *- 1014475 12/28/05 YIK
5943 lnCoeff = 1 && Used to update Ratio_confirm. If we increase qty, then lnCoeff = -1.
5944 THIS.lUpdateRatioCursor = .F.
5945
5946 lcSizeStr = ""
5947 FOR lnCnt = 1 TO THIS.nMaxSizes
5948 lcSizeStr = lcSizeStr + "Size" + PADL(lnCnt, 2, "0") + "_Qty WITH Vzzoordrd_860I.Size" + ;
5949 PADL(lnCnt, 2, "0") + "_Qty, "
5950 ENDFOR
5951 *-- lcReplaceStr = " REPLACE " + ;
5952 *-- " PKey WITH Vzzoordrd_860I.PKey, " + ;
5953 *-- " FKey WITH Vzzoordrd_860I.FKey, " + ;
5954 *-- " Last_Mod WITH DATETIME(), " + ;
5955 *-- " Total_Qty WITH Vzzoordrd_860I.Total_Qty, " + ;
5956 *-- lcSizeStr + ;
5957 *-- " ParKey WITH 0 IN VzzoUnits_Ratio_Confirm"
5958 *- removed ParKey
5959 lcReplaceStr = " REPLACE " + ;
5960 " PKey WITH Vzzoordrd_860I.PKey, " + ;
5961 " FKey WITH Vzzoordrd_860I.FKey, " + ;
5962 " Last_Mod WITH Vzzoordrd_860I.Last_Mod, " + ;
5963 lcSizeStr + ;
5964 " Total_Qty WITH Vzzoordrd_860I.Total_Qty " + ;
5965 " IN VzzoUnits_Ratio_Confirm"
5966
5967 *= 1014475 YIK
5968
5969 *lcMac = "Size" + PADL(ALLTRIM(STR(lnSizeBucket)), 2, "0") + "_Qty"
5970
5971 *--- TR 1028744 19-FEB-2008 VKK
5972 IF EMPTY(This.c860SODetailAddMatchCriteria)
5973 lcLineFilter = "1 = 1"
5974 ELSE
5975 lcLineFilter = This.c860SODetailAddMatchCriteria + " = tcEiPctd.line_id"
5976 ENDIF
5977 *=== TR 1028744 19-FEB-2008 VKK
5978
5979 SELECT Vzzoordrd_860I
5980 *--- TR 1028744 19-FEB-2008 VKK Added &lcLineFilter
5981 LOCATE FOR ;
5982 STYLE = tcEiPCtd.STYLE AND ;
5983 color_code = tcEiPCtd.color_code AND ;
5984 lbl_code = tcEiPCtd.lbl_code AND ;
5985 DIMENSION = tcEiPCtd.DIMENSION AND ;
5986 &lcLineFilter
5987
5988 llLineExists = FOUND("Vzzoordrd_860i")
5989
5990 IF lcQualifier = "AI" AND llLineExists
5991 * We are updating a qty on an existing line.
5992 lcQualifier = "QI"
5993 ENDIF
5994
5995 *--- TR 1021052 20-AUG-2007 HNISAR and Goutam
5996 * We are adding a line to an order that does not exist.
5997 llNewOrderExists = (lcQualifier = "QI" OR lcQualifier = "AI" ) AND NOT llLineExists
5998
5999 IF llNewOrderExists AND .lNewOrder AND NOT .lOrderExist
6000 llRetVal = llRetval AND .CreateNewStoreOrder(@taDuplicateFields)
6001 IF llRetval
6002 lcQualifier = "QI"
6003 ELSE
6004 .RecordHeaderError("Corresponding sales order not found.")
6005 .lOneDetailLineBad = .T.
6006 ENDIF
6007 ENDIF
6008 *=== TR 1021052 20-AUG-2007 HNISAR and Goutam
6009
6010 *--- TR 1019356 NH
6011 *--- Only for "AI" qualifier which is not just add qty
6012 *--- First get header start_date, end_date
6013 IF this.lResl_Delv
6014 llRetVal = llRetVal and this.SetDelvCodeForQualifierAI("tcEiPCth", "tcEiPCtd", "Vzzoordrh_860I")
6015 ENDIF
6016 *=== TR 1019356 NH
6017
6018 *- 1014475 01/17/06 YIK
6019 *- qualifier RZ sends new qty (or price), so we need to know
6020 *- the original qty to calculate qty_change
6021 IF lcQualifier = "RZ" AND llLineExists
6022 lnOrig_Qty = .GetQtyFromSizeBucket(tcEiPCtd.Sizebucket)
6023 lnQty_Change = lnQty_Change - lnOrig_Qty
6024 * Price Change -
6025 * Poc_Cost is Price, Poc_Price is Retail1.
6026 * Whichever is not 0 gets set.
6027 DO CASE
6028 CASE tcEiPCtd.POC_Cost <> 0
6029 IF NOT .lOneDetailLineBad
6030 REPLACE Price WITH tcEiPCtd.POC_Cost IN Vzzoordrd_860I
6031 .lUpdateSalesOrder = .T.
6032 .lDelete860Records = .T.
6033 ENDIF
6034 CASE tcEiPCtd.POC_Price <> 0
6035 IF NOT .lOneDetailLineBad
6036 REPLACE Retail1 WITH tcEiPCtd.POC_Price IN Vzzoordrd_860I
6037 .lUpdateSalesOrder = .T.
6038 .lDelete860Records = .T.
6039 ENDIF
6040 *--- TechRec 1054692 21-Sep-2011 jisingh ---
6041 CASE tcEiPCtd.POC_Retail2 <> 0
6042 IF NOT .lOneDetailLineBad
6043 REPLACE Retail2 WITH tcEiPCtd.POC_Retail2 IN Vzzoordrd_860I
6044 .lUpdateSalesOrder = .T.
6045 .lDelete860Records = .T.
6046 ENDIF
6047 *=== TechRec 1054692 21-Sep-2011 jisingh ===
6048 OTHERWISE
6049 ENDCASE
6050 DO CASE
6051 CASE lnQty_Change >= 0
6052 lcQualifier = "QI"
6053 CASE lnQty_Change < 0
6054 lcQualifier = "QD"
6055 *--- TR 1015747 NH/YIK : When it is QD we need to the Qty change number with out the (-) sign
6056 lnQty_Change = ABS(lnQty_Change)
6057 *=== TR 1015747
6058 ENDCASE
6059 ENDIF
6060
6061 IF llLineExists
6062 LOCAL lcSQLString
6063 IF vl_ctnpd2(Vzzoordrh_860I.Ord_Num, , "tcCartons" , Vzzoordrh_860I.Pick_Num, Vzzoordrh_860I.Inv_Num) AND ;
6064 USED("tcCartons") AND RECCOUNT("tcCartons") > 0
6065 llCartonized = .T.
6066 ENDIF
6067 USE IN SELECT("tcCartons")
6068
6069 lnPKey = vl_ORDUD( Vzzoordrd_860I.Ord_Num, "PKey",, Vzzoordrd_860I.line_seq)
6070 IF TYPE("lnPKey") = "N" AND lnPKey > 0
6071 llOrdud = .T.
6072 ENDIF
6073
6074 lcSQLString = ;
6075 "select 'o' as source, ord_num, line_seq, line_status, pick_num, inv_num " + ;
6076 " from zzoordrd " + ;
6077 " where ord_num = " + SQLFormatNum(Vzzoordrd_860I.Ord_Num) + ;
6078 " and line_seq = " + SQLFormatNum(Vzzoordrd_860I.line_seq) + ;
6079 "union " + ;
6080 "select 's' as source, ord_num, line_seq, line_status, pick_num, inv_num " + ;
6081 " from zzoshprd " + ;
6082 " where ord_num = " + SQLFormatNum(Vzzoordrd_860I.Ord_Num) + ;
6083 " and line_seq = " + SQLFormatNum(Vzzoordrd_860I.line_seq)
6084 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcOrders')
6085 IF USED('tcOrders')
6086 SELECT tcOrders
6087 SCAN
6088 IF tcOrders.SOURCE = "S"
6089 llInvoiced = .T.
6090 ENDIF
6091
6092 IF tcOrders.Line_Status = "P"
6093 llPicked = .T.
6094 ENDIF
6095 ENDSCAN
6096 ENDIF
6097
6098 USE IN SELECT('tcOrders')
6099 ENDIF
6100
6101 WITH THIS
6102 * Any notes?
6103 IF llLineExists AND NOT EMPTY(tcEiPCtd.notes)
6104 * Look at clsmschg.InsertUpdateNote for an example of this.
6105 ENDIF
6106
6107 IF NOT EMPTY(tcEiPCth.notes)
6108 * Look at clsmschg.InsertUpdateNote for an example of this.
6109 ENDIF
6110 DO CASE
6111 CASE lcQualifier = "DI"
6112 * Delete record from zzoordrd
6113 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .T.)
6114
6115 * Validations -
6116 * 1) Line exists.
6117 * 2) Line is not partially / completely picked.
6118 * 3) Line is not partially / completely invoiced.
6119 * 4) Line is not partially / completely cartonized.
6120 * 5) zzoordud link.
6121 DO CASE
6122 CASE NOT llLineExists
6123 .RecordError("Sales Order detail line not found.")
6124 .lOneDetailLineBad = .T.
6125 CASE llPicked
6126 .RecordError("Sales Order detail line is partially or fully picked.")
6127 .lOneDetailLineBad = .T.
6128 CASE llInvoiced
6129 .RecordError("Sales Order detail line is partially or fully invoiced.")
6130 .lOneDetailLineBad = .T.
6131 CASE llCartonized
6132 .RecordError("Sales Order detail line is partially or fully cartonized.")
6133 .lOneDetailLineBad = .T.
6134 CASE llOrdud
6135 .RecordError("Sales Order detail line is hardlinked to a production order.")
6136 .lOneDetailLineBad = .T.
6137 OTHERWISE
6138 IF NOT .lOneDetailLineBad
6139 IF NOT .lCreatedRatioCursor
6140 lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
6141 lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
6142
6143 WITH THIS.oBPOCancel
6144 .CreateRatioCursor()
6145 .cCncl_Rsn = lcCncl_Rsn
6146 .cCncl_Type = lcCncl_Type
6147 ENDWITH
6148
6149 * Fill Ratio Cursor with values from sales order detail. Using all records so that if
6150 * other cancellations happen at detail level, we just find the lines' sizebuckets as
6151 * they come and wipe out their quantity(s). The cancellation class takes care of the
6152 * rest when oBPOCancel.ProcessCancelByOrder() is called.
6153 SELECT Vzzoordrd_860I
6154 .PushRecordSet()
6155 SCAN
6156 SELECT VzzoUnits_Ratio_Confirm
6157 APPEND BLANK
6158 *- 1014475 12/02/05 YIK
6159 *-- REPLACE ;
6160 *-- PKey WITH Vzzoordrd_860I.PKey, ;
6161 *-- FKey WITH Vzzoordrd_860I.FKey, ;
6162 *-- Last_Mod WITH DATETIME(), ;
6163 *-- Total_Qty WITH Vzzoordrd_860I.Total_Qty, ;
6164 *-- Size01_Qty WITH Vzzoordrd_860I.Size01_Qty, ;
6165 *-- Size02_Qty WITH Vzzoordrd_860I.Size02_Qty, ;
6166 *-- Size03_Qty WITH Vzzoordrd_860I.Size03_Qty, ;
6167 *-- Size04_Qty WITH Vzzoordrd_860I.Size04_Qty, ;
6168 *-- Size05_Qty WITH Vzzoordrd_860I.Size05_Qty, ;
6169 *-- Size06_Qty WITH Vzzoordrd_860I.Size06_Qty, ;
6170 *-- Size07_Qty WITH Vzzoordrd_860I.Size07_Qty, ;
6171 *-- Size08_Qty WITH Vzzoordrd_860I.Size08_Qty, ;
6172 *-- Size09_Qty WITH Vzzoordrd_860I.Size09_Qty, ;
6173 *-- Size10_Qty WITH Vzzoordrd_860I.Size10_Qty, ;
6174 *-- Size11_Qty WITH Vzzoordrd_860I.Size11_Qty, ;
6175 *-- Size12_Qty WITH Vzzoordrd_860I.Size12_Qty, ;
6176 *-- Size13_Qty WITH Vzzoordrd_860I.Size13_Qty, ;
6177 *-- Size14_Qty WITH Vzzoordrd_860I.Size14_Qty, ;
6178 *-- Size15_Qty WITH Vzzoordrd_860I.Size15_Qty, ;
6179 *-- Size16_Qty WITH Vzzoordrd_860I.Size16_Qty, ;
6180 *-- Size17_Qty WITH Vzzoordrd_860I.Size17_Qty, ;
6181 *-- Size18_Qty WITH Vzzoordrd_860I.Size18_Qty, ;
6182 *-- Size19_Qty WITH Vzzoordrd_860I.Size19_Qty, ;
6183 *-- Size20_Qty WITH Vzzoordrd_860I.Size20_Qty, ;
6184 *-- Size21_Qty WITH Vzzoordrd_860I.Size21_Qty, ;
6185 *-- Size22_Qty WITH Vzzoordrd_860I.Size22_Qty, ;
6186 *-- Size23_Qty WITH Vzzoordrd_860I.Size23_Qty, ;
6187 *-- Size24_Qty WITH Vzzoordrd_860I.Size24_Qty, ;
6188 *-- ParKey WITH 0 ;
6189 *-- IN VzzoUnits_Ratio_Confirm
6190
6191 &lcReplaceStr
6192 *= 1014475 12/02/05 YIK
6193 ENDSCAN
6194 .PopRecordSet()
6195
6196 .lCreatedRatioCursor = .T.
6197 ENDIF && Haven't populated ratio curso yet
6198
6199 lnQty_Change = .GetQtyFromSizeBucket(tcEiPCtd.Sizebucket)
6200 *- 1014475 12/27/05 YIK
6201 *- shouldn't we move this method AFTER ENDCASE
6202 *- so that the VzzoUnits_Ratio_Confirm is updated after ALL the changes.
6203 *-.UpdateRatioSizeBucket(Vzzoordrd_860I.PKey, tceipctd.SizeBucket, lnQty_Change)
6204 .lDelete860Records = .T.
6205 .lUpdateRatioCursor = .T.
6206
6207 ENDIF && NOT .lOneDetailLineBad
6208
6209 *!* lcQualifier = "QD"
6210 *!* lnQty_Change = .GetQtyFromSizeBucket(tceipctd.SizeBucket)
6211
6212 *!* REPLACE ;
6213 *!* Qty_Change WITH lnQty_Change ;
6214 *!* IN tceipctd
6215
6216 *!* llWasDelete = .T.
6217 ENDCASE
6218
6219 CASE lcQualifier = "CT"
6220 * Date change - Start_Date and/or End_Date will be populated:
6221 IF NOT .lOneDetailLineBad
6222 *--- TR 1015747 NH : data needs to be not empty also
6223 *IF tcEiPCtd.start_date <> {01/01/1900}
6224 IF NOT EMPTY(tcEiPCtd.start_date) AND tcEiPCtd.start_date <> {01/01/1900}
6225 *=== TR 1015747 NH
6226 REPLACE start_date WITH tcEiPCtd.start_date IN Vzzoordrd_860I
6227 IF Vzzoordrd_860I.end_date < tcEiPCtd.start_date
6228 REPLACE end_date WITH tcEiPCtd.start_date IN Vzzoordrd_860I
6229 ENDIF
6230 .lUpdateSalesOrder = .T.
6231 .lDelete860Records = .T.
6232 ENDIF
6233 *--- TR 1015747 NH : data needs to be not empty also
6234 *IF tcEiPCth.end_date <> {01/01/1900}
6235 IF NOT EMPTY(tcEiPCth.end_date) AND tcEiPCth.end_date <> {01/01/1900}
6236 *=== TR 1015474 NH
6237 REPLACE end_date WITH tcEiPCtd.end_date IN Vzzoordrd_860I
6238 .lUpdateSalesOrder = .T.
6239 .lDelete860Records = .T.
6240 ENDIF
6241 ENDIF
6242
6243 CASE lcQualifier = "PC"
6244 * Price Change -
6245 * Poc_Cost is Price, Poc_Price is Retail1.
6246 * Whichever is not 0 gets set.
6247 IF NOT llLineExists
6248 .RecordError("Sales Order detail line not found.")
6249 ELSE
6250 DO CASE
6251 CASE tcEiPCtd.POC_Cost <> 0
6252 IF NOT .lOneDetailLineBad
6253 REPLACE Price WITH tcEiPCtd.POC_Cost IN Vzzoordrd_860I
6254 .lUpdateSalesOrder = .T.
6255 .lDelete860Records = .T.
6256 ENDIF
6257 CASE tcEiPCtd.POC_Price <> 0
6258 IF NOT .lOneDetailLineBad
6259 REPLACE Retail1 WITH tcEiPCtd.POC_Price IN Vzzoordrd_860I
6260 .lUpdateSalesOrder = .T.
6261 .lDelete860Records = .T.
6262 ENDIF
6263 *--- TechRec 1054692 21-Sep-2011 jisingh ---
6264 CASE tcEiPCtd.POC_Retail2 <> 0
6265 IF NOT .lOneDetailLineBad
6266 REPLACE Retail2 WITH tcEiPCtd.POC_Retail2 IN Vzzoordrd_860I
6267 .lUpdateSalesOrder = .T.
6268 .lDelete860Records = .T.
6269 ENDIF
6270 *=== TechRec 1054692 21-Sep-2011 jisingh ===
6271 OTHERWISE
6272 .RecordError("New price not specified.")
6273 ENDCASE
6274 ENDIF
6275
6276 *--- TR 1028744 19-FEB-2008 VKK
6277 CASE lcQualifier = "DB" AND llLineExists
6278 * UDF FIelds
6279 IF NOT .lOneDetailLineBad
6280 REPLACE UDFOORDD1C WITH tcEiPCtd.UDFOORDD1C, ;
6281 UDFOORDD2C WITH tcEiPCtd.UDFOORDD2C IN Vzzoordrd_860I
6282 .lUpdateSalesOrder = .T.
6283 .lDelete860Records = .T.
6284 ENDIF
6285 *=== TR 1028744 19-FEB-2008 VKK
6286
6287 CASE lcQualifier = "AI"
6288 * Add new record to zzoordrd:
6289 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .F.)
6290 * Validations -
6291 * 1) Style/Color/Label/Dimension doesn't already exist.
6292 * NOTE: Per meetings on spec, no validations against style/color/etc.
6293 IF llLineExists
6294 .RecordError("Line already exists on sales order.")
6295 *- 1014475 12/28/05 YIK
6296 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6297 *- and the changes go through
6298 .lOneDetailLineBad = .T.
6299
6300 ELSE
6301 IF NOT .lOneDetailLineBad
6302 *--- TR 1017210 NH
6303 *--- making sure all fields have default value
6304 SELECT Vzzoordrd_860I
6305 SCATTER MEMVAR MEMO BLANK
6306 APPEND BLANK
6307 GATHER MEMVAR memo
6308 *=== TR 1017210 NH
6309
6310 SELECT Vzzoordrh_860I
6311 SCATTER MEMVAR
6312 SELECT Vzzoordrd_860I
6313 *--- TR 1017210 NH
6314*!* APPEND BLANK
6315 *=== TR 1017210 NH
6316 GATHER MEMVAR
6317 *--- TR 1017210 NH
6318 lnPkey_oordrd = v_nextPkey("zzoordrd")
6319 Replace fkey WITH pkey, pkey WITH lnPkey_oordrd IN Vzzoordrd_860I
6320
6321*!* REPLACE ;
6322*!* division WITH tcEiPCth.division, ;
6323*!* Ord_Num WITH tcEiPCth.Ord_Num, ;
6324*!* Pick_Num WITH tcEiPCth.Pick_Num, ;
6325*!* start_date WITH tcEiPCth.start_date, ;
6326*!* end_date WITH tcEiPCth.end_date, ;
6327*!* Cncl_Date WITH tcEiPCth.Cncl_Date, ;
6328*!* line_seq WITH tcEiPCtd.line_seq, ;
6329*!* STYLE WITH tcEiPCtd.STYLE, ;
6330*!* color_code WITH tcEiPCtd.color_code, ;
6331*!* lbl_code WITH tcEiPCtd.lbl_code, ;
6332*!* DIMENSION WITH tcEiPCtd.DIMENSION, ;
6333*!* Org_Price WITH tcEiPCtd.Org_Price, ;
6334*!* Total_Qty WITH 0 ;
6335*!* IN Vzzoordrd_860I
6336 .DefaultHeaderDataToDetail("Vzzoordrh_860I","Vzzoordrd_860I", @taDuplicateFields )
6337 tnMaxOrdrdLine_seq = tnMaxOrdrdLine_seq + 1
6338 Replace ;
6339 Cncl_Date WITH tcEiPCth.Cncl_Date, ;
6340 STYLE WITH tcEiPCtd.STYLE, ;
6341 color_code WITH tcEiPCtd.color_code, ;
6342 lbl_code WITH tcEiPCtd.lbl_code, ;
6343 DIMENSION WITH tcEiPCtd.DIMENSION, ;
6344 Org_Price WITH tcEiPCtd.Org_Price, ;
6345 line_seq WITH tnMaxOrdrdLine_seq, ;
6346 LINE_STATUS WITH Vzzoordrh_860I.Ord_status, ;
6347 Price WITH tcEiPCtd.poc_cost, ; && TR 1016560 NH :For AI item price needs to be populated by poc_price
6348 retail1 WITH tcEiPCtd.poc_price, ;
6349 retail2 WITH tcEiPCtd.poc_retail2, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
6350 Total_Qty WITH 0 ;
6351 IN Vzzoordrd_860I
6352
6353 *--- TR 1019356 NH
6354 IF this.lResl_Delv
6355 replace delv_code with IIF(TYPE("tcEiPCtd.delv_code") == "C", tcEiPCtd.delv_code,delv_code) ; && TR 1019356 NH
6356 IN Vzzoordrd_860I
6357 ENDIF
6358 *=== TR 1019356 NH
6359
6360 .UpdateSizeBucket(lnSizeBucket, lnQty_Change, "QI")
6361 .lUpdateSalesOrder = .T.
6362 .lDelete860Records = .T.
6363 *- 1014475 12/27/05 YIK
6364 *- This action increases qty of the UPC being updated.
6365 lnCoeff = -1
6366 .lUpdateRatioCursor = .T.
6367
6368 ENDIF
6369 ENDIF
6370
6371 CASE lcQualifier = "QI" OR lcQualifier = "QD"
6372 * Increase the quantity by the amount in tceipctd.Qty_Change:
6373 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .T.)
6374 * Validations:
6375 * Line exists.
6376 * If decreasing
6377 * Total_Qty > Qty_Change
6378 * Min/Mult???
6379 DO CASE
6380 *--- TR 1021052 21-AUG-2007 HNISAR & Goutam
6381 *CASE NOT llLineExists
6382 CASE NOT llLineExists AND NOT .lNewOrder AND .lOrderExist
6383 *=== TR 1021052 21-AUG-2007 HNISAR & Goutam
6384
6385 .RecordError("Sales Order detail line not found.")
6386 *- 1014475 12/28/05 YIK
6387 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6388 *- and the changes go through
6389 .lOneDetailLineBad = .T.
6390 CASE lcQualifier = "QD" AND NOT .ValidateDecrease(lnSizeBucket, lnQty_Change, lcQualifier)
6391 .RecordError("Quantity to decrease is more than found on sales order detail line.")
6392 *- 1014475 12/28/05 YIK
6393 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6394 *- and the changes go through
6395 .lOneDetailLineBad = .T.
6396
6397 OTHERWISE
6398 IF NOT .lOneDetailLineBad
6399 IF lcQualifier = "QI"
6400 THIS.UpdateSizeBucket(lnSizeBucket, lnQty_Change, lcQualifier)
6401 .lUpdateSalesOrder = .T.
6402 .lDelete860Records = .T.
6403 *- 1014475 12/27/05 YIK
6404 *- This action increases qty of the UPC being updated.
6405 lnCoeff = -1
6406 .lUpdateRatioCursor = .T.
6407
6408 ELSE
6409 * Quantity Decrease - handle through cancellation class:
6410 IF NOT .lCreatedRatioCursor
6411 lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
6412 lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
6413
6414 WITH THIS.oBPOCancel
6415 .CreateRatioCursor()
6416 .cCncl_Rsn = lcCncl_Rsn
6417 .cCncl_Type = lcCncl_Type
6418 ENDWITH
6419
6420 * Fill Ratio Cursor with values from sales order detail. Using all records so that if
6421 * other cancellations happen at detail level, we just find the lines' sizebuckets as
6422 * they come and wipe out their quantity(s). The cancellation class takes care of the
6423 * rest when oBPOCancel.ProcessCancelByOrder() is called.
6424 SELECT Vzzoordrd_860I
6425 .PushRecordSet()
6426 SCAN
6427 SELECT VzzoUnits_Ratio_Confirm
6428 APPEND BLANK
6429 *-- REPLACE ;
6430 *-- PKey WITH Vzzoordrd_860I.PKey, ;
6431 *-- FKey WITH Vzzoordrd_860I.FKey, ;
6432 *-- Last_Mod WITH DATETIME(), ;
6433 *-- Total_Qty WITH Vzzoordrd_860I.Total_Qty, ;
6434 *-- Size01_Qty WITH Vzzoordrd_860I.Size01_Qty, ;
6435 *-- Size02_Qty WITH Vzzoordrd_860I.Size02_Qty, ;
6436 *-- Size03_Qty WITH Vzzoordrd_860I.Size03_Qty, ;
6437 *-- Size04_Qty WITH Vzzoordrd_860I.Size04_Qty, ;
6438 *-- Size05_Qty WITH Vzzoordrd_860I.Size05_Qty, ;
6439 *-- Size06_Qty WITH Vzzoordrd_860I.Size06_Qty, ;
6440 *-- Size07_Qty WITH Vzzoordrd_860I.Size07_Qty, ;
6441 *-- Size08_Qty WITH Vzzoordrd_860I.Size08_Qty, ;
6442 *-- Size09_Qty WITH Vzzoordrd_860I.Size09_Qty, ;
6443 *-- Size10_Qty WITH Vzzoordrd_860I.Size10_Qty, ;
6444 *-- Size11_Qty WITH Vzzoordrd_860I.Size11_Qty, ;
6445 *-- Size12_Qty WITH Vzzoordrd_860I.Size12_Qty, ;
6446 *-- Size13_Qty WITH Vzzoordrd_860I.Size13_Qty, ;
6447 *-- Size14_Qty WITH Vzzoordrd_860I.Size14_Qty, ;
6448 *-- Size15_Qty WITH Vzzoordrd_860I.Size15_Qty, ;
6449 *-- Size16_Qty WITH Vzzoordrd_860I.Size16_Qty, ;
6450 *-- Size17_Qty WITH Vzzoordrd_860I.Size17_Qty, ;
6451 *-- Size18_Qty WITH Vzzoordrd_860I.Size18_Qty, ;
6452 *-- Size19_Qty WITH Vzzoordrd_860I.Size19_Qty, ;
6453 *-- Size20_Qty WITH Vzzoordrd_860I.Size20_Qty, ;
6454 *-- Size21_Qty WITH Vzzoordrd_860I.Size21_Qty, ;
6455 *-- Size22_Qty WITH Vzzoordrd_860I.Size22_Qty, ;
6456 *-- Size23_Qty WITH Vzzoordrd_860I.Size23_Qty, ;
6457 *-- Size24_Qty WITH Vzzoordrd_860I.Size24_Qty, ;
6458 *-- ParKey WITH 0 ;
6459 *-- IN VzzoUnits_Ratio_Confirm
6460
6461 &lcReplaceStr
6462 *= 1014475 12/02/05 YIK
6463
6464 ENDSCAN
6465 .PopRecordSet()
6466
6467 .lCreatedRatioCursor = .T.
6468 ENDIF && Haven't populated ratio curso yet
6469 *- 1014475 12/27/05 YIK
6470 *- Move this method after ENDCASE
6471 *- so that the VzzoUnits_Ratio_Confirm is updated after ALL the changes.
6472 *-.UpdateRatioSizeBucket(Vzzoordrd_860I.PKey, lnSizeBucket, lnQty_Change)
6473 .lDelete860Records = .T.
6474 .lUpdateRatioCursor = .T.
6475 *= 1014475
6476
6477 ENDIF
6478 ENDIF
6479 ENDCASE
6480 ENDCASE
6481 *- 1014475 12/27/05 YIK
6482 IF .lCreatedRatioCursor AND !.lOneDetailLineBad AND .lUpdateRatioCursor
6483 .UpdateRatioSizeBucket(Vzzoordrd_860I.pkey, lnSizeBucket, lnQty_Change, lnCoeff)
6484 ENDIF
6485 *=
6486 ENDWITH
6487
6488 RETURN llRetVal
6489 ENDFUNC
6490
6491 * ===============================================
6492
6493 *---- TR 1019356 NH
6494 *--- select only the AI records
6495 *---
6496 PROCEDURE SetDelvCodeForQualifierAI
6497 LPARAMETERS pcEiPCth, pcEiPCtd, pVzzoordrh_860I
6498
6499 LOCAL llRetVal, lnOldSelect, lcOldOrder
6500 lnOldSelect = SELECT()
6501 llRetVal = .t.
6502 SELECT(pcEiPCtd)
6503 IF qualifier = "AI"
6504
6505 *--- set tran header start and end data from Sales Order start date and end date
6506 *--- if tran header start and end data is empty
6507 this.SetStartEndDate(pcEiPCth,pVzzoordrh_860I)
6508 *--- Set season from Sales order when season is empty
6509 this.SetSeason(pcEiPCth,pVzzoordrh_860I)
6510 *--- cascase start and end data from header to detail trans
6511 this.SetStartEndDateFromHdrToDtl(pcEiPCth, pcEiPCtd)
6512 *--- resolve Delivery Code
6513 IF NOT this.oBPOSalesOrder.ResolveDelvCode2(pcEiPCth, pcEiPCtd)
6514 THIS.LogEntry("Delivery Code not resolved for PO# " + ;
6515 EVALUATE(pcEiPCth + ".Po_num") + ", customer " + EVALUATE(pcEiPCth + ".customer"))
6516 ENDIF
6517 ENDIF
6518 SELECT(lnOldSelect)
6519 RETURN llRetVal
6520 ENDPROC
6521
6522
6523 **************************************************************************************
6524
6525 PROCEDURE SetStartEndDateFromHdrToDtl
6526 LPARAMETERS pcEiPCth, pcEiPCtd
6527
6528 LOCAL llRetVal, lnOldSelect
6529 llRetVal = .t.
6530 lnOldSelect = SELECT()
6531
6532 IF EMPTY(EVALUATE(pcEiPCtd + ".start_date")) OR EVALUATE(pcEiPCtd + ".start_date") = {01/01/1900}
6533 REPLACE start_date WITH EVALUATE(pcEiPCth + ".start_date") IN (pcEiPCtd)
6534 ENDIF
6535
6536 IF EMPTY(EVALUATE(pcEiPCtd + ".end_date")) OR EVALUATE(pcEiPCtd + ".end_date") = {01/01/1900}
6537 REPLACE end_date WITH EVALUATE(pcEiPCth + ".end_date") IN (pcEiPCtd)
6538 ENDIF
6539
6540 RETURN llRetVal
6541
6542 ENDPROC
6543
6544 **************************************************************************************
6545
6546 PROCEDURE SetStartEndDateFromHdrToDtl
6547 LPARAMETERS pcEiPCth, pcEiPCtd
6548
6549 LOCAL llRetVal, lnOldSelect
6550 llRetVal = .t.
6551 lnOldSelect = SELECT()
6552
6553 IF EMPTY(EVALUATE(pcEiPCtd + ".start_date")) OR EVALUATE(pcEiPCtd + ".start_date") = {01/01/1900}
6554 REPLACE start_date WITH EVALUATE(pcEiPCth + ".start_date") IN (pcEiPCtd)
6555 ENDIF
6556
6557 IF EMPTY(EVALUATE(pcEiPCtd + ".end_date")) OR EVALUATE(pcEiPCtd + ".end_date") = {01/01/1900}
6558 REPLACE end_date WITH EVALUATE(pcEiPCth + ".end_date") IN (pcEiPCtd)
6559 ENDIF
6560
6561 RETURN llRetVal
6562
6563 ENDPROC
6564
6565 **************************************************************************************
6566
6567 PROCEDURE SetSeason
6568 LPARAMETERS pcEiPCth, pVzzoordrh_860I
6569
6570 LOCAL lnOldSelect, llRetVal
6571 llRetVal = .t.
6572 lnOldSelect = SELECT()
6573 SELECT(pcEiPCth)
6574 IF EMPTY(EVALUATE(pcEiPCth + ".season"))
6575 replace season WITH EVALUATE(pVzzoordrh_860I + ".season") in (pcEiPCth)
6576 ENDIF
6577 SELECT(lnOldSelect)
6578 RETURN llRetVal
6579 ENDPROC
6580
6581 **************************************************************************************
6582
6583 PROCEDURE SetStartEndDate
6584 LPARAMETERS pcEiPCth,pVzzoordrh_860I
6585 LOCAL llRetval, lnOldSelect
6586 lnOldSelect = SELECT()
6587 llRetval = .t.
6588 IF EMPTY(EVALUATE(pcEiPCth + ".Start_date"))
6589 replace start_date with EVALUATE(pVzzoordrh_860I + ".Start_date") in (pcEiPCth)
6590 ENDIF
6591
6592 IF EMPTY(EVALUATE(pcEiPCth + ".end_date"))
6593 replace end_date with EVALUATE(pVzzoordrh_860I + ".end_date") in (pcEiPCth)
6594 ENDIF
6595
6596 RETURN llRetVal
6597 ENDPROC
6598
6599 **************************************************************************************
6600 *=== TR 1019356 NH