· 7 years ago · Oct 10, 2018, 03:00 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 INDEX ON STR(doc_num)+PO1_Line TAG PO1_Line
892 * === TR 1047609 7/7/10 CM
893
894 SET ORDER TO TAG doc_num
895
896 SELECT VzzeiPCtc_iPCproc
897 INDEX ON pkey TAG pkey
898 INDEX ON fkey TAG fkey
899 INDEX ON doc_num TAG doc_num
900
901
902 *--- TR 1016589 NH
903 SELECT Vnotes_IPCH_iPCproc
904 INDEX ON pkey TAG pkey
905 INDEX ON fkey TAG fkey
906
907
908 SELECT Vnotes_IPCD_iPCproc
909 INDEX ON pkey TAG pkey
910 INDEX ON fkey TAG fkey
911 INDEX ON STR(fkey) + Note_type TAg fkeyNtTpy
912
913 *=== TR 1016589 NH
914
915 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
916 Select VzzeiPCta_iPCproc
917 Index On pkey Tag pkey
918 Index On fkey Tag fkey
919 Index On doc_num Tag doc_num
920
921 .SetBufferMode("VzzeiPCta_iPCproc", DB_BufOptTable)
922
923 .SetBufferMode("VzzeiPCtWhse_iPCproc", DB_BUFOPTRECORD)
924 Select VzzeiPCtWhse_iPCproc
925 Index On pkey Tag pkey
926 Index On hfkey Tag hfkey
927 Index On dfkey Tag dfkey
928 Index On sfkey Tag sfkey
929 Index On doc_num Tag doc_num
930 Index On Str(doc_num) + edi_line Tag Whse_Line && PO1_Line
931 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
932 Index On Alltrim(Str(hfkey)) + Alltrim(Str(dfkey)) Tag h_dfkey
933 .SetBufferMode("VzzeiPCtWhse_iPCproc", DB_BufOptTable)
934 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
935
936 * set table buffer to 5
937 .SetBufferMode("VzzeiPCth_iPCproc", DB_BUFOPTTABLE)
938 .SetBufferMode("VzzeiPCtd_iPCproc", DB_BUFOPTTABLE)
939 .SetBufferMode("VzzeiPCtc_iPCproc", DB_BUFOPTTABLE)
940 *--- TR 1016589 NH
941 .SetBufferMode("Vnotes_IPCH_iPCproc", DB_BUFOPTTABLE)
942 .SetBufferMode("Vnotes_IPCD_iPCproc", DB_BUFOPTTABLE)
943 *=== TR 1016589 NH
944
945 * --- TR 1047609 7/7/10 CM
946 .SetBufferMode("VzzeiPCts_iPCproc", DB_BUFOPTRECORD)
947 Select VzzeiPCts_iPCproc
948 Index On doc_num Tag doc_num
949 Index On Str(doc_num)+SLN_Line Tag SLN_Line && PO1_Line
950 INDEX on pkey Tag pkey
951 Index On fkey Tag fkey
952 .SetBufferMode("VzzeiPCts_iPCproc", DB_BufOptTable)
953 * === TR 1047609 7/7/10 CM
954
955 ENDIF
956
957 * Query for all control locally (--need to join with
958 * local cursor lots to get flags/parameters for the process)
959 .oLog.LogEntry("Retrieving 860(i) Control References.")
960 lcSQLString = "SELECT * FROM zzeipcCR"
961 *--- TR 1019356 NH
962 *llRetVal = v_SqlPrep(lcSQLString, "zzeipccr")
963 llRetVal = llRetVal and v_SqlExec(lcSQLString, "zzeipccr")
964 *=== TR 1019356 NH
965 IF llRetVal
966 SELECT zzeipccr
967
968 *--- TR 1048865 24-Dec-2010 Goutam
969 INDEX on pkey TAG pkey
970 *=== TR 1048865 24-Dec-2010 Goutam
971
972 INDEX ON customer TAG customer
973 INDEX ON division TAG division
974 INDEX ON division+customer TAG divcust
975 ENDIF
976
977 .oLog.LogEntry("Retrieving Customer Label References.")
978 lcSQLString = "SELECT * FROM zzxclblr"
979 *--- TR 1019356 NH
980 *llHaveRec = v_SqlPrep(lcSQLString, "zzxclblr")
981 *IF llHaveRec
982 llRetVal = llRetVal and v_SqlExec(lcSQLString, "zzxclblr")
983 IF llRetVal
984 llHaveRec = RECCOUNT("zzxclblr")
985 *=== TR 1019356 NH
986 SELECT zzxclblr
987 INDEX ON customer TAG customer
988 INDEX ON lbl_code TAG lbl_code
989 ENDIF
990
991 *--- TR 1015747 02/24/06 NH
992 * create transaction R/W cursor from views
993 IF llRetVal &&continue it successfully table update Inter. and Trans. views
994
995 .oLog.LogEntry("Creating transaction header cursors from views.")
996 .AdvanceThermoTotalWithCaptionPlus("Creating temporary transaction cursors...", ;
997 vcLogName)
998
999 *--- TR 1062197 13-Sep-2012 Goutam. Added consol_code
1000 *--- TR 1085815 27-Mar-2015 BNarayanan added SPACE(3) as ord_type, ---
1001 SELECT SPACE(3) as ord_type, SPACE(5) as consol_code, * FROM VzzeiPCth_iPCproc INTO CURSOR __EiPCth
1002 THIS.MakeCursorWritable("__EiPCth", "tcEiPCth")
1003 SELECT tcEiPCth
1004 .niPCOrderHeader= THIS.CountTotalRecs ("tcEiPCth")
1005 INDEX ON impl_ok TAG ImplOK FOR impl_ok = '' && TR 1041492 JUL-20-2009 BR
1006 INDEX ON customer+po_num TAG custpo && TR 1023071
1007 INDEX ON pkey TAG pkey
1008
1009 .oLog.LogEntry("Creating transaction detail cursors from views.")
1010 * --- TR 1047609 7/7/10 CM --- Added Style_SLN_OK
1011 SELECT SPACE(7) AS customer, " " AS Style_SLN_OK, * FROM VzzeiPCtd_iPCproc INTO CURSOR __eipcTD
1012
1013 THIS.MakeCursorWritable("__eiPCtd", "tcEiPCtd")
1014 .TableClose('__eipCTD')
1015
1016 SELECT tcEiPCtd
1017 .niPCOrderDetail= THIS.CountTotalRecs ("tcEiPCtd")
1018 INDEX ON pkey TAG pkey
1019 INDEX ON fkey TAG fkey
1020 INDEX ON qualifier TAG qualifier && TR 1019356 NH
1021 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1022
1023 *--- TechRec 1073591 31-Oct-2013 TShenbagavalli ---
1024 Index On Str(doc_num)+PO1_Line Tag PO1_Line
1025 *=== TechRec 1073591 31-Oct-2013 TShenbagavalli ===
1026
1027
1028 SELECT * FROM VzzeiPCtc_iPCproc INTO CURSOR __EiPCtc
1029 THIS.MakeCursorWritable("__EiPCtc", "tcEiPCtc")
1030 SELECT tcEiPCtc
1031 INDEX ON fkey TAG fkey
1032 .lHaveComment= (THIS.CountTotalRecs ("tcEiPCtc")> 0)
1033
1034 * --- TR 1047609 7/7/10 CM
1035 Select *, ' ' As customer From VzzeiPCts_iPCproc Into Cursor __EiPCts
1036 This.MakeCursorWritable("__EiPCts", "tcEiPCts")
1037 Select tcEiPCts
1038 Index On pkey Tag pkey
1039 Index On fkey Tag fkey
1040 Index On customer+division+Style+color_code+lbl_code+Dimension+Str(sizebucket) Tag CstBcSku
1041 .lHaveSLN = Reccount('tcEiPCts') > 0
1042 * === TR 1047609 7/7/10 CM
1043
1044 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1045 Select * From VzzeiPCta_iPCproc Into Cursor __EiPCta
1046 This.MakeCursorWritable("__EiPCta", "tcEiPCta")
1047 Select tcEiPCta
1048 .lHaveAddress= (This.CountTotalRecs ("tcEiPCta")> 0)
1049 Select Count(*) ;
1050 FROM tcEiPCta ;
1051 WHERE addr_type = 'OT' ; &&One Time
1052 Into Array laCnt
1053
1054 .lHaveOneTimeShippingAddress= (laCnt[1] > 0)
1055
1056 SELECT * FROM VzzeiPCtwhse_iPCproc INTO CURSOR __EiPCtwhse
1057 THIS.MakeCursorWritable("__EiPCtwhse", "tcEiPCtwhse")
1058 SELECT tcEiPCtwhse
1059 Index On hfkey Tag hfkey
1060 Index On dfkey Tag dfkey
1061 Index On sfkey Tag sfkey
1062 Index On doc_num Tag doc_num
1063 Index On Str(doc_num) + edi_line Tag Whse_Line && PO1_Line
1064 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
1065 Index On Alltrim(Str(hfkey)) + Alltrim(Str(dfkey)) Tag h_dfkey
1066 .lHaveWhse = (THIS.CountTotalRecs ("tcEiPCtwhse")> 0)
1067 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1068
1069 ENDIF
1070 *=== TR 1015747 02/24/06 NH
1071
1072 THIS.ResetThermoPlus()
1073 ENDWITH
1074 SELECT(lnOldSelect)
1075 RETURN llRetVal
1076 ENDPROC
1077
1078 *- If we decide to create Interface views - it has to be done here.
1079 PROCEDURE CreateiPCViews
1080 LOCAL llRetVal, lcSQLSelect, lcSQLOrder
1081 llRetVal = .T.
1082 lnOldSelect = SELECT()
1083
1084 LOCAL l_nThermoCnt
1085 l_nThermoCnt = 0
1086 *--- TR 1015747 02/24/06 NH
1087 WITH THIS
1088*!* .oLog.LogEntry("Creating views.")
1089*!* THIS.InitThermoWithCaption(@l_nThermoCnt, 5, "Creating and open transaction, history views...")
1090
1091 .oLog.LogEntry("Creating IPC views.")
1092 *--- added thermo counter
1093 THIS.InitThermoWithCaption(@l_nThermoCnt, 7, "Creating and open transaction views...")
1094
1095 * create EDIiPC work table views
1096 lcSQLOrder = " customer, isa_num, po_num, store "
1097 lcSQLSelect = "select h.* from zzeiPCth h WHERE 1 = 0"
1098 THIS.CreateSQLView("VzzeiPCth_iPCproc", lcSQLSelect,, lcSQLOrder)
1099 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1100
1101 lcSQLOrder = " sku, upc, ean "
1102 lcSQLSelect = "select * from zzeiPCtd where 1 = 0"
1103 THIS.CreateSQLView("VzzeiPCtd_iPCproc", lcSQLSelect,, lcSQLOrder)
1104 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1105
1106 lcSQLOrder = "" && TR 1016560 NH
1107 lcSQLSelect = "select * from zzeiPCtc where 1 = 0"
1108 THIS.CreateSQLView("VzzeiPCtc_iPCproc", lcSQLSelect,, lcSQLOrder)
1109 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1110
1111 *--- TR 1016589 05/08/06 NH
1112 lcSQLSelect = "select * from sysnotes where 1 = 0 "
1113 THIS.CreateSQLView("Vnotes_ipch_iPCproc", lcSQLSelect)
1114 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1115
1116 lcSQLSelect = "select * from sysnotes where 1 = 0 "
1117 THIS.CreateSQLView("Vnotes_ipcd_iPCproc", lcSQLSelect)
1118 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1119 *=== TR 1016589 05/08/06 NH
1120
1121 * --- TR 1047609 7/7/10 CM
1122 lcSQLSelect = "select * from zzeipcts where 1 = 0 "
1123 THIS.CreateSQLView("Vzzeipcts_iPCproc", lcSQLSelect,,"NoOrderBy")
1124 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1125 * === TR 1047609 7/7/10 CM
1126
1127 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1128 lcSQLSelect = "select * from zzeipcta where 1 = 0 "
1129 THIS.CreateSQLView("VzzeiPCta_iPCproc", lcSQLSelect,,"NoOrderBy")
1130 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1131
1132 lcSQLSelect = "select * from zzeipctwhse where 1 = 0 "
1133 THIS.CreateSQLView("Vzzeipctwhse_iPCproc", lcSQLSelect,,"NoOrderBy")
1134 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1135 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1136
1137 .oLog.LogEntry("Opening transaction views.")
1138 lnCursorBuffer = DB_BUFOPTRECORD
1139
1140 *--- TR 1016589 nh : added notes cursor in opentable condition
1141 IF !(THIS.OPENTABLE("VzzeiPCth_iPCproc",, .T.,,lnCursorBuffer) AND ;
1142 THIS.OPENTABLE("VzzeiPCtd_iPCproc",, .T.,,lnCursorBuffer) AND ;
1143 THIS.OPENTABLE("VzzeiPCtc_iPCproc",, .T.,,lnCursorBuffer) AND ;
1144 THIS.OPENTABLE("Vnotes_ipch_iPCproc",, .T.,,lnCursorBuffer) AND ;
1145 THIS.OPENTABLE("Vnotes_ipcd_iPCproc",, .T.,,lnCursorBuffer) AND ;
1146 THIS.OPENTABLE("VzzeiPCts_iPCproc",, .T.,,lnCursorBuffer) AND ; && TR 1047609 7/7/10 CM
1147 THIS.OPENTABLE("VzzeiPCta_iPCproc",, .T.,,lnCursorBuffer) AND ; &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1148 THIS.OPENTABLE("VzzeiPCtwhse_iPCproc",, .T.,,lnCursorBuffer)) &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1149
1150 llRetVal = .F.
1151 ELSE
1152 .oLog.LogEntry("Indexing transaction views.")
1153 THIS.AdvanceThermoPlus(@l_nThermoCnt)
1154 * create index for optimizing
1155 SELECT VzzeiPCth_iPCproc
1156 INDEX ON pkey TAG pkey
1157 INDEX ON doc_num TAG doc_num
1158 INDEX ON Errs_flg_h TAG ErrsFlgH
1159 *--- TR 1036066 NH
1160 INDEX ON edi_store TAG edi_store
1161 *=== TR 1036066 NH
1162
1163 SELECT VzzeiPCtd_iPCproc
1164 INDEX ON ALLTRIM(STR(doc_num))+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) TAG Ckey
1165 INDEX ON pkey TAG pkey
1166 INDEX ON fkey TAG fkey
1167 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1168 * --- TR 1047609 7/7/10 CM
1169 INDEX ON STR(doc_num)+PO1_Line TAG PO1_Line
1170 * === TR 1047609 7/7/10 CM
1171 INDEX ON doc_num TAG doc_num
1172
1173 INDEX on STR(fkey)+upc+sku+line_id DESCENDING TAG dupdele &&--- TechRec 1073148 06-Aug-2014 asharma ===
1174
1175 SET ORDER TO TAG doc_num
1176
1177 SELECT VzzeiPCtc_iPCproc
1178 INDEX ON pkey TAG pkey
1179 INDEX ON fkey TAG fkey
1180 INDEX ON doc_num TAG doc_num
1181
1182 *--- TR 1016589 NH
1183 SELECT Vnotes_IPCH_iPCproc
1184 INDEX ON pkey TAG pkey
1185 INDEX ON fkey TAG fkey
1186
1187 SELECT Vnotes_IPCD_iPCproc
1188 INDEX ON pkey TAG pkey
1189 INDEX ON fkey TAG fkey
1190 *=== TR 1016589 NH
1191
1192 * --- TR 1047609 7/7/10 CM
1193 SELECT VzzeiPCts_iPCproc
1194 Index On doc_num Tag doc_num
1195 Index On Str(doc_num)+SLN_Line Tag SLN_Line && PO1_Line
1196 Index On fkey Tag fkey
1197 * === TR 1047609 7/7/10 CM
1198
1199 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
1200 Select VzzeiPCta_iPCproc
1201 Index On pkey Tag pkey
1202 Index On fkey Tag fkey
1203 Index On doc_num Tag doc_num
1204 .SetBufferMode("VzzeiPCta_iPCproc", DB_BufOptTable)
1205
1206 SELECT VzzeiPCtwhse_iPCproc
1207 Index On pkey Tag pkey
1208 Index On hfkey Tag hfkey
1209 Index On dfkey Tag dfkey
1210 Index On doc_num Tag doc_num
1211 Index On Str(Doc_Num)+SLN_Line Tag SLN_Line
1212 .SetBufferMode("VzzeiPCtwhse_iPCproc", DB_BUFOPTTABLE)
1213 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
1214
1215 * set table buffer to 5
1216 .SetBufferMode("VzzeiPCth_iPCproc", DB_BUFOPTTABLE)
1217 .SetBufferMode("VzzeiPCtd_iPCproc", DB_BUFOPTTABLE)
1218 .SetBufferMode("VzzeiPCtc_iPCproc", DB_BUFOPTTABLE)
1219 .SetBufferMode("Vnotes_IPCH_iPCproc", DB_BUFOPTTABLE)
1220 .SetBufferMode("Vnotes_IPCD_iPCproc", DB_BUFOPTTABLE)
1221 * --- TR 1047609 7/7/10 CM --- Setting table buffering at this point
1222 .SetBufferMode("VzzeiPCts_iPCproc", DB_BUFOPTTABLE)
1223 * === TR 1047609 7/7/10 CM
1224
1225
1226 ENDIF
1227 ENDWITH
1228 *=== TR 1015747 02/24/06 NH
1229 THIS.ResetThermoPlus()
1230 SELECT(lnOldSelect)
1231 RETURN llRetVal
1232 ENDPROC
1233
1234 PROCEDURE LoadFromFlatfileToTransaction
1235 LOCAL llRetVal
1236 llRetVal = .T.
1237 * --- TR 1047609 7/7/10 CM --- Added lciPCSLNFlatFile
1238 LOCAL lnCurrentHeaderPkey, lnCurrentHeaderDoc_num, lnPriorHeaderPkey, lnCurrentDetailDoc_num,;
1239 lnLine_seq, lciPCHNTFlatFile, lciPCDNTFlatFile, lciPCSLNFlatFile
1240
1241 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1242 LOCAL lciPCAddrFlatFile, lciPCEDIHFlatFile, lciPCEDIDFlatFile, lciPCEDISFlatFile, lciPCAddrFlatFilepri, lciPCEDIHFlatFilePri, lciPCEDIDFlatFilePri, ;
1243 lciPCEDISFlatFilePri
1244 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1245
1246 lnCurrentHeaderPkey= 0
1247 lnCurrentHeaderDoc_num= 0
1248 lnCurrentDetailDoc_num=0
1249 lnLine_seq= 0
1250 lnCurrentHeaderStore=""
1251 lnOldSelect = SELECT()
1252
1253 WITH THIS
1254 .LogMajorStage("Loading flatfile to transaction tables.") && TR 1016560 NH
1255 * 1. Load from flatfile into transaction tables directlty
1256 .AdvanceThermoTotalWithCaptionPlus("Loading data from flatfile to transaction tables...", ;
1257 vcLogName)
1258 *--- TR 1015983 NH
1259
1260 IF .TIE_Setup
1261 .oLog.LogEntry("Splitting 860(i) flat file.")
1262 IF .SplitFlatFile("860.dat") && splits into 850hdr.dat, 850dtl.dat etc., renames 850.dat to .pri
1263 IF !.RenFileDat("860.pri") && timestamps 850.pri
1264 .oLog.LogEntry("Timestamping 860(i) flat file - FAILED.")
1265 ENDIF
1266 ELSE
1267 .oLog.LogEntry("Splitting 860(i) flat file - FAILED.")
1268 ENDIF
1269 ENDIF
1270
1271 *=== TR 1015983 NH
1272
1273 lcEDIPath = THIS.GetEDIFlatFileDirectory("Inbound")
1274 lciPCHeaderFlatFile = UPPER(lcEDIPath + "860hdr.dat")
1275 lciPCDetailFlatFile = UPPER(lcEDIPath + "860dtl.dat")
1276 lciPCSDQFlatFile = UPPER(lcEDIPath + "860sdq.dat")
1277 lciPCHNTFlatFile = UPPER(lcEDIPath + "860hnt.dat")
1278 lciPCDNTFlatFile = UPPER(lcEDIPath + "860dnt.dat")
1279 lciPCCommentFlatFile = UPPER(lcEDIPath + "860cmt.dat")
1280
1281 * --- TR 1047609 7/7/10 CM
1282 lciPCSLNFlatFile = UPPER(lcEDIPath + "860sln.dat")
1283 * === TR 1047609 7/7/10 CM
1284
1285 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
1286 lciPCEDIHFlatFile = UPPER(lcEDIPath + "860edih.dat")
1287 lciPCEDIDFlatFile = UPPER(lcEDIPath + "860edid.dat")
1288 lciPCEDISFlatFile = UPPER(lcEDIPath + "860edis.dat")
1289 lciPCAddrFlatFile = UPPER(lcEDIPath + "860adr.dat")
1290 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
1291
1292 .oLog.LogEntry("Loading 860(i) flatfiles.")
1293 *--- TR 1016589 NH 05/08/06 - added two param "Vnotes_IPCH_iPCproc", "VzzeiPCtd_notes_iPCproc"
1294 * --- TR 1047609 7/7/10 CM --- Added lciPCSLNFlatFile, "ZZEIPCTS", VzzeiPCts_iPCproc
1295 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli added lciPCAddressFlatFile, VzzeiPCta_iPCproc, ZZEIPCTA ===
1296 llRetVal= .LoadFromFlatFile("IPC", lciPCHeaderFlatFile, lciPCDetailFlatFile, lciPCCommentFlatFile, ;
1297 lciPCSDQFlatFile, lciPCHNTFlatFile, lciPCDNTFlatFile, lciPCSLNFlatFile, ;
1298 "VzzeiPCth_iPCproc", "VzzeiPCtd_iPCproc", "VzzeiPCtc_iPCproc", "VzzeiPCts_iPCproc", ;
1299 "ZZEIPCTH", "ZZEIPCTD", "ZZEIPCTC", "ZZEIPCTS", "Vnotes_IPCH_iPCproc", "Vnotes_IPCD_iPCproc", ;
1300 lciPCAddrFlatFile, "VzzeiPCta_iPCproc", "ZZEIPCTA" )
1301 * .nTranHeader, .nTranDetail
1302
1303 .oLog.LogEntry("Replace all error message with not yet process.")
1304 REPLACE ALL Errs_flg_h WITH "Y", Errs_msg_H WITH Errs_msg_H + " Not yet processed. " ;
1305 IN VzzeiPCth_iPCproc
1306
1307 * -- TR 1042514 DEC-4-2009 BR
1308 REPLACE ALL Pending_flg WITH 'Y' FOR Pending_flg <> 'N' IN VzzeiPCth_iPCproc
1309 * == TR 1042514 DEC-4-2009 BR
1310
1311 *--- TR 1036066 NH : remove ALL key word from edi_store field
1312 LOCAL lcPrevOrderBy
1313 SELECT VzzeiPCth_iPCproc
1314 lcPrevOrderBy = ORDER()
1315 SET ORDER TO edi_store
1316 *--- TR 1044959 BR
1317*!* IF SEEK(THIS.cStore_ALL,"VzzeiPCth_iPCproc","edi_store")
1318*!* SCAN WHILE edi_store = THIS.cStore_ALL
1319*!* replace edi_store WITH " " IN VzzeiPCth_iPCproc
1320*!* ENDSCAN
1321*!* ENDIF
1322 DO WHILE SEEK(THIS.cStore_ALL,"VzzeiPCth_iPCproc","edi_store")
1323 replace edi_store WITH " " IN VzzeiPCth_iPCproc
1324 ENDDO
1325
1326 *--- TR 1066871 13-May-2013 Goutam
1327 IF llRetVal AND USED(this.c850RefCursor) AND RECCOUNT(this.c850RefCursor) > 0
1328 llRetVal = .SetRelation("VzzeiPCth_iPCproc", "DOC_NUM", this.c850RefCursor, "DOC_NUM")
1329 IF llRetVal
1330 Select VzzeiPCth_iPCproc
1331 Replace All PROC_850 With 'Y' FOR !EOF(this.c850RefCursor)
1332 ENDIF
1333 Set Relation To
1334 ENDIF
1335 *=== TR 1066871 13-May-2013 Goutam
1336
1337 *=== TR 1044959 BR
1338 SET ORDER TO lcPrevOrderBy
1339 *=== TR 1036066 NH
1340
1341 *--- TechRec 1022169 28-Jun-2007 jjanand ---
1342 llRetVal= llRetVal And .RemoveDuplicatePOC()
1343 *=== TechRec 1022169 28-Jun-2007 jjanand ===
1344
1345 * 3. Tableupdate trans. views before rename DAT to PRI
1346 IF llRetVal
1347 .oLog.LogEntry("Sending transaction tables to server.")
1348 .AdvanceThermoTotalWithCaptionPlus("Sending transaction tables to server...", ;
1349 vcLogName)
1350 *--- TR 1016589 NH : added Notes tables to update
1351 *LOCAL laTables[2], llBeganTransaction
1352
1353 * --- TR 1047609 7/7/10 CM
1354 *LOCAL laTables[5], llBeganTransaction
1355 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli changed from 6 to 8 ===
1356 &&--- TechRec 1078492 05-Jun-2014 TSV changed from 8 to 9 ===
1357 LOCAL laTables[9], llBeganTransaction
1358 * === TR 1047609 7/7/10 CM
1359
1360 laTables[1] = "VzzeiPCth_iPCproc"
1361 laTables[2] = "VzzeiPCtd_iPCproc"
1362 laTables[3] = "VzzeiPCtc_iPCproc"
1363 laTables[4] = "Vnotes_IPCH_iPCproc"
1364 laTables[5] = "Vnotes_IPCD_iPCproc"
1365
1366 * --- TR 1047609 7/7/10 CM
1367 laTables[6] = "VzzeiPCts_iPCproc"
1368 * === TR 1047609 7/7/10 CM
1369
1370 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1371 laTables[7] = "VzzeiPCtwhse_iPCproc"
1372 laTables[8] = "VzzeiPCta_iPCproc"
1373 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1374
1375 *--- TechRec 1078492 05-Jun-2014 TSV---
1376 laTables[9] = "VzzeiPCts_iPCproc"
1377 *=== TechRec 1078492 05-Jun-2014 TSV===
1378
1379 llBeganTransaction = THIS.BeginTransaction()
1380 llRetVal = IIF(!THIS.TABLEUPDATE(@laTables), .F., .T.)
1381 IF llRetVal
1382 IF llBeganTransaction
1383 THIS.EndTransaction()
1384 ENDIF
1385 ELSE
1386 IF llBeganTransaction
1387 THIS.RollbackTransaction()
1388 ENDIF
1389 ENDIF
1390
1391 *--- TR 1027724 NH
1392 *--- TR 1022465 NH 03/12/07
1393*!* IF llRetVal AND llBeganTransaction
1394*!* *--- expode orders with no dtl and no sdq
1395*!* llRetval = llRetVal and this.ExplodeOrderForAllStore("VzzeiPCth_iPCproc")
1396*!* ENDIF
1397 *=== TR 1022465 NH 03/12/07
1398 *=== TR 1027724 NH
1399 *--- TR 1016589 NH : Rem out: in case following table update fails than we will have a header with no deatil scenario
1400*!* llBeganTransaction = THIS.BeginTransaction()
1401*!* llRetVal = IIF(!THIS.TABLEUPDATE("VzzeiPCtd_iPCproc"), .F., .T.)
1402*!* IF llRetVal
1403*!* IF llBeganTransaction
1404*!* THIS.EndTransaction()
1405*!* ENDIF
1406*!* ELSE
1407*!* IF llBeganTransaction
1408*!* THIS.RollbackTransaction()
1409*!* ENDIF
1410*!* ENDIF
1411
1412 *--- GS Notes: It would be better to use ForceExt(<lcFileName>, "PRI") here instead of StrTran(<lcFileName>, ".DAT", ".PRI")
1413 IF llRetVal && COMMIT successful
1414 * Delete *.pri and rename from *.dat to *.pri
1415 lciPCHeaderFlatFilePri= STRTRAN(lciPCHeaderFlatFile, ".DAT", ".PRI") && ".pri"
1416 lciPCDetailFlatFilePri= STRTRAN(lciPCDetailFlatFile, ".DAT", ".PRI") && ".pri"
1417 lciPCSDQFlatFilePri= STRTRAN(lciPCSDQFlatFile, ".DAT", ".PRI")
1418 lciPCHNTFlatFilePri= STRTRAN(lciPCHNTFlatFile, ".DAT", ".PRI")
1419 lciPCDNTFlatFilePri= STRTRAN(lciPCDNTFlatFile, ".DAT", ".PRI")
1420 lciPCCommentFlatFilePri= STRTRAN(lciPCCommentFlatFile, ".DAT", ".PRI")
1421
1422 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1423 lciPCAddrFlatFilePri= Strtran(lciPCAddrFlatFile, ".DAT", ".PRI")
1424 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1425
1426 * --- TR 1047609 7/7/10 CM
1427 lciPCSLNFlatFilePri= STRTRAN(lciPCSLNFlatFile, ".DAT", ".PRI")
1428 * === TR 1047609 7/7/10 CM
1429
1430 .oLog.LogEntry("Renaming 860(i) flatfiles.")
1431 IF FILE(lciPCHeaderFlatFile)
1432 .oLog.LogEntry("Renaming 860(i) header : " + lciPCHeaderFlatFilePri )
1433 COPY FILE (lciPCHeaderFlatFile) TO (lciPCHeaderFlatFilePri)
1434 DELETE FILE (lciPCHeaderFlatFile)
1435 ENDIF
1436
1437 IF FILE(lciPCDetailFlatFile)
1438 .oLog.LogEntry("Renaming 860(i) detail : " + lciPCDetailFlatFilePri )
1439 COPY FILE (lciPCDetailFlatFile) TO (lciPCDetailFlatFilePri)
1440 DELETE FILE (lciPCDetailFlatFile)
1441 ENDIF
1442
1443 IF FILE(lciPCSDQFlatFile)
1444 .oLog.LogEntry("Renaming 860(i) SDQ : " + lciPCSDQFlatFilePri)
1445 COPY FILE (lciPCSDQFlatFile) TO (lciPCSDQFlatFilePri)
1446 DELETE FILE (lciPCSDQFlatFile)
1447 ENDIF
1448
1449 IF FILE(lciPCHNTFlatFile)
1450 .oLog.LogEntry("Renaming 860(i) header notes: " + lciPCHNTFlatFilePri)
1451 COPY FILE (lciPCHNTFlatFile) TO (lciPCHNTFlatFilePri)
1452 DELETE FILE (lciPCHNTFlatFile)
1453 ENDIF
1454
1455 IF FILE(lciPCDNTFlatFile)
1456 .oLog.LogEntry("Renaming 860(i) detail notes: " + lciPCDNTFlatFilePri)
1457 COPY FILE (lciPCDNTFlatFile) TO (lciPCDNTFlatFilePri)
1458 DELETE FILE (lciPCDNTFlatFile)
1459 ENDIF
1460
1461 IF FILE(lciPCCommentFlatFile)
1462 .oLog.LogEntry("Renaming 860(i) comment: " + lciPCCommentFlatFilePri)
1463 COPY FILE (lciPCCommentFlatFile) TO (lciPCCommentFlatFilePri)
1464 DELETE FILE (lciPCCommentFlatFile)
1465 ENDIF
1466
1467 * --- TR 1047609 7/7/10 CM
1468 IF FILE(lciPCSLNFlatFile)
1469 .oLog.LogEntry("Renaming 860(i) SLN : " + lciPCSLNFlatFilePri)
1470 COPY FILE (lciPCSLNFlatFile) TO (lciPCSLNFlatFilePri)
1471 DELETE FILE (lciPCSLNFlatFile)
1472 ENDIF
1473 * === TR 1047609 7/7/10 CM
1474
1475 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1476 If File(lciPCAddrFlatFile)
1477 .oLog.LogEntry("Renaming 860(i)address: " + lciPCAddrFlatFilepri)
1478 Copy File (lciPCAddrFlatFile) To (lciPCAddrFlatFilepri)
1479 Delete File (lciPCAddrFlatFile)
1480 Endif
1481
1482 lciPCEDIHFlatFilePri = Strtran(lciPCEDIHFlatFile, ".DAT", ".PRI")
1483 lciPCEDIDFlatFilePri = Strtran(lciPCEDIDFlatFile, ".DAT", ".PRI")
1484 lciPCEDISFlatFilePri = Strtran(lciPCEDISFlatFile, ".DAT", ".PRI")
1485
1486 IF File(lciPCEDIHFlatFile)
1487 .oLog.LogEntry("Renaming 860(i) EDI Header : " + lciPCEDIHFlatFilePri)
1488 Copy File (lciPCEDIHFlatFile) To (lciPCEDIHFlatFilePri)
1489 Delete File (lciPCEDIHFlatFile)
1490 ENDIF
1491
1492 IF File(lciPCEDIDFlatFile)
1493 .oLog.LogEntry("Renaming 860(i) EDI Detail: " + lciPCEDIDFlatFilePri)
1494 Copy File (lciPCEDIDFlatFile) To (lciPCEDIDFlatFilePri)
1495 Delete File (lciPCEDIDFlatFile)
1496 ENDIF
1497
1498 IF File(lciPCEDISFlatFile)
1499 .oLog.LogEntry("Renaming 860(i) EDI Detail: " + lciPCEDISFlatFilePri)
1500 Copy File (lciPCEDISFlatFile) To (lciPCEDISFlatFilePri)
1501 Delete File (lciPCEDISFlatFile)
1502 ENDIF
1503 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1504
1505 ENDIF
1506 ENDIF
1507
1508 .AdvanceThermoTotalWithCaptionPlus("Refresh transaction base on filter criterias...", ;
1509 vcLogName)
1510 *--- TR 1015747 02/24/06 NH
1511*!* IF llRetVal
1512*!* .oLog.LogEntry("Refresh transaction base on filter criterias.")
1513*!* IF (REQUERY("VzzeipcTH_ipcproc")> 0) AND ;
1514*!* (REQUERY("VzzeipcTD_ipcproc")> 0) AND ;
1515*!* (REQUERY("VzzeipcTC_ipcproc")> 0)
1516*!* ELSE
1517*!* llRetVal= .F.
1518*!* .oLog.LogWarning("Failed to refresh transaction views.")
1519*!* ENDIF
1520*!* ENDIF
1521
1522*!* * 4. create transaction R/W cursor from views
1523*!* IF llRetVal &&continue it successfully table update Inter. and Trans. views
1524
1525*!* .oLog.LogEntry("Creating transaction header cursors from views.")
1526*!* .AdvanceThermoTotalWithCaptionPlus("Creating temporary transaction cursors...", ;
1527*!* vcLogName)
1528
1529*!* SELECT * FROM VzzeiPCth_iPCproc INTO CURSOR __EiPCth
1530*!* THIS.MakeCursorWritable("__EiPCth", "tcEiPCth")
1531*!* SELECT tcEiPCth
1532*!* .niPCOrderHeader= THIS.CountTotalRecs ("tcEiPCth")
1533*!* INDEX ON pkey TAG pkey
1534
1535*!* .oLog.LogEntry("Creating transaction detail cursors from views.")
1536*!* SELECT SPACE(7) AS customer, * FROM VzzeiPCtd_iPCproc INTO CURSOR __eipcTD
1537*!* THIS.MakeCursorWritable("__eiPCtd", "tcEiPCtd")
1538*!* .TableClose('__eipCTD')
1539
1540*!* SELECT tcEiPCtd
1541*!* .niPCOrderDetail= THIS.CountTotalRecs ("tcEiPCtd")
1542*!* INDEX ON pkey TAG pkey
1543*!* INDEX ON fkey TAG fkey
1544*!* INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
1545
1546*!* SELECT * FROM VzzeiPCtc_iPCproc INTO CURSOR __EiPCtc
1547*!* THIS.MakeCursorWritable("__EiPCtc", "tcEiPCtc")
1548*!* SELECT tcEiPCtc
1549*!* INDEX ON fkey TAG fkey
1550*!* .lHaveComment= (THIS.CountTotalRecs ("tcEiPCtc")> 0)
1551
1552*!* ENDIF
1553 *- 1014475 12/04/05 YIK
1554 *- Close all views later
1555 * Close all views
1556 *--- TR 1015747 02/24/06 NH : need to close these views because they will be recreated later in QueryTransaction()
1557 IF llRetVal
1558 *--- TR 1016589 NH
1559 *LOCAL laTables[3]
1560 * --- TR 1047609 7/7/10 --- Changed array from 5 to 6
1561 &&--- TechRec 1073591 06-Feb-2014 TShenbagavalli changed array dimension from 6 to 8 ===
1562 LOCAL laTables[8]
1563 laTables[1] = "VzzeiPCth_iPcproc"
1564 laTables[2] = "VzzeiPCtd_iPCproc"
1565 laTables[3] = "VzzeiPCtc_iPCproc"
1566 laTables[4] = "Vnotes_IPCH_iPCproc"
1567 laTables[5] = "Vnotes_IPCD_iPCproc"
1568
1569 * --- TR 1047609 7/7/10 CM
1570 laTables[6] = "Vzzeipcts_iPCproc"
1571 * === TR 1047609 7/7/10 CM
1572
1573 *--- TechRec 1073591 06-Feb-2014 TShenbagavalli ---
1574 laTables[7] = "VzzeipctWhse_iPCproc"
1575 laTables[8] = "Vzzeipcta_iPCproc"
1576 *=== TechRec 1073591 06-Feb-2014 TShenbagavalli ===
1577
1578 .oLog.LogEntry("Close all transaction views.")
1579 llRetVal = THIS.TableClose(@laTables, True) && close and delete all temp views
1580 IF NOT llRetVal
1581 .oLog.LogWarning("Failed to close all transaction views.")
1582 ENDIF
1583 ENDIF
1584 ENDWITH
1585 *=== TR 1015747 02/24/06 NH
1586 SELECT(lnOldSelect)
1587 RETURN llRetVal
1588 ENDPROC
1589 ******************************************************************************
1590 *--- TechRec 1022169 28-Jun-2007 jjanand ---
1591 ** To remove the first occurence (with smaller poc_line) of a duplicate detail
1592 ** in VzzeiPCtd_iPCproc that has the same fkey and upc and keep only the 2nd.
1593 ** The reason is that the 2nd occurence of POC does have the price and qualifier.
1594 PROCEDURE RemoveDuplicatePOC
1595
1596 LOCAL llRetVal,lnRecCount,lcsql,tcCheckPoc,lcTmpDuplIPCtdCursor,lcPocKEY,lcUPC,lcFKEY
1597
1598 LOCAL lnCountTotalRecs, lcDupKey, lnDuplRecordsRemoved,lcKey &&--- TechRec 1073148 06-Aug-2014 asharma ===
1599
1600 llRetVal = .T.
1601
1602 WITH THIS
1603
1604 .PushRecordSet()
1605
1606 .oLog.LogEntry("Removing Smallest POC Line")
1607
1608 IF USED('VzzeiPCtd_iPCproc')
1609
1610 *--- TechRec 1073148 06-Aug-2014 asharma ---
1611 * CountTotalRecs was killing time with deleted records on large table rec > 100000
1612*!* IF .CountTotalRecs('VzzeiPCtd_iPCproc') > 1
1613
1614*!* .oLog.LogEntry( "Transaction records : " + LTRIM(STR(THIS.CountTotalRecs('VzzeiPCtd_iPCproc'))))
1615 SELECT ('VzzeiPCtd_iPCproc')
1616 tcCheckPoc = GetUniqueFilename()
1617 COPY TO (tcCheckPoc)
1618 USE (tcCheckPoc) IN 0
1619 SELECT (tcCheckPoc)
1620 COUNT TO lnCountTotalRecs
1621 USE IN (tcCheckPoc)
1622 SELECT ('VzzeiPCtd_iPCproc')
1623
1624 IF lnCountTotalRecs > 1
1625
1626 .oLog.LogEntry( "Transaction records : " + LTRIM(STR(lnCountTotalRecs )))
1627
1628 tcCheckPoc = GetUniqueFilename()
1629
1630 IF .lOptmizedExplodeSDQ
1631
1632 .oLog.LogEntry("Removing Smallest POC Line")
1633
1634 SELECT ('VzzeiPCtd_iPCproc')
1635
1636 SET ORDER TO dupdele IN VzzeiPCtd_iPCproc
1637
1638 LOCATE
1639
1640 lcDupKey = '*'
1641 lnDuplRecordsRemoved = 0
1642
1643 SCAN
1644
1645 lcKey = STR(fkey)+upc+sku+line_id
1646
1647 IF lcKey = lcDupKey
1648 DELETE
1649 lnDuplRecordsRemoved = lnDuplRecordsRemoved + 1
1650 ELSE
1651 lcDupKey = lcKey
1652 ENDIF
1653
1654 ENDSCAN
1655
1656 .oLog.LogEntry( "No. of Smallest POC Line Removed : " + LTRIM(STR(lnDuplRecordsRemoved)))
1657
1658 ELSE
1659
1660 *=== TechRec 1073148 06-Aug-2014 asharma ===
1661
1662
1663 lcTmpDuplIPCtdCursor = GetUniqueFilename()
1664
1665 .RetrieveBufferedDataToCursor('VzzeiPCtd_iPCproc',lcTmpDuplIPCtdCursor)
1666
1667 lcSql = " SELECT MAX(pkey) " + ;
1668 " AS PocKEY, COUNT(*) " + ;
1669 " AS Line_count,FKEY,UPC,SKU,line_id " + ; &&--- TR 1027127 - include SKU
1670 " FROM " + lcTmpDuplIPCtdCursor + ;
1671 " GROUP BY Fkey,UPC,SKU,line_id " + ; &&--- TR 1027127
1672 " having Line_count > 1 "
1673
1674 tcCheckPoc = GetUniqueFilename()
1675
1676 llRetval = V_SqlExec(lcSql,tcCheckPoc,,.T.)
1677
1678 IF llRetval
1679
1680 SELECT (tcCheckPoc)
1681
1682 GO TOP
1683 DO WHILE !EOF()
1684 lcUPC = UPC
1685 lcSKU = SKU &&--- TR 1027127
1686 lcline_id = line_id
1687 lcFKEY = FKEY
1688 lcPocKEY = PocKEY
1689
1690 DELETE IN VzzeiPCtd_iPCproc ;
1691 FOR VzzeiPCtd_iPCproc.pkey <> lcPocKEY;
1692 AND UPC = lcUPC ;
1693 AND SKU = lcSKU ; &&--- TR 1027127
1694 and line_id = lcline_id ;
1695 AND FKEY = lcFKEY
1696
1697 SKIP
1698 ENDDO
1699 .oLog.LogEntry( "No. of Smallest POC Line Removed : " + LTRIM(STR(THIS.CountTotalRecs(tcCheckPoc,'line_count > 1'))))
1700 .TableClose(tcCheckPoc)
1701 ENDIF
1702 .TableClose(lcTmpDuplIPCtdCursor)
1703
1704 ENDIF && --- TechRec 1073148 06-Aug-2014 asharma ===
1705
1706 ELSE
1707 *--- TechRec 1073148 06-Aug-2014 asharma ---
1708 *.oLog.LogEntry( "Transaction records : " + LTRIM(STR(THIS.CountTotalRecs('VzzeiPCtd_iPCproc'))))
1709 .oLog.LogEntry( "Transaction records : " + LTRIM(STR(lnCountTotalRecs )))
1710 *=== TechRec 1073148 06-Aug-2014 asharma ===
1711 ENDIF
1712 ELSE
1713 .oLog.LogEntry( "Could not Open the Transaction Table")
1714 ENDIF
1715 .oLog.LogEntry( "Removing Smallest POC Line " + IIF(llRetVal,"sucessful.", "failed."))
1716 .PopRecordSet()
1717 ENDWITH
1718
1719 RETURN llRetVal
1720
1721 ENDPROC
1722 *=== TechRec 1022169 28-Jun-2007 jjanand ===
1723 ******************************************************************************
1724
1725 PROCEDURE LoadFromFlatFile
1726 * --- TR 1047609 7/7/10 CM --- Added tcSLNFlatFile,tcTransSLN,tcSLNPkeyTag
1727 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcAddressFlatFile, tcTransAddress, tcAddressPkeyTag ===
1728 LPARAMETERS tcProcess, tcHeaderFlatFile, tcDetailFlatFile, tcCommentFlatFile, tcSDQFlatFile, ;
1729 tcHNTFlatFile, tcDNTFlatFile, tcSLNFlatFile, ;
1730 tcTransHeader, tcTransDetail, tcTransComment, tcTransSLN, ;
1731 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, tcSLNPkeyTag, ;
1732 tcTransHdrNotes, tcTransDtlNotes, tcAddressFlatFile, tcTransAddress, tcAddressPkeyTag
1733
1734 LOCAL llRetVal, lcSQLString, lnLine_seq
1735 *--- TR 1016589 NH
1736 LOCAL lcDocCount
1737 lcDocCount = ""
1738 *=== TR 1016589 NH
1739
1740 * --- TR 1047609 7/7/10 CM
1741 Local llSLN
1742 llSLN = !Empty(tcSLNFlatFile) And File(tcSLNFlatFile)
1743 * === TR 1047609 7/7/10 CM
1744
1745 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1746 Local lcEDIPath, lcEDIHFlatFile, lcEDIDFlatFile, lcEDISFlatFile, lcTransWhse, lcWHSEPkeyTag
1747
1748 lcEDIPath = THIS.GetEDIFlatFileDirectory("Inbound")
1749
1750 lcEDIHFlatFile = lcEDIPath + "860edih.dat"
1751 lcEDIDFlatFile = lcEDIPath + "860edid.dat"
1752 lcEDISFlatFile = lcEDIPath + "860edis.dat"
1753
1754 lcTransWhse = "VzzeiPCtWhse_ipcproc"
1755 lcWHSEPkeyTag = "ZZEIPCTWHSE"
1756 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1757
1758 llRetVal= .T.
1759 WITH THIS
1760 * get Metadata for a process
1761 .oLog.LogEntry("Retrieving EDI Metadata definitions.")
1762 IF .GetTranslationDefinition(tcProcess, "tcEmData")
1763
1764 .oLog.LogEntry("Creating work cursors from EDI Metadata.")
1765 * Create Metadata work tables
1766 IF !EMPTY(tcHeaderFlatFile)
1767 .CreateMetaDataWorkTable("tcEmData", "HEADER", "tcALLmwH")
1768 ENDIF
1769 IF !EMPTY(tcDetailFlatFile)
1770 .CreateMetaDataWorkTable("tcEmData", "DETAIL", "tcALLmwD")
1771 ENDIF
1772 IF !EMPTY(tcCommentFlatFile)
1773 .CreateMetaDataWorkTable("tcEmData", "COMMENT", "tcALLmwC")
1774 ENDIF
1775
1776 IF !EMPTY(tcSDQFlatFile)
1777 .CreateMetaDataWorkTable("tcEmData", "SDQ", "tcALLmwS")
1778 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli added edi_center C(13) ---
1779 CREATE CURSOR tcStore (STORE C(13), pkey I(4), edi_center C(13))
1780 .CreateCursorStructure("tcALLmwD", "tcStore" , "tcSDQWrk")
1781 ENDIF
1782
1783 IF !EMPTY(tcHNTFlatFile)
1784 IF .CreateMetaDataWorkTable("tcEmData", "HDRNOTES", "tcHdrNotes")
1785 .PopulateDataToInterfaceTable(tcHNTFlatFile, "tcHdrNotes")
1786 ENDIF
1787 ENDIF
1788 IF !EMPTY(tcDNTFlatFile)
1789 IF .CreateMetaDataWorkTable("tcEmData", "DTLNOTES", "tcDtlNotes")
1790 .PopulateDataToInterfaceTable(tcDNTFlatFile, "tcDtlNotes")
1791 ENDIF
1792 ENDIF
1793
1794 * --- TR 1047609 7/7/10 CM
1795 IF llSLN
1796 .CreateMetaDataWorkTable("tcEmData", "SLN", "tcALLmwL")
1797 ENDIF
1798 * === TR 1047609 7/7/10 CM
1799
1800 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1801 IF !EMPTY(tcAddressFlatFile)
1802 .CreateMetaDataWorkTable("tcEmData", "ADDRESS", "tcALLmwA")
1803 ENDIF
1804
1805 IF (!Empty(lcEDIHFlatFile) And File(lcEDIHFlatFile)) Or (!Empty(lcEDIDFlatFile) And File(lcEDIDFlatFile))
1806 .CreateMetaDataWorkTable("tcEmData", "EDIH", "tcEDIH")
1807 .CreateMetaDataWorkTable("tcEmData", "EDID", "tcEDID")
1808 ENDIF
1809
1810 IF !EMPTY(lcEDISFlatFile) And FILE(lcEDISFlatFile)
1811 .CreateMetaDataWorkTable("tcEmData", "EDIS", "tcEDIS")
1812 ENDIF
1813 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
1814
1815 IF !EMPTY(tcHeaderFlatFile)
1816 llRetVal = llRetVal and .PopulateDataToInterfaceTable(tcHeaderFlatFile, "tcALLmwH", tcTransHeader,,"DOC_NUM") && TR 1024757 NH - check for unique value in "DOC_NUM" field
1817 ENDIF
1818 *--- TR 1024757 NH - Process fails when there is duplicate in doc_num field
1819 IF NOT llRetVal
1820 RETURN llRetVal
1821 ENDIF
1822 *===TR 1024757 NH
1823 IF !EMPTY(tcDetailFlatFile)
1824 .PopulateDataToInterfaceTable(tcDetailFlatFile, "tcALLmwD", tcTransDetail)
1825 ENDIF
1826 IF !EMPTY(tcCommentFlatFile)
1827 .PopulateDataToInterfaceTable(tcCommentFlatFile, "tcALLmwC", tcTransComment)
1828 ENDIF
1829
1830 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1831 If !Empty(tcAddressFlatFile)
1832 .PopulateDataToInterfaceTable(tcAddressFlatFile, "tcALLmwA", tcTransAddress)
1833 ENDIF
1834 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1835
1836 IF THIS.CountTotalRecs (tcTransHeader)> 0
1837 .oLog.LogEntry( "Transaction header records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransHeader))))
1838 ELSE
1839 .oLog.LogEntry( "No 860(i) flatfiles to load.")
1840 ENDIF
1841 IF THIS.CountTotalRecs (tcTransDetail)> 0
1842 .oLog.LogEntry( "Transaction detail records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransDetail))))
1843 ENDIF
1844 IF THIS.CountTotalRecs (tcTransComment)> 0 AND THIS.CountTotalRecs (tcTransHeader)> 0
1845 .oLog.LogEntry( "Transaction comment records : " + LTRIM(STR(THIS.CountTotalRecs (tcTransComment))))
1846 ENDIF
1847
1848 * Assign pkeys for all interface tables
1849 .oLog.LogEntry("Assigning primary keys.")
1850 IF !EMPTY(tcHeaderFlatFile)
1851 .GetPkeyForAllRecordsInBatch(tcTransHeader, tcHeaderPkeyTag, THIS.CountTotalRecs ("tcALLmwH"))
1852 ENDIF
1853 IF !EMPTY(tcDetailFlatFile)
1854 .GetPkeyForAllRecordsInBatch(tcTransDetail, tcDetailPkeyTag, THIS.CountTotalRecs ("tcALLmwD"))
1855 ENDIF
1856 IF !EMPTY(tcCommentFlatFile)
1857 .GetPkeyForAllRecordsInBatch(tcTransComment, tcCommentPkeyTag, THIS.CountTotalRecs ("tcALLmwC"))
1858 ENDIF
1859
1860 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
1861 If !Empty(tcAddressFlatFile)
1862 .GetPkeyForAllRecordsInBatch(tcTransAddress, tcAddressPkeyTag, THIS.CountTotalRecs("tcALLmwA"))
1863 Endif
1864 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
1865
1866 * Sync header Pkey to all child tables Fkey using doc_num
1867 * could just be header only.
1868 .oLog.LogEntry("Assigning parent keys.")
1869 LOCAL lnOldDoc_num, lnLine_seq
1870 lnOldDoc_num= 0
1871 llRetVal= .SetRelation(tcTransHeader, "doc_num", tcTransDetail, "doc_num")
1872 IF llRetVal
1873 SELECT (tcTransDetail)
1874 SCAN
1875 IF ! lnOldDoc_num = doc_num
1876 lnOldDoc_num= doc_num
1877 lnLine_seq= 0
1878 ENDIF
1879 IF line_seq=0
1880 lnLine_seq= lnLine_seq + 1
1881 REPLACE line_seq WITH lnLine_seq
1882 ENDIF
1883 REPLACE fkey WITH EVALUATE(tcTransHeader + ".pkey")
1884
1885 ENDSCAN
1886 ENDIF
1887 SET RELATION TO
1888
1889 lcEnt_user= EDI_USER
1890 ltLast_mod= DATETIME()
1891
1892 * --- TR 1047609 7/7/10 CM
1893 IF llSLN
1894 .oLog.LogEntry("Populating SLN Data.")
1895 .PopulateDataToInterfaceTable(tcSLNFlatFile, "tcALLmwL", tcTransSLN)
1896 .GetPkeyForAllRecordsInBatch(tcTransSLN, tcSLNPkeyTag, This.CountTotalRecs("tcALLmwL"))
1897
1898 llRetVal= .SetRelation(tcTransDetail, "PO1_Line", tcTransSLN, "Str(Doc_Num)+SLN_Line")
1899 Select (tcTransSLN)
1900 Replace All fkey With Evaluate(tcTransDetail + ".pkey"), ;
1901 User_id With lcEnt_user, Last_mod With ltLast_mod
1902 Set Relation To
1903 ENDIF
1904 * === TR 1047609 7/7/10 CM
1905
1906 llRetVal= .SetRelation(tcTransHeader, "doc_num", tcTransComment, "doc_num")
1907 IF llRetVal
1908 IF THIS.CountTotalRecs (tcTransComment)>0
1909 SELECT (tcTransComment)
1910 lnOldDoc_num= 0
1911
1912 SCAN
1913 IF ! lnOldDoc_num = doc_num
1914 lnOldDoc_num= doc_num
1915 lnLine_num= 0
1916 ENDIF
1917 IF line_num=0
1918 lnLine_num= lnLine_num + 1
1919 REPLACE line_num WITH lnLine_num
1920 ENDIF
1921 REPLACE fkey WITH EVALUATE(tcTransHeader + ".pkey"), ;
1922 User_id WITH lcEnt_user, Last_mod WITH ltLast_mod
1923
1924 ENDSCAN
1925
1926 ENDIF
1927 ENDIF
1928 SET RELATION TO
1929
1930 * Explode SDQ segments
1931 IF !EMPTY(tcSDQFlatFile)
1932 *
1933 * get flatfile SDQ data into work tables
1934 .PopulateDataToInterfaceTable(tcSDQFlatFile, "tcALLmwS")
1935 *
1936 *--- TR 1016904 NH
1937 this.AddALLStoreToFlatFileData("tcALLmwH","tcALLmwD","tcALLmwS")
1938 *=== TR 1016904 NH
1939 * have some SDQ to explode
1940 IF THIS.CountTotalRecs ("tcALLmwS")>0
1941 .oLog.LogEntry("Preparing cursor for exploding multiple store orders (SDQ).")
1942
1943 *--- TR 1021052 20-AUG-2007 HNISAR/Goutam
1944 *--- Added AND IIF(EMPTY(s.sdq_line), .T. , s.sdq_line = d.poc_line)
1945 *SELECT d.*, s.store_01,s.qty_01,s.store_02,s.qty_02,s.store_03,s.qty_03,;
1946 s.store_04,s.qty_04,s.store_05,s.qty_05,s.store_06,s.qty_06,s.store_07,s.qty_07,;
1947 s.store_08,s.qty_08,s.store_09,s.qty_09,s.store_10,s.qty_10 ;
1948 FROM tcALLmwD d, tcALLmwS s ;
1949 WHERE s.doc_num= d.doc_num ;
1950 AND s.upc= d.upc AND s.sku= d.sku AND s.ean= d.ean ;
1951 INTO CURSOR __SDQDet ;
1952 ORDER BY s.doc_num, s.upc, s.sku, s.ean
1953
1954 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli added s.edi_center in the select list ---
1955 SELECT d.*, s.store_01,s.qty_01,s.store_02,s.qty_02,s.store_03,s.qty_03,;
1956 s.store_04,s.qty_04,s.store_05,s.qty_05,s.store_06,s.qty_06,s.store_07,s.qty_07,;
1957 s.store_08,s.qty_08,s.store_09,s.qty_09,s.store_10,s.qty_10, s.edi_center ;
1958 FROM tcALLmwD d, tcALLmwS s ;
1959 WHERE s.doc_num= d.doc_num ;
1960 AND s.upc= d.upc AND s.sku= d.sku AND s.ean= d.ean ;
1961 AND IIF(EMPTY(s.sdq_line), .T. , s.sdq_line = d.poc_line) ;
1962 INTO CURSOR __SDQDet ;
1963 ORDER BY s.doc_num, s.upc, s.sku, s.ean
1964 *=== TR 1021052 20-AUG-2007 HNISAR/Goutam
1965
1966 * turn 10 pairs of SDQ store,qty from horizontal to vertical
1967 IF USED("__SDQDet")
1968 .PreExplodeSQDOrders("__SDQDet", "tcSDQWrk")
1969 ENDIF
1970 * should alway have something here to explode
1971 IF THIS.CountTotalRecs ("tcSDQWrk")>0
1972 SELECT * FROM tcSDQWrk INTO CURSOR _SDQDet ORDER BY doc_num, STORE, upc, sku, ean
1973 *--- TR 1016589 05/05/06 NH
1974 .CreateDocStoreCursor("_SDQDet", "tcDoc_Count")
1975 lcDocCount = "tcDoc_Count"
1976 *=== TR 1016589 05/05/06 NH
1977 .MakeCursorWritable("_SDQDet", "tcSDQDet")
1978 SELECT tcSDQDet
1979 INDEX ON pkey TAG pkey
1980 INDEX ON doc_num TAG doc_num
1981 *
1982 * Explode orders into Transaction tables all will have same doc_num
1983 * already, adjust clsIPCpr to handle dulication in doc_num when
1984 * sync Pkey/fkey in transaction table
1985 .oLog.LogEntry("Exploding multiple store orders (SDQ).")
1986 * --- TR 1047609 7/7/10 CM --- Added tcTransSLN, tcSLNPkeyTag
1987 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcTransaddress, "tcALLmwA", tcAddressPkeyTag ===
1988 .ExplodeSDQOrders("tcSDQDet", tcTransHeader, tcTransDetail, tcTransComment, ;
1989 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, ;
1990 "tcALLmwH", "tcALLmwD", "tcALLmwC",IIF(llSLN, tcTransSLN, ""), IIF(llSLN, tcSLNPkeyTag, ""),;
1991 tcTransaddress, "tcALLmwA", tcAddressPkeyTag )
1992 ENDIF
1993 ENDIF
1994 ENDIF
1995
1996 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
1997 IF (!Empty(lcEDIHFlatFile) And File(lcEDIHFlatFile)) Or (!Empty(lcEDIDFlatFile) And File(lcEDIDFlatFile))
1998 .oLog.LogEntry("Populating EDI Data.")
1999 .PopulateDataToInterfaceTable(lcEDIDFlatFile, "tcEDID", lcTransWhse)
2000 .oLog.LogEntry("Getting Pkey for EDI detail datawhse")
2001 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, This.CountTotalRecs("tcEDID"))
2002
2003 .oLog.LogEntry("Populating EDI header datawhse")
2004 .PopulateDataToInterfaceTable(lcEDIHFlatFile, "tcEDIH", lcTransWhse)
2005 .oLog.LogEntry("Populating pkey for EDI header datawhse")
2006 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, This.CountTotalRecs("tcEDIH"))
2007 .oLog.LogEntry("Populating all keys for EDI datawhse")
2008 Select (lcTransWhse)
2009 SCAN
2010 IF SEEK(Str(Doc_Num)+ edi_line, "vzzeipctd_ipcproc", "PO1_Line")
2011 Replace dfkey With vzzeipctd_ipcproc.pkey, ;
2012 line_seq With vzzeipctd_ipcproc.line_seq
2013 IF vzzeipctd_ipcproc.pkey > 0
2014 Replace table_name WITH "ZZOORDRD"
2015 ENDIF
2016 ENDIF
2017 IF SEEK(Doc_Num, "vzzeipcth_ipcproc", "Doc_Num")
2018 Replace hfkey With vzzeipcth_ipcproc.pkey, ;
2019 User_id With lcEnt_user, ;
2020 Last_mod With ltLast_mod
2021 IF dfkey = 0
2022 Replace table_name WITH "ZZOORDRH"
2023 ENDIF
2024 ENDIF
2025 ENDSCAN
2026 .oLog.LogEntry("Populating all keys for EDI datawhse completed.")
2027 ENDIF
2028
2029 IF !EMPTY(lcEDISFlatFile) And FILE(lcEDISFlatFile)
2030 .oLog.LogEntry("Populating EDIS Data.")
2031
2032 .PopulateDataToInterfaceTable(lcEDISFlatFile, "tcEDIS", lcTransWhse)
2033 .GetPkeyForAllRecordsInBatch(lcTransWhse, lcWHSEPkeyTag, .CountTotalRecs("tcEDIS"))
2034
2035 llRetVal = .SetRelation(tcTransDetail, "PO1_Line", lcTransWhse, "Str(Doc_Num)+ edi_line")
2036 IF llRetVal
2037 SELECT (lcTransWhse)
2038 REPLACE ALL dfkey WITH EVALUATE(tcTransDetail + ".pkey"), ;
2039 line_seq WITH EVALUATE(tcTransDetail + ".line_seq")
2040 ENDIF
2041 SET RELATION TO
2042
2043 llRetVal = .SetRelation(tcTransHeader, "Doc_Num", lcTransWhse, "Doc_Num")
2044 IF llRetVal
2045 SELECT (lcTransWhse)
2046 REPLACE ALL hfkey WITH EVALUATE(tcTransHeader + ".pkey")
2047 ENDIF
2048 SET RELATION TO
2049
2050 llRetVal = .SetRelation(tcTransSLN, "SLN_Line", lcTransWhse, "Str(Doc_Num)+SLN_Line")
2051 If llRetVal
2052 SELECT (lcTransWhse)
2053 REPLACE ALL sfkey WITH EVALUATE(tcTransSLN+ ".pkey"), ;
2054 user_id WITH lcEnt_User, ;
2055 last_mod WITH ltLast_Mod
2056
2057 Replace ALL table_name WITH "ZZEIPOHS" FOR sfkey > 0
2058
2059 ENDIF
2060 SET RELATION TO
2061 ENDIF
2062 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
2063
2064 .oLog.LogEntry("loading 850(i) header and detail notes.")
2065 *--- TR 1016589 05/05/06 NH Bring notes just as IPO process.
2066*!* .LoadHeaderDetailNotes("tcHdrNotes", "tcDtlNotes", ;
2067*!* tcTransHeader, tcTransDetail)
2068 .LoadHeaderDetailNotes("tcHdrNotes", "tcDtlNotes", ;
2069 tcTransHeader, tcTransDetail, tcTransHdrNotes, tcTransDtlNotes, lcDocCount)
2070 *=== TR 1016589 05/05/06 NH
2071 ELSE
2072 llRetVal=.F.
2073 ENDIF
2074 ENDWITH
2075
2076 * --- TR 1047609 7/7/10 CM
2077 *LOCAL laTables[7]
2078 &&--- TechRec 1073591 30-Oct-2013 TShenbagavalli changed from 8 to 12 ===
2079 LOCAL laTables[12]
2080 * === TR 1047609 7/7/10 CM
2081
2082 laTables[1] = "tcALLmwH"
2083 laTables[2] = "tcALLmwD"
2084 laTables[3] = "tcEmdata"
2085 laTables[4] = "__SDQDet"
2086 laTables[5] = "tcSDQDet"
2087 laTables[6] = "tcSDQWrk"
2088 laTables[7]= "tcStore"
2089
2090 * --- TR 1047609 7/7/10 CM
2091 laTables[8] = "tcALLmwL"
2092 * === TR 1047609 7/7/10 CM
2093
2094 *--- TechRec 1073591 30-Oct-2013 TShenbagavalli ---
2095 laTables[9] = "tcEDIH"
2096 laTables[10] = "tcEDID"
2097 laTables[11] = "tcEDIS"
2098 laTables[12] = "tcALLmwA"
2099 *=== TechRec 1073591 30-Oct-2013 TShenbagavalli ===
2100
2101 .TableClose(@laTables)
2102
2103 RETURN llRetVal
2104 ENDPROC
2105 ******************************************************************************
2106 *--- TR 1022465 NH 03/13/07
2107 ******************************************************************************
2108 *--- expode orders with no dtl and no sdq
2109 *--- TR 1027724 NH 11/05/07
2110 PROCEDURE ExplodeOrderForAllStore
2111 *LPARAMETERS tcTransHeader
2112
2113 LOCAL llRetVal, lcipcth_key, lcSql, loIpcth, lcipcth_New,lcipcth_Update
2114 llRetVal = .t.
2115 lnOldSelect = SELECT()
2116 *--- TR 1027724 NH : use .cFilterCriteria to get the transaction records that need to be worked on.
2117*!* lcipcth_key = "#ipoth_key" + SYS(2015)
2118*!* lcSql = "SELECT pkey INTO " + lcipcth_key + " FROM zzeipcth where 1 = 2"
2119*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2120*!*
2121*!* lcSql = "INSERT INTO " + lcipcth_key + " VALUES (loIpcth.pkey)"
2122*!* SELECT ("VzzeiPCth_iPCproc")
2123*!* SCAN
2124*!* SCATTER NAME loIpcth
2125*!* *IF loIpcth.Errs_flg_h <> 'Y'
2126*!* IF loIpcth.store = '' AND loIpcth.edi_store = ''
2127*!* lcSqlInsert = STRTRAN(lcSql,"loIpcth.pkey",SqlFormatNum(loIpcth.pkey))
2128*!* llRetVal = llRetVal and v_sqlexec(lcSqlInsert)
2129*!* ENDIF
2130*!* ENDSCAN
2131 *=== TR 1027724 NH
2132
2133 lcipcth_New = "#Zzeipcth_new" + SYS(2015)
2134 lcipcth_Update = "#Zzeipcth_update" + SYS(2015)
2135 *--- now, we have list of orders to explode
2136
2137 loCopyUtil = NEWOBJECT("CopyUtil","CopyUtil.prg")
2138 IF VARTYPE(loCopyUtil) <> "O"
2139 SELECT(lnOldSelect)
2140 RETURN llRetVal
2141 ENDIF
2142
2143 *--- In 860 transaction header has one record per PO. We will update store, edi_store information.
2144 *--- First, move this (Update) records into another table for future update.
2145 *--- Second, delete (remove) these records from exploded order list using customer, po_num, and edi_store
2146 *--- Thrid, prepare new order table for insert (pkey)
2147 *--- Fourth, Open transaction
2148 *--- Fifth, Update 860 trans header.
2149 *--- Sixth, Insert 860 trans header.
2150 *--- TR 1027724 NH
2151*!*
2152*!* lcSql = "select th.* into #zzeipcth_update from #zzeipcth_main th inner join #zzeipcth_pkey k on th.pkey = k.pkey"
2153*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2154*!* lcSql = STRTRAN(lcSql,"#zzeipcth_main","zzeipcth")
2155*!* lcSql = STRTRAN(lcSql,"#zzeipcth_pkey",lcipcth_key)
2156*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2157 LOCAL lcFilter
2158 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
2159 lcFilter = STRTRAN(lcFilter,"H.","TH.")
2160 lcFilter = STRTRAN(lcFilter,"Where","")
2161
2162 *--- TR 1035409 NH
2163 lcSQL = "SELECT * into " + lcipcth_Update + " FROM zzeipcth th where 1 = 1 " + IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2164 llRetVal = llRetVal and v_sqlexec(lcSQL)
2165
2166 *--- TR 1072834 20-Aug-2013 Goutam
2167 *lcSQL = "UPDATE h SET errs_flg_h = 'N', errs_msg_h = '' FROM " + lcipcth_Update + " h"
2168 lcSQL = "UPDATE h SET errs_flg_h = 'N', warn_flg_h = 'N', errs_msg_h = '', warn_msg_h = '' FROM " + lcipcth_Update + " h"
2169 *=== TR 1072834 20-Aug-2013 Goutam
2170
2171 llRetVal = llRetVal and v_sqlexec(lcSQL)
2172
2173 *--- TR 1048865 10-Feb-2011 Goutam. added ,,"CR_Pkey" at the end of the parameter
2174 llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcipcth_Update, "zzeipccr","customer","errs_flg_h","errs_msg_h",,"CR_Pkey")
2175
2176 *--- TR 1048865 10-Feb-2011 Goutam. added "CR_Pkey" for updation
2177 *--- TR 1072834 20-Aug-2013 Goutam. Added warn_flg_h, warn_msg_h
2178 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 " + ;
2179 " , errs_msg_h = case when h.errs_flg_h = 'Y' then h.errs_msg_h else th.errs_msg_h end " + ;
2180 " , warn_flg_h = case when h.warn_flg_h = 'Y' then 'Y' else th.warn_flg_h end " + ;
2181 " , warn_msg_h = case when h.warn_flg_h = 'Y' then h.warn_msg_h else th.warn_msg_h end " + ;
2182 " from zzeipcth th inner join " + lcipcth_Update + " h on th.pkey = h.pkey "
2183 llRetVal = llRetVal and v_sqlexec(lcSQL)
2184 v_sqlexec("drop table " + lcipcth_Update)
2185 *=== TR 1035409 NH
2186 *--- TR 1036066 NH
2187 llRetVal = llRetVal and this.PopulateStoreForSingleStorePO_AtServer()
2188 *=== TR 1036066 NH
2189 *--- get all trans header record to explode for empty store and edi_store
2190 *--- TR 1034532 NH : take header that has no details for lcipcth_Update table
2191 *--- TR 1036066 NH : Added - ForAllStore = 'Y'
2192 lcSQL = "SELECT th.* into " + lcipcth_Update + " from zzeipcth th " + ;
2193 " WHERE th.store = '' and th.edi_store = '' and th.customer > '' " +; && TR 1035409
2194 " and th.ForAllStore = 'Y' " + ;
2195 " and not exists ( select * from zzeipctd td where td.fkey = th.pkey) " + ; && TR 1034532 NH
2196 IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2197 *=== TR 1036066 NH
2198 llRetVal = llRetVal and v_SQLexec(lcSQL)
2199
2200 *--- TR 1035409 NH : added condition to add trans header for date change.
2201 *--- date change is for accross PO, so we need to add
2202
2203 *--- TR 1036066 NH
2204 *--- create new trans headers for each SO orders.
2205 *--- do not create copy of details. because it is only header change.
2206 *--- If there are details with this trans header leave the original trans header with empty edi_store, empty store, and ForAllStore = 'Y'
2207 *--- If detail has qualifier 'DI' or 'PC' then in later steps it will be exploded for all stores of the PO.
2208 *--- If detail has qualifier 'AI', 'QI', 'QD', 'RZ' then it will be handled in later steps.
2209 *=== TR 1036066 NH
2210
2211 LOCAL lcipcth_Update_tmp
2212 lcipcth_Update_tmp = "#Zzeipcth_update_tmp" + SYS(2015)
2213
2214 lcSql = " select th.* into " + lcipcth_Update_tmp + " from zzeipcth th where exists ( " + ;
2215 " select h.customer, h.po_num from zzeipcth h " + ;
2216 " where (h.start_date > {ts '1900-01-01 12:00:00.000'} " + ;
2217 " or h.End_date > {ts '1900-01-01 12:00:00.000'}) " + ;
2218 " group by h.customer, h.po_num having MIN(h.pkey) = th.pkey ) " + ;
2219 " AND th.customer > '' " + ;
2220 IIF(EMPTY(lcFilter),lcFilter," AND " + lcFilter)
2221
2222 llRetVal = llRetVal and v_SQLexec(lcSQL)
2223
2224 *--- TR 1072834 20-Aug-2013 Goutam. Added warn_flg_h, warn_msg_h
2225 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 "
2226 llRetVal = llRetVal and v_SQLexec(lcSQL)
2227
2228 *=== TR 1035409 NH
2229 *=== TR 1027724
2230
2231 *--- TR 1026113 08/15/2007 NH
2232 *--- get store, and edi_store information from sales order and customer store ref
2233*!* TEXT TO lcSql NOSHOW
2234*!* SELECT u.*, oh.store as ord_store, s.edi_store as Ord_edi_store into #Zzeipcth_new
2235*!* FROM #Zzeipcth_update u inner join zzeipccr cr ON u.vnd_id = cr.vnd_id and u.vnd_qual = cr.vnd_qual
2236*!* inner join zzoordrh oh WITH (nolock) ON u.po_num = oh.po_num and cr.customer = oh.customer and oh.ord_status = 'O'
2237*!* inner join zzxstorr s with (nolock) on s.store = oh.store and s.customer = oh.customer
2238*!* WHERE not EXISTS (SELECT * FROM zzeipctd d WHERE d.fkey = u.pkey)
2239*!* ENDTEXT
2240 *--- update ipc with customer from ipc control reference
2241 *--- TR 1027724 NH
2242*!* 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"
2243*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2244 *--- clear errors
2245 *--- TR 1035409 NH : no need this here
2246*!* lcSQL = "UPDATE h SET errs_flg_h = '', errs_msg_h = '' FROM " + lcipcth_Update + " h"
2247*!* llRetVal = llRetVal and v_sqlexec(lcSQL)
2248*!* llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcipcth_Update, "zzeipccr","customer","errs_flg_h","errs_msg_h")
2249 *=== TR 1035409 NH
2250 *--- TR 1035409 NH : resolve customer before insert into lcipcth_Update. Need customer for the join - h.customer = tmp.customer
2251 *--- update customer information in zzeipcth - customer is need to delete record later on
2252 lcSql = " insert into " + lcipcth_Update + " select * from " + lcipcth_Update_tmp + " tmp " + ;
2253 " where not exists (select h.pkey from " + lcipcth_Update + " h " + ;
2254 " where h.po_num = tmp.po_num and h.customer = tmp.customer ) " +;
2255 " AND tmp.errs_flg_h <> 'Y'"
2256 llRetVal = llRetVal and v_SQLexec(lcSQL)
2257 *--- drop temp table
2258 v_sqlexec("drop table " + lcipcth_Update_tmp )
2259 *=== TR 1035409 NH
2260
2261 *--- update 860 transaction table if any validation error occured in customer resolution
2262
2263
2264 *--- Added condition and u.customer > '' to eliminate the ones with customer not resolved.
2265 *--- TR 1035409 NH
2266 *not EXISTS (SELECT * FROM zzeipctd d WHERE d.fkey = u.pkey) and
2267 *--- exclude headers which are already in the trans main.
2268 *--- TR 1089812 14-Sep-2015 BNarayanan removed and oh.ord_status = 'O' from inner join ---
2269 TEXT TO lcSql NOSHOW
2270 SELECT u.*, oh.store as ord_store, s.edi_store as Ord_edi_store into #Zzeipcth_new
2271 FROM #Zzeipcth_update u inner join zzoordrh oh WITH (nolock) ON u.po_num = oh.po_num and u.customer = oh.customer
2272 inner join zzxstorr s with (nolock) on s.store = oh.store and s.customer = oh.customer
2273 WHERE u.customer > ''
2274 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)
2275 ENDTEXT
2276
2277 *=== TR 1027724 NH
2278 *=== TR 1026113 NH
2279 *u.errs_flg_h <> 'Y' AND
2280
2281 lcSql = STRTRAN(lcSql,"#Zzeipcth_new",lcipcth_New)
2282 lcSql = STRTRAN(lcSql,"#Zzeipcth_update",lcipcth_Update)
2283 *lcSql = STRTRAN(lcSql,"CHR(13)","cr") && TR 1026113 08/15/2007 NH
2284 llRetVal = llRetVal and v_sqlexec(lcSql)
2285
2286 *--- TR 1036066 NH
2287 *--- update store, and edi_store information for temp columns ord_store, ord_edi_store
2288 *lcSql = "update th SET store = ord_store, edi_store = ord_edi_store from #zzeipcth_New th"
2289 lcSql = "update th SET store = ord_store, edi_store = ord_edi_store " + ;
2290 " , ForAllStore = case when th.ForAllStore = 'Y' then 'P' ELSE th.ForAllStore end " + ;
2291 " from #zzeipcth_New th"
2292 *=== TR 1036006 NH
2293 lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2294 llRetVal = llRetVal and v_sqlexec(lcSql)
2295
2296 *--- to preserver one record per PO for update only
2297 *--- TR 1035409 NH : Rem out - no need now
2298 *thn.pkey, thn.store, thn.edi_store, thn.customer, thn.po_num
2299*!* lcSql = "update u SET store = thn.store, edi_store = thn.edi_store FROM #zzeipcth_update u " + ;
2300*!* "INNER JOIN #zzeipcth_New thn on thn.customer = u.customer and thn.po_num = u.po_num " + ;
2301*!* "and u.Customer > '' " && TR 1027724 added u.Customer > ''
2302
2303*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2304*!* lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2305*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2306
2307 *--- remove preservered po records from insert table.
2308*!* TEXT TO lcSql NOSHOW
2309*!* delete thn FROM #zzeipcth_New thn inner join #zzeipcth_update u
2310*!* on thn.customer = u.customer and thn.po_num = u.po_num and thn.edi_store = u.edi_store
2311*!* ENDTEXT
2312*!* lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2313*!* lcSql = STRTRAN(lcSql,"#zzeipcth_update",lcipcth_Update)
2314*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2315 *=== TR 1035409 NH
2316 llRetVal = llRetVal and loCopyUtil.DropColumn(lcipcth_New, "ord_store")
2317 llRetVal = llRetVal and loCopyUtil.DropColumn(lcipcth_New, "Ord_edi_store")
2318
2319 *--- lcipcth_Update has trans header records to update
2320 *--- lcIpcth_New has trans header records to insert
2321 *--- set pkey of trans header
2322 lcSql = "select COUNT(*) Rec_count from #zzeipcth_New"
2323 lcSql = STRTRAN(lcSql,"#zzeipcth_New",lcipcth_New)
2324 llRetVal = llRetVal and v_sqlexec(lcSql,"RowAffected")
2325
2326
2327 *--- TR 1034532 - add trans detail for new trans header
2328 *--- TR 106066 NH
2329*!* LOCAL lcipctd_New
2330*!* lcipctd_New = "#Zzeipctd_new" + SYS(2015)
2331*!* lcSql = "select td.* into " + lcipctd_New + " from zzeipctd td inner join " + lcipcth_New + " th on th.pkey = td.fkey"
2332*!* llRetVal = llRetVal and v_sqlexec(lcSql)
2333 *=== TR 1036066 NH
2334 *=== TR 1034532 NH
2335 IF llRetVal AND RowAffected.Rec_Count > 0
2336 lnMaxNumber = v_nextPkey("zzeipcth",RowAffected.Rec_Count)
2337 *--- TR 1034532 NH - set pkey for trans header and fkey for trans detail
2338 *--- TR 1036066 NH
2339 llRetVal = llRetVal and loCopyUtil.KeyFldUpdate(lcipcth_New, "pkey", lnMaxNumber, RowAffected.Rec_Count, "pkey_I")
2340
2341*!* DECLARE ladtlTmp[1,4]
2342*!* ladtlTmp[1,1] = lcipctd_New
2343*!* ladtlTmp[1,2] = 'fkey'
2344*!* ladtlTmp[1,3] = 'fkey'
2345*!* ladtlTmp[1,4] = 'pkey'
2346*!* loCopyUtil.HdrDtlNumKeyFldUpdate(lcipcth_New,"pkey",@ladtlTmp, lnMaxNumber,RowAffected.Rec_Count,"pkey_I")
2347 *=== TR 1036066 NH
2348 *=== TR 1034532 NH
2349 ENDIF
2350
2351 *--- Prepare 860 transaction update, insert SQL
2352 *--- TR 1027724 NH : added update fields , errs_msg_h = u.errs_msg_h, errs_flg_h = u.errs_flg_h
2353 *--- TR 1035409 NH : no need to update here
2354*!* TEXT TO lcSqlUpdate NOSHOW
2355*!* update th SET store = u.store, edi_store = u.edi_store, errs_msg_h = u.errs_msg_h,
2356*!* errs_flg_h = u.errs_flg_h FROM #zzeipcth_main th inner join #zzeipcth_update u on u.pkey = th.pkey
2357*!* ENDTEXT
2358*!* lcSqlUpdate = STRTRAN(lcSqlUpdate, "#zzeipcth_main","zzeipcth")
2359*!* lcSqlUpdate = STRTRAN(lcSqlUpdate, "#zzeipcth_update",lcipcth_Update)
2360 *=== TR 1035409 NH
2361 TEXT TO lcSQlInsert NOSHOW
2362 insert into #zzeipcth_main select * from #zzeipcth_New
2363 ENDTEXT
2364 lcSQlInsert = STRTRAN(lcSQlInsert, "#zzeipcth_main","zzeipcth")
2365 lcSQlInsert = STRTRAN(lcSQlInsert, "#zzeipcth_New",lcipcth_New)
2366
2367 *--- TR 1035409 NH
2368 *--- remove empty store, edi_store
2369 *--- preserve the trans header if there is any detail attached with it.
2370 LOCAL lcSqlDelete
2371 lcSqlDelete = "delete th from zzeipcth th inner join " + lcipcth_New + " tn on th.po_num = tn.po_num " + ;
2372 " and th.customer = tn.customer and th.doc_num = tn.doc_num " + ;
2373 " where th.edi_store = '' and th.store = '' " + ;
2374 " AND th.ForAllStore = 'Y' and not exists (select td.pkey from zzeipctd td where td.fkey = th.pkey)"
2375
2376 *=== TR 1035409 NH
2377
2378 *--- TR 1034532 NH - update detail fkey
2379 *--- TR 1036066 NH
2380*!* LOCAL lcSqlDtlUpdate
2381*!* lcSqlDtlUpdate = "update td set fkey = d.fkey from zzeipctd td inner join " + lcipctd_New + " d on td.pkey = d.pkey "
2382 *=== TR 1036066 NH
2383 *=== TR 1034532 NH
2384 IF NOT llRetVal
2385 SELECT(lnOldSelect)
2386 RETURN llRetVal
2387 ENDIF
2388
2389 llBeganTransaction = THIS.BeginTransaction()
2390 IF llBeganTransaction
2391 *--- TR 1035409 NH : no need to update any more -> delete + insert
2392 *llRetVal = llRetVal and v_sqlexec(lcSqlUpdate)
2393 llRetVal = llRetVal and v_sqlexec(lcSqlDelete)
2394 *=== TR 1035409 NH
2395 llRetVal = llRetVal and v_sqlexec(lcSqlInsert)
2396 *--- TR 1036066 NH
2397 *llRetVal = llRetVal and v_sqlexec(lcSqlDtlUpdate) &&--- TR 1034532 NH
2398 *=== TR 1036066 NH
2399 IF llRetVal
2400 THIS.EndTransaction()
2401 ELSE
2402 THIS.RollbackTransaction()
2403 ENDIF
2404 ENDIF
2405
2406 SELECT(lnOldSelect)
2407 RETURN llRetVal
2408 ENDPROC
2409 *=== TR 1022465 NH 03/13/07
2410
2411
2412 ******************************************************************************
2413 *--- TR 1016904 NH
2414 ******************************************************************************
2415 PROCEDURE AddALLStoreToFlatFileData
2416 LPARAMETERS pcALLmwH, pcALLmwD, pcALLmwS
2417 LOCAL llRetVal, lnOldSelect, loALLmwS, loALLmwD_noSDQ
2418 llRetVal = .t.
2419 lnOldSelect = SELECT()
2420 lnSdqCount = 0
2421
2422
2423 this.LogEntry("Starting procedure " + PROGRAM())
2424 *--- ALL store candidate : detail records has qualifier 'DI' and there is no related SDQ and
2425 *--- header does not have any store in it.
2426 *--- TR 1022465 NH Added: OR d.qualifier = 'PC'
2427 *--- TR 1034532 NH : removed - (d.qualifier = 'DI' OR d.qualifier = 'PC')
2428 *--- first use ALL in edi_store for empty edi_store to bring detail to transaction
2429
2430*- TR 1072151 FH - added for scenario when we have bulk order with both DI and AI, but only AI have store.
2431*- We are loosing the DI records because we don't have SDQ associated with it.
2432
2433*!* SELECT * FROM (pcALLmwD)d WHERE 1=1 ;
2434*!* AND NOT EXISTS (SELECT * FROM (pcALLmwS) s WHERE s.doc_num = d.DOC_NUM ;
2435*!* 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
2436*!* AND exists (select * from (pcALLmwH) h WHERE h.edi_store = "" AND h.doc_num = d.doc_num ; && 1021200 : Removed brace ')'
2437*!* 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
2438*!* into cursor _tcALLmwD_noSDQ
2439
2440 select * ;
2441 from (pcALLmwD)d ;
2442 where 1=1 ;
2443 and not exists ( ;
2444 select * ;
2445 from (pcALLmwS) s ;
2446 where s.doc_num = d.DOC_NUM ;
2447 and s.upc = d.UPC ;
2448 and s.sku = d.sku ;
2449 and s.ean = d.ean ;
2450 and s.sdq_line = d.poc_line) ;
2451 and exists ( ;
2452 select * ;
2453 from (pcALLmwH) h ;
2454 where h.edi_store = "" ;
2455 and h.doc_num = d.doc_num ;
2456 and ( not (po_type = 'BK' or po_type ='BL' or po_type = 'KC') ;
2457 OR EXISTS ( SELECT * FROM (pcALLmwS) s WHERE s.doc_num = h.DOC_NUM) ) ; && TR 1072151 FH - added.
2458 ) ;
2459 into cursor _tcALLmwD_noSDQ
2460*- TR 1072151 FH
2461
2462
2463 this.LogEntry("Numbers of SDQ record will be added are " + TRANSFORM(RECCOUNT("_tcALLmwD_noSDQ")))
2464
2465 SELECT _tcALLmwD_noSDQ
2466 SCAN
2467 SCATTER NAME loALLmwD_noSDQ
2468 SELECT (pcALLmwS)
2469 SCATTER NAME loALLmwS BLANK
2470 loALLmwS.SDQ_TAG = 'SDQ'
2471 loALLmwS.DOC_NUM = loALLmwD_noSDQ.doc_num
2472 loALLmwS.upc = loALLmwD_noSDQ.upc
2473 loALLmwS.sku = loALLmwD_noSDQ.sku
2474 loALLmwS.ean = loALLmwD_noSDQ.ean
2475 loALLmwS.store_01 = this.cStore_ALL
2476 loALLmwS.qty_01 = IIF(INLIST(loALLmwD_noSDQ.qualifier, 'DI','PC'), "0" ,loALLmwD_noSDQ.qty_change) && all values are character including numeric ones
2477 *loALLmwS.ForAllStore = 'Y' && TR 1027127 NH
2478 loALLmwS.sdq_line = loALLmwD_noSDQ.poc_line
2479 APPEND BLANK
2480 GATHER NAME loAllmwS
2481 lnSdqCount = lnSdqCount + 1
2482 ENDSCAN
2483 this.LogEntry("Numbers of SDQ records have be added are " + TRANSFORM(lnSdqCount))
2484
2485 IF USED("_tcALLmwD_noSDQ")
2486 USE IN ("_tcALLmwD_noSDQ")
2487 ENDIF
2488
2489 SELECT(lnOldSelect)
2490 RETURN llRetVal
2491 ENDPROC
2492 ******************************************************************************
2493 *=== TR 1016904 NH
2494
2495 PROCEDURE PreExplodeSQDOrders
2496 PARAMETER tcSDQWorkTable, tcSDQDetailTable
2497 LOCAL lnOldSele, llRetVal, lcSQLString, lnSDQCount
2498 llRetVal= .T.
2499 lnOldSele= SELECT()
2500 SELECT (tcSDQWorkTable)
2501 SCAN
2502 SCATT MEMVAR
2503 FOR lnSDQCount = 1 TO MAX_SDQ_COUNT
2504 lcSDQCount= TRANS(lnSDQCount , "@L 99")
2505 m.Store=EVAL( "store_" + lcSDQCount)
2506 *- 1014475 01/18/06 YIK
2507 *- We did not populate SDQ quantities!
2508 m.Qty_change = EVAL( "qty_" + lcSDQCount)
2509 IF !EMPTY(m.Store)
2510 INSERT INTO (tcSDQDetailTable) FROM MEMVAR
2511 ENDIF
2512 ENDFOR
2513 ENDSCAN
2514 * Each SDQDetail records need ALL pkey (recno())
2515 REPLACE ALL pkey WITH RECNO() IN (tcSDQDetailTable)
2516 RETURN llRetVal
2517 ENDPROC
2518
2519 PROCEDURE ExplodeSDQOrders
2520 * --- TR 1047609 7/7/10 CM --- Added tcTransSLN, tcSLNPkeyTag
2521 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tcTransaddress, tcMetaWorkAddress, tcAddressPkeyTag ===
2522 PARAMETER tcSDQDetailTable, tcTransHeader, tcTransDetail, tcTransComment,;
2523 tcHeaderPkeyTag, tcDetailPkeyTag, tcCommentPkeyTag, ;
2524 tcMetaWorkHeader, tcMetaWorkDetail, tcMetaWorkComment, tcTransSLN, tcSLNPkeyTag,;
2525 tcTransaddress, tcMetaWorkAddress, tcAddressPkeyTag
2526
2527 LOCAL lnOldSele, llRetVal, lcSQLString, lnSDQCount,lnCurrentDoc_num, lcCurrentDoc_num, ;
2528 lnOrdersHeaderToExplode,lnOrdersLineToExplode, lcDBFName, lnCurrentStart_date
2529
2530 LOCAL lnCurrentEnd_Date, lnOldDtlPKey, lnNewDtlPKey, I, lnCnt, lcDoc_Num
2531
2532 * --- TR 1047609 7/7/10 CM
2533 LOCAL lnNewDtlPKey, lcPO1_Line, lcDoc_Num, lnOldDtlPKey, lnOldHdrPKey
2534 * === TR 1047609 7/7/10 CM
2535
2536 llRetVal= .T.
2537 lnOldSele= SELECT()
2538
2539 * create temporary cursor to hold exploded orders before append to interface tables
2540 * should have same layout as interface tables
2541 SELECT (tcTransHeader)
2542 AFIELDS(laWorkHeader)
2543 * Walmart - Store truncate to 9 position for
2544 * SDQ orders when expand EDI store to 13 position
2545 lnRow =ASUB(laWorkHeader, ASCAN(laWorkHeader, 'STORE'), 1)
2546 laWorkHeader[lnRow, 3]= 13 && expand store to 13 pos in SQD work header
2547 CREATE CURSOR TargetWH FROM ARRAY laWorkHeader
2548 SELECT (tcTransDetail)
2549 AFIELDS(laWorkDetail)
2550 CREATE CURSOR TargetWD FROM ARRAY laWorkDetail
2551 SELECT (tcTransComment)
2552 AFIELDS(laWorkComment)
2553 CREATE CURSOR TargetWC FROM ARRAY laWorkComment
2554
2555 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2556 Select (tcTransAddress)
2557 Afields(laWorkAddress)
2558 Create Cursor TargetWA From Array laWorkAddress
2559 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2560
2561 * --- TR 1047609 7/7/10 CM
2562 llSLN = !Empty(tcTransSLN) And Used(tcTransSLN) And Reccount(tcTransSLN) > 0
2563 If llSLN
2564 Select (tcTransSLN)
2565 Afields(laWorkSLN)
2566 Create Cursor TargetSLN From Array laWorkSLN
2567 Endif
2568 * === TR 1047609 7/7/10 CM
2569
2570 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
2571 LOCAL llWhsData
2572 lcTransWhse = "vzzeiPCtWhse_iPCproc"
2573 If Used(lcTransWhse) and RecCount(lcTransWhse) > 0
2574 llWhsData = .T.
2575 Select (lcTransWhse)
2576 =AFields(laWorkWHSE)
2577 Create Cursor TargetWhse from array laWorkWHSE
2578 EndIf
2579 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
2580
2581 WITH THIS
2582
2583 *--- TechRec 1073148 06-Aug-2014 asharma ---
2584
2585 IF .lOptmizedExplodeSDQ
2586
2587 SELECT distinct h.*, 000000000 as pkey, d.store as store, d.edi_center as dedi_center ;
2588 FROM (tcMetaWorkHeader) h, (tcSDQDetailTable) d ;
2589 WHERE h.doc_num = d.doc_num ;
2590 INTO CURSOR _WrkHdr READWRITE
2591
2592 SELECT distinct h.*, 000000000 as pkey, 000000000 as fkey, d.store ;
2593 FROM (tcMetaWorkComment) h, (tcSDQDetailTable) d ;
2594 WHERE h.doc_num = d.doc_num ;
2595 INTO CURSOR _WrkCmt READWRITE
2596
2597 SELECT d.*, d.pkey as oldPkey, d.pkey as fkey ;
2598 FROM (tcSDQDetailTable) d ;
2599 INTO CURSOR _WrkDtl READWRITE
2600
2601 lnHdrRecords = RECCOUNT("_WrkHdr")
2602 lnCmtRecords = RECCOUNT("_WrkCmt")
2603 lnDtlRecords = RECCOUNT("_WrkDtl")
2604
2605 lnLastHeaderPkey = v_NextPkey(tcHeaderPkeyTag, lnHdrRecords )
2606 lnLastCommentPkey = v_NextPkey(tcCommentPkeyTag, lnCmtRecords )
2607 lnLastDetailPkey = v_NextPkey(tcDetailPkeyTag, lnDtlRecords )
2608
2609 REPLACE ALL EDI_Store WITH STORE ;
2610 , store WITH "" ;
2611 , EDI_Center With Iif(!Empty(dedi_center), dedi_center,edi_center) ;
2612 , Pkey with (lnLastHeaderPkey - lnHdrRecords ) + RECNO() ;
2613 IN _WrkHdr
2614
2615 REPLACE ALL pkey WITH (lnLastDetailPkey - lnDtlRecords ) + RECNO();
2616 in _WrkDtl
2617
2618 REPLACE ALL pkey WITH (lnLastCommentPkey - lnCmtRecords ) + RECNO();
2619 IN _WrkCmt
2620
2621 SELECT _WrkHdr
2622 INDEX on Doc_Num+edi_store TAG docNoStore
2623 INDEX on Doc_Num TAG docNum
2624
2625 SELECT _WrkDtl
2626 INDEX on doc_num+store TAG docNostore
2627 SET ORDER TO 0
2628 SET ORDER TO docNoStore IN _WrkHdr
2629 SET RELATION OFF INTO _WrkHdr
2630 SET RELATION TO Doc_Num+store INTO _WrkHdr
2631 REPLACE ALL fkey WITH _WrkHdr.Pkey
2632 SET RELATION OFF INTO _WrkHdr
2633
2634 SELECT _WrkCmt
2635 SET ORDER TO docNoStore IN _WrkHdr
2636 SET RELATION OFF INTO _WrkHdr
2637 SET RELATION TO Doc_Num+store INTO _WrkHdr
2638 REPLACE ALL fkey WITH _WrkHdr.Pkey
2639 SET RELATION OFF INTO _WrkHdr
2640
2641 SELECT doc_num, store, COUNT(store) as scount, MAX(oldpkey) as mRecNO ;
2642 FROM _WrkDtl ;
2643 ORDER BY 1 ,2 ;
2644 GROUP BY 1 ,2 ;
2645 INTO CURSOR _WrkDtlH
2646
2647 SELECT _WrkDtlH
2648 SET ORDER TO docNostore IN _WrkDtl
2649 SCAN
2650 IF SEEK(_WrkDtlH.Doc_Num + _WrkDtlH.store,"_WrkDtl","docNostore")
2651 SELECT _WrkDtl
2652 REPLACE line_seq WITH str(_WrkDtlH.scount - _WrkDtlH.mRecNO + RECNO()) WHILE doc_num + store = _WrkDtlH.Doc_Num + _WrkDtlH.store
2653 ENDIF
2654 SELECT _WrkDtlH
2655 ENDSCAN
2656 SET ORDER TO 0 IN _WrkDtl
2657
2658 IF llSLN
2659
2660 SELECT s.*, s.fkey as oldFkey ;
2661 FROM (tcTransSLN) s ;
2662 INTO CURSOR _WrkSLN READWRITE
2663
2664 lnSlnRecords = RECCOUNT("_WrkSLN")
2665 lnLastSLNPkey = v_NextPkey(tcSLNPkeyTag, lnSlnRecords )
2666
2667 SELECT _WrkDtl
2668 INDEX on oldPkey TAG oldpkey
2669 SET ORDER TO oldpkey
2670
2671 SELECT _WrkSLN
2672 SET RELATION OFF INTO _WrkDtl
2673 SET RELATION TO oldfkey INTO _WrkDtl
2674
2675 REPLACE ALL pkey WITH (lnLastSLNPkey - lnSlnRecords ) + RECNO(),;
2676 fkey WITH _WrkDtl.Pkey ;
2677 IN _WrkSLN
2678
2679 SELECT Doc_Num, PO1_Line ;
2680 FROM _WrkDtl ;
2681 WHERE Doc_Num+PO1_Line NOT IN (SELECT STR(Doc_Num)+PO1_Line from (tcTransDetail) WITH (buff = .t.)) ;
2682 INTO CURSOR _msngDP
2683
2684 SELECT _msngDP
2685 SCAN
2686 .logEntry("No DOC_NUM, PO1_Line found for: " + Doc_Num + " | " + PO1_Line)
2687 ENDSCAN
2688
2689 ENDIF
2690
2691 SELECT _WrkHdr
2692
2693 SCAN
2694
2695 lnCurrentDoc_num = VAL(Doc_Num)
2696
2697 SELECT (tcTransHeader)
2698 If Seek(lnCurrentDoc_num,tcTransHeader,"doc_num")
2699 lcOrder = Set("Order")
2700 Set Order To Doc_Num
2701 Delete While Doc_Num = lnCurrentDoc_num
2702 set order to &lcOrder
2703 Endif
2704
2705 SELECT (tcTransComment)
2706 If Seek(lnCurrentDoc_num,tcTransComment,"doc_num")
2707 lcOrder = Set("Order")
2708 Set Order To Doc_Num
2709 Delete While Doc_Num = lnCurrentDoc_num
2710 set order to &lcOrder
2711 Endif
2712
2713 SELECT (tcTransDetail)
2714 If Seek(lnCurrentDoc_num,tcTransDetail,"doc_num")
2715 lcOrder = Set("Order")
2716 Set Order To Doc_Num
2717 Delete While Doc_Num = lnCurrentDoc_num
2718 set order to &lcOrder
2719 Endif
2720
2721 IF llSLN
2722 SELECT (tcTransSLN)
2723 If Seek(lnCurrentDoc_num,tcTransSLN,"doc_num")
2724 lcOrder = Set("Order")
2725 Set Order To Doc_Num
2726 Delete While Doc_Num = lnCurrentDoc_num
2727 set order to &lcOrder
2728 ENDIF
2729 ENDIF
2730
2731 SELECT _WrkHdr
2732
2733 ENDSCAN
2734
2735 SET ORDER TO 0 IN _WrkHdr
2736 SET ORDER TO 0 IN _WrkDtl
2737
2738 SELECT _WrkHdr
2739 lcDBFName = DBF()
2740 SELECT (tcTransHeader)
2741 APPEND FROM (lcDBFName)
2742
2743 SELECT _WrkCmt
2744 lcDBFName = DBF()
2745 SELECT (tcTransComment)
2746 APPEND FROM (lcDBFName)
2747
2748 SELECT _WrkDtl
2749 lcDBFName = DBF()
2750 SELECT (tcTransDetail)
2751 APPEND FROM (lcDBFName)
2752
2753 IF llSLN
2754 SELECT _WrkSLN
2755 lcDBFName = DBF()
2756 SELECT (tcTransSLN)
2757 APPEND FROM (lcDBFName)
2758 ENDIF
2759
2760 IF llSLN
2761 LOCAL laTables[6]
2762 laTables[6] = "_WrkSLN"
2763 ELSE
2764 LOCAL laTables[5]
2765 ENDIF
2766 laTables[1] = "_WrkHdr"
2767 laTables[2] = "_WrkDtl"
2768 laTables[3] = "_WrkCmt"
2769 laTables[4] = "_WrkDtlH"
2770 laTables[5] = "_msngDP"
2771 .TableClose(@laTables)
2772
2773 ELSE
2774
2775 *=== TechRec 1073148 06-Aug-2014 asharma ===
2776
2777 * number of SDQ Orders (by doc_num) to explode
2778 SELECT doc_num, pkey FROM (tcSDQDetailTable) INTO CURSOR tcSDQOrds GROUP BY doc_num
2779
2780 SELECT tcSDQOrds
2781 SCAN && group of SDQ orders (doc_num)
2782
2783 * The following _Wrk### will hold template orders to be expode to multiple base
2784 * on group by store,UPC,SKU in detail SDQ work table
2785 lcCurrentDoc_num= tcSDQOrds.doc_num
2786 SELECT * FROM (tcMetaWorkHeader) INTO CURSOR _WrkHdr WHERE doc_num= lcCurrentDoc_num
2787 SELECT * FROM (tcMetaWorkComment) INTO CURSOR _WrkCmt WHERE doc_num= lcCurrentDoc_num
2788
2789 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2790 Select * From (tcMetaWorkAddress) Into Cursor _WrkAdr Where doc_num= lcCurrentDoc_num
2791 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2792
2793 SELECT * FROM (tcSDQDetailTable) INTO CURSOR _WrkDtl WHERE doc_num= lcCurrentDoc_num ;
2794 ORDER BY STORE, upc, sku, ean
2795
2796 * Get current header image into Memvar (only one per doc_num)
2797 SELECT _WrkHdr
2798 SCATT MEMVAR MEMO
2799 lnCurrentStart_date= m.start_date
2800 lnCurrentEnd_Date= m.end_date
2801
2802 * Get pkey for ALL headers (ZZEIPCTH- tag)
2803 SELECT STORE FROM _WrkDtl GROUP BY STORE INTO CURSOR tcHdrCnt
2804 lnOrdersHeaderToExplode = RECC("tcHdrCnt")
2805 USE IN tcHdrCnt
2806 lnLastHeaderPkey = v_NextPkey(tcHeaderPkeyTag, lnOrdersHeaderToExplode)
2807
2808 * Get pkey for ALL detail we're about to create (ZZEIPCID- tag)
2809 lnOrdersLineToExplode = RECC("_WrkDtl")
2810 lnLastDetailPkey = v_NextPkey(tcDetailPkeyTag, lnOrdersLineToExplode)
2811
2812 * Get pkey for ALL order comments we're about to create (ZZEIPOID- tag)
2813 lnTotalCommentLines = RECC("_WrkCmt")
2814 IF lnTotalCommentLines>0
2815 lnLastCommentPkey = v_NextPkey(tcCommentPkeyTag, lnOrdersHeaderToExplode * lnTotalCommentLines)
2816 lnCurrentCommentLines = 0
2817 ENDIF
2818
2819 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2820 lnTotalAddressLines = Recc("_WrkAdr")
2821 If lnTotalAddressLines>0
2822 lnLastAddressPkey = v_NextPkey(tcAddressPkeyTag, lnOrdersHeaderToExplode * lnTotalAddressLines)
2823 lnCurrentAddressLines = 0
2824 Endif
2825 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2826
2827 lnHdrCnt = 0
2828 lnDtlCnt = 0
2829 lnOrd_qty = 0
2830 lcPreviousStore = ""
2831 SELECT _WrkDtl
2832
2833 SCAN
2834 * restore header start/end_date back (SDQ explotion order all start/end-date same
2835 * as the template header
2836 m.start_date= lnCurrentStart_date
2837 m.end_date= lnCurrentEnd_Date
2838
2839 * start of store level break*********************************************************
2840 * Each time store change create order header
2841 IF !(STORE == lcPreviousStore)
2842 lnHdrCnt = lnHdrCnt + 1
2843 *
2844 * Calc next pkey b/c we got all of them at once
2845 lnCurrentHeaderPkey = (lnLastHeaderPkey - lnOrdersHeaderToExplode) + lnHdrCnt
2846 m.pkey = lnCurrentHeaderPkey && header pkey
2847 m.Store = _WrkDtl.STORE && assign header store with explode store
2848
2849 lnLine_seq = 0 && reset lnLine_seq
2850 * replace ord_qty for current order header
2851 * before insert a new order header
2852 * For order header does not need to accumulate as in Multi-store
2853 * will be recalculate before stuff to live tables
2854 SELECT TargetWH
2855 APPEND BLANK
2856 GATHER MEMVAR MEMO
2857
2858 * Exchange store with EDI_Store
2859 *--- TechRec 1061414 01-Oct-2012 TShenbagavalli ---
2860 *REPLACE EDI_Store WITH STORE, STORE WITH "" IN TargetWH
2861 REPLACE EDI_Store WITH STORE, ;
2862 STORE WITH "", ;
2863 EDI_Center With Iif(!Empty(_WrkDtl.edi_center), _WrkDtl.edi_center,_WrkHdr.edi_center) ;
2864 IN TargetWH
2865 *=== TechRec 1061414 01-Oct-2012 TShenbagavalli ===
2866
2867 IF lnTotalCommentLines>0
2868 * use current comment lines for pkey calculation smallest pkey 1st
2869 SELECT _WrkCmt
2870 SCAN
2871 SCATT MEMVAR MEMO
2872 lnCurrentCommentLines = lnCurrentCommentLines + 1
2873 m.pkey = (lnLastCommentPkey - (lnOrdersHeaderToExplode * lnTotalCommentLines)) + ;
2874 lnCurrentCommentLines
2875 m.fkey = lnCurrentHeaderPkey
2876 SELECT TargetWC
2877 APPEND BLANK
2878 GATHER MEMVAR MEMO
2879 ENDSCAN
2880 ENDIF
2881
2882 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
2883 If lnTotalAddressLines>0
2884 * use current Address lines for pkey calculation smallest pkey 1st
2885 Select _WrkAdr
2886 Scan
2887 Scatt Memvar Memo
2888 lnCurrentAddressLines = lnCurrentAddressLines + 1
2889 m.Pkey = (lnLastAddressPkey - (lnOrdersHeaderToExplode * lnTotalAddressLines)) + ;
2890 lnCurrentAddressLines
2891 m.Fkey = lnCurrentHeaderPkey
2892 Select TargetWA
2893 Append Blank
2894 Gather Memvar Memo
2895 Endscan
2896 Endif
2897 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
2898
2899 * keep track of Previous Store
2900 lcPreviousStore = m.Store
2901 ENDIF && End of store level break****************************************************
2902
2903 *Create order detail using template _WrkDtl (combine of DTL+SDQ)
2904 SELECT _WrkDtl
2905 lnDtlCnt = lnDtlCnt + 1
2906 SCATTER MEMVAR MEMO
2907
2908 m.fkey = lnCurrentHeaderPkey && Sync detail fkey with header pkey
2909 m.pkey = (lnLastDetailPkey - lnOrdersLineToExplode) + lnDtlCnt && Detail pkey
2910
2911 lnLine_seq = lnLine_seq + 1 && incr. lnLine_seq
2912 m.line_seq = lnLine_seq && next line_seq
2913 SELECT TargetWD
2914 APPEND BLANK
2915 GATHER MEMVAR MEMO
2916
2917 * --- TR 1047609 7/7/10 CM
2918 If llSLN
2919 lnNewDtlPKey = m.pkey
2920 lcPO1_Line = PO1_Line
2921 lcDoc_Num = Doc_Num
2922 Select (tcTransDetail)
2923 If Not Seek(Str(lcDoc_Num) + lcPO1_Line,tcTransDetail,"PO1_Line")
2924 .logEntry("No DOC_NUM, PO1_Line found for: " + Transform(lcDoc_Num) + " | " + lcPO1_Line)
2925 Endif
2926 lnOldDtlPKey = Pkey
2927 lnOldHdrPKey = Fkey
2928
2929 If llSLN
2930 Select (tcTransSLN)
2931 lnCnt = 0
2932 If Seek(lnOldDtlPKey,tcTransSLN,"fkey")
2933 lcOrder = Set("Order")
2934 Set Order To Tag Fkey
2935 Scan While Fkey = lnOldDtlPKey
2936 Scatter Memvar Memo
2937 Select TargetSLN
2938 Append Blank
2939 Gather Memvar Memo
2940 lnCnt = lnCnt + 1
2941 Replace Fkey With lnNewDtlPKey
2942 Endscan
2943 Set Order To &lcOrder
2944 Endif
2945 If lnCnt > 0
2946 m.Pkey = v_NextPkey(tcSLNPkeyTag, lnCnt) + 1
2947 Select TargetSLN
2948 For i = 1 To lnCnt
2949 Replace Pkey With m.Pkey - i
2950 Skip -1
2951 Endfor
2952 Endif
2953 EndIf
2954 Endif
2955 * === TR 1047609 7/7/10 CM
2956
2957 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
2958 If llWhsData
2959 Select (lcTransWhse)
2960 lnCnt = 0
2961 If Seek(lnOldDtlPKey,lcTransWhse,"dFKey")
2962 lcOrder = Set("Order")
2963 Set Order To Tag dfkey
2964 Scan While dfkey = lnOldDtlPKey
2965 lnOldHdrPKey = hfkey
2966 Scatter Memvar Memo
2967 m.store = _WrkDtl.Store
2968 Select TargetWhse
2969 Append Blank
2970 Gather Memvar Memo
2971 lnCnt = lnCnt + 1
2972 Replace dfkey With lnNewDtlPKey, ;
2973 hfkey With lnCurrentHeaderPkey
2974 Endscan
2975 Set Order To &lcOrder
2976 ENDIF
2977
2978 IF llFirstDetail
2979 lcSeek = Alltrim(Str(lnOldHdrPKey)) + "0"
2980 If SEEK(lcSeek, lcTransWhse, "h_dfkey")
2981 lcOrder = SET("Order")
2982 SET ORDER TO TAG hfkey
2983 SCAN WHILE hfkey = lnOldHdrPKey And dfkey = 0
2984 SCATTER MEMVAR MEMO
2985 SELECT TargetWhse
2986 APPEND BLANK
2987 GATHER MEMVAR MEMO
2988 lnCnt = lnCnt + 1
2989 REPLACE dfkey WITH 0, ;
2990 hfkey WITH lnCurrentHeaderPkey
2991 ENDSCAN
2992 SET ORDER TO &lcOrder
2993 ENDIF
2994 ENDIF
2995 llFirstDetail = False
2996
2997 If lnCnt > 0
2998 m.PKey = v_NextPkey("ZZEIPCTWHSE", lnCnt) + 1
2999 Select TargetWhse
3000 For i = 1 To lnCnt
3001 Replace PKey With m.PKey - i
3002 Skip -1
3003 EndFor
3004 Endif
3005 ENDIF
3006 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3007
3008 ENDSCAN
3009
3010 * Delete Template order
3011 lnCurrentDoc_num=VAL(lcCurrentDoc_num)
3012 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransHeader)
3013 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransDetail)
3014 *- 1015091 01/13/06 YIK
3015 *-Delete For doc_num=lnCurrentDoc_num In (tcInterfaceComment)
3016 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransComment)
3017
3018 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3019 DELETE FOR doc_num=lnCurrentDoc_num IN (tcTransAddress)
3020 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3021
3022 * --- TR 1047609 7/7/10 CM
3023 If llSLN
3024 Select (tcTransSLN)
3025 If Seek(lnCurrentDoc_num,tcTransSLN,"doc_num")
3026 lcOrder = Set("Order")
3027 Set Order To Doc_Num
3028 Delete While Doc_Num = lnCurrentDoc_num
3029 set order to &lcOrder
3030 Endif
3031 Endif
3032 * === TR 1047609 7/7/10 CM
3033
3034 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3035 IF llWhsData
3036 Select (lcTransWhse)
3037 If Seek(lnCurrentDoc_num,lcTransWhse,"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
3044 ENDIF
3045 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3046
3047 ENDSCAN && all doc_num,store,upc,sku
3048
3049 * Append all exploded orders into Interfact tables
3050 SELECT TargetWH
3051 lcDBFName = DBF()
3052 SELECT (tcTransHeader)
3053 APPEND FROM (lcDBFName)
3054 SELECT TargetWD
3055 lcDBFName = DBF()
3056 SELECT (tcTransDetail)
3057 APPEND FROM (lcDBFName)
3058 SELECT TargetWC
3059 lcDBFName = DBF()
3060 SELECT (tcTransComment)
3061 APPEND FROM (lcDBFName)
3062
3063 * --- TR 1047609 7/7/10 CM
3064 IF llSLN
3065 Select (tcTransSLN)
3066 Append From Dbf("TargetSLN")
3067 Endif
3068 * === TR 1047609 7/7/10 CM
3069
3070 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3071 Select TargetWA
3072 lcDBFName = Dbf()
3073 Select (tcTransAddress)
3074 Append From (lcDBFName)
3075
3076 If llWhsData
3077 Select (lcTransWhse)
3078 Append From (Dbf("TargetWhse"))
3079 ENDIF
3080 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3081
3082 SELECT _WrkHdr
3083 SCATT MEMVAR MEMO BLANK
3084 SELECT _WrkDtl
3085 SCATT MEMVAR MEMO BLANK
3086 SELECT _WrkCmt
3087 SCATT MEMVAR MEMO BLANK
3088
3089 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
3090 Select _WrkAdr
3091 Scatter Memvar Memo Blank
3092 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
3093
3094 * cleanup temp tables
3095 * --- TR 1047609 7/7/10
3096 * Changed dimension from 6 to 7
3097 &&--- TechRec 1073591 23-Oct-2013 TShenbagavalli changed dimension from 7 to 10 ===
3098 LOCAL laTables[10]
3099 laTables[1] = "TargetWH"
3100 laTables[2] = "TargetWD"
3101 laTables[3] = "_WrkHdr"
3102 laTables[4] = "_WrkDtl"
3103 laTables[5] = "TargetWC"
3104 laTables[6] = "_WrkCmt"
3105
3106 * --- TR 1047609 7/7/10 CM
3107 laTables[7] = "TargetSLN"
3108 * === TR 1047609 7/7/10 CM
3109
3110 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3111 laTables[8] = "TargetWA"
3112 laTables[9] = "_WrkAdr"
3113 laTables[10]= "TargetWhse"
3114 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3115
3116 .TableClose(@laTables)
3117
3118 ENDIF &&--- TechRec 1073148 06-Aug-2014 asharma ===
3119
3120 ENDWITH
3121
3122 SELECT (lnOldSele)
3123 RETURN llRetVal
3124 ENDPROC
3125
3126 PROCEDURE LoadHeaderDetailNotes
3127 *--- TR 1016589 05/05/06 NH adding parameter tcTransHdrNotes, tcTransDtlNotes, tcDocCount
3128 PARAMETER tcHNTFlatFile, tcDNTFlatFile, tcTransHeader, tcTransDetail, tcTransHdrNotes, tcTransDtlNotes, tcDocCount
3129 LOCAL llRetVal, lnOldSelect, lcNotes, llHaveNotes, lcCurrDoc_num, lcCurrNote_type
3130 llRetVal = .T.
3131 lnOldSelect = SELECT()
3132 *--- TR 1016589 NH 05/05/06 NH
3133 LOCAL llRetVal, lnOldSelect, lcNotes, llHaveNotes, lcCurrDoc_num, lcCurrNote_type, lcUser_ID, ltLast_mod, lnSeq
3134 lcUser_ID = EDI_USER
3135 ltLast_mod = DATETIME()
3136 lnSeq = 0
3137 *==== TR 1016589 NH
3138
3139 WITH THIS
3140 * Accumulate all notes per doc_num and write them in proper
3141 * Header notes record
3142 IF THIS.CountTotalRecs (tcHNTFlatFile)>0
3143 .oLog.LogEntry("Loading header notes.")
3144 lcNotes= ""
3145 lcCurrDoc_num= ""
3146 lcCurrNote_type = ""
3147
3148 llHaveNotes= .F.
3149 SELECT (tcHNTFlatFile)
3150 INDEX ON doc_num + note_type TAG doc_num
3151 SCAN
3152 IF lcCurrDoc_num= doc_num AND lcCurrNote_type = note_type
3153 IF !EMPTY(notes)
3154 *--- TR 1016589 NH : Use all trim to remove empty space
3155 lcNotes= lcNotes + ALLTRIM(notes) + CRLF && Accumulate all notes lines
3156 llHaveNotes= .T.
3157 ENDIF
3158 ELSE
3159 IF llHaveNotes
3160 *--- TR 1016589 NH
3161 lnSeq = lnSeq + 1
3162 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3163*!* .WriteNotes(lcCurrDoc_num, tcTransHeader, "doc_num", lcNotes , ;
3164*!* "allt((str(doc_num))) = '" + ALLT(lcCurrDoc_num) + "'")
3165 .WriteHdrSysNotes(lcCurrDoc_num, VAL(ALLT(lcCurrDoc_num)), ;
3166 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
3167 tcTransHdrNotes, tcTransHeader, lnDoc_count)
3168 *=== TR 1016589 NH
3169 ENDIF
3170 *--- TR 1016589 NH
3171 IF NOT lcCurrDoc_num = doc_num
3172 lnSeq = 0
3173 ENDIF
3174 *=== TR 101689 NH
3175 lcCurrDoc_num= doc_num
3176 lcCurrNote_type = note_type
3177
3178 IF !EMPTY(notes)
3179 *---- TR 1016589 NH
3180*!* SELECT COUNT(*) FROM &tcHNTFlatFile ;
3181*!* WHERE !EMPTY(note_type) AND doc_num = lcCurrDoc_num ;
3182*!* INTO ARRAY laNT
3183*!* llHasNoteType = (laNT[1] > 0)
3184*!* IF llHasNoteType
3185*!* lcNotes = IIF(!EMPTY(lcNotes), "|", "") + ;
3186*!* IIF(EMPTY(lcCurrNote_type), "EDI", lcCurrNote_type) + "|" + notes + CRLF
3187*!* ELSE
3188*!* lcNotes= notes + CRLF && Accumulate all notes lines
3189*!* ENDIF
3190 *=
3191 lcNotes = ALLTRIM(notes) + CRLF && Accumulate all notes lines
3192 *=== TR 1016589 NH
3193 llHaveNotes= .T.
3194 ELSE
3195 llHaveNotes= .F.
3196 ENDIF
3197 ENDIF
3198 ENDSCAN
3199 IF llHaveNotes
3200 *--- TR 1016589 NH
3201 lnSeq = lnSeq + 1
3202*!* .WriteNotes(lcCurrDoc_num, tcTransHeader, "doc_num", lcNotes, ;
3203*!* "allt((str(doc_num))) = '" + ALLT(lcCurrDoc_num) + "'" ) && 29656
3204 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3205 .WriteHdrSysNotes(lcCurrDoc_num, VAL(ALLT(lcCurrDoc_num)) , ;
3206 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
3207 tcTransHdrNotes, tcTransHeader, lnDoc_count)
3208
3209 *=== TR 1016589 NH
3210 ENDIF
3211 ENDIF
3212
3213 IF THIS.CountTotalRecs (tcDNTFlatFile)>0
3214 .oLog.LogEntry("Loading detail notes.")
3215 lcNotes= ""
3216 lcCurrCkey= ""
3217 *--- TR 1016589 NH
3218 lcCurrNote_type = ""
3219 lcCurrDoc_num = ""
3220 *=== TR 1016589 NH
3221 llHaveNotes= .F.
3222 SELECT (tcDNTFlatFile)
3223 INDEX ON ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) TAG Ckey
3224 SCAN
3225 *--- TR 1016589 NH Added condition : lcCurrNote_type = note_type
3226 IF lcCurrCkey= ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean) AND lcCurrNote_type = note_type
3227 IF !EMPTY(notes)
3228 *--- TR 1016589 NH : Remove space
3229 lcNotes= lcNotes + ALLTRIM(notes) + CRLF && Accumulate all notes lines
3230 llHaveNotes= .T.
3231 ENDIF
3232 ELSE
3233 IF llHaveNotes
3234 *--- TR 1016589 NH
3235 lnSeq = lnSeq + 1
3236*!* .WriteNotes(lcCurrCkey, tcTransDetail, "CKey", lcNotes, ;
3237*!* "allt(str(doc_num))+allt(upc)+allt(sku)+allt(ean) = '" + ALLT(lcCurrCkey) + "'")
3238 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3239 .WriteDtlSysNotes(ALLT(lcCurrCkey),;
3240 "Ckey",lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod,lnSeq,;
3241 tcTransDtlNotes, tcTransDetail, lnDoc_count)
3242 *=== TR 1016589 NH
3243 ENDIF
3244 *--- TR 1016589 NH
3245 IF NOT lcCurrCkey = ALLTRIM(doc_num)+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean)
3246 lnSeq = 0
3247 ENDIF
3248 lcCurrDoc_num = ALLTRIM(doc_num)
3249 *=== TR 1016589 NH
3250 lcCurrCkey= ALLTRIM(STR(VAL(doc_num)))+ALLTRIM(upc)+ALLTRIM(sku)+ALLTRIM(ean)
3251 IF !EMPTY(notes)
3252 *--- TR 1016589 NH : Removing space
3253 lcNotes= ALLTRIM(notes) + CRLF && Accumulate all notes lines
3254 llHaveNotes= .T.
3255 ELSE
3256 llHaveNotes= .F.
3257 ENDIF
3258 ENDIF
3259 ENDSCAN
3260
3261 IF llHaveNotes
3262 *--- TR 1016589 NH
3263*!* .WriteNotes(lcCurrCkey, tcTransDetail, "CKey", lcNotes, ;
3264*!* "allt(str(doc_num))+allt(upc)+allt(sku)+allt(ean) = '" + ALLT(lcCurrCkey) + "'")
3265 lnSeq = lnSeq + 1
3266 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
3267 .WriteDtlSysNotes(ALLT(lcCurrCkey),;
3268 "Ckey", lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod,lnSeq,;
3269 tcTransDtlNotes, tcTransDetail, lnDoc_count)
3270 *=== TR 1016589 NH
3271 ENDIF
3272 ENDIF
3273
3274 ENDWITH
3275 SELECT(lnOldSelect)
3276 RETURN llRetVal
3277 ENDPROC
3278
3279 ************************************************************************************
3280
3281 PROCEDURE WriteNotes
3282 PARAMETER tcCurrKey, tcTransTable , tcTag, tcNotes, tcSameKeys
3283 LOCAL llRetVal, lnOldSelect
3284 lnOldSelect= SELECT()
3285 llRetVal= .T.
3286 SELECT (tcTransTable)
3287 SET ORDER TO tcTag
3288 IF SEEK(tcCurrKey, tcTransTable, tcTag)
3289 SCAN WHILE &tcSameKeys
3290 REPLACE notes WITH ALLTRIM(notes) + tcNotes ;
3291 IN (tcTransTable)
3292 ENDSCAN
3293 SET ORDER TO
3294 ENDIF
3295 SELECT(lnOldSelect)
3296 RETURN llRetVal
3297 ENDPROC
3298
3299 *--- TR 1016589 NH 05/05/06
3300 ************************************************************************************
3301
3302 PROCEDURE GetDocNumCount
3303 LPARAMETERS tcDocCount, tcDoc_num
3304
3305 LOCAL lnDoc_count, lnOldSelect
3306 lnOldSelect = SELECT()
3307 lnDoc_count = 1
3308 IF NOT EMPTY(tcDocCount) && if there is SDQ (multi orders with same doc_num)
3309 SELECT (tcDocCount)
3310 IF SEEK(tcDoc_num)
3311 lnDoc_count = Doc_count
3312 ENDIF
3313 ENDIF
3314
3315 SELECT(lnOldSelect)
3316 RETURN lnDoc_count
3317 ENDPROC
3318
3319 ***********************************************************************************
3320
3321 PROCEDURE CreateDocStoreCursor
3322 LPARAMETERS tcDtl_SDQ, tcDocCount
3323 LOCAL lnOldSelect, llRetVal
3324
3325 llRetVal = .t.
3326 lnOldSelect = SELECT()
3327 lcDocCountTmp = tcDocCount + "_TMP"
3328 *--- narrow down to doc_num and store
3329 SELECT DISTINCT doc_num, store FROM (tcDTl_SDQ) INTO CURSOR (lcDocCountTmp)
3330 *--- find the number of stores for each doc_num this will be used to create Notes pkey
3331 SELECT doc_num, count(*) as Doc_count FROM (lcDocCountTmp) GROUP BY doc_num INTO CURSOR (tcDocCount)
3332 INDEX ON doc_num TAG doc_num
3333 IF USED(lcDocCountTmp)
3334 USE IN (lcDocCountTmp)
3335 ENDIF
3336 SELECT(lnOldSelect)
3337 RETURN llRetVal
3338 ENDPROC
3339
3340 ***********************************************************************************
3341
3342 PROCEDURE WriteHdrSysNotes
3343 LPARAMETERS tcDoc_num, tcExpr, tcNote_type, tcNotes, tcuser_id, ttLast_mod, tnSeq, tcInterfaceHdrNotes, tcInterfaceHdr, tnDocCount)
3344 LOCAL lnOldSelect, llRetVal, lcHdrPkey, lcExpr, lnPkey
3345 LOCAL lnMaxPkey
3346 lnOldSelect = SELECT()
3347 llRetVal = .T.
3348 lcExpr = tcExpr
3349
3350 SELECT (tcInterfaceHdr)
3351 SET ORDER TO TAG doc_num
3352 lnMaxPkey = v_nextPkey('sysnotes', tnDocCount)
3353 lnPkey = lnMaxPkey - tnDocCount
3354 SELECT (tcInterfaceHdr)
3355 IF SEEK (lcExpr)
3356 SCAN WHILE doc_num = tcExpr
3357 lcHdrPkey = pkey
3358 lnPkey = lnPkey + 1
3359 IF lnPkey > lnMaxPkey
3360 *--- It should not come to this point. But in case it does, pkey will not over lap.
3361 lnPkey = v_nextPkey('sysnotes')
3362 ENDIF
3363 SELECT(tcInterfaceHdrNotes)
3364 APPEND BLANK
3365 SCATTER NAME loHdrNotes MEMO BLANK
3366 loHdrNotes.table_Name = "ZZEIPCTH"
3367 loHdrNotes.fkey = lcHdrPkey
3368 loHdrNotes.note_type = IIF(EMPTY(tcNote_type),"EDI",tcNote_type)
3369 loHdrNotes.notes = tcNotes
3370 loHdrNotes.Last_mod = ttLast_mod
3371 loHdrNotes.User_id = tcuser_id
3372 loHdrNotes.Seq = tnSeq
3373 loHdrNotes.pkey = lnPkey
3374 loHdrNotes.CascadeNote = 'N'
3375 loHdrNotes.COMMENT = "DEFAULT"
3376 loHdrNotes.note_date = ttLast_mod
3377 GATHER NAME loHdrNotes MEMO
3378 ENDSCAN
3379 ENDIF
3380 SELECT(lnOldSelect)
3381 RETURN llRetVal
3382 ENDPROC
3383
3384 ***********************************************************************************
3385
3386 PROCEDURE WriteDtlSysNotes
3387 LPARAMETERS tcExpr, tcOrderby, tcNote_type, tcNotes, tcuser_id,;
3388 ttLast_mod, tnSeq, tcInterfaceDtlNotes, tcInterfaceDtl, tnDoc_count)
3389
3390 LOCAL lnOldSelect, llRetVal, lcDtlPkey, lcHdrPkey, lcExpr, lnPkey, lnLine_seq
3391 lnOldSelect = SELECT()
3392 llRetVal = .T.
3393 lcExpr = tcExpr
3394 lnLine_seq = 0
3395 *--- collect pkey form tcInterfaceHdr
3396 SELECT (tcInterfaceDtl)
3397 SET ORDER TO (tcOrderby)
3398 IF SEEK (lcExpr)
3399 LOCAL lcFlds
3400 lcFlds = SYS(14,VAL(SYS(21)))
3401 lnMaxPkey = v_nextPkey('sysnotes', tnDoc_count)
3402 lnPkey = lnMaxPkey - tnDoc_count
3403 SCAN WHILE &lcFlds == tcExpr
3404 lnPkey = lnPkey + 1
3405 *--- this is only when flat file has multiple UPCs for same doc_num
3406 *--- also, when same store is used multiple times at SDQ
3407 IF lnPkey > lnMaxPkey
3408 lnPkey = v_nextPkey('sysnotes')
3409 ENDIF
3410 lcHdrPkey = fkey
3411 lcDtlPkey = pkey
3412 lnLine_seq = line_seq
3413 SELECT(tcInterfaceDtlNotes)
3414 APPEND BLANK
3415 SCATTER NAME loDtlNotes MEMO BLANK
3416 loDtlNotes.table_Name = "ZZEIPCTD"
3417 loDtlNotes.fkey = lcDtlPkey
3418 loDtlNotes.parentkey = lcHdrPkey
3419 loDtlNotes.note_type = IIF(EMPTY(tcNote_type),"EDI",tcNote_type)
3420 loDtlNotes.notes = tcNotes
3421 loDtlNotes.Last_mod = ttLast_mod
3422 loDtlNotes.User_id = tcuser_id
3423 loDtlNotes.Seq = tnSeq
3424 loDtlNotes.pkey = lnPkey
3425 loDtlNotes.CascadeNote = 'N'
3426 loDtlNotes.COMMENT = "DEFAULT"
3427 loDtlNotes.line_seq = lnLine_seq
3428 loDtlNotes.note_date = ttLast_mod
3429 GATHER NAME loDtlNotes MEMO
3430 ENDSCAN
3431 ENDIF
3432
3433 SELECT(lnOldSelect)
3434 RETURN llRetVal
3435 ENDPROC
3436
3437 ***********************************************************************************
3438 *=== TR 1016589 NH 05/05/06
3439
3440 PROCEDURE PreValidation
3441 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3442 *--- TR 1050827 24-NOV-2010 HNISAR && Added plSkipSLNUpdate
3443 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
3444 PARAMETERS pceipcTH, pceipcTD, pceipcCR, pceipcTS,plSkipSLNUpdate, pceipcTWHSE
3445 LOCAL llRetVal, lcSQLSelect, lcSQLOrder
3446 llRetVal = .T.
3447 WITH THIS
3448 .LogMajorStage("Validating transactions.") && TR 1016560 NH
3449 .oLog.LogEntry("Resetting all error messages in transaction tables.")
3450 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", ;
3451 vcLogName)
3452
3453 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3454 *llRetVal= llRetVal AND .ClearErrors(pceipcTH, pceipcTD)
3455 llRetVal= llRetVal AND .ClearErrors(pceipcTH, pceipcTD, pceipcTS)
3456 * === TR 1047609 7/7/10 CM
3457
3458 .AdvanceThermoTotalWithCaptionPlus("Validating Customer, Store...", ;
3459 vcLogName)
3460 llRetVal= llRetVal AND .CheckHeader(pceipcTH, pceipcCR, pceipcTD) &&--- TR 1036066 NH
3461 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU...", ;
3462 vcLogName)
3463
3464 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3465 *llRetVal= llRetVal AND .CheckDetail(pceipcTH, pceipcTD, pceipcCR)
3466 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceiPCTWhse ===
3467 llRetVal= llRetVal AND .CheckDetail(pceipcTH, pceipcTD, pceipcCR, pceipcTS, pceiPCTWhse)
3468 * === TR 1047609 7/7/10 CM
3469
3470 .AdvanceThermoTotalWithCaptionPlus("Updating header division from detail...", ;
3471 vcLogName)
3472 llRetVal= llRetVal AND .UpdtHeaderDivs(pceipcTH, pceipcTD)
3473
3474 *--- TR 1023071 04/03/07 NH
3475 *--- TR 1048865 23-Mar-2011 Goutam. Deleted following and moved to CheckHeader
3476*!* .LogEntry("Populating division for transaction header with no detail.")
3477*!* llRetVal = llRetVal and .CheckPoAndPopulateHdrDivision(pceipcTH)
3478*!* .LogEntry("Populating division for transaction header with no detail " + IIF(llRetVal,"completed.","failed."))
3479 *=== TR 1048865 23-Mar-2011 Goutam
3480
3481 *=== 1023071 04/03/07 NH
3482
3483 .AdvanceThermoTotalWithCaptionPlus("Populating implosion flag to transaction header.")
3484 .LogEntry("Populating implosion flag to transaction header.")
3485 llRetVal = llRetVal AND .PopulatingImplosionFlag(pceipcTH, pceipcCR)
3486
3487 *--- TR 1016560 NH
3488 *--- TR 1047609 7/7/10 CM --- Added tcEiPCts
3489 *llRetVal = llRetVal and .TableUpdateTransaction("tcEiPCth", "tcEiPCtd", "tcEiPCtC")
3490 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added tceipcTWHSE ===
3491 llRetVal = llRetVal and .TableUpdateTransaction("tcEiPCth", "tcEiPCtd", "tcEiPCtC", "", "", "tcEiPCts",plSkipSLNUpdate,"tceipcTWHSE")
3492 *=== TR 1016560 NH
3493
3494 ENDWITH
3495 RETURN llRetVal
3496 ENDPROC
3497
3498
3499 *--- TR 1017209 NH
3500 ********************************************************************************
3501 PROCEDURE UpdateAutoProcFlag
3502 LPARAMETERS pceIPCth, pceIPCcr
3503 LOCAL llRetVal, lnOldSelect
3504 llRetVal = .t.
3505 lnOldSelect = SELECT()
3506 SELECT(pceIPCth)
3507 SCAN
3508
3509 *--- TR 1072834 22-Aug-2013 Goutam
3510*!* *--- TR 1048865 27-Dec-2010 Goutam
3511*!* *IF EMPTY(auto_proc) AND SEEK(division+customer,pceIPCcr,'divcust')
3512*!* IF EMPTY(auto_proc) AND SEEK(cr_pkey,pceIPCcr,'pkey')
3513*!* *=== TR 1048865 27-Dec-2010 Goutam
3514
3515*!* replace auto_proc with zzeipccr.auto_proc IN (pceIPCth)
3516*!* ENDIF
3517
3518 IF SEEK(cr_pkey, pceIPCcr, 'pkey')
3519 IF EMPTY(auto_proc)
3520 replace auto_proc with zzeipccr.auto_proc IN (pceIPCth)
3521 ENDIF
3522 IF EMPTY(ignore_warn)
3523 replace ignore_warn with zzeipccr.ignore_warn IN (pceIPCth)
3524 ENDIF
3525 ENDIF
3526 *=== TR 1072834 22-Aug-2013 Goutam
3527
3528 ENDSCAN
3529
3530 SELECT(lnOldSelect)
3531 RETURN llRetVal
3532 ENDPROC
3533 **********************************************************************************
3534 *=== TR 1017209 NH
3535
3536 ************************************************************************************
3537 * Clear all previous errors
3538 ************************************************************************************
3539 PROCEDURE ClearErrors
3540 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
3541 LPARAMETERS pceipcTH, pceipcTD, pceipcTS
3542 LOCAL llRetVal, lnOldSelect, laTables[2]
3543 llRetVal = .T.
3544 lnOldSelect = SELECT()
3545
3546 REPLACE ALL Errs_msg_H WITH "", Errs_flg_h WITH "N" IN (pceipcTH)
3547 REPLACE ALL Errs_Msg_D WITH "", Errs_Flg_D WITH "N" IN (pceipcTD)
3548 REPLACE Errs_Msg_D WITH "SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_D WITH "Y" ;
3549 FOR EMPTY(sku) AND EMPTY(upc) AND EMPTY(ean) AND EMPTY(size_desc) IN (pceipcTD)
3550
3551 * --- TR 1047609 7/7/10 CM
3552 Replace All Errs_Msg_S With "", Errs_Flg_S With "N" In (pceipcTS)
3553 Replace Errs_Msg_S With "SLN SKU and UPC/EAN are both missing." + CRLF, Errs_Flg_S With "Y" ;
3554 For Empty(SLN_SKU) And Empty(SLN_UPC) And Empty(SLN_EAN) And Empty(size_desc) In (pceipcTS)
3555 * === TR 1047609 7/7/10 CM
3556
3557 *--- TR 1072834 20-Aug-2013 Goutam
3558 REPLACE ALL warn_msg_H WITH "", warn_flg_h WITH "N" IN (pceipcTH)
3559 REPLACE ALL warn_Msg_D WITH "", warn_Flg_D WITH "N" IN (pceipcTD)
3560 *=== TR 1072834 20-Aug-2013 Goutam
3561
3562 SELECT(lnOldSelect)
3563 RETURN llRetVal
3564 ENDPROC
3565
3566 ************************************************************************************
3567 * Error check EDI headers
3568 ************************************************************************************
3569 PROCEDURE CheckHeader
3570 LPARAMETERS pceipcTH, pceipcCR,pceipcTD
3571 LOCAL llRetVal, lnOldSelect, llCustOk, llDeptOk, llStorOk, llCntrOk, llTermOk
3572 llRetVal = .T.
3573 lnOldSelect = SELECT()
3574 WITH THIS
3575 .oLog.LogEntry("Getting customer code using trading partner ID/Qualifier.")
3576 *--- TR 1027724 NH
3577 *llRetVal= .FindCustomerUsingTradingPartnerID(pceipcTH,"IPC") && TR 1016904 - send ipc as second param
3578 llRetVal = llRetVal AND this.UpdateCustomerUsingTrandingPartnerID(pceipcTH)
3579 *=== TR 1027724 NH
3580 IF llRetVal
3581
3582 .oLog.LogEntry("Validating Customer.")
3583 llRetVal= .CheckCustomer(pceipcTH)
3584 IF llRetVal
3585
3586 *--- TR 1048865 23-Mar-2011 Goutam
3587 .LogEntry("Populating division for transaction header with no detail.")
3588 llRetVal = .CheckPoAndPopulateHdrDivision(pceipcTH, pceipcTD, pceipcCR)
3589 .LogEntry("Populating division for transaction header with no detail " + IIF(llRetVal,"completed.","failed."))
3590
3591 .oLog.LogEntry("Validating EDI store.")
3592
3593 *--- TR 1048865 23-Mar-2011 Goutam
3594 *llRetVal= .CheckStore(pceipcTH, pceipcCR)
3595 llRetVal= llRetVal and .CheckStore(pceipcTH, pceipcCR)
3596 *=== TR 1048865 23-Mar-2011 Goutam
3597
3598 IF llRetVal
3599 *- We are not doing it
3600
3601 *--- TR 1062197 7-Sep-2012 Goutam. Uncommented below portion of code
3602 .oLog.LogEntry("Validating EDI center.")
3603 llRetVal= .CheckDistribution(pceipcTH)
3604 *=== TR 1062197 7-Sep-2012 Goutam
3605
3606 ENDIF
3607 ENDIF
3608
3609 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
3610 IF llRetVal
3611 .LogEntry("Validating shipper code.")
3612 llRetVal = .CheckShipper(pceipcTH)
3613 ENDIF
3614 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
3615
3616 ENDIF
3617
3618 *--- TechRec 1073591 23-Oct-2013 TShenbagavalli ---
3619 IF llRetVal
3620 .LogEntry("Resolving Customer Shipper.")
3621 llRetVal = .ResolveCustShipper(pceipcTH, pceipcCR)
3622 ENDIF
3623 *=== TechRec 1073591 23-Oct-2013 TShenbagavalli ===
3624
3625 *--- TR 1034532 NH
3626 llRetVal = llRetVal and this.PopulateStoreForSingleStorePO(pceipcTH)
3627 llRetVal = llRetVal and this.SetDivisionForOrderWithoutDetail(pceipcTH) &&--- TR 1036066
3628 llRetVal = llRetVal and this.PopulateOrderNumber(pceipcTH,pceipcTD)
3629 *=== TR 1034532 NH
3630
3631 *--- TechRec 1056904 24-Oct-2011 jisingh ---
3632 .LogEntry("Checking 850 transaction maintenance.")
3633 llRetVal = llRetVal AND .Check850TM(pceipcTH, pceipcCR)
3634 *=== TechRec 1056904 24-Oct-2011 jisingh ===
3635
3636 ENDWITH
3637 SELECT(lnOldSelect)
3638 RETURN llRetVal
3639 ENDPROC
3640
3641 *--- TechRec 1073591 17-Oct-2013 TShenbagavalli ---
3642***********************************************************************************
3643 Procedure CheckShipper
3644 LPARAMETERS pcHeader
3645 Local llRetVal, lnOldSelect, lcSQL
3646 llRetVal= true
3647 lnOldSelect= Select()
3648
3649 lcSQL = " SELECT Distinct shipper FROM " + pcHeader + ;
3650 " WHERE NOT EMPTY(shipper) "
3651
3652 llRetVal = v_SqlExec(lcSQL, "__tmpShipper",,.T.)
3653
3654 SELECT __tmpShipper
3655 WITH This
3656 .cSQLTempTable=""
3657 IF .GenerateSQLTempTable('__tmpShipper')
3658 IF .PopulateSQLTempTable('__tmpShipper')
3659 IF !EMPTY(.cSQLTempTable)
3660 lcSQLString= "Select s.shipper from " +;
3661 " zzxshipr s, " + .cSQLTempTable + " t " +;
3662 "Where s.shipper= t.shipper"
3663 llRetVal = v_SqlExec(lcSQLString, "_Shiper")
3664 IF llRetVal
3665 SELECT _Shiper
3666 INDEX On shipper TAG Shipper
3667 llRetVal= .SetRelation("_Shiper", "Shipper", pcHeader, "Shipper")
3668 IF llRetVal
3669 SELECT (pcHeader)
3670 Replace Errs_msg_H WITH Errs_msg_H + "Invalid shipper code." + CRLF , ;
3671 Errs_flg_h WITH "Y" FOR EOF("_shiper") AND NOT EMPTY(Shipper) In (pcHeader)
3672 SET RELATION TO
3673 ENDIF
3674 ENDIF
3675 ENDIF
3676 ENDIF
3677 ENDIF
3678 ENDWITH
3679
3680 IF USED("__tmpShipper")
3681 USE IN __tmpShipper
3682 ENDIF
3683 IF USED("_Shiper")
3684 USE IN _Shiper
3685 ENDIF
3686
3687 Select(lnOldSelect)
3688 Return llRetVal
3689 ENDPROC
3690 ***********************************************************************************
3691 PROCEDURE PopulateAuxsku
3692 LPARAMETERS pceipcTH, pceipcTD
3693
3694 Local llRetVal, lnOldSelect, lcSQL
3695
3696 llRetVal = .T.
3697 lnOldSelect = Select()
3698
3699 WITH THIS
3700
3701 IF RECCOUNT(pceipcTD) > 0
3702
3703 lcSQL = " Select DISTINCT customer, division, Style, color_code, lbl_code, " + ;
3704 " Dimension, sizebucket, aux_sku " + ;
3705 " from " + pceipcTD + ;
3706 " Where !EMPTY(aux_sku) "
3707
3708 llRetVal = v_SqlExec(lcSQL, "__eipcTD",,.T.)
3709
3710 IF RECCOUNT("__eipcTD") > 0
3711
3712 .cSQLTempTable = ""
3713 llRetVal = llRetVal And .GenerateSQLTempTable("__eipcTD")
3714 llRetVal = llRetVal And .PopulateSQLTempTable("__eipcTD")
3715 lceipcTD_tmp = .cSQLTempTable
3716
3717 .LogEntry("Create tranaction detail temporary table " + Iif(llRetVal, "successful.","failed."))
3718
3719 IF llRetVal
3720
3721 lcSQL = " UPDATE d set d.aux_sku = x.aux_sku " + ;
3722 " FROM zzxcstdr d JOIN " + lceipcTD_tmp + " x " + ;
3723 " ON d.customer = x.customer " + ;
3724 " AND d.division = x.division " + ;
3725 " AND d.style = x.style " + ;
3726 " AND d.color_code = x.color_code " + ;
3727 " AND d.lbl_code = x.lbl_code " + ;
3728 " AND d.dimension = x.dimension " + ;
3729 " AND d.size_bk = x.sizebucket " + ;
3730 " WHERE x.aux_sku > '' "
3731
3732 v_SqlExec(lcSQL)
3733 ENDIF
3734
3735 IF Used("tmpCstdr")
3736 Use In tmpCstdr
3737 ENDIF
3738 ENDIF
3739
3740 ENDIF
3741
3742 ENDWITH
3743
3744 Select(lnOldSelect)
3745 Return llRetVal
3746 ENDPROC
3747 ***********************************************************************************
3748 *=== TechRec 1073591 17-Oct-2013 TShenbagavalli ===
3749
3750 ***********************************************************************************
3751 *--- TR 1034532 NH
3752 *--- populate transaction records with store when only one store exists per PO in Sales Order.
3753
3754 PROCEDURE PopulateStoreForSingleStorePO
3755 LPARAMETERS pceipcTH
3756
3757 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
3758 llRetVal = .t.
3759 lnOldSelect = SELECT()
3760 lcTmpTbl = ""
3761 lcEipcTh = SYS(2015)
3762
3763 *--- get
3764 *--- TR 1048865 27-May-2011 Goutam. Added division
3765 *--- TR 1053720 23-May-2011 Goutam. Added cr_pkey in the list
3766 SELECT pkey, po_num, customer, store, division, cr_pkey FROM (pceipcTH) th ;
3767 WHERE th.customer > '' AND store = '' AND edi_store = '' AND po_num > '' ;
3768 INTO CURSOR (lcEipcTh)
3769
3770 IF RECCOUNT(lcEipcTh) = 0
3771 *--- no need to do any thing when customer is populated for all records
3772 SELECT(lnOldSelect)
3773 RETURN llRetVal
3774 ENDIF
3775
3776 WITH this
3777 .cSQLTempTable = ""
3778 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
3779 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
3780 lcTmpTbl = .cSQLTempTable
3781 USE IN (lcEipcTh)
3782 *--- store
3783
3784 *--- TR 1048865 27-May-2011 Goutam. Added condition ih.division = th.division
3785 *--- TR 1053720 23-May-2011 Goutam.
3786 *lcSql = " select th.pkey, th.po_num, th.customer, oh.store, r.edi_store " + ;
3787 " From " + lcTmpTbl + " th inner join zzoordrh oh (nolock) on th.po_num = oh.po_num and th.customer = oh.customer " + ;
3788 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3789 " Where exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3790 " where ih.ord_status = 'O' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3791 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3792 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) "
3793
3794 *--- 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 > '' " + ---
3795 lcSql = " select th.pkey, th.po_num, th.customer, oh.store, r.edi_store " + ;
3796 " From " + lcTmpTbl + " th inner join zzoordrh oh (nolock) on th.po_num = oh.po_num and th.customer = oh.customer " + ;
3797 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store inner join zzeipccr c on c.pkey = th.cr_pkey " + ;
3798 " Where exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3799 " where ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3800 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3801 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3802 " or " + ;
3803 " exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3804 " where ih.ord_status = 'C' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3805 " and ih.customer = th.customer and ih.po_num = th.po_num and ih.division = th.division " + ;
3806 " 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') " + ;
3807 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3808 " group by th.pkey, th.po_num, th.customer, oh.store, r.edi_store "
3809
3810 *--- TR 1053720 23-May-2011 Goutam.
3811
3812 lcOrderStore = "tcOrderStore" + SYS(2015)
3813 llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderStore)
3814 IF llRetVal
3815 SELECT (lcOrderStore)
3816 INDEX on pkey TAG pkey
3817 *--- TR 1036066 NH : added ForAllStore = 'P'
3818 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
3819 *=== TR 1036066 NH
3820 ENDIF
3821 ENDWITH
3822
3823 IF USED(lcOrderStore)
3824 USE IN (lcOrderStore)
3825 ENDIF
3826 SELECT(lnOldSelect)
3827 RETURN llRetVal
3828 ENDPROC
3829
3830 ***********************************************************************************
3831
3832 PROCEDURE PopulateStoreForSingleStorePO_AtServer
3833
3834 LOCAL llRetVal, lnOldSelect
3835 llRetVal = .t.
3836 lnOldSelect = SELECT()
3837
3838 LOCAL lcFilter
3839 lcFilter = IIF (EMPTY(this.cFilterCriteria),"",THIS.cFilterCriteria)
3840 lcFilter = STRTRAN(lcFilter,"Where","")
3841
3842 *--- populate trans header with store, and edi_store value when PO has only one store order in OPEN order
3843 LOCAL lcSql
3844
3845 *-- TR 1047337 MAY-19-2010 BR
3846 *lcSql = " Update h Set store = oh.store, edi_store = r.edi_store " + ;
3847 " , ForAllStore = CASE h.ForAllStore WHEN 'Y' then 'P' ELSE h.ForAllStore End " + ;
3848 " From zzeipcth h inner join zzoordrh oh (nolock) on h.po_num = oh.po_num and h.customer = oh.customer " + ;
3849 " inner join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3850 " Where h.ForAllStore = 'Y' AND exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3851 " where ih.ord_status = 'O' and ih.store > '' and ih.customer > '' and ih.po_num > '' " + ;
3852 " and ih.customer = h.customer and ih.po_num = h.po_num " + ;
3853 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3854 IIF(EMPTY(lcFilter),""," and " + lcFilter)
3855 lcSql = " Update h Set store = oh.store, edi_store = CASE oh.store WHEN '' THEN '' ELSE r.edi_store END " + ;
3856 " , ForAllStore = CASE h.ForAllStore WHEN 'Y' then 'P' ELSE h.ForAllStore End " + ;
3857 " From zzeipcth h inner join zzoordrh oh (nolock) on h.po_num = oh.po_num and h.customer = oh.customer " + ;
3858 " left outer join zzxstorr r on r.customer = oh.customer and r.store = oh.store " + ;
3859 " Where h.ForAllStore = 'Y' AND exists ( select po_num, customer, min(pkey) from zzoordrh ih (nolock) " + ;
3860 " where ih.ord_status = 'O' and ih.store > = '' and ih.customer > '' and ih.po_num > '' " + ;
3861 " and ih.customer = h.customer and ih.po_num = h.po_num " + ;
3862 " group by ih.po_num, ih.customer having count(*) = 1 and min(ih.pkey) = oh.pkey) " + ;
3863 IIF(EMPTY(lcFilter),""," and " + lcFilter)
3864 *== TR 1047337 MAY-19-2010 BR
3865
3866 llRetVal = llRetVal and v_sqlexec(lcSql)
3867
3868 SELECT(lnOldSelect)
3869 RETURN llRetVal
3870 ENDPROC
3871
3872 ***********************************************************************************
3873
3874 PROCEDURE PopulateOrderNumber
3875 LPARAMETERS pceipcTH,pceipcTD
3876
3877 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
3878 llRetVal = .t.
3879 lnOldSelect = SELECT()
3880 lcTmpTbl = ""
3881 lcEipcTh = SYS(2015)
3882 *--- TR 1036066 NH
3883 lcTmpTbl_D = ""
3884 lceipcTD = SYS(2015)
3885 *=== TR 1036066 NH
3886
3887 *--- get trans records which has proper customer, po_num, and store
3888 *--- TR 1048865 27-Dec-2010 Goutam. Added cr_pkey in the following sql list
3889 *- TR 1056230 FH - Took out check for store, our store can be empty.
3890 *--- TR 1062197 10-Sep-2012 Goutam. Added poc_purp, poc_store
3891
3892 *--- TR 1086404 18-May-2015 BNarayanan added condition AND ForAllStore < 'Y' to avoid updating the order number for all store record ---
3893 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 ;
3894 FROM (pcEipcTh) th WHERE th.customer > '' AND th.po_num > '' AND ord_num = 0 AND ForAllStore < 'Y' ;
3895 INTO CURSOR (lcEipcTh)
3896 *=== TR 1086404 18-May-2015 BNarayanan ===
3897
3898 *--- TR 1036066 NH :
3899 SELECT td.pkey, td.fkey, td.qualifier, td.qty_change FROM (pceipcTD) td INNER JOIN (lcEipcTh) th ;
3900 ON th.pkey = td.fkey INTO CURSOR (lceipcTD)
3901 *=== TR 1036066 NH
3902
3903
3904 IF RECCOUNT(lcEipcTh) = 0
3905 *--- no need to do any thing when customer is populated for all records
3906 SELECT(lnOldSelect)
3907 RETURN llRetVal
3908 ENDIF
3909
3910 WITH this
3911 .cSQLTempTable = ""
3912 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
3913 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
3914 lcTmpTbl = .cSQLTempTable
3915 *--- TR 1036066 NH
3916 .cSQLTempTable = ""
3917 llRetVal = llRetVal AND .GenerateSQLTempTable(lceipcTD)
3918 IF RECCOUNT(lceipcTD) > 0
3919 llRetVal = llRetVal AND .PopulateSQLTempTable(lceipcTD) and not EMPTY(.cSQLTempTable)
3920 ENDIF
3921 lcTmpTbl_D = .cSQLTempTable
3922 *=== TR 1036066 NH
3923
3924 USE IN (lcEipcTh)
3925
3926 *--- TR 1048865 27-Dec-2010 Goutam
3927 *-- Changed from inner join zzeipccr r on r.customer = th.customer and r.division = th.division to ;
3928 inner join zzeipccr r on r.pkey = th.cr_pkey ;
3929 Also added condition and ith.division = h.division before where h.ord_status = 'O'
3930
3931 *--- 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 ;
3932 join the same subquery with table #zzeipctd and zzeipccr. Changed count(*) as ord_count to count(distinct ord_num) as ord_count
3933 *--- 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)
3934 *--- TR 1085815 27-Mar-2015 BNarayanan , coalesce(oh.ord_type,'') ord_type & min(h.ord_type) as ord_type,added ---
3935 TEXT TO lcSql noshow
3936 select th.pkey, th.customer, th.po_num, th.store
3937 , coalesce(oh.ord_num,0) ord_num
3938 , case when oh.ord_num is null and td.pkey is null then 'Y'
3939 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'
3940 when coalesce(ord_count,0) > 1 then 'Y'
3941 else '' end errs_flg_h
3942 , case when oh.ord_num is null and td.pkey is null then 'Order not found.'
3943 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.'
3944 when coalesce(ord_count,0) > 1 then 'More than one order found.'
3945 else '' end errs_msg_h
3946 , coalesce(oh.ord_type,'') ord_type
3947 from #zzeipcth th
3948 inner join zzeipccr r on r.pkey = th.cr_pkey
3949 LEFT OUTER join #zzeipctd td on th.pkey = td.fkey
3950 left outer join
3951 (select ith.pkey, ith.customer, ith.po_num, ith.store, min(h.ord_type) as ord_type,
3952 min(h.ord_num) as ord_num, count(distinct ord_num) as ord_count
3953 from zzoordrh h inner join #zzeipcth ith
3954 on ith.po_num = h.po_num and ith.customer = h.customer
3955 and (ith.store = case when (poc_purp = '04' and poc_store > '') then ith.store else h.store end)
3956 and ith.division = h.division
3957 join zzeipccr c on ith.cr_pkey = c.pkey
3958 left join #zzeipctd itd on itd.fkey = ith.pkey
3959 where (h.ord_status = 'O' or ((itd.qualifier = 'AI' or (itd.qualifier = 'RZ'
3960 and itd.qty_change > 0))
3961 and c.new_order = 'Y')
3962 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')))
3963 group by ith.pkey, ith.customer, ith.po_num, ith.store) oh
3964 on oh.pkey = th.pkey
3965 ENDTEXT
3966
3967 lcSql = STRTRAN(lcSql,"#zzeipcth",lcTmpTbl)
3968 lcSql = STRTRAN(lcSql,"#zzeipctd",lcTmpTbl_D)
3969 lcOrderNumbers = "tcOrderNumbers" + SYS(2015)
3970 llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderNumbers)
3971 IF llRetVal
3972 SELECT (lcOrderNumbers)
3973 INDEX on pkey TAG pkey
3974 *--- TR 1085815 27-Mar-2015 BNarayanan , ord_type = u.ord_type added ---
3975 UPDATE th SET ord_num = u.ord_num, ord_type = u.ord_type ;
3976 , errs_flg_h = IIF(u.errs_flg_h = 'Y',u.errs_flg_h, th.errs_flg_h) ;
3977 , errs_msg_h = th.errs_msg_h + IIF(!EMPTY(u.errs_msg_h), u.errs_msg_h + CRLF, "") ;
3978 from (pcEipcTh) th inner join (lcOrderNumbers) u on th.PKEY = u.PKEY
3979 ENDIF
3980
3981 IF USED(lcOrderNumbers)
3982 USE IN (lcOrderNumbers)
3983 ENDIF
3984 IF USED(lcEipcTh)
3985 USE IN (lcEipcTh)
3986 ENDIF
3987 ENDWITH
3988
3989 SELECT(lnOldSelect)
3990 RETURN llRetVal
3991 ENDPROC
3992
3993 *=== TR 1034532 NH
3994 ***********************************************************************************
3995
3996 *--- TR 1027724 NH
3997 PROCEDURE UpdateCustomerUsingTrandingPartnerID
3998 LPARAMETERS pcEipcTh
3999
4000 LOCAL llRetVal, lnOldSelect,lcTmpTbl,lcEipcTh
4001 llRetVal = .t.
4002 lnOldSelect = SELECT()
4003 lcTmpTbl = ""
4004 lcEipcTh = SYS(2015)
4005
4006 SELECT * FROM (pcEipcTh) th WHERE th.customer = '' INTO CURSOR (lcEipcTh)
4007
4008
4009 IF RECCOUNT(lcEipcTh) = 0
4010 *--- no need to do any thing when customer is populated for all records
4011 RETURN llRetVal
4012 ENDIF
4013
4014 WITH this
4015 .cSQLTempTable = ""
4016 llRetVal = llRetVal AND .GenerateSQLTempTable(lcEipcTh)
4017 llRetVal = llRetVal AND .PopulateSQLTempTable(lcEipcTh) and not EMPTY(.cSQLTempTable)
4018 lcTmpTbl = .cSQLTempTable
4019 USE IN (lcEipcTh)
4020
4021 *--- 1048865 24-Dec-2010 Goutam. Added CR_Pkey in the following parameter
4022 llRetVal = llRetVal and UpdateTradingPartnerUsingCommunicationID(lcTmpTbl, "zzeipccr","customer","errs_flg_h","errs_msg_h",,"CR_Pkey")
4023 llRetVal = llRetVal and v_sqlexec("select * from " + lcTmpTbl,lcEipcTh)
4024
4025 *--- 1048865 24-Dec-2010 Goutam. Added CR_Pkey = u.CR_Pkey in the following sql
4026 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 ;
4027 from (pcEipcTh) th inner join (lcEipcTh) u on th.PKEY = u.PKEY
4028
4029 ENDWITH
4030
4031 SELECT(lnOldSelect)
4032 RETURN llRetVal
4033 ENDPROC
4034
4035 ***********************************************************************************
4036 *=== TR 1027724 NH
4037 PROCEDURE CheckStore
4038 LPARAMETERS pcHeader, pcControl
4039 LOCAL llRetVal, lnOldSelect
4040 llRetVal= .T.
4041 lnOldSelect= SELECT()
4042
4043 * 1st - group get store using cust,edi_store but not overwrite existing store
4044 * users could change store in Trans Maint.
4045 SELECT DISTINCT customer, EDI_Store, STORE FROM (pcHeader) ;
4046 WHERE !EMPTY(customer) AND !EMPTY(EDI_Store) AND EMPTY(STORE) ;
4047 INTO CURSOR __TmpCursor
4048
4049 SELECT __TmpCursor
4050 WITH THIS
4051 .cSQLTempTable=""
4052 IF .GenerateSQLTempTable('__TmpCursor')
4053 IF .PopulateSQLTempTable('__TmpCursor')
4054 IF !EMPTY(.cSQLTempTable)
4055 *- 850 resolves consolidate/ distribution center from store if not empty
4056 *- also, populates center_code, consol_code if empty.
4057 *- We don't do that in the 860, assuming that the store does not change.
4058 *- We need the resolution just to find the original order.
4059 lcSQLString= "Select s.customer, s.store, s.edi_store " +;
4060 " from zzxstorr s, " + .cSQLTempTable + " t " +;
4061 "Where s.customer= t.customer and s.edi_store= t.edi_store"
4062 llRetVal = v_SQLExec(lcSQLString, "_Storr")
4063 IF llRetVal
4064 SELECT _Storr
4065 INDEX ON customer+EDI_Store TAG CustStore
4066 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
4067 "customer+edi_store")
4068 IF llRetVal
4069 SELECT (pcHeader)
4070 *--- TR 1018294 02-Aug-2006 BR ---
4071 SCAN FOR !EMPTY(EDI_Store) AND EMPTY(Store)
4072
4073 *=== TR 1018294 02-Aug-2006 BR ===
4074 IF EMPTY(_Storr.customer)
4075 *--- TR 1062197 7-Sep-2012 Goutam
4076 *REPLACE Errs_msg_H WITH Errs_msg_H + "Invalid EDI Store code." +CRLF ,;
4077 Errs_flg_h WITH "Y" IN (pcHeader)
4078
4079 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 ,;
4080 Errs_flg_h WITH "Y" IN (pcHeader)
4081 *=== TR 1062197 7-Sep-2012 Goutam
4082
4083 ELSE
4084 IF EMPTY(STORE) && don't want to overwrite previous data
4085 REPLACE STORE WITH _Storr.STORE
4086 ENDIF
4087 ENDIF
4088 ENDSCAN
4089 SET RELATION TO
4090 USE IN _Storr
4091 ENDIF
4092 ENDIF
4093 ENDIF
4094 ENDIF
4095 ENDIF
4096 ENDWITH
4097 IF USED("__TmpCursor")
4098 USE IN __TmpCursor
4099 ENDIF
4100
4101 * 2nd - validate store by cust,store
4102 SELECT DISTINCT customer, STORE FROM (pcHeader) ;
4103 WHERE !EMPTY(customer) AND !EMPTY(STORE) INTO CURSOR __TmpCursor
4104 SELECT __TmpCursor
4105 WITH THIS
4106 .cSQLTempTable=""
4107 IF .GenerateSQLTempTable('__TmpCursor')
4108 IF .PopulateSQLTempTable('__TmpCursor')
4109 IF !EMPTY(.cSQLTempTable)
4110 lcSQLString= "Select s.customer, s.store " +;
4111 " from zzxstorr s, " + .cSQLTempTable + " t " +;
4112 "Where s.customer= t.customer and s.store= t.store"
4113 llRetVal = v_SQLExec(lcSQLString, "_Storr")
4114 IF llRetVal
4115 SELECT _Storr
4116 INDEX ON customer+STORE TAG CustStore
4117 llRetVal= .SetRelation("_Storr", "CustStore", pcHeader, ;
4118 "customer+store")
4119 IF llRetVal
4120 SELECT (pcHeader)
4121 SCAN FOR !EMPTY(EDI_Store)
4122 IF EMPTY(_Storr.customer)
4123 REPLACE Errs_msg_H WITH Errs_msg_H + "Invalid Store code." +CRLF ,;
4124 Errs_flg_h WITH "Y" IN (pcHeader)
4125 ENDIF
4126 ENDSCAN
4127 SET RELATION TO
4128 USE IN _Storr
4129 ENDIF
4130 ENDIF
4131 ENDIF
4132 ENDIF
4133 ENDIF
4134 ENDWITH
4135 IF USED("__TmpCursor")
4136 USE IN __TmpCursor
4137 ENDIF
4138
4139 IF USED("_Storr")
4140 USE IN _Storr
4141 ENDIF
4142
4143 SELECT(lnOldSelect)
4144 RETURN llRetVal
4145 ENDPROC
4146
4147 PROCEDURE CheckDetail
4148 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
4149 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
4150 LPARAMETERS pceipcTH, pceipcTD, pceipcCR, pceipcTS, pceipcTWHSE
4151 LOCAL llRetVal, lnOldSelect
4152 llRetVal = .T.
4153 lnOldSelect = SELECT()
4154 WITH THIS
4155
4156 .oLog.LogEntry("Resolving style using UPC.")
4157 *--- TR 1031588 17-APR-2008 VKK Added pceipccr
4158
4159
4160 * --- TR 1047609 7/7/10 CM
4161 If .lHaveSLN
4162 .LogEntry("Resolving SLNs.")
4163 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
4164 llRetVal= llRetVal AND .ResolveBCSkuFromSLN(pceipcTH, pceipcTD, pceipcTS, pceipcCR, pceipcTWHSE )
4165 Endif
4166 * === TR 1047609 7/7/10 CM
4167
4168 llRetVal= llRetVal AND .CheckUpc(pceipcTH, pceipcTD, pceipcCR)
4169
4170 .oLog.LogEntry("Resolving style using EAN.")
4171 llRetVal= llRetVal AND .CheckEAN(pceipcTH, pceipcTD)
4172
4173 .oLog.LogEntry("Resolving style using SKU.")
4174 llRetVal= llRetVal AND .CheckSku(pceipcTH, pceipcTD)
4175
4176 *- Advanced resolution. Out of the scope. For future use.
4177 *-- .AdvanceThermoTotalWithCaptionPlus("Validating/Exploding Range Styles...", ;
4178 *-- vcLogName)
4179 *-- .oLog.LogEntry("Resolving range style.")
4180 *-- llRetVal= llRetVal AND .RangeStyle(pceipoTH, pceipoTD) && "Vzzeipotd_IPOProc"
4181 *-- .AdvanceThermoTotalWithCaptionPlus("Getting Customer Label...", ;
4182 *-- vcLogName)
4183 *-- .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", ;
4184 *-- vcLogName)
4185 *-- llRetVal= llRetVal AND .PrepackConversion(pceipoTH, pceipoTD)
4186
4187 *-- .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
4188 *-- vcLogName)
4189 *-- llRetVal= llRetVal AND .ResolvePrepack(pceipoTH, pceipoTD, pceipcCR)
4190
4191 llRetVal= llRetVal AND .UpdtHeaderDivs(pceipcTH, pceipcTD)
4192 .AdvanceThermoTotalWithCaptionPlus("Populating implosion flag to transaction header.")
4193
4194 *--- TR 1022465 NH/BR : - we have division populated for normal orders, but orders with no detail have no division value.
4195 *--- need to join with zzoordrh on po_num + customer only find the division from zzoordrh and stamp it in zzeipcth.division field
4196 .oLog.LogEntry("Setting Division for order without detail.")&&TR 1041492 JUL-20-2009 BR
4197 llRetVal = llRetVal and .SetDivisionForOrderWithoutDetail(pceipcTH)
4198
4199 *- TR 1054193 FH 5/13/11
4200 llRetVal = llRetVal and .ValidateIfControlReferenceExist(pceipcTH, "zzeipccr")
4201 *- TR 1054193 FH 5/13/11
4202
4203 .LogEntry("Populating implosion flag to transaction header.")
4204 llRetVal = llRetVal AND .PopulatingImplosionFlag(pceipcTH, pceipcCR)
4205
4206 *--- TR 1032030 NH
4207 .oLog.LogEntry("Setting Values from customer sales ref.") &&TR 1041492 JUL-20-2009 BR
4208 *---TR 1088126 2-JUL-2015 Venuk. Added param pceipcTD ===
4209 llRetVal = llRetVal and .SetValuesFromCustomerSalesRef(pceipcTH, pceipcTD)
4210
4211 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", vcLogName)
4212 llRetVal= llRetVal AND .RangeStyle(pceipcTH, pceipcTD, pceipcCR)
4213 .oLog.LogEntry("Prepack Quantity Conversion " + IIF(llRetVal,"successful.","failed."))
4214
4215 .oLog.LogEntry("Resolving Price From Range Style.") &&TR 1041492 JUL-20-2009 BR
4216 llRetVal= llRetVal AND .ResolvePriceFromRangeStyle(pceipcTH, pceipcTD)
4217 *=== TR 1032030 NH
4218
4219 *--- TR 1016559 NH
4220 .AdvanceThermoTotalWithCaptionPlus("Prepack Quantity Conversion...", vcLogName)
4221 llRetVal= llRetVal AND .PrepackConversion(pceipcTD)
4222 .oLog.LogEntry("Prepack Quantity Conversion " + IIF(llRetVal,"successful.","failed."))
4223 *=== TR 1016559 NH
4224
4225 *--- TR 1016560 NH
4226 IF .lPrepackImplosionOk
4227 .AdvanceThermoTotalWithCaptionPlus("Resolving Single Prepack...", ;
4228 vcLogName)
4229 llRetVal= llRetVal AND .Resolve860Prepack(pceipcTH, pceipcTD, pceipcCR)
4230 .LogEntry("Resolving Single Prepack " + IIF(llRetVal," sucessful.","failed."))
4231 ENDIF
4232 *=== TR 1016560 NH
4233
4234 .oLog.LogMajorStage("Resolving and getting default fields.")
4235 .AdvanceThermoTotalWithCaptionPlus("Resolving customer label.", vcLogName)
4236 .oLog.LogEntry("Resolving customer label.")
4237
4238 llRetVal= llRetVal AND .ResolveCustomerLabel(pceipcTH, pceipcTD, pceipcCR)
4239
4240 *--- TechRec 1073591 14-Feb-2014 TShenbagavalli ---
4241 .LogEntry("Populating Auxsku")
4242 llRetVal = llRetVal and this.PopulateAuxsku(pceipcTH, pceipcTD)
4243 *=== TechRec 1073591 14-Feb-2014 TShenbagavalli ===
4244
4245 .AdvanceThermoTotalWithCaptionPlus("Validating Style/Color/Label/Dimension...", ;
4246 vcLogName)
4247
4248 .oLog.LogEntry("Validating style.")
4249 llRetVal= llRetVal AND .ValidateOurSKU(pceipcTH, pceipcTD)
4250
4251 .AdvanceThermoTotalWithCaptionPlus("Checking Minimum/Multiple for all orders...", ;
4252 vcLogName)
4253
4254 .oLog.LogEntry("Validating MinMultiple.")
4255 llRetVal= llRetVal AND .ValidateMinMultiple(pceipcTH, pceipcTD)
4256
4257 *--- TR 1034532 NH
4258 .oLog.LogEntry("Validating Qualifier.")&&TR 1041492 JUL-20-2009 BR
4259 llRetVal = llRetVal and this.ValidateQualifier(pceipcTD)
4260 *=== TR 1034532 NH
4261
4262 ENDWITH
4263
4264 SELECT(lnOldSelect)
4265 RETURN llRetVal
4266 ENDPROC
4267
4268 *-----------------------------------------------------------------------------------------
4269 *--- TR 1034532 NH
4270 PROCEDURE ValidateQualifier(pceipcTD)
4271
4272 LOCAL llRetVal, lnOldSelect
4273 lnOldSelect = SELECT()
4274 llRetVal = .t.
4275
4276 *--- TR 1039757 18-Aug-2009 Goutam. Added NZ in where list.
4277 *--- TechRec 1052780 17-Mar-2011 MANI. Added NC in Where list ===
4278 UPDATE td SET errs_flg_d = 'Y', errs_msg_d = errs_msg_d + 'Invalid PO change Action code' + CRLF ;
4279 from (pceipcTD) td WHERE td.qualifier NOT in ('AI','DI','QI','QD','RZ','PC','CT','DB','NZ','NC') AND td.errs_flg_d <> 'Y'
4280
4281 Select(lnOldSelect)
4282 Return llRetVal
4283 Endproc
4284 *=== TR 1034532 NH
4285
4286 * TR 1022465 BR/NH 5/10/07
4287 **********************************************************************************************
4288 PROCEDURE SetDivisionForOrderWithoutDetail
4289 LPARAMETERS pceipcTH
4290 LOCAL llRetVal, lcOldOrder, lnOldSelect, lcPo_Cust
4291 llRetVal = .t.
4292 lnOldSelect = SELECT()
4293 lcEmptyDiv = SYS(2015)
4294 lcDivFound = SYS(2015)
4295 *--- find empty divisions
4296 SELECT po_num, customer FROM (pceipcTH) WHERE EMPTY(division) INTO CURSOR (lcEmptyDiv)
4297 *--- zzoordrh
4298 IF reccount(lcEmptyDiv) > 0
4299 .cSQLTempTable=""
4300 llRetval = llRetVal and .GenerateSQLTempTable(lcEmptyDiv)
4301 llRetval = llRetVal and .PopulateSQLTempTable(lcEmptyDiv) and !EMPTY(.cSQLTempTable)
4302
4303 lcSql = "SELECT distinct th.po_num, th.customer, h.division from " + .cSQLTempTable + " th " + ;
4304 " INNER JOIN zzoordrh h (nolock) on th.po_num = h.po_num and th.customer = h.customer "
4305
4306 llRetVal = llRetVal and v_sqlexec(lcSql,lcDivFound)
4307
4308 SELECT(pceipcTH)
4309 lcOldOrder = ORDER()
4310 INDEX on po_num + customer TAG po_cust
4311
4312 SELECT (lcDivFound)
4313 SCAN
4314 SCATTER NAME loDivFound
4315 lcPo_Cust = po_num+customer
4316 IF SEEK(po_num+customer, pceipcTH, "po_cust")
4317 SELECT (pceipcTH)
4318 SCAN WHILE lcPo_Cust == po_num+customer
4319 replace division WITH loDivFound.division in (pceipcTH)
4320 ENDSCAN
4321 ENDIF
4322 ENDSCAN
4323 SELECT (pceipcTH)
4324 SET ORDER TO (lcOldOrder)
4325
4326 ENDIF
4327
4328 SELECT(lnOldSelect)
4329 RETURN llRetval
4330 ENDPROC
4331 **********************************************************************************************
4332 * TR 1022465 BR/NH 5/10/07
4333 **********************************************************************************************
4334
4335 PROCEDURE CheckUpc
4336 *--- TR 1031588 17-APR-2008 VKK Added pceipccr
4337 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4338 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcMssg, lcOldCust, lcOldItem, ;
4339 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
4340 lnSize_desc
4341
4342 llRetVal = .T.
4343 lcErrs_Msg= ""
4344 lnOldSelect = SELECT()
4345
4346 *--- TR 1031588 17-APR-2008 VKK ignore upc resoltion
4347
4348*!* SELECT h.customer, d.upc, d.pkey ;
4349*!* FROM (pceipcTH) h, (pceipcTD) d ;
4350*!* WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4351*!* (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4352*!* ORDER BY h.customer, d.upc ;
4353*!* INTO CURSOR tmpCurs
4354
4355 *--- TR 1048865 23-Mar-2011 Goutam. Deleted following line of code
4356*!* SELECT customer, MAX (ResvCustSKU) as ResvCustSKU ;
4357*!* FROM (pceipccr) ;
4358*!* GROUP BY customer ;
4359*!* INTO CURSOR __ResvCustSKU
4360 *=== TR 1048865 23-Mar-2011 Goutam
4361
4362 && TR 1031588 22-Apr-2008 T.Shenbagavalli added (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') condition instead of c.ResvCustSKU <> 'Y'
4363
4364 *--- TR 1048865 23-Mar-2011 Goutam
4365*!* SELECT h.customer, d.upc, d.pkey ;
4366*!* FROM (pceipcTH) h, (pceipcTD) d, __ResvCustSKU C ;
4367*!* WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4368*!* c.customer = h.customer AND (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') AND ;
4369*!* (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4370*!* ORDER BY h.customer, d.upc ;
4371*!* INTO CURSOR tmpCurs
4372
4373 SELECT h.customer, d.upc, d.pkey ;
4374 FROM (pceipcTH) h, (pceipcTD) d, (pceipccr) c ;
4375 WHERE !EMPTY(d.upc) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4376 c.pkey = h.cr_pkey AND (EMPTY(d.sku) OR c.ResvCustSKU < 'Y') AND ;
4377 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4378 ORDER BY h.customer, d.upc ;
4379 INTO CURSOR tmpCurs
4380 *=== TR 1048865 23-Mar-2011 Goutam
4381
4382 *=== TR 1031588 17-APR-2008 VKK
4383
4384 lcOldCust = ""
4385 lcOldItem = ""
4386 SELECT tmpCurs
4387 IF THIS.lUserInterface
4388 * Init Thermometer
4389 THIS.UpdateThermoCaption("Validating UPC(s)...")
4390 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4391 l_nThermoCnt = 0
4392 ENDIF
4393 SCAN
4394 IF THIS.lUserInterface
4395 * Advance progress bar, if we're using one.
4396 l_nThermoCnt = l_nThermoCnt + 1
4397 THIS.AdvanceThermo(l_nThermoCnt)
4398 ENDIF
4399 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.upc == lcOldItem)
4400 lcErrs_Msg = ""
4401 lcOldCust = tmpCurs.customer
4402 lcOldItem = tmpCurs.upc
4403
4404 IF THIS.oBPOSalesOrder.ValidCustomerUPC(@lcErrs_Msg, tmpCurs.customer, tmpCurs.upc, "tmpCstdr")
4405 lcDivision = tmpCstdr.division
4406 lcStyle = tmpCstdr.STYLE
4407 lcColor_code = tmpCstdr.color_code
4408 lcLbl_code = tmpCstdr.lbl_code
4409 lcDimension = tmpCstdr.DIMENSION
4410 lnSizeBucket = tmpCstdr.size_bk
4411 lnSize_desc = tmpCstdr.size_desc
4412 ELSE
4413 lcErrs_Msg = ""
4414 IF THIS.oBPOSalesOrder.ValidUPC(@lcErrs_Msg, tmpCurs.upc, "tmpUpcnr")
4415 lcDivision = tmpUpcnr.division
4416 lcStyle = tmpUpcnr.STYLE
4417 lcColor_code = tmpUpcnr.color_code
4418 lcLbl_code = tmpUpcnr.lbl_code
4419 lcDimension = tmpUpcnr.DIMENSION
4420 lnSizeBucket = tmpUpcnr.Sizebucket
4421 lnSize_desc = tmpUpcnr.size_desc
4422 ELSE
4423 lcErrs_Msg = lcErrs_Msg + CRLF
4424 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4425 STORE 0 TO lnSizeBucket
4426 ENDIF
4427 ENDIF
4428 ENDIF && level break
4429
4430 SELECT (pceipcTD)
4431 lnWorkArea = SELECT()
4432 =SEEK(tmpCurs.pkey, lnWorkArea, "pkey")
4433 SCATTER NAME loEiPCtd MEMO
4434 IF !EMPTY(lcErrs_Msg)
4435 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4436 loEiPCtd.Errs_Flg_D = "Y"
4437 ENDIF
4438 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4439 loEiPCtd.division = lcDivision
4440 loEiPCtd.STYLE = lcStyle
4441 loEiPCtd.color_code = lcColor_code
4442 loEiPCtd.lbl_code = lcLbl_code
4443 loEiPCtd.DIMENSION = lcDimension
4444 loEiPCtd.Sizebucket = lnSizeBucket
4445 loEiPCtd.size_desc = lnSize_desc
4446 ENDIF
4447
4448 *- check for future possibility of a range style
4449 *- If there's no field "rng_style" or there is, but it is empty - Ok.
4450 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4451 GATHER NAME loEiPCtd MEMO
4452 ENDIF
4453 ENDSCAN
4454 USE IN tmpCurs
4455
4456 IF THIS.lUserInterface
4457 * Reset Thermometer
4458 THIS.ResetThermo()
4459 ENDIF
4460
4461 IF USED("tmpCstdr")
4462 USE IN tmpCstdr
4463 ENDIF
4464 IF USED("tmpUpcnr")
4465 USE IN tmpUpcnr
4466 ENDIF
4467
4468 SELECT(lnOldSelect)
4469 RETURN llRetVal
4470 ENDPROC
4471
4472 PROCEDURE CheckEAN
4473 LPARAMETERS pceipcTH, pceipcTD
4474 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcMssg, lcOldCust, lcOldItem, ;
4475 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
4476 lnSize_desc
4477 llRetVal = .T.
4478 lcErrs_Msg= ""
4479 lnOldSelect = SELECT()
4480
4481 SELECT h.customer, d.ean, d.pkey ;
4482 FROM (pceipcTH) h, (pceipcTD) d ;
4483 WHERE !EMPTY(d.ean) AND h.pkey = d.fkey AND !EMPTY(h.customer) AND ;
4484 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4485 ORDER BY h.customer, d.ean ;
4486 INTO CURSOR tmpCurs
4487
4488 lcOldCust = ""
4489 lcOldItem = ""
4490 SELECT tmpCurs
4491 IF THIS.lUserInterface
4492 * Init Thermometer
4493 THIS.UpdateThermoCaption("Validating EAN(s)...")
4494 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4495 l_nThermoCnt = 0
4496 ENDIF
4497 SCAN
4498 IF THIS.lUserInterface
4499 * Advance progress bar, if we're using one.
4500 l_nThermoCnt = l_nThermoCnt + 1
4501 THIS.AdvanceThermo(l_nThermoCnt)
4502 ENDIF
4503 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.ean == lcOldItem)
4504 lcErrs_Msg = ""
4505 lcOldCust = tmpCurs.customer
4506 lcOldItem = tmpCurs.ean
4507
4508 IF THIS.oBPOSalesOrder.ValidCustomerEAN(@lcErrs_Msg, tmpCurs.customer, tmpCurs.ean, "tmpCstdr")
4509 lcDivision = tmpCstdr.division
4510 lcStyle = tmpCstdr.STYLE
4511 lcColor_code = tmpCstdr.color_code
4512 lcLbl_code = tmpCstdr.lbl_code
4513 lcDimension = tmpCstdr.DIMENSION
4514 lnSizeBucket = tmpCstdr.size_bk
4515 lnSize_desc = tmpCstdr.size_desc
4516 ELSE
4517 lcErrs_Msg = ""
4518 IF THIS.oBPOSalesOrder.ValidEAN(@lcErrs_Msg, tmpCurs.ean, "tmpUpcnr")
4519 lcDivision = tmpUpcnr.division
4520 lcStyle = tmpUpcnr.STYLE
4521 lcColor_code = tmpUpcnr.color_code
4522 lcLbl_code = tmpUpcnr.lbl_code
4523 lcDimension = tmpUpcnr.DIMENSION
4524 lnSizeBucket = tmpUpcnr.Sizebucket
4525 lnSize_desc = tmpUpcnr.size_desc
4526 ELSE
4527 lcErrs_Msg = lcErrs_Msg + CRLF
4528 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4529 STORE 0 TO lnSizeBucket
4530 ENDIF
4531 ENDIF
4532 ENDIF && level break
4533
4534 SELECT (pceipcTD)
4535
4536 lnWorkArea = SELECT()
4537 =SEEK(tmpCurs.pkey, lnWorkArea, "pkey")
4538 SCATTER NAME loEiPCtd MEMO
4539 IF !EMPTY(lcErrs_Msg)
4540 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4541 loEiPCtd.Errs_Flg_D = "Y"
4542 ENDIF
4543 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4544 loEiPCtd.division = lcDivision
4545 loEiPCtd.STYLE = lcStyle
4546 loEiPCtd.color_code = lcColor_code
4547 loEiPCtd.lbl_code = lcLbl_code
4548 loEiPCtd.DIMENSION = lcDimension
4549 loEiPCtd.Sizebucket = lnSizeBucket
4550 loEiPCtd.size_desc = lnSize_desc
4551 ENDIF
4552
4553 * only replace our SKU when no range style explosion happen
4554 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4555 GATHER NAME loEiPCtd MEMO
4556 ENDIF
4557 ENDSCAN
4558 USE IN tmpCurs
4559
4560 IF THIS.lUserInterface
4561 * Reset Thermometer
4562 THIS.ResetThermo()
4563 ENDIF
4564
4565 IF USED("tmpCstdr")
4566 USE IN tmpCstdr
4567 ENDIF
4568 IF USED("tmpUpcnr")
4569 USE IN tmpUpcnr
4570 ENDIF
4571
4572 SELECT(lnOldSelect)
4573 RETURN llRetVal
4574 ENDPROC
4575
4576 PROCEDURE CheckSku
4577 LPARAMETERS pceipcTH, pceipcTD
4578 LOCAL llRetVal, lnOldSelect, loEiPCth, loEiPCtd, lcErrs_Msg, lcOldCust, lcOldItem, ;
4579 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg,;
4580 lnSize_desc, llSLN
4581
4582 llRetVal = .T.
4583 lcErrs_Msg= ""
4584 lnOldSelect = SELECT()
4585
4586 SELECT h.customer, d.sku, d.pkey ;
4587 FROM (pceipcTH) h, (pceipcTD) d ;
4588 WHERE !EMPTY(h.customer) AND !EMPTY(d.sku) AND h.pkey = d.fkey AND ;
4589 (EMPTY(d.division) OR EMPTY(d.STYLE) OR EMPTY(d.color_code)) ; && Only RESOLVE ONCE
4590 ORDER BY h.customer, d.sku ;
4591 INTO CURSOR tmpCurs
4592
4593 lcOldCust = ""
4594 lcOldItem = ""
4595 SELECT tmpCurs
4596 IF THIS.lUserInterface
4597 * Init Thermometer
4598 THIS.UpdateThermoCaption("Validating SKU(s)...")
4599 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4600 l_nThermoCnt = 0
4601 ENDIF
4602 SCAN
4603 IF THIS.lUserInterface
4604 l_nThermoCnt = l_nThermoCnt + 1
4605 THIS.AdvanceThermo(l_nThermoCnt)
4606 ENDIF
4607 IF !(tmpCurs.customer == lcOldCust AND tmpCurs.sku == lcOldItem) && level break
4608 lcErrs_Msg = ""
4609 lcOldCust = tmpCurs.customer
4610 lcOldItem = tmpCurs.sku
4611 IF THIS.oBPOSalesOrder.ValidCustomerSKU(@lcErrs_Msg, tmpCurs.customer, tmpCurs.sku, "tmpCstdr")
4612 lcDivision = tmpCstdr.division
4613 lcStyle = tmpCstdr.STYLE
4614 lcColor_code = tmpCstdr.color_code
4615 lcLbl_code = tmpCstdr.lbl_code
4616 lcDimension = tmpCstdr.DIMENSION
4617 lnSizeBucket = tmpCstdr.size_bk
4618 lnSize_desc = tmpCstdr.size_desc
4619 ELSE
4620 lcErrs_Msg = lcErrs_Msg + CRLF
4621 STORE "" TO lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSize_desc
4622 STORE 0 TO lnSizeBucket
4623 ENDIF
4624 ENDIF && level break
4625
4626 SELECT (pceipcTD)
4627 IF SEEK(tmpCurs.pkey, pceipcTD, "PKey")
4628 SCATTER NAME loEiPCtd MEMO
4629 IF !EMPTY(lcErrs_Msg)
4630 loEiPCtd.Errs_Msg_D = ALLTRIM(loEiPCtd.Errs_Msg_D) + lcErrs_Msg
4631 loEiPCtd.Errs_Flg_D = "Y"
4632 ENDIF
4633 IF !EMPTY(lcDivision) && update w/ style if found, no matter good or bad
4634 loEiPCtd.division = lcDivision
4635 loEiPCtd.STYLE = lcStyle
4636 loEiPCtd.color_code = lcColor_code
4637 loEiPCtd.lbl_code = lcLbl_code
4638 loEiPCtd.DIMENSION = lcDimension
4639 loEiPCtd.Sizebucket = lnSizeBucket
4640 loEiPCtd.size_desc = lnSize_desc
4641 ENDIF
4642
4643 IF TYPE(pceipcTD + ".rng_style") = "U" OR EMPTY(EVALUATE(pceipcTD + ".rng_style"))
4644 GATHER NAME loEiPCtd MEMO
4645 ENDIF
4646
4647 ENDIF
4648 ENDSCAN
4649 USE IN tmpCurs
4650
4651 IF THIS.lUserInterface
4652 * Reset Thermometer
4653 THIS.ResetThermo()
4654 ENDIF
4655
4656 IF USED("tmpCstdr")
4657 USE IN tmpCstdr
4658 ENDIF
4659
4660 SELECT(lnOldSelect)
4661 RETURN llRetVal
4662 ENDPROC
4663
4664 PROCEDURE ResolveCustomerLabel
4665 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4666 LOCAL llRetVal, lnOldSelect
4667 llRetVal = .T.
4668 lnOldSelect = SELECT()
4669 WITH THIS
4670 .AdvanceThermoTotalWithCaptionPlus("Cascading Customer To Detail.", vcLogName)
4671 .oLog.LogEntry("Cascading Customer To Detail.")
4672 llRetVal= llRetVal AND .CascadingCustomerToDetail(pceipcTH, pceipcTD)
4673 .AdvanceThermoTotalWithCaptionPlus("Substituding customer label.", vcLogName)
4674 .oLog.LogEntry("Substituding customer label.")
4675 llRetVal= llRetVal AND .SubstitudeValidLabel(pceipcTH, pceipcTD, pceipcCR)
4676 ENDWITH
4677 SELECT(lnOldSelect)
4678 RETURN llRetVal
4679 ENDPROC
4680
4681 ************************************************************************************
4682 * Resolve shared UPC
4683 ************************************************************************************
4684 PROCEDURE CascadingCustomerToDetail
4685 LPARAMETERS pceipcTH, pceipcTD
4686 LOCAL llRetVal, lnOldSelect
4687 llRetVal = .T.
4688 lnOldSelect = SELECT()
4689 WITH THIS
4690 * set header/detail Relation
4691 llRetVal= llRetVal AND .SetRelation(pceipcTH, "Pkey", pceipcTD, "Fkey")
4692 REPLACE ALL customer WITH &pceipcTH..customer IN (pceipcTD)
4693 SET RELATION TO
4694 ENDWITH
4695 SELECT(lnOldSelect)
4696 RETURN llRetVal
4697 ENDPROC
4698
4699 ************************************************************************************
4700 * Resolve shared UPC
4701 ************************************************************************************
4702 * unconditional substitution with proper lbl_code from 850 control and resv_label='Y'
4703 * regardless of auto_create of style flag set in Customer Label Ref.
4704 PROCEDURE SubstitudeValidLabel
4705 LPARAMETERS pceipcTH, pceipcTD, pceipcCR
4706 LOCAL llRetVal, lnOldSelect
4707 llRetVal = .T.
4708 lnOldSelect = SELECT()
4709 LOCAL lcOrder_ipcTD && TR 1019356
4710 lcOrder_ipcTD = "" && TR 1019356
4711 WITH THIS
4712 *-- TR 1019356 NH 01/05/07
4713 LOCAL lcBcSku
4714 lcBcSku = ""
4715 *- Also process when resv_label= 'V' (Validate). In this case populate label only
4716 *- if the SKU with the label is valid and active in the style master.
4717 *--- TR 1027127 NH
4718 *IF .lResl_delv
4719 IF TYPE(pceipcCR + ".resv_label") == "C"
4720 *=== TR 1027127 NH
4721 *--- TR 1048865 27-Dec-2010 Goutam
4722 *--- Changed from d.division= C.division AND h.customer= C.customer to ;
4723 h.cr_pkey = c.pkey in the following sql
4724 SELECT DISTINCT C.customer,d.division,d.STYLE,d.color_code,C.lbl_code,d.DIMENSION, C.resv_label ; &&Use SubCust lbl_code
4725 FROM (pceipcTH) h, (pceipcTD) d, (pceipcCR) C ;
4726 WHERE h.pkey= d.fkey AND ;
4727 h.cr_pkey = c.pkey AND ;
4728 (C.resv_label= 'Y' OR C.resv_label= 'V') AND d.lbl_code= '' AND ; && Only Blank label and flag set for resv_label
4729 EMPTY(d.Errs_Msg_D) AND ; && Valid detail SKU, UPC OK
4730 h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4731 INTO CURSOR tmpCurs
4732 ELSE
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, '' resv_label ; &&Use SubCust lbl_code - 1027127
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' 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 ENDIF
4745 *=== TR 1019356 NH
4746 INDEX ON customer+division+STYLE+color_code+DIMENSION TAG OurSkuNoLb
4747 llRetVal= .SetRelation("tmpCurs", "OurSkuNoLb", pceipcTD, ;
4748 "customer+division+style+color_code+dimension")
4749 IF llRetVal
4750 *--- 1019356 NH 01/05/07
4751*!* REPLACE ALL lbl_code WITH tmpCurs.lbl_code IN (pceipcTD);
4752*!* FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
4753 SELECT (pceipcTD)
4754 *--- remove the order of pceipcTD, otherwise replace moves the record pointer to the end of the match.
4755 lcOrder_ipcTD = ORDER()
4756 SET ORDER TO
4757 SCAN FOR !EMPTY(tmpCurs.STYLE) AND EMPTY(Errs_Msg_D)
4758 lcBcSku = tmpCurs.division + tmpCurs.style + tmpCurs.color_code + tmpCurs.lbl_code + tmpCurs.dimension
4759 *--- update label value only when Resv_label flag is 'Y' or
4760 *--- Resv_label flag is 'V' and blue cherry sku exists with matching label and active
4761 IF tmpCurs.Resv_label = "Y" OR ;
4762 (tmpCurs.Resv_label = "V" AND SEEK(lcBcSku,"tcScolr","SKU") AND tcScolr.active_ok = "Y")
4763 REPLACE lbl_code WITH tmpCurs.lbl_code IN (pceipcTD)
4764 ENDIF
4765 ENDSCAN
4766 SELECT (pceipcTD)
4767 SET ORDER TO (lcOrder_ipcTD)
4768 *=== TR 1019356 NH
4769 SET RELATION TO
4770 ENDIF
4771 .TableClose('tmpCurs')
4772 ENDWITH
4773 SELECT(lnOldSelect)
4774 RETURN llRetVal
4775 ENDPROC
4776
4777 PROCEDURE ValidateOurSKU
4778 LPARAMETERS pceipcTH, pceipcTD, plValidateStyleOrderType
4779 LOCAL llRetVal, lnOldSelect
4780 llRetVal = .T.
4781 lnOldSelect = SELECT()
4782
4783 IF NOT plValidateStyleOrderType
4784 SELECT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code,;
4785 d.DIMENSION, d.Sizebucket, d.pkey, '' AS ord_type ;
4786 FROM (pceipcTH) h, (pceipcTD) d ;
4787 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' ;
4788 AND d.STYLE<>'' AND d.color_code<>'' ;
4789 ORDER BY h.customer,d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4790 INTO CURSOR tmpCurs
4791
4792 *- For range styles need to add
4793 *- WHERE d.rng_style = ' '
4794
4795 ELSE
4796 lcSQLSelect = "select * from zzotyper"
4797 llRetVal= THIS.vsqlexec(lcSQLSelect, "tcotyper")
4798 IF llRetVal
4799 SELECT h.customer, d.division, d.STYLE, d.color_code, d.lbl_code,;
4800 d.DIMENSION, d.Sizebucket, d.pkey, h.ord_type ;
4801 FROM (pceipcTH) h, (pceipcTD) d, tcotyper o ;
4802 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' ;
4803 AND d.STYLE<>'' AND d.color_code<>'' AND ;
4804 (h.ord_type<>'' AND h.ord_type=o.ord_type AND o.val_styl_ord='Y') ;
4805 ORDER BY h.customer,d.division,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4806 INTO CURSOR tmpCurs
4807
4808 ELSE
4809 RETURN llRetVal
4810 ENDIF
4811 ENDIF
4812
4813 lcErrs_Msg = ''
4814 SCATTER MEMO NAME oTmpCurs BLANK
4815
4816 THIS.oLog.LogEntry("Begin Available Size Validation")&&TR 1041492 JUL-20-2009 BR
4817
4818 WITH oTmpCurs
4819 SCAN
4820 IF !(tmpCurs.customer == .customer ;
4821 AND tmpCurs.division == .division ;
4822 AND tmpCurs.STYLE == .STYLE ;
4823 AND tmpCurs.color_code == .color_code ;
4824 AND tmpCurs.lbl_code == .lbl_code ;
4825 AND tmpCurs.DIMENSION == .DIMENSION ;
4826 AND tmpCurs.Sizebucket == .Sizebucket)
4827 lcErrs_Msg = ''
4828
4829 SCATTER MEMO NAME oTmpCurs
4830 IF NOT THIS.oBPOSalesOrder.ValidAvailableSize(@lcErrs_Msg,oTmpCurs)
4831 lcErrs_Msg= lcErrs_Msg + CRLF
4832 ENDIF
4833 ENDIF
4834 * for each detail line replace detail error msg if have one
4835 IF !EMPTY(lcErrs_Msg) AND SEEK(tmpCurs.pkey, pceipcTD, "Pkey")
4836 REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Msg, ;
4837 Errs_Flg_D WITH 'Y' IN (pceipcTD)
4838 ENDIF
4839 ENDSCAN
4840 ENDWITH
4841 THIS.oLog.LogEntry("Available Size Validation...Complete")&&TR 1041492 JUL-20-2009 BR
4842 THIS.TableClose("tcotyper")
4843
4844 SELECT(lnOldSelect)
4845 RETURN llRetVal
4846 ENDPROC
4847
4848 ****************************************************************************
4849 PROCEDURE ValidateMinMultiple
4850 LPARAMETERS pceipcTH, pceipcTD
4851 LOCAL llRetVal, lnOldSelect, lcCurrKeys, l_nThermoCnt
4852 llRetVal = .T.
4853 lnOldSelect = SELECT()
4854
4855 WITH THIS
4856 * 1st Get distinct list of div,sty,col,lbl,dim for min_multiple check
4857 SELECT DISTINCT d.division, d.STYLE, d.color_code, d.lbl_code, d.DIMENSION ;
4858 FROM (pceipcTH) h, (pceipcTD) d ;
4859 WHERE h.pkey = d.fkey AND h.customer<>'' AND d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4860 ORDER BY 1,2,3,4,5 ;
4861 INTO CURSOR __TmpCursor
4862 * 2nd. Server-side join previous list to get cursor of scolr
4863 * that have ONLY min_multiple> 1
4864 .cSQLTempTable=""
4865 IF .GenerateSQLTempTable('__TmpCursor')
4866 IF .PopulateSQLTempTable('__TmpCursor')
4867 IF !EMPTY(.cSQLTempTable)
4868 lcSQLString= "select s.* from zzxscolr s," + .cSQLTempTable + " t " +;
4869 "Where s.division= t.division and s.style= t.style and "+;
4870 "s.color_code= t.color_code and s.lbl_code= t.lbl_code and "+;
4871 "s.dimension= t.dimension and s.min_multiple> 1"
4872 llRetVal = v_SQLExec(lcSQLString, "_Scolr")
4873
4874 *--- TR 1085815 27-Mar-2015 BNarayanan ---
4875 llRetVal = v_SQLExec("select * from zzotyper" , "_OrdTyp")
4876 *=== TR 1085815 27-Mar-2015 BNarayanan ===
4877
4878 * 3rd. Per order sum all total_qty to verify not break Min_multiple
4879 * Fkey (OrderbyOrder),PO1_SKU,PO1_UPC,price,org_price,div,style,col,lbl,dim
4880 *--- TR 1085815 27-Mar-2015 BNarayanan skip validation for order types having skip Min multiplier option ---
4881 SELECT h.customer, d.fkey, d.division, d.STYLE, d.color_code,d.lbl_code,;
4882 d.DIMENSION, SUM(d.Qty_change) AS line_qty, s.min_multiple ;
4883 FROM (pceipcTH) h, (pceipcTD) d, _Scolr s ;
4884 WHERE h.pkey = d.fkey AND h.customer<>'' AND ;
4885 d.division= s.division AND d.STYLE= s.STYLE AND ;
4886 d.color_code= s.color_code AND d.lbl_code= s.lbl_code AND ;
4887 d.DIMENSION= s.DIMENSION AND ;
4888 d.division<>'' AND d.STYLE<>'' AND d.color_code<>'' ;
4889 AND NOT exists (select * FROM _OrdTyp o WHERE o.ord_type = h.ord_type AND o.skip_mmult = 'Y') ; && 1085815
4890 ORDER BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4891 GROUP BY d.fkey,d.STYLE,d.color_code,d.lbl_code,d.DIMENSION ;
4892 INTO CURSOR tmpCurs
4893
4894 l_nThermoCnt = 0
4895 .InitThermoWithCaption(@l_nThermoCnt, THIS.CountTotalRecs ("tmpCurs"), ;
4896 "Checking Minimum/Multiple for all orders...")
4897 SCAN
4898 .AdvanceThermoPlus(@l_nThermoCnt)
4899 lcCurrKeys= STR(fkey)+STYLE+color_code+lbl_code+DIMENSION
4900
4901 lcErrs_Msg = ''
4902 IF NOT vl_min_mult(line_qty, division, STYLE, color_code, lbl_code, DIMENSION, ;
4903 @lcErrs_Msg, .T.) && Don't display Errorbox()
4904 REPLACE Errs_Msg_D WITH Errs_Msg_D + lcErrs_Msg + CRLF, Errs_Flg_D WITH "Y" ;
4905 FOR STR(fkey)+STYLE+color_code+lbl_code+DIMENSION = lcCurrKeys ;
4906 IN (pceipcTD)
4907 ENDIF
4908 ENDSCAN
4909 .ResetThermoPlus()
4910 .TableClose("_Scolr")
4911 .TableClose("__TmpCursor")
4912 *--- TR 1085815 27-Mar-2015 BNarayanan ---
4913 .TableClose("_OrdTyp")
4914 *=== TR 1085815 27-Mar-2015 BNarayanan ===
4915 ENDIF
4916 ENDIF
4917 ENDIF
4918
4919 ENDWITH
4920 SELECT(lnOldSelect)
4921 RETURN llRetVal
4922 ENDPROC
4923
4924 PROCEDURE UpdtHeaderDivs
4925 LPARAMETERS pceipcTH, pceipcTD
4926 LOCAL llRetVal, lnOldSelect, llUpdate
4927 llRetVal = .T.
4928 lnOldSelect = SELECT()
4929
4930 .oLog.LogEntry("Resolving header division.")
4931 SELECT DISTINCT fkey, division FROM (pceipcTD) ;
4932 WHERE !EMPTY(division) INTO CURSOR tmpCurs
4933 SELECT tmpCurs
4934 IF THIS.lUserInterface
4935 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
4936 l_nThermoCnt = 0
4937 ENDIF
4938 SCAN
4939 IF THIS.lUserInterface
4940 l_nThermoCnt = l_nThermoCnt + 1
4941 THIS.AdvanceThermo(l_nThermoCnt)
4942 ENDIF
4943 SELECT (pceipcTH)
4944 *--- TR 1041492 JUL-20-2009 BR
4945 IF SEEK(tmpCurs.fkey,pceipcTH,"pkey")
4946*!* LOCATE FOR pkey = tmpCurs.fkey
4947*!* IF FOUND()
4948 *=== TR 1041492 JUL-20-2009 BR
4949 REPLACE division WITH tmpCurs.division IN (pceipcTH)
4950 ENDIF
4951 ENDSCAN
4952 USE IN tmpCurs
4953
4954 IF THIS.lUserInterface
4955 THIS.ResetThermo()
4956 ENDIF
4957 SELECT(lnOldSelect)
4958 RETURN llRetVal
4959 ENDPROC
4960
4961 FUNCTION ApplyPOChanges
4962 * LPARAMETER pcSQLFilterString, plNoScreenUI
4963 LOCAL llRetVal, lnSelect, lcMsg, lcSyslockTablePath, lnPKey
4964 LOCAL laRatioViews(1)
4965 PRIVATE pcCustomer, pcDivision, pnPO_Num, pcStore
4966 *--- TR 1017210 NH
4967 LOCAL lnMaxLine_seq
4968 lnMaxLine_seq = 0
4969 *=== TR 1017210 NH
4970
4971 *--- TR 1021052 18-SEP-2007 Goutam
4972 LOCAL lcSqlString, lcWorkAlias
4973
4974 *--- TR 1028744 19-FEB-2008 VKK
4975 LOCAL llValidOrder
4976
4977 llRetVal = true
4978 lnSelect = SELECT()
4979 pcCustomer = ""
4980 pcDivision = ""
4981 pnPO_Num = 0
4982 pcStore = ""
4983 *--- TR 1017210 NH
4984 DECLARE laDuplicateFields[1]
4985 ACOPY(THIS.aDuplicateFields, laDuplicateFields)
4986 *=== TR 1017210 NH
4987 *!* lcSyslockTablePath = AddBS(goEnv.envLoginTablePath.VALUE)
4988 *!* IF NOT v_SysLock(lcSyslockTablePath+"SYSLOCK", "EDI860INBOUND", goEnv.cCompany)
4989 *!* This.lProcessLocked = .T.
4990 *!* RETURN false
4991 *!* ENDIF
4992
4993 WITH THIS
4994 * Initialize object properties
4995 .lNoDataFound = false
4996 .cMessage = ''
4997 * .lScheduled = plNoScreenUI
4998
4999 * Retrieve records to process
5000 * .CreateFormProgressBar(.lScheduled)
5001 *!* * .UpdateThermoCaption("Selecting 860 inbound records to process...")
5002 *!* .InitProgressBarTotal(2, "Total 860 Inbound Process.")
5003 *!* .InitThermo(2)
5004 *!* INKEY(0.2)
5005
5006 *!* lcLogFile = AddBS(goEnv.SystemParm(SP_PATH_LOGS)) + ;
5007 *!* goEnv.SystemParm(SP_COMP_CODE) + "_" + .cLogFile
5008 *!* DELETE FILE &lcLogFile
5009
5010 *!* THIS.lIncludeLog = .T.
5011 *!* .InstantiateLogging()
5012
5013 *!* * .oLog.OpenLog(.cJobID, i(.cJobID), .lScheduled, .cLogFile)
5014 *!* .oLog.LogProgram("clsIPCPR.prg")
5015 *!* * .oLog.LogEntry("Filter Criteria: " + IIF(EMPTY(pcSQLFilterString), " - None - ", pcSQLFilterString))
5016
5017 IF NOT .CreateSOViews()
5018 .lErrorState = true
5019 llRetVal = false
5020 .cMessage = MSG_FILTER_ERROR + CRLF + MSG_TRY_AGAIN_NOW
5021
5022 .oLog.LogEntry(.cMessage)
5023 .oLog.LogEntry("")
5024 * .oLog.CloseLog()
5025 .m_close()
5026 ELSE
5027 .AdvanceThermoTotal(1)
5028 .AdvanceThermo(2)
5029 INKEY(0.2)
5030
5031 .nToProcess = RECCOUNT("tceipcth")
5032 .nProcessed = 0
5033
5034 IF .nToProcess = 0
5035 .lNoDataFound = true
5036 .cMessage = 'There are no 860 records to process.'
5037
5038 .oLog.LogEntry(.cMessage)
5039 ELSE
5040 lcMsg = ALLTRIM(STR(.nToProcess)) + " 860 inbound record(s) were found." + CRLF + ;
5041 "Are you sure you want to process them?"
5042
5043 IF .lScheduled OR AskBox(lcMsg,,,true) && Default second
5044 * Calculate proration
5045 .UpdateThermoCaption("Processing 860 inbound records...")
5046 .InitThermo(2)
5047 INKEY(0.2)
5048
5049 *!* Could have used something like the following to create sales order views. This is more set-based,
5050 *!* but if one record in the tableupdate fails, they all fail, and the process is doomed.
5051 *!* Per Yuriah, use the one record at a time logic.
5052
5053 *!* .UpdateThermoCaption("Pulling down Header, Detail, Cost, and BOM views...")
5054 *!* .InitThermo(2) && 2 = The number of tables to pull
5055 *!* lcSQLString = "SELECT * FROM ZZCORDRD WHERE Prod_num IN (" + lcProd_Nums + ") " + ;
5056 *!* " AND EXISTS(SELECT * FROM zzccostd WHERE FKey = zzcordrd.PKey) " + ;
5057 *!* " ORDER BY Prod_Num, Open_Seq"
5058 *!* llRetVal = .CreateSQLView("Vzzcordrd_Tree", lcSQLString, , 'prod_num, open_seq, stage_num')
5059 *!* llRetVal = llRetVal AND .OpenTable("Vzzcordrd_Tree",,true,,3)
5060 *!* .AdvanceThermo(1)
5061
5062 *!* lcSQLString = "..."
5063 *!* .AdvanceThermo(2)
5064
5065 *!* IF llRetVal
5066 *!* .IndexSalesOrder()
5067 *!* ENDIF
5068
5069 *!* llRetVal = llRetVal AND CURSORSETPROP("BUFFER", 5, "Vzzoordrh_860I")
5070 *!* llRetVal = llRetVal AND CURSORSETPROP("BUFFER", 5, "Vzzoordrd_860I")
5071 *!* .InitThermo(2)
5072 *- 1014475 12/02/05 YIK
5073
5074 *--- TR 1021052 18-SEP-2007 Goutam
5075 lcWorkAlias = GetUniqueFileName()
5076
5077 SELECT h.pkey as HPKey, ;
5078 d.pkey as DPKey, ;
5079 h.Customer, ;
5080 h.Division, ;
5081 h.Po_Num, ;
5082 d.Style, ;
5083 d.Color_code, ;
5084 d.lbl_code, ;
5085 d.Dimension ;
5086 FROM ;
5087 tcEiPCth h ;
5088 INNER JOIN ;
5089 tcEiPCtd d ;
5090 ON d.fkey = h.pkey ;
5091 INTO Cursor (lcWorkAlias)
5092
5093 llRetVal = llRetVal AND .GenerateSQLTempTable(lcWorkAlias)
5094
5095 *---TR 1028239 11/7/07 BR
5096 *llRetVal = llRetVal AND .PopulateSQLTempTable(lcWorkAlias)
5097 IF llRetVal and RECCOUNT(lcWorkAlias) > 0
5098 llRetVal = llRetVal AND .PopulateSQLTempTable(lcWorkAlias)
5099 ENDIF
5100 *===TR 1028239 11/7/07 BR
5101
5102 llRetVal = llRetVal AND NOT EMPTY(.cSQLTempTable)
5103 .TableClose(lcWorkAlias)
5104 *=== TR 1021052 18-SEP-2007 Goutam
5105
5106 THIS.nMaxSizes = vl_compr("", "max_bucket")
5107
5108 SELECT tcEiPCtd
5109 SET ORDER TO TAG fkey
5110
5111 SELECT tcEiPCtc
5112 SET ORDER TO TAG fkey
5113
5114 *--- TR 1021052 18-SEP-2007 Goutam. Deleted following line
5115 *llRetVal = .T.
5116
5117 SELECT tcEiPCth
5118 SCAN
5119
5120 *--- TR 1021052 18-SEP-2007 Goutam
5121 IF NOT llRetVal
5122 EXIT
5123 ENDIF
5124 *=== TR 1021052 18-SEP-2007 Goutam
5125
5126 IF tcEiPCth.Errs_flg_h = "Y" AND tcEiPCth.Auto_proc = "Y" && TR 1019356
5127 LOOP
5128 ENDIF
5129 *- 1015584 02/14/06 YIK
5130 lnPKey = tcEiPCth.pkey
5131
5132 ACOPY(.oBPOCancel.aRatioViews, laRatioViews) && Need for each iteration, might get changed.
5133 .lOneDetailLineBad = .F.
5134 .lUpdateCancelViews = .F.
5135 .lCreatedRatioCursor = .F.
5136
5137 pcCustomer = tcEiPCth.customer
5138 pcDivision = tcEiPCth.division
5139 pnPO_Num = tcEiPCth.PO_Num
5140 pcStore = tcEiPCth.STORE
5141
5142 *--- TR 1021052 20-AUG-2007 HNISAR & Goutam
5143 .lNewOrder = false
5144
5145 *--- TR 1048865 27-Dec-2010 Goutam
5146 *IF SEEK(pcDivision+pcCustomer, 'zzeipccr', 'divcust')
5147 IF SEEK(tcEiPCth.cr_pkey, 'zzeipccr', 'pkey')
5148 *=== TR 1048865 27-Dec-2010 Goutam
5149 .lNewOrder = (zzeipccr.new_order=='Y')
5150 ENDIF
5151 *=== TR 1021052 20-AUG-2007 HNISAR & Goutam
5152
5153 *- 1014475 01/16/06 YIK
5154 *- change RECCOUNT("Vzzoordrh_860I") > 0 to RECCOUNT("Vzzoordrh_860I") = 1
5155 *- if we get 2 or more records, it means the order is partially picked.
5156 *--- TR 1016589 NH : just requery header and detail notes, there may not be any notes at all so,
5157 *---- no need for reccount() for notes.
5158*!* IF ( (REQUERY("Vzzoordrh_860I") > 0 AND RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5159*!* (REQUERY("Vzzoordrd_860I") > 0 AND RECCOUNT("Vzzoordrd_860I") > 0) )
5160
5161 *--- TR 1021052 20-AUG-2007 HNISAR
5162 *IF llRetVAl AND ((REQUERY("Vzzoordrh_860I") > 0 AND RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5163 (REQUERY("Vzzoordrd_860I") > 0 AND RECCOUNT("Vzzoordrd_860I") > 0) AND ;
5164 REQUERY("Vnotes_zzoordrh_860I") > 0 AND REQUERY("Vnotes_zzoordrd_860I") > 0 )
5165
5166 .lOrderExist = (REQUERY("Vzzoordrh_860I") > 0) AND ;
5167 (REQUERY("Vzzoordrd_860I") > 0) AND ;
5168 (REQUERY("Vnotes_zzoordrh_860I")) > 0 AND ;
5169 (REQUERY("Vnotes_zzoordrd_860I") > 0) AND ;
5170 (RECCOUNT("Vzzoordrh_860I") = 1) AND ;
5171 (RECCOUNT("Vzzoordrd_860I") > 0)
5172
5173 IF .lOrderExist OR (Not .lOrderExist AND .lNewOrder)
5174 *=== TR 1021052 20-AUG-2007 HNISAR
5175
5176 *---
5177 *=== TR 1016589 NH
5178 IF tcEiPCth.POC_Purp = "01"
5179 IF tcEiPCth.Auto_proc = 'Y' && TR 1019356 - do cancel only when Auto_proc flag is true
5180 * Header level change:
5181 * Cancel entire sales odor:
5182 *--- TR 1019356 - does not make sence for two vl calls for two values of same record.
5183 *--- zzeipccr is already cached so.. why not use that!
5184*!* lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
5185*!* lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
5186
5187 *--- TR 1048865 27-Dec-2010 Goutam
5188 *IF SEEK(Vzzoordrh_860I.division + Vzzoordrh_860I.customer , "zzeipccr","divCust")
5189 IF SEEK(Vzzoordrh_860I.cr_pkey, "zzeipccr","pkey")
5190 *=== TR 1048865 27-Dec-2010 Goutam
5191
5192 lcCncl_Rsn = zzeipccr.Cncl_Rsn
5193 lcCncl_Type = zzeipccr.Cncl_Type
5194 ELSE
5195 lcCncl_Rsn = ""
5196 lcCncl_Type = ""
5197 ENDIF
5198 *=== TR 1019356
5199 WITH THIS.oBPOCancel
5200 .CreateRatioCursor()
5201 .cCncl_Rsn = lcCncl_Rsn
5202 .cCncl_Type = lcCncl_Type
5203 ENDWITH
5204
5205 .CancelSO(lcCncl_Rsn, lcCncl_Type)
5206 ENDIF
5207 ELSE
5208
5209 * Detail level change:
5210 lnPKey = tcEiPCth.pkey
5211 SELECT tcEiPCtd
5212
5213 .lUpdateSalesOrder = .F.
5214 .lUpdate860Records = .F.
5215 .lDelete860Records = .F.
5216 *--- TR 1017210 NH
5217 SELECT MAX(line_seq) as maxLine_seq FROM Vzzoordrd_860I INTO CURSOR tcOrdrd_MaxLine_seq
5218 lnMaxLine_seq = tcOrdrd_MaxLine_seq.maxLine_seq
5219 USE IN tcOrdrd_MaxLine_seq
5220 SELECT tcEiPCtd
5221 *=== TR 1017210 NH
5222
5223 *--- TR 1028744 19-FEB-2008 VKK
5224 llValidOrder = .CheckHardLink(Vzzoordrh_860I.Ord_Num)
5225 *=== TR 1028744 19-FEB-2008 VKK
5226
5227 *--- TR 1021052 17-SEP-2007 Goutam
5228 .lOrderHdrFound = false
5229 *=== TR 1021052 17-SEP-2007 Goutam
5230
5231 SEEK lnPKey
5232 *--- TR 1028744 19-FEB-2008 VKK Aded llvalidorder
5233 SCAN WHILE fkey = lnPKey AND llValidOrder
5234 *--- TR 1017210 NH
5235 *.ValidateDetail()
5236 .ValidateDetail(@lnMaxLine_seq, @laDuplicateFields)
5237 *=== TR 1017210 NH
5238 ENDSCAN
5239
5240 * Date change - Start_Date and/or End_Date will be populated:
5241 *--- TR 1015747 NH :
5242 *IF tcEiPCth.start_date <> {01/01/1900}
5243 IF NOT EMPTY(tcEiPCth.start_date) and tcEiPCth.start_date <> {01/01/1900}
5244 *=== TR 1015747 NH
5245 *- 1014475 12/21/05 YIK
5246 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
5247 *- and Vzzoordrd_860I
5248 REPLACE ;
5249 start_date WITH tcEiPCth.start_date, ;
5250 User_id WITH goEnv.cUser ;
5251 IN Vzzoordrh_860I
5252 REPLACE ALL ;
5253 start_date WITH tcEiPCth.start_date, ;
5254 end_date WITH IIF(end_date < tcEiPCth.start_date, ;
5255 tcEiPCth.start_date, end_date), ;
5256 User_id WITH goEnv.cUser ;
5257 IN Vzzoordrd_860I
5258
5259 .lUpdateSalesOrder = .T.
5260 .lDelete860Records = .T.
5261 ENDIF
5262 *- 1014475 12/21/05 YIK
5263 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
5264 *- and Vzzoordrd_860I
5265 *--- TR 1015747 NH :
5266 *IF tcEiPCth.end_date <> {01/01/1900}
5267 IF NOT EMPTY(tcEiPCth.end_date) AND tcEiPCth.end_date <> {01/01/1900}
5268 *==== TR 1015747 NH
5269 REPLACE ;
5270 end_date WITH tcEiPCth.end_date, ;
5271 User_id WITH goEnv.cUser ;
5272 IN Vzzoordrh_860I
5273 REPLACE ALL ;
5274 end_date WITH tcEiPCth.end_date, ;
5275 User_id WITH goEnv.cUser ;
5276 IN Vzzoordrd_860I
5277 .lUpdateSalesOrder = .T.
5278 .lDelete860Records = .T.
5279 ENDIF
5280
5281 *--- TR 1028909 6-Dec-2007 Goutam
5282 IF NOT EMPTY(tcEiPCth.altpo)
5283 REPLACE ;
5284 altpo WITH tcEiPCth.altpo, ;
5285 User_id WITH goEnv.cUser ;
5286 IN Vzzoordrh_860I
5287 .lUpdateSalesOrder = .T.
5288 .lDelete860Records = .T.
5289 ENDIF
5290 IF NOT EMPTY(tcEiPCth.po_desc)
5291 REPLACE ;
5292 po_desc WITH tcEiPCth.po_desc, ;
5293 User_id WITH goEnv.cUser ;
5294 IN Vzzoordrh_860I
5295 .lUpdateSalesOrder = .T.
5296 .lDelete860Records = .T.
5297 ENDIF
5298 *=== TR 1028909 6-Dec-2007 Goutam
5299
5300 *--- TR 1028744 19-FEB-2008 VKK
5301 IF NOT EMPTY(tcEiPCth.UDFORD7C)
5302 REPLACE ;
5303 UDFORD7C WITH tcEiPCth.UDFORD7C, ;
5304 User_id WITH goEnv.cUser ;
5305 IN Vzzoordrh_860I
5306
5307 .lUpdateSalesOrder = .T.
5308 .lDelete860Records = .T.
5309 ENDIF
5310
5311 IF NOT EMPTY(tcEiPCth.pri_date) AND tcEiPCth.pri_date <> {01/01/1900}
5312 REPLACE ;
5313 pri_date WITH tcEiPCth.pri_date, ;
5314 User_id WITH goEnv.cUser ;
5315 IN Vzzoordrh_860I
5316 REPLACE ALL ;
5317 pri_date WITH tcEiPCth.pri_date, ;
5318 User_id WITH goEnv.cUser ;
5319 IN Vzzoordrd_860I
5320
5321 .lUpdateSalesOrder = .T.
5322 .lDelete860Records = .T.
5323 ENDIF
5324 *=== TR 1028744 19-FEB-2008 VKK
5325
5326 *--- TR 1016589 NH
5327 IF .lUpdateSalesOrder
5328 llRetVal = llRetVal ;
5329 and .AddHdrNotes("tcEiPCth","Vnotes_ipch_iPCproc", "Vnotes_zzoordrh_860I",;
5330 "Vzzoordrh_860I")
5331 llRetVal = llRetVal ;
5332 and .AddDtlNotes("tcEiPCth", "tcEiPCtd", "Vnotes_ipcd_iPCproc", ;
5333 "Vnotes_zzoordrd_860I","Vzzoordrd_860I" )
5334 ENDIF
5335 *=== TR 1016589 NH
5336 ENDIF
5337
5338 .UpdateThermoCaption("Sending data back to server...")
5339 .InitThermo(5)
5340 *--- TR 1019356 NH - when Auto_proc flag is not set then only update the transactions tables.
5341 IF tcEiPCth.Auto_proc <> "Y"
5342 .lUpdate860Records = .T.
5343 .lUpdateSalesOrder = .F.
5344 .lDelete860Records = .F.
5345 .lOneDetailLineBad = .T.
5346 .lDelete860Records = .f.
5347 .lUpdateCancelViews = .f.
5348 ENDIF
5349 *=== TR 1019356 NH
5350
5351
5352 * Only update if something happened:
5353 IF .lUpdateSalesOrder OR .lUpdate860Records OR (.lDelete860Records AND NOT .lOneDetailLineBad)
5354 IF .lCreatedRatioCursor AND NOT .lOneDetailLineBad
5355 * This batch involved some cancellations. oBPOCancel.ProcessCancelByOrder()
5356 * finalizes these by taking the data in the Ratio Cursor and performing
5357 * some magic to create the cancel and header records:
5358 llRetVal = .oBPOCancel.ProcessCancelByOrder(Vzzoordrh_860I.pkey)
5359 IF llRetVal
5360 .lUpdateCancelViews = true
5361 * Check to see if Vzzoordrh/d_860I is supposed to be updated. Since
5362 * the cancel cursors are to be updated already, instead of doing two
5363 * updates to the backend, move any potentially changed fields on SO
5364 * views back to the Ratio Sales Order Views, and do the tableupdate
5365 * on them instead of normal SO views:
5366 IF .lUpdateSalesOrder
5367 * A header record becomes two header records, one with Cncl_Num filled in.
5368 * A detail record keeps its PKey, but gets a few fields like FKey, Line_Type, Cncl_Date changed.
5369
5370 *--- TR 1028909 15-Jul-2008 Goutam Added altpo, po_desc in the following replace statement.
5371
5372 REPLACE ALL ;
5373 start_date WITH Vzzoordrh_860I.start_date, ;
5374 end_date WITH Vzzoordrh_860I.end_date, ;
5375 altpo WITH Vzzoordrh_860I.altpo, ;
5376 po_desc WITH Vzzoordrh_860I.po_desc, ;
5377 User_id WITH Vzzoordrh_860I.User_id, ;
5378 Last_mod WITH Vzzoordrh_860I.Last_mod ;
5379 IN Vzzoordrh_Ratio_Confirm
5380
5381 SELECT Vzzoordrd_860I
5382 SCAN
5383 SELECT Vzzoordrd_Ratio_Confirm
5384 LOCATE FOR pkey = Vzzoordrd_860I.pkey
5385 IF FOUND()
5386 REPLACE ;
5387 start_date WITH Vzzoordrd_860I.start_date, ;
5388 end_date WITH Vzzoordrd_860I.end_date, ;
5389 Price WITH Vzzoordrd_860I.Price, ;
5390 Retail1 WITH Vzzoordrd_860I.Retail1, ;
5391 Retail2 WITH Vzzoordrd_860I.Retail2, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
5392 User_id WITH Vzzoordrd_860I.User_id, ;
5393 Last_mod WITH Vzzoordrd_860I.Last_mod ;
5394 IN Vzzoordrd_Ratio_Confirm
5395 ENDIF
5396 ENDSCAN
5397
5398 .lUpdateSalesOrder = false
5399 = .TABLEREVERT("Vzzoordrh_860I")
5400 = .TABLEREVERT("Vzzoordrd_860I")
5401
5402 ENDIF
5403
5404 ELSE
5405 .RecordError("Could not perform cancellation.")
5406 .lUpdate860Records = true
5407 .lUpdateCancelViews = false
5408 ENDIF
5409 ENDIF
5410
5411 llBeganTransaction = .BeginTransaction()
5412
5413 IF .lUpdateSalesOrder AND NOT .lOneDetailLineBad
5414 llRetVal = llRetVal AND .TABLEUPDATE("Vzzoordrh_860I")
5415 .AdvanceThermo(1)
5416
5417 llRetVal = llRetVal AND .TABLEUPDATE("Vzzoordrd_860I")
5418 IF llRetVal
5419 .nProcessed = .nProcessed + 1
5420 ENDIF
5421 ENDIF
5422
5423 * Probably not the best place for this, but...
5424 * If any comments exist in comments table (zzeipctc),
5425 * shoot em to the backend:
5426 *!* SELECT tceipctc
5427 *!* SEEK lnPKey
5428 *!* SCAN WHILE FKey = lnPKey
5429 *!* lcSQLString = "INSERT INTO zzoordcd " + CHR(13) + ;
5430 *!* " (Ord_Num, Line_Num, Cmt_Code, Cmmnt, Notes, User_ID, Last_Mod, PKey, FKey)" + CHR(13) + ;
5431 *!* "VALUES " + CHR(13) + ;
5432 *!* " (" + ;
5433 *!* SQLFormatNum(tceipctc.Ord_Num) + ", " + ;
5434 *!* SQLFormatNum(tceipctc.Line_Num) + ", " + ;
5435 *!* SQLFormatChar(tceipctc.Cmt_Code) + ", " + ;
5436 *!* SQLFormatChar(tceipctc.Cmmnt) + ", " + ;
5437 *!* "'', " + ;
5438 *!* SQLFormatChar(goEnv.cUser) + ;
5439 *!* ", " + SQLFormatTS(DATETIME()) + ", " + ;
5440 *!* SQLFormatNum(v_NextPKey("zzoordcd")) + ", " + ;
5441 *!* SQLFormatNum(Vzzoordrh_860I.PKey) + " )"
5442
5443 *!* llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5444 *!* ENDSCAN
5445
5446 IF .lUpdate860Records
5447 lcSQLString = ;
5448 "UPDATE zzeipcth SET " + ;
5449 " Errs_Msg_H = " + SQLFormatChar(tcEiPCth.Errs_msg_H) + ;
5450 ", Errs_Flg_H = " + SQLFormatChar(tcEiPCth.Errs_flg_h) + ;
5451 ", Last_Mod = " + SQLFormatTS(DATETIME()) + ;
5452 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5453 ", Store = " + SQLFormatChar(tcEiPCth.STORE) + ;
5454 ", Customer = " + SQLFormatChar(tcEiPCth.customer) + ;
5455 ", Ord_Num = " + SQLFormatNum (tcEiPCth.Ord_Num) + ;
5456 ", Season = " + SQLFormatChar(tcEiPCth.Season) + ;
5457 ", Pick_Num = " + SQLFormatNum (tcEiPCth.Pick_Num) + ;
5458 ", Center_Code = " + SQLFormatChar(tcEiPCth.Center_Code) + ;
5459 ", PO_Type = " + SQLFormatChar(tcEiPCth.PO_Type) + ;
5460 ", PO_Date = " + SQLFormatTS (tcEiPCth.PO_Date) + ;
5461 ", PO_Purp = " + SQLFormatChar(tcEiPCth.PO_Purp) + ;
5462 ", Auto_Proc = " + SQLFormatChar(tcEiPCth.Auto_Proc) + ;
5463 ", Resv_Label = " + SQLFormatChar(tcEiPCth.resv_label) + ;
5464 " WHERE PKey = " + SQLFormatNum(lnPKey)
5465 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5466
5467 lnPKey = tcEiPCth.pkey
5468 SELECT tcEiPCtd
5469
5470 SEEK lnPKey
5471 SCAN WHILE fkey = lnPKey
5472 lcSQLString = ;
5473 "UPDATE zzeipctd SET " + ;
5474 " Division = " + SQLFormatChar(tcEiPCtd.division) + ;
5475 ", Errs_Msg_D = " + SQLFormatChar(tcEiPCtd.Errs_Msg_D) + ;
5476 ", Style = " + SQLFormatChar(tcEiPCtd.STYLE) + ;
5477 ", Color_Code = " + SQLFormatChar(tcEiPCtd.color_code) + ;
5478 ", Lbl_Code = " + SQLFormatChar(tcEiPCtd.lbl_code) + ;
5479 ", Dimension = " + SQLFormatChar(tcEiPCtd.DIMENSION) + ;
5480 ", SizeBucket = " + SQLFormatNum (tcEiPCtd.Sizebucket) + ;
5481 ", Errs_Flg_D = " + SQLFormatChar(tcEiPCtd.Errs_Flg_D) + ;
5482 ", Last_Mod = " + SQLFormatTS (DATETIME()) + ;
5483 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5484 IIF(this.lResl_delv,", Delv_code = " + SQLFormatChar(tcEiPCtd.Delv_code),"") + ; && TR 1019356 NH
5485 " WHERE PKey = " + SQLFormatNum (tcEiPCtd.pkey)
5486 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5487 ENDSCAN
5488 ENDIF
5489
5490 IF .lDelete860Records AND NOT .lOneDetailLineBad
5491 * This done via a trigger on zzeipctd (the last detail line to be deleted wipes out the header:
5492 * llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipcth where PKey = " + SQLFormatNum(lnPKey))
5493 * If no records exist on detail, trigger will never fire, thus:
5494 * Trigger not working correctly. Since it's all or nothing anyway, just perform
5495 * delete on both tables:
5496 * IF RECCOUNT("tceipctd") > 0
5497 llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipctd where FKey = " + SQLFormatNum(tcEiPCth.pkey))
5498 * ELSE
5499 llRetVal = llRetVal AND v_SQLExec("DELETE FROM zzeipcth where PKey = " + SQLFormatNum(tcEiPCth.pkey))
5500 * ENDIF
5501 *--- TR 1016589 NH
5502 *--- send view to server
5503 llRetVal = llRetVal and .TABLEUPDATE('Vnotes_ipch_iPCproc')
5504 llRetVal = llRetVal and .TABLEUPDATE('Vnotes_ipcd_iPCproc')
5505 *=== TR 1016589 NH
5506 ENDIF
5507
5508 IF .lUpdateCancelViews AND NOT .lOneDetailLineBad
5509 llRetVal = llRetVal AND .TABLEUPDATE(@laRatioViews)
5510 *--- TR 1016589 NH
5511 llRetVal = llRetVal and .TABLEUPDATE("Vnotes_zzoordrh_860I")
5512 llRetVal = llRetVal and .TABLEUPDATE("Vnotes_zzoordrd_860I")
5513 *=== TR 1016589 NH
5514
5515 IF llRetVal
5516 .nProcessed = .nProcessed + 1
5517 ENDIF
5518 ENDIF
5519
5520 IF llBeganTransaction
5521 IF llRetVal
5522 .EndTransaction()
5523 ELSE
5524 .RollbackTransaction()
5525 llRetVal = .F.
5526 ENDIF
5527 ENDIF
5528 ENDIF && .lUpdateSalesOrder OR .lUpdate860Records OR (.lDelete860Records AND NOT .lOneDetailLineBad)
5529
5530 IF .lOneDetailLineBad
5531 llRetVal = llRetVal AND .TABLEREVERT("Vzzoordrh_860I")
5532 llRetVal = llRetVal AND .TABLEREVERT("Vzzoordrd_860I")
5533 ENDIF
5534
5535 ELSE
5536 *--- requery failed
5537
5538 *--- TR 1021052 24-Aug-2007 Goutam
5539 IF Not .lNewOrder AND RECCOUNT("Vzzoordrh_860I") > 0
5540 .RecordHeaderError("Flag to create new sales order is set to N.")
5541 ENDIF
5542 *=== TR 1021052 24-Aug-2007 Goutam
5543
5544 *- 1014475 01/16/06 YIK
5545 *- either order not found or it is partially picked.
5546 IF RECCOUNT("Vzzoordrh_860I") = 0
5547 * Corresponding Sales Odor not found:
5548 *- 1015584 02/14/06 YIK
5549 *- .RecordError("Corresponding sales order not found.")
5550
5551 *--- TR 1021052 20-Sep-2007 Goutam
5552 *.RecordHeaderError("Corresponding sales order not found.")
5553 .RecordHeaderError("Corresponding sales order not found/Flag to create new sales order is set to N.")
5554 *=== TR 1021052 20-Sep-2007 Goutam
5555 ELSE
5556 *- more than 1 header - partially picked
5557 *- 1015584 02/14/06 YIK
5558 *- .RecordError("Corresponding sales order is partially picked. Cannot process.")
5559 .RecordHeaderError("Corresponding sales order is partially picked. Cannot process.")
5560 ENDIF
5561
5562 *= 1014475
5563 llBeganTransaction = .BeginTransaction()
5564 lcSQLString = ;
5565 "UPDATE zzeipcth SET " + ;
5566 " Errs_Msg_H = " + SQLFormatChar(tcEiPCth.Errs_msg_H) + ;
5567 ", Errs_Flg_H = " + SQLFormatChar(tcEiPCth.Errs_flg_h) + ;
5568 ", Last_Mod = " + SQLFormatTS(DATETIME()) + ;
5569 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5570 ", Store = " + SQLFormatChar(tcEiPCth.STORE) + ;
5571 ", Customer = " + SQLFormatChar(tcEiPCth.customer) + ;
5572 ", Ord_Num = " + SQLFormatNum (tcEiPCth.Ord_Num) + ;
5573 ", Season = " + SQLFormatChar(tcEiPCth.Season) + ;
5574 ", Pick_Num = " + SQLFormatNum (tcEiPCth.Pick_Num) + ;
5575 ", Center_Code = " + SQLFormatChar(tcEiPCth.Center_Code) + ;
5576 ", PO_Type = " + SQLFormatChar(tcEiPCth.PO_Type) + ;
5577 ", PO_Date = " + SQLFormatTS (tcEiPCth.PO_Date) + ;
5578 ", PO_Purp = " + SQLFormatChar(tcEiPCth.PO_Purp) + ;
5579 ", Auto_Proc = " + SQLFormatChar(tcEiPCth.Auto_Proc) + ;
5580 ", Resv_Label = " + SQLFormatChar(tcEiPCth.resv_label) + ;
5581 " WHERE PKey = " + SQLFormatNum(lnPKey)
5582 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5583
5584 lcSQLString = ;
5585 "UPDATE zzeipctd SET " + ;
5586 " Division = " + SQLFormatChar(tcEiPCtd.division) + ;
5587 ", Errs_Msg_D = " + SQLFormatChar(tcEiPCtd.Errs_Msg_D) + ;
5588 ", Style = " + SQLFormatChar(tcEiPCtd.STYLE) + ;
5589 ", Color_Code = " + SQLFormatChar(tcEiPCtd.color_code) + ;
5590 ", Lbl_Code = " + SQLFormatChar(tcEiPCtd.lbl_code) + ;
5591 ", Dimension = " + SQLFormatChar(tcEiPCtd.DIMENSION) + ;
5592 ", SizeBucket = " + SQLFormatNum (tcEiPCtd.Sizebucket) + ;
5593 ", Errs_Flg_D = " + SQLFormatChar(tcEiPCtd.Errs_Flg_D) + ;
5594 ", Last_Mod = " + SQLFormatTS (DATETIME()) + ;
5595 ", User_ID = " + SQLFormatChar(goEnv.cUser) + ;
5596 " WHERE PKey = " + SQLFormatNum (tcEiPCtd.pkey)
5597 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5598
5599 IF llBeganTransaction
5600 IF llRetVal
5601 .EndTransaction()
5602 ELSE
5603 .RollbackTransaction()
5604 llRetVal = .F.
5605 ENDIF
5606 ENDIF
5607 ENDIF && Requery
5608 *--- TR 1016589 NH
5609 llRetVal = llRetVal AND .TABLEREVERT("Vnotes_zzoordrh_860I")
5610 llRetVal = llRetVal AND .TABLEREVERT("Vnotes_zzoordrd_860I")
5611 *=== TR 1016589 NH
5612
5613 .AdvanceThermo(2*RECNO("tceipcth")/.nToProcess)
5614
5615 IF NOT llRetVal
5616 * Connectivity or other DB probs - exit out of scan.
5617 EXIT
5618 ENDIF
5619
5620 ENDSCAN && 860 Header
5621
5622 .cMessage = ALLTRIM(STR(.nProcessed)) + " 860 inbound record(s) were successfully processed."
5623 IF .nProcessed < .nToProcess
5624 .cMessage = .cMessage + CRLF + ALLTRIM(STR(.nToProcess - .nProcessed)) + " 860 inbound record(s) failed processing."
5625 ENDIF
5626
5627 .oLog.LogEntry(.cMessage)
5628
5629 .AdvanceThermo(2)
5630 .AdvanceThermoTotal(2)
5631 INKEY(0.2)
5632
5633 IF .lScheduled
5634 .cMessage = MSG_DONT_PRINT && Don't print msg on exitM
5635 ENDIF
5636
5637 ENDIF && .lScheduled OR AskBox(lcMsg,,,true)
5638 ENDIF && .nToProcess = 0
5639
5640 .oLog.LogEntry("")
5641 * .oLog.CloseLog()
5642 ENDIF && CreateSOViews()
5643
5644 * Clean up -
5645
5646 * Close cursors:
5647 .AdvanceThermo(5)
5648 .UpdateThermoCaption("Cleaning up...")
5649
5650 .TableClose("tceipcth")
5651 .TableClose("tceipctd")
5652
5653 *!* * Get rid of the progress bar:
5654 *!* IF IsObject(.oFrmProgressBar) AND NOT IsNull(.oFrmProgressBar)
5655 *!* .m_Close()
5656 *!* ENDIF
5657
5658 * Destroy private variables:
5659 RELEASE pcCustomer, pcDivision, pnPO_Num, pcStore
5660
5661 *--- TR 1021052 18-SEP-2007 Goutam
5662 .cSQLTempTable = ""
5663
5664 ENDWITH
5665
5666 * v_SysUnLock(lcSyslockTablePath+"SYSLOCK", "EDI860INBOUND", goEnv.cCompany)
5667 SELECT (lnSelect)
5668 RETURN llRetVal
5669 ENDFUNC
5670
5671 *--- TR 1016589 NH
5672 **************************************************************************************
5673
5674 PROCEDURE AddHdrNotes
5675 LPARAMETERS pcEiPCth, pVzzeipcth_notes_860I, pVnotes_zzoordrh_860I, pVzzoordrh_860I
5676 LOCAL llRetVal, lnOldSelect, lnOrd_num, lcOrd_NTtyp, lnSeq, lcNotes_ipcd_pkeys
5677
5678 llRetVal = .t.
5679 lnOldselect = SELECT()
5680 lcNotes_ipcd_pkeys = ""
5681 *--- scan tran header notes
5682 *--- find same so header notes
5683 *--- add trans header notes to so header default note type
5684 SELECT (pVzzeipcth_notes_860I)
5685 SET ORDER TO "Fkey"
5686 *--- pVzzeipcth_notes_860I has notes for many trans header. first locate the current trans header notes
5687 IF SEEK(EVALUATE(pcEiPCth + ".PKEY"),pVzzeipcth_notes_860I,"fkey")
5688 SCAN WHILE FKEY = EVALUATE(pcEiPCth + ".PKEY")
5689 SCATTER NAME loHdrTransNotes memo
5690 *--- get ([customer + division + po_num + store] or order number) + note_type from tran header
5691 lcOrd_NTtyp = ALLTRIM(STR(EVALUATE(pVzzoordrh_860I + ".Ord_num"))) + loHdrTransNotes.note_type
5692 SELECT(pVnotes_zzoordrh_860I)
5693 *--- find the OrdHdrNotes for same notes type of transaction notes
5694 IF SEEK(lcOrd_NTtyp,pVnotes_zzoordrh_860I,"Ord_NTtyp")
5695
5696 *--- SO header notes exists then append to notes field
5697 replace notes WITH notes + loHdrTransNotes.notes IN (pVnotes_zzoordrh_860I)
5698
5699 ELSE
5700 *--- no SO header notes then create new notes
5701 *--- Trans hdr notes and SO hdr notes are all in samme sysnotes table.
5702 *--- get the max seq number
5703 lnOrd_num = EVALUATE(pVzzoordrh_860I + ".Ord_num")
5704 loHdrTransNotes.pkey = v_nextPkey('sysnotes')
5705 loHdrTransNotes.fkey = EVALUATE(pVzzoordrh_860I + ".PKEY")
5706 loHdrTransNotes.table_name = 'ZZOORDRH'
5707 loHdrTransNotes.Ord_num = lnOrd_num
5708 loHdrTransNotes.Seq = this.GetHdrNotesMaxSeq(lnOrd_num, pVnotes_zzoordrh_860I)
5709 SELECT (pVnotes_zzoordrh_860I)
5710 APPEND BLANK
5711 GATHER NAME loHdrTransNotes memo
5712 *--- update order header notes exists flag
5713 replace hasnotes WITH 'Y' IN (pVzzoordrh_860I)
5714 ENDIF
5715 DELETE IN (pVzzeipcth_notes_860I)
5716 ENDSCAN
5717 ENDIF
5718
5719 SELECT(lnOldSelect)
5720 RETURN llREtVal
5721 ENDPROC
5722
5723 **************************************************************************************
5724
5725 PROCEDURE AddDtlNotes
5726 LPARAMETERS pceIPCth, pcEiPCtd, pVnotes_IPCD_860I, pVnotes_zzoordrd_860I, pVzzoordrd_860I
5727
5728 LOCAL llRetVal, lnOldSelect, loDtlTransNotes, lczzoordrd_KEY
5729 LOCAL loPrevDtlTransNotes
5730 LOCAL lcNotes
5731
5732 llREtVal = .t.
5733 llContinue = .t.
5734 lcNote_type = ""
5735 lnOldSelect = SELECT()
5736 lcNotes = ""
5737
5738 *--- creating sysnotes cursor with group by detail sku
5739 LOCAL loSysnotes, lcSKU, lcSKU_NoteType, lcPrevSKU_NoteType
5740 STORE "" TO lcSKU, lcSKU_NoteType, lcPrevSKU_NoteType
5741 *--- get distinct BC_SKU, Note_type, Notes
5742 lcSQL = "Select d.division, d.style, d.color_code, d.lbl_code, d.dimension, n.note_type, " + ;
5743 " n.COMMENT, cast(n.Notes as varchar(2000)) as NOTES, 'N' as updated" + ;
5744 " from sysnotes n inner join zzeipctd d on d.pkey = n.fkey AND n.Table_name = 'ZZEIPCTD' " + ;
5745 " inner join zzeipcth h on h.pkey = d.fkey where h.customer = '" + pcCustomer + "' " + ;
5746 " and h.division = '" + pcDivision + "' and h.po_num = '" + pnPO_Num + "'" + ;
5747 " and h.store = '" + pcStore + "'" + ;
5748 " 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)) " + ;
5749 " 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)) "
5750
5751 llRetVal = llRetVal and v_SQLExec(lcSQL, "SKU_SysNotesRO") and USED("SKU_SysNotesRO")
5752 IF llRetVal
5753 *--- get writeable cursor and also aggregate Notes base on SKU and Note_Type
5754 .CreateRWCursorFromROCursor("SKU_SysNotesRO","SKU_SysNotes")
5755 SELECT SKU_SysNotesRO
5756 SCAN
5757 SCATTER NAME loSysnotes memo
5758 lcSKU_NoteType = loSysNotes.division + loSysNotes.style + loSysNotes.color_code + ;
5759 loSysNotes.lbl_code + loSysNotes.dimension + loSysNotes.Note_Type
5760
5761 IF lcPrevSKU_NoteType = lcSKU_NoteType
5762 *--- same notes type of same detail line do not add new record
5763 IF NOT (loSysnotes.Notes $ SKU_SysNotes.Notes)
5764 Replace Notes WITH Notes + ALLTRIM(loSysnotes.Notes) IN SKU_SysNotes
5765 ENDIF
5766 ELSE
5767 *--- add new record
5768 SELECT SKU_SysNotes
5769 APPEND BLANK
5770 GATHER NAME loSysNotes memo
5771 *--- clear lcNotes which has notes data of previous Note_type
5772 ENDIF
5773 lcPrevSKU_NoteType = lcSKU_NoteType
5774 ENDSCAN
5775 Release loSysnotes
5776
5777 *--- Update Order detail Notes with Trans detail Notes
5778 SELECT ("SKU_SysNotes")
5779 SCAN
5780 SCATTER NAME loSysNotes memo
5781 lcSKU = loSysNotes.division + loSysNotes.style + loSysNotes.color_code + ;
5782 loSysNotes.lbl_code + loSysNotes.dimension
5783
5784 IF SEEK(lcSKU, pVzzoordrd_860I,"OUR_SKU")
5785 lcFkeyNoteType = ALLTRIM(STR(EVALUATE(pVzzoordrd_860I + ".PKEY"))) + loSysNotes.Note_type
5786 IF SEEK(lcFkeyNoteType, pVnotes_zzoordrd_860I, "FkeyNT")
5787 *--- already Notes of this Note_type exists for this order detail
5788 *--- just append to the notes
5789 replace Notes WITH ALLTRIM(Notes) + IIF(EMPTY(Notes),"",CRLF) + ALLTRIM(loSysNotes.Notes) IN (pVnotes_zzoordrd_860I)
5790 ELSE
5791 SELECT (pVnotes_zzoordrd_860I)
5792 SCATTER NAME loOrdd_Notes MEMO BLANK
5793 loOrdd_Notes.ord_num = EVALUATE(pVzzoordrd_860I + ".Ord_num")
5794 loOrdd_Notes.FKEY = EVALUATE(pVzzoordrd_860I + ".PKEY")
5795 loOrdd_Notes.LINE_SEQ = EVALUATE(pVzzoordrd_860I + ".LINE_SEQ")
5796 loOrdd_Notes.SEQ = .GetMaxDTLNoteSEQ(pVnotes_zzoordrd_860I, EVALUATE(pVzzoordrd_860I + ".Pkey"))
5797 loOrdd_Notes.TABLE_NAME = "ZZOORDRD"
5798 loOrdd_Notes.Pkey = v_nextPkey('sysnotes')
5799 loOrdd_Notes.Notes = loSysNotes.Notes
5800 loOrdd_Notes.Note_type = loSysNotes.Note_type
5801 loOrdd_Notes.Comment = loSysNotes.Comment
5802 loOrdd_Notes.CascadeNote = 'N'
5803 loOrdd_Notes.User_id = goEnv.cUser
5804 loOrdd_Notes.last_mod = DATETIME()
5805
5806 SELECT (pVnotes_zzoordrd_860I)
5807 APPEND BLANK
5808 GATHER NAME loOrdd_Notes memo
5809 *--- set order detail notes exists flag
5810 REPLACE hasnotes WITH 'Y' IN (pVzzoordrd_860I)
5811 ENDIF
5812 *--- record which has been updated.
5813 replace Updated WITH 'Y' IN SKU_SysNotes
5814 ELSE
5815 ASSERT .f. message "Orphan order detail Notes!!"
5816 ENDIF
5817 ENDSCAN
5818
5819 *--- update transaction detail notes view
5820 *--- fine matching transaction detail records for division, style, color_code, lbl_code, dimension
5821 *--- this trans detail view has been created for a single order
5822 LOCAL loSKU, lcIPCH_Pkey
5823 lcIPCH_Pkey = EVALUATE(pcEiPcth + ".pkey")
5824 SELECT ("SKU_SysNotes")
5825 SCAN FOR Updated = "Y"
5826 lcSKU = division + style + color_code + lbl_code + dimension
5827 *--- go to detail of current header
5828 IF SEEK(lcIPCH_Pkey,pcEiPCtd,"FKEY")
5829 SELECT (pcEiPCtd)
5830 *--- travers through detail to find out matching sku
5831 SCAN WHILE fkey = lcIPCH_Pkey
5832 IF division + style + color_code + lbl_code + dimension = lcSKU
5833 *--- matching detail found for the SKU
5834 *--- now find the notes of this detail
5835 IF SEEK(EVALUATE(pcEiPCtd + ".pkey"),pVnotes_IPCD_860I,"fkey")
5836 *--- notes found now delete this notes from the view
5837 SELECT(pVnotes_IPCD_860I)
5838 SCAN WHILE fkey = EVALUATE(pcEiPCtd + ".pkey")
5839 DELETE IN (pVnotes_IPCD_860I)
5840 ENDSCAN
5841 ENDIF
5842 ENDIF
5843 ENDSCAN
5844 ENDIF
5845 ENDSCAN
5846
5847 IF USED("SKU_SysNotesRO")
5848 USE IN SKU_SysNotesRO
5849 ENDIF
5850 IF USED("SKU_SysNotes")
5851 USE IN SKU_SysNotes
5852 ENDIF
5853 ENDIF
5854
5855 SELECT(lnOldSelect)
5856 return llRetVal
5857 ENDPROC
5858
5859 **************************************************************************************
5860
5861 PROCEDURE GetHdrNotesMaxSeq
5862 LPARAMETERS pnOrd_num, pVnotes_zzoordrh_860I
5863
5864 LOCAL lnSeq, lnOldSelect
5865 lnOldSelect = SELECT()
5866 SELECT (pVnotes_zzoordrh_860I)
5867 lnSeq = 0
5868 SCAN FOR ord_num = pnOrd_num
5869 IF lnSeq < EVALUATE(pVnotes_zzoordrh_860I + ".SEQ")
5870 lnSeq = EVALUATE(pVnotes_zzoordrh_860I + ".SEQ")
5871 ENDIF
5872 ENDSCAN
5873 lnSeq = lnSeq + 1
5874 SELECT(lnOldSelect)
5875 RETURN lnSeq
5876 ENDPROC
5877
5878 **************************************************************************************
5879
5880 PROCEDURE GetMaxDTLNoteSEQ
5881 LPARAMETERS pVnotes_zzoordrd_860I, pnPkey
5882 LOCAL lnSeq, lnOldSelect
5883 lnOldSelect = SELECT()
5884 SELECT (pVnotes_zzoordrd_860I)
5885 lnSeq = 0
5886 SCAN FOR fkey = pnPkey
5887 IF lnSeq < EVALUATE(pVnotes_zzoordrd_860I + ".SEQ")
5888 lnSeq = EVALUATE(pVnotes_zzoordrd_860I + ".SEQ")
5889 ENDIF
5890 ENDSCAN
5891 lnSeq = lnSeq + 1
5892 SELECT(lnOldSelect)
5893 RETURN lnSeq
5894 ENDPROC
5895
5896
5897 **************************************************************************************
5898 *=== TR 1016589 NH
5899
5900 *=================================================
5901 *--- This routine is called inside a scan loop of detail : that for each detail this routine is called once
5902 *--- TR 1017210 NH
5903 FUNCTION ValidateDetail
5904 LPARAMETERS tnMaxOrdrdLine_seq, taDuplicateFields
5905 LOCAL lcQualifier, llRetVal, lcDivision, lnPO_Num, lcStore, lcCustomer, lnSizeBucket, lnQty_Change, ;
5906 llLineExists, llPicked, llInvoiced, llCartonized, llOrdud, lcCncl_Rsn, lcCncl_Type, lnCoeff && 1014475 12/27/05 YIK
5907
5908 *--- TR 1021052 24-Aug-2007 Goutam
5909 LOCAL llNewOrderExists
5910
5911 *--- TR 1028744 19-FEB-2008 VKK Added lcLineFilter
5912 LOCAL lcLineFilter
5913 lcLineFilter = ""
5914 *=== TR 1028744 19-FEB-2008 VKK Added lcLineFilter
5915
5916 llRetVal = .T.
5917 lcCustomer = tcEiPCth.customer
5918 lcDivision = tcEiPCth.division
5919 lnPO_Num = tcEiPCth.PO_Num
5920 lcStore = tcEiPCth.STORE
5921 lcQualifier = tcEiPCtd.Qualifier
5922 lnSizeBucket = tcEiPCtd.Sizebucket
5923 lnQty_Change = tcEiPCtd.Qty_change
5924 llPicked = .F.
5925 llInvoiced = .F.
5926 llCartonized = .F.
5927 llOrdud = .F.
5928 llWasDelete = .F.
5929
5930 *- 1014475 12/28/05 YIK
5931 lnCoeff = 1 && Used to update Ratio_confirm. If we increase qty, then lnCoeff = -1.
5932 THIS.lUpdateRatioCursor = .F.
5933
5934 lcSizeStr = ""
5935 FOR lnCnt = 1 TO THIS.nMaxSizes
5936 lcSizeStr = lcSizeStr + "Size" + PADL(lnCnt, 2, "0") + "_Qty WITH Vzzoordrd_860I.Size" + ;
5937 PADL(lnCnt, 2, "0") + "_Qty, "
5938 ENDFOR
5939 *-- lcReplaceStr = " REPLACE " + ;
5940 *-- " PKey WITH Vzzoordrd_860I.PKey, " + ;
5941 *-- " FKey WITH Vzzoordrd_860I.FKey, " + ;
5942 *-- " Last_Mod WITH DATETIME(), " + ;
5943 *-- " Total_Qty WITH Vzzoordrd_860I.Total_Qty, " + ;
5944 *-- lcSizeStr + ;
5945 *-- " ParKey WITH 0 IN VzzoUnits_Ratio_Confirm"
5946 *- removed ParKey
5947 lcReplaceStr = " REPLACE " + ;
5948 " PKey WITH Vzzoordrd_860I.PKey, " + ;
5949 " FKey WITH Vzzoordrd_860I.FKey, " + ;
5950 " Last_Mod WITH Vzzoordrd_860I.Last_Mod, " + ;
5951 lcSizeStr + ;
5952 " Total_Qty WITH Vzzoordrd_860I.Total_Qty " + ;
5953 " IN VzzoUnits_Ratio_Confirm"
5954
5955 *= 1014475 YIK
5956
5957 *lcMac = "Size" + PADL(ALLTRIM(STR(lnSizeBucket)), 2, "0") + "_Qty"
5958
5959 *--- TR 1028744 19-FEB-2008 VKK
5960 IF EMPTY(This.c860SODetailAddMatchCriteria)
5961 lcLineFilter = "1 = 1"
5962 ELSE
5963 lcLineFilter = This.c860SODetailAddMatchCriteria + " = tcEiPctd.line_id"
5964 ENDIF
5965 *=== TR 1028744 19-FEB-2008 VKK
5966
5967 SELECT Vzzoordrd_860I
5968 *--- TR 1028744 19-FEB-2008 VKK Added &lcLineFilter
5969 LOCATE FOR ;
5970 STYLE = tcEiPCtd.STYLE AND ;
5971 color_code = tcEiPCtd.color_code AND ;
5972 lbl_code = tcEiPCtd.lbl_code AND ;
5973 DIMENSION = tcEiPCtd.DIMENSION AND ;
5974 &lcLineFilter
5975
5976 llLineExists = FOUND("Vzzoordrd_860i")
5977
5978 IF lcQualifier = "AI" AND llLineExists
5979 * We are updating a qty on an existing line.
5980 lcQualifier = "QI"
5981 ENDIF
5982
5983 *--- TR 1021052 20-AUG-2007 HNISAR and Goutam
5984 * We are adding a line to an order that does not exist.
5985 llNewOrderExists = (lcQualifier = "QI" OR lcQualifier = "AI" ) AND NOT llLineExists
5986
5987 IF llNewOrderExists AND .lNewOrder AND NOT .lOrderExist
5988 llRetVal = llRetval AND .CreateNewStoreOrder(@taDuplicateFields)
5989 IF llRetval
5990 lcQualifier = "QI"
5991 ELSE
5992 .RecordHeaderError("Corresponding sales order not found.")
5993 .lOneDetailLineBad = .T.
5994 ENDIF
5995 ENDIF
5996 *=== TR 1021052 20-AUG-2007 HNISAR and Goutam
5997
5998 *--- TR 1019356 NH
5999 *--- Only for "AI" qualifier which is not just add qty
6000 *--- First get header start_date, end_date
6001 IF this.lResl_Delv
6002 llRetVal = llRetVal and this.SetDelvCodeForQualifierAI("tcEiPCth", "tcEiPCtd", "Vzzoordrh_860I")
6003 ENDIF
6004 *=== TR 1019356 NH
6005
6006 *- 1014475 01/17/06 YIK
6007 *- qualifier RZ sends new qty (or price), so we need to know
6008 *- the original qty to calculate qty_change
6009 IF lcQualifier = "RZ" AND llLineExists
6010 lnOrig_Qty = .GetQtyFromSizeBucket(tcEiPCtd.Sizebucket)
6011 lnQty_Change = lnQty_Change - lnOrig_Qty
6012 * Price Change -
6013 * Poc_Cost is Price, Poc_Price is Retail1.
6014 * Whichever is not 0 gets set.
6015 DO CASE
6016 CASE tcEiPCtd.POC_Cost <> 0
6017 IF NOT .lOneDetailLineBad
6018 REPLACE Price WITH tcEiPCtd.POC_Cost IN Vzzoordrd_860I
6019 .lUpdateSalesOrder = .T.
6020 .lDelete860Records = .T.
6021 ENDIF
6022 CASE tcEiPCtd.POC_Price <> 0
6023 IF NOT .lOneDetailLineBad
6024 REPLACE Retail1 WITH tcEiPCtd.POC_Price IN Vzzoordrd_860I
6025 .lUpdateSalesOrder = .T.
6026 .lDelete860Records = .T.
6027 ENDIF
6028 *--- TechRec 1054692 21-Sep-2011 jisingh ---
6029 CASE tcEiPCtd.POC_Retail2 <> 0
6030 IF NOT .lOneDetailLineBad
6031 REPLACE Retail2 WITH tcEiPCtd.POC_Retail2 IN Vzzoordrd_860I
6032 .lUpdateSalesOrder = .T.
6033 .lDelete860Records = .T.
6034 ENDIF
6035 *=== TechRec 1054692 21-Sep-2011 jisingh ===
6036 OTHERWISE
6037 ENDCASE
6038 DO CASE
6039 CASE lnQty_Change >= 0
6040 lcQualifier = "QI"
6041 CASE lnQty_Change < 0
6042 lcQualifier = "QD"
6043 *--- TR 1015747 NH/YIK : When it is QD we need to the Qty change number with out the (-) sign
6044 lnQty_Change = ABS(lnQty_Change)
6045 *=== TR 1015747
6046 ENDCASE
6047 ENDIF
6048
6049 IF llLineExists
6050 LOCAL lcSQLString
6051 IF vl_ctnpd2(Vzzoordrh_860I.Ord_Num, , "tcCartons" , Vzzoordrh_860I.Pick_Num, Vzzoordrh_860I.Inv_Num) AND ;
6052 USED("tcCartons") AND RECCOUNT("tcCartons") > 0
6053 llCartonized = .T.
6054 ENDIF
6055 USE IN SELECT("tcCartons")
6056
6057 lnPKey = vl_ORDUD( Vzzoordrd_860I.Ord_Num, "PKey",, Vzzoordrd_860I.line_seq)
6058 IF TYPE("lnPKey") = "N" AND lnPKey > 0
6059 llOrdud = .T.
6060 ENDIF
6061
6062 lcSQLString = ;
6063 "select 'o' as source, ord_num, line_seq, line_status, pick_num, inv_num " + ;
6064 " from zzoordrd " + ;
6065 " where ord_num = " + SQLFormatNum(Vzzoordrd_860I.Ord_Num) + ;
6066 " and line_seq = " + SQLFormatNum(Vzzoordrd_860I.line_seq) + ;
6067 "union " + ;
6068 "select 's' as source, ord_num, line_seq, line_status, pick_num, inv_num " + ;
6069 " from zzoshprd " + ;
6070 " where ord_num = " + SQLFormatNum(Vzzoordrd_860I.Ord_Num) + ;
6071 " and line_seq = " + SQLFormatNum(Vzzoordrd_860I.line_seq)
6072 llRetVal = llRetVal AND v_SQLExec(lcSQLString, 'tcOrders')
6073 IF USED('tcOrders')
6074 SELECT tcOrders
6075 SCAN
6076 IF tcOrders.SOURCE = "S"
6077 llInvoiced = .T.
6078 ENDIF
6079
6080 IF tcOrders.Line_Status = "P"
6081 llPicked = .T.
6082 ENDIF
6083 ENDSCAN
6084 ENDIF
6085
6086 USE IN SELECT('tcOrders')
6087 ENDIF
6088
6089 WITH THIS
6090 * Any notes?
6091 IF llLineExists AND NOT EMPTY(tcEiPCtd.notes)
6092 * Look at clsmschg.InsertUpdateNote for an example of this.
6093 ENDIF
6094
6095 IF NOT EMPTY(tcEiPCth.notes)
6096 * Look at clsmschg.InsertUpdateNote for an example of this.
6097 ENDIF
6098 DO CASE
6099 CASE lcQualifier = "DI"
6100 * Delete record from zzoordrd
6101 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .T.)
6102
6103 * Validations -
6104 * 1) Line exists.
6105 * 2) Line is not partially / completely picked.
6106 * 3) Line is not partially / completely invoiced.
6107 * 4) Line is not partially / completely cartonized.
6108 * 5) zzoordud link.
6109 DO CASE
6110 CASE NOT llLineExists
6111 .RecordError("Sales Order detail line not found.")
6112 .lOneDetailLineBad = .T.
6113 CASE llPicked
6114 .RecordError("Sales Order detail line is partially or fully picked.")
6115 .lOneDetailLineBad = .T.
6116 CASE llInvoiced
6117 .RecordError("Sales Order detail line is partially or fully invoiced.")
6118 .lOneDetailLineBad = .T.
6119 CASE llCartonized
6120 .RecordError("Sales Order detail line is partially or fully cartonized.")
6121 .lOneDetailLineBad = .T.
6122 CASE llOrdud
6123 .RecordError("Sales Order detail line is hardlinked to a production order.")
6124 .lOneDetailLineBad = .T.
6125 OTHERWISE
6126 IF NOT .lOneDetailLineBad
6127 IF NOT .lCreatedRatioCursor
6128 lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
6129 lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
6130
6131 WITH THIS.oBPOCancel
6132 .CreateRatioCursor()
6133 .cCncl_Rsn = lcCncl_Rsn
6134 .cCncl_Type = lcCncl_Type
6135 ENDWITH
6136
6137 * Fill Ratio Cursor with values from sales order detail. Using all records so that if
6138 * other cancellations happen at detail level, we just find the lines' sizebuckets as
6139 * they come and wipe out their quantity(s). The cancellation class takes care of the
6140 * rest when oBPOCancel.ProcessCancelByOrder() is called.
6141 SELECT Vzzoordrd_860I
6142 .PushRecordSet()
6143 SCAN
6144 SELECT VzzoUnits_Ratio_Confirm
6145 APPEND BLANK
6146 *- 1014475 12/02/05 YIK
6147 *-- REPLACE ;
6148 *-- PKey WITH Vzzoordrd_860I.PKey, ;
6149 *-- FKey WITH Vzzoordrd_860I.FKey, ;
6150 *-- Last_Mod WITH DATETIME(), ;
6151 *-- Total_Qty WITH Vzzoordrd_860I.Total_Qty, ;
6152 *-- Size01_Qty WITH Vzzoordrd_860I.Size01_Qty, ;
6153 *-- Size02_Qty WITH Vzzoordrd_860I.Size02_Qty, ;
6154 *-- Size03_Qty WITH Vzzoordrd_860I.Size03_Qty, ;
6155 *-- Size04_Qty WITH Vzzoordrd_860I.Size04_Qty, ;
6156 *-- Size05_Qty WITH Vzzoordrd_860I.Size05_Qty, ;
6157 *-- Size06_Qty WITH Vzzoordrd_860I.Size06_Qty, ;
6158 *-- Size07_Qty WITH Vzzoordrd_860I.Size07_Qty, ;
6159 *-- Size08_Qty WITH Vzzoordrd_860I.Size08_Qty, ;
6160 *-- Size09_Qty WITH Vzzoordrd_860I.Size09_Qty, ;
6161 *-- Size10_Qty WITH Vzzoordrd_860I.Size10_Qty, ;
6162 *-- Size11_Qty WITH Vzzoordrd_860I.Size11_Qty, ;
6163 *-- Size12_Qty WITH Vzzoordrd_860I.Size12_Qty, ;
6164 *-- Size13_Qty WITH Vzzoordrd_860I.Size13_Qty, ;
6165 *-- Size14_Qty WITH Vzzoordrd_860I.Size14_Qty, ;
6166 *-- Size15_Qty WITH Vzzoordrd_860I.Size15_Qty, ;
6167 *-- Size16_Qty WITH Vzzoordrd_860I.Size16_Qty, ;
6168 *-- Size17_Qty WITH Vzzoordrd_860I.Size17_Qty, ;
6169 *-- Size18_Qty WITH Vzzoordrd_860I.Size18_Qty, ;
6170 *-- Size19_Qty WITH Vzzoordrd_860I.Size19_Qty, ;
6171 *-- Size20_Qty WITH Vzzoordrd_860I.Size20_Qty, ;
6172 *-- Size21_Qty WITH Vzzoordrd_860I.Size21_Qty, ;
6173 *-- Size22_Qty WITH Vzzoordrd_860I.Size22_Qty, ;
6174 *-- Size23_Qty WITH Vzzoordrd_860I.Size23_Qty, ;
6175 *-- Size24_Qty WITH Vzzoordrd_860I.Size24_Qty, ;
6176 *-- ParKey WITH 0 ;
6177 *-- IN VzzoUnits_Ratio_Confirm
6178
6179 &lcReplaceStr
6180 *= 1014475 12/02/05 YIK
6181 ENDSCAN
6182 .PopRecordSet()
6183
6184 .lCreatedRatioCursor = .T.
6185 ENDIF && Haven't populated ratio curso yet
6186
6187 lnQty_Change = .GetQtyFromSizeBucket(tcEiPCtd.Sizebucket)
6188 *- 1014475 12/27/05 YIK
6189 *- shouldn't we move this method AFTER ENDCASE
6190 *- so that the VzzoUnits_Ratio_Confirm is updated after ALL the changes.
6191 *-.UpdateRatioSizeBucket(Vzzoordrd_860I.PKey, tceipctd.SizeBucket, lnQty_Change)
6192 .lDelete860Records = .T.
6193 .lUpdateRatioCursor = .T.
6194
6195 ENDIF && NOT .lOneDetailLineBad
6196
6197 *!* lcQualifier = "QD"
6198 *!* lnQty_Change = .GetQtyFromSizeBucket(tceipctd.SizeBucket)
6199
6200 *!* REPLACE ;
6201 *!* Qty_Change WITH lnQty_Change ;
6202 *!* IN tceipctd
6203
6204 *!* llWasDelete = .T.
6205 ENDCASE
6206
6207 CASE lcQualifier = "CT"
6208 * Date change - Start_Date and/or End_Date will be populated:
6209 IF NOT .lOneDetailLineBad
6210 *--- TR 1015747 NH : data needs to be not empty also
6211 *IF tcEiPCtd.start_date <> {01/01/1900}
6212 IF NOT EMPTY(tcEiPCtd.start_date) AND tcEiPCtd.start_date <> {01/01/1900}
6213 *=== TR 1015747 NH
6214 REPLACE start_date WITH tcEiPCtd.start_date IN Vzzoordrd_860I
6215 IF Vzzoordrd_860I.end_date < tcEiPCtd.start_date
6216 REPLACE end_date WITH tcEiPCtd.start_date IN Vzzoordrd_860I
6217 ENDIF
6218 .lUpdateSalesOrder = .T.
6219 .lDelete860Records = .T.
6220 ENDIF
6221 *--- TR 1015747 NH : data needs to be not empty also
6222 *IF tcEiPCth.end_date <> {01/01/1900}
6223 IF NOT EMPTY(tcEiPCth.end_date) AND tcEiPCth.end_date <> {01/01/1900}
6224 *=== TR 1015474 NH
6225 REPLACE end_date WITH tcEiPCtd.end_date IN Vzzoordrd_860I
6226 .lUpdateSalesOrder = .T.
6227 .lDelete860Records = .T.
6228 ENDIF
6229 ENDIF
6230
6231 CASE lcQualifier = "PC"
6232 * Price Change -
6233 * Poc_Cost is Price, Poc_Price is Retail1.
6234 * Whichever is not 0 gets set.
6235 IF NOT llLineExists
6236 .RecordError("Sales Order detail line not found.")
6237 ELSE
6238 DO CASE
6239 CASE tcEiPCtd.POC_Cost <> 0
6240 IF NOT .lOneDetailLineBad
6241 REPLACE Price WITH tcEiPCtd.POC_Cost IN Vzzoordrd_860I
6242 .lUpdateSalesOrder = .T.
6243 .lDelete860Records = .T.
6244 ENDIF
6245 CASE tcEiPCtd.POC_Price <> 0
6246 IF NOT .lOneDetailLineBad
6247 REPLACE Retail1 WITH tcEiPCtd.POC_Price IN Vzzoordrd_860I
6248 .lUpdateSalesOrder = .T.
6249 .lDelete860Records = .T.
6250 ENDIF
6251 *--- TechRec 1054692 21-Sep-2011 jisingh ---
6252 CASE tcEiPCtd.POC_Retail2 <> 0
6253 IF NOT .lOneDetailLineBad
6254 REPLACE Retail2 WITH tcEiPCtd.POC_Retail2 IN Vzzoordrd_860I
6255 .lUpdateSalesOrder = .T.
6256 .lDelete860Records = .T.
6257 ENDIF
6258 *=== TechRec 1054692 21-Sep-2011 jisingh ===
6259 OTHERWISE
6260 .RecordError("New price not specified.")
6261 ENDCASE
6262 ENDIF
6263
6264 *--- TR 1028744 19-FEB-2008 VKK
6265 CASE lcQualifier = "DB" AND llLineExists
6266 * UDF FIelds
6267 IF NOT .lOneDetailLineBad
6268 REPLACE UDFOORDD1C WITH tcEiPCtd.UDFOORDD1C, ;
6269 UDFOORDD2C WITH tcEiPCtd.UDFOORDD2C IN Vzzoordrd_860I
6270 .lUpdateSalesOrder = .T.
6271 .lDelete860Records = .T.
6272 ENDIF
6273 *=== TR 1028744 19-FEB-2008 VKK
6274
6275 CASE lcQualifier = "AI"
6276 * Add new record to zzoordrd:
6277 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .F.)
6278 * Validations -
6279 * 1) Style/Color/Label/Dimension doesn't already exist.
6280 * NOTE: Per meetings on spec, no validations against style/color/etc.
6281 IF llLineExists
6282 .RecordError("Line already exists on sales order.")
6283 *- 1014475 12/28/05 YIK
6284 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6285 *- and the changes go through
6286 .lOneDetailLineBad = .T.
6287
6288 ELSE
6289 IF NOT .lOneDetailLineBad
6290 *--- TR 1017210 NH
6291 *--- making sure all fields have default value
6292 SELECT Vzzoordrd_860I
6293 SCATTER MEMVAR MEMO BLANK
6294 APPEND BLANK
6295 GATHER MEMVAR memo
6296 *=== TR 1017210 NH
6297
6298 SELECT Vzzoordrh_860I
6299 SCATTER MEMVAR
6300 SELECT Vzzoordrd_860I
6301 *--- TR 1017210 NH
6302*!* APPEND BLANK
6303 *=== TR 1017210 NH
6304 GATHER MEMVAR
6305 *--- TR 1017210 NH
6306 lnPkey_oordrd = v_nextPkey("zzoordrd")
6307 Replace fkey WITH pkey, pkey WITH lnPkey_oordrd IN Vzzoordrd_860I
6308
6309*!* REPLACE ;
6310*!* division WITH tcEiPCth.division, ;
6311*!* Ord_Num WITH tcEiPCth.Ord_Num, ;
6312*!* Pick_Num WITH tcEiPCth.Pick_Num, ;
6313*!* start_date WITH tcEiPCth.start_date, ;
6314*!* end_date WITH tcEiPCth.end_date, ;
6315*!* Cncl_Date WITH tcEiPCth.Cncl_Date, ;
6316*!* line_seq WITH tcEiPCtd.line_seq, ;
6317*!* STYLE WITH tcEiPCtd.STYLE, ;
6318*!* color_code WITH tcEiPCtd.color_code, ;
6319*!* lbl_code WITH tcEiPCtd.lbl_code, ;
6320*!* DIMENSION WITH tcEiPCtd.DIMENSION, ;
6321*!* Org_Price WITH tcEiPCtd.Org_Price, ;
6322*!* Total_Qty WITH 0 ;
6323*!* IN Vzzoordrd_860I
6324 .DefaultHeaderDataToDetail("Vzzoordrh_860I","Vzzoordrd_860I", @taDuplicateFields )
6325 tnMaxOrdrdLine_seq = tnMaxOrdrdLine_seq + 1
6326 Replace ;
6327 Cncl_Date WITH tcEiPCth.Cncl_Date, ;
6328 STYLE WITH tcEiPCtd.STYLE, ;
6329 color_code WITH tcEiPCtd.color_code, ;
6330 lbl_code WITH tcEiPCtd.lbl_code, ;
6331 DIMENSION WITH tcEiPCtd.DIMENSION, ;
6332 Org_Price WITH tcEiPCtd.Org_Price, ;
6333 line_seq WITH tnMaxOrdrdLine_seq, ;
6334 LINE_STATUS WITH Vzzoordrh_860I.Ord_status, ;
6335 Price WITH tcEiPCtd.poc_cost, ; && TR 1016560 NH :For AI item price needs to be populated by poc_price
6336 retail1 WITH tcEiPCtd.poc_price, ;
6337 retail2 WITH tcEiPCtd.poc_retail2, ; &&--- TechRec 1054692 21-Sep-2011 jisingh ===
6338 Total_Qty WITH 0 ;
6339 IN Vzzoordrd_860I
6340
6341 *--- TR 1019356 NH
6342 IF this.lResl_Delv
6343 replace delv_code with IIF(TYPE("tcEiPCtd.delv_code") == "C", tcEiPCtd.delv_code,delv_code) ; && TR 1019356 NH
6344 IN Vzzoordrd_860I
6345 ENDIF
6346 *=== TR 1019356 NH
6347
6348 .UpdateSizeBucket(lnSizeBucket, lnQty_Change, "QI")
6349 .lUpdateSalesOrder = .T.
6350 .lDelete860Records = .T.
6351 *- 1014475 12/27/05 YIK
6352 *- This action increases qty of the UPC being updated.
6353 lnCoeff = -1
6354 .lUpdateRatioCursor = .T.
6355
6356 ENDIF
6357 ENDIF
6358
6359 CASE lcQualifier = "QI" OR lcQualifier = "QD"
6360 * Increase the quantity by the amount in tceipctd.Qty_Change:
6361 * llRetVal = THIS.FindCorrespondingSalesOrder(lcDivision, lnPO_Num, lcStore, lcCustomer, .T.)
6362 * Validations:
6363 * Line exists.
6364 * If decreasing
6365 * Total_Qty > Qty_Change
6366 * Min/Mult???
6367 DO CASE
6368 *--- TR 1021052 21-AUG-2007 HNISAR & Goutam
6369 *CASE NOT llLineExists
6370 CASE NOT llLineExists AND NOT .lNewOrder AND .lOrderExist
6371 *=== TR 1021052 21-AUG-2007 HNISAR & Goutam
6372
6373 .RecordError("Sales Order detail line not found.")
6374 *- 1014475 12/28/05 YIK
6375 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6376 *- and the changes go through
6377 .lOneDetailLineBad = .T.
6378 CASE lcQualifier = "QD" AND NOT .ValidateDecrease(lnSizeBucket, lnQty_Change, lcQualifier)
6379 .RecordError("Quantity to decrease is more than found on sales order detail line.")
6380 *- 1014475 12/28/05 YIK
6381 *- Need to set up .lOneDetailLineBad, otherwise the error messages are discarded
6382 *- and the changes go through
6383 .lOneDetailLineBad = .T.
6384
6385 OTHERWISE
6386 IF NOT .lOneDetailLineBad
6387 IF lcQualifier = "QI"
6388 THIS.UpdateSizeBucket(lnSizeBucket, lnQty_Change, lcQualifier)
6389 .lUpdateSalesOrder = .T.
6390 .lDelete860Records = .T.
6391 *- 1014475 12/27/05 YIK
6392 *- This action increases qty of the UPC being updated.
6393 lnCoeff = -1
6394 .lUpdateRatioCursor = .T.
6395
6396 ELSE
6397 * Quantity Decrease - handle through cancellation class:
6398 IF NOT .lCreatedRatioCursor
6399 lcCncl_Rsn = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Rsn",,Vzzoordrh_860I.customer)
6400 lcCncl_Type = vl_ipccr(Vzzoordrh_860I.division, "Cncl_Type",,Vzzoordrh_860I.customer)
6401
6402 WITH THIS.oBPOCancel
6403 .CreateRatioCursor()
6404 .cCncl_Rsn = lcCncl_Rsn
6405 .cCncl_Type = lcCncl_Type
6406 ENDWITH
6407
6408 * Fill Ratio Cursor with values from sales order detail. Using all records so that if
6409 * other cancellations happen at detail level, we just find the lines' sizebuckets as
6410 * they come and wipe out their quantity(s). The cancellation class takes care of the
6411 * rest when oBPOCancel.ProcessCancelByOrder() is called.
6412 SELECT Vzzoordrd_860I
6413 .PushRecordSet()
6414 SCAN
6415 SELECT VzzoUnits_Ratio_Confirm
6416 APPEND BLANK
6417 *-- REPLACE ;
6418 *-- PKey WITH Vzzoordrd_860I.PKey, ;
6419 *-- FKey WITH Vzzoordrd_860I.FKey, ;
6420 *-- Last_Mod WITH DATETIME(), ;
6421 *-- Total_Qty WITH Vzzoordrd_860I.Total_Qty, ;
6422 *-- Size01_Qty WITH Vzzoordrd_860I.Size01_Qty, ;
6423 *-- Size02_Qty WITH Vzzoordrd_860I.Size02_Qty, ;
6424 *-- Size03_Qty WITH Vzzoordrd_860I.Size03_Qty, ;
6425 *-- Size04_Qty WITH Vzzoordrd_860I.Size04_Qty, ;
6426 *-- Size05_Qty WITH Vzzoordrd_860I.Size05_Qty, ;
6427 *-- Size06_Qty WITH Vzzoordrd_860I.Size06_Qty, ;
6428 *-- Size07_Qty WITH Vzzoordrd_860I.Size07_Qty, ;
6429 *-- Size08_Qty WITH Vzzoordrd_860I.Size08_Qty, ;
6430 *-- Size09_Qty WITH Vzzoordrd_860I.Size09_Qty, ;
6431 *-- Size10_Qty WITH Vzzoordrd_860I.Size10_Qty, ;
6432 *-- Size11_Qty WITH Vzzoordrd_860I.Size11_Qty, ;
6433 *-- Size12_Qty WITH Vzzoordrd_860I.Size12_Qty, ;
6434 *-- Size13_Qty WITH Vzzoordrd_860I.Size13_Qty, ;
6435 *-- Size14_Qty WITH Vzzoordrd_860I.Size14_Qty, ;
6436 *-- Size15_Qty WITH Vzzoordrd_860I.Size15_Qty, ;
6437 *-- Size16_Qty WITH Vzzoordrd_860I.Size16_Qty, ;
6438 *-- Size17_Qty WITH Vzzoordrd_860I.Size17_Qty, ;
6439 *-- Size18_Qty WITH Vzzoordrd_860I.Size18_Qty, ;
6440 *-- Size19_Qty WITH Vzzoordrd_860I.Size19_Qty, ;
6441 *-- Size20_Qty WITH Vzzoordrd_860I.Size20_Qty, ;
6442 *-- Size21_Qty WITH Vzzoordrd_860I.Size21_Qty, ;
6443 *-- Size22_Qty WITH Vzzoordrd_860I.Size22_Qty, ;
6444 *-- Size23_Qty WITH Vzzoordrd_860I.Size23_Qty, ;
6445 *-- Size24_Qty WITH Vzzoordrd_860I.Size24_Qty, ;
6446 *-- ParKey WITH 0 ;
6447 *-- IN VzzoUnits_Ratio_Confirm
6448
6449 &lcReplaceStr
6450 *= 1014475 12/02/05 YIK
6451
6452 ENDSCAN
6453 .PopRecordSet()
6454
6455 .lCreatedRatioCursor = .T.
6456 ENDIF && Haven't populated ratio curso yet
6457 *- 1014475 12/27/05 YIK
6458 *- Move this method after ENDCASE
6459 *- so that the VzzoUnits_Ratio_Confirm is updated after ALL the changes.
6460 *-.UpdateRatioSizeBucket(Vzzoordrd_860I.PKey, lnSizeBucket, lnQty_Change)
6461 .lDelete860Records = .T.
6462 .lUpdateRatioCursor = .T.
6463 *= 1014475
6464
6465 ENDIF
6466 ENDIF
6467 ENDCASE
6468 ENDCASE
6469 *- 1014475 12/27/05 YIK
6470 IF .lCreatedRatioCursor AND !.lOneDetailLineBad AND .lUpdateRatioCursor
6471 .UpdateRatioSizeBucket(Vzzoordrd_860I.pkey, lnSizeBucket, lnQty_Change, lnCoeff)
6472 ENDIF
6473 *=
6474 ENDWITH
6475
6476 RETURN llRetVal
6477 ENDFUNC
6478
6479 * ===============================================
6480
6481 *---- TR 1019356 NH
6482 *--- select only the AI records
6483 *---
6484 PROCEDURE SetDelvCodeForQualifierAI
6485 LPARAMETERS pcEiPCth, pcEiPCtd, pVzzoordrh_860I
6486
6487 LOCAL llRetVal, lnOldSelect, lcOldOrder
6488 lnOldSelect = SELECT()
6489 llRetVal = .t.
6490 SELECT(pcEiPCtd)
6491 IF qualifier = "AI"
6492
6493 *--- set tran header start and end data from Sales Order start date and end date
6494 *--- if tran header start and end data is empty
6495 this.SetStartEndDate(pcEiPCth,pVzzoordrh_860I)
6496 *--- Set season from Sales order when season is empty
6497 this.SetSeason(pcEiPCth,pVzzoordrh_860I)
6498 *--- cascase start and end data from header to detail trans
6499 this.SetStartEndDateFromHdrToDtl(pcEiPCth, pcEiPCtd)
6500 *--- resolve Delivery Code
6501 IF NOT this.oBPOSalesOrder.ResolveDelvCode2(pcEiPCth, pcEiPCtd)
6502 THIS.LogEntry("Delivery Code not resolved for PO# " + ;
6503 EVALUATE(pcEiPCth + ".Po_num") + ", customer " + EVALUATE(pcEiPCth + ".customer"))
6504 ENDIF
6505 ENDIF
6506 SELECT(lnOldSelect)
6507 RETURN llRetVal
6508 ENDPROC
6509
6510
6511 **************************************************************************************
6512
6513 PROCEDURE SetStartEndDateFromHdrToDtl
6514 LPARAMETERS pcEiPCth, pcEiPCtd
6515
6516 LOCAL llRetVal, lnOldSelect
6517 llRetVal = .t.
6518 lnOldSelect = SELECT()
6519
6520 IF EMPTY(EVALUATE(pcEiPCtd + ".start_date")) OR EVALUATE(pcEiPCtd + ".start_date") = {01/01/1900}
6521 REPLACE start_date WITH EVALUATE(pcEiPCth + ".start_date") IN (pcEiPCtd)
6522 ENDIF
6523
6524 IF EMPTY(EVALUATE(pcEiPCtd + ".end_date")) OR EVALUATE(pcEiPCtd + ".end_date") = {01/01/1900}
6525 REPLACE end_date WITH EVALUATE(pcEiPCth + ".end_date") IN (pcEiPCtd)
6526 ENDIF
6527
6528 RETURN llRetVal
6529
6530 ENDPROC
6531
6532 **************************************************************************************
6533
6534 PROCEDURE SetStartEndDateFromHdrToDtl
6535 LPARAMETERS pcEiPCth, pcEiPCtd
6536
6537 LOCAL llRetVal, lnOldSelect
6538 llRetVal = .t.
6539 lnOldSelect = SELECT()
6540
6541 IF EMPTY(EVALUATE(pcEiPCtd + ".start_date")) OR EVALUATE(pcEiPCtd + ".start_date") = {01/01/1900}
6542 REPLACE start_date WITH EVALUATE(pcEiPCth + ".start_date") IN (pcEiPCtd)
6543 ENDIF
6544
6545 IF EMPTY(EVALUATE(pcEiPCtd + ".end_date")) OR EVALUATE(pcEiPCtd + ".end_date") = {01/01/1900}
6546 REPLACE end_date WITH EVALUATE(pcEiPCth + ".end_date") IN (pcEiPCtd)
6547 ENDIF
6548
6549 RETURN llRetVal
6550
6551 ENDPROC
6552
6553 **************************************************************************************
6554
6555 PROCEDURE SetSeason
6556 LPARAMETERS pcEiPCth, pVzzoordrh_860I
6557
6558 LOCAL lnOldSelect, llRetVal
6559 llRetVal = .t.
6560 lnOldSelect = SELECT()
6561 SELECT(pcEiPCth)
6562 IF EMPTY(EVALUATE(pcEiPCth + ".season"))
6563 replace season WITH EVALUATE(pVzzoordrh_860I + ".season") in (pcEiPCth)
6564 ENDIF
6565 SELECT(lnOldSelect)
6566 RETURN llRetVal
6567 ENDPROC
6568
6569 **************************************************************************************
6570
6571 PROCEDURE SetStartEndDate
6572 LPARAMETERS pcEiPCth,pVzzoordrh_860I
6573 LOCAL llRetval, lnOldSelect
6574 lnOldSelect = SELECT()
6575 llRetval = .t.
6576 IF EMPTY(EVALUATE(pcEiPCth + ".Start_date"))
6577 replace start_date with EVALUATE(pVzzoordrh_860I + ".Start_date") in (pcEiPCth)
6578 ENDIF
6579
6580 IF EMPTY(EVALUATE(pcEiPCth + ".end_date"))
6581 replace end_date with EVALUATE(pVzzoordrh_860I + ".end_date") in (pcEiPCth)
6582 ENDIF
6583
6584 RETURN llRetVal
6585 ENDPROC
6586
6587 **************************************************************************************
6588 *=== TR 1019356 NH
6589
6590 FUNCTION UpdateRatioSizeBucket
6591 LPARAMETERS pnPKey, pnSizeBucket, pnQty_Change, pnCoeff && 1014475 12/27/05 YIK
6592
6593 *- 1014475 12/27/05 YIK
6594 *- We may need to increase qty if we add qty for one UPC along with deleting/decreasing qty
6595 *- for another. Added pnCoeff to handle that.
6596 SELECT VzzoUnits_Ratio_Confirm
6597 LOCATE FOR pkey = pnPKey
6598 IF FOUND()
6599 DO CASE
6600 CASE tcEiPCtd.Sizebucket = 1
6601 REPLACE ;
6602 Size01_Qty WITH Size01_Qty - pnCoeff*pnQty_Change, ;
6603 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6604 IN VzzoUnits_Ratio_Confirm
6605
6606 CASE tcEiPCtd.Sizebucket = 2
6607 REPLACE ;
6608 Size02_Qty WITH Size02_Qty - pnCoeff*pnQty_Change, ;
6609 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6610 IN VzzoUnits_Ratio_Confirm
6611
6612 CASE tcEiPCtd.Sizebucket = 3
6613 REPLACE ;
6614 Size03_Qty WITH Size03_Qty - pnCoeff*pnQty_Change, ;
6615 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6616 IN VzzoUnits_Ratio_Confirm
6617
6618 CASE tcEiPCtd.Sizebucket = 4
6619 REPLACE ;
6620 Size04_Qty WITH Size04_Qty - pnCoeff*pnQty_Change, ;
6621 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6622 IN VzzoUnits_Ratio_Confirm
6623
6624 CASE tcEiPCtd.Sizebucket = 5
6625 REPLACE ;
6626 Size05_Qty WITH Size05_Qty - pnCoeff*pnQty_Change, ;
6627 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6628 IN VzzoUnits_Ratio_Confirm
6629
6630 CASE tcEiPCtd.Sizebucket = 6
6631 REPLACE ;
6632 Size06_Qty WITH Size06_Qty - pnCoeff*pnQty_Change, ;
6633 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6634 IN VzzoUnits_Ratio_Confirm
6635
6636 CASE tcEiPCtd.Sizebucket = 7
6637 REPLACE ;
6638 Size07_Qty WITH Size07_Qty - pnCoeff*pnQty_Change, ;
6639 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6640 IN VzzoUnits_Ratio_Confirm
6641
6642 CASE tcEiPCtd.Sizebucket = 8
6643 REPLACE ;
6644 Size08_Qty WITH Size08_Qty - pnCoeff*pnQty_Change, ;
6645 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6646 IN VzzoUnits_Ratio_Confirm
6647
6648 CASE tcEiPCtd.Sizebucket = 9
6649 REPLACE ;
6650 Size09_Qty WITH Size09_Qty - pnCoeff*pnQty_Change, ;
6651 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6652 IN VzzoUnits_Ratio_Confirm
6653
6654 CASE tcEiPCtd.Sizebucket = 10
6655 REPLACE ;
6656 Size10_Qty WITH Size10_Qty - pnCoeff*pnQty_Change, ;
6657 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6658 IN VzzoUnits_Ratio_Confirm
6659
6660 CASE tcEiPCtd.Sizebucket = 11
6661 REPLACE ;
6662 Size11_Qty WITH Size11_Qty - pnCoeff*pnQty_Change, ;
6663 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6664 IN VzzoUnits_Ratio_Confirm
6665
6666 CASE tcEiPCtd.Sizebucket = 12
6667 REPLACE ;
6668 Size12_Qty WITH Size12_Qty - pnCoeff*pnQty_Change, ;
6669 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6670 IN VzzoUnits_Ratio_Confirm
6671
6672 CASE tcEiPCtd.Sizebucket = 13
6673 REPLACE ;
6674 Size13_Qty WITH Size13_Qty - pnCoeff*pnQty_Change, ;
6675 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6676 IN VzzoUnits_Ratio_Confirm
6677
6678 CASE tcEiPCtd.Sizebucket = 14
6679 REPLACE ;
6680 Size14_Qty WITH Size14_Qty - pnCoeff*pnQty_Change, ;
6681 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6682 IN VzzoUnits_Ratio_Confirm
6683
6684 CASE tcEiPCtd.Sizebucket = 15
6685 REPLACE ;
6686 Size15_Qty WITH Size15_Qty - pnCoeff*pnQty_Change, ;
6687 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6688 IN VzzoUnits_Ratio_Confirm
6689
6690 CASE tcEiPCtd.Sizebucket = 16
6691 REPLACE ;
6692 Size16_Qty WITH Size16_Qty - pnCoeff*pnQty_Change, ;
6693 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6694 IN VzzoUnits_Ratio_Confirm
6695
6696 CASE tcEiPCtd.Sizebucket = 17
6697 REPLACE ;
6698 Size17_Qty WITH Size17_Qty - pnCoeff*pnQty_Change, ;
6699 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6700 IN VzzoUnits_Ratio_Confirm
6701
6702 CASE tcEiPCtd.Sizebucket = 18
6703 REPLACE ;
6704 Size18_Qty WITH Size18_Qty - pnCoeff*pnQty_Change, ;
6705 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6706 IN VzzoUnits_Ratio_Confirm
6707
6708 CASE tcEiPCtd.Sizebucket = 19
6709 REPLACE ;
6710 Size19_Qty WITH Size19_Qty - pnCoeff*pnQty_Change, ;
6711 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6712 IN VzzoUnits_Ratio_Confirm
6713
6714 CASE tcEiPCtd.Sizebucket = 20
6715 REPLACE ;
6716 Size20_Qty WITH Size20_Qty - pnCoeff*pnQty_Change, ;
6717 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6718 IN VzzoUnits_Ratio_Confirm
6719
6720 CASE tcEiPCtd.Sizebucket = 21
6721 REPLACE ;
6722 Size21_Qty WITH Size21_Qty - pnCoeff*pnQty_Change, ;
6723 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6724 IN VzzoUnits_Ratio_Confirm
6725
6726 CASE tcEiPCtd.Sizebucket = 22
6727 REPLACE ;
6728 Size22_Qty WITH Size22_Qty - pnCoeff*pnQty_Change, ;
6729 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6730 IN VzzoUnits_Ratio_Confirm
6731
6732 CASE tcEiPCtd.Sizebucket = 23
6733 REPLACE ;
6734 Size23_Qty WITH Size23_Qty - pnCoeff*pnQty_Change, ;
6735 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6736 IN VzzoUnits_Ratio_Confirm
6737
6738 CASE tcEiPCtd.Sizebucket = 24
6739 REPLACE ;
6740 Size24_Qty WITH Size24_Qty - pnCoeff*pnQty_Change, ;
6741 Total_Qty WITH Total_Qty - pnCoeff*pnQty_Change ;
6742 IN VzzoUnits_Ratio_Confirm
6743 ENDCASE
6744 ENDIF
6745 ENDFUNC
6746
6747 * ===============================================
6748
6749 FUNCTION RecordError
6750 LPARAMETERS pcErrorMessage
6751
6752 * Record error in tceipctd.errs_msg_d, errs_flg_d / tceipcth.errs_msg_d / errs_flg_d:
6753 *- 1014475 12/28/05 YIK
6754 *- Append new error message to the existing.
6755 SELECT tcEiPCtd
6756 REPLACE ;
6757 Errs_Msg_D WITH Errs_Msg_D + pcErrorMessage + CHR(10) + CHR(13), ;
6758 Errs_Flg_D WITH "Y" ;
6759 IN tcEiPCtd
6760
6761 SELECT tcEiPCth
6762 REPLACE ;
6763 Errs_msg_H WITH Errs_msg_H + pcErrorMessage + CHR(10) + CHR(13), ;
6764 Errs_flg_h WITH "Y" ;
6765 IN tcEiPCth
6766
6767 THIS.lUpdate860Records = .T.
6768
6769 ENDFUNC
6770
6771 * ===============================================
6772
6773 PROCEDURE CancelSO
6774 LPARAMETERS pcCncl_Rsn, pcCncl_Type
6775 LOCAL llRetVal
6776 * Cancels an entire Sales Order.
6777
6778 * Create blank record in ratio cursor for each line item in SO detail:
6779 * NOTE: Vzzounits_Ratio_860I has been freshly created for POC_Purp = "01"
6780 SELECT Vzzoordrd_860I
6781
6782 SCAN
6783 SELECT VzzoUnits_Ratio_Confirm
6784 APPEND BLANK
6785 *- 1014475 12/21/05 YIK
6786 *- Replaced "Last_Mod WITH DATETIME()"
6787 REPLACE ;
6788 pkey WITH Vzzoordrd_860I.pkey, ;
6789 fkey WITH Vzzoordrd_860I.fkey, ;
6790 Last_mod WITH Vzzoordrd_860I.Last_mod ;
6791 IN VzzoUnits_Ratio_Confirm
6792 ENDSCAN
6793
6794 WITH THIS
6795 llRetVal = .oBPOCancel.ProcessCancelByOrder(Vzzoordrh_860I.pkey)
6796
6797 IF llRetVal
6798 .lUpdateSalesOrder = false
6799 .lUpdate860Records = false
6800 .lDelete860Records = true
6801 .lOneDetailLineBad = false
6802 .lUpdateCancelViews = true
6803 ELSE
6804 .RecordError("Could not perform cancellation.")
6805 .lUpdate860Records = true
6806 .lUpdateCancelViews = false
6807 ENDIF
6808 ENDWITH
6809
6810 ENDPROC
6811
6812 * ===============================================
6813
6814 FUNCTION GetQtyFromSizeBucket
6815 LPARAMETERS pnSizeBucket
6816 LOCAL lnRetVal
6817
6818 lnRetVal = 0
6819
6820 DO CASE
6821 CASE pnSizeBucket = 1
6822 lnRetVal = Vzzoordrd_860I.Size01_Qty
6823
6824 CASE pnSizeBucket = 2
6825 lnRetVal = Vzzoordrd_860I.Size02_Qty
6826
6827 CASE pnSizeBucket = 3
6828 lnRetVal = Vzzoordrd_860I.Size03_Qty
6829
6830 CASE pnSizeBucket = 4
6831 lnRetVal = Vzzoordrd_860I.Size04_Qty
6832
6833 CASE pnSizeBucket = 5
6834 lnRetVal = Vzzoordrd_860I.Size05_Qty
6835
6836 CASE pnSizeBucket = 6
6837 lnRetVal = Vzzoordrd_860I.Size06_Qty
6838
6839 CASE pnSizeBucket = 7
6840 lnRetVal = Vzzoordrd_860I.Size07_Qty
6841
6842 CASE pnSizeBucket = 8
6843 lnRetVal = Vzzoordrd_860I.Size08_Qty
6844
6845 CASE pnSizeBucket = 9
6846 lnRetVal = Vzzoordrd_860I.Size09_Qty
6847
6848 CASE pnSizeBucket = 10
6849 lnRetVal = Vzzoordrd_860I.Size10_Qty
6850
6851 CASE pnSizeBucket = 11
6852 lnRetVal = Vzzoordrd_860I.Size11_Qty
6853
6854 CASE pnSizeBucket = 12
6855 lnRetVal = Vzzoordrd_860I.Size12_Qty
6856
6857 CASE pnSizeBucket = 13
6858 lnRetVal = Vzzoordrd_860I.Size13_Qty
6859
6860 CASE pnSizeBucket = 14
6861 lnRetVal = Vzzoordrd_860I.Size14_Qty
6862
6863 CASE pnSizeBucket = 15
6864 lnRetVal = Vzzoordrd_860I.Size15_Qty
6865
6866 CASE pnSizeBucket = 16
6867 lnRetVal = Vzzoordrd_860I.Size16_Qty
6868
6869 CASE pnSizeBucket = 17
6870 lnRetVal = Vzzoordrd_860I.Size17_Qty
6871
6872 CASE pnSizeBucket = 18
6873 lnRetVal = Vzzoordrd_860I.Size18_Qty
6874
6875 CASE pnSizeBucket = 19
6876 lnRetVal = Vzzoordrd_860I.Size19_Qty
6877
6878 CASE pnSizeBucket = 20
6879 lnRetVal = Vzzoordrd_860I.Size20_Qty
6880
6881 CASE pnSizeBucket = 21
6882 lnRetVal = Vzzoordrd_860I.Size21_Qty
6883
6884 CASE pnSizeBucket = 22
6885 lnRetVal = Vzzoordrd_860I.Size22_Qty
6886
6887 CASE pnSizeBucket = 23
6888 lnRetVal = Vzzoordrd_860I.Size23_Qty
6889
6890 CASE pnSizeBucket = 24
6891 lnRetVal = Vzzoordrd_860I.Size24_Qty
6892
6893 ENDCASE
6894
6895 RETURN lnRetVal
6896 ENDFUNC
6897 * ===============================================
6898
6899 FUNCTION ValidateDecrease
6900 LPARAMETERS pnSizeBucket, pnQty_Change, pcQualifier
6901 LOCAL llRetVal
6902
6903 * CB - All of the less than comparisons in this room were less than or equal to's.
6904 * Removed the equal to because of a deadline (today) for ALPHA. Since DI's come through
6905 * this same code, this would never work. We may want to add a property to the class -
6906 * lWasDelete - and decide whether to do <= or < based on this. Currently a variable
6907 * is set in ValidateDetail() that says that the line was a delete.
6908
6909 IF Vzzoordrd_860I.Total_Qty < pnQty_Change
6910 RETURN .F.
6911 ENDIF
6912
6913 llRetVal = .T.
6914 DO CASE
6915 CASE pnSizeBucket = 1
6916 IF Vzzoordrd_860I.Size01_Qty < pnQty_Change
6917 llRetVal = .F.
6918 ENDIF
6919 CASE pnSizeBucket = 2
6920 IF Vzzoordrd_860I.Size02_Qty < pnQty_Change
6921 llRetVal = .F.
6922 ENDIF
6923 CASE pnSizeBucket = 3
6924 IF Vzzoordrd_860I.Size03_Qty < pnQty_Change
6925 llRetVal = .F.
6926 ENDIF
6927 CASE pnSizeBucket = 4
6928 IF Vzzoordrd_860I.Size04_Qty < pnQty_Change
6929 llRetVal = .F.
6930 ENDIF
6931 CASE pnSizeBucket = 5
6932 IF Vzzoordrd_860I.Size05_Qty < pnQty_Change
6933 llRetVal = .F.
6934 ENDIF
6935 CASE pnSizeBucket = 6
6936 IF Vzzoordrd_860I.Size06_Qty < pnQty_Change
6937 llRetVal = .F.
6938 ENDIF
6939 CASE pnSizeBucket = 7
6940 IF Vzzoordrd_860I.Size07_Qty < pnQty_Change
6941 llRetVal = .F.
6942 ENDIF
6943 CASE pnSizeBucket = 8
6944 IF Vzzoordrd_860I.Size08_Qty < pnQty_Change
6945 llRetVal = .F.
6946 ENDIF
6947 CASE pnSizeBucket = 9
6948 IF Vzzoordrd_860I.Size09_Qty < pnQty_Change
6949 llRetVal = .F.
6950 ENDIF
6951 CASE pnSizeBucket = 10
6952 IF Vzzoordrd_860I.Size10_Qty < pnQty_Change
6953 llRetVal = .F.
6954 ENDIF
6955 CASE pnSizeBucket = 11
6956 IF Vzzoordrd_860I.Size11_Qty < pnQty_Change
6957 llRetVal = .F.
6958 ENDIF
6959 CASE pnSizeBucket = 12
6960 IF Vzzoordrd_860I.Size12_Qty < pnQty_Change
6961 llRetVal = .F.
6962 ENDIF
6963 CASE pnSizeBucket = 13
6964 IF Vzzoordrd_860I.Size13_Qty < pnQty_Change
6965 llRetVal = .F.
6966 ENDIF
6967 CASE pnSizeBucket = 14
6968 IF Vzzoordrd_860I.Size14_Qty < pnQty_Change
6969 llRetVal = .F.
6970 ENDIF
6971 CASE pnSizeBucket = 15
6972 IF Vzzoordrd_860I.Size15_Qty < pnQty_Change
6973 llRetVal = .F.
6974 ENDIF
6975 CASE pnSizeBucket = 16
6976 IF Vzzoordrd_860I.Size16_Qty < pnQty_Change
6977 llRetVal = .F.
6978 ENDIF
6979 CASE pnSizeBucket = 17
6980 IF Vzzoordrd_860I.Size17_Qty < pnQty_Change
6981 llRetVal = .F.
6982 ENDIF
6983 CASE pnSizeBucket = 18
6984 IF Vzzoordrd_860I.Size18_Qty < pnQty_Change
6985 llRetVal = .F.
6986 ENDIF
6987 CASE pnSizeBucket = 19
6988 IF Vzzoordrd_860I.Size19_Qty < pnQty_Change
6989 llRetVal = .F.
6990 ENDIF
6991 CASE pnSizeBucket = 20
6992 IF Vzzoordrd_860I.Size20_Qty < pnQty_Change
6993 llRetVal = .F.
6994 ENDIF
6995 CASE pnSizeBucket = 21
6996 IF Vzzoordrd_860I.Size21_Qty < pnQty_Change
6997 llRetVal = .F.
6998 ENDIF
6999 CASE pnSizeBucket = 22
7000 IF Vzzoordrd_860I.Size22_Qty < pnQty_Change
7001 llRetVal = .F.
7002 ENDIF
7003 CASE pnSizeBucket = 23
7004 IF Vzzoordrd_860I.Size23_Qty < pnQty_Change
7005 llRetVal = .F.
7006 ENDIF
7007 CASE pnSizeBucket = 24
7008 IF Vzzoordrd_860I.Size24_Qty < pnQty_Change
7009 llRetVal = .F.
7010 ENDIF
7011 ENDCASE
7012
7013 RETURN llRetVal
7014 ENDFUNC
7015
7016 * ===============================================
7017
7018 FUNCTION UpdateSizeBucket
7019 LPARAMETERS pnSizeBucket, pnQty_Change, pcQualifier
7020
7021 IF pcQualifier = "QD"
7022 pnQty_Change = pnQty_Change * -1
7023 ENDIF
7024
7025 DO CASE
7026 CASE pnSizeBucket = 1
7027 REPLACE ;
7028 Size01_Qty WITH Size01_Qty + pnQty_Change ;
7029 IN Vzzoordrd_860I
7030 CASE pnSizeBucket = 2
7031 REPLACE ;
7032 Size02_Qty WITH Size02_Qty + pnQty_Change ;
7033 IN Vzzoordrd_860I
7034 CASE pnSizeBucket = 3
7035 REPLACE ;
7036 Size03_Qty WITH Size03_Qty + pnQty_Change ;
7037 IN Vzzoordrd_860I
7038 CASE pnSizeBucket = 4
7039 REPLACE ;
7040 Size04_Qty WITH Size04_Qty + pnQty_Change ;
7041 IN Vzzoordrd_860I
7042 CASE pnSizeBucket = 5
7043 REPLACE ;
7044 Size05_Qty WITH Size05_Qty + pnQty_Change ;
7045 IN Vzzoordrd_860I
7046 CASE pnSizeBucket = 6
7047 REPLACE ;
7048 Size06_Qty WITH Size06_Qty + pnQty_Change ;
7049 IN Vzzoordrd_860I
7050 CASE pnSizeBucket = 7
7051 REPLACE ;
7052 Size07_Qty WITH Size07_Qty + pnQty_Change ;
7053 IN Vzzoordrd_860I
7054 CASE pnSizeBucket = 8
7055 REPLACE ;
7056 Size08_Qty WITH Size08_Qty + pnQty_Change ;
7057 IN Vzzoordrd_860I
7058 CASE pnSizeBucket = 9
7059 REPLACE ;
7060 Size09_Qty WITH Size09_Qty + pnQty_Change ;
7061 IN Vzzoordrd_860I
7062 CASE pnSizeBucket = 10
7063 REPLACE ;
7064 Size10_Qty WITH Size10_Qty + pnQty_Change ;
7065 IN Vzzoordrd_860I
7066 CASE pnSizeBucket = 11
7067 REPLACE ;
7068 Size11_Qty WITH Size11_Qty + pnQty_Change ;
7069 IN Vzzoordrd_860I
7070 CASE pnSizeBucket = 12
7071 REPLACE ;
7072 Size12_Qty WITH Size12_Qty + pnQty_Change ;
7073 IN Vzzoordrd_860I
7074 CASE pnSizeBucket = 13
7075 REPLACE ;
7076 Size13_Qty WITH Size13_Qty + pnQty_Change ;
7077 IN Vzzoordrd_860I
7078 CASE pnSizeBucket = 14
7079 REPLACE ;
7080 Size14_Qty WITH Size14_Qty + pnQty_Change ;
7081 IN Vzzoordrd_860I
7082 CASE pnSizeBucket = 15
7083 REPLACE ;
7084 Size15_Qty WITH Size15_Qty + pnQty_Change ;
7085 IN Vzzoordrd_860I
7086 CASE pnSizeBucket = 16
7087 REPLACE ;
7088 Size16_Qty WITH Size16_Qty + pnQty_Change ;
7089 IN Vzzoordrd_860I
7090 CASE pnSizeBucket = 17
7091 REPLACE ;
7092 Size17_Qty WITH Size17_Qty + pnQty_Change ;
7093 IN Vzzoordrd_860I
7094 CASE pnSizeBucket = 18
7095 REPLACE ;
7096 Size18_Qty WITH Size18_Qty + pnQty_Change ;
7097 IN Vzzoordrd_860I
7098 CASE pnSizeBucket = 19
7099 REPLACE ;
7100 Size19_Qty WITH Size19_Qty + pnQty_Change ;
7101 IN Vzzoordrd_860I
7102 CASE pnSizeBucket = 20
7103 REPLACE ;
7104 Size20_Qty WITH Size20_Qty + pnQty_Change ;
7105 IN Vzzoordrd_860I
7106 CASE pnSizeBucket = 21
7107 REPLACE ;
7108 Size21_Qty WITH Size21_Qty + pnQty_Change ;
7109 IN Vzzoordrd_860I
7110 CASE pnSizeBucket = 22
7111 REPLACE ;
7112 Size22_Qty WITH Size22_Qty + pnQty_Change ;
7113 IN Vzzoordrd_860I
7114 CASE pnSizeBucket = 23
7115 REPLACE ;
7116 Size23_Qty WITH Size23_Qty + pnQty_Change ;
7117 IN Vzzoordrd_860I
7118 CASE pnSizeBucket = 24
7119 REPLACE ;
7120 Size24_Qty WITH Size24_Qty + pnQty_Change ;
7121 IN Vzzoordrd_860I
7122 ENDCASE
7123 *- 1014475 12/21/05 YIK
7124 *- Removed Last_Mod WITH DATETIME() in Vzzoordrh_860I
7125 *- and Vzzoordrd_860I
7126
7127 REPLACE ;
7128 Total_Qty WITH Total_Qty + pnQty_Change, ;
7129 User_id WITH goEnv.cUser ;
7130 IN Vzzoordrd_860I
7131
7132 REPLACE ;
7133 Ord_Qty WITH Ord_Qty + pnQty_Change, ;
7134 User_id WITH goEnv.cUser ;
7135 IN Vzzoordrh_860I
7136 ENDFUNC
7137
7138 *=================================================
7139
7140 *!* Use this logic if we change the approach to all records in result set, and one table update, rather than
7141 *!* requery/tableupdate one record at a time. NOTE: would have to add the index to the sales order header to
7142 *!* make this work...
7143 *!* FUNCTION FindCorrespondingSalesOrder
7144 *!* LPARAMETERS pcDivision, pnPO_Num, pcStore, pcCustomer, plFindDetail
7145
7146 *!* LOCAL llRetVal, lnSelect
7147
7148 *!* llRetVal = .T.
7149 *!* lnSelect = SELECT()
7150
7151 *!* SELECT Vzzoordrh_860I
7152 *!* SEEK pcDivision + STR(pnPO_Num) + pcStore + pcCustomer
7153 *!* IF FOUND()
7154 *!* IF plFindDetail
7155 *!* SELECT Vzzoordrd_860I
7156 *!* SEEK Vzzoordrh_860I.PKey
7157 *!* IF NOT FOUND()
7158 *!* llRetVal = .F.
7159 *!* ENDIF
7160 *!* ENDIF
7161 *!* ELSE
7162 *!* llRetVal = .F.
7163 *!* ENDIF
7164 *!*
7165 *!* SELECT (lnSelect)
7166 *!* RETURN llRetVal
7167 *!* ENDFUNC
7168
7169 *=================================================
7170
7171 FUNCTION IndexSalesOrder
7172 LOCAL lnSelect
7173
7174 lnSelect = SELECT()
7175
7176 SELECT Vzzoordrh_860I
7177 INDEX ON division + STR(PO_Num) + STORE + customer TAG sku
7178 SET ORDER TO TAG sku
7179
7180 SELECT Vzzoordrd_860I
7181 INDEX ON fkey TAG fkey
7182 SET ORDER TO TAG fkey
7183
7184 SELECT (lnSelect)
7185 ENDFUNC
7186
7187 *=================================================
7188
7189 FUNCTION CreateSOViews
7190 * LPARAMETERS pcSQLFilterString
7191 LOCAL llRetVal, lnSelect, lcSQLString
7192
7193 llRetVal = true
7194 lnSelect = SELECT()
7195
7196 *!* pcSQLFilterString = IIF(EMPTY(pcSQLFilterString), "", " AND " + pcSQLFilterString)
7197
7198 *!* * Header table:
7199 *!* lcSQLString = ;
7200 *!* "SELECT * " + ;
7201 *!* " FROM zzeipcth " + ;
7202 *!* " WHERE (1=1) " + ;
7203 *!* pcSQLFilterString
7204
7205 *!* llRetVal = v_SQLExec(lcSQLString, "tceipcth")
7206
7207 *!* * Detail table:
7208 *!* lcSQLString = ;
7209 *!* "SELECT * " + ;
7210 *!* " FROM zzeipctd " + ;
7211 *!* " WHERE FKey IN " + ;
7212 *!* " (SELECT PKey " + ;
7213 *!* " FROM zzeipcth " + ;
7214 *!* " WHERE (1=1) " + ;
7215 *!* pcSQLFilterString + ;
7216 *!* ")"
7217
7218 *!* llRetVal = llRetVal AND v_SQLExec(lcSQLString, "tceipctd")
7219
7220 IF llRetVal
7221 SELECT tcEiPCtd
7222 INDEX ON fkey TAG fkey
7223 SET ORDER TO TAG fkey
7224 ENDIF
7225
7226 * Create views for Sales Order Header and Detail:
7227 *- 1014975 12/21/05 YIK
7228 *-- Add ..AND ord_status = 'O' otherwise if we have the same order
7229 *- as Open and Pick - REQUERY fails with "Buffer..contains uncommited changes"
7230 lcSQLString = ;
7231 "SELECT * FROM zzoordrh " + ;
7232 " WHERE Customer = ?pcCustomer " + ;
7233 " AND PO_Num = ?pnPO_Num " + ;
7234 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
7235 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
7236 " AND Ord_Status = 'O' "
7237 *- 01/16/06 YIK
7238 *- We may want to modify the view to allow picks also,
7239 *- but check that the view creates only 1 header, i.e.
7240 *- the entire order either open or picked, no partial pick allowed.
7241 *- Cancels, of course are excluded.
7242 *- Currently it is out of scope.
7243 *- " AND (Ord_Status = 'O' OR Ord_Status = 'P')"
7244
7245 llRetVal = llRetVal AND THIS.CreateSQLView("Vzzoordrh_860I", lcSQLString)
7246
7247 lcSQLString = ;
7248 "SELECT * FROM zzoordrd " + ;
7249 " WHERE FKey IN " + ;
7250 "(SELECT PKey FROM zzoordrh " + ;
7251 " WHERE Customer = ?pcCustomer " + ;
7252 " AND PO_Num = ?pnPO_Num " + ;
7253 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
7254 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
7255 " AND Ord_Status = 'O') "
7256 *- 01/16/06 YIK
7257 *- see the comment above re: picked orders.
7258 *- " AND (Ord_Status = 'O' OR Ord_Status = 'P') )"
7259
7260 llRetVal = llRetVal AND THIS.CreateSQLView("Vzzoordrd_860I", lcSQLString)
7261
7262 *--- TR 1016589 NH : SO Notes are in sysnotes table
7263 lcSQLString = ;
7264 "SELECT * FROM sysnotes " + ;
7265 " WHERE table_name = 'ZZOORDRH' AND ord_num IN " + ;
7266 "(SELECT ord_num FROM zzoordrh " + ;
7267 " WHERE Customer = ?pcCustomer " + ;
7268 " AND PO_Num = ?pnPO_Num " + ;
7269 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
7270 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
7271 " AND Ord_Status = 'O') "
7272
7273 llRetVal = llRetVal AND THIS.CreateSQLView("Vnotes_zzoordrh_860I", lcSQLString)
7274
7275 lcSQLString = ;
7276 "SELECT * FROM sysnotes " + ;
7277 " WHERE table_name = 'ZZOORDRD' AND ord_num IN " + ;
7278 "(SELECT ord_num FROM zzoordrH " + ;
7279 " WHERE Customer = ?pcCustomer " + ;
7280 " AND PO_Num = ?pnPO_Num " + ;
7281 " AND Division = CASE WHEN ?pcDivision = '' THEN Division ELSE ?pcDivision END" + ;
7282 " AND Store = CASE WHEN ?pcStore = '' THEN Store ELSE ?pcStore END " + ;
7283 " AND Ord_Status = 'O') "
7284
7285 llRetVal = llRetVal AND THIS.CreateSQLView("Vnotes_zzoordrd_860I", lcSQLString)
7286
7287 *=== TR 1016589 NH
7288
7289 *--- TR 1016589 NH : Add opentable for order notes
7290 llRetVal = llRetVal AND ;
7291 THIS.OPENTABLE("Vzzoordrh_860I",,.F.) AND ;
7292 THIS.OPENTABLE("Vzzoordrd_860I",,.F.) AND ;
7293 THIS.OPENTABLE("Vnotes_zzoordrh_860I",,.F.) AND ;
7294 THIS.OPENTABLE("Vnotes_zzoordrd_860I",,.F.)
7295
7296 .SetBufferMode("Vzzoordrh_860I", DB_BUFOPTRECORD)
7297 SELECT Vzzoordrh_860I
7298 INDEX ON pkey TAG pkey
7299 *--- TR 1016589 NH
7300 INDEX ON customer + division + po_num + store TAG OrdKey
7301 *=== TR 1016589 NH
7302 INDEX ON ord_num TAG ord_num
7303 .SetBufferMode("Vzzoordrh_860I", DB_BUFOPTTABLE)
7304
7305 .SetBufferMode("Vzzoordrd_860I", DB_BUFOPTRECORD)
7306 SELECT Vzzoordrd_860I
7307 INDEX ON pkey TAG pkey
7308 INDEX ON fkey TAG fkey
7309 INDEX ON division + style + color_code + lbl_code + dimension TAG OUR_SKU
7310 *---- TR 1019356 NH: typo - should be order detail instead of order header table buffering.
7311 *.SetBufferMode("Vzzoordrh_860I", DB_BUFOPTTABLE)
7312 .SetBufferMode("Vzzoordrd_860I", DB_BUFOPTTABLE)
7313 *==== TR 1019356 NH
7314 .SetBufferMode("Vnotes_zzoordrh_860I", DB_BUFOPTRECORD)
7315 SELECT Vnotes_zzoordrh_860I
7316 INDEX ON pkey TAG pkey
7317 INDEX ON fkey TAG fkey
7318 INDEX ON ord_num TAG ord_num
7319 INDEX ON ALLTRIM(STR(ord_num)) + note_type TAG Ord_NTtyp
7320 .SetBufferMode("Vnotes_zzoordrh_860I", DB_BUFOPTTABLE)
7321
7322 .SetBufferMode("Vnotes_zzoordrd_860I", DB_BUFOPTRECORD)
7323 SELECT Vnotes_zzoordrd_860I
7324 INDEX ON pkey TAG pkey
7325 INDEX ON fkey TAG fkey
7326 INDEX ON ALLTRIM(STR(FKEY)) + note_type TAG FkeyNT
7327 .SetBufferMode("Vnotes_zzoordrd_860I", DB_BUFOPTTABLE)
7328
7329 *=== TR 1016589 NH
7330
7331 llRetVal = llRetVal AND THIS.oBPOCancel.DeclareViewsAndCursors()
7332 SELECT (lnSelect)
7333 RETURN llRetVal
7334 ENDFUNC
7335 *- 1014475 12/02/05 YIK
7336 *--- TR 1016904 NH
7337 PROCEDURE TableUpdateTransaction
7338 * --- TR 1047609 7/7/10 CM --- Added pceipcTS
7339 *--- TR 1050827 24-NOV-2010 HNISAR && Added plSkipSLNUpdate
7340 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
7341 LPARAMETERS pceipcTH, pceipcTD, pceipcTC, pcVnotes_IPCH_iPCproc, pcVnotes_IPCD_iPCproc, ;
7342 pceipcTS,plSkipSLNUpdate, pceipcTWHSE
7343 LOCAL llRetVal, lcSQLDelete, lcTempTable&& TR 1016560 NH
7344 llRetVal= .T.
7345 lcSQLDelete = "" && TR 1016560 NH
7346 WITH THIS
7347 lcMessage= "Sending transaction records to server"
7348 .InitThermo(1)
7349 .UpdateThermoCaption(lcMessage + "...")
7350 *--- TR 1016904 NH : increase dimension size from 3 to 5
7351 * --- TR 1047609 7/7/10 CM --- Changed arrray from 5 to 6
7352 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli Changed array from 6 to 8 ===
7353 LOCAL laTables[8], llBeganTransaction
7354 LOCAL llBeganTransaction, loEiPCth
7355 LOCAL lceipcTH_temp, lceipcTD_temp ,lceipcTC_temp, lcSQL_eipcTH
7356 LOCAL loEiPCth,loEiPCtd,loeipctc
7357
7358 laTables[1] = "VzzeiPCth_iPCproc"
7359 laTables[2] = "VzzeiPCtc_iPCproc"
7360 laTables[3] = "VzzeiPCtd_iPCproc"
7361 *--- TR 1016904 NH
7362 laTables[4] = pcVnotes_IPCH_iPCproc
7363 laTables[5] = pcVnotes_IPCD_iPCproc
7364 *=== TR 1016904 NH
7365
7366 * --- TR 1047609 7/7/10 CM
7367 laTables[6] = "VzzeiPCts_iPCproc"
7368 * === TR 1047609 7/7/10 CM
7369
7370 *--- TechRec 1073591 27-Oct-2013 TShenbagavalli ---
7371 laTables[7] = "VzzeiPCtWhse_iPCproc"
7372 laTables[8] = "VzzeiPCta_iPCproc"
7373 *=== TechRec 1073591 27-Oct-2013 TShenbagavalli ===
7374
7375 SELECT(pceipcTH)
7376 SCAN
7377 SCATTER NAME loEiPCth MEMO
7378 IF SEEK(loEiPCth.pkey,'Vzzeipcth_ipcproc','PKEY')
7379 SELECT('Vzzeipcth_ipcproc')
7380 GATHER NAME loEiPCth MEMO
7381 *--- TR 1016904 NH -- need to add records for "DI" qualifier (ALL store)
7382 ELSE
7383 SELECT('Vzzeipcth_ipcproc')
7384 APPEND BLANK
7385 GATHER NAME loEiPCth MEMO
7386 *=== TR 1016904 NH
7387 ENDIF
7388 ENDSCAN
7389
7390
7391 SELECT(pceipcTD)
7392 SCAN
7393 SCATTER NAME loEiPCtd MEMO
7394 IF SEEK(loEiPCtd.pkey,'Vzzeipctd_ipcproc','PKEY')
7395 SELECT('Vzzeipctd_ipcproc')
7396 GATHER NAME loEiPCtd MEMO
7397 *--- TR 1016904 NH -- need to add records for "DI" qualifier (ALL store)
7398 ELSE
7399 SELECT('Vzzeipctd_ipcproc')
7400 APPEND BLANK
7401 GATHER NAME loEiPCtd MEMO
7402 *=== TR 1016904 NH
7403 ENDIF
7404 ENDSCAN
7405
7406
7407 *--- TR 1016560 NH
7408 *--- delete record from history detail table for matching transaction detail pkey .
7409 *--- TR 1041492 JUL-20-2009 BR
7410 *CREATE CURSOR tmpPkey (pkey i)
7411 *--- TR 1032802 NH 04/23/08
7412 SELECT ("Vzzeipctd_ipcproc")
7413*!* SCAN
7414*!* IF NOT SEEK(pkey,pceipcTD,"pkey")
7415*!* INSERT INTO tmpPkey (PKEY) VALUES (Vzzeipctd_ipcproc.pkey)
7416*!* DELETE in Vzzeipctd_ipcproc
7417*!* ENDIF
7418*!* ENDSCAN
7419 .LogEntry("Inserting pkey from views to temporary cursor for final table update.")
7420 SELECT PKEY FROM Vzzeipctd_ipcproc WHERE pkey NOT IN(SELECT pkey FROM (pceipcTD)) INTO CURSOR tmpPkey READWRITE
7421 .LogEntry("Inserting pkey from views to temporary cursor for final table update...Complete")
7422
7423 .LogEntry("Deleting records from views for matching pkeys.")
7424 DELETE FROM Vzzeipctd_ipcproc WHERE pkey in(Select pkey FROM tmpPkey)
7425 .LogEntry("Deleting records from views for matching pkeys...Complete")
7426 *=== TR 1041492 JUL-20-2009 BR
7427
7428*!* SELECT(pceipcTD)
7429*!* LOCAL lcOldSetDeleted
7430*!* lcOldSetDeleted = SET("Deleted")
7431*!* SET DELETED off
7432*!* SCAN FOR DELETED()
7433*!* IF SEEK(pkey,"Vzzeipctd_ipcproc","Pkey")
7434*!* INSERT INTO tmpPkey (PKEY) VALUES (Vzzeipctd_ipcproc.pkey)
7435*!* DELETE in Vzzeipctd_ipcproc
7436*!* ENDIF
7437*!* ENDSCAN
7438*!* SET DELETED &lcOldSetDeleted
7439 *=== TR 1032802 NH 04/23/08
7440 lcTempTable = ""
7441 llRetVal = llRetVal and .GetDeleteSQLForMatchingTransHistoryPkey(@lcSQLDelete,@lcTempTable, "tmpPkey")
7442 *=== TR 1016560 NH
7443
7444 SELECT(pceipcTC)
7445 SCAN
7446 SCATTER NAME loeipctc MEMO
7447 IF SEEK(loeipctc.pkey,'Vzzeipctc_ipcproc','PKEY')
7448 SELECT('Vzzeipctc_ipcproc')
7449 GATHER NAME loeipctc MEMO
7450 ENDIF
7451 ENDSCAN
7452
7453 * --- TR 1047609 7/7/10 CM
7454 *--- TR 1050827 24-NOV-2010 HNISAR
7455 * The This method is called Totally Thrice out of which twice from Prevaliation method
7456 * When Prevalidation method is called second time from PopulateActualStoreForALLStore
7457 * , the Vzzeipcts_ipcproc view is MAY be already populated ( specially when the process fetches data from Flat file
7458 * and not one which is avalilable in transaction maintanance ) In that case we need to prevent scattering to this view
7459 * otherwise it throws error of "Cursor update Conflict" to achive this added the parameter plSkipSLNUpdate to this method.
7460
7461*!* IF NOT EMPTY(pceipcTS)
7462 IF NOT EMPTY(pceipcTS) AND NOT plSkipSLNUpdate
7463 *=== TR 1050827 24-NOV-2010 HNISAR
7464
7465 SELECT(pceipcTS)
7466 SCAN
7467 SCATTER NAME loEiPCts MEMO
7468 IF SEEK(loEiPCts.pkey,'Vzzeipcts_ipcproc','PKEY')
7469 SELECT('Vzzeipcts_ipcproc')
7470 GATHER NAME loEiPCts MEMO
7471 ENDIF
7472 ENDSCAN
7473 ENDIF
7474 * === TR 1047609 7/7/10 CM
7475
7476 IF llRetVal
7477 llBeganTransaction = THIS.BeginTransaction()
7478 *--- TR 1016560 NH
7479 *--- First delete the matching pkey from history.
7480 IF NOT EMPTY(lcSQLDelete)
7481 llRetVal = llRetVal and v_SQLExec(lcSQLDelete)
7482 ENDIF
7483 *llRetVal = IIF(!THIS.TABLEUPDATE(@laTables), .F., .T.)
7484 llRetVal = llRetVal and THIS.TABLEUPDATE(@laTables)
7485 *=== TR 1016560 NH
7486 IF llRetVal
7487 IF llBeganTransaction
7488 THIS.EndTransaction()
7489 ENDIF
7490 ELSE
7491 IF llBeganTransaction
7492 THIS.RollbackTransaction()
7493 ENDIF
7494 ENDIF
7495 ENDIF
7496 *--- TR 1016560 NH
7497 *--- temp table has been created and will be droped here
7498 IF NOT EMPTY(lcSQLDelete)
7499 llRetVal = llRetVal and v_Sqlexec( "drop table " + lcTempTable)
7500 ENDIF
7501 *=== TR 1016560 NH
7502 .oLog.LogEntry(lcMessage + ": " + IIF(llRetVal, 'Succeeded','FAILED'))
7503 ENDWITH
7504 RETURN llRetVal
7505 ENDPROC
7506
7507 PROCEDURE CloseIPCViews
7508 LOCAL llRetVal
7509 llRetVal = .T.
7510 IF llRetVal
7511 * --- TR 1047609 7/7/10 CM --- Changed array from 3 to 4
7512 &&--- TechRec 1073591 31-Oct-2013 TShenbagavalli changed from 4 to 6 ===
7513 LOCAL laTables[6]
7514 laTables[1] = "VzzeiPCth_iPcproc"
7515 laTables[2] = "VzzeiPCtd_iPCproc"
7516 laTables[3] = "VzzeiPCtc_iPCproc"
7517
7518 * --- TR 1047609 7/7/10 CM
7519 laTables[4] = "VzzeiPCts_iPCproc"
7520 * === TR 1047609 7/7/10 CM
7521
7522 *--- TechRec 1073591 31-Oct-2013 TShenbagavalli ---
7523 laTables[5] = "VzzeiPCtWhse_iPCproc"
7524 laTables[6] = "VzzeiPCta_iPCproc"
7525 *=== TechRec 1073591 31-Oct-2013 TShenbagavalli ===
7526
7527 THIS.oLog.LogEntry("Close all transaction views.")
7528 llRetVal = THIS.TableClose(@laTables, true) && close and delete all temp views
7529 IF NOT llRetVal
7530 THIS.oLog.LogWarning("Failed to close all transaction views.")
7531 ENDIF
7532 ENDIF
7533 ENDPROC
7534 *= 1014475
7535
7536 *- 1015584 02/14/06 YIK
7537 FUNCTION RecordHeaderError
7538 LPARAMETERS pcErrorMessage
7539
7540 SELECT tcEiPCth
7541 REPLACE ;
7542 Errs_msg_H WITH Errs_msg_H + pcErrorMessage + CHR(10) + CHR(13), ;
7543 Errs_flg_h WITH "Y" ;
7544 IN tcEiPCth
7545
7546 THIS.lUpdate860Records = .T.
7547
7548 ENDFUNC
7549
7550 *--- TR 1016904 NH
7551 ********************************************************************************
7552
7553 PROCEDURE PopulateActualStoreForALLStore
7554 *--- TR 1050827 18-NOV-2010 HNISAR && Added newparameter pceipcTS
7555 &&--- TechRec 1073591 27-Oct-2013 TShenbagavalli added pceipcTWHSE ===
7556 LPARAMETERS pceIPCth, pceIPCtd, pceIPCcr, pceIPCth_nt, pceIPCtd_nt, pceipcTS, pceipcTWHSE
7557
7558
7559 LOCAL llRetVal, lnOldSelect, lceIPCth_d, lceIPCtd_d, lcActualStoreToAdd, lceipcth_dbf_add, LceipctD_dbf_add
7560 DIMENSION arrSeverTempTbl[5]
7561
7562 llRetVal = .t.
7563 lnOldSelect = SELECT()
7564 lceIPCth_d = "tceIPCth_ALL"
7565 lceIPCtd_d = "tceIPCtd_ALL"
7566 lceIPCth_svr = ""
7567 lceIPCtd_svr = ""
7568
7569 this.LogMajorStage("Adding actual SDQ orders for ALL stores for 'DI' qualifier ")
7570 this.LogEntry("Starting procedure " + PROGRAM())
7571
7572 *--- TR 1036066 NH
7573 llRetVal = llRetVal and this.PopulateStoreFromOrderForSingleOrder(pceIPCth)
7574 *=== TR 1036066 NH
7575
7576 *--- create cursor with ALL store ipc header
7577 *--- TR 1036066 NH
7578 *select * from tceipcth a where a.edi_store = this.cStore_ALL AND a.CUSTOMER > '' into cursor (lceIPCth_d)
7579 select * from tceipcth a where a.ForAllStore = 'Y' AND a.CUSTOMER > '' into cursor (lceIPCth_d)
7580 *=== TR 1036066 NH
7581 this.LogEntry("Number of header record found with ALL store is " + TRANSFORM(RECCOUNT(lceIPCth_d)))
7582
7583 IF NOT RECCOUNT(lceIPCth_d) > 0
7584 SELECT(lnOldSelect)
7585 RETURN
7586 ENDIF
7587
7588 *--- create cursor with ALL store ipc detail
7589 *--- TR 1036066 NH
7590*!* SELECT * FROM tceIPCtd d where exists ( ;
7591*!* select * from tceipcth h where h.pkey = d.fkey and h.edi_store = this.cStore_ALL and h.customer > '') ;
7592*!* into cursor (lceIPCtd_d)
7593 SELECT * FROM tceIPCtd d where exists ( select h.pkey from (lceIPCth_d) h where h.pkey = d.fkey ) ;
7594 into cursor (lceIPCtd_d)
7595
7596 IF NOT RECCOUNT(lceIPCtd_d) > 0
7597 *--- nothing to process no need to go any further just return true from here.
7598 SELECT(lnOldSelect)
7599 RETURN
7600 ENDIF
7601
7602 arrSeverTempTbl[1] = '#tceipctD_dbf_add' + SYS(2015)
7603 lceipctD_dbf_add = arrSeverTempTbl[1]
7604 arrSeverTempTbl[2] = "#tceipcth_dbf_add" + SYS(2015)
7605 lceipcth_dbf_add = arrSeverTempTbl[2]
7606 arrSeverTempTbl[3] = "#ActualStoreToAdd" + SYS(2015)
7607 lcActualStoreToAdd = arrSeverTempTbl[3]
7608 arrSeverTempTbl[4] = "#Ipcth_dbf_exists" + SYS(2015)
7609 lceipcth_dbf_exists = arrSeverTempTbl[4]
7610 arrSeverTempTbl[5] = "#ipctD_dbf_addForHeaderExists" + SYS(2015)
7611 lceipctD_dbf_addForHeaderExists = arrSeverTempTbl[5]
7612
7613 this.LogEntry("Number of detail record found with ALL store is " + TRANSFORM(RECCOUNT(lceIPCtd_d)))
7614
7615 *--- set to server
7616 WITH this
7617 .cSQLTempTable = ""
7618 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCth_d)
7619 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCth_d)
7620 lceIPCth_svr = .cSQLTempTable
7621
7622 .cSQLTempTable = ""
7623 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCtd_d)
7624 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCtd_d)
7625 lceIPCtd_svr = .cSQLTempTable
7626
7627 *--- create list of customer, po_num, and stores with actual store for ALL store orders
7628 *--- all the orders (stores) available for the each PO number + Customer
7629 *--- exclude any order (store) that already have been counted.
7630 *--- add IPCH for DI detail that does not included in ipch for any po_num, customer combination
7631
7632 ******************************************** new header **********************************
7633 *--- get all stores that needs to be counted to created new IPC header.
7634 *--- TR 1028857 NH : no need to check if the detail exists or not at this point, only check that trans detail exists
7635 *--- for each header
7636*!* "exists (select * from " + lceIPCtd_svr + " td " + ;
7637*!* "where d.division = td.division and d.style = td.style and " + ;
7638*!* " d.color_code = td.color_code and d.lbl_code = td.lbl_code " + ;
7639*!* "and d.dimension = td.dimension) " + ;
7640*!* " and exists (select * from " + lceIPCth_svr + " t WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
7641 *--- TR 1036066 NH
7642*!* lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
7643*!* lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
7644*!* "WHERE H.ORD_STATUS = 'O' " + ;
7645*!* " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
7646*!* " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
7647*!* " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
7648*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
7649*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
7650*!* " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
7651 *--- Added - n.ForAllStore <> 'Y'
7652 *--- removed - n.edi_store <> '" + this.cStore_ALL + "'
7653 *--- TR 1039809 APR-17-2009 BR - ADDED and n.doc_num = t.doc_num
7654 *--- TechRec 1051992 14-Feb-2011 TShenbagavalli added " and h.ord_qty > case when h.conf_type = 'B' then 0 end " in condition ---
7655
7656 *- TR 1062971 YIK/FH - removed TR 1051992 and replace it with simply AND d.TOTAL_QTY > 0.
7657*!* lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
7658*!* lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
7659*!* "WHERE H.ORD_STATUS = 'O' " + ;
7660*!* " and 1 = case when h.CONF_TYPE = 'B' and h.ORD_QTY > 0 then 1 else 2 end " + ; && tr 1051992
7661*!* " and 1 = case when h.CONF_TYPE = 'B' and d.TOTAL_QTY > 0 then 1 else 2 end " + ; && tr 1051992
7662*!* " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
7663*!* " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
7664*!* " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
7665*!* " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
7666*!* " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
7667*!* " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
7668
7669 lcSQL = "SELECT DISTINCT h.CUSTOMER, h.PO_NUM, h.STORE, h.ord_num into " + ;
7670 lcActualStoreToAdd + " FROM zzoordrh h INNER JOIN zzoordrd d ON h.pkey = d.fkey " + ;
7671 "WHERE H.ORD_STATUS = 'O' " + ;
7672 " AND d.TOTAL_QTY > 0 " + ; && 1062971
7673 " and exists (select * from " + lceIPCth_svr + " t inner join " + lceIPCtd_svr +;
7674 " td on t.pkey = td.fkey WHERE t.customer = h.customer and t.po_num = h.po_num ) " + ;
7675 " and not exists (select * from zzeipcth n inner join " + lceIPCth_svr + ;
7676 " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
7677 " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
7678 " and n.customer = h.customer and n.po_num = h.po_num and n.store = h.store) "
7679
7680 *=== TR 1036066 NH
7681 *=== TR 1028857 NH
7682 llRetVal = llRetVal and v_sqlExec(lcSQL)
7683 this.LogEntry("Create list of customer, po_num, and stores with actual " + ;
7684 "store for ALL store " + IIF(llRetVal,"successful.","failed."))
7685
7686 *--- Create entire IPC header with order info from existing IPC header for ALL store
7687 *--- for only the one (order) that does not exists in IPC header.
7688 *--- TR 1036066 NH : Added - ForAllStore = 'Y'
7689 *--- removed - a.edi_store = '" + this.cStore_ALL + "'"
7690*!* lcSQL = "Select b.ord_num as ord_num_add , b.store as store_add , a.* into " + lceipcth_dbf_add + ;
7691*!* " from " + lceIPCth_svr + " a JOIN " + lcActualStoreToAdd + " b on a.customer = b.customer " + ;
7692*!* " and a.po_num = b.po_num where a.edi_store = '" + this.cStore_ALL + "'"
7693 lcSQL = "Select b.ord_num as ord_num_add , b.store as store_add , a.* into " + lceipcth_dbf_add + ;
7694 " from " + lceIPCth_svr + " a JOIN " + lcActualStoreToAdd + " b on a.customer = b.customer " + ;
7695 " and a.po_num = b.po_num where a.ForAllStore = 'Y'"
7696 *=== TR 1036066 NH
7697 llRetVal = llRetVal and v_sqlExec(lcSQL)
7698
7699 this.LogEntry("Creating entire IPC header with order info for only the ones " + ;
7700 "that needs to be added " + IIF(llRetVal,"successful.","failed."))
7701
7702 *-- update ord_num and store
7703 lcSQL = "Update " + lceipcth_dbf_add + " set ord_num = ord_num_add, store = store_add"
7704 llRetVal = llRetVal and v_sqlExec(lcSQL)
7705
7706 *-- got rid of extra column ord_num_add, store_add, pkey
7707 lcSQL = "Alter table " + lceipcth_dbf_add + " drop column ord_num_add, store_add"
7708 llRetVal = llRetVal and v_sqlExec(lcSQL)
7709
7710
7711 *--- TR 1032802 NH 04/23/08
7712 *--- Get rid of the detail lines that does not exists in SO order
7713 *--- then get rid of the order (store) has no detail line.
7714
7715 LOCAL lceipctD_add_tmp
7716 lceipctD_add_tmp = "#EipctD_add_tmp" + SYS(2015)
7717 llRetVal = llRetVal and this.RemoveTransHdrAndDtlForOrderLineNotExists(lceipcth_dbf_add,lceIPCtd_svr,lceipctD_add_tmp)
7718 *=== TR 1032802 NH 04/23/08
7719
7720 *--alter table #tceipcth_dbf_add drop column pkey_add
7721 lcSQL = "Alter table " + lceipcth_dbf_add + " add pkeyI int not null identity(1,1)"
7722 llRetVal = llRetVal and v_sqlExec(lcSQL)
7723
7724 *-- create #tceipctD_dbf_add table
7725 *-- NOTE: As header and detail are inner join, fkey_add will have correct pkey
7726 *-- from header even though doc_num remains same.
7727 *--- making details for all new headers
7728 *--- TR 1032802 NH 04/23/08
7729*!* lcSQL = "select h.pkeyI as fkey_add, d.* into " + lceipctD_dbf_add + " from " + lceIPCtd_svr + " d " + ;
7730*!* "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num"
7731*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
7732
7733 lcSQL = "select h.pkeyI as fkey_add, d.* into " + lceipctD_dbf_add + " from " + lceipctD_add_tmp + " d " + ;
7734 "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num and h.po_num = d.po_num " + ;
7735 " and h.customer = d.customer and h.store = d.store "
7736 llRetVal = llRetVal and v_sqlExec(lcSQL)
7737
7738 lcSql = "Alter table " + lceipctD_dbf_add + " drop column store, po_num "
7739 llRetVal = llRetVal and v_sqlExec(lcSQL)
7740 *=== TR 1032802 NH 04/23/08
7741
7742 *-- update fkey value
7743 lcSQL = "update " + lceipctD_dbf_add + " set fkey = fkey_add"
7744 llRetVal = llRetVal and v_sqlExec(lcSQL)
7745
7746 *-- got rid of extra column fkey_add
7747 lcSQL = "alter table " + lceipctD_dbf_add + " drop column fkey_add"
7748 llRetVal = llRetVal and v_sqlExec(lcSQL)
7749
7750 lcSQL = "select count(*) as Reccount from " + lceipcth_dbf_add
7751 llRetVal = llRetVal and v_sqlExec(lcSQL,"IPCH_COUNT")
7752
7753 lnPkey_ipch = 0
7754 IF llRetVal AND USED("IPCH_COUNT")
7755 this.LogEntry("Number of new IPC header will be added for ALL stores are " + TRANSFORM(IPCH_COUNT.Reccount))
7756 ENDIF
7757 *--- update pkey of ipcth
7758 IF llRetVal AND USED("IPCH_COUNT") AND IPCH_COUNT.Reccount > 0
7759 lnPkey_ipch = v_NextPkey("ZZEIPCTH",IPCH_COUNT.Reccount) - IPCH_COUNT.Reccount
7760 *--- set pkey for ipcth
7761 lcSQL = "Update " + lceipctH_dbf_add + " set pkey = pkeyI + " + TRANSFORM(lnPkey_ipch)
7762 llRetVal = llRetVal and v_sqlExec(lcSQL)
7763
7764 *--- update fkey of ipctd
7765 lcSQL = "Update d set fkey = h.pkey from " + lceipctD_dbf_add + " d inner join " + lceipctH_dbf_add +;
7766 " h on h.pkeyI = d.fkey"
7767 llRetVal = llRetVal and v_sqlExec(lcSQL)
7768
7769 *--- populate edi_store for new orders
7770 lcSQL = "Update d set edi_store = r.edi_store from " + lceipctH_dbf_add + " d inner join " + ;
7771 " zzxstorr r on d.customer = r.customer and d.store = r.store "
7772 llRetVal = llRetVal and v_sqlExec(lcSQL)
7773 ENDIF
7774
7775 *--- no use of pkeyI field in ipcth - remove it here.
7776 lcSQL = "alter table " + lceipctH_dbf_add + " drop column pkeyI"
7777 llRetVal = llRetVal and v_sqlExec(lcSQL)
7778
7779
7780 ************************** Header exists for other details with qualifier <> "DI" *************************************
7781 *--- find the transaction header records that are already available for other qualifiers
7782 *--- transaction detail records
7783 *---- and add these transaction record into lceipcth_dbf_add table and update the fkey of lceipctD_dbf_add
7784 *--- TR 1035409 NH
7785*!* lcSQL = " select n.* into " + lceipcth_dbf_exists +" from zzeipcth n inner join " + lceIPCth_svr + ;
7786*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
7787*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
7788*!* " AND not exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
7789*!* " and td.qualifier IN ('DI','PC')) "
7790
7791*!* llRetVal = llRetVal and v_SQLExec(lcSQL)
7792*!*
7793
7794*!* *--- now create details (DI) for these headers joining on doc_num
7795*!* lcSQL = "select h.pkey as fkey_add, d.* into " + lceipctD_dbf_addForHeaderExists + " from " + lceIPCtd_svr + " d " + ;
7796*!* "inner join " + lceipcth_dbf_exists + " h on h.doc_num = d.doc_num"
7797*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
7798
7799*!* *-- update fkey value
7800*!* lcSQL = "update " + lceipctD_dbf_addForHeaderExists + " set fkey = fkey_add"
7801*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
7802
7803*!* *-- got rid of extra column fkey_add
7804*!* lcSQL = "alter table " + lceipctD_dbf_addForHeaderExists + " drop column fkey_add"
7805*!* llRetVal = llRetVal and v_sqlExec(lcSQL)
7806 llRetVal = llRetVal and this.AddDetailForExistingHeader(lceIPCth_svr, lceIPCtd_svr, lceipcth_dbf_exists, lceipctD_dbf_addForHeaderExists)
7807 *=== 1035409 nh
7808 lcSQL = "insert into " + lceipctD_dbf_add + " select * from " + lceipctD_dbf_addForHeaderExists
7809 llRetVal = llRetVal and v_sqlExec(lcSQL)
7810
7811 *--- moving existing header into Add header table for validation
7812 lcSQL = "insert into " + lceipcth_dbf_add + " select * from " + lceipcth_dbf_exists
7813 llRetVal = llRetVal and v_sqlExec(lcSQL)
7814
7815 ************************************************************************************
7816
7817 lcSQL = "Select count(*) as Reccount from " + lceipctd_dbf_add
7818 llRetVal = llRetVal and v_sqlExec(lcSQL,"IPCD_COUNT")
7819
7820 lnPkey_ipcd = 0
7821 IF llRetVal AND IPCD_COUNT.Reccount > 0
7822 lnPkey_ipcd = v_NextPkey("ZZEIPCTD",IPCD_COUNT.Reccount) - IPCD_COUNT.Reccount
7823 ENDIF
7824
7825 lcSQL = "Alter table " + lceipctD_dbf_add + " add pkeyI int not null identity(1,1)"
7826 llRetVal = llRetVal and v_sqlExec(lcSQL)
7827
7828 *--- update pkey of ipctd
7829 lcSQL = "Update " + lceipctD_dbf_add + " set pkey = pkeyI + " + TRANSFORM(lnPkey_ipcD)
7830 llRetVal = llRetVal and v_sqlExec(lcSQL)
7831
7832 lcSQL = "alter table " + lceipctD_dbf_add + " drop column pkeyI"
7833 llRetVal = llRetVal and v_sqlExec(lcSQL)
7834
7835 *--- TR 1036066 NH : stamp 'P' in forallstore field for the already exploded store orders.
7836 lcSql = "update h set forallstore = 'P' from " + lceipcth_dbf_add + " h where edi_store > '' and store > '' and forallstore = 'Y'"
7837 llRetVal = llRetVal and v_sqlExec(lcSQL)
7838 *=== TR 1036066 NH
7839
7840 *--- lceipcth_dbf_add and lceipctD_dbf_add has new order header and detail for "DI" qualifier
7841 lcSQL = "select * from " + lceipcth_dbf_add
7842 llRetVal = llRetVal and v_sqlexec(lcSQL,"tceipcth_dbf_add_readOnly")
7843
7844 lcSQL = "select * from " + lceipctd_dbf_add
7845 llRetVal = llRetVal and v_sqlexec(lcSQL,"tceipctd_dbf_add_readOnly")
7846
7847 *--- make cursor writable "tceipcth_dbf_add", "tceipctd_dbf_add" - FIX ME
7848 .MakeCursorWritable("tceipcth_dbf_add_readOnly","tceipcth_dbf_add")
7849 .MakeCursorWritable("tceipctd_dbf_add_readOnly","tceipctd_dbf_add")
7850
7851 *--- TR 1036066 NH : any detail line with qualifier not 'DI' or 'PC' should be kept with the transaction header for error
7852 *--- lceIPCtd_svr table has records that are suppose to be exploded for all store
7853 *--- and any qualifier other than 'DI' and 'PC' can not be exploded for all store and should be error out in transaction
7854 lcSql = "select * from " + lceIPCtd_svr + " d where qualifier not in ('DI','PC') "
7855 llRetVal = llRetVal and v_sqlexec(lcSql,"tceipctD_dbf_Bad")
7856
7857 SELECT tceipctD_dbf_Bad
7858 INDEX on pkey TAG pkey
7859 INDEX on fkey TAG fkey
7860
7861 IF llRetVal AND USED("tceipcth_dbf_add") AND USED("tceipctd_dbf_add") &&--- TR 1032802 NH 04/23/08
7862 SELECT tceipcth_dbf_add
7863 INDEX ON impl_ok TAG ImplOK FOR impl_ok = '' && TR 1041492 JUL-20-2009 BR
7864 INDEX ON customer + PO_num TAG CustPo
7865 INDEX ON pkey TAG pkey
7866 SELECT tceipctd_dbf_add
7867 INDEX ON pkey TAG pkey
7868 INDEX ON fkey TAG fkey
7869 INDEX ON STR(fkey)+STYLE+color_code+lbl_code+DIMENSION TAG GrpDetail
7870 ENDIF &&--- TR 1032802 NH 04/23/08
7871 *--- validate only the new records
7872 *--- TR 1050827 18-NOV-2010 HNISAR && Passed 2paramerter pceipcTS , .T.
7873 llRetVal = llRetVal and .PreValidation("tceipcth_dbf_add", "tceipctd_dbf_add", pceIPCcr,pceipcTS,.T.)
7874
7875 *--- append to additional records for "DI" SDQ to respective cursors
7876 llRetVal = llRetVal and .ScatterGatherOnExistsCopyErrorMsg("tceipcth_dbf_add",pceIPCth)
7877 llRetVal = llRetVal and .ScatterGather("tceipctd_dbf_add",pceIPCtd)
7878 llRetVal = llRetVal and .UpdateActualStoreNotesWithALLStoreNotes(pceIPCth,pceIPCtd,"Vnotes_IPCH_iPCproc","Vnotes_iPCD_iPCproc")
7879
7880 *--- TechRec 1073591 18-Oct-2013 TShenbagavalli ---
7881 llRetVal = llRetVal and .UpdateActualStoreDatawhseWithALLStoreDatawhse(pceIPCth,pceIPCtd,pceIPCtwhse)
7882 *=== TechRec 1073591 18-Oct-2013 TShenbagavalli ===
7883
7884 llRetVal = llRetVal and .DeleteALLStoreOrder(pceIPCth, pceIPCtd,"VzzeiPCth_iPCproc", "VzzeiPCtd_iPCproc", "tceipcth_dbf_add", "tceipctD_dbf_Bad") && -- tr 1036066 nh
7885 llRetVal = llRetVal and .DropSeverTempTable(@arrSeverTempTbl)
7886 ENDWITH
7887
7888 SELECT(lnOldSelect)
7889 RETURN llRetVal
7890 ENDPROC
7891
7892 *****************************************************************************************
7893 *--- TR 1036066 NH
7894 PROCEDURE PopulateStoreFromOrderForSingleOrder
7895 LPARAMETERS pceIPCth
7896
7897 LOCAL llRetVal, lnOldSelect, lceIPCth_d
7898 llRetVal = .t.
7899 lnOldSelect = SELECT()
7900 lceIPCth = "tcEIPCth" + SYS(2015)
7901
7902 select customer, po_num, pkey from tceipcth a where a.ForAllStore = 'Y' AND a.CUSTOMER > '' into cursor (lceIPCth)
7903 IF RECCOUNT(lceIPCth) = 0
7904 SELECT(lnOldSelect)
7905 RETURN llRetVal
7906 ENDIF
7907 LOCAL lceIPCth_svr, lcSinglePO
7908 lcSinglePO = "tcSinglePO" + SYS(2015)
7909 WITH this
7910 .cSQLTempTable = ""
7911 llRetVal = llRetVal and .GenerateSQLTempTable(lceIPCth)
7912 llRetVal = llRetVal and .PopulateSQLTempTable(lceIPCth)
7913 lceIPCth_svr = .cSQLTempTable
7914
7915 *--- find the PO that has only one order in Sales order and then get the store and edi_store from order and store ref
7916 lcSql = " select th.pkey, oh.customer, oh.po_num, oh.store, r.edi_store " + ;
7917 " from zzoordrh oh " + ;
7918 " inner join " + lceIPCth_svr + " th on th.customer = oh.customer and th.po_num = oh.po_num " + ;
7919 " inner join zzxstorr r on oh.customer = r.customer and oh.store = r.store " + ;
7920 " where oh.ord_status = 'O' and oh.pkey in " + ;
7921 " ( select max(pkey) as pkey from zzoordrh h (nolock) " + ;
7922 " where h.ord_status = 'O' and h.customer = oh.customer and h.po_num = oh.po_num " + ;
7923 " group by customer, po_num having count(*) = 1) " + ;
7924 " order by th.pkey "
7925
7926 llRetVal = llRetVal and v_sqlexec(lcSql, lcSinglePO)
7927 IF USED(lcSinglePO) AND RECCOUNT(lcSinglePO) > 0
7928 *--- update pceIPCth store and edi_store and set ForAllStore as processed = 'P'
7929 UPDATE th SET store = oh.store, edi_store = oh.edi_store, ForAllStore = 'P' ;
7930 from (lcSinglePO) oh inner join (pceIPCth) th on th.pkey = oh.pkey
7931
7932 USE IN (lcSinglePO)
7933 ENDIF
7934
7935 ENDWITH
7936
7937 SELECT(lnOldSelect)
7938 RETURN llRetVal
7939 ENDPROC
7940
7941 *=== TR 1036066 NH
7942 ********************************************************************************
7943 *--- TR 1035409 NH
7944 PROCEDURE AddDetailForExistingHeader
7945 LPARAMETERS pceIPCth_svr, pceIPCtd_svr, pceipcth_dbf_exists, pceipctD_dbf_addForHeaderExists
7946
7947 LOCAL llRetVal, lnOldSelect, lcSql
7948 lnOldSelect = SELECT()
7949 llRetVal = .t.
7950 lcSql = ""
7951 LOCAL lcOrderDtl
7952 lceIPCth_svr = pceIPCth_svr
7953 lceIPCtd_svr = pceIPCtd_svr
7954 lcOrderDtl = "#OrderDtl" + SYS(2015)
7955 lcSql = " select od.* into " + lcOrderDtl + " from zzoordrd od (nolock) " + ;
7956 " inner join zzoordrh oh (nolock) on oh.pkey = od.fkey " + ;
7957 " inner join " + lceIPCth_svr + " th on th.po_num = oh.po_num and th.customer = oh.customer " + ;
7958 " AND oh.ord_status = 'O' "
7959 llRetVal = llRetVal and v_sqlExec(lcSQL)
7960 LOCAL lcZzoordrdv
7961 lcZzoordrdv = ""
7962 llRetVal = llRetVal and this.GetVerticalOpenOrder(lcOrderDtl,@lcZzoordrdv)
7963 *--- TR 1036066 NH - remove - n.edi_store <> '" + this.cStore_ALL + "'
7964
7965*!* lcSQL = " select n.* into " + pceipcth_dbf_exists + " from zzeipcth n inner join " + lceIPCth_svr + ;
7966*!* " t on n.customer = t.customer and n.po_num = t.po_num " + ;
7967*!* " where n.edi_store <> '" + this.cStore_ALL + "' and n.customer > '' " + ;
7968*!* " AND exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
7969*!* " and td.qualifier IN ('DI','PC')) " + ;
7970*!* " AND exists (select oh.pkey from zzoordrh oh (nolock) " + ;
7971*!* " inner join " + lcZzoordrdv + " od (nolock) on od.fkey = oh.pkey " + ;
7972*!* " inner join " + lceIPCtd_svr + " td on td.style = od.style and td.color_code = od.color_code " + ;
7973*!* " and td.lbl_code = od.lbl_code and td.dimension = od.dimension and td.sizebucket = od.sizebucket " + ;
7974*!* " where oh.po_num = n.po_num " + ;
7975*!* " and oh.customer = n.customer and oh.store = n.store and oh.ord_status = 'O' " + ;
7976*!* " and td.fkey = t.pkey )"
7977 *--- TR 1039809 APR-17-2009 BR - ADDED and n.doc_num = t.doc_num
7978 *--- TR 1062197 15-Oct-2012 Goutam. Added consol_code
7979 *- TR 1093179 FH - add ord_type
7980 lcSQL = " select t.ord_type, SPACE(5) as consol_code, n.* into " + pceipcth_dbf_exists + " from zzeipcth n inner join " + lceIPCth_svr + ;
7981 " t on n.customer = t.customer and n.po_num = t.po_num and n.doc_num = t.doc_num " + ;
7982 " where n.ForAllStore <> 'Y' and n.customer > '' " + ;
7983 " AND exists (select td.pkey from " + lceIPCtd_svr + " td where td.fkey = t.pkey " + ;
7984 " and td.qualifier IN ('DI','PC')) " + ;
7985 " AND exists (select oh.pkey from zzoordrh oh (nolock) " + ;
7986 " inner join " + lcZzoordrdv + " od (nolock) on od.fkey = oh.pkey " + ;
7987 " inner join " + lceIPCtd_svr + " td on td.style = od.style and td.color_code = od.color_code " + ;
7988 " and td.lbl_code = od.lbl_code and td.dimension = od.dimension and td.sizebucket = od.sizebucket " + ;
7989 " where oh.po_num = n.po_num " + ;
7990 " and oh.customer = n.customer and oh.store = n.store and oh.ord_status = 'O' " + ;
7991 " and td.fkey = t.pkey )"
7992 *=== TR 1036066 NH
7993 *=== TR 1035409 NH
7994 llRetVal = llRetVal and v_SQLExec(lcSQL)
7995
7996 *--- now create details (DI) for these headers joining on doc_num
7997 *--- TR 1048315 JUL-21-2010 BR - ADDED h.ord_num as ord_num
7998 lcSQL = "select h.pkey as fkey_add, h.ord_num as ord_num, d.* into " + pceipctD_dbf_addForHeaderExists + " from " + lceIPCtd_svr + " d " + ;
7999 "inner join " + pceipcth_dbf_exists + " h on h.doc_num = d.doc_num and h.customer = d.customer" + ; &&--- TR 1036066 NH
8000 " where d.qualifier in ('DI','PC') " &&--- TR 1036066 NH
8001 llRetVal = llRetVal and v_sqlExec(lcSQL)
8002
8003 *-- TR 1048315 JUL-21-2010 BR
8004 lcDelExistDTL = "#DelExistDTL" + SYS(2015)
8005 lcSQL = " select d.style, d.color_code, d.dimension, d.lbl_code, d.sizebucket, d.ord_num, dv.style as st_style into " + lcDelExistDTL + ;
8006 " from " + pceipctD_dbf_addForHeaderExists + " d " + ;
8007 " left outer join " + lcZzoordrdv + " dv on dv.division = d.division and dv.style = d.style and dv.color_code = d.color_code " + ;
8008 " and dv.lbl_code = d.lbl_code and dv.dimension = d.dimension and dv.sizebucket = d.sizebucket and dv.ord_num = d.ord_num " + ;
8009 " where dv.style is null "
8010
8011 llRetVal = llRetVal and v_sqlExec(lcSQL)
8012
8013 lcSQL = " delete d from " + pceipctD_dbf_addForHeaderExists + " d Join " + lcDelExistDTL + " e on d.style = e.style " + ;
8014 " and d.color_code = e.color_code and d.lbl_code = e.lbl_code " + ;
8015 " and d.dimension = e.dimension and d.sizebucket = e.sizebucket and d.ord_num = e.ord_num "
8016 llRetVal = llRetVal and v_sqlExec(lcSQL)
8017
8018 *-- got rid of extra column ord_num
8019 lcSQL = "alter table " + pceipctD_dbf_addForHeaderExists + " drop column ord_num"
8020 llRetVal = llRetVal and v_sqlExec(lcSQL)
8021 *== TR 1048315 JUL-21-2010 BR
8022
8023 *-- update fkey value
8024 lcSQL = "update " + pceipctD_dbf_addForHeaderExists + " set fkey = fkey_add"
8025 llRetVal = llRetVal and v_sqlExec(lcSQL)
8026
8027 *-- got rid of extra column fkey_add
8028 lcSQL = "alter table " + pceipctD_dbf_addForHeaderExists + " drop column fkey_add"
8029 llRetVal = llRetVal and v_sqlExec(lcSQL)
8030
8031 SELECT(lnOldSelect)
8032 RETURN llRetVal
8033 ENDPROC
8034
8035 *=== TR 1035409 NH
8036 ********************************************************************************
8037 *--- TR 1032802 NH 04/25/08
8038
8039 PROCEDURE RemoveTransHdrAndDtlForOrderLineNotExists
8040 LPARAMETERS pceipcth_dbf_add,pceIPCtd_svr,pceipctD_add_tmp
8041
8042 LOCAL lceipcth_dbf_add,lceIPCtd_svr,lceipctD_add_tmp
8043
8044 lceipcth_dbf_add = pceipcth_dbf_add
8045 lceIPCtd_svr = pceIPCtd_svr
8046 lceipctD_add_tmp = pceipctD_add_tmp
8047
8048 LOCAL llRetVal,lcSQL
8049 llRetVal = .t.
8050 lcSQL = ""
8051 *--- Get rid of the detail lines that does not exists in SO order
8052 *--- then get rid of the order (store) has no detail line.
8053 *--- TR 1036066 NH : we can only add detail to existing order for qualifier 'DI' and 'PC'
8054 lcSQL = "select d.*, h.po_num , h.store into " + lceipctD_add_tmp + " from " + lceIPCtd_svr + " d " + ;
8055 "inner join " + lceipcth_dbf_add + " h on h.doc_num = d.doc_num " + ;
8056 " where d.qualifier in ('DI','PC') "
8057 llRetVal = llRetVal and v_sqlExec(lcSQL)
8058
8059 *--- vericalize order detail
8060 LOCAL lcOrderDtl
8061 lcOrderDtl = "#OrderDtl" + SYS(2015)
8062 *--- TR 1036066 NH - check for line_status = 'O'
8063 lcSql = " select od.* into " + lcOrderDtl + " from zzoordrd od (nolock) " + ;
8064 " inner join zzoordrh oh (nolock) on oh.pkey = od.fkey " + ;
8065 " inner join " + lceipcth_dbf_add + " th on th.po_num = oh.po_num and th.customer = oh.customer " + ;
8066 " and th.store = oh.store " + ;
8067 " WHERE od.line_status = 'O'"
8068 llRetVal = llRetVal and v_sqlExec(lcSQL)
8069 LOCAL lcZzoordrdv
8070 lcZzoordrdv = ""
8071 llRetVal = llRetVal and this.GetVerticalOpenOrder(lcOrderDtl,@lcZzoordrdv)
8072
8073 *--- Get rid of the detail lines that does not exists in SO order
8074 *--- then get rid of the order (store) has no detail line.
8075
8076
8077 lcSql = " delete d from " + lceipctD_add_tmp + " d " + ;
8078 " where not exists (select dv.fkey from " + lcZzoordrdv + " dv inner join zzoordrh oh (nolock) on dv.fkey = oh.Pkey " + ;
8079 " where oh.customer = d.customer and oh.po_num = d.po_num and oh.store = d.store " + ;
8080 " and dv.division = d.division and dv.style = d.style and dv.color_code = d.color_code " + ;
8081 " and dv.lbl_code = d.lbl_code and dv.dimension = d.dimension and dv.sizebucket = d.sizebucket) "
8082
8083 llRetVal = llRetVal and v_sqlExec(lcSQL)
8084
8085 lcSql = " delete h from " + lceipcth_dbf_add + " h where not exists (select d.pkey from " + lceipctD_add_tmp + " d " + ;
8086 " where d.doc_num = h.doc_num and d.store = h.store and d.po_num = h.po_num and d.customer = h.customer) "
8087 llRetVal = llRetVal and v_sqlExec(lcSQL)
8088
8089 RETURN llRetVal
8090 ENDPROC
8091 *=== TR 1032802 NH 04/25/08
8092 ********************************************************************************
8093
8094 PROCEDURE CheckAllStoreForError
8095 LPARAMETERS pceIPCth
8096 LOCAL llRetVal, lnOldSelect
8097 lnOldSelect = SELECT()
8098
8099 SELECT(lnOldSelect)
8100 RETURN llRetVal
8101 ENDPROC
8102
8103 ********************************************************************************
8104
8105 PROCEDURE DropSeverTempTable
8106 LPARAMETERS arrSeverTempTbl
8107 LOCAL llRetVal, nIndex
8108 llRetVal = .t.
8109 FOR nIndex = 1 TO ALEN(arrSeverTempTbl)
8110 this.dropTempTable(arrSeverTempTbl[nIndex])
8111 ENDFOR
8112
8113 RETURN llRetVal
8114 ENDPROC
8115
8116 ********************************************************************************
8117 PROCEDURE dropTempTable
8118 LPARAMETERS pcTempTable, plCheckTblExists
8119
8120 IF NOT VARTYPE(pcTempTable) = "C" OR EMPTY(pcTempTable)
8121 RETURN .F.
8122 ENDIF
8123
8124 LOCAL llRetVal,lnOldSelect, lcCursor
8125 llRetVal = .T.
8126 lnOldSelect = SELECT()
8127 IF plCheckTblExists
8128 lcCursor = SYS(2015)
8129 lcSQL = "Select * from tempdb..sysobjects where xtype = 'U' AND name like '" + ALLTRIM(pcTempTable) + "%'"
8130 llRetVal = llRetVal AND v_SqlExec(lcSQL,lcCursor)
8131 SELECT(lcCursor)
8132 ENDIF
8133
8134 IF NOT plCheckTblExists OR ( USED(lcCursor) AND RECCOUNT(lcCursor) > 0)
8135 lcSQL = "DROP TABLE " + pcTempTable
8136 llRetVal = llRetVal AND v_SqlExec(lcSQL)
8137 ENDIF
8138
8139 IF NOT EMPTY(lcCursor) AND USED(lcCursor)
8140 USE IN (lcCursor)
8141 ENDIF
8142
8143 SELECT(lnOldSelect)
8144 RETURN llRetVal
8145
8146 ENDPROC
8147
8148 ********************************************************************************