· 7 years ago · Feb 20, 2019, 08:02 PM
1**********************************************************************************************
2* Program....: CLSISPPR.PRG
3* Version....: 1.0
4* Author.....: Goutam Dutta/T.Shenbagavalli
5* Date.......: 19-Jan-2009
6* Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
7* Techreq....: 1037490
8* Compiler...: Visual FoxPro 09.00.0000.3504
9* Abstract...: EDI 856 Inbound Process Business Object Class
10* Changes....:
11***********************************************************************************************
12
13#Include SYSTEM.h
14#Include EDI.h
15
16*--- TR 1082847 31-1-2015 VKK
17#DEFINE FAKE_CARTON_PREFIX "00999999"
18#DEFINE ASN_TYPE_VFP_COND " (INLIST(asn_type,'SH','DS','X1') OR EMPTY(asn_type)) "
19#DEFINE ASN_TYPE_SQL_COND " h.asn_type IN('','SH','DS','X1','X2','X3',' ')"
20*=== TR 1082847 31-1-2015 VKK
21
22*--- TR 1082847 31-1-2015 VKK
23*New ASN Types added
24*1. 'DS' -> Full stage movement rigth from GIT process, receive stage, convert fake into correct carton,Sales carton creation , pick , cusotmer shipment and invoice
25*2. 'X1' -> Same as empty , will move till GIT process
26*3. 'X2' -> Move from intranist or later stages till Receives
27*4. 'X3' -> convert fake into correct carton,Sales carton creation , pick , customer shipment and invoice
28*Also
29*GIT_Ind feild -> values
30* 0 -> Initial /default value
31* 1 -> Ready for GIT Process
32
33* IF 'DS'
34* -> Do not delete Transaction if any of the following fails
35* -> GIT PRocess
36* -> Convert Fake into Sales carton
37* -> Pick order
38* -> Customer shipment
39* -> Invoice (based on param bro or customer sales)
40* IF 'X2'
41* -> Do not delete Transaction if any of the following fails
42* -> Move to Receive
43* IF 'X3'
44* -> Do not delete Transaction if any of the following fails
45* -> Convert Fake into Sales carton
46* -> Pick order
47* -> Customer shipment
48* -> Invoice (based on param bro or customer sales)
49* Pending items for 1082847 changes
50* 1. Details logging if any
51* 2.
52*===TR 1082847 31-1-2015 VKK
53
54*--- TR 1085844 7-Apr-2015 Goutam. corrected spelling of sucessful everywhere.
55
56DEFINE CLASS BPO856iPOProcess AS BPOEDIBase
57
58 NAME = "BPO856iPOProcess"
59
60 cJobID = "EDI856ISPPROCESS"
61 cLogFile = "EDI856I.log"
62 cDescription = "EDI 856 Production Inbound process"
63
64 cFilterCriteria = ""
65 Tie_setup = ""
66 lUserInterface = .F.
67 lScheduled = .F.
68
69 lNoDataFound = .F.
70 lNoDataInFlatFile = .F.
71 cMessage = ''
72 nToProcess = 0
73 nProcessed = 0
74
75 niSPHeader = 0
76 niSPHeaderNotes = 0 && TR 1050836 27-Jul-2011 Partha
77 niSPContainer = 0
78 niSPOrder = 0
79 niSPCarton = 0
80 niSPDetail = 0
81
82 *--- TR 1037787 7-Apr-2009 Goutam
83 cMsgFromGIT = ""
84 oGITProcess = Null
85 *=== TR 1037787 7-Apr-2009 Goutam
86
87 *--- TR 1039837
88 l856BatchSupport = .F.
89 lUsePOShpDate = .F.
90 *=== TR 1039837
91 lImplodeByPOLine = .F.
92 lUsePassThrough = .F.
93 DIMENSION aViews[1,3]
94
95 *--- TechRec 1067730 16-Jul-2013 vkrishnamurthy ---
96 cProdcursor = ''
97 *=== TechRec 1067730 16-Jul-2013 vkrishnamurthy ===
98
99 *--- TR 1065007 13-Jan-2014 Goutam
100 cToUOMVolume = ""
101 cToUOMWeight = ""
102 *=== TR 1065007 13-Jan-2014 Goutam
103
104 *--- TR 1076260 18-Mar-2014 Goutam
105 nTotalRecordToProcessed = 0
106 nTotalRecordProcesseded = 0
107 cNotesCursor = ""
108 oProduction = NULL
109 *=== TR 1076260 18-Mar-2014 Goutam
110
111 *--- TR 1082847 8-2-2015 VKK
112 cMsgFromAutoPick = ""
113 oAutoPickProcess = Null
114 cMsgFromAutoInvoice = ""
115 oAutoInvoiceProcess = Null
116* oEdi = null
117 oSB = null
118
119 cOrdersPicked = ""
120 cAutoInvoice = ""
121 cOrdersETA = ""
122 nTotalCartonsCreated = 0
123 cMsgFromCartons = ""
124 *=== TR 1082847 8-2-2015 VKK
125
126 *--- TR 1104734 2-Sep-2017 Goutam
127 oAutoSplitProcess = Null
128 *=== TR 1104734 2-Sep-2017 Goutam
129
130*============================================================
131
132 PROCEDURE INIT
133 LPARAMETERS plUserInterface
134
135 LOCAL llRetVal, lcStyleCosting
136
137 llRetVal = .T.
138
139 THIS.lUserInterface = plUserInterface
140 THIS.lScheduled = (NOT plUserInterface)
141
142 This.Tie_setup = (goEnv.sv("TIE_SETUP","N") = 'Y')
143
144 *--- TR 1039837
145 this.l856BatchSupport = (goEnv.SV("856I_BATCH_SUPPORT","N")="Y")
146 This.lUsePOShpDate = (goEnv.SV("856I_USE_SHIP_DATE","N")="Y")
147 this.lImplodeByPOLine = (goEnv.SV("856I_IMPLODE_BY_PO_LINE","N")="Y")
148 *=== TR 1039837
149
150 *--- TR 1037787 7-Apr-2009 Goutam
151 If !("CLSTRNST" $ Upper(Set("Procedure")))
152 Set Procedure to CLSTRNST Additive
153 Endif
154
155 This.oGITProcess = CreateObject("BPOGoodsInTransit")
156 If !(Type('This.oGITProcess') = "O" AND !Isnull(This.oGITProcess))
157 llRetVal = .F.
158 Endif
159 *=== TR 1037787 7-Apr-2009 Goutam
160
161 *--- TR 1082847 8-2-2015 VKK
162 Set Procedure to clsautop, clspkstl, clspksth, clspick, clsratio, clsslsop, clsniblr Additive
163 This.oAutoPickProcess = CREATEOBJECT("BPOAutoPickTicketProcess")
164 llRetVal = llRetVal And Isobject(This.oAutoPickProcess, true)
165
166
167 Set Procedure to clsainpr, clsablpr, clsinvce Additive
168 This.oAutoInvoiceProcess = CREATEOBJECT("BPOAutoInvoice")
169 llRetVal = llRetVal And Isobject(This.oAutoInvoiceProcess , true)
170
171 *--- TR 1085844 5-4-2015 VKK
172 IF llRetVal
173 This.oAutoInvoiceProcess.lScheduled = true
174 This.oAutoPickProcess.lScheduled = true
175 ENDIF
176 *=== TR 1085844 5-4-2015 VKK
177
178* Set Procedure to clsedi Additive
179* This.oEdi = CREATEOBJECT("BPOEDIBase")
180* llRetVal = llRetVal And Isobject(This.oEdi, true)
181
182
183 this.oSB = NEWOBJECT("SQLStringBuilder", "clsgnstr.prg")
184 llRetVal = llRetVal AND IsObject(this.oSB, true)
185
186 *=== TR 1082847 8-2-2015 VKK
187
188 *--- TR 1076260 18-Mar-2014 Goutam
189 llRetVal = llRetVal AND this.LoadProduction()
190 *=== TR 1076260 18-Mar-2014 Goutam
191
192 *--- TR 1104734 2-Sep-2017 Goutam
193 Set Procedure to clsalslt Additive
194 This.oAutoSplitProcess = CREATEOBJECT("BPOProductionAlloc")
195 llRetVal = llRetVal And Isobject(This.oAutoSplitProcess, true)
196 *=== TR 1104734 2-Sep-2017 Goutam
197
198 RETURN llRetVal
199 ENDPROC
200
201*============================================================
202
203 PROCEDURE ProcessISP
204 LPARAMETERS pcFilterCriteria
205
206 LOCAL lcSyslockTablePath, llRetVal, llOKToContinue
207
208 *--- TR 1076260 18-Mar-2014 Goutam.
209 LOCAL lcASNType
210 *=== TR 1076260 18-Mar-2014 Goutam.
211
212 PRIVATE vcLogName
213
214 llRetVal = true
215 llOKToContinue = true
216
217 WITH This
218 lcSyslockTablePath = ADDBS(goEnv.envLoginTablePath.VALUE)
219 .lUsePassThrough = .F.
220
221 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
222 IF !v_SysLock( lcSyslockTablePath+"SYSLOCK", "EDI856ISPPROCESS", goEnv.EnvLogin.cCompany)
223 THIS.lProcessLocked = true
224 RETURN false
225 ENDIF
226
227 vcLogName= lcSyslockTablePath + "856i.log"
228
229 .oLog.OpenLog("EDI856ISPPROCESS", I("EDI856ISPPROCESS"), .lScheduled)
230 .oLog.LogProgram("clsisppr.prg")
231 .oLog.LogEntry("Filter Criteria: " + pcFilterCriteria)
232
233 .oLog.LogMajorStage("Preparing work tables and parameters for 856(i) process.")
234 .lNoDataFound = .F.
235
236 .CreateFrmProgressBar(43,"Selecting EDI 856i records to process...",;
237 "Total EDI 856 inbound process.")
238
239 *--- TR 1082847 11-2-2015 VKK
240 lnParamIndex = ASCAN(.aParamBROs,"PRM_FORCE_AUTO_INV",1,ALEN(.aParamBROs,1),1,9)
241
242 IF lnParamIndex> 0
243 .cAutoInvoice = (ALLTRIM(.aParamBROs[lnParamIndex, 2]))
244
245 IF NOT EMPTY(.cAutoInvoice) AND NOT (.cAutoInvoice== "Y" OR .cAutoInvoice == "N")
246 llRetVal = False
247
248 .cMessage= "Invalid Force Auto Invoice Flag."
249
250 .oLog.LogEntry(.cMessage)
251 ENDIF
252
253 .oLog.LogEntry("Force Auto Invoice :" + .cAutoInvoice)
254
255 ENDIF
256 *=== TR 1082847 11-2-2015 VKK
257
258 IF llOKToContinue
259 IF !EMPTY(pcFilterCriteria)
260 THIS.cFilterCriteria = IIF(!EMPTY(pcFilterCriteria), " WHERE " + pcFilterCriteria,"")
261 ENDIF
262
263 *--- TR 1065007 13-Jan-2014 Goutam
264 .AdvanceThermoTotalWithCaptionPlus("Get TO UOM from company control")
265 llRetVal = llRetVal and .GetFromUOM()
266 .LogEntry("Getting TO UOM from company control " + IIF(llRetVal,"successful.", "failed."))
267 .cTranDetail1Table = "tceispTC"
268 .cTranDetail2Table = "tceispTN"
269 .cToUOMVolume = .cFromUOMVolume
270 .cToUOMWeight = .cFromUOMWeight
271 *=== TR 1065007 13-Jan-2014 Goutam
272
273 .AdvanceThermoTotalWithCaptionPlus("Creating all views...", vcLogName)
274 llRetVal = llRetVal and .CreateispViews()
275 .LogEntry("Creating all views " + IIF(llRetVal,"successful.", "failed."))
276
277 llRetVal = llRetVal and .LoadFromFlatfileToTransaction()
278 .LogEntry("Loading flatfile to transaction tables " + IIF(llRetVal,"successful.", "failed."))
279
280 *--- TR 1082847 31-1-2015 VKK
281 .CalculateCounts()
282 *=== TR 1082847 31-1-2015 VKK
283
284 *--- TR 1076260 18-Mar-2014 Goutam
285 .oProduction.oLog = .oLog && Assign log to prodction log so that it wont crash
286 .oProduction.lPartialCancelQuantity = true && set to true to handle
287
288 FOR lnCountASNType = 1 TO 3
289 .nToProcess = 0
290 .nProcessed = 0
291
292 DO CASE
293 CASE lnCountASNType = 1
294 lcASNType = ''
295 CASE lnCountASNType = 2
296 lcASNType = 'NO'
297 CASE lnCountASNType = 3
298 lcASNType = 'TH'
299 ENDCASE
300 *=== TR 1076260 18-Mar-2014 Goutam
301
302 *--- TR 1076260 18-Mar-2014 Goutam. Added one more parameter lcASNType
303 llRetVal = llRetVal and .QueryTransaction(THIS.cFilterCriteria, lcASNType)
304 .LogEntry("Creating and open transaction views " + IIF(llRetVal,"successful.", "failed."))
305
306 *--- TR 1076260 18-Mar-2014 Goutam. Addd llRetVal
307 IF llRetVal AND NOT This.lNoDatafound
308
309 *--- TR 1082855 11/21/14 ATHIRUNAVU Moved clearerrors call here
310 llRetVal= llRetVal AND .ClearErrors("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD")
311 *=== TR 1082855 11/21/14 ATHIRUNAVU
312
313 *--- TR 1037787 21-Apr-2009 Goutam
314 llRetVal = llRetVal and .UpdateControlKey("tceispTH")
315 .LogEntry("Updating control table PKey in transactions header " + IIF(llRetVal,"successful.", "failed."))
316 *=== TR 1037787 21-Apr-2009 Goutam
317
318 *--- TechRec 1067730 14-May-2013 vkrishnamurthy ---
319 *--- TR 1082855 11/21/14 ATHIRUNAVU Moved clearerrors call to above
320 *llRetVal= llRetVal AND .ClearErrors("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD")
321
322 *--- TR 1076260 18-Mar-2014 Goutam
323 IF EMPTY(lcASNType)
324 *=== TR 1076260 18-Mar-2014 Goutam
325
326 llRetVal = llRetVal and .ExplodeConsolidatedLines("tceispTD","tceispTH")
327 .LogEntry("Exploding Consolidated Production lines " + IIF(llRetVal,"successful.", "failed."))
328
329 *--- TR 1076260 18-Mar-2014 Goutam
330 ENDIF
331 *=== TR 1076260 18-Mar-2014 Goutam
332
333 *=== TechRec 1067730 14-May-2013 vkrishnamurthy ===
334
335 *--- TR 1076260 18-Mar-2014 Goutam. Added one more parameter lcASNType
336 llRetVal = llRetVal and .PreValidation("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD", lcASNType)
337 .LogEntry("Validating transactions " + IIF(llRetVal,"successful.", "failed."))
338
339 .AdvanceThermoTotalWithCaptionPlus("Updating all transaction header(s) with detail in error stage...", vcLogName)
340 llRetVal = llRetVal AND .MarkHeaderForDetailWithError("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD")
341
342 .AdvanceThermoTotalWithCaptionPlus("Updating Carton and Order from detail...", vcLogName)
343
344 llRetVal= llRetVal AND .UpdtCartonQty("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD")
345
346 *--- TR 1037787 7-Apr-2009 Goutam
347
348 *--- TR 1076260 18-Mar-2014 Goutam
349 IF EMPTY(lcASNType)
350 *=== TR 1076260 18-Mar-2014 Goutam
351
352 .AdvanceThermoTotalWithCaptionPlus("Updating Container Usage from container table and Shipment Number...", vcLogName)
353 llRetVal= llRetVal AND .UpdtContrUsgNShpmNum("tceispTC", "tceiSPTH", "zzeispcr")
354
355 *--- TR 1076260 18-Mar-2014 Goutam
356 ENDIF
357 *=== TR 1076260 18-Mar-2014 Goutam
358
359 *--- TR 1050836 27-Jul-2011 Partha added tcEiSPth_notes in param list---
360 *--- TR 1076260 18-Mar-2014 Goutam. Added tcEiSPto_notes
361 llRetVal = llRetVal AND .TableUpdateTransaction("tceispTH", "tceispTC", "tceispTO", "tceispTN", "tceispTD", "tcEiSPth_notes", "tcEiSPto_notes")
362 llRetVal = llRetVal and .CloseISPViews()
363
364ASSERT .f.
365 *--- TR 1076260 18-Mar-2014 Goutam
366 IF EMPTY(lcASNType)
367 *=== TR 1076260 18-Mar-2014 Goutam
368
369 *--- TR 1037787 7-Apr-2009 Goutam
370 *- all results are stored in file tceGIT
371 llRetVal = llRetVal And .PrepareFileForGIT("tceispTH", "tceispTN", "tceGIT")
372 *=== TR 1037787 7-Apr-2009 Goutam
373
374 *--- TR 1050836 27-Jul-2011 Partha added tcEiSPth_notes in param list---
375 llRetVal = llRetVal and .UpdateISPChanges("tceispTH", "tceispTD", "tceispTN", "tceispTO", "tceispTC", "tcEiSPth_notes")
376 .LogEntry("Updating target ISP tables " + IIF(llRetVal,"successful.", "failed."))
377
378 *--- TR 1037787 7-Apr-2009 Goutam
379 IF llRetVal
380 .CallGITProcess()
381 ENDIF
382 *=== TR 1037787 7-Apr-2009 Goutam
383
384 *--- TR 1104734 2-Sep-2017 Goutam
385 IF llRetVal
386 llRetVal = .BackFillProductionStage("tceispTH", "tceispTD", "tceispTO", "zzeispcr")
387 .LogEntry("Back filling production from 1st stage " + IIF(llRetVal,"successful.", "failed."))
388 ENDIF
389 *=== TR 1104734 2-Sep-2017 Goutam
390
391 *--- TR 1082847 31-1-2015 VKK
392 llRetVal = llRetVal AND .CheckProcessStatus("tceispTH", "tceispTD", "tceispTN", "tceispTO", "tceispTC", "GIT")
393 llRetVal = llRetVal AND .DeleteFromTransaction("tcEiSPth", "G") && GIT process over
394 *=== TR 1082847 31-1-2015 VKK
395
396 *--- TR 1076260 18-Mar-2014 Goutam
397 ENDIF
398 *=== TR 1076260 18-Mar-2014 Goutam
399
400 *--- TR 1076260 18-Mar-2014 Goutam
401 IF INLIST(lcASNType, 'NO', 'TH')
402 .AdvanceThermoTotalWithCaptionPlus("Updating Production Order detail based on ASN type...", vcLogName)
403 llRetVal = llRetVal and .UpdatePODetail("tceispTH", "tceispTD", "tceispTO", lcASNType)
404 .LogEntry("Updating Production Order detail " + IIF(llRetVal,"successful.", "failed."))
405 ENDIF
406 *=== TR 1076260 18-Mar-2014 Goutam
407
408 *--- TR 1082847 31-1-2015 VKK
409 IF llRetVal AND EMPTY(lcASNType)
410 .AdvanceThermoTotalWithCaptionPlus("Moving Shipments[ASN TYPE(X2 or DS)] to receiving stage...", vcLogName)
411 llRetVal = llRetVal AND .MoveGoodsToReceive("tceispTH", "tceispTD", "tceispTN", "tceispTO", "tceispTC", true)
412
413 llRetVal = llRetVal AND .DeleteFromTransaction("tcEiSPth", "R") && Receiving process over
414
415 *--- TR 1085844 7-Apr-2015 Goutam. Moved log to function MoveGoodsToReceive
416 *.LogEntry("Moving Shipments[ASN TYPE(X2 or DS)] to receiving stage " + IIF(llRetVal,"successful.", "failed."))
417 *=== TR 1085844 7-Apr-2015 Goutam
418
419 .AdvanceThermoTotalWithCaptionPlus("Fetching records for Auto Pick...", vcLogName)
420 llRetVal = llRetVal And .PrepareFileForAutoPick("tceispTH", "tceispTN", "tceispTD", "tceispTo")
421 .LogEntry("Fetching records for Auto Pick " + IIF(llRetVal,"successful.", "failed."))
422
423 * Auto Pick Packed Qties
424 IF llRetVal AND USED(.oAutoPickProcess.cPick_Cursor) AND RECCOUNT(.oAutoPickProcess.cPick_Cursor) > 0
425
426 .AdvanceThermoTotalWithCaptionPlus("Processing Auto Pick...", vcLogName)
427 llRetVal = llRetVal And .AutoPickPackedQty()
428 .LogEntry("Processing Auto Pick " + IIF(llRetVal,"successful.", "failed."))
429
430 llRetVal = llRetVal AND .CheckProcessStatus("tceispTH", "tceispTD", "tceispTN", "tceispTO", "tceispTC", "PCK")
431
432 .AdvanceThermoTotalWithCaptionPlus("Converting Production Cartons Into Sales...", vcLogName)
433 *--- TR 1088958 28-Jul-2015 Goutam/Yuri. *- Added container tceispTC as parameter
434 llRetVal = llRetVal And .ConvertProductionCartonsIntoSales("tceispTH", "tceispTN", "tceispTD", "tceispTo", "tceispTC")
435 .LogEntry("Converting Production Cartons Into Sales " + IIF(llRetVal,"successful.", "failed."))
436
437 .AdvanceThermoTotalWithCaptionPlus("Processing Auto Pick...", vcLogName)
438 llRetVal = llRetVal And .AutoInvoice()
439 .LogEntry("Processing Auto Pick " + IIF(llRetVal,"successful.", "failed."))
440
441 llRetVal = llRetVal AND .DeleteFromTransaction("tcEiSPth", "P") && Pick process/All are over
442
443 ENDIF
444
445 ENDIF
446
447 *=== TR 1082847 31-1-2015 VKK
448
449 *--- TR 1076260 18-Mar-2014 Goutam
450 ENDIF
451 llRetVal = llRetVal and .CloseISPViews()
452
453 .nTotalRecordToProcessed = .nTotalRecordToProcessed + .nToProcess
454 .nTotalRecordProcesseded = .nTotalRecordProcesseded + .nProcessed
455 NEXT
456 .nToProcess = .nTotalRecordToProcessed
457 .nProcessed = .nTotalRecordProcesseded
458 *=== TR 1076260 18-Mar-2014 Goutam
459
460 *--- TR 1082847 31-1-2015 VKK
461 .CalculateCounts()
462 *=== TR 1082847 31-1-2015 VKK
463
464 .cMessage = AllTRIM(STR(.nToProcess)) + " EDI 856i Record(s) Found " + CRLF
465 .cMessage = .cMessage + ALLTRIM(STR(.nProcessed)) + " EDI 856i Record(s) processed successfully." + CRLF
466 .cMessage = .cMessage + ALLTRIM(STR(.nToProcess - .nProcessed)) + " EDI 856i Record(s) failed processing." + CRLF
467
468 *--- TR 1082847 31-1-2015 VKK
469 .cMessage= .cMessage + .cMsgFromCartons
470 *=== TR 1082847 31-1-2015 VKK
471
472 .LogEntry("")
473 .LogEntry(allTRIM(STR(.nToProcess)) + " EDI 856i Record(s) Found ")
474 .LogEntry(ALLTRIM(STR(.nProcessed)) + " EDI 856i Record(s) processed successfully.")
475 .LogEntry(ALLTRIM(STR(.nToProcess - .nProcessed)) + " EDI 856i Record(s) failed processing.")
476
477 *--- TR 1082847 31-1-2015 VKK
478 IF NOT EMPTY(.cMsgFromCartons) && just to avoid unncessary message(ie Not X3 or DS)
479 .LogEntry(ALLTRIM(STR(.nTotalCartonsCreated)) + " Sales carton(s) created.")
480 ENDIF
481 *=== TR 1082847 31-1-2015 VKK
482
483 *--- TR 1076260 18-Mar-2014 Goutam
484 *ELSE
485 IF .nTotalRecordToProcessed = 0
486 *=== TR 1076260 18-Mar-2014 Goutam
487
488 .cMessage= "There are no EDI Record to process."
489 .LogEntry(.cMessage)
490 llRetVal = llRetVal and .CloseISPViews()
491 ENDIF
492
493 *--- TR 1081057/1080996 19-Sep-2014 Goutam.
494 .lNoDataFound = (.nTotalRecordToProcessed = 0)
495 *=== TR 1081057/1080996 19-Sep-2014 Goutam.
496
497 *--- TR 1037787 7-Apr-2009 Goutam
498 .cMessage= .cMessage + .cMsgFromGIT
499 *=== TR 1037787 7-Apr-2009 Goutam
500
501 *--- TR 1082847 31-1-2015 VKK
502 .cMessage= .cMessage + .cMsgFromAutoPick
503 .cMessage= .cMessage + .cMsgFromAutoInvoice
504 *=== TR 1082847 31-1-2015 VKK
505
506 IF NOT llRetVal
507 .CloseISPViews()
508 .cMessage = "856i Process Failed."
509 ENDIF
510
511 lcLogMsg= STRTRAN(.cMessage, CRLF, "")
512
513 IF THIS.lUserInterface
514 THIS.m_close()
515 ENDIF
516
517 *--- TR 1037787 7-Apr-2009 Goutam
518 .TableClose("tceGIT")
519 .TableClose("zzeispcr")
520 *=== TR 1037787 7-Apr-2009 Goutam
521
522 ENDIF
523
524 .oLog.LogResult(llOKToContinue)
525 .oLog.CloseLog()
526 v_SysUnLock( lcSyslockTablePath+"SYSLOCK", "EDI856ISPPROCESS", goEnv.EnvLogin.cCompany)
527 RELEASE vcLogName
528 ENDWITH
529 ENDPROC
530
531*============================================================
532
533 PROCEDURE CreateiSPViews
534 LOCAL llRetVal, lcSQLSelect, lcSQLOrder, lnThermoCnt, ;
535 lnCursorBuffer, lcAddHdrFld, lcAddDtlFld
536
537 llRetVal = .T.
538 lnThermoCnt = 0
539 lnOldSelect = SELECT()
540
541 WITH This
542
543 .oLog.LogEntry("Creating ISP views.")
544
545 *-- Added thermo counter
546 THIS.InitThermoWithCaption(@lnThermoCnt, 3, "Creating and opening transaction views...")
547
548 *-- Create EDIiSP work table views
549 lcSQLOrder = "doc_num"
550 lcSQLSelect = "select * from zzeisPth h WHERE 1 = 0"
551 THIS.CreateSQLView("VzzeiSpth_iSPproc", lcSQLSelect,, lcSQLOrder)
552 THIS.AdvanceThermoPlus(@lnThermoCnt)
553
554 *--- TR 1050836 27-Jul-2011 Partha ---
555 lcSQLSelect = "select * from sysnotes where TABLE_NAME = 'ZZEISPTH'"
556 This.CreateSQLView("Vzzeispth_notes_iSPproc", lcSQLSelect,,"NoOrderBy")
557 This.AdvanceThermoPlus(@lnThermoCnt)
558 *=== TR 1050836 27-Jul-2011 Partha ===
559
560 *--- TR 1076260 18-Mar-2014 Goutam
561 lcSQLSelect = "select * from sysnotes where TABLE_NAME = 'ZZEISPTO'"
562 This.CreateSQLView("Vzzeispto_notes_iSPproc", lcSQLSelect,,"NoOrderBy")
563 This.AdvanceThermoPlus(@lnThermoCnt)
564 *=== TR 1076260 18-Mar-2014 Goutam
565
566 lcSQLOrder = "doc_num, cntr_num"
567 lcSQLSelect = "select * from zzeiSPtc where 1 = 0"
568 THIS.CreateSQLView("VzzeiSPtc_iSPproc", lcSQLSelect,, lcSQLOrder)
569 THIS.AdvanceThermoPlus(@lnThermoCnt)
570
571 lcSQLOrder = "doc_num, cntr_num, prod_num"
572 lcSQLSelect = "select * from zzeiSPto where 1 = 0"
573 THIS.CreateSQLView("VzzeiSPto_iSPproc", lcSQLSelect,, lcSQLOrder)
574 THIS.AdvanceThermoPlus(@lnThermoCnt)
575
576 lcSQLOrder = "doc_num, cntr_num, prod_num, carton_num"
577 lcSQLSelect = "select * from zzeiSPtn where 1 = 0"
578 THIS.CreateSQLView("VzzeiSPtn_iSPproc", lcSQLSelect,, lcSQLOrder)
579 THIS.AdvanceThermoPlus(@lnThermoCnt)
580
581 lcSQLOrder = "doc_num, cntr_num, prod_num, carton_num, open_seq"
582 lcSQLSelect = "select * from zzeiSPtd where 1 = 0"
583 THIS.CreateSQLView("VzzeiSPtd_iSPproc", lcSQLSelect,, lcSQLOrder)
584 THIS.AdvanceThermoPlus(@lnThermoCnt)
585
586 .oLog.LogEntry("Opening transaction views.")
587
588 lnCursorBuffer = DB_BUFOPTRECORD
589
590 IF NOT (THIS.OPENTABLE("VzzeiSPth_iSPproc",, .T.,,lnCursorBuffer) AND ;
591 THIS.OPENTABLE("VzzeiSPth_notes_iSPproc",, .T.,,lnCursorBuffer) And ; && TR 1050836 27-Jul-2011 Partha
592 THIS.OPENTABLE("VzzeiSPto_notes_iSPproc",, .T.,,lnCursorBuffer) And ; && *--- TR 1076260 18-Mar-2014 Goutam
593 THIS.OPENTABLE("VzzeiSPtc_iSPproc",, .T.,,lnCursorBuffer) AND ;
594 THIS.OPENTABLE("VzzeiSPto_iSPproc",, .T.,,lnCursorBuffer) AND ;
595 THIS.OPENTABLE("VzzeiSPtn_iSPproc",, .T.,,lnCursorBuffer) AND ;
596 THIS.OPENTABLE("VzzeiSPtd_iSPproc",, .T.,,lnCursorBuffer))
597 llRetVal = .F.
598 ELSE
599 SELECT VzzeiSPth_iSPproc
600 INDEX ON pkey TAG pkey
601 INDEX ON STR(doc_num) TAG doc_num
602 SET ORDER TO
603
604 *--- TR 1050836 27-Jul-2011 Partha ---
605 Select VzzeiSPth_notes_iSPproc
606 Index On pkey Tag pkey
607 *=== TR 1050836 27-Jul-2011 Partha ===
608
609 *--- TR 1076260 18-Mar-2014 Goutam
610 Select VzzeiSPto_notes_iSPproc
611 Index On pkey Tag pkey
612 *=== TR 1076260 18-Mar-2014 Goutam
613
614 SELECT VzzeiSPtc_iSPproc
615 INDEX ON pkey TAG pkey
616 INDEX ON fkey TAG fkey
617 INDEX ON STR(doc_num) TAG doc_num
618 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
619 SET ORDER TO
620
621 SELECT VzzeiSPto_iSPproc
622 INDEX ON pkey TAG pkey
623 INDEX ON fkey TAG fkey
624 INDEX ON ckey TAG ckey
625 INDEX ON STR(doc_num) TAG doc_num
626 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
627 INDEX ON STR(doc_num) + STR(prod_num) TAG prod_num
628 INDEX on STR(doc_num) + cntr_num + STR(prod_num) TAG cntr_prod
629 SET ORDER TO
630
631 SELECT VzzeiSPtn_iSPproc
632 INDEX ON pkey TAG pkey
633 INDEX ON fkey TAG fkey
634 INDEX ON ckey TAG ckey
635 INDEX ON okey TAG okey
636 INDEX ON STR(doc_num) TAG doc_num
637 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
638 INDEX ON EMPTY(carton_num) TAG empty_ctn
639 INDEX ON STR(doc_num) + STR(prod_num) TAG prod_num
640 INDEX ON STR(doc_num) + carton_num TAG carton_num
641
642 *--- TR 1080996 14-Sep-2014 Goutam
643 INDEX ON STR(doc_num) + STR(prod_num) + cntr_num TAG prod_cntr
644 *=== TR 1080996 14-Sep-2014 Goutam
645
646 SET ORDER TO
647
648 SELECT VzzeiSPtd_iSPproc
649 INDEX ON pkey TAG pkey FOR NOT DELETED()
650 INDEX ON fkey TAG fkey
651 INDEX ON ckey TAG ckey
652 INDEX ON okey TAG okey
653 INDEX ON ctnkey TAG ctnkey
654 INDEX ON STR(doc_num) TAG doc_num
655
656 SET ORDER TO
657
658 *-- Set table buffer to 5
659 .SetBufferMode("VzzeiSPth_iSPproc", DB_BUFOPTTABLE)
660 .SetBufferMode("VzzeiSPth_notes_iSPproc", DB_BUFOPTTABLE) && TR 1050836 27-Jul-2011 Partha
661 .SetBufferMode("VzzeiSPto_notes_iSPproc", DB_BUFOPTTABLE) && *--- TR 1076260 18-Mar-2014 Goutam
662 .SetBufferMode("VzzeiSPtc_iSPproc", DB_BUFOPTTABLE)
663 .SetBufferMode("VzzeiSPto_iSPproc", DB_BUFOPTTABLE)
664 .SetBufferMode("VzzeiSPtn_iSPproc", DB_BUFOPTTABLE)
665 .SetBufferMode("VzzeiSPtd_iSPproc", DB_BUFOPTTABLE)
666
667 ENDIF
668
669 *--- TR 1037787 7-Apr-2009 Goutam
670 lcSQLString = "SELECT * FROM zzeispCR"
671 llRetVal = v_SqlPrep(lcSQLString, "zzeispcr")
672 *=== TR 1037787 7-Apr-2009 Goutam
673
674 *--- TR 1074657 18-Nov-2013 Goutam
675 SELECT zzeispcr
676 INDEX on pkey TAG pkey
677 SET ORDER TO
678 *=== TR 1074657 18-Nov-2013 Goutam
679
680 ENDWITH
681
682 THIS.ResetThermoPlus()
683 SELECT(lnOldSelect)
684 RETURN llRetVal
685 ENDPROC
686
687*============================================================
688 PROCEDURE LoadFromFlatfileToTransaction
689
690 LOCAL llRetVal, lnCurrentHeaderPkey, lnCurrentHeaderDoc_num, ;
691 lnPriorHeaderPkey, lnCurrentDetailDoc_num, lnLine_seq, ;
692 lciSPHeaderFlatFile, lciSPIContnrFlatFile, lciSPOrderFlatFile, lciSPCartonFlatFile, lciSPDetailFlatFile, ;
693 lciSPHeaderFlatFilePri, lciSPIContnrFlatFilePri, lciSPOrderFlatFilePri, lciSPCartonFlatFilePri, ;
694 lciSPDetailFlatFilePri, ;
695 laTables[7], ; && TR 1050836 27-Jul-2011 Partha - increased length to 6 *--- TR 1076260 18-Mar-2014 Goutam. increased length to 7
696 llBeganTransaction
697
698 LOCAL lciSPHNTFlatFile && TR 1050836 26-Jul-2011 Partha
699
700 LOCAL lciSPONTFlatFile && *--- TR 1076260 18-Mar-2014 Goutam
701
702 llRetVal = .T.
703 lnCurrentHeaderPkey = 0
704 lnCurrentHeaderDoc_num = 0
705 lnCurrentDetailDoc_num = 0
706 lnLine_seq = 0
707 lnOldSelect = SELECT()
708 laTables[1] = "VzzeiSPth_iSPproc"
709 laTables[2] = "VzzeiSPtc_iSPproc"
710 laTables[3] = "VzzeiSPto_iSPproc"
711 laTables[4] = "VzzeiSPtn_iSPproc"
712 laTables[5] = "VzzeiSPtd_iSPproc"
713 laTables[6] = "VzzeiSPth_Notes_iSPproc" && && TR 1050836 26-Jul-2011 Partha
714 laTables[7] = "VzzeiSPto_Notes_iSPproc" && && *--- TR 1076260 18-Mar-2014 Goutam
715
716 WITH THIS
717 .LogMajorStage("Loading flatfile to transaction tables.")
718
719 .AdvanceThermoTotalWithCaptionPlus("Loading data from flatfile to transaction tables...", vcLogName)
720
721 IF .TIE_Setup
722
723 *--- TR 1039837 NSD
724 IF .l856BatchSupport
725 .oLog.LogEntry("Merging 856(i) files from EDI\Inbound\Batch")
726 .MergeFlatFiles("856*.dat","856.dat")
727 ENDIF
728 *=== TR 1039837 NSD
729
730 .oLog.LogEntry("Splitting 856(i) flat file.")
731 IF .SplitFlatFile("856.dat")
732 IF NOT .RenFileDat("856.pri")
733 .oLog.LogEntry("Timestamping 856(i) flat file - FAILED.")
734 ENDIF
735 ELSE
736 .oLog.LogEntry("Splitting 856(i) flat file - FAILED.")
737 ENDIF
738 ENDIF
739
740 lcEDIPath = THIS.GetEDIFlatFileDirectory("Inbound")
741 lciSPHeaderFlatFile = UPPER(lcEDIPath + "856hdr.dat")
742 lciSPIContnrFlatFile = UPPER(lcEDIPath + "856con.dat")
743 lciSPOrderFlatFile = UPPER(lcEDIPath + "856ord.dat")
744 lciSPCartonFlatFile = UPPER(lcEDIPath + "856ctn.dat")
745 lciSPDetailFlatFile = UPPER(lcEDIPath + "856dtl.dat")
746 lciSPHNTFlatFile = UPPER(lcEDIPath + "856hnt.dat") && TR 1050836 26-Jul-2011 Partha
747 lciSPONTFlatFile = UPPER(lcEDIPath + "856ont.dat") && *--- TR 1076260 18-Mar-2014 Goutam
748
749 .oLog.LogEntry("Loading 856(i) flatfiles.")
750
751 llRetVal = .LoadFromFlatFile("ISP", lciSPHeaderFlatFile, lciSPIContnrFlatFile, lciSPOrderFlatFile, ;
752 lciSPCartonFlatFile, lciSPDetailFlatFile, ;
753 lciSPHNTFlatFile , ; && TR 1050836 27-Jul-2011 Partha
754 lciSPONTFlatFile , ; && *--- TR 1076260 18-Mar-2014 Goutam
755 "VzzeiSPth_iSPproc", "VzzeiSPtc_iSPproc", "VzzeiSPto_iSPproc", ;
756 "VzzeiSPtn_iSPproc", "VzzeiSPtd_iSPproc", ;
757 "VzzeiSPth_Notes_iSPproc", ; && TR 1050836 27-Jul-2011 Partha
758 "VzzeiSPto_Notes_iSPproc", ; && *--- TR 1076260 18-Mar-2014 Goutam
759 "ZZEISPTH", "ZZEISPTC", "ZZEISPTO", "ZZEISPTN", "ZZEISPTD")
760
761 IF NOT This.lNoDataInFlatFile
762 .oLog.LogEntry("Replace all error message with not yet process.")
763
764 REPLACE ;
765 ALL errs_flg_h WITH "Y", ;
766 Errs_msg_H WITH Errs_msg_H + " Not yet processed. ", ;
767 User_Id WITH EDI_USER, ;
768 GIT_Ind WITH 0 ; && *--- TR 1082847 31-1-2015 VKK
769 Last_mod WITH DATETIME() ;
770 IN VzzeiSPth_iSPproc
771
772*!* REPLACE ;
773*!* ALL errs_flg_cntr WITH "Y", ;
774*!* Errs_msg_CNTR WITH Errs_msg_CNTR + " Not yet processed. ", ;
775*!* User_Id WITH EDI_USER, ;
776*!* Last_mod WITH DATETIME() ;
777*!* IN VzzeiSPtc_iSPproc
778*!*
779*!* REPLACE ;
780*!* ALL errs_flg_o WITH "Y", ;
781*!* Errs_msg_O WITH Errs_msg_O + " Not yet processed. ", ;
782*!* User_Id WITH EDI_USER, ;
783*!* Last_mod WITH DATETIME() ;
784*!* IN VzzeiSPto_iSPproc
785
786*!* REPLACE ;
787*!* ALL errs_flg_ctn WITH "Y", ;
788*!* Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. ", ;
789*!* User_Id WITH EDI_USER, ;
790*!* Last_mod WITH DATETIME() ;
791*!* IN VzzeiSPtn_iSPproc
792*!*
793*!* REPLACE ;
794*!* ALL errs_flg_d WITH "Y", ;
795*!* Errs_msg_d WITH Errs_msg_d + " Not yet processed. ", ;
796*!* User_Id WITH EDI_USER, ;
797*!* Last_mod WITH DATETIME() ;
798*!* IN VzzeiSPtd_iSPproc
799
800 IF llRetVal
801 .oLog.LogEntry("Sending transaction tables to server.")
802 .AdvanceThermoTotalWithCaptionPlus("Sending transaction tables to server...", vcLogName)
803
804 llBeganTransaction = THIS.BeginTransaction()
805
806 llRetVal = IIF(!THIS.TABLEUPDATE(@laTables), .F., .T.)
807
808 IF llRetVal
809 IF llBeganTransaction
810 THIS.EndTransaction()
811 ENDIF
812 ELSE
813 IF llBeganTransaction
814 THIS.RollbackTransaction()
815 ENDIF
816 ENDIF
817 ENDIF
818 ENDIF
819
820 IF llRetVal
821 lciSPHeaderFlatFilePri = STRTRAN(lciSPHeaderFlatFile, ".DAT", ".PRI") && ".pri"
822 lciSPIContnrFlatFilePri = STRTRAN(lciSPIContnrFlatFile, ".DAT", ".PRI") && ".pri"
823 lciSPOrderFlatFilePri = STRTRAN(lciSPOrderFlatFile, ".DAT", ".PRI") && ".pri"
824 lciSPCartonFlatFilePri = STRTRAN(lciSPCartonFlatFile, ".DAT", ".PRI") && ".pri"
825 lciSPDetailFlatFilePri = STRTRAN(lciSPDetailFlatFile, ".DAT", ".PRI") && ".pri"
826 lciSPHNTFlatFilePri = STRTRAN(lciSPHNTFlatFile, ".DAT", ".PRI") && TR 1050836 27-Jul-2011 Partha
827 lciSPONTFlatFilePri = STRTRAN(lciSPONTFlatFile, ".DAT", ".PRI") && *--- TR 1076260 18-Mar-2014 Goutam
828
829 .oLog.LogEntry("Renaming 856(i) flat files.")
830
831 IF FILE(lciSPHeaderFlatFile)
832 .oLog.LogEntry("Renaming 856(i) header : " + lciSPHeaderFlatFilePri)
833 COPY FILE (lciSPHeaderFlatFile) TO (lciSPHeaderFlatFilePri)
834 DELETE FILE (lciSPHeaderFlatFile)
835 ENDIF
836 IF FILE(lciSPIContnrFlatFile)
837 .oLog.LogEntry("Renaming 856(i) container : " + lciSPIContnrFlatFilePri)
838 COPY FILE (lciSPIContnrFlatFile) TO (lciSPIContnrFlatFilePri)
839 DELETE FILE (lciSPIContnrFlatFile)
840 ENDIF
841 IF FILE(lciSPOrderFlatFile)
842 .oLog.LogEntry("Renaming 856(i) order : " + lciSPOrderFlatFilePri)
843 COPY FILE (lciSPOrderFlatFile) TO (lciSPOrderFlatFilePri)
844 DELETE FILE (lciSPOrderFlatFile)
845 ENDIF
846 IF FILE(lciSPCartonFlatFile)
847 .oLog.LogEntry("Renaming 856(i) carton : " + lciSPCartonFlatFilePri)
848 COPY FILE (lciSPCartonFlatFile) TO (lciSPCartonFlatFilePri)
849 DELETE FILE (lciSPCartonFlatFile)
850 ENDIF
851 IF FILE(lciSPDetailFlatFile)
852 .oLog.LogEntry("Renaming 856(i) detail : " + lciSPDetailFlatFilePri)
853 COPY FILE (lciSPDetailFlatFile) TO (lciSPDetailFlatFilePri)
854 DELETE FILE (lciSPDetailFlatFile)
855 ENDIF
856
857 *--- TR 1050836 27-Jul-2011 Partha ---
858 IF FILE(lciSPHNTFlatFile)
859 .oLog.LogEntry("Renaming 856(i) Notes Header : " + lciSPHNTFlatFilePri)
860 COPY FILE (lciSPHNTFlatFile) TO (lciSPHNTFlatFilePri)
861 DELETE FILE (lciSPHNTFlatFile)
862 ENDIF
863 *=== TR 1050836 27-Jul-2011 Partha ===
864
865 *--- TR 1076260 18-Mar-2014 Goutam
866 IF FILE(lciSPONTFlatFile)
867 .oLog.LogEntry("Renaming 856(i) Notes Order : " + lciSPONTFlatFilePri)
868 COPY FILE (lciSPONTFlatFile) TO (lciSPONTFlatFilePri)
869 DELETE FILE (lciSPONTFlatFile)
870 ENDIF
871 *=== TR 1076260 18-Mar-2014 Goutam
872
873 ENDIF
874
875 .AdvanceThermoTotalWithCaptionPlus("Refresh transaction base on filter criterias...", vcLogName)
876
877 IF llRetVal
878 .oLog.LogEntry("Close all transaction views.")
879
880 llRetVal = THIS.TableClose(@laTables, True)
881 IF NOT llRetVal
882 .oLog.LogWarning("Failed to close all transaction views.")
883 ENDIF
884 ENDIF
885 ENDWITH
886
887 SELECT(lnOldSelect)
888 RETURN llRetVal
889 ENDPROC
890
891*============================================================
892
893 PROCEDURE LoadFromFlatFile
894 LPARAMETERS tcProcess, tcHeaderFlatFile, tcContainerFlatFile, tcOrderFlatFile, tcCartonFlatFile, tcDetailFlatFile, ;
895 tcHNTFlatFile, ; && TR 1050836 27-Jul-2011 Partha
896 tcONTFlatFile, ; && *--- TR 1076260 18-Mar-2014 Goutam
897 tcTransHeader, tcTransContainer, tcTransOrder, tcTransCarton, tcTransDetail, ;
898 tcTransHdrNotes, ; && TR 1050836 27-Jul-2011 Partha
899 tcTransOdrNotes, ; && *--- TR 1076260 18-Mar-2014 Goutam
900 tcHeaderPkeyTag, tcContainerPkeyTag, tcOrderPkeyTag, tcCartonPkeyTag, tcDetailPkeyTag
901
902 LOCAL llRetVal, lcSQLString, lnLine_seq, lcDocCount, lnOldDoc_num, lnLine_seq,llGenerateCartons, lcOrder, lcCtnNum, lnCtnPkey
903
904 *--- TR 1076260 18-Mar-2014 Goutam
905 LOCAL lcOrdDocCount
906 lcOrdDocCount = 0
907 *=== TR 1076260 18-Mar-2014 Goutam
908
909 lcDocCount = ""
910 llRetVal = .T.
911 lnOldDoc_num = 0
912 llGenerateCartons = .F.
913
914 WITH THIS
915 *-- Get Metadata for a process
916 .oLog.LogEntry("Retrieving EDI Metadata definitions.")
917
918 IF .GetTranslationDefinition(tcProcess, "tcEmData")
919 .oLog.LogEntry("Creating work cursors from EDI Metadata.")
920
921 *-- Create Metadata work tables
922 IF !EMPTY(tcHeaderFlatFile)
923 .CreateMetaDataWorkTable("tcEmData", "HDR", "tcALLmwH")
924 ENDIF
925 IF !EMPTY(tcContainerFlatFile)
926 .CreateMetaDataWorkTable("tcEmData", "CON", "tcALLmwC")
927 ENDIF
928 IF !EMPTY(tcOrderFlatFile)
929 .CreateMetaDataWorkTable("tcEmData", "ORD", "tcALLmwO")
930 ENDIF
931 IF !EMPTY(tcCartonFlatFile)
932 .CreateMetaDataWorkTable("tcEmData", "CTN", "tcALLmwN")
933 ENDIF
934 IF !EMPTY(tcDetailFlatFile)
935 .CreateMetaDataWorkTable("tcEmData", "DTL", "tcALLmwD")
936 ENDIF
937
938 *--- TR 1050836 27-Jul-2011 Partha ---
939 If !Empty(tcHNTFlatFile)
940 .CreateMetaDataWorkTable("tcEmData", "HNT", "tcHdrNotes")
941 Endif
942 *=== TR 1050836 27-Jul-2011 Partha ===
943
944 *--- TR 1076260 18-Mar-2014 Goutam
945 If !Empty(tcONTFlatFile)
946 .CreateMetaDataWorkTable("tcEmData", "ONT", "tcOdrNotes")
947 Endif
948 *=== TR 1076260 18-Mar-2014 Goutam
949
950 IF !EMPTY(tcHeaderFlatFile)
951 .PopulateDataToInterfaceTable(tcHeaderFlatFile, "tcALLmwH", tcTransHeader)
952 ENDIF
953 IF !EMPTY(tcHeaderFlatFile)
954 .PopulateDataToInterfaceTable(tcContainerFlatFile, "tcALLmwC", tcTransContainer)
955 ENDIF
956 IF !EMPTY(tcHeaderFlatFile)
957 .PopulateDataToInterfaceTable(tcOrderFlatFile, "tcALLmwO", tcTransOrder)
958 ENDIF
959 IF !EMPTY(tcHeaderFlatFile)
960 .PopulateDataToInterfaceTable(tcCartonFlatFile, "tcALLmwN", tcTransCarton)
961 ENDIF
962 IF !EMPTY(tcDetailFlatFile)
963 .PopulateDataToInterfaceTable(tcDetailFlatFile, "tcALLmwD", tcTransDetail)
964 ENDIF
965
966 *--- TR 1050836 27-Jul-2011 Partha ---
967 If !Empty(tcHNTFlatFile)
968 .PopulateDataToInterfaceTable(tcHNTFlatFile, "tcHdrNotes")
969 Endif
970 *=== TR 1050836 27-Jul-2011 Partha ===
971
972 *--- TR 1076260 18-Mar-2014 Goutam
973 If !Empty(tcONTFlatFile)
974 .PopulateDataToInterfaceTable(tcONTFlatFile, "tcOdrNotes")
975 Endif
976 *=== TR 1076260 18-Mar-2014 Goutam
977
978 IF THIS.CountTotalRecs(tcTransHeader)> 0
979 .oLog.LogEntry( "Transaction header records : " + LTRIM(STR(THIS.CountTotalRecs(tcTransHeader))))
980 ELSE
981 .oLog.LogEntry( "No 856(i) flat files to load.")
982 This.lNoDataInFlatFile = .T.
983 ENDIF
984
985 IF NOT This.lNoDataInFlatFile
986 IF THIS.CountTotalRecs (tcTransContainer)> 0
987 .oLog.LogEntry( "Transaction container records : " + LTRIM(STR(THIS.CountTotalRecs(tcTransContainer))))
988 ENDIF
989 IF THIS.CountTotalRecs (tcTransOrder)> 0
990 .oLog.LogEntry( "Transaction order records : " + LTRIM(STR(THIS.CountTotalRecs(tcTransOrder))))
991 ENDIF
992 IF THIS.CountTotalRecs (tcTransCarton)> 0
993 .oLog.LogEntry( "Transaction carton records : " + LTRIM(STR(THIS.CountTotalRecs(tcTransCarton))))
994 ENDIF
995 IF THIS.CountTotalRecs (tcTransDetail)> 0
996 .oLog.LogEntry( "Transaction detail records : " + LTRIM(STR(THIS.CountTotalRecs(tcTransDetail))))
997 ENDIF
998
999 *-- Assign pkeys for all interface tables
1000 .oLog.LogEntry("Assigning primary keys.")
1001
1002 IF !EMPTY(tcHeaderFlatFile)
1003 .GetPkeyForAllRecordsInBatch(tcTransHeader, tcHeaderPkeyTag, THIS.CountTotalRecs("tcALLmwH"))
1004 ENDIF
1005 IF !EMPTY(tcContainerFlatFile)
1006 .GetPkeyForAllRecordsInBatch(tcTransContainer, tcContainerPkeyTag, THIS.CountTotalRecs("tcALLmwC"))
1007 ENDIF
1008 IF !EMPTY(tcOrderFlatFile)
1009 .GetPkeyForAllRecordsInBatch(tcTransOrder, tcOrderPkeyTag, THIS.CountTotalRecs("tcALLmwO"))
1010 ENDIF
1011 IF !EMPTY(tcCartonFlatFile)
1012 .GetPkeyForAllRecordsInBatch(tcTransCarton, tcCartonPkeyTag, THIS.CountTotalRecs("tcALLmwN"))
1013 ENDIF
1014 IF !EMPTY(tcDetailFlatFile)
1015 .GetPkeyForAllRecordsInBatch(tcTransDetail, tcDetailPkeyTag, THIS.CountTotalRecs("tcALLmwD"))
1016 ENDIF
1017
1018 *-- Sync header Pkey to all child tables Fkey using doc_num
1019 .oLog.LogEntry("Assigning parent keys.")
1020
1021 *--- Update fkey of tcTransContainer
1022 llRetVal= llRetVal and .SetRelation(tcTransHeader, "doc_num", tcTransContainer, "str(doc_num)")
1023
1024
1025 SELECT (tcTransContainer)
1026 Replace All fkey WITH EVALUATE(tcTransHeader + ".pkey"), ;
1027 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1028 errs_flg_cntr WITH "Y", ;
1029 Errs_msg_CNTR WITH Errs_msg_CNTR + " Not yet processed. "
1030 SET RELATION TO
1031
1032
1033
1034 *--- Update ckey of tcTransOrder
1035 llRetVal= llRetVal and .SetRelation(tcTransContainer, "cntr_num", tcTransOrder, "str(doc_num)+cntr_num")
1036
1037 SELECT (tcTransOrder)
1038 Replace All ckey WITH EVALUATE(tcTransContainer + ".pkey"), ;
1039 fkey WITH EVALUATE(tcTransContainer + ".fkey"), ;
1040 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1041 errs_flg_o WITH "Y", ;
1042 Errs_msg_O WITH Errs_msg_O + " Not yet processed. "
1043 SET RELATION TO
1044
1045
1046 *--- Update fkey of tcTransOrder
1047 llRetVal= llRetVal and .SetRelation(tcTransHeader, "doc_num", tcTransOrder, "str(doc_num)")
1048
1049 SELECT (tcTransOrder)
1050 Replace All fkey WITH EVALUATE(tcTransHeader + ".pkey"), ;
1051 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1052 errs_flg_o WITH "Y", ;
1053 Errs_msg_O WITH Errs_msg_O + " Not yet processed. " ;
1054 FOR fkey = 0
1055 SET RELATION TO
1056
1057
1058*!* *--- Update fkey of tcTransCarton
1059*!* llRetVal= llRetVal and .SetRelation(tcTransHeader, "doc_num", tcTransCarton, "str(doc_num)")
1060
1061*!* SELECT (tcTransCarton)
1062*!* Replace All fkey WITH EVALUATE(tcTransHeader + ".pkey"), ;
1063*!* User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1064*!* errs_flg_ctn WITH "Y", ;
1065*!* Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. "
1066*!* SET RELATION TO
1067
1068 *--- Update ckey of tcTransCarton
1069*!* llRetVal= llRetVal and .SetRelation(tcTransContainer, "cntr_num", tcTransCarton, "str(doc_num)+cntr_num")
1070
1071*!* SELECT (tcTransCarton)
1072*!* Replace All ckey WITH EVALUATE(tcTransContainer + ".pkey"), ;
1073*!* fkey WITH EVALUATE(tcTransContainer + ".fkey")
1074*!* User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1075*!* errs_flg_ctn WITH "Y", ;
1076*!* Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. "
1077*!* SET RELATION TO
1078
1079
1080 *--- Update okey of tcTransCarton for prod, no cntr
1081 llRetVal= llRetVal and .SetRelation(tcTransOrder, "cntr_prod", tcTransCarton, "str(doc_num)+cntr_num+STR(prod_num)")
1082
1083 SELECT (tcTransCarton)
1084 Replace All okey WITH EVALUATE(tcTransOrder+ ".pkey"), ;
1085 fkey WITH EVALUATE(tcTransOrder + ".fkey"),;
1086 ckey WITH EVALUATE(tcTransOrder + ".ckey"),;
1087 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1088 errs_flg_ctn WITH "Y", ;
1089 Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. "
1090 SET RELATION TO
1091
1092
1093 *---- oKEY FOR TRANSCARTON FROM TRANSORDER ----*
1094 *--- Update okey of tcTransCarton for cntr + prod
1095 llRetVal= llRetVal and .SetRelation(tcTransOrder, "prod_num", tcTransCarton, "str(doc_num)+STR(prod_num)")
1096
1097 SELECT (tcTransCarton)
1098 Replace All okey WITH EVALUATE(tcTransOrder+ ".pkey"), ;
1099 fkey WITH EVALUATE(tcTransOrder + ".fkey"),;
1100 ckey WITH EVALUATE(tcTransOrder + ".ckey"),;
1101 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1102 errs_flg_ctn WITH "Y", ;
1103 Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. " FOR fkey = 0
1104 SET RELATION TO
1105
1106
1107 *==== oKEY FOR TRANSCARTON FROM TRANSORDER ====*
1108
1109
1110 *--- Update ctnkey of tcTransDetail
1111 *llRetVal= llRetVal and .SetRelation(tcTransCarton, "carton_num", tcTransDetail, "str(doc_num)+carton_num")
1112 SELECT (tcTransDetail)
1113 SCAN
1114
1115 IF NOT EMPTY(carton_num)
1116 IF SEEK(str(doc_num)+carton_num,tcTransCarton,"carton_num")
1117 Replace ctnkey WITH EVALUATE(tcTransCarton+ ".pkey"), ;
1118 okey WITH EVALUATE(tcTransCarton+ ".okey"),;
1119 ckey WITH EVALUATE(tcTransCarton+ ".ckey"),;
1120 fkey WITH EVALUATE(tcTransCarton+ ".fkey"),;
1121 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1122 errs_flg_d WITH "Y", ;
1123 Errs_msg_d WITH Errs_msg_d + " Not yet processed. "
1124 ENDIF
1125 ELSE
1126
1127 * See if we have already generated a blank carton for this prod num
1128 *--- TR 1080996 14-Sep-2014 Goutam
1129 *IF SEEK(str(doc_num)+STR(prod_num),tcTransCarton,"prod_num")
1130 IF SEEK(str(doc_num)+STR(prod_num)+cntr_num,tcTransCarton,"prod_cntr")
1131 *=== TR 1080996 14-Sep-2014 Goutam
1132 *--- TR 1082847 31-1-2015 VKK
1133 llGenerateCartons = EMPTY(EVALUATE(tcTransCarton+ ".carton_num"))
1134 *=== TR 1082847 31-1-2015 VKK
1135
1136 Replace ctnkey WITH EVALUATE(tcTransCarton+ ".pkey"), ;
1137 okey WITH EVALUATE(tcTransCarton+ ".okey"),;
1138 ckey WITH EVALUATE(tcTransCarton+ ".ckey"),;
1139 fkey WITH EVALUATE(tcTransCarton+ ".fkey"),;
1140 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1141 errs_flg_d WITH "Y", ;
1142 Errs_msg_d WITH Errs_msg_d + " Not yet processed. "
1143 ELSE
1144 * Did not find carton header. will need to generate
1145 llGenerateCartons = .T.
1146
1147 IF NOT SEEK(str(doc_num)+cntr_num+STR(prod_num),tcTransOrder,"cntr_prod")
1148 =SEEK(str(doc_num)+STR(prod_num),tcTransOrder,"prod_num")
1149 ENDIF
1150
1151 Replace okey WITH EVALUATE(tcTransOrder+ ".pkey"),;
1152 ckey WITH EVALUATE(tcTransOrder+ ".ckey"),;
1153 fkey WITH EVALUATE(tcTransOrder+ ".fkey"),;
1154 User_id WITH EDI_USER, Last_mod WITH DATETIME(),;
1155 errs_flg_d WITH "Y", ;
1156 Errs_msg_d WITH Errs_msg_d + " Not yet processed. "
1157
1158
1159 SELECT (tcTransDetail)
1160 SCATTER NAME loDtl MEMO
1161
1162 loDtl.pkey = v_nextpkey("ZZEISPTN")
1163
1164 replace ctnkey WITH loDTL.pkey
1165
1166 SELECT(tcTransCarton)
1167 APPEND BLANK
1168
1169
1170 GATHER NAME loDtl MEMO
1171
1172 replace carton_ref WITH '',;
1173 carton_wgt WITH 0,;
1174 carton_vol WITH 0,;
1175 ERRS_FLG_CTN WITH "Y",;
1176 Errs_msg_CTN WITH Errs_msg_CTN + " Not yet processed. "
1177
1178 ENDIF
1179 ENDIF
1180
1181 ENDSCAN
1182
1183 LOCAL lcDtlOrder
1184 IF llGenerateCartons
1185 SELECT (tcTransDetail)
1186 lcDtlOrder = SET("Order")
1187 SET ORDER TO ctnkey
1188
1189 SELECT(tcTransCarton)
1190 IF SEEK(.T.,tcTransCarton,"empty_ctn")
1191 lcOrder = SET("Order")
1192 SET ORDER TO empty_ctn
1193
1194 SCAN WHILE EMPTY(carton_num)
1195
1196 *--- TR 1076260 18-Mar-2014 Goutam
1197 IF SEEK(fkey, tcTransHeader, "PKEY") AND !INLIST(EVALUATE(tcTransHeader + ".asn_type"),'NO','TH')
1198 *=== TR 1076260 18-Mar-2014 Goutam
1199
1200 *--- TR 1082847 31-1-2015 VKK Added asn_type
1201 lcCtnNum = .GetNextCartonNum(EVALUATE(tcTransHeader + ".asn_type"))
1202
1203 SELECT(tcTransCarton)
1204 replace carton_num WITH lcCtnNum
1205 lnCtnPkey = pkey
1206 IF SEEK(lnCtnPkey,tcTransDetail,"ctnkey")
1207 SELECT (tcTransDetail)
1208 SCAN WHILE ctnkey = lnCtnPkey
1209 replace carton_num WITH lcCtnNum
1210 ENDSCAN
1211 ENDIF
1212
1213 *--- TR 1076260 18-Mar-2014 Goutam
1214 ENDIF
1215 *=== TR 1076260 18-Mar-2014 Goutam
1216
1217 ENDSCAN
1218 SET ORDER TO &lcOrder
1219 ENDIF
1220 SELECT (tcTransDetail)
1221 SET ORDER TO &lcDtlOrder
1222
1223 ENDIF
1224
1225 *SET RELATION TO
1226 ENDIF
1227
1228 *--- TR 1050836 27-Jul-2011 Partha ---
1229 .CreateDocStoreCursor(tcTransHeader, "tcDoc_Count")
1230 lcDocCount = "tcDoc_Count"
1231
1232 *--- TR 1076260 18-Mar-2014 Goutam
1233 *.LoadHeaderDetailNotes("tcHdrNotes", tcTransHdrNotes, lcDocCount)
1234 .LoadHeaderDetailNotes("tcHdrNotes", tcTransHdrNotes, lcDocCount, 'H')
1235 *=== TR 1076260 18-Mar-2014 Goutam
1236
1237 *=== TR 1050836 27-Jul-2011 Partha ===
1238
1239 *--- TR 1076260 18-Mar-2014 Goutam
1240 .CreateDocOrderCursor(tcTransOrder, "tcOrdDoc_Count")
1241 lcOrdDocCount = "tcOrdDoc_Count"
1242
1243 .LoadHeaderDetailNotes("tcOdrNotes", tcTransOdrNotes, lcOrdDocCount, 'O')
1244 *=== TR 1076260 18-Mar-2014 Goutam
1245
1246
1247 ELSE
1248 llRetVal=.F.
1249 ENDIF
1250 ENDWITH
1251
1252 .TableClose("tcALLmwH")
1253 .TableClose("tcALLmwC")
1254 .TableClose("tcALLmwO")
1255 .TableClose("tcALLmwN")
1256 .TableClose("tcALLmwD")
1257 .TableClose("tcDoc_Count") && TR 1050836 27-Jul-2011 Partha
1258 .TableClose("tcOrdDoc_Count") && *--- TR 1076260 18-Mar-2014 Goutam
1259
1260 RETURN llRetVal
1261 ENDPROC
1262
1263*============================================================
1264 PROCEDURE QueryTransaction
1265 PARAMETERS pcFilterCriteria, pcASNType
1266 *--- TR 1076260 18-Mar-2014 Goutam. Added one more parameter pcASNType
1267
1268 LOCAL llRetVal, lcSQLSelect, lcSQLOrder, lnThermoCnt, lnCursorBuffer, ;
1269 lcAddHdrFld, lcAddDtlFld
1270
1271 llRetVal = .T.
1272 lnOldSelect = SELECT()
1273 lnThermoCnt = 0
1274ASSERT .f.
1275 WITH THIS
1276
1277 *--- TR 1076260 18-Mar-2014 Goutam.
1278 This.lNoDataFound = false
1279
1280 *--- 1078769 10-Jul-2014 Goutam
1281 IF EMPTY(pcASNType)
1282 *--- TR 1082847 31-1-2015 VKK Added list of asn_type here 'DS', 'X1','X2' or 'X3'
1283 *pcFilterCriteria = IIF(EMPTY(pcFilterCriteria), " Where h.asn_type in ('SH','')", pcFilterCriteria + " And h.asn_type in ('SH','')")
1284 pcFilterCriteria = IIF(EMPTY(pcFilterCriteria), " Where ", pcFilterCriteria + " And " ) + ASN_TYPE_SQL_COND
1285 *=== TR 1082847 31-1-2015 VKK
1286 ELSE
1287 *=== 1078769 10-Jul-2014 Goutam
1288 pcFilterCriteria = IIF(EMPTY(pcFilterCriteria), " Where h.asn_type = " + SqlFormatChar(pcASNType), pcFilterCriteria + " And h.asn_type = " + SqlFormatChar(pcASNType))
1289
1290 *--- 1078769 10-Jul-2014 Goutam
1291 ENDIF
1292 *=== 1078769 10-Jul-2014 Goutam
1293
1294 *=== TR 1076260 18-Mar-2014 Goutam.
1295
1296 .oLog.LogEntry("Creating transaction views.")
1297 THIS.InitThermoWithCaption(@lnThermoCnt, 5, "Creating and open transaction views...")
1298
1299 *-- Create EDIiSP work table views
1300 lcSQLOrder = "doc_num"
1301 lcSQLSelect = "select * from zzeisPth h " + pcFilterCriteria
1302 THIS.CreateSQLView("VzzeiSpth_iSPproc", lcSQLSelect,, lcSQLOrder)
1303 THIS.AdvanceThermoPlus(@lnThermoCnt)
1304
1305 lcSQLOrder = "doc_num, cntr_num"
1306 lcSQLSelect = "select * from zzeiSPtc where fkey in (select h.pkey from zzeisPth h " + ;
1307 pcFilterCriteria + ")"
1308 THIS.CreateSQLView("VzzeiSPtc_iSPproc", lcSQLSelect,, lcSQLOrder)
1309 THIS.AdvanceThermoPlus(@lnThermoCnt)
1310
1311 lcSQLOrder = "doc_num, cntr_num, prod_num"
1312 lcSQLSelect = "select * from zzeiSPto where fkey in (select h.pkey from zzeisPth h " + ;
1313 pcFilterCriteria + ")"
1314 THIS.CreateSQLView("VzzeiSPto_iSPproc", lcSQLSelect,, lcSQLOrder)
1315 THIS.AdvanceThermoPlus(@lnThermoCnt)
1316
1317 lcSQLOrder = "doc_num, cntr_num, prod_num, carton_num"
1318 lcSQLSelect = "select * from zzeiSPtn where fkey in (select h.pkey from zzeisPth h " + ;
1319 pcFilterCriteria + ")"
1320 THIS.CreateSQLView("VzzeiSPtn_iSPproc", lcSQLSelect,, lcSQLOrder)
1321 THIS.AdvanceThermoPlus(@lnThermoCnt)
1322
1323 lcSQLOrder = "doc_num, cntr_num, prod_num, carton_num, open_seq"
1324 lcSQLSelect = "select * from zzeiSPtd where fkey in (select h.pkey from zzeisPth h " + ;
1325 pcFilterCriteria + ")"
1326 THIS.CreateSQLView("VzzeiSPtd_iSPproc", lcSQLSelect,, lcSQLOrder)
1327 THIS.AdvanceThermoPlus(@lnThermoCnt)
1328
1329 *--- TR 1050836 27-Jul-2011 Partha ---
1330 lcSQLSelect = "select * from sysnotes where fkey in (select h.pkey from zzeiSPth h " +;
1331 pcFilterCriteria + ") AND TABLE_NAME = 'ZZEISPTH'"
1332 This.CreateSQLView("VzzeiSpth_notes_iSPproc", lcSQLSelect,,"NoOrderBy")
1333 *=== TR 1050836 27-Jul-2011 Partha ===
1334
1335 *--- TR 1076260 18-Mar-2014 Goutam
1336 lcSQLSelect = "select n.* from sysnotes n where exists(select 1 from zzeiSPto o where o.pkey = n.fkey " + ;
1337 " and exists(select 1 from zzeiSPth h " + pcFilterCriteria + " and h.pkey = o.fkey)) " + ;
1338 " and n.table_name = 'ZZEISPTO'"
1339
1340 This.CreateSQLView("VzzeiSpto_notes_iSPproc", lcSQLSelect,,"NoOrderBy")
1341 *=== TR 1076260 18-Mar-2014 Goutam
1342
1343 .oLog.LogEntry("Opening transaction views.")
1344
1345 lnCursorBuffer = DB_BUFOPTRECORD
1346
1347 IF NOT (THIS.OPENTABLE("VzzeiSPth_iSPproc",, .T.,,lnCursorBuffer) AND ;
1348 THIS.OPENTABLE("Vzzeispth_notes_iSPproc",, .T.,,lnCursorBuffer) AND ; && TR 1050836 27-Jul-2011 Partha
1349 THIS.OPENTABLE("Vzzeispto_notes_iSPproc",, .T.,,lnCursorBuffer) AND ; && *--- TR 1076260 18-Mar-2014 Goutam
1350 THIS.OPENTABLE("VzzeiSPtc_iSPproc",, .T.,,lnCursorBuffer) AND ;
1351 THIS.OPENTABLE("VzzeiSPto_iSPproc",, .T.,,lnCursorBuffer) AND ;
1352 THIS.OPENTABLE("VzzeiSPtn_iSPproc",, .T.,,lnCursorBuffer) AND ;
1353 THIS.OPENTABLE("VzzeiSPtd_iSPproc",, .T.,,lnCursorBuffer))
1354 llRetVal = .F.
1355 ELSE
1356
1357 SELECT VzzeiSPth_iSPproc
1358 INDEX ON pkey TAG pkey
1359 INDEX ON STR(doc_num) TAG doc_num
1360 SET ORDER TO
1361
1362 *--- TR 1050836 27-Jul-2011 Partha ---
1363 Select Vzzeispth_notes_iSPproc
1364 Index On pkey Tag pkey
1365 SET ORDER TO
1366 *=== TR 1050836 27-Jul-2011 Partha ===
1367
1368 *--- TR 1076260 18-Mar-2014 Goutam
1369 Select Vzzeispto_notes_iSPproc
1370 Index On pkey Tag pkey
1371 SET ORDER TO
1372 *=== TR 1076260 18-Mar-2014 Goutam
1373
1374 SELECT VzzeiSPtc_iSPproc
1375 INDEX ON pkey TAG pkey
1376 INDEX ON fkey TAG fkey
1377 INDEX ON STR(doc_num) TAG doc_num
1378 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
1379 SET ORDER TO
1380
1381 SELECT VzzeiSPto_iSPproc
1382 INDEX ON pkey TAG pkey
1383 INDEX ON fkey TAG fkey
1384 INDEX ON ckey TAG ckey
1385 INDEX ON STR(doc_num) TAG doc_num
1386 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
1387 INDEX ON STR(doc_num) + STR(prod_num) TAG prod_num
1388 SET ORDER TO
1389
1390 SELECT VzzeiSPtn_iSPproc
1391 INDEX ON pkey TAG pkey
1392 INDEX ON fkey TAG fkey
1393 INDEX ON ckey TAG ckey
1394 INDEX ON okey TAG okey
1395 INDEX ON STR(doc_num) TAG doc_num
1396 INDEX ON STR(doc_num) + cntr_num TAG cntr_num
1397 INDEX ON STR(doc_num) + carton_num TAG carton_num
1398 SET ORDER TO
1399
1400 SELECT VzzeiSPtd_iSPproc
1401 INDEX ON pkey TAG pkey FOR NOT DELETED()
1402 INDEX ON fkey TAG fkey
1403 INDEX ON ckey TAG ckey
1404 INDEX ON okey TAG okey
1405 INDEX ON ctnkey TAG ctnkey
1406 INDEX ON STR(doc_num) TAG doc_num
1407
1408 SET ORDER TO
1409
1410 *-- Set table buffer to 5
1411 .SetBufferMode("VzzeiSPth_iSPproc", DB_BUFOPTTABLE)
1412 .SetBufferMode("VzzeiSPtc_iSPproc", DB_BUFOPTTABLE)
1413 .SetBufferMode("VzzeiSPto_iSPproc", DB_BUFOPTTABLE)
1414 .SetBufferMode("VzzeiSPtn_iSPproc", DB_BUFOPTTABLE)
1415 .SetBufferMode("VzzeiSPtd_iSPproc", DB_BUFOPTTABLE)
1416 .SetBufferMode("Vzzeispth_notes_iSPproc", DB_BUFOPTTABLE) && TR 1050836 27-Jul-2011 Partha
1417 .SetBufferMode("Vzzeispto_notes_iSPproc", DB_BUFOPTTABLE) && *--- TR 1076260 18-Mar-2014 Goutam
1418
1419 ENDIF
1420
1421 *--- TR 1076260 18-Mar-2014 Goutam. Addd llRetVal
1422 IF llRetVal AND RECCOUNT("VzzeiSPth_iSPproc") > 0
1423
1424 .oLog.LogEntry("Creating transaction header cursors from views.")
1425 .AdvanceThermoTotalWithCaptionPlus("Creating temporary transaction cursors...", vcLogName)
1426
1427 *--- TR 1037787 8-Apr-2009 Goutam. added Control_Key
1428 SELECT *, 999999999 As Control_Key FROM VzzeiSPth_iSPproc INTO CURSOR __EiSPth
1429
1430 THIS.MakeCursorWritable("__EiSPth", "tcEiSPth")
1431 SELECT tcEiSPth
1432 .niSPHeader = THIS.CountTotalRecs("tcEiSPth")
1433 INDEX ON pkey TAG pkey
1434 *--- TR 1037787 8-Apr-2009 Goutam
1435 INDEX ON shipment_num TAG SHPMNUM
1436 *=== TR 1037787 8-Apr-2009 Goutam
1437
1438 *--- TR 1050836 27-Jul-2011 Partha ---
1439 SELECT * FROM VzzeiSPth_notes_iSPproc INTO CURSOR __EiSPth_notes
1440 THIS.MakeCursorWritable("__EiSPth_notes", "tcEiSPth_notes")
1441 SELECT tcEiSPth_notes
1442 .niSPHeaderNotes = THIS.CountTotalRecs("tcEiSPth_notes")
1443 INDEX ON pkey TAG pkey
1444 INDEX ON fkey TAG fkey
1445 *=== TR 1050836 27-Jul-2011 Partha ===
1446
1447 *--- TR 1076260 18-Mar-2014 Goutam
1448 SELECT * FROM VzzeiSPto_notes_iSPproc INTO CURSOR __EiSPto_notes
1449 THIS.MakeCursorWritable("__EiSPto_notes", "tcEiSPto_notes")
1450 SELECT tcEiSPto_notes
1451 INDEX ON pkey TAG pkey
1452 INDEX ON fkey TAG fkey
1453 *=== TR 1076260 18-Mar-2014 Goutam
1454
1455 .oLog.LogEntry("Creating transaction container cursors from views.")
1456 SELECT * FROM VzzeiSPtc_iSPproc INTO CURSOR __EiSPtc
1457 THIS.MakeCursorWritable("__EiSPtc", "tcEiSPtc")
1458 SELECT tcEiSPtc
1459 .niSPContainer = THIS.CountTotalRecs("tcEiSPtc")
1460 INDEX ON pkey TAG pkey
1461 INDEX ON fkey TAG fkey
1462 SET ORDER TO
1463
1464 .oLog.LogEntry("Creating transaction order cursors from views.")
1465 SELECT * FROM VzzeiSPto_iSPproc INTO CURSOR __EiSPto
1466 THIS.MakeCursorWritable("__EiSPto", "tcEiSPto")
1467 SELECT tcEiSPto
1468 .niSPOrder = THIS.CountTotalRecs("tcEiSPto")
1469 INDEX ON pkey TAG pkey
1470 INDEX ON fkey TAG fkey
1471 INDEX ON ckey TAG ckey
1472 SET ORDER TO
1473
1474 .oLog.LogEntry("Creating transaction carton cursors from views.")
1475 SELECT * FROM VzzeiSPtn_iSPproc INTO CURSOR __EiSPtn
1476 THIS.MakeCursorWritable("__EiSPtn", "tcEiSPtn")
1477 SELECT tcEiSPtn
1478 .niSPCarton = THIS.CountTotalRecs("tcEiSPtn")
1479 INDEX ON pkey TAG pkey
1480 INDEX ON fkey TAG fkey
1481 INDEX ON ckey TAG ckey
1482 INDEX ON okey TAG okey
1483 INDEX ON STR(fkey)+STR(ckey) TAG FCKEY
1484 SET ORDER TO
1485
1486 .oLog.LogEntry("Creating transaction detail cursors from views.")
1487 SELECT * FROM VzzeiSPtd_iSPproc INTO CURSOR __EiSPtd
1488 THIS.MakeCursorWritable("__EiSPtd", "tcEiSPtd")
1489 SELECT tcEiSPtd
1490 .niSPDetail = THIS.CountTotalRecs("tcEiSPtd")
1491 INDEX ON pkey TAG pkey
1492 INDEX ON fkey TAG fkey
1493 INDEX ON ckey TAG ckey
1494 INDEX ON okey TAG okey
1495 INDEX ON ctnkey TAG ctnkey
1496 INDEX ON STR(fkey)+STR(ckey)+STR(ctnkey) TAG ALLKEY
1497 INDEX ON STR(fkey)+STR(ctnkey) TAG CTNFKEY
1498
1499 *--- TR 1074657 17-Dec-2013 Goutam
1500 INDEX ON STR(prod_num)+consol_prod_line+upc TAG CONSL_PROD
1501 *=== TR 1074657 17-Dec-2013 Goutam
1502
1503 *--- TR 1076260 18-Mar-2014 Goutam
1504 INDEX on STR(prod_num) + STR(open_seq) TAG prod_num
1505 *=== TR 1076260 18-Mar-2014 Goutam
1506
1507 SET ORDER TO
1508 ELSE
1509 This.lNoDataFound = .T.
1510 ENDIF
1511
1512 THIS.ResetThermoPlus()
1513 .tableclose("__EiSPth")
1514 .tableclose("__EiSPtc")
1515 .tableclose("__EiSPto")
1516 .tableclose("__EiSPtn")
1517 .tableclose("__EiSPtd")
1518 .tableclose("__EiSPth_notes") && TR 1050836 27-Jul-2011 Partha
1519 .tableclose("__EiSPto_notes") && TR *--- TR 1076260 18-Mar-2014 Goutam
1520 ENDWITH
1521
1522 SELECT(lnOldSelect)
1523 RETURN llRetVal
1524 ENDPROC
1525
1526*============================================================
1527
1528 PROCEDURE PreValidation
1529 PARAMETERS pceispTH, pceispTC, pceispTO, pceispTN, pceispTD, pcASNType
1530 *--- TR 1076260 18-Mar-2014 Goutam. Added above parameter pcASNType
1531
1532 LOCAL llRetVal
1533
1534 llRetVal = true
1535
1536 WITH THIS
1537 .LogMajorStage("Validating transactions.")
1538 .oLog.LogEntry("Resetting all error messages in transaction tables.")
1539 .AdvanceThermoTotalWithCaptionPlus("Clear all error messages in transaction...", vcLogName)
1540
1541 *--- TechRec 1067730 07-Aug-2013 vkrishnamurthy --- Moved above this method
1542*!* llRetVal= llRetVal AND .ClearErrors(pceispTH, pceispTC, pceispTO, pceispTN, pceispTD)
1543 *=== TechRec 1067730 07-Aug-2013 vkrishnamurthy ===
1544
1545 .AdvanceThermoTotalWithCaptionPlus("Validating Header...", vcLogName)
1546
1547 *--- TR 1076260 18-Mar-2014 Goutam. Added below parameter pcASNType
1548 llRetVal= llRetVal AND .CheckHeader(pceiSPTH, pcASNType)
1549
1550 .AdvanceThermoTotalWithCaptionPlus("Validating Container...", vcLogName)
1551 llRetVal= llRetVal AND .Checkcontainer(pceiSPTH, pceiSPTC)
1552
1553 .AdvanceThermoTotalWithCaptionPlus("Validating Order...", vcLogName)
1554
1555 *--- TR 1076260 18-Mar-2014 Goutam. Added below parameter pcASNType
1556 llRetVal= llRetVal AND .CheckOrder(pceiSPTH, pceiSPTO, pcASNType)
1557
1558 .AdvanceThermoTotalWithCaptionPlus("Validating Carton...", vcLogName)
1559 llRetVal= llRetVal AND .CheckCarton(pceiSPTN)
1560
1561 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU...", vcLogName)
1562
1563 *--- TR 1076260 18-Mar-2014 Goutam. Added below parameter pcASNType
1564 llRetVal= llRetVal AND .CheckDetail(pceiSPTH, pceiSPTO, pceiSPTD, pcASNType)
1565
1566 *--- TR 1082847 31-1-2015 VKK
1567 IF EMPTY(pcASNType)
1568 llRetVal= llRetVal AND .CheckCrossDock(pceiSPTH, pcASNType,pceiSPTO,pceiSPTN,pceiSPTD)
1569 ENDIF
1570 *=== TR 1082847 31-1-2015 VKK
1571
1572 *--- TR 1065007 15-Jan-2014 Goutam
1573 .AdvanceThermoTotalWithCaptionPlus("Validating UOM...", vcLogName)
1574 llRetVal= llRetVal AND .ValidateInboundUOM(pceiSPTH, "Control_Key", "zzeispcr", "pkey")
1575 *=== TR 1065007 15-Jan-2014 Goutam
1576
1577 ENDWITH
1578
1579 RETURN llRetVal
1580 ENDPROC
1581
1582*============================================================
1583 PROCEDURE ClearErrors
1584 LPARAMETERS pceiSPTH, pceiSPTC, pceiSPTO, pceiSPTN, pceiSPTD
1585
1586 LOCAL llRetVal, lnOldSelect
1587 llRetVal = true
1588 lnOldSelect = SELECT()
1589
1590 REPLACE ALL Errs_msg_H WITH "", errs_flg_h WITH "N" IN (pceiSPTH)
1591 REPLACE ALL Errs_msg_CNTR WITH "", errs_flg_CNTR WITH "N" IN (pceiSPTC)
1592 REPLACE ALL Errs_msg_O WITH "", errs_flg_O WITH "N" IN (pceiSPTO)
1593 REPLACE ALL Errs_msg_CTN WITH "", errs_flg_CTN WITH "N" IN (pceiSPTN)
1594 REPLACE ALL Errs_Msg_D WITH "", errs_flg_D WITH "N" IN (pceiSPTD)
1595
1596 *--- TR 1074657 18-Nov-2013 Goutam
1597 REPLACE ALL warn_flg_d WITH "N", warn_msg_d WITH "" IN (pceispTD)
1598 *=== TR 1074657 18-Nov-2013 Goutam
1599
1600 *--- TR 1077026 22-May-2014 Partha ---
1601 REPLACE ALL Warn_msg_H WITH "", warn_flg_h WITH "N" IN (pceiSPTH)
1602 REPLACE ALL Warn_msg_CNTR WITH "", warn_flg_CNTR WITH "N" IN (pceiSPTC)
1603 REPLACE ALL Warn_msg_O WITH "", warn_flg_O WITH "N" IN (pceiSPTO)
1604 REPLACE ALL Warn_msg_CTN WITH "", warn_flg_CTN WITH "N" IN (pceiSPTN)
1605 *=== TR 1077026 22-May-2014 Partha ===
1606
1607 SELECT(lnOldSelect)
1608 RETURN llRetVal
1609 ENDPROC
1610
1611*============================================================
1612 PROCEDURE CheckHeader
1613 LPARAMETERS pceiSPTH, pcASNType
1614 *--- TR 1076260 18-Mar-2014 Goutam. Added above parameter pcASNType
1615
1616 LOCAL llRetVal, lnOldSelect, lcSql, llValidHeader
1617
1618 lnOldSelect = SELECT()
1619 llValidHeader = true
1620
1621 *---- Default Ship Stage and Ship Code
1622 LOCAL lcDefShptCode,lcDefShptStage
1623 lcDefShptCode = goEnv.sv("856I_DEFAULT_SHPT_CODE","")
1624 lcDefShptStage = goEnv.SV("856I_DEFAULT_SHPT_STAGE","")
1625
1626
1627 SELECT (pceiSPTH)
1628 IF NOT EMPTY(lcDefShptCode)
1629 REPLACE ALL shpt_code WITH lcDefShptCode FOR EMPTY(shpt_code)
1630 ENDIF
1631
1632 IF NOT EMPTY(lcDefShptStage)
1633 REPLACE ALL shpt_stage WITH lcDefShptStage FOR EMPTY(shpt_stage)
1634 ENDIF
1635 *==== Default Ship Stage and Ship Code
1636
1637 * populate auto proc
1638 &&--- TechRec 1067730 16-Jul-2013 vkrishnamurthy === Added ignore_warn
1639 UPDATE h ;
1640 SET auto_proc = IIF(EMPTY(h.auto_proc),c.auto_proc,h.auto_proc), ;
1641 ignore_warn = IIF(EMPTY(h.ignore_warn),c.ignore_warn,h.ignore_warn) ;
1642 ,x_dock_flg = IIF(EMPTY(h.x_dock_flg),c.x_dock_flg,h.x_dock_flg) ; && *--- TR 1082847 31-1-2015 VKK
1643 ,recalc_eta= IIF(EMPTY(h.recalc_eta),c.recalc_eta,h.recalc_eta) ; && *--- TR 1082847 31-1-2015 VKK
1644 FROM (pceiSPTH) h ;
1645 JOIN zzeispcr c ;
1646 ON c.pkey = h.Control_Key
1647
1648
1649 *--- TR 1037787 Goutam
1650 *--- TR 1076260 18-Mar-2014 Goutam. Added field asn_purpose, asn_type, book_num
1651 SELECT pkey, frght_frwdr, iso_fob, vessl_code, iso_port_entry, shpt_code, shpt_stage, iso_country, ;
1652 shipper, due_date, shpm_ref, vnd_qual, vnd_id, vnd_key, our_qual, our_id, Control_Key, ;
1653 asn_purpose, asn_type, book_num ;
1654 from (pceiSPTH) ;
1655 where errs_flg_h <> 'Y' ;
1656 AND git_ind = 0 ; && *--- TR 1082847 31-1-2015 VKK If 1 then it has already passed all these validation, so ignore
1657 INTO CURSOR __TmpTHCursor
1658
1659 WITH THIS
1660 .cSQLTempTable=""
1661 IF RECCOUNT('__TmpTHCursor') > 0 AND .GenerateSQLTempTable('__TmpTHCursor')
1662 IF .PopulateSQLTempTable('__TmpTHCursor')
1663 IF !EMPTY(.cSQLTempTable)
1664
1665 *------- Freight forwdr
1666 .oLog.LogEntry("Validating Freight Frwdr.")
1667 lcErrs_Msg = "Invalid Freight Frwdr." + CRLF
1668 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzxlocar b on " + ;
1669 " b.location = a.frght_frwdr " + ;
1670 " where a.frght_frwdr <> '' and b.loc_type <> 'W'"
1671 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1672
1673 SELECT _tmpValidationCursor
1674 INDEX on PKey TAG Pkey
1675 SELECT (pceiSPTH)
1676 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1677 FOR NOT EMPTY(frght_frwdr) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1678
1679 *------- ISO FOB Port
1680 .oLog.LogEntry("Validating ISO FOB Port.")
1681 lcErrs_Msg = "Invalid ISO FOB Port." + CRLF
1682 lcSql = "Select a.pkey, b.fob from " + .cSQLTempTable + " a join zzxfobpr b on " + ;
1683 " b.iso_port = a.iso_fob " + ;
1684 " where a.iso_fob <> ''"
1685 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1686
1687 SELECT _tmpValidationCursor
1688 INDEX on PKey TAG Pkey
1689 SELECT (pceiSPTH)
1690 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1691 FOR NOT EMPTY(iso_fob) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1692
1693 llRetVal= llRetVal and .SetRelation("_tmpValidationCursor", "pkey", pceiSPTH, "pkey")
1694
1695 SELECT (pceiSPTH)
1696 Replace All fob WITH _tmpValidationCursor.fob
1697 SET RELATION TO
1698
1699 *------- Vessl_code
1700 .oLog.LogEntry("Validating Vessel Code.")
1701 lcErrs_Msg = "Invalid Vessel Code." + CRLF
1702
1703 lcSql = "select h.pkey " + ;
1704 " from " + .cSQLTempTable + " h join zzmvessl v on v.vessl_code = h.vessl_code " + ;
1705 " and h.Shipper = v.Shipper " + ;
1706 " where h.vessl_code <> ''"
1707
1708 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1709
1710 SELECT _tmpValidationCursor
1711 INDEX on PKey TAG Pkey
1712 SELECT (pceiSPTH)
1713 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1714 FOR NOT EMPTY(vessl_code) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1715
1716 *------- ISO_Port_Entry
1717 .oLog.LogEntry("Validating port Entry.")
1718 lcErrs_Msg = "'Invalid ISO port Entry." + CRLF
1719 lcSql = "Select a.pkey, b.fob from " + .cSQLTempTable + " a join zzxfobpr b on " + ;
1720 " b.iso_port = a.iso_port_entry " + ;
1721 " where a.iso_port_entry <> ''"
1722 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1723
1724 SELECT _tmpValidationCursor
1725 INDEX on PKey TAG Pkey
1726 SELECT (pceiSPTH)
1727 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1728 FOR NOT EMPTY(iso_port_entry) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1729
1730 llRetVal= llRetVal and .SetRelation("_tmpValidationCursor", "pkey", pceiSPTH, "pkey")
1731
1732 SELECT (pceiSPTH)
1733 Replace All port_entry WITH _tmpValidationCursor.fob
1734 SET RELATION TO
1735
1736 *------- Shpt_code
1737 .oLog.LogEntry("Validating Ship Type.")
1738 lcErrs_Msg = "Invalid Ship Type." + CRLF
1739 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzmshpth b on " + ;
1740 " b.Shpt_code = a.Shpt_code "
1741 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1742
1743 SELECT _tmpValidationCursor
1744 INDEX on PKey TAG Pkey
1745 SELECT (pceiSPTH)
1746 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1747 FOR EMPTY(Shpt_code) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1748
1749 *------- Shpt_stage
1750 .oLog.LogEntry("Validating Ship Stage.")
1751 lcErrs_Msg = "Invalid ship Stage." + CRLF
1752
1753 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzmshptd b on " + ;
1754 " b.Shpt_code = a.Shpt_code and b.Shpt_stage = a.Shpt_stage"
1755 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1756
1757 SELECT _tmpValidationCursor
1758 INDEX on PKey TAG Pkey
1759 SELECT (pceiSPTH)
1760 *--- TechRec 1074501 31-Oct-2013 vkrishnamurthy ---
1761*!* replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1762*!* FOR EMPTY(Shpt_code) or EMPTY(Shpt_stage) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1763 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1764 FOR EMPTY(Shpt_code) or (NOT EMPTY(Shpt_stage) and NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" ) )
1765 *=== TechRec 1074501 31-Oct-2013 vkrishnamurthy ===
1766
1767 *------- ISO_Country
1768 .oLog.LogEntry("Validating Country.")
1769 lcErrs_Msg = "Invalid ISO Country." + CRLF
1770 lcSql = "Select a.pkey, b.Country from " + .cSQLTempTable + " a join zzxcntyr b on " + ;
1771 " a.iso_country = b.iso_code_char " + ;
1772 " And LEN(a.iso_country) = 3 " + ; && *--- TR 1082847 31-1-2015 VKK
1773 " where a.iso_country <> ''"
1774
1775 *--- TR 1082847 31-1-2015 VKK
1776 lcSql = lcSQL + " UNION ALL " + ;
1777 " Select a.pkey, b.Country from " + .cSQLTempTable + " a join zzxcntyr b on " + ;
1778 " a.iso_country = b.iso_code_2 " + ;
1779 " And LEN(a.iso_country) = 2 " + ;
1780 " where a.iso_country <> ''"
1781 *=== TR 1082847 31-1-2015 VKK
1782
1783 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1784
1785 SELECT _tmpValidationCursor
1786 INDEX on PKey TAG Pkey
1787 SELECT (pceiSPTH)
1788 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1789 FOR NOT EMPTY(iso_country) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1790
1791 llRetVal= llRetVal and .SetRelation("_tmpValidationCursor", "pkey", pceiSPTH, "pkey")
1792
1793 SELECT (pceiSPTH)
1794 Replace All Country WITH _tmpValidationCursor.Country
1795 SET RELATION TO
1796
1797
1798 *------- Shipper
1799 .oLog.LogEntry("Validating Shipper.")
1800 lcErrs_Msg = "Invalid Shipper." + CRLF
1801 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzxshipr b on " + ;
1802 " b.Shipper = a.Shipper " + ;
1803 " where a.Shipper <> ''"
1804 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1805
1806 SELECT _tmpValidationCursor
1807 INDEX on PKey TAG Pkey
1808 SELECT (pceiSPTH)
1809 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1810 FOR NOT EMPTY(Shipper) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1811
1812
1813 *------- Due Date
1814 *.oLog.LogEntry("Validating Due Date.")
1815 *lcErrs_Msg = "Empty Due Date." + CRLF
1816 *replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1817 * FOR EMPTY(due_date) IN (pceiSPTH)
1818
1819 *------- shpm_ref
1820 *--- TR 1037787 9-Apr-2009 Goutam
1821 .oLog.LogEntry("Validating Shipment Reference.")
1822
1823 *--- TR 1060457 04/02/12 ATHIRUNAVU Modified condition to check Asg_shipment <> 'Y'
1824 *Select h.pkey from __TmpTHCursor h ;
1825 JOIN zzeispcr c ;
1826 ON c.pkey = h.Control_Key ;
1827 WHERE c.Asg_shipment = 'Y' ;
1828 INTO Cursor _tmpShpmRef
1829
1830 Select h.pkey from __TmpTHCursor h ;
1831 JOIN zzeispcr c ;
1832 ON c.pkey = h.Control_Key ;
1833 WHERE c.Asg_shipment = 'N' ;
1834 INTO Cursor _tmpShpmRef
1835 *=== TR 1060457 04/02/12 ATHIRUNAVU
1836
1837 SELECT _tmpShpmRef
1838 INDEX on PKey TAG Pkey
1839
1840 SELECT (pceiSPTH)
1841 *--- TR 1060457 04/02/12 ATHIRUNAVU Removed ! from INDEXSEEK(
1842 lcErrs_Msg = "Missing Shipment Reference." + CRLF
1843 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1844 FOR INDEXSEEK(Pkey,.F., "_tmpShpmRef" ) AND EMPTY(shpm_ref)
1845
1846 lcErrs_Msg = "Invalid Shipment Reference Format. Must be an integer." + CRLF
1847 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1848 FOR INDEXSEEK(Pkey,.F., "_tmpShpmRef" ) AND NOT EMPTY(shpm_ref) AND ;
1849 ((VAL(shpm_ref) <> INT(VAL(shpm_ref))) OR VAL(shpm_ref) <= 0)
1850
1851 lcErrs_Msg = "Invalid Shipment Reference Length (max 999999999)." + CRLF
1852 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1853 FOR INDEXSEEK(Pkey,.F., "_tmpShpmRef" ) AND (VAL(shpm_ref)>999999999)
1854
1855 lcErrs_Msg = "Shipment number already exists." + CRLF
1856 lcSql = "Select a.pkey from " + .cSQLTempTable + " a " + ;
1857 " Where exists(select 1 from zzmshpmh where convert(char(25),shipment_num) = a.shpm_ref)"
1858
1859 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1860
1861 SELECT _tmpValidationCursor
1862 INDEX on PKey TAG Pkey
1863 SELECT (pceiSPTH)
1864 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1865 FOR INDEXSEEK(Pkey,.F., "_tmpShpmRef" ) ;
1866 AND NOT INLIST(asn_type, 'X3', 'X2') ; && *--- TR 1082847 31-1-2015 VKK
1867 AND INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
1868
1869 *--- TR 1060457 04/02/12 ATHIRUNAVU Removed ! from INDEXSEEK( when it searched in _tmpShpmref
1870 *=== TR 1037787 9-Apr-2009 Goutam
1871
1872 *--- TR 1076260 18-Mar-2014 Goutam.
1873 IF INLIST(pcASNType, 'NO', 'TH')
1874 .oLog.LogEntry("Validating header for ASN type 'NO' or 'TH'.")
1875
1876 *--- TR 1078769 17-Jun-2014 Goutam. Change book number to booking number
1877 lcErrs_Msg = "Booking Number does not exist for this PO." + CRLF
1878
1879 SELECT (pceiSPTH)
1880 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1881 FOR EMPTY(book_num) AND !(asn_type = 'NO' AND asn_purpose = '00')
1882
1883 *--- TR 1078769 17-Jun-2014 Goutam. Commented below condition.
1884*!* lcErrs_Msg = "Book Number should not exist for this PO." + CRLF
1885*!* replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1886*!* FOR !EMPTY(book_num) AND asn_type = 'NO' AND asn_purpose = '00'
1887
1888 lcErrs_Msg = "Invalid ASN Purpose." + CRLF
1889 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1890 FOR (asn_type = 'TH' AND asn_purpose = '00')
1891 *=== TR 1078769 17-Jun-2014 Goutam
1892
1893 lcErrs_Msg = "Invalid ASN Purpose." + CRLF
1894 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg ;
1895 FOR !INLIST(asn_purpose, '00', '03', '05')
1896 ENDIF
1897 *=== TR 1076260 18-Mar-2014 Goutam.
1898
1899 ENDIF
1900 ENDIF
1901 ENDIF
1902
1903*!* *--- TR 1082847 31-1-2015 VKK
1904*!* SELECT Distinct h.pkey, o.prod_type, o.division ;
1905*!* FROM (pceiSPTH) h ;
1906*!* JOIN (pceiSPTO) o ON h.pkey = o.fkey ;
1907*!* where h.errs_flg_h <> 'Y' ;
1908*!* AND h.x_doc_flg = 'Y' ;
1909*!* And INLIST(h.asn_type, 'DS','X1','X2','X3') ;
1910*!* INTO CURSOR __TmpTHCursor
1911*!*
1912*!* .cSQLTempTable=""
1913*!* IF RECCOUNT('__TmpTHCursor') > 0 AND .GenerateSQLTempTable('__TmpTHCursor') AND .PopulateSQLTempTable('__TmpTHCursor') AND !EMPTY(.cSQLTempTable)
1914*!*
1915
1916*!* .oLog.LogEntry("Validating Cross Dock in All Production Type.")
1917*!* lcProdTypeList = ""
1918*!* lcErrs_Msg = "Production Types {<<lcProdTypeList>>} is not set up for Cross Dock functionality." + CRLF
1919*!*
1920*!* lcSql = "Select Distinct a.pkey, typ.prod_type from " + .cSQLTempTable + " a join zzctypeh typ on " + ;
1921*!* " typ.division = a.division" + ;
1922*!* " typ.prod_type = a.prod_type" + ;
1923*!* " where a.x_dock <> 'Y'"
1924*!* llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1925*!*
1926*!* SELECT _tmpValidationCursor
1927*!* INDEX on PKey TAG Pkey
1928*!* SELECT (pceiSPTH)
1929*!* SCAN
1930*!* lnPkey = Pkey
1931*!* lcProdTypeList = ""
1932*!*
1933*!* IF SEEK(lnPkey, "_tmpValidationCursor", "Pkey")
1934*!* SELECT _tmpValidationCursor
1935*!*
1936*!* SCAN WHILE Pkey = lnPkey
1937*!* lcProdTypeList = lcProdTypeList + SQLFormatChar(ALLTRIM(Prod_Type)) + ","
1938*!* ENDSCAN
1939*!*
1940*!* lcProdTypeList = RemoveLastdelimiter(lcProdTypeList)
1941*!*
1942*!* ENDIF
1943*!*
1944*!* IF NOT EMPTY(lcProdTypeList )
1945*!* replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcErrs_Msg) IN (pceiSPTH)
1946*!* ENDIF
1947*!*
1948*!* ENDSCAN
1949*!*
1950*!* ENDIF
1951
1952*!* * Validation for Cross Dock Upc and ord and qty
1953*!* SELECT Distinct h.pkey, n.ord_num, d.upc, ;
1954*!* FROM (pceiSPTH) h ;
1955*!* JOIN (pceiSPTn) n ON h.pkey = n.fkey ;
1956*!* JOIN (pceiSPTd) n ON h.pkey = n.fkey ;
1957*!* where h.errs_flg_h <> 'Y' ;
1958*!* AND h.x_doc_flg = 'Y' ;
1959*!* And INLIST(h.asn_type, 'DS','X3') ;
1960*!* INTO CURSOR __TmpTHCursor
1961*!*
1962*!* .cSQLTempTable=""
1963*!* IF RECCOUNT('__TmpTHCursor') > 0 AND .GenerateSQLTempTable('__TmpTHCursor') AND .PopulateSQLTempTable('__TmpTHCursor') AND !EMPTY(.cSQLTempTable)
1964*!*
1965
1966*!* .oLog.LogEntry("Validating Cross Dock in All Production Type.")
1967*!* lcProdTypeList = ""
1968*!* lcErrs_Msg = "Production Types {<<lcProdTypeList>>} is not set up for Cross Dock functionality." + CRLF
1969*!*
1970*!* lcSql = "Select Distinct a.pkey, typ.prod_type from " + .cSQLTempTable + " a join zzctypeh typ on " + ;
1971*!* " typ.division = a.division" + ;
1972*!* " typ.prod_type = a.prod_type" + ;
1973*!* " where a.x_dock <> 'Y'"
1974*!* llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
1975*!*
1976*!* SELECT _tmpValidationCursor
1977*!* INDEX on PKey TAG Pkey
1978*!* SELECT (pceiSPTH)
1979*!* SCAN
1980*!* lnPkey = Pkey
1981*!* lcProdTypeList = ""
1982*!*
1983*!* IF SEEK(lnPkey, "_tmpValidationCursor", "Pkey")
1984*!* SELECT _tmpValidationCursor
1985*!*
1986*!* SCAN WHILE Pkey = lnPkey
1987*!* lcProdTypeList = lcProdTypeList + SQLFormatChar(ALLTRIM(Prod_Type)) + ","
1988*!* ENDSCAN
1989*!*
1990*!* lcProdTypeList = RemoveLastdelimiter(lcProdTypeList)
1991*!*
1992*!* ENDIF
1993*!*
1994*!* IF NOT EMPTY(lcProdTypeList )
1995*!* replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcErrs_Msg) IN (pceiSPTH)
1996*!* ENDIF
1997*!*
1998*!* ENDSCAN
1999*!*
2000*!* ENDIF
2001*!* *--- TR 1082847 31-1-2015 VKK
2002
2003 USE IN __TmpTHCursor
2004 .tableclose('_tmpValidationCursor')
2005 ENDWITH
2006
2007 SELECT(lnOldSelect)
2008 RETURN llValidHeader
2009 ENDPROC
2010*============================================================
2011
2012 PROCEDURE CheckContainer
2013 LPARAMETERS pceiSPTH, pceiSPTC
2014
2015 LOCAL llRetVal, lnOldSelect, llValidContainer
2016
2017 llRetVal = true
2018 llValidContainer = true
2019 lnOldSelect = SELECT()
2020
2021 *---- Default Container Size
2022 LOCAL lcDefContSize
2023 lcDefContSize = goEnv.sv("856I_DEFAULT_CONT_SIZE","")
2024
2025 SELECT (pceiSPTC)
2026 IF NOT EMPTY(lcDefContSize)
2027 REPLACE ALL cont_size WITH lcDefContSize FOR EMPTY(cont_size)
2028 ENDIF
2029 *==== Default Container Size
2030
2031 *--- TR 1076599 18-Mar-2014 Partha - Added cntr num, shipment ref.
2032
2033 SELECT pkey, cont_size, location, cntr_num, shpm_ref ;
2034 from (pceiSPTC) ;
2035 where errs_flg_cntr <> 'Y' ;
2036 AND Fkey In (SELECT Pkey FROM (pceiSPTH) Where GIT_Ind = 0) ; && *--- TR 1082847 31-1-2015 VKK
2037 INTO CURSOR __TmpTCCursor
2038
2039 WITH THIS
2040 .cSQLTempTable=""
2041 IF RECCOUNT('__TmpTCCursor') > 0 AND .GenerateSQLTempTable('__TmpTCCursor')
2042 IF .PopulateSQLTempTable('__TmpTCCursor')
2043 IF !EMPTY(.cSQLTempTable)
2044
2045 *--- TR 1076599 18-Mar-2014 Partha ---
2046
2047 *------- Duplicate container
2048 .oLog.LogEntry("Validating Duplicate Containers.")
2049 lcErrs_Msg = "Duplicate Container." + CRLF
2050
2051 lcSql = "Select a.pkey from " + .cSQLTempTable + " a " + ;
2052 "JOIN ( SELECT cntr_num, shpm_ref, COUNT(*) cntr_occur " + ;
2053 " FROM " + .cSQLTempTable + ;
2054 " GROUP BY cntr_num,shpm_ref " + ;
2055 " ) B " + ;
2056 " ON a.cntr_num = B.cntr_num " + ;
2057 " AND B.cntr_occur =1 "
2058 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2059
2060 SELECT _tmpValidationCursor
2061 INDEX on PKey TAG Pkey
2062 SELECT (pceiSPTC)
2063 replace errs_flg_cntr with 'Y', errs_msg_cntr with errs_msg_cntr + lcErrs_Msg ;
2064 FOR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2065
2066 *=== TR 1076599 18-Mar-2014 Partha ===
2067
2068 *------- cont_size
2069 .oLog.LogEntry("Validating Container Sizes.")
2070 lcErrs_Msg = "Invalid Container Sizes." + CRLF
2071
2072 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzmcntsz b on " + ;
2073 " b.cont_size = a.cont_size "
2074 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2075
2076 SELECT _tmpValidationCursor
2077 INDEX on PKey TAG Pkey
2078 SELECT (pceiSPTC)
2079 replace errs_flg_cntr with 'Y', errs_msg_cntr with errs_msg_cntr + lcErrs_Msg ;
2080 FOR EMPTY(cont_size) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2081
2082
2083 *------- Location
2084 .oLog.LogEntry("Validating Location.")
2085 lcErrs_Msg = "Invalid Location." + CRLF
2086 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzxlocar b on " + ;
2087 " b.Location = a.Location "
2088 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2089
2090 SELECT _tmpValidationCursor
2091 INDEX on PKey TAG Pkey
2092 SELECT (pceiSPTC)
2093 replace errs_flg_cntr with 'Y', errs_msg_cntr with errs_msg_cntr + lcErrs_Msg ;
2094 FOR NOT EMPTY(Location) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2095
2096 ENDIF
2097 ENDIF
2098 ENDIF
2099
2100 USE IN __TmpTCCursor
2101 .tableclose('_tmpValidationCursor')
2102 ENDWITH
2103
2104 SELECT(lnOldSelect)
2105 RETURN llValidContainer
2106 ENDPROC
2107
2108***************************************
2109 PROCEDURE CheckOrder
2110 LPARAMETERS pceiSPTH, pceiSPTO, pcASNType
2111 *--- TR 1076260 18-Mar-2014 Goutam. Added above parameter pcASNType
2112
2113 LOCAL llRetVal, lnOldSelect, llValidOrder
2114
2115 llRetVal = true
2116 llValidOrder = true
2117 lnOldSelect = SELECT()
2118
2119 *--- TR 1082847 31-1-2015 VKK added join to pceispth and added alias and asn_type feidls
2120 SELECT o.pkey, h.asn_type, h.shpm_ref, o.Prod_Num, o.Prod_type, o.Division, o.Contractor, o.Shipto ;
2121 from (pceiSPTO) o ;
2122 JOIN (pceiSPTH) h ;
2123 ON h.pkey = o.fkey ;
2124 where errs_flg_o <> 'Y' ;
2125 AND GIT_Ind = 0 ; && *--- TR 1082847 31-1-2015 VKK
2126 INTO CURSOR __TmpTOCursor
2127
2128 WITH THIS
2129 .cSQLTempTable=""
2130 IF RECCOUNT('__TmpTOCursor') > 0 AND .GenerateSQLTempTable('__TmpTOCursor')
2131 IF .PopulateSQLTempTable('__TmpTOCursor')
2132 IF !EMPTY(.cSQLTempTable)
2133
2134 *--- Prod_Num
2135 .oLog.LogEntry("Validating Production Number.")
2136 lcErrs_Msg = "Invalid Production Number." + CRLF
2137 *--- TR 1082847 31-1-2015 VKK
2138*!* lcSql = "Select a.pkey,b.contractor,b.division,b.prod_type, shpdate from " + .cSQLTempTable + " a join zzcordrh b on " + ;
2139*!* " b.Prod_Num = a.Prod_Num "
2140
2141 TEXT TO lcSQL TEXTMERGE noshow
2142 select a.pkey
2143 , b.contractor
2144 , b.division
2145 , b.prod_type
2146 , b.shpdate
2147 , a.prod_num
2148 , Case When COALESCE(inTran.fkey, 0) = 0 Then 'N' Else 'Y' END As Prod_inTrans
2149 , Case When COALESCE(Recv.fkey, 0) = 0 Then 'N' Else 'Y' END As Prod_received
2150 , a.asn_type
2151 from <<.cSQLTempTable>> a
2152 join zzcordrh b
2153 on b.Prod_Num = a.Prod_Num
2154 left join (
2155 SELECT distinct d.fkey
2156 From zzcordrd d
2157 join <<.cSQLTempTable>> a
2158 ON a.prod_num = d.prod_num
2159 join (
2160 select t.division
2161 , t.prod_type
2162 , min(t.stage_num) intran_stage_num
2163 from zzctyped t
2164 where t.shp_ok = 'Y'
2165 group by t.division, t.prod_type) intran
2166 ON intran.division = d.division
2167 And intran.prod_type = d.prod_type
2168 Where d.stage_num >= COALESCE(intran.intran_stage_num, 0)
2169 ) inTran
2170 on intran.fkey = b.pkey
2171 left join (Select distinct d.fkey
2172 from zzcordrd d
2173 join <<.cSQLTempTable>> a
2174 ON a.prod_num = d.prod_num
2175 where d.last_stage = 'Y') Recv
2176 ON Recv.fkey = b.pkey
2177 ENDTEXT
2178 *=== TR 1082847 31-1-2015 VKK
2179
2180 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2181
2182 SELECT _tmpValidationCursor
2183 INDEX on PKey TAG Pkey
2184 SELECT (pceiSPTO)
2185
2186 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2187 FOR EMPTY(Prod_Num) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2188
2189
2190 *--- TR 1082847 31-1-2015 VKK
2191 * Validation for Cross Dock types
2192 .oLog.LogEntry("Validating Cross Dock Shipments.")
2193 lcErrs_Msg = "Cannot Receive Cross Dock Shipment <<shpm_ref>> against Production Order <<_tmpValidationCursor.Prod_Num>>. " + ;
2194 "The Shipment has already been received." + CRLF
2195
2196 *a. If asn_type = 'X2', the Production order has to be on or after InTransit stage and nothing should be in RECEIVE stage for
2197 *this Shipment Reference#. Error message: "Cannot Receive Cross Dock Shipment ABC against Production Order NNN.
2198 *The Shipment has already been received."
2199 SELECT (pceiSPTO)
2200 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + TEXTMERGE(lcErrs_Msg) ;
2201 FOR INDEXSEEK(Pkey,.T., "_tmpValidationCursor") AND _tmpValidationCursor.asn_type = 'X2' ;
2202 AND _tmpValidationCursor.Prod_inTrans = 'Y' AND _tmpValidationCursor.Prod_received = 'Y'
2203
2204
2205 lcErrs_Msg = "Cannot create sales cartons for Cross Dock Shipment <<shpm_ref>>/Production Order <<_tmpValidationCursor.Prod_Num>>. " + ;
2206 "The Shipment is not in InTransit stage." + CRLF
2207
2208 *a. If asn_type = 'X2', the Production order has to be on or after InTransit stage and nothing should be in RECEIVE stage for
2209 *this Shipment Reference#. Error message: "Cannot Receive Cross Dock Shipment ABC against Production Order NNN.
2210 *The Shipment has already been received."
2211 SELECT (pceiSPTO)
2212 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + TEXTMERGE(lcErrs_Msg) ;
2213 FOR INDEXSEEK(Pkey,.T., "_tmpValidationCursor") AND _tmpValidationCursor.asn_type = 'X2' ;
2214 AND _tmpValidationCursor.Prod_inTrans <> 'Y'
2215
2216 *****************************
2217
2218 * newly added**********************************
2219 *--- TR 1085844 22-4-2015 VKK added OR..not in InTranist.
2220 *lcErrs_Msg = "Cannot Receive Cross Dock Shipment <<shpm_ref>> against Production Order <<_tmpValidationCursor.Prod_Num>>. " + ;
2221 "The Shipment has not been yet received." + CRLF
2222 lcErrs_Msg = "Cannot Receive Cross Dock Shipment <<shpm_ref>> against Production Order <<_tmpValidationCursor.Prod_Num>>. " + ;
2223 "The Shipment has not been moved to Intransit/Received." + CRLF
2224 *=== TR 1085844 22-4-2015 VKK
2225
2226 SELECT (pceiSPTO)
2227 *b. If asn_type = 'X3', the Production order has to be in RECEIVE stage for this Shipment Reference#. Error message:
2228 *-"Cannot create sales cartons for Cross Dock Shipment ABC/Production Order NNN.
2229 *The Shipment has not been yet received."
2230 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + TEXTMERGE(lcErrs_Msg) ;
2231 FOR INDEXSEEK(Pkey,.T., "_tmpValidationCursor") AND _tmpValidationCursor.asn_type = 'X3' ;
2232 AND _tmpValidationCursor.Prod_received <> 'Y' AND _tmpValidationCursor.Prod_inTrans <> 'Y' && *--- TR 1085844 22-4-2015 VKK addedd _tmpValidationCursor.Prod_inTrans <> 'Y' condition
2233 *=== TR 1082847 31-1-2015 VKK
2234
2235 SELECT (pceiSPTO)
2236 SCAN
2237 IF NOT EMPTY(prod_num) AND SEEK(pkey,"_tmpValidationCursor","pkey")
2238
2239 IF EMPTY(EVALUATE(pceiSPTO + ".prod_type"))
2240 replace prod_type WITH _tmpValidationCursor.prod_type IN (pceiSPTO)
2241 ENDIF
2242 IF EMPTY(EVALUATE(pceiSPTO + ".contractor"))
2243 replace contractor WITH _tmpValidationCursor.contractor IN (pceiSPTO)
2244 ENDIF
2245 IF EMPTY(EVALUATE(pceiSPTO + ".division"))
2246 replace division WITH _tmpValidationCursor.division IN (pceiSPTO)
2247 ENDIF
2248
2249 IF EMPTY(EVALUATE(pcEispTo + ".shpdate")) AND .lUsePOShpDate
2250 replace shpdate WITH _tmpValidationCursor.shpdate IN (pceiSPTO)
2251 ENDIF
2252
2253 ENDIF
2254 ENDSCAN
2255
2256
2257 lcSQL = "UPDATE t " + ;
2258 " SET prod_type = case when t.prod_type > '' THEN t.prod_type ELSE h.prod_type end " + ;
2259 " ,contractor = case when t.contractor > '' THEN t.contractor ELSE h.contractor end " + ;
2260 " ,division = case when t.division > '' THEN t.division ELSE h.division end " + ;
2261 " FROM " + .cSQLTempTable + " t join zzcordrh h ON t.prod_num = h.prod_num "
2262 llRetVal = llRetVal AND v_sqlexec(lcSQL)
2263
2264
2265 *--- Prod_type
2266 .oLog.LogEntry("Validating Production Type for Production Number.")
2267 lcErrs_Msg = "Invalid Type for given Production Number." + CRLF
2268 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzcordrh b on " + ;
2269 " b.Prod_Num = a.Prod_Num and b.Prod_type = a.Prod_type"
2270 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2271
2272 SELECT _tmpValidationCursor
2273 INDEX on PKey TAG Pkey
2274 SELECT (pceiSPTO)
2275 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2276 FOR EMPTY(Prod_Num) OR EMPTY(Prod_Type) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2277
2278
2279 *--- Division
2280 .oLog.LogEntry("Validating Division for Production Number.")
2281 lcErrs_Msg = "Invalid Division for given Production Number." + CRLF
2282 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzcordrh b on " + ;
2283 " b.Prod_Num = a.Prod_Num and b.Prod_type = a.Prod_type and b.Division = a.Division"
2284 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2285
2286 SELECT _tmpValidationCursor
2287 INDEX on PKey TAG Pkey
2288 SELECT (pceiSPTO)
2289 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2290 FOR EMPTY(Prod_Num) OR EMPTY(Prod_Type) OR EMPTY(Division) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2291
2292 *--- Contractor
2293 .oLog.LogEntry("Validating Contractor for Production Number.")
2294 lcErrs_Msg = "Invalid Contractor for given Production Number." + CRLF
2295 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzcordrh b on " + ;
2296 " b.Prod_Num = a.Prod_Num and b.Prod_type = a.Prod_type and b.Division = a.Division and b.Contractor = a.Contractor "
2297 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2298
2299 SELECT _tmpValidationCursor
2300 INDEX on PKey TAG Pkey
2301 SELECT (pceiSPTO)
2302 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2303 FOR EMPTY(Prod_Num) OR EMPTY(Prod_Type) OR EMPTY(Division) OR EMPTY(Contractor) OR NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2304
2305 *--- Shipto
2306
2307 .oLog.LogEntry("Validating Shipto.")
2308 lcErrs_Msg = "Invalid Shipto." + CRLF
2309 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzxlocar b on " + ;
2310 " b.Location = a.Shipto "
2311 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2312
2313 *--- TechRec 1067730 27-May-2013 vkrishnamurthy ---
2314 *!* Change ORD records SHIPTO validation to check against both zzxlocar and zzxwhsgh.
2315 *!* Invalidate those records that do not match to any of these references - see function .CheckOrder()
2316 lcSql = "Select a.pkey from " + .cSQLTempTable + " a join zzxwhsgh b on " + ;
2317 " b.whs_grp = a.Shipto "
2318 llRetVal = v_sqlexec(lcSql, '_tmpValidWhsCursor')
2319 *=== TechRec 1067730 27-May-2013 vkrishnamurthy ===
2320
2321 SELECT _tmpValidationCursor
2322 INDEX on PKey TAG Pkey
2323
2324 *--- TechRec 1067730 27-May-2013 vkrishnamurthy ---
2325 SELECT _tmpValidWhsCursor
2326 INDEX on PKey TAG Pkey
2327 *=== TechRec 1067730 27-May-2013 vkrishnamurthy ===
2328
2329 SELECT (pceiSPTO)
2330
2331 &&--- TechRec 1067730 27-May-2013 vkrishnamurthy === Added AND NOT INDEXSEEK(Pkey,.F., "_tmpValidWhsCursor"
2332 *--- TR 1078769 21-Jun-2014 Goutam. shipto should be validated only if it is not blank
2333 *replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2334 FOR EMPTY(Shipto) OR (NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" ) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidWhsCursor" ))
2335
2336 replace errs_flg_o with 'Y', errs_msg_o with errs_msg_o + lcErrs_Msg ;
2337 FOR (EMPTY(Shipto) AND !INLIST(pcASNType,'NO','TH')) OR (!EMPTY(Shipto) AND (NOT INDEXSEEK(Pkey,.F., "_tmpValidationCursor" ) AND NOT INDEXSEEK(Pkey,.F., "_tmpValidWhsCursor" )))
2338 *=== TR 1078769 21-Jun-2014 Goutam
2339
2340 *------- ShpDate
2341
2342 *--- TR 1078769 21-Jun-2014 Goutam.
2343 IF !INLIST(pcASNType,'NO','TH')
2344 *=== TR 1078769 21-Jun-2014 Goutam.
2345 .oLog.LogEntry("Validating Ship Date.")
2346 lcErrs_Msg = "Empty Ship Date." + CRLF
2347 replace errs_flg_o with 'Y' , errs_msg_o with errs_msg_o + lcErrs_Msg ;
2348 FOR EMPTY(ShpDate) IN (pceiSPTO)
2349
2350 *--- TR 1078769 21-Jun-2014 Goutam.
2351 ENDIF
2352 *=== TR 1078769 21-Jun-2014 Goutam.
2353
2354 *--- TR 1076260 18-Mar-2014 Goutam
2355 IF pcASNType = 'NO'
2356 *--- TR 1078769 17-Jun-2014 Goutam. Changed from book to booking
2357 .oLog.LogEntry("Validating Booking Date.")
2358 lcErrs_Msg = "Empty Booking Date." + CRLF
2359 replace errs_flg_o with 'Y' , errs_msg_o with errs_msg_o + lcErrs_Msg ;
2360 FOR EMPTY(book_date) IN (pceiSPTO)
2361 ENDIF
2362 IF pcASNType = 'TH'
2363 .oLog.LogEntry("Validating Delivery Date.")
2364 lcErrs_Msg = "Empty Delivery Date." + CRLF
2365 replace errs_flg_o with 'Y' , errs_msg_o with errs_msg_o + lcErrs_Msg ;
2366 FOR EMPTY(delv_date) IN (pceiSPTO)
2367 ENDIF
2368 *=== TR 1076260 18-Mar-2014 Goutam
2369
2370 ENDIF
2371 ENDIF
2372 ENDIF
2373
2374 USE IN __TmpTOCursor
2375 .tableclose('_tmpValidationCursor')
2376 .tableclose('_tmpValidWhsCursor') &&--- TechRec 1067730 27-May-2013 vkrishnamurthy ===
2377 ENDWITH
2378
2379 SELECT(lnOldSelect)
2380 RETURN llValidOrder
2381 ENDPROC
2382
2383*============================================================
2384
2385 PROCEDURE UpdateError
2386 LPARAMETERS pcErrorType, pcErrorTable, pcErrs_Msg
2387 DO CASE
2388 CASE pcErrorType = 'H'
2389 replace errs_flg_h WITH 'Y', ;
2390 errs_msg_h WITH pcErrs_Msg ;
2391 IN (pcErrorTable)
2392 CASE pcErrorType = 'C'
2393 replace errs_flg_cntr WITH 'Y', ;
2394 errs_msg_cntr WITH pcErrs_Msg ;
2395 IN (pcErrorTable)
2396 CASE pcErrorType = 'O'
2397 replace errs_flg_o WITH 'Y', ;
2398 errs_msg_o WITH pcErrs_Msg ;
2399 IN (pcErrorTable)
2400 CASE pcErrorType = 'N'
2401 replace errs_flg_ctn WITH 'Y', ;
2402 errs_msg_ctn WITH pcErrs_Msg ;
2403 IN (pcErrorTable)
2404 CASE pcErrorType = 'D'
2405 replace errs_flg_d WITH 'Y', ;
2406 errs_msg_d WITH pcErrs_Msg ;
2407 IN (pcErrorTable)
2408 ENDCASE
2409 ENDPROC
2410
2411*============================================================
2412
2413 PROCEDURE CheckDetail
2414 LPARAMETERS pceiSPTH, pceiSPTO, pceiSPTD, pcASNType
2415 *--- TR 1076260 18-Mar-2014 Goutam. Added above parameter pcASNType
2416
2417 LOCAL llRetVal, lnOldSelect
2418
2419 llRetVal = true
2420 lnOldSelect = SELECT()
2421
2422 WITH THIS
2423
2424 * need to add the following validations prior to qa
2425 * 1- Details on the cartons must match what is on the PO at the size level otherwise fail. cannot receive goods in buckets that have no previous qty
2426 * 2- PO Line must be at the stage prior to "INTRANSIT" or shp_ok = 'Y' in zzctyped.
2427
2428 .oLog.LogEntry("Resolving Current Production Line.")
2429 *--- TR 1082847 16-2-2015 VKK addedpceiSPTH
2430 llRetVal= llRetVal AND .ResolveCurrentProdLine(pceiSPTD, pceiSPTH)
2431
2432 IF .lImplodeByPOLine
2433 * Ivory Implode by PO Dtl.
2434 .oLog.LogEntry("Imploding PO by Prod Line.")
2435 llRetVal= llRetVal AND .ImplodeCartonDetailByProdLine(pceiSPTD)
2436 ENDIF
2437
2438 .oLog.LogEntry("Resolving style using UPC.")
2439 llRetVal= llRetVal AND .CheckUpc(pceiSPTH, pceiSPTD)
2440
2441 .oLog.LogEntry("Resolving style using SKU.")
2442 llRetVal= llRetVal AND .CheckBCSku(pceiSPTH, pceiSPTO, pceiSPTD)
2443
2444 .oLog.LogEntry("Validate SKU against PO")
2445 llRetVal= llRetVal and .ValidateProductionSku(pceiSPTH, pceiSPTO, pceiSPTD)
2446
2447 *------- Open Seq
2448 .oLog.LogEntry("Validating Line Sequence.")
2449 lcErrs_Msg = "Empty/Invalid Line Sequence." + CRLF
2450 replace errs_flg_d with 'Y' , errs_msg_d with errs_msg_d + lcErrs_Msg ;
2451 FOR EMPTY(Open_Seq) IN (pceiSPTD)
2452
2453 *--- TR 1076260 18-Mar-2014 Goutam.
2454 IF INLIST(pcASNType, 'NO', 'TH')
2455 .oLog.LogEntry("Validating UPC, Carton, total_cubic, total_weight.")
2456
2457 lcErrs_Msg = "Empty UPC." + CRLF
2458 replace errs_flg_d with 'Y' , errs_msg_d with errs_msg_d + lcErrs_Msg ;
2459 FOR EMPTY(UPC) IN (pceiSPTD)
2460
2461 lcErrs_Msg = "Empty Carton." + CRLF
2462 replace errs_flg_d with 'Y' , errs_msg_d with errs_msg_d + lcErrs_Msg ;
2463 FOR EMPTY(carton) IN (pceiSPTD)
2464
2465 lcErrs_Msg = "Empty Total Cubic." + CRLF
2466 replace errs_flg_d with 'Y' , errs_msg_d with errs_msg_d + lcErrs_Msg ;
2467 FOR EMPTY(total_cubic) IN (pceiSPTD)
2468
2469 lcErrs_Msg = "Empty Total Weight." + CRLF
2470 replace errs_flg_d with 'Y' , errs_msg_d with errs_msg_d + lcErrs_Msg ;
2471 FOR EMPTY(total_weight) IN (pceiSPTD)
2472
2473 .oLog.LogEntry("Validating replacement ASN")
2474 llRetVal= llRetVal and .ValidateReplacementASN(pceiSPTH, pceiSPTD, pcASNType)
2475
2476 ENDIF
2477 *=== TR 1076260 18-Mar-2014 Goutam.
2478
2479 *--- TR 1076885 KISHORE 14-APR-2014
2480 .oLog.LogEntry("Validating Dye Lot.")
2481 llRetVal= llRetVal AND .ValidateLot(pceiSPTH, pceiSPTD)
2482 *=== TR 1076885 KISHORE 14-APR-2014
2483
2484 *--- TR 1081057/1080996 9-Sep-2014 Goutam.
2485 IF EMPTY(pcASNType)
2486 .oLog.LogEntry("Validating line for GIT process...")
2487 llRetVal= llRetVal AND .ValidateGITLine(pceiSPTH, pceiSPTD)
2488 ENDIF
2489 *=== TR 1081057/1080996 9-Sep-2014 Goutam.
2490
2491 ENDWITH
2492
2493 SELECT(lnOldSelect)
2494 RETURN llRetVal
2495 ENDPROC
2496
2497*============================================================
2498
2499 PROCEDURE CheckCarton
2500 LPARAMETERS pceiSPTN
2501
2502 LOCAL llRetVal, lnOldSelect, lcSql
2503
2504 llRetVal = true
2505 lnOldSelect = SELECT()
2506
2507 *--- TR 1082847 31-1-2015 VKK added ord_num
2508 SELECT pkey, carton_num, ord_num FROM (pceiSPTN) ;
2509 WHERE Fkey In (SELECT Pkey FROM (pceiSPTH) Where GIT_Ind = 0 AND NOT INLIST(asn_type,'X2','X3')) ; && *--- TR 1082847 31-1-2015 VKK
2510 INTO CURSOR _tmpCarton
2511
2512 WITH THIS
2513 .cSQLTempTable=""
2514 .oLog.LogEntry("Validating Carton.")
2515 IF RECCOUNT('_tmpCarton') > 0 AND .GenerateSQLTempTable('_tmpCarton')
2516 IF .PopulateSQLTempTable('_tmpCarton')
2517 IF !EMPTY(.cSQLTempTable)
2518
2519 lcErrs_Msg = "Carton already exists." + CRLF
2520
2521 lcSql = "select n.pkey from " + .cSQLTempTable + " n join zzoctnph h on h.carton_num = n.carton_num"
2522
2523 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
2524
2525 SELECT _tmpValidationCursor
2526 INDEX on PKey TAG Pkey
2527
2528 SELECT (pceiSPTN)
2529 replace errs_flg_ctn with 'Y', errs_msg_ctn with errs_msg_ctn + lcErrs_Msg ;
2530 FOR INDEXSEEK(Pkey,.F., "_tmpValidationCursor" )
2531
2532 ENDIF
2533 ENDIF
2534 ENDIF
2535 .cSQLTempTable = ""
2536 .tableclose('_tmpValidationCursor')
2537 USE IN '_tmpCarton'
2538
2539 *--- TR 1078769 28-Jul-2014 Goutam. Duplicate check not valid on empty carton.
2540 *SELECT carton_num FROM (pceiSPTN) INTO CURSOR _tmpDupes GROUP BY carton_num HAVING COUNT(*) > 1
2541 SELECT carton_num FROM (pceiSPTN) INTO CURSOR _tmpDupes WHERE carton_num > '' GROUP BY carton_num HAVING COUNT(*) > 1
2542 *--- TR 1078769 28-Jul-2014 Goutam.
2543
2544 UPDATE c SET errs_flg_ctn = 'Y', errs_msg_ctn = errs_msg_ctn + "Duplicate Carton in 856(i) Transaction Maintenance." + CRLF;
2545 FROM (pceiSPTN) c ;
2546 JOIN _tmpDupes d ON c.carton_num = d.carton_num
2547 USE IN SELECT("_tmpDupes")
2548
2549
2550
2551 ENDWITH
2552
2553 SELECT(lnOldSelect)
2554 RETURN llRetVal
2555 ENDPROC
2556
2557*============================================================
2558
2559 PROCEDURE CheckBCSku
2560 LPARAMETERS pceiSPTH, pceiSPTO, pceiSPTD
2561
2562 LOCAL llRetVal, lnOldSelect, lcErrs_Msg, l_nThermoCnt, lnSizeBucket
2563
2564 *--- TR 1082596 11-Nov-2014 Goutam
2565 LOCAL lcSizeString1, lcSizeString2, l_cBucketNum
2566 lcSizeString1 = ""
2567 lcSizeString2 = ""
2568 *=== TR 1082596 11-Nov-2014 Goutam
2569
2570 llRetVal = .T.
2571 lcErrs_Msg= ""
2572 lnOldSelect = SELECT()
2573
2574 SELECT o.division, d.Style, d.color_code, d.lbl_code, d.Dimension, d.size_desc, d.pkey ;
2575 FROM (pceiSPTH) h JOIN (pceiSPTD) d ;
2576 ON h.pkey = d.fkey ;
2577 join (pceiSPTO) o ;
2578 on o.pkey = d.okey ;
2579 and o.fkey = h.pkey ;
2580 WHERE EMPTY(d.upc) ;
2581 ORDER BY o.division, d.Style, d.color_code, d.lbl_code, d.Dimension ;
2582 INTO CURSOR tmpCurs
2583
2584 .cSQLTempTable=""
2585
2586 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
2587 *llRetVal = .GenerateSQLTempTable('tmpCurs') and .PopulateSQLTempTable('tmpCurs') and !EMPTY(.cSQLTempTable)
2588 IF .GenerateSQLTempTable('tmpCurs') and .PopulateSQLTempTable('tmpCurs') and !EMPTY(.cSQLTempTable)
2589 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
2590
2591
2592 IF THIS.lUserInterface
2593 THIS.UpdateThermoCaption("Validating BC SKU(s)...")
2594 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
2595 l_nThermoCnt = 0
2596 ENDIF
2597
2598 *--- TR 1082596 11-Nov-2014 Goutam
2599 FOR lnTotalSizes = 1 TO goEnv.MaxBuckets - 1
2600 l_cBucketNum = TRANSFORM(lnTotalSizes, "@L 99")
2601 lcSizeString1 = lcSizeString1 + " WHEN " + l_cBucketNum + " THEN savl.call" + l_cBucketNum
2602 lcSizeString2 = lcSizeString2 + " WHEN " + l_cBucketNum + " THEN size.size" + l_cBucketNum
2603 NEXT
2604 lcSizeString1 = lcSizeString1 + " else savl.call" + TRANSFORM(goEnv.MaxBuckets, "@L 99") + " end = 'Y' "
2605 lcSizeString2 = lcSizeString2 + " else size.size" + TRANSFORM(goEnv.MaxBuckets, "@L 99") + " end = temp.size_desc "
2606 *=== TR 1082596 11-Nov-2014 Goutam
2607
2608 *--- TR 1082596 11-Nov-2014 Goutam.
2609*!* lcSql = "SELECT temp.pkey, buck.size_num " + ;
2610*!* " FROM " + .cSQLTempTable + " temp " + ;
2611*!* " JOIN zzxbuckt buck " + ;
2612*!* " ON (1=1) " + ;
2613*!* " JOIN zzxstylr styl " + ;
2614*!* " ON (styl.division = temp.division " + ;
2615*!* " AND styl.style = temp.style) " + ;
2616*!* " JOIN zzxsizer size " + ;
2617*!* " ON (size.division = temp.division " + ;
2618*!* " AND size.size_code = styl.size_code) " + ;
2619*!* " JOIN zzxscolr savl " + ;
2620*!* " ON (savl.division = temp.division " + ;
2621*!* " AND savl.style = temp.style " + ;
2622*!* " AND savl.color_code = temp.color_code " + ;
2623*!* " AND savl.lbl_code = temp.lbl_code " + ;
2624*!* " AND savl.dimension = temp.dimension " + ;
2625*!* " AND CASE buck.size_num " + ;
2626*!* " WHEN 01 THEN savl.call01 WHEN 02 THEN savl.call02 " + ;
2627*!* " WHEN 03 THEN savl.call03 WHEN 04 THEN savl.call04 " + ;
2628*!* " WHEN 05 THEN savl.call05 WHEN 06 THEN savl.call06 " + ;
2629*!* " WHEN 07 THEN savl.call07 WHEN 08 THEN savl.call08 " + ;
2630*!* " WHEN 09 THEN savl.call09 WHEN 10 THEN savl.call10 " + ;
2631*!* " WHEN 11 THEN savl.call11 WHEN 12 THEN savl.call12 " + ;
2632*!* " WHEN 13 THEN savl.call13 WHEN 14 THEN savl.call14 " + ;
2633*!* " WHEN 15 THEN savl.call15 WHEN 16 THEN savl.call16 " + ;
2634*!* " WHEN 17 THEN savl.call17 WHEN 18 THEN savl.call18 " + ;
2635*!* " WHEN 19 THEN savl.call19 WHEN 20 THEN savl.call20 " + ;
2636*!* " WHEN 21 THEN savl.call21 WHEN 22 THEN savl.call22 " + ;
2637*!* " WHEN 23 THEN savl.call23 else savl.call24 end = 'Y' " + ;
2638*!* " AND CASE buck.size_Num " + ;
2639*!* " WHEN 01 then size.size01 when 02 THEN size.size02 " + ;
2640*!* " WHEN 03 then size.size03 when 04 THEN size.size04 " + ;
2641*!* " WHEN 05 then size.size05 when 06 THEN size.size06 " + ;
2642*!* " WHEN 07 then size.size07 when 08 THEN size.size08 " + ;
2643*!* " WHEN 09 then size.size09 when 10 THEN size.size10 " + ;
2644*!* " WHEN 11 then size.size11 when 12 THEN size.size12 " + ;
2645*!* " WHEN 15 then size.size15 when 16 THEN size.size16 " + ;
2646*!* " WHEN 17 then size.size17 when 18 THEN size.size18 " + ;
2647*!* " WHEN 19 then size.size19 when 20 THEN size.size20 " + ;
2648*!* " WHEN 21 then size.size21 when 22 THEN size.size22 " + ;
2649*!* " WHEN 23 then size.size23 else size.size24 end = temp.size_desc) " + ;
2650*!* " AND temp.size_desc <> '' "
2651
2652
2653 lcSql = "SELECT temp.pkey, buck.size_num " + ;
2654 " FROM " + .cSQLTempTable + " temp " + ;
2655 " JOIN zzxbuckt buck " + ;
2656 " ON (1=1) " + ;
2657 " JOIN zzxstylr styl " + ;
2658 " ON (styl.division = temp.division " + ;
2659 " AND styl.style = temp.style) " + ;
2660 " JOIN zzxsizer size " + ;
2661 " ON (size.division = temp.division " + ;
2662 " AND size.size_code = styl.size_code) " + ;
2663 " JOIN zzxscolr savl " + ;
2664 " ON (savl.division = temp.division " + ;
2665 " AND savl.style = temp.style " + ;
2666 " AND savl.color_code = temp.color_code " + ;
2667 " AND savl.lbl_code = temp.lbl_code " + ;
2668 " AND savl.dimension = temp.dimension " + ;
2669 " AND CASE buck.size_num " + ;
2670 lcSizeString1 + ;
2671 " AND CASE buck.size_Num " + ;
2672 lcSizeString2 + ")" + ;
2673 " AND temp.size_desc <> '' "
2674 *=== TR 1082596 11-Nov-2014 Goutam.
2675
2676 llRetVal = v_SqlExec(lcSql, "__tmpSizeBucket")
2677
2678 *--- TR 1078769 25-Jul-2014 Goutam
2679 IF llRetVal
2680 *=== TR 1078769 25-Jul-2014 Goutam
2681
2682 SELECT '__tmpSizeBucket'
2683 INDEX on pkey TAG pkey
2684
2685 llRetVal= llRetVal and .SetRelation("__tmpSizeBucket", "pkey", pceiSPTD, "pkey")
2686
2687 SELECT (pceiSPTD)
2688 Replace All SizeBucket WITH __tmpSizeBucket.size_num FOR INDEXSEEK(Pkey,.F., "__tmpSizeBucket")
2689
2690 lcErrs_Msg = "Invalid BC SKU." + CRLF
2691 replace errs_flg_d with 'Y', errs_msg_d with errs_msg_d + lcErrs_Msg ;
2692 FOR EMPTY(upc) AND NOT INDEXSEEK(Pkey,.F., "__tmpSizeBucket")
2693
2694 SET RELATION TO
2695
2696 lcErrs_Msg = ""
2697 USE IN tmpCurs
2698
2699 .Tableclose("__tmpSizeBucket")
2700
2701 *--- TR 1078769 25-Jul-2014 Goutam
2702 ENDIF
2703 *=== TR 1078769 25-Jul-2014 Goutam
2704
2705 IF THIS.lUserInterface
2706 THIS.ResetThermo()
2707 ENDIF
2708 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
2709 ENDIF
2710 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
2711
2712 IF USED("tmpSizeBucket")
2713 USE IN tmpSizeBucket
2714 ENDIF
2715
2716 SELECT(lnOldSelect)
2717 RETURN llRetVal
2718 ENDPROC
2719
2720*============================================================
2721
2722 PROCEDURE CheckUpc
2723 LPARAMETERS pceiSPTH, pceiSPTD
2724
2725 *--- TR 1060099 14-Mar-2012 BNarayanan Code revamped
2726
2727 LOCAL llRetVal, lnOldSelect, loEiSPth, loEiSPtd, lcMssg, lcOldCust, lcOldItem, ;
2728 lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
2729 lnSize_desc
2730
2731 llRetVal = .T.
2732 lcErrs_Msg= ""
2733 lnOldSelect = SELECT()
2734
2735 SELECT d.prod_num, d.open_seq as prod_line, d.upc, d.pkey ;
2736 FROM (pceiSPTH) h join (pceiSPTD) d ;
2737 ON h.pkey = d.fkey ;
2738 WHERE NOT EMPTY(d.upc) ;
2739 AND (EMPTY(d.STYLE) OR EMPTY(d.color_code) OR d.sizebucket = 0 OR EMPTY(d.size_desc) ) ;
2740 ORDER BY h.doc_num, d.upc ;
2741 INTO CURSOR tmpCurs
2742
2743 IF .GenerateSQLTempTable('tmpCurs')
2744 IF .PopulateSQLTempTable('tmpCurs')
2745 IF !EMPTY(.cSQLTempTable)
2746
2747 lcSQLString = "SELECT t.pkey,u.Sizebucket,u.size_desc,u.division, u.style, u.color_code, u.lbl_code, u.dimension, t.upc " + ;
2748 " FROM " + This.cSQLTempTable + " t " + ;
2749 " JOIN zzcordrd d " + ;
2750 " ON d.prod_num=t.prod_num " + ;
2751 " AND d.prod_line= t.prod_line" + ;
2752 " JOIN zveupcnr u " + ;
2753 " ON u.upc = t.upc " + ;
2754 " AND u.lbl_code = d.lbl_code "
2755
2756 v_SQLExec(lcSQLString, "tmpcurs")
2757
2758
2759 SELECT tmpCurs
2760 IF THIS.lUserInterface
2761 THIS.UpdateThermoCaption("Validating UPC(s)...")
2762 THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
2763 l_nThermoCnt = 0
2764 ENDIF
2765
2766 UPDATE d SET ;
2767 Style = t.STYLE, ;
2768 Color_code = t.color_code, ;
2769 Lbl_code = t.lbl_code, ;
2770 Dimension = t.DIMENSION, ;
2771 SizeBucket = t.Sizebucket, ;
2772 Size_desc = t.size_desc ;
2773 FROM (pceiSPTD) d JOIN tmpcurs t ;
2774 on d.pkey = t.pkey
2775
2776 *--- TR 1061865 01-June-2012 BNarayanan avoid updating of error message to already resolved SKU
2777 *UPDATE d SET ;
2778 d.Errs_Msg_D = ALLTRIM(d.Errs_Msg_D) + "Invalid UPC." + CRLF, ;
2779 d.errs_flg_D = "Y" ;
2780 FROM (pceiSPTD) d ;
2781 WHERE NOT EXISTS(SELECT * FROM tmpcurs T WHERE t.pkey = d.pkey)
2782
2783 UPDATE d SET ;
2784 d.Errs_Msg_D = ALLTRIM(d.Errs_Msg_D) + "Invalid UPC." + CRLF, ;
2785 d.errs_flg_D = "Y" ;
2786 FROM (pceiSPTD) d ;
2787 WHERE EMPTY(d.STYLE) OR EMPTY(d.color_code) OR d.sizebucket = 0 OR EMPTY(d.size_desc)
2788 *=== TR 1061865 01-June-2012 BNarayanan
2789
2790 USE IN tmpCurs
2791
2792 IF THIS.lUserInterface
2793 THIS.ResetThermo()
2794 ENDIF
2795
2796 ENDIF
2797 ENDIF
2798 ENDIF
2799
2800 SELECT(lnOldSelect)
2801 RETURN llRetVal
2802 ENDPROC
2803
2804*============================================================
2805 PROCEDURE MarkHeaderForDetailWithError
2806 LPARAMETERS pceiSPTH, pceiSPTC, pceiSPTO, pceiSPTN, pceiSPTD
2807
2808 LOCAL llRetVal, lnOldSelect
2809
2810 llRetVal = .T.
2811 lnOldSelect = SELECT()
2812
2813
2814 UPDATE n ;
2815 SET errs_flg_ctn = 'Y', ;
2816 errs_msg_ctn = 'Has errors in details' ;
2817 FROM (pceiSPTN) n ;
2818 JOIN (pceiSPTD) d ON n.pkey = d.ctnkey ;
2819 WHERE errs_flg_d = 'Y' AND errs_flg_ctn <> 'Y'
2820
2821
2822 UPDATE o ;
2823 SET errs_flg_o = 'Y', ;
2824 errs_msg_o = 'Has errors in cartons' ;
2825 FROM (pceiSPTO) o ;
2826 JOIN (pceiSPTN) n ON o.pkey = n.okey ;
2827 WHERE errs_flg_ctn = 'Y' AND errs_flg_o <> 'Y'
2828
2829
2830 UPDATE c ;
2831 SET errs_flg_cntr = 'Y', ;
2832 errs_msg_cntr = 'Has errors in orders' ;
2833 FROM (pceiSPTC) c ;
2834 JOIN (pceiSPTO) o ON c.pkey = o.ckey ;
2835 WHERE errs_flg_cntr <> 'Y' AND errs_flg_o = 'Y'
2836
2837
2838 SELECT (pceiSPTH)
2839 UPDATE h SET errs_flg_h = 'Y' ;
2840 ,errs_msg_h = 'Has errors in containers' ;
2841 FROM (pceiSPTH) h ;
2842 JOIN (pceiSPTC) c ON h.pkey = c.fkey ;
2843 WHERE errs_flg_h <> 'Y' AND errs_flg_cntr = 'Y'
2844
2845 UPDATE h SET errs_flg_h = 'Y' ;
2846 ,errs_msg_h = 'Has errors in Orders' ;
2847 FROM (pceiSPTH) h ;
2848 JOIN (pceiSPTO) c ON h.pkey = c.fkey ;
2849 WHERE errs_flg_h <> 'Y' AND errs_flg_o = 'Y'
2850
2851
2852
2853 replace errs_flg_h WITH 'Y', ;
2854 errs_msg_h WITH 'Auto Process flag is set to N' ;
2855 FOR Auto_Proc <> 'Y' AND errs_flg_h <> 'Y' ;
2856 IN (pceiSPTH)
2857
2858 *--- TR 1077026 10-Mar-2014 Partha ---
2859 UPDATE n ;
2860 SET warn_flg_ctn = 'Y', ;
2861 warn_msg_ctn = 'Has warnings in details' ;
2862 FROM (pceiSPTN) n ;
2863 JOIN (pceiSPTD) d ON n.pkey = d.ctnkey ;
2864 WHERE warn_flg_d = 'Y' AND warn_flg_ctn <> 'Y'
2865
2866 UPDATE o ;
2867 SET warn_flg_o = 'Y', ;
2868 warn_msg_o = 'Has warnings in cartons' ;
2869 FROM (pceiSPTO) o ;
2870 JOIN (pceiSPTN) n ON o.pkey = n.okey ;
2871 WHERE warn_flg_ctn = 'Y' AND warn_flg_o <> 'Y'
2872
2873 UPDATE c ;
2874 SET warn_flg_cntr = 'Y', ;
2875 warn_msg_cntr = 'Has warnings in orders' ;
2876 FROM (pceiSPTC) c ;
2877 JOIN (pceiSPTO) o ON c.pkey = o.ckey ;
2878 WHERE warn_flg_cntr <> 'Y' AND warn_flg_o = 'Y'
2879
2880 *=== TR 1077026 10-Mar-2014 Partha ===
2881
2882 *--- TechRec 1067730 15-Jul-2013 vkrishnamurthy ---
2883 && Reset Header Warnings
2884 UPDATE h SET warn_flg_h = 'N' ;
2885 ,warn_msg_h = '' ;
2886 FROM (pceiSPTH) h
2887
2888 UPDATE h SET warn_flg_h = 'Y' ;
2889 ,warn_msg_h = 'Has Warnings in Details.' + CRLF ;
2890 FROM (pceiSPTH) h ;
2891 JOIN (pceiSPTD) c ON h.pkey = c.fkey ;
2892 WHERE warn_flg_d ='Y' AND ignore_warn <> 'Y'
2893 *=== TechRec 1067730 15-Jul-2013 vkrishnamurthy ===
2894
2895 *--- TR 1077026 10-Mar-2014 Partha ---
2896 UPDATE h SET warn_flg_h = 'Y' ;
2897 ,warn_msg_h = 'Has warning in containers' ;
2898 FROM (pceiSPTH) h ;
2899 JOIN (pceiSPTC) c ON h.pkey = c.fkey ;
2900 WHERE warn_flg_h <> 'Y' AND warn_flg_cntr = 'Y' AND ignore_warn <> 'Y'
2901
2902 UPDATE h SET warn_flg_h = 'Y' ;
2903 ,warn_msg_h = 'Has warning in Orders' ;
2904 FROM (pceiSPTH) h ;
2905 JOIN (pceiSPTO) c ON h.pkey = c.fkey ;
2906 WHERE warn_flg_h <> 'Y' AND warn_flg_o = 'Y' AND ignore_warn <> 'Y'
2907
2908 *=== TR 1077026 10-Mar-2014 Partha ===
2909
2910 SELECT(lnOldSelect)
2911 RETURN llRetVal
2912 ENDPROC
2913
2914*============================================================
2915 PROCEDURE UpdtContrUsgNShpmNum
2916 LPARAMETERS pceiSPTC, pceiSPTH, pceiSPCR && 1037787 Goutam
2917
2918 LOCAL llRetVal, lnOldSelect, lcSQL, lcCntrCurs
2919 LOCAL lnUsg && TR 1076599 13-Aug-2014 Partha
2920
2921 llRetVal = .T.
2922 lnOldSelect = SELECT()
2923
2924 IF RECCOUNT(pceiSPTC) > 0
2925
2926 *--- TR 1076599 13-Aug-2014 Partha ---
2927*!* lcSQL = " SELECT DISTINCT cntr_num FROM " + pceiSPTC
2928*!* lcCntrCurs = GetUniqueFileName()
2929*!* llRetVal = llRetVal AND v_sqlexec(lcSQL, lcCntrCurs,,true)
2930
2931 lcCntrCurs = GetUniqueFileName()
2932 SELECT DISTINCT cntr_num, shpm_ref, 0 as cntr_usg FROM (pceiSPTC) ORDER BY cntr_num INTO CURSOR (lcCntrCurs ) READWRITE
2933
2934 lnUsg = 0
2935 SELECT (lcCntrCurs)
2936 GO TOP
2937 lcCntr = ALLTRIM(cntr_num)
2938 SCAN
2939 IF lcCntr = ALLTRIM(cntr_num)
2940 lnUsg = lnUsg + 1
2941 ELSE
2942 lnUsg = 1
2943 ENDIF
2944 REPLACE cntr_usg WITH lnUsg
2945 lcCntr = ALLTRIM(cntr_num)
2946 ENDSCAN
2947 *=== TR 1076599 13-Aug-2014 Partha ===
2948
2949 llRetVal = llRetVal AND .GenerateSQLTempTable(lcCntrCurs) and .PopulateSQLTempTable(lcCntrCurs) and !EMPTY(.cSQLTempTable)
2950
2951 IF llRetVal
2952 *--- TR 1076599 18-Mar-2014 Partha ---
2953*!* lcSQL = " SELECT t.cntr_num, CASE WHEN MAX(c.cntr_usg) is null then 1 " + ;
2954*!* " ELSE MAX(c.cntr_usg) + 1 end as cntr_usg " + ;
2955*!* " FROM " + .cSQLTempTable + " t left join zzmcntnr c " + ;
2956*!* " on c.cntr_num = t.cntr_num " + ;
2957*!* " Group By t.cntr_num"
2958
2959 lcSQL = " SELECT t.cntr_num, t.shpm_ref, t.cntr_usg + ( CASE WHEN MAX(c.cntr_usg) is null then 0 " + ;
2960 " ELSE MAX(c.cntr_usg) END ) AS cntr_usg " + ;
2961 " FROM " + .cSQLTempTable + " t " + ;
2962 " LEFT JOIN zzmcntnr c " + ;
2963 " ON c.cntr_num = t.cntr_num " + ;
2964 " GROUP By t.cntr_num, t.shpm_ref, t.cntr_usg "
2965 *=== TR 1076599 18-Mar-2014 Partha ===
2966
2967 llRetVal = v_sqlExec(lcSQL, 'tcCntr_Usg')
2968 ENDIF
2969
2970 IF llRetVal
2971 *--- TR 1076599 18-Mar-2014 Partha ---
2972*!* lcSql = "UPDATE c SET c.cntr_usg = t.cntr_usg " + ;
2973*!* "From " + pceiSPTC + " c join tcCntr_Usg t on c.cntr_num = t.cntr_num"
2974
2975 lcSql = "UPDATE c " + ;
2976 " SET c.cntr_usg = t.cntr_usg " + ;
2977 " FROM " + pceiSPTC + " c " + ;
2978 " JOIN tcCntr_Usg t " + ;
2979 " ON c.cntr_num = t.cntr_num " + ;
2980 " AND c.shpm_ref=t.shpm_ref "
2981 *=== TR 1076599 18-Mar-2014 Partha ===
2982 llRetVal = v_sqlexec(lcSql,,,true)
2983 ENDIF
2984
2985 .tableclose(lcCntrCurs)
2986 .tableclose('tcCntr_Usg')
2987 ENDIF
2988
2989 *--- TR 1037787 8-Apr-2009 Goutam
2990 IF llRetVal
2991 *--- TechRec 1067730 15-Jul-2013 vkrishnamurthy ---
2992*!* lcSql = "UPDATE h SET h.shipment_num = VAL(h.shpm_ref) " + ;
2993*!* " FROM " + pceiSPTH + " h " + ;
2994*!* " JOIN " + pceiSPCR + " c " + ;
2995*!* " ON c.pkey = h.Control_Key " + ;
2996*!* "WHERE h.Auto_Proc = 'Y' AND h.Errs_Flg_H <> 'Y' AND c.Asg_shipment <> 'Y'"
2997
2998 lcSql = "UPDATE h SET h.shipment_num = VAL(h.shpm_ref) " + ;
2999 " FROM " + pceiSPTH + " h " + ;
3000 " JOIN " + pceiSPCR + " c " + ;
3001 " ON c.pkey = h.Control_Key " + ;
3002 "WHERE h.Auto_Proc = 'Y' AND h.Errs_Flg_H <> 'Y' AND c.Asg_shipment <> 'Y'" + ;
3003 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
3004 *=== TechRec 1067730 15-Jul-2013 vkrishnamurthy ===
3005 llRetVal = llRetVal and v_sqlexec(lcSql,,,true)
3006
3007 ENDIF
3008 *=== TR 1037787 8-Apr-2009 Goutam
3009
3010 SELECT(lnOldSelect)
3011 RETURN llRetVal
3012 ENDPROC
3013
3014*============================================================
3015 PROCEDURE UpdtCartonQty
3016 LPARAMETERS pceiSPTH, pceiSPTC, pceiSPTO, pceiSPTN, pceiSPTD
3017
3018 LOCAL llRetVal, lnOldSelect
3019
3020 llRetVal = .T.
3021 lnOldSelect = SELECT()
3022
3023 select ckey ;
3024 , Count(ckey) as Carton_qty ;
3025 from (pceiSPTN) ;
3026 group by ckey ;
3027 into CURSOR __tmpISPTN
3028
3029* having errs_flg_ctn <> 'Y' ;
3030
3031 SELECT '__tmpISPTN'
3032 INDEX on ckey tag ckey
3033
3034 llRetVal= llRetVal and .SetRelation("__tmpISPTN", "ckey", pceiSPTC, "pkey")
3035
3036 SELECT (pceiSPTC)
3037 Replace All Carton WITH __tmpISPTN.Carton_qty
3038 SET RELATION TO
3039
3040 select ckey ;
3041 , Count(ckey) as Order_qty ;
3042 from (pceiSPTO) ;
3043 group by ckey ;
3044 into CURSOR __tmpISPTO
3045
3046* having errs_flg_o <> 'Y' ;
3047
3048 SELECT '__tmpISPTO'
3049 INDEX on ckey tag ckey
3050
3051 llRetVal= llRetVal and .SetRelation("__tmpISPTO", "ckey", pceiSPTC, "pkey")
3052
3053 SELECT (pceiSPTC)
3054 Replace All Orders WITH __tmpISPTO.Order_qty
3055 SET RELATION TO
3056
3057 select okey ;
3058 , Count(okey) as Carton_qty ;
3059 from (pceiSPTN) ;
3060 group by okey ;
3061 into CURSOR __tmpISPTN
3062
3063* having errs_flg_ctn <> 'Y' ;
3064
3065 SELECT '__tmpISPTN'
3066 INDEX on okey tag okey
3067
3068 llRetVal= llRetVal and .SetRelation("__tmpISPTN", "okey", pceiSPTO, "pkey")
3069
3070 SELECT (pceiSPTO)
3071 Replace All Carton WITH __tmpISPTN.Carton_qty
3072 SET RELATION TO
3073
3074 select ctnkey ;
3075 , SUM(Qty) as Carton_qty ;
3076 from (pceiSPTD) ;
3077 group by ctnkey ;
3078 into CURSOR __tmpISPTD
3079
3080* having errs_flg_d <> 'Y' ;
3081
3082 SELECT '__tmpISPTD'
3083 INDEX on ctnkey tag ctnkey
3084
3085 llRetVal= llRetVal and .SetRelation("__tmpISPTD", "ctnkey", pceiSPTN, "pkey")
3086
3087 SELECT (pceiSPTN)
3088 Replace All Qty WITH __tmpISPTD.Carton_qty
3089 SET RELATION TO
3090
3091 USE IN __tmpISPTN
3092 USE IN __tmpISPTO
3093 USE IN __tmpISPTD
3094
3095 SELECT(lnOldSelect)
3096 RETURN llRetVal
3097 ENDPROC
3098
3099*============================================================
3100 PROCEDURE CloseiSPViews
3101 LOCAL llRetVal
3102
3103 llRetVal = .T.
3104
3105 IF llRetVal
3106 LOCAL laTables[7] && TR 1050836 27-Jul-2011 Partha changed array length to 6 --- *--- TR 1076260 18-Mar-2014 Goutam array Changed from 6 to 7
3107 laTables[1] = "VzzeiSPth_iSPproc"
3108 laTables[2] = "VzzeiSPtc_iSPproc"
3109 laTables[3] = "VzzeiSPto_iSPproc"
3110 laTables[4] = "VzzeiSPtn_iSPproc"
3111 laTables[5] = "VzzeiSPtd_iSPproc"
3112 laTables[6] = "VzzeiSPth_notes_iSPproc" && TR 1050836 27-Jul-2011 Partha
3113 laTables[7] = "VzzeiSPto_notes_iSPproc" && *--- TR 1076260 18-Mar-2014 Goutam
3114
3115 THIS.oLog.LogEntry("Close all transaction views.")
3116
3117 llRetVal = THIS.TableClose(@laTables, true)
3118
3119 IF NOT llRetVal
3120 THIS.oLog.LogWarning("Failed to close all transaction views.")
3121 ENDIF
3122 ENDIF
3123 ENDPROC
3124
3125*============================================================
3126
3127 PROCEDURE TableUpdateTransaction
3128 *--- TR 1050836 27-Jul-2011 Partha added pceispTH_notes in param list
3129 *--- TR 1076260 18-Mar-2014 Goutam added pceispTO_notes in param list
3130 LPARAMETERS pceispTH, pceispTC, pceispTO, pceispTN, pceispTD,pceispTH_notes, pceispTO_notes
3131
3132 *--- TR 1050836 27-Jul-2011 Partha increased laTables length to 6 ---
3133 *--- TR 1076260 18-Mar-2014 Goutam increased laTables length to 7 ---
3134 LOCAL llRetVal, lcSQLDelete, lcTempTable, laTables[7], llBeganTransaction, ;
3135 lceispTH_temp, lceispTD_temp, lceispTC_temp, lceispTO_temp, lceispTN_temp, lcSQL_eispTH, loEispth, ;
3136 loEisptc, loEispto, loEisptn, loEisptd, lcOldSetDeleted
3137
3138 llRetVal = .T.
3139 lcSQLDelete = ""
3140
3141 WITH THIS
3142 lcMessage= "Sending transaction records to server"
3143 .InitThermo(1)
3144 .UpdateThermoCaption(lcMessage + "...")
3145
3146 laTables[1] = "VzzeiSPth_iSPproc"
3147 laTables[2] = "VzzeiSPtc_iSPproc"
3148 laTables[3] = "VzzeiSPto_iSPproc"
3149 laTables[4] = "VzzeiSPtn_iSPproc"
3150 laTables[5] = "VzzeiSPtd_iSPproc"
3151 laTables[6] = "VzzeiSPth_notes_iSPproc" && TR 1050836 27-Jul-2011 Partha
3152 laTables[7] = "VzzeiSPto_notes_iSPproc" && *--- TR 1076260 18-Mar-2014 Goutam
3153
3154 SELECT(pceispTH)
3155 SCAN
3156 SCATTER NAME loEiSPth MEMO
3157 loEiSPth.User_Id = EDI_USER
3158 loEiSPth.Last_mod = DATETIME()
3159 *--- TR 1082847 31-1-2015 VKK
3160 loEiSPth.GIT_Ind = 1 && GIT Process ready to go
3161 Replace Git_Ind WITH 1
3162 *=== TR 1082847 31-1-2015 VKK
3163
3164 IF SEEK(loEiSPth.pkey,'Vzzeispth_ispproc','PKEY')
3165 SELECT('Vzzeispth_ispproc')
3166 GATHER NAME loEiSPth MEMO
3167 ELSE
3168 SELECT('Vzzeispth_ispproc')
3169 APPEND BLANK
3170 BLANK
3171 GATHER NAME loEiSPth MEMO
3172 ENDIF
3173 ENDSCAN
3174
3175 *--- TR 1050836 27-Jul-2011 Partha ---
3176 SELECT(pceispTH_notes)
3177 SCAN
3178 SCATTER NAME loEiSPth_notes MEMO
3179 loEiSPth_notes.User_Id = EDI_USER
3180 loEiSPth_notes.Last_mod = DATETIME()
3181
3182 IF SEEK(loEiSPth_notes.pkey,'Vzzeispth_notes_ispproc','PKEY')
3183 SELECT('Vzzeispth_notes_ispproc')
3184 GATHER NAME loEiSPth_notes MEMO
3185 ELSE
3186 SELECT('Vzzeispth_notes_ispproc')
3187 APPEND BLANK
3188 BLANK
3189 GATHER NAME loEiSPth_notes MEMO
3190 ENDIF
3191 ENDSCAN
3192 *=== TR 1050836 27-Jul-2011 Partha ===
3193
3194 *--- TR 1076260 18-Mar-2014 Goutam
3195 SELECT(pceispTO_notes)
3196 SCAN
3197 SCATTER NAME loEiSPto_notes MEMO
3198 loEiSPto_notes.User_Id = EDI_USER
3199 loEiSPto_notes.Last_mod = DATETIME()
3200
3201 IF SEEK(loEiSPto_notes.pkey,'Vzzeispto_notes_ispproc','PKEY')
3202 SELECT('Vzzeispto_notes_ispproc')
3203 GATHER NAME loEiSPto_notes MEMO
3204 ELSE
3205 SELECT('Vzzeispto_notes_ispproc')
3206 APPEND BLANK
3207 BLANK
3208 GATHER NAME loEiSPto_notes MEMO
3209 ENDIF
3210 ENDSCAN
3211 *=== TR 1076260 18-Mar-2014 Goutam
3212
3213 SELECT(pceiSPTC)
3214 SCAN
3215 SCATTER NAME loEiSPtc MEMO
3216 loEiSPtc.User_Id = EDI_USER
3217 loEiSPtc.Last_mod = DATETIME()
3218
3219 IF SEEK(loEiSPtc.pkey,'VzzeiSPtc_iSPproc','PKEY')
3220 SELECT('VzzeiSPtc_iSPproc')
3221 GATHER NAME loEiSPtc MEMO
3222 ELSE
3223 SELECT('VzzeiSPtc_iSPproc')
3224 APPEND BLANK
3225 BLANK
3226 GATHER NAME loEiSPtc MEMO
3227 ENDIF
3228 ENDSCAN
3229
3230 SELECT(pceiSPTO)
3231 SCAN
3232 SCATTER NAME loEiSPto MEMO
3233 loEiSPto.User_Id = EDI_USER
3234 loEiSPto.Last_mod = DATETIME()
3235
3236 IF SEEK(loEiSPto.pkey,'VzzeiSPto_iSPproc','PKEY')
3237 SELECT('VzzeiSPto_iSPproc')
3238 GATHER NAME loEiSPto MEMO
3239 ELSE
3240 SELECT('VzzeiSPto_iSPproc')
3241 APPEND BLANK
3242 BLANK
3243 GATHER NAME loEiSPto MEMO
3244 ENDIF
3245 ENDSCAN
3246
3247 SELECT(pceiSPTN)
3248 SCAN
3249 SCATTER NAME loEiSPtn MEMO
3250 loEiSPtn.User_Id = EDI_USER
3251 loEiSPtn.Last_mod = DATETIME()
3252
3253 IF SEEK(loEiSPtn.pkey,'VzzeiSPtn_iSPproc','PKEY')
3254 SELECT('VzzeiSPtn_iSPproc')
3255 GATHER NAME loEiSPtn MEMO
3256 ELSE
3257 SELECT('VzzeiSPtn_iSPproc')
3258 APPEND BLANK
3259 BLANK
3260 GATHER NAME loEiSPtn MEMO
3261 ENDIF
3262 ENDSCAN
3263
3264 *------ Deleted for optimization. Seek is taking more time on deleted record and looks like process is hanging.
3265 *------ So we will delete record from view only if record is deleted in the source cursor.
3266 *SELECT VzzeiSPtd_iSPproc
3267 *DELETE ALL
3268 *------
3269
3270 SELECT(pceiSPTD)
3271 lcOldSetDeleted = SET("DELETED")
3272 SET DELETED OFF
3273 SCAN
3274 SCATTER NAME loEiSPtd MEMO
3275 loEiSPtd.User_Id = EDI_USER
3276 loEiSPtd.Last_mod = DATETIME()
3277
3278 IF SEEK(loEiSPtd.pkey,'VzzeiSPtd_iSPproc','PKEY')
3279 IF DELETED()
3280 DELETE IN VzzeiSPtd_iSPproc
3281 LOOP
3282 ENDIF
3283 SELECT('VzzeiSPtd_iSPproc')
3284 GATHER NAME loEiSPtd MEMO
3285 ELSE
3286 SELECT('VzzeiSPtd_iSPproc')
3287 APPEND BLANK
3288 BLANK
3289 GATHER NAME loEiSPtd MEMO
3290 ENDIF
3291 ENDSCAN
3292
3293 SET DELETED &lcOldSetDeleted
3294
3295 IF llRetVal
3296 llBeganTransaction = THIS.BeginTransaction()
3297
3298 llRetVal = llRetVal and THIS.TABLEUPDATE(@laTables)
3299
3300 IF llRetVal
3301 IF llBeganTransaction
3302 THIS.EndTransaction()
3303 ENDIF
3304 ELSE
3305 IF llBeganTransaction
3306 THIS.RollbackTransaction()
3307 ENDIF
3308 ENDIF
3309 ENDIF
3310
3311 .oLog.LogEntry(lcMessage + ": " + IIF(llRetVal, 'Succeeded','FAILED'))
3312 ENDWITH
3313
3314 RETURN llRetVal
3315 ENDPROC
3316
3317*============================================================
3318
3319 PROCEDURE UpdateISPChanges
3320
3321 *--- TR 1050836 28-Jul-2011 Partha added tcEispth_notes in paramlist ---
3322 LPARAMETERS tcEispth, tcEisptd, tcEisptn, tcEispto, tcEisptc, tcEispth_notes
3323
3324 *--- TR 1050836 28-Jul-2011 Partha increased laTables array length to 7 ---
3325 LOCAL lnPkey, lnCntr_usg, lnShipment_Num, laTables[7], lnOldProd_num, lnProd_num, lnCarton_seq, lcLocation, ;
3326 lnCntr_pkey, lnOordsp_pkey, lnCntph_Pkey, lnCtnPd_PKey, lnSelect, llProcessSuccess, lcOrderDivision, ;
3327 lcMaxLineNoCurs, lnCarton_lin
3328
3329 *--- TR 1050836 28-Jul-2011 Partha ---
3330 LOCAL lnHntCount, lnHnt_pkey
3331 STORE 0 TO lnHntCount, lnHnt_pkey
3332 *=== TR 1050836 28-Jul-2011 Partha ===
3333
3334 *--- TR 1058968
3335 LOCAL lnShipmentCartonCnt
3336 lnShipmentCartonCnt = 0
3337 *=== TR 1058968
3338
3339
3340 laTables[1] = "Vzzmshpmh_iSPproc"
3341 laTables[2] = "Vzzmcntnr_iSPproc"
3342 laTables[3] = "Vzzyrfshp_iSPproc"
3343 laTables[4] = "Vzzoordsp_iSPproc"
3344 laTables[5] = "Vzzoctnph_iSPproc"
3345 laTables[6] = "Vzzoctnpd_iSPproc"
3346 laTables[7] = "Vsysnotes_iSPproc" && TR 1050836 28-Jul-2011 Partha
3347
3348 *lcTmpISPtdCursor = GetUniqueFilename()
3349 *lcMaxLineNoCurs = GetUniqueFilename()
3350
3351 lnCntr_usg = 0
3352 llRetVal = .T.
3353 lnSelect = SELECT()
3354
3355 CREATE CURSOR tcSPPkey (pkey i)
3356
3357 WITH This
3358
3359 .LogMajorStage("Update Shipment......")
3360 .lUsePassThrough = .T.
3361 llRetVal = .CreateShipmentViews()
3362
3363 IF llRetVal
3364 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3365 lcSql = "SELECT COUNT(*) shpCount " + ;
3366 " FROM ( SELECT DISTINCT shpm_ref FROM " + tcEiSPth + ;
3367 " WHERE errs_flg_h <> 'Y' "+ ;
3368 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3369 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y')) a "
3370
3371 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcShpmhCount",,.T.)
3372
3373 IF llRetVal
3374 lnShpCount = tcShpmhCount.shpCount
3375 ENDIF
3376
3377 *--- TR 1050836 28-Jul-2011 Partha ---
3378 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3379 lcSql = "SELECT COUNT(*) hntCount " + ;
3380 " FROM (SELECT pkey " + ;
3381 " FROM " + tcEiSPth_notes + ;
3382 " WHERE fkey in (SELECT pkey " + ;
3383 " FROM " + tcEiSPth + ;
3384 " WHERE errs_flg_h <> 'Y' " + ;
3385 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3386 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3387
3388 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcNotesCount",,.T.)
3389
3390 IF llRetVal
3391 lnHntCount = tcNotesCount.hntCount
3392 ENDIF
3393 *=== TR 1050836 28-Jul-2011 Partha ===
3394
3395 *- TR 1057395 FH - don't need distinct
3396 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3397 lcSql = "SELECT COUNT(*) cntCount " + ;
3398 " FROM (SELECT fkey, cntr_num, cntr_usg " + ;
3399 " FROM " + tcEiSPtc + ;
3400 " WHERE fkey in (SELECT pkey " + ;
3401 " FROM " + tcEiSPth + ;
3402 " WHERE errs_flg_h <> 'Y' " + ;
3403 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3404 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3405
3406 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcCntnrCount",,.T.)
3407
3408 IF llRetVal
3409 lnCntCount = tcCntnrCount.cntCount
3410 ENDIF
3411
3412 *- TR 1057395 FH - don't need distinct
3413 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3414 lcSQL = "SELECT COUNT(*) ctnHdrCount " + ;
3415 " FROM (SELECT fkey, carton_num " + ;
3416 " FROM " + tcEisptn + ;
3417 " WHERE fkey in (SELECT pkey " + ;
3418 " FROM " + tcEiSPth + ;
3419 " WHERE errs_flg_h <> 'Y' " + ;
3420 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3421 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3422
3423
3424 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcCtnHdrCount",,.T.)
3425
3426 IF llRetVal
3427 lnCtnHdrCount = tcCtnHdrCount.ctnHdrCount
3428 ENDIF
3429 *-TR 1057395 FH - removed sizebucket, added upc, open_seq
3430 *-TR 1051082 FH - added sizebucket
3431 lcSQL = "SELECT COUNT(*) ctnDtlCount " + ;
3432 " FROM (SELECT DISTINCT fkey, carton_num, prod_num, upc, open_seq " + ;
3433 " FROM " + tcEiSPtd + ;
3434 " WHERE ctnkey in (SELECT pkey " + ;
3435 " FROM " + tcEisptn + ;
3436 " WHERE errs_flg_ctn <> 'Y') " + ;
3437 " AND fkey in (SELECT pkey " + ; && *--- TR 1082847 31-1-2015 VKK
3438 " FROM " + tcEiSPth + ; && *--- TR 1082847 31-1-2015 VKK
3439 " WHERE errs_flg_h <> 'Y' " + ; && *--- TR 1082847 31-1-2015 VKK
3440 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3441 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3442
3443
3444 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcCtnDtlCount",,.T.)
3445
3446 IF llRetVal
3447 lnCtnDtlCount = tcCtnDtlCount.ctnDtlCount
3448 ENDIF
3449
3450 *- TR 1057395 FH - don't need distinct
3451 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3452 lcSQL = "SELECT COUNT(*) OrdSpCount " + ;
3453 " FROM (SELECT fkey, shpm_ref, cntr_num, prod_num " + ;
3454 " FROM " + tcEisptn + ;
3455 " WHERE fkey in (SELECT pkey " + ;
3456 " FROM " + tcEiSPth + ;
3457 " WHERE errs_flg_h <> 'Y' " + ;
3458 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3459 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3460
3461
3462 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcOrdSpCount",,.T.)
3463
3464 IF llRetVal
3465 lnOrdShpCount = tcOrdSpCount.OrdSpCount
3466 ENDIF
3467
3468 *- TR 1057395 FH - don't need distinct
3469 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (warn_flg_h <> 'Y' Or ignore_warn = 'Y')
3470 lcSQL = "SELECT COUNT(*) RfShpCount " + ;
3471 " FROM (SELECT fkey, shpm_ref, carton_num, cntr_num " + ;
3472 " FROM " + tcEisptn + ;
3473 " WHERE fkey in (SELECT pkey " + ;
3474 " FROM " + tcEiSPth + ;
3475 " WHERE errs_flg_h <> 'Y' " + ;
3476 " ANd " + ASN_TYPE_VFP_COND + ; && *--- TR 1082847 31-1-2015 VKK
3477 " and (warn_flg_h <> 'Y' Or ignore_warn = 'Y'))) a "
3478
3479
3480 llRetVal = llRetval AND v_Sqlexec(lcSql, "tcRfShpCount",,.T.)
3481
3482 IF llRetVal
3483 lnRfShp_Count = tcRfShpCount.RfShpCount
3484 ENDIF
3485
3486 lnPkey = v_NextPkey("ZZMSHPMH",lnShpCount)
3487 lnCntr_pkey = v_NextPkey("ZZMCNTNR",lnCntCount)
3488 lnOordsp_pkey = v_NextPkey("ZZOORDSP",lnOrdShpCount * 2) && *-TR 1057395 FH - multiply by 2
3489 lnCtnPh_PKey = v_NextPkey("ZZOCTNPH",lnCtnHdrCount ) - lnCtnHdrCount + 1
3490 lnCtnPd_PKey = v_NextPkey("ZZOCTNPD",lnCtnDtlCount ) - lnCtnDtlCount + 1
3491 lnCntr_pkey = v_NextPkey("ZZMCNTNR",lnCntCount)
3492
3493 lnHnt_pkey = v_NextPkey("SYSNOTES",lnHntCount) && TR 1050836 28-Jul-2011 Partha
3494
3495 *lnRfshp_Pkey = v_NextPkey("ZZYRFSHP",lnRfShp_Count )
3496 lcSql = "Select MAX(pkey) pkey from ZZYRFSHP"
3497 llRetVal = llRetval AND v_Sqlexec(lcSql, "__tmpPkeyCurs")
3498 lnRfshp_Pkey = NVL(__tmpPkeyCurs.pkey,0) + 1
3499
3500 lnPkey = lnPkey - (lnShpCount - 1)
3501 lnCntr_pkey = lnCntr_pkey - (lnCntCount - 1)
3502 lnOordsp_pkey = lnOordsp_pkey - (lnOrdShpCount * 2) && *-TR 1057395 FH - multiply by 2
3503 *lnCtnPh_PKey = lnCtnPh_PKey - (lnCtnHdrCount - 1)
3504 *lnCtnPd_PKey = lnCtnPd_PKey - (lnCtnDtlCount - 1)
3505 *lnRfshp_Pkey = lnRfshp_Pkey - ( lnRfShp_Count -1 )
3506
3507 lnHnt_pkey = lnHnt_pkey - lnHntCount && TR 1050836 28-Jul-2011 Partha
3508
3509 *--- TR 1037787 8-Apr-2009 Goutam
3510 *lnShipment_Num = v_NextID('ZZMCNTRC', "SHIPMENT_NUM", lnShpCount)
3511 *lnShipment_Num = lnShipment_Num - (lnShpCount - 1)
3512 *=== TR 1037787 8-Apr-2009 Goutam
3513
3514 SELECT (tcEiSPth)
3515 .nToProcess = RECCOUNT()
3516
3517 *--- TechRec 1067730 15-Jul-2013 vkrishnamurthy ---
3518*!* SCAN FOR NOT (errs_flg_h == "Y")
3519 *--- TR 1082847 31-1-2015 VKK Added eval(ASN_TYPE_VFP_COND)
3520 SCAN FOR NOT (errs_flg_h == "Y") AND (warn_flg_h <> 'Y' OR ignore_warn = 'Y') AND EVALUATE(ASN_TYPE_VFP_COND)
3521 *=== TechRec 1067730 15-Jul-2013 vkrishnamurthy ===
3522
3523 .nProcessed = .nProcessed + 1
3524
3525 *--- TR 1037787 8-Apr-2009 Goutam
3526 IF Shipment_Num > 0
3527 lnShipment_Num = Shipment_Num
3528 ELSE
3529 DO WHILE .T.
3530 lnShipment_Num = v_NextID('ZZMCNTRC', "SHIPMENT_NUM")
3531 IF INDEXSEEK(lnShipment_Num, .F., tcEiSPth, "SHPMNUM") OR vl_shpmh(lnShipment_Num)
3532 LOOP
3533 ELSE
3534 EXIT
3535 ENDIF
3536 ENDDO
3537 ENDIF
3538 *--- TR 1037787 8-Apr-2009 Goutam
3539
3540 *--- Inserting new record
3541 SCATTER NAME loEiSPth MEMO
3542
3543 SELECT Vzzmshpmh_iSPproc
3544 APPEND BLANK
3545 BLANK
3546
3547 REPLACE ;
3548 duty_fee WITH 0, ;
3549 duty_by WITH 'U', ;
3550 udf01_by WITH 'U', ;
3551 udf02_by WITH 'U', ;
3552 udf03_by WITH 'U', ;
3553 udf04_by WITH 'U', ;
3554 udf05_by WITH 'U', ;
3555 udf06_by WITH 'U', ;
3556 udf07_by WITH 'U', ;
3557 udf08_by WITH 'U', ;
3558 udf09_by WITH 'U', ;
3559 udf10_by WITH 'U', ;
3560 udf01_fee WITH 0, ;
3561 udf02_fee WITH 0, ;
3562 udf03_fee WITH 0, ;
3563 udf04_fee WITH 0, ;
3564 udf05_fee WITH 0, ;
3565 udf06_fee WITH 0, ;
3566 udf07_fee WITH 0, ;
3567 udf08_fee WITH 0, ;
3568 udf09_fee WITH 0, ;
3569 udf10_fee WITH 0, ;
3570 pkey WITH lnPKey, ;
3571 last_mod WITH DATETIME(), ;
3572 user_id WITH g_cUser, ;
3573 shipment_num WITH lnShipment_Num, ;
3574 cs_entr_Date WITH loEiSPth.cs_entr_Date, ;
3575 due_date WITH loEiSPth.due_date, ;
3576 eta_date WITH loEiSPth.eta_date, ;
3577 shpdate WITH loEiSPth.shpdate, ;
3578 shpm_UDF2 WITH loEiSPth.shpm_UDF2 , ; && TR 1050836 28-Jul-2011 Partha
3579 shpm_UDF1 WITH loEiSPth.shpm_UDF1, ; && TR 1050836 28-Jul-2011 Partha
3580 shpm_UDF3 WITH loEiSPth.shpm_UDF3, ; && TR 1050836 28-Jul-2011 Partha
3581 shpm_UDF4 WITH loEiSPth.shpm_UDF4, ; && TR 1050836 28-Jul-2011 Partha
3582 shpm_UDF5 WITH loEiSPth.shpm_UDF5, ; && TR 1050836 28-Jul-2011 Partha
3583 shpm_UDF6 WITH loEiSPth.shpm_UDF6, ; && TR 1050836 28-Jul-2011 Partha
3584 SHPM_UDF1D WITH loEiSPth.SHPM_UDF1D, ; && TR 1050836 28-Jul-2011 Partha
3585 SHPM_UDF2D WITH loEiSPth.SHPM_UDF2D, ; && TR 1050836 28-Jul-2011 Partha
3586 SHPM_UDF3D WITH loEiSPth.SHPM_UDF3D, ; && TR 1050836 28-Jul-2011 Partha
3587 SHPM_UDF4D WITH loEiSPth.SHPM_UDF4D, ; && TR 1050836 28-Jul-2011 Partha
3588 SHPM_UDF5D WITH loEiSPth.SHPM_UDF5D, ; && TR 1050836 28-Jul-2011 Partha
3589 SHPM_UDF6D WITH loEiSPth.SHPM_UDF6D, ; && TR 1050836 28-Jul-2011 Partha
3590 SHPM_UDF7D WITH loEiSPth.SHPM_UDF7D, ; && TR 1050836 28-Jul-2011 Partha
3591 SHPM_UDF8D WITH loEiSPth.SHPM_UDF8D, ; && TR 1050836 28-Jul-2011 Partha
3592 shpm_bol WITH loEiSPth.shpm_bol, ;
3593 country WITH loEiSPth.country, ;
3594 port_entry WITH loEiSPth.port_entry, ;
3595 fob WITH loEiSPth.fob, ;
3596 voyage WITH loEiSPth.voyage, ;
3597 vessl_code WITH loEiSPth.vessl_code, ;
3598 shipper WITH loEiSPth.shipper, ;
3599 shpt_stage WITH loEiSPth.shpt_stage, ;
3600 shpt_code WITH loEiSPth.shpt_code, ;
3601 shpm_Ref WITH loEiSPth.shpm_Ref IN 'Vzzmshpmh_iSPProc'
3602
3603 lnCntr_usg = 0
3604
3605 *--- TR 1058968
3606 * reset carton cnt
3607 lnShipmentCartonCnt = 0
3608 *=== TR 1058968
3609
3610 *--- TR 1050836 28-Jul-2011 Partha ---
3611 SELECT (tcEiSPth_notes)
3612 SET ORDER TO fkey
3613
3614 IF SEEK(loEispth.pkey)
3615 SCAN WHILE (fkey = loEispth.pkey)
3616
3617 SCATTER NAME loEiSPth_notes MEMO
3618 lnHnt_pkey = lnHnt_pkey + 1
3619
3620 SELECT Vsysnotes_iSPproc
3621 APPEND BLANK
3622 loEiSPth_notes.pkey = lnHnt_pkey
3623 loEiSPth_notes.fkey = lnPkey
3624 loEiSPth_notes.table_name = "ZZMSHPMH"
3625 GATHER NAME loEiSPth_notes MEMO
3626
3627 SELECT (tcEiSPth_notes)
3628 ENDSCAN
3629 ENDIF
3630 *=== TR 1050836 28-Jul-2011 Partha ===
3631
3632 SELECT (tcEisptc)
3633 *LOCATE FOR NOT(errs_flg_cntr == "Y") AND (fkey = loEispth.pkey)
3634 SET ORDER TO fkey
3635
3636 IF SEEK(loEispth.pkey)
3637 *SCAN FOR NOT(errs_flg_cntr == "Y") AND (fkey = loEispth.pkey)
3638 *SCAN WHILE (fkey = loEispth.pkey) FOR NOT(errs_flg_cntr == "Y")
3639 SCAN WHILE (fkey = loEispth.pkey)
3640
3641 SCATTER NAME loEiSPtc MEMO
3642 lnCntr_usg = loEiSPtc.cntr_usg
3643
3644 *--- TR 1065007 13-Jan-2014 Goutam. Added loEispth.Control_Key
3645 llRetVal = llRetVal And .UpdateZzmcntnr(loEiSPtc, lnCntr_usg, lnCntr_pkey, lnShipment_Num, loEispth.Control_Key)
3646
3647 lnCntr_pkey = lnCntr_pkey + 1
3648
3649 *--Inserting 2 new records in zzoordsp
3650 IF SEEK(loEiSptc.pkey, 'tcEiSpto', 'CKEY')
3651 lnProd_num = tcEiSpto.Prod_num
3652 ELSE
3653 lnProd_num = 0
3654 ENDIF
3655
3656 *--Inserting First record
3657 lnOordsp_pkey = lnOordsp_pkey + 1
3658 llRetVal = llRetVal And .UpdateVzzoordspP(loEiSPtc.cntr_num, lnOordsp_pkey, lnCntr_usg, lnProd_num)
3659 INSERT INTO tcSPPkey VALUES (lnOordsp_pkey)
3660
3661
3662 *--Inserting Second record
3663 lnOordsp_pkey = lnOordsp_pkey + 1
3664 llRetVal = llRetVal And .UpdateVzzoordspF(loEiSPtc.cntr_num, @lnOordsp_pkey, lnCntr_usg, lnProd_num)
3665 INSERT INTO tcSPPkey VALUES (lnOordsp_pkey)
3666
3667
3668 *--- Update zzoctnph
3669 lnCarton_seq = 0
3670
3671 SELECT (tcEisptn)
3672
3673 *SCAN FOR NOT (errs_flg_ctn == "Y") AND (fkey = loeiSpth.pkey ) AND (ckey = loeiSPtc.Pkey)
3674 SET ORDER TO FCKEY
3675 SEEK(STR(loeiSpth.pkey)+STR(loeiSPtc.Pkey))
3676 *SCAN WHILE ((fkey = loeiSpth.pkey) AND (ckey = loeiSPtc.Pkey)) FOR NOT (errs_flg_ctn == "Y")
3677 SCAN WHILE ((fkey = loeiSpth.pkey) AND (ckey = loeiSPtc.Pkey))
3678
3679 SCATTER NAME loEiSPtCtn MEMO
3680
3681 lnCarton_seq = lnCarton_seq + 1
3682
3683 *--- TR 1058968
3684 * add to carton count
3685 lnShipmentCartonCnt = lnShipmentCartonCnt + 1
3686 *=== TR 1058968
3687
3688
3689 *--- TR 1065007 13-Jan-2014 Goutam. Added loEispth.Control_Key
3690 llRetVal = llRetVal And .UpdateZzoctnph(loEiSPtCtn, "tcEispto", lnCarton_seq, lnShipment_num, ;
3691 lnOordsp_pkey, lnCntr_usg, @lnRfShp_Pkey, lnCtnph_Pkey, "B", loEispth.Control_Key)
3692
3693 lnCarton_lin = 0
3694 SELECT (tcEisptd)
3695 *SCAN FOR NOT (errs_flg_d == "Y") AND (fkey = loEispth.pkey) AND (ckey = loEisptc.pkey) AND (ctnkey = loEiSPtCtn.pkey)
3696 SET ORDER TO ALLKEY
3697 =SEEK(STR(loEispth.pkey)+STR(loEisptc.pkey)+STR(loEiSPtCtn.pkey))
3698 *SCAN WHILE ((fkey = loEispth.pkey) AND (ckey = loEisptc.pkey) AND (ctnkey = loEiSPtCtn.pkey)) FOR NOT (errs_flg_d == "Y")
3699 SCAN WHILE ((fkey = loEispth.pkey) AND (ckey = loEisptc.pkey) AND (ctnkey = loEiSPtCtn.pkey))
3700
3701 SCATTER NAME loEiSPtd MEMO
3702 lnCarton_lin = lnCarton_lin + 1
3703 *--- TechRec 1057959 07-Dec-2011 TShenbagavalli ---
3704 *llRetVal = llRetVal And .UpdateZzoctnpd(loEiSPtd, lnCtnPd_PKey, lnCtnPh_pkey,lnCarton_lin)
3705 llRetVal = llRetVal And .UpdateZzoctnpd(loEiSPtd, lnCtnPd_PKey, lnCtnPh_pkey,lnCarton_lin, lnShipment_num, ;
3706 loEiSPtCtn, lnCntr_usg, @lnRfShp_Pkey )
3707 *=== TechRec 1057959 07-Dec-2011 TShenbagavalli ===
3708 lnCtnPd_PKey = lnCtnPd_PKey + 1
3709 ENDSCAN
3710
3711 lnCtnPh_pkey = lnCtnPh_pkey + 1
3712 SELECT (tcEisptn)
3713 ENDSCAN
3714 SELECT (tcEisptc)
3715 ENDSCAN
3716 ELSE
3717 SELECT (tcEisptn)
3718 *LOCATE FOR NOT (errs_flg_ctn == "Y") AND (fkey = loeiSpth.pkey)
3719 SET ORDER TO fkey
3720 =SEEK(loeiSpth.pkey)
3721 SCAN WHILE (fkey = loeiSpth.pkey)
3722 *--Inserting 1 new records in zzoordsp
3723 IF SEEK(okey, 'tcEiSpto', 'PKEY')
3724 lnProd_num = tcEiSpto.Prod_num
3725 ELSE
3726 lnProd_num = 0
3727 ENDIF
3728
3729 lnCntr_usg = 0
3730 lnOordsp_pkey = lnOordsp_pkey + 1
3731 lnOordsp_pkey_old = lnOordsp_pkey
3732 llRetVal = llRetVal And .UpdateVzzoordspF("", @lnOordsp_pkey, lnCntr_usg, lnProd_num)
3733 INSERT INTO tcSPPkey VALUES (lnOordsp_pkey)
3734
3735 lnCarton_seq = 0
3736 *SCAN FOR NOT (errs_flg_ctn == "Y") AND (fkey = loeiSpth.pkey)
3737 SCAN WHILE (fkey = loeiSpth.pkey) FOR NOT (errs_flg_ctn == "Y")
3738
3739 SCATTER NAME loEiSPtCtn MEMO
3740
3741 lnCarton_seq = lnCarton_seq + 1
3742
3743 *--- TR 1058968
3744 * add to carton count
3745 lnShipmentCartonCnt = lnShipmentCartonCnt + 1
3746 *=== TR 1058968
3747
3748 *--- TR 1065007 13-Jan-2014 Goutam. Added loEispth.Control_Key
3749 llRetVal = llRetVal And .UpdateZzoctnph(loEiSPtCtn, "tcEiSpto", lnCarton_seq, lnShipment_num, ;
3750 lnOordsp_pkey, lnCntr_usg, @lnRfShp_Pkey, lnCtnph_Pkey, "S", loEispth.Control_Key)
3751
3752 SELECT (tcEisptd)
3753 lnCarton_lin = 0
3754 *SCAN FOR NOT (errs_flg_d == "Y") AND (fkey = loEispth.pkey) AND (ctnkey = loEiSPtCtn.pkey)
3755 SET ORDER TO CTNFKEY
3756 SEEK(STR(loEispth.pkey)+STR(loEiSPtCtn.pkey))
3757 SCAN WHILE ((fkey = loEispth.pkey) AND (ctnkey = loEiSPtCtn.pkey)) FOR NOT (errs_flg_d == "Y")
3758
3759 SCATTER NAME loEiSPtd MEMO
3760 lnCarton_lin = lnCarton_lin + 1
3761 *--- TechRec 1057959 07-Dec-2011 TShenbagavalli ---
3762 *llRetVal = llRetVal And .UpdateZzoctnpd(loEiSPtd, lnCtnPd_PKey, lnCtnPh_pkey,lnCarton_lin )
3763 llRetVal = llRetVal And .UpdateZzoctnpd(loEiSPtd, lnCtnPd_PKey, lnCtnPh_pkey,lnCarton_lin, lnShipment_num, ;
3764 loEiSPtCtn, lnCntr_usg, @lnRfShp_Pkey )
3765 *=== TechRec 1057959 07-Dec-2011 TShenbagavalli ===
3766
3767 lnCtnPd_PKey = lnCtnPd_PKey + 1
3768 ENDSCAN
3769
3770 lnCtnPh_pkey = lnCtnPh_pkey + 1
3771 SELECT (tcEisptn)
3772 ENDSCAN
3773
3774 lnOordsp_pkey = lnOordsp_pkey_old
3775
3776
3777 ENDSCAN
3778
3779 ENDIF
3780
3781
3782 *--- TR 1058968
3783 * update carton count
3784 replace carton WITH lnShipmentCartonCnt IN Vzzmshpmh_iSPproc
3785 *=== TR 1058968
3786
3787 *--- TR 1037787 8-Apr-2009 Goutam
3788 *lnShipment_Num = lnShipment_Num + 1
3789 *=== TR 1037787 8-Apr-2009 Goutam
3790
3791 lnPkey = lnPkey + 1
3792 SELECT 'tcEispth'
3793 llProcessSuccess = true
3794 ENDSCAN
3795
3796 IF llProcessSuccess
3797 SELECT fkey, MAX(carton_seq) as carton_seq ;
3798 FROM Vzzoctnph_iSPproc ;
3799 WHERE carton_cls = 'F' ;
3800 GROUP BY fkey ;
3801 INTO CURSOR 'tcSeqNum'
3802
3803 IF USED('tcSeqNum')
3804
3805 *---- Updating zzoordsp
3806 UPDATE s SET cartons = 'Y', s.carton_seq = t.carton_seq ;
3807 FROM Vzzoordsp_iSPproc s JOIN tcSeqNum t ;
3808 ON t.fkey = s.pkey
3809
3810 USE in 'tcSeqNum'
3811 ENDIF
3812 ENDIF
3813
3814 ENDIF
3815
3816 IF llRetVal
3817
3818 llRetVal = llRetVal AND .GenerateSQLTempTable("tcSPPkey")
3819 IF RECCOUNT("tcSPPkey") > 0
3820 llRetVal = llRetVal AND .PopulateSQLTempTable("tcSPPkey")
3821 ENDIF
3822 lcSPKeyTmp = .cSQLTempTable
3823 lcCartonCnt = "#" + getuniquefilename()
3824
3825
3826 llBeganTransaction = THIS.BeginTransaction()
3827
3828 v_SqlExec("SET IDENTITY_INSERT zzyrfshp ON")
3829
3830 *llRetVal = llRetVal and THIS.TABLEUPDATE(@laTables)
3831 llRetVal = llRetVal AND .TableUpdateFromCursor(@laTables)
3832 *--- TR 1082847 31-1-2015 VKK Added added "I" Intranist
3833 llRetVal = llRetVal AND .DeleteFromTransaction(tcEiSPth, "I")
3834
3835 lcSQL = "SELECT h.pkey,COUNT(*) as cnt,MAX(carton_seq) as carton_seq " + ;
3836 " INTO " + lcCartonCnt + " " + ;
3837 " FROM " + lcSPKeyTmp + " h " + ;
3838 " JOIN zzoctnph c ON h.pkey = c.fkey GROUP BY h.pkey "
3839 llRetVal = llRetVal AND v_sqlexec(lcSQL)
3840
3841 lcSQL = ;
3842 "UPDATE sp SET cartons = 'Y', carton_seq = h.carton_seq " + ;
3843 " FROM zzoordsp sp " + ;
3844 " JOIN " + lcCartonCnt + " h ON sp.pkey = h.pkey "
3845 llRetVal = llRetVal AND v_sqlexec(lcSQL)
3846
3847 v_SqlExec("SET IDENTITY_INSERT zzyrfshp OFF")
3848
3849 IF llRetVal
3850 IF llBeganTransaction
3851 THIS.EndTransaction()
3852 ENDIF
3853 ELSE
3854 IF llBeganTransaction
3855 THIS.RollbackTransaction()
3856 ENDIF
3857 ENDIF
3858 v_sqlexecnoerror("DROP TABLE " + lcSPKeyTmp )
3859 v_sqlexecnoerror("DROP TABLE " + lcCartonCnt)
3860 ENDIF
3861
3862 .TableClose("tcShpmhCount")
3863 .TableClose("tcNotesCount") && TR 1050836 28-Jul-2011 Partha
3864 .TableClose("tcCntnrCount")
3865 .TableClose("tcOrdSpCount")
3866 .TableClose("tcCtnHdrCount")
3867 .TableClose("tcCtnDtlCount")
3868 .TableClose("tcRfShpCount")
3869 .TableClose("tcCntr_Usg")
3870 .TableClose("tcCntrNum")
3871 .Tableclose("__tmpPkeyCurs")
3872
3873 .TableClose(@laTables, True)
3874
3875 ENDWITH
3876
3877 SELECT (lnSelect)
3878 RETURN llRetVal
3879 ENDPROC
3880
3881****************************************
3882PROCEDURE CreateShipmentViews
3883 LOCAL llRetVal, lcSQLSelect, lcSQLOrder, lnThermoCnt, lnCursorBuffer
3884
3885 llRetVal = .T.
3886 lnThermoCnt = 0
3887 lnOldSelect = SELECT()
3888
3889 WITH This
3890
3891 .oLog.LogEntry("Creating Shipment views.")
3892
3893 *-- Added thermo counter
3894 THIS.InitThermoWithCaption(@lnThermoCnt, 3, "Creating and open Shipment views...")
3895
3896 lcSQLSelect = "select * from zzmshpmh WHERE 1 = 0"
3897 THIS.CreateSQLView("Vzzmshpmh_iSPproc", lcSQLSelect,,)
3898 THIS.AdvanceThermoPlus(@lnThermoCnt)
3899
3900 *--- TR 1050836 27-Jul-2011 Partha ---
3901 lcSQLSelect = "select * from sysnotes WHERE 1 = 0"
3902 THIS.CreateSQLView("Vsysnotes_iSPproc", lcSQLSelect,,)
3903 THIS.AdvanceThermoPlus(@lnThermoCnt)
3904 *=== TR 1050836 27-Jul-2011 Partha ===
3905
3906 lcSQLSelect = "select * from zzmcntnr where 1 = 0"
3907 THIS.CreateSQLView("Vzzmcntnr_iSPproc", lcSQLSelect,,)
3908 THIS.AdvanceThermoPlus(@lnThermoCnt)
3909
3910 lcSQLSelect = "select * from zzoordsp where 1 = 0"
3911 THIS.CreateSQLView("Vzzoordsp_iSPproc", lcSQLSelect,,)
3912 THIS.AdvanceThermoPlus(@lnThermoCnt)
3913
3914 lcSQLSelect = "select * from zzyrfshp where 1 = 0"
3915 THIS.CreateSQLView("Vzzyrfshp_iSPproc", lcSQLSelect,,)
3916 THIS.AdvanceThermoPlus(@lnThermoCnt)
3917
3918 lcSQLSelect = "select * from zzoctnph where 1 = 0"
3919 THIS.CreateSQLView("Vzzoctnph_iSPproc", lcSQLSelect,,)
3920 THIS.AdvanceThermoPlus(@lnThermoCnt)
3921
3922 lcSQLSelect = "select * from zzoctnpd where 1 = 0"
3923 THIS.CreateSQLView("Vzzoctnpd_iSPproc", lcSQLSelect,,)
3924 THIS.AdvanceThermoPlus(@lnThermoCnt)
3925
3926 .oLog.LogEntry("Opening Shipment views.")
3927
3928 lnCursorBuffer = DB_BUFOPTRECORD
3929
3930 IF NOT (THIS.OPENTABLE("Vzzmshpmh_iSPproc",, .T.,,lnCursorBuffer) AND ;
3931 THIS.OPENTABLE("Vsysnotes_iSPproc",, .T.,,lnCursorBuffer) AND ; && TR 1050836 27-Jul-2011 Partha
3932 THIS.OPENTABLE("Vzzmcntnr_iSPproc",, .T.,,lnCursorBuffer) AND ;
3933 THIS.OPENTABLE("Vzzoordsp_iSPproc",, .T.,,lnCursorBuffer) AND ;
3934 THIS.OPENTABLE("Vzzyrfshp_iSPproc",, .T.,,lnCursorBuffer) AND ;
3935 THIS.OPENTABLE("Vzzoctnph_iSPproc",, .T.,,lnCursorBuffer) AND ;
3936 THIS.OPENTABLE("Vzzoctnpd_iSPproc",, .T.,,lnCursorBuffer) )
3937 llRetVal = .F.
3938 ELSE
3939
3940 SELECT Vzzyrfshp_iSPproc
3941 INDEX ON PADL(shipment_num,10)+carton_num+cntr_num+PADL(cntr_usg,10) TAG rf_chk
3942
3943
3944 *-- Set table buffer to 5
3945*!* .SetBufferMode("Vzzmshpmh_iSPproc", DB_BUFOPTTABLE)
3946*!* .SetBufferMode("Vzzmcntnr_iSPproc", DB_BUFOPTTABLE)
3947*!* .SetBufferMode("Vzzoordsp_iSPproc", DB_BUFOPTTABLE)
3948*!* .SetBufferMode("Vzzyrfshp_iSPproc", DB_BUFOPTTABLE)
3949*!* .SetBufferMode("Vzzoctnph_iSPproc", DB_BUFOPTTABLE)
3950*!* .SetBufferMode("Vzzoctnpd_iSPproc", DB_BUFOPTTABLE)
3951 ENDIF
3952 ENDWITH
3953
3954 THIS.ResetThermoPlus()
3955 SELECT(lnOldSelect)
3956 RETURN llRetVal
3957 ENDPROC
3958
3959 PROCEDURE DeleteFromTransaction
3960 *--- TR 1082847 31-1-2015 VKK Added tcISPStage possible vlaues -> Empty, 'I','R'
3961 * Blank
3962 *'I' - InTranist , Before GIT process called
3963 *'G' - GIT Done , After GIT process called
3964 *'R' -> Received, AFter moved to received
3965 *'P' -> Pciked , AFter Pick Process called
3966 *'M' -> asn type NO. TH , AFter moving to next stage for asn types
3967 LPARAMETERS tcEiSPth, tcISPStage
3968
3969 LOCAL llRetVal, lnSelect
3970
3971 *--- TR 1082847 31-1-2015 VKK
3972 LOCAL lcAsnCondition
3973 lcAsnCondition = ICASE(tcISPStage = " ", " ", ;
3974 tcISPStage = "I", " AND h.asn_type NOT IN('DS','X2','X1',' ')", ; && for X1 and empty we will delete after GIT process based on status
3975 tcISPStage = "G", " AND h.asn_type IN('X1',' ')", ;
3976 tcISPStage = "P", " AND h.asn_type IN('X3','DS')", ;
3977 tcISPStage = "M", " AND h.asn_type IN('NO','TH')", ;
3978 tcIspStage = "R", " AND h.asn_type IN('X2')", "")
3979 *=== TR 1082847 31-1-2015 VKK
3980
3981 llRetVal = true
3982 lnSelect = SELECT()
3983
3984 WITH This
3985 .cSQLTempTable = ""
3986
3987 IF llRetVal AND .GenerateSQLTempTable(tcEiSPth)
3988 IF .PopulateSQLTempTable(tcEiSPth)
3989
3990 *--- TechRec 1037787 24-Jun-2009 vkrishnamurthy ---
3991 *--- TR 1082847 31-1-2015 VKK Added lcAsnCondition
3992 llRetVal = llRetVal AND .InsertHistoryTables(lcAsnCondition )
3993 *=== TechRec 1037787 24-Jun-2009 vkrishnamurthy ===
3994
3995 *--- TechRec 1067730 15-Jul-2013 vkrishnamurthy ---
3996*!* lcSql = " DELETE FROM zzeisptd " + ;
3997*!* " FROM zzeisptd d " + ;
3998*!* " JOIN " + .cSqlTempTable + " h " + ;
3999*!* " ON h.pkey = d.fkey " + ;
4000*!* " AND h.errs_flg_h <> 'Y'"
4001
4002 lcSql = " DELETE FROM zzeisptd " + ;
4003 " FROM zzeisptd d " + ;
4004 " JOIN " + .cSqlTempTable + " h " + ;
4005 " ON h.pkey = d.fkey " + ;
4006 " AND h.errs_flg_h <> 'Y'" +;
4007 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4008 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4009 *=== TechRec 1067730 15-Jul-2013 vkrishnamurthy ===
4010 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4011
4012 *--- TR 1050836 28-Jul-2011 Partha ---
4013 *--- TechRec 1067730 15-Jul-2013 vkrishnamurthy ---
4014*!* lcSql = " DELETE FROM sysnotes " + ;
4015*!* " FROM sysnotes d " + ;
4016*!* " JOIN " + .cSqlTempTable + " h " + ;
4017*!* " ON h.pkey = d.fkey " + ;
4018*!* " AND h.errs_flg_h <> 'Y'"
4019
4020 lcSql = " DELETE FROM sysnotes " + ;
4021 " FROM sysnotes d " + ;
4022 " JOIN " + .cSqlTempTable + " h " + ;
4023 " ON h.pkey = d.fkey " + ;
4024 " AND h.errs_flg_h <> 'Y'"+;
4025 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4026 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4027 *=== TechRec 1067730 15-Jul-2013 vkrishnamurthy ===
4028 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4029 *=== TR 1050836 28-Jul-2011 Partha ===
4030
4031 *--- TR 1076260 26-Mar-2012 Goutam
4032 lcSql = " DELETE FROM sysnotes " + ;
4033 " FROM sysnotes d " + ;
4034 " JOIN zzeispto o " + ;
4035 " ON o.pkey = d.fkey " + ;
4036 " JOIN " + .cSqlTempTable + " h " + ;
4037 " ON h.pkey = o.fkey " + ;
4038 " AND h.errs_flg_h <> 'Y'"+;
4039 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4040 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4041 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4042 *=== TR 1076260 26-Mar-2012 Goutam
4043
4044 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
4045 lcSql = " DELETE FROM zzeisptn " + ;
4046 " FROM zzeisptn d " + ;
4047 " JOIN " + .cSqlTempTable + " h " + ;
4048 " ON h.pkey = d.fkey " + ;
4049 " AND h.errs_flg_h <> 'Y'"+;
4050 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4051 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4052
4053 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4054
4055 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
4056 lcSql = " DELETE FROM zzeispto " + ;
4057 " FROM zzeispto d " + ;
4058 " JOIN " + .cSqlTempTable + " h " + ;
4059 " ON h.pkey = d.fkey " + ;
4060 " AND h.errs_flg_h <> 'Y'"+;
4061 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4062 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4063
4064 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4065
4066 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
4067 lcSql = " DELETE FROM zzeisptc " + ;
4068 " FROM zzeisptc d " + ;
4069 " JOIN " + .cSqlTempTable + " h " + ;
4070 " ON h.pkey = d.fkey " + ;
4071 " AND h.errs_flg_h <> 'Y'"+;
4072 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4073 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4074
4075 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4076
4077 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
4078 lcSql = " DELETE FROM zzeispth " + ;
4079 " FROM zzeispth h " + ;
4080 " JOIN " + .cSqlTempTable + " h1 " + ;
4081 " ON h.pkey = h1.pkey " + ;
4082 " AND h.errs_flg_h <> 'Y'"+;
4083 lcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
4084 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
4085
4086 llRetVal = llRetVal AND v_Sqlexec(lcSql)
4087 .cSqlTempTable = ""
4088 ENDIF
4089 ENDIF
4090 ENDWITH
4091
4092 SELECT (lnSelect)
4093 RETURN llRetVal
4094 ENDPROC
4095
4096 *---------------------------------------------------------------------------------
4097 PROCEDURE UpdateZzoctnpd
4098 *--- TechRec 1057959 07-Dec-2011 TShenbagavalli added tnShipment_num, toEiSPtCtn, tnCntr_usg, tnRfShp_Pkey in list ---
4099 LPARAMETERS toEiSPtd, tnCtnPd_PKey, tnCtnPh_pkey,tnCarton_lin, tnShipment_num, toEiSPtCtn, tnCntr_usg, tnRfShp_Pkey
4100
4101 LOCAL llRetVal, lnSelect, lcMaxLineNoCurs, lcOrderDivision, lcTmpISPtdCursor
4102
4103 llRetVal = true
4104 lcMaxLineNoCurs = GetUniqueFilename()
4105 lcTmpISPtdCursor = GetUniqueFilename()
4106 lnSelect = SELECT()
4107
4108 *.RetrieveBufferedDataToCursor('Vzzoctnpd_iSPproc',lcTmpISPtdCursor)
4109
4110 *lcSql = " SELECT MAX(carton_lin) " + ;
4111 " AS carton_lin " + ;
4112 " FROM " + lcTmpISPtdCursor + ;
4113 " GROUP BY carton_num " + ;
4114 " having carton_num = '" + toEiSPtd.carton_num + "'"
4115
4116 *llRetval = V_SqlExec(lcSql,lcMaxLineNoCurs,,true)
4117 *SELECT (lcMaxLineNoCurs)
4118 *lnCarton_lin = carton_lin
4119
4120 SELECT 'Vzzoctnpd_iSPproc'
4121 APPEND BLANK
4122 BLANK
4123
4124 IF SEEK(toEiSPtd.okey, 'tcEiSpto', 'PKEY')
4125 lcOrderDivision = tcEiSpto.Division
4126 ELSE
4127 lcOrderDivision = ""
4128 ENDIF
4129
4130 REPLACE;
4131 carton_num WITH toEiSPtd.carton_num, ;
4132 upc_num WITH LEFT(toEiSPtd.upc,11), ;
4133 chk_digit WITH SUBSTR(ALLTRIM(toEiSPtd.upc), 12), ; &&FH 1067429 - changed to 12
4134 sku WITH '', ;
4135 division WITH lcOrderDivision, ;
4136 style WITH toEiSPtd.style, ;
4137 color_code WITH toEiSPtd.color_code, ;
4138 lbl_code WITH toEiSPtd.lbl_code, ;
4139 dimension WITH toEiSPtd.dimension, ;
4140 size_desc WITH toEiSPtd.size_desc, ;
4141 sizebucket WITH toEiSPtd.sizebucket, ;
4142 carton_lin WITH tnCarton_lin, ;
4143 line_seq WITH 0, ;
4144 total_qty WITH toEiSPtd.qty, ;
4145 user_id WITH g_cuser, ;
4146 last_mod WITH DATETIME(), ;
4147 pkey WITH tnCtnPd_PKey, ;
4148 fkey WITH tnCtnPh_pkey, ;
4149 prod_num WITH toEiSPtd.prod_num, ;
4150 prod_line WITH toEiSPtd.open_seq
4151
4152 *.TableClose(lcMaxLineNoCurs)
4153 *.Tableclose(lcTmpISPtdCursor)
4154
4155 *--- TechRec 1057959 07-Dec-2011 TShenbagavalli ---
4156 IF NOT SEEK(PADL(tnShipment_num,10)+toEiSPtCtn.carton_num+toEiSPtCtn.cntr_num+PADL(tnCntr_usg,10),"Vzzyrfshp_iSPProc","rf_chk")
4157
4158 SELECT Vzzyrfshp_iSPProc
4159 APPEND BLANK
4160 BLANK
4161
4162 REPLACE ;
4163 shipment_num WITH tnShipment_num, ;
4164 carton_num WITH toEiSPtCtn.carton_num, ;
4165 cntr_num WITH toEiSPtCtn.cntr_num, ;
4166 cntr_usg WITH tnCntr_usg, ;
4167 pkey WITH tnRfShp_Pkey, ;
4168 user_id WITH g_cUser, ;
4169 last_mod WITH DATETIME(), ;
4170 udfcordd1c WITH toEiSPtd.udfcordd1c, ;
4171 udfcordd2c WITH toEiSPtd.udfcordd2c
4172
4173 tnRfShp_Pkey = tnRfShp_Pkey + 1
4174 ELSE
4175 REPLACE ;
4176 last_mod WITH DATETIME(), ;
4177 udfcordd1c WITH toEiSPtd.udfcordd1c, ;
4178 udfcordd2c WITH toEiSPtd.udfcordd2c IN 'Vzzyrfshp_iSPProc'
4179 ENDIF
4180 *=== TechRec 1057959 07-Dec-2011 TShenbagavalli ===
4181
4182
4183 SELECT (lnSelect)
4184 RETURN llRetVal
4185
4186 ENDPROC
4187
4188 PROCEDURE UpdateZzoctnph
4189 LPARAMETERS toEiSPtCtn, tcEispto, tnCarton_seq, tnShipment_num, tnOordsp_pkey, tnCntr_usg, tnRfShp_Pkey, ;
4190 tnCtnph_Pkey, tcCalledFrom, tnControl_Key
4191
4192 *--- TR 1065007 13-Jan-2014 Goutam. Added parameter tnControl_Key
4193
4194 LOCAL llRetVal, lnSelect, lcLocation
4195
4196 llRetVal = true
4197 lnSelect = SELECT()
4198
4199 SELECT 'Vzzoctnph_iSPproc'
4200 APPEND BLANK
4201 BLANK
4202 IF SEEK(loEisptCtn.Okey, tcEispto, 'PKEY')
4203 lcLocation = SysGetFieldValue(tcEispto, "SHIPTO")
4204 ELSE
4205 lcLocation = ""
4206 ENDIF
4207
4208 REPLACE;
4209 carton_num WITH toEiSPtCtn.carton_num, ;
4210 carton_wgt WITH toEiSPtCtn.carton_wgt, ;
4211 carton_seq WITH tnCarton_seq, ;
4212 track_no WITH '', ;
4213 proc_856 WITH 'N', ;
4214 date_856 WITH {//}, ;
4215 user_id WITH g_cuser, ;
4216 last_mod WITH DATETIME(), ;
4217 pkey WITH tnCtnph_Pkey, ;
4218 shipped WITH 'N', ;
4219 fkey with tnOordsp_pkey, ;
4220 carton_code WITH '', ;
4221 carton_ref WITH '', ;
4222 carton_cls WITH 'F', ;
4223 location WITH lcLocation, ;
4224 loc_id WITH '', ;
4225 pick_user WITH g_cuser, ;
4226 pack_user WITH g_cuser, ;
4227 pack_date WITH DATE(), ;
4228 carton_udf1 WITH '', ;
4229 carton_udf2 WITH '', ;
4230 hasnotes WITH 'N', ;
4231 shipment_num WITH tnShipment_num, ;
4232 pallet WITH '', ;
4233 ack_prn WITH '', ;
4234 carton_udf3 WITH '', ;
4235 bol_ok WITH 'N', ;
4236 carton_vol WITH toEiSPtCtn.carton_vol, ;
4237 verify_status WITH '', ;
4238 cont_typenum WITH 0, ;
4239 fill_perc WITH 0, ;
4240 ctn_stage WITH 'SHIP', ;
4241 cart_num WITH '', ;
4242 verify_user with '', ;
4243 last_verified WITH {//}, ;
4244 obr_proc WITH '', ;
4245 goh_chk WITH 0, ;
4246 canpar_smart WITH '', ;
4247 pallet_Date WITH {//}, ;
4248 carton_seq_manual WITH 0, ;
4249 truck_num WITH '', ;
4250 decl_value WITH 0, ;
4251 tare_num WITH '' , ;
4252 pallet with toEiSPtCtn.pallet &&--- TechRec 1067730 28-May-2013 vkrishnamurthy ===
4253
4254 *--- TR 1065007 13-Jan-2014 Goutam
4255 IF SEEK(tnControl_Key, "zzeispcr", "PKEY") AND zzeispcr.UOM_Recal = 'Y'
4256 IF !EMPTY(toEiSPtCtn.carton_vol) AND !EMPTY(toEiSPtCtn.UOM_Volume)
4257 lnConvValue = vl_suomc(toEiSPtCtn.UOM_Volume,"uom_factor",,this.cToUOMVolume)
4258 replace carton_vol WITH carton_vol*lnConvValue IN Vzzoctnph_iSPproc
4259 ENDIF
4260 IF !EMPTY(toEiSPtCtn.carton_wgt) AND !EMPTY(toEiSPtCtn.UOM_Weight)
4261 lnConvValue = vl_suomc(toEiSPtCtn.UOM_Weight,"uom_factor",,this.cToUOMWeight)
4262 replace carton_wgt WITH carton_wgt*lnConvValue IN Vzzoctnph_iSPproc
4263 ENDIF
4264 ENDIF
4265 *=== TR 1065007 13-Jan-2014 Goutam
4266
4267 *--- Unique Key carton_num, shipment_num, cntr_num, cntr_usg
4268 *-- Inserting in zzyrfshp
4269
4270 * SELECT shipment_num ;
4271 FROM Vzzyrfshp_iSPProc ;
4272 WHERE Shipment_num = tnShipment_num and ;
4273 carton_num = toEiSPtCtn.carton_num and ;
4274 cntr_num = toEiSPtCtn.cntr_num and ;
4275 cntr_usg = tnCntr_usg ;
4276 INTO CURSOR 'tcrfShp'
4277* INDEX ON PADL(shipment_num,10)+carton_num+cntr_num+PADL(cntr_usg,10) TAG rf_chk
4278* IF tcCalledFrom = 'B' AND ;
4279* NOT SEEK(PADL(tnShipment_num,10)+toEiSPtCtn.carton_num+toEiSPtCtn.cntr_num+PADL(tnCntr_usg,10),"Vzzyrfshp_iSPProc","rf_chk")
4280
4281 IF NOT SEEK(PADL(tnShipment_num,10)+toEiSPtCtn.carton_num+toEiSPtCtn.cntr_num+PADL(tnCntr_usg,10),"Vzzyrfshp_iSPProc","rf_chk")
4282
4283 SELECT Vzzyrfshp_iSPProc
4284 APPEND BLANK
4285 BLANK
4286
4287 REPLACE ;
4288 shipment_num WITH tnShipment_num, ;
4289 carton_num WITH toEiSPtCtn.carton_num, ;
4290 cntr_num WITH toEiSPtCtn.cntr_num, ;
4291 cntr_usg WITH tnCntr_usg, ;
4292 pkey WITH tnRfShp_Pkey, ;
4293 user_id WITH g_cUser, ;
4294 last_mod WITH DATETIME()
4295
4296 tnRfShp_Pkey = tnRfShp_Pkey + 1
4297
4298 ENDIF
4299
4300 SELECT (lnSelect)
4301 RETURN llRetVal
4302
4303 ENDPROC
4304
4305
4306 PROCEDURE UpdateVzzoordspF
4307 LPARAMETERS tccntr_num, tnOordsp_pkey, tnCntr_usg, tnProd_num
4308
4309 LOCAL llRetVal, lnSelect
4310
4311 llRetVal = true
4312 lnSelect = SELECT()
4313
4314 llRetVal = llRetVal AND v_sqlexec("SELECT * FROM zzoordsp WHERE " + ;
4315 " prod_num = " + SQLFormatNum(tnProd_num) + ;
4316 " AND cntr_num = " + SQLFormatChar(tccntr_num) + ;
4317 " AND cntr_usg = " + SQLFormatNum(tnCntr_usg) + ;
4318 " AND carton_cls = 'F'","tcSPExists")
4319
4320
4321 IF llRetVal AND USED("tcSPExists") AND RECCOUNT("tcSPExists") > 0
4322 tnOordsp_pkey = tcSPExists.pkey
4323 ELSE
4324
4325 *--Inserting Second record
4326 SELECT Vzzoordsp_iSPProc
4327 APPEND BLANK
4328 BLANK
4329
4330 REPLACE ;
4331 cntr_num WITH tccntr_num, ;
4332 cntr_usg WITH tnCntr_usg, ;
4333 cartons WITH 'N', ;
4334 carton_cls WITH 'F', ;
4335 prod_num WITH tnProd_num, ;
4336 carton_seq WITH 1, ;
4337 pack_seq WITH 0, ;
4338 packs WITH 'N', ;
4339 cncl_num WITH 0, ;
4340 inv_num WITH 0, ;
4341 pkey WITH tnOordsp_pkey, ;
4342 last_mod WITH DATETIME(), ;
4343 user_id WITH g_cUser, ;
4344 pick_num WITH 0, ;
4345 ord_num WITH 0
4346
4347 ENDIF
4348
4349 SELECT (lnSelect)
4350 RETURN llRetVal
4351
4352 ENDPROC
4353
4354 PROCEDURE UpdateVzzoordspP
4355 LPARAMETERS tccntr_num, tnOordsp_pkey, tnCntr_usg, tnProd_num
4356
4357 LOCAL llRetVal, lnSelect
4358
4359 llRetVal = true
4360 lnSelect = SELECT()
4361
4362 *--Inserting first record
4363
4364 SELECT Vzzoordsp_iSPProc
4365 APPEND BLANK
4366 BLANK
4367
4368 REPLACE ;
4369 cntr_num WITH tccntr_num, ;
4370 cntr_usg WITH tnCntr_usg, ;
4371 cartons WITH 'N', ;
4372 carton_cls WITH 'P', ;
4373 prod_num WITH tnProd_num, ;
4374 carton_seq WITH 1, ;
4375 pack_seq WITH 0, ;
4376 packs WITH 'N', ;
4377 cncl_num WITH 0, ;
4378 inv_num WITH 0, ;
4379 pkey WITH tnOordsp_pkey, ;
4380 last_mod WITH DATETIME(), ;
4381 user_id WITH g_cUser, ;
4382 pick_num WITH 0, ;
4383 ord_num WITH 0
4384
4385
4386 SELECT (lnSelect)
4387 RETURN llRetVal
4388
4389 ENDPROC
4390
4391 PROCEDURE UpdateZzmcntnr
4392 LPARAMETERS toEiSPtc, tnCntr_usg, tnCntr_pkey, tnShipment_num, tnControl_Key
4393 *--- TR 1065007 13-Jan-2014 Goutam. Added tnControl_Key as parameter
4394
4395 LOCAL llRetVal, lnSelect
4396
4397 *--- TR 1065007 13-Jan-2014 Goutam.
4398 LOCAL lnConvValue
4399 *=== TR 1065007 13-Jan-2014 Goutam.
4400
4401 llRetVal = true
4402 lnSelect = SELECT()
4403
4404 SELECT Vzzmcntnr_iSPproc
4405 APPEND BLANK
4406 BLANK
4407
4408 REPLACE;
4409 cntr_num WITH toEiSPtc.cntr_num, ;
4410 cont_size WITH toEiSPtc.cont_size, ;
4411 cntr_bol WITH toEiSPtc.cntr_bol, ;
4412 seal_num WITH toEiSPtc.seal_num, ;
4413 cntr_volume WITH toEiSPtc.cntr_volume, ;
4414 cntr_weight WITH toEiSPtc.cntr_weight, ;
4415 cs_exam_date WITH toEiSPtc.cs_exam_date, ;
4416 cs_rels_num WITH toEiSPtc.cs_rels_num, ;
4417 pkey WITH tnCntr_pkey, ;
4418 user_id WITH g_cUser, ;
4419 last_mod WITH DATETIME(), ;
4420 cntr_usg WITH tnCntr_usg, ;
4421 cntr_stage WITH '', ;
4422 location WITH toEiSPtc.location,;
4423 shipment_num WITH tnShipment_num ,;
4424 UOM_WEIGHT WITH toEiSPtc.UOM_WEIGHT , ; && TR 1070281 FH
4425 UOM_VOLUME WITH toEiSPtc.UOM_VOLUME && TR 1070281 FH
4426
4427 *--- TR 1065007 13-Jan-2014 Goutam
4428 IF SEEK(tnControl_Key, "zzeispcr", "PKEY") AND zzeispcr.UOM_Recal = 'Y'
4429 IF !EMPTY(toEiSPtc.cntr_volume) AND !EMPTY(toEiSPtc.UOM_VOLUME)
4430 lnConvValue = vl_suomc(toEiSPtc.UOM_VOLUME,"uom_factor",,this.cToUOMVolume)
4431 replace cntr_volume WITH cntr_volume*lnConvValue IN Vzzmcntnr_iSPproc
4432 ENDIF
4433 IF !EMPTY(toEiSPtc.cntr_weight) AND !EMPTY(toEiSPtc.UOM_WEIGHT)
4434 lnConvValue = vl_suomc(toEiSPtc.UOM_WEIGHT,"uom_factor",,this.cToUOMWeight)
4435 replace cntr_weight WITH cntr_weight *lnConvValue IN Vzzmcntnr_iSPproc
4436 ENDIF
4437 ENDIF
4438 *=== TR 1065007 13-Jan-2014 Goutam
4439
4440 SELECT (lnSelect)
4441 RETURN llRetVal
4442
4443 ENDPROC
4444
4445 *--- TR 1037787 7-Apr-2009 Goutam
4446 PROCEDURE CallGITProcess
4447
4448 LOCAL llRetVal, lnSelect, lcMsgFromGIT
4449
4450 llRetVal = true
4451 lnSelect = SELECT()
4452
4453 *- Create filter expression
4454 .cSQLTempTable=""
4455 IF RECCOUNT('tceGIT')> 0 AND .GenerateSQLTempTable('tceGIT') AND .PopulateSQLTempTable('tceGIT') AND !EMPTY(.cSQLTempTable)
4456
4457 lcMsgFromGIT = .cMsgFromGIT
4458 .oLog.LogMajorStage("Running the GIT process.")
4459 .InitThermo(1)
4460 .UpdateThermoCaption("Running the GIT process.")
4461 *- Parameters:
4462 *- 1. Filter - empty
4463 *- 2. Name of the table that contains the requests
4464 *- 3. Is the process ran in user interface mode.
4465
4466 .oGITProcess.cSQL856TmpTable = .cSQLTempTable
4467 .cSQLTempTable = ""
4468 .oGITProcess.oLog = THIS.oLog
4469
4470 .oGITProcess.lFrom856i = .T.
4471 *.oGITProcess.ProcessGoodsInTransit("", tceisptn, @lcMsgFromGIT, This.lUserInterface)
4472 .oGITProcess.ProcessGoodsInTransit("")
4473 .cMsgFromGIT = .oGITProcess.cMessage
4474
4475 IF !EMPTY(.cMsgFromGIT)
4476 .cMsgFromGIT = CRLF + "-- GIT Process --" + CRLF + .cMsgFromGIT
4477 ENDIF
4478 .AdvanceThermoTotal(1)
4479 ELSE
4480 .cMessage = .cMessage + CRLF + "Nothing to process in the Goods In Transit Process."
4481 ENDIF
4482 SELECT (lnSelect)
4483 RETURN llRetVal
4484 ENDPROC
4485
4486 Procedure PrepareFileForGIT
4487 PARAMETERS tcTranHeader, tcTranCarton, tceGIT
4488 *- All records in transaction header with no errors
4489
4490 *--- TR 1080664 28-Nov-2014 Goutam. Added skip_opt_stage
4491 *--- TR 1082847 31-1-2015 VKK asn_type, If asn_type = 'DS' then make skip_opt_stage = 'Y'
4492 Select d.carton_num, asn_type, IIF(INLIST(asn_type,'DS','X1'),'Y', c.skip_opt_stage) Skip_opt_stage from (tcTranHeader) h JOIN (tcTranCarton) d ;
4493 ON d.fkey = h.pkey JOIN zzeispcr c ;
4494 ON h.Control_Key = c.pkey ;
4495 WHERE h.Errs_Flg_H <> "Y" AND ;
4496 (c.Auto_GT = 'Y' OR asn_type = 'DS' OR asn_type = 'X1') ; && *--- TR 1082847 31-1-2015 VKK auto gt must be y for these modes
4497 AND INLIST(asn_type, "", " ", "DS", "X1", "SH") AND git_ind = 1 ; && *--- TR 1082847 31-1-2015 VKK N oneed for X2 where,
4498 INTO Cursor (tceGIT)
4499
4500 RETURN .T.
4501 ENDPROC
4502
4503 Procedure UpdateControlKey
4504 PARAMETERS tcTranHeader
4505
4506 LOCAL llRetVal, lnOldSelect, lctmpCurs
4507
4508 llRetVal = .T.
4509 lnOldSelect = SELECT()
4510 lctmpCurs = GetUniqueFileName()
4511
4512 SELECT Distinct vnd_qual, vnd_id, our_qual, our_id, vnd_key, Control_Key FROM (tcTranHeader) ;
4513 INTO CURSOR __tmpSLSRef
4514
4515 .cSQLTempTable=""
4516 If .GenerateSQLTempTable('__tmpSLSRef')
4517 If .PopulateSQLTempTable('__tmpSLSRef')
4518 If !Empty(.cSQLTempTable)
4519 lcSqlString = "Update " + .cSQLTempTable + ;
4520 " Set Control_Key = coalesce((Select Top 1 pkey " + ;
4521 " From zzeispcr " + ;
4522 " Where vnd_qual = h.vnd_qual " + ;
4523 " and vnd_id = h.vnd_id " + ;
4524 " and (our_qual = h.our_qual or our_qual = '') " + ;
4525 " and (our_id = h.our_id or our_id = '') " + ;
4526 " and (vnd_key = h.vnd_key or vnd_key = '') " + ;
4527 " order by our_qual desc,our_id desc,vnd_key desc),'') " + ;
4528 " From " + .cSQLTempTable + " h"
4529
4530 llRetVal = v_sqlExec(lcSqlString)
4531
4532 IF llRetVal
4533 lcSqlString = "Select * from " + .cSQLTempTable
4534 llRetVal = v_sqlExec(lcSqlString, lctmpCurs)
4535
4536 lcSqlString = "UPDATE h " + ;
4537 " SET Control_Key = c.Control_Key " + ;
4538 " From " + tcTranHeader + " h, " + lctmpCurs + " c " + ;
4539 " Where h.vnd_qual = c.vnd_qual " + ;
4540 " And h.vnd_id = c.vnd_id " + ;
4541 " And h.our_qual = c.our_qual " + ;
4542 " And h.our_id = c.our_id " + ;
4543 " And h.vnd_key = c.vnd_key "
4544
4545 llRetVal = llRetVal and v_sqlexec(lcSqlString,,,true)
4546 ENDIF
4547
4548 *--- TR 1073515 22-Oct-2013 BNarayanan Validate vendor id and qualifier ---
4549 llRetVal = llRetVal and .ValidateEDIControl(tcTranHeader)
4550 *=== TR 1073515 22-Oct-2013 BNarayanan ===
4551 endif
4552 endif
4553 endif
4554 .cSQLTempTable=""
4555 .TableClose('__tmpSLSRef')
4556 .TableClose(lctmpCurs)
4557
4558 SELECT (lnOldSelect)
4559 RETURN llRetVal
4560 ENDPROC
4561
4562 *=== TR 1037787 7-Apr-2009 Goutam
4563
4564*----------------------------------------------------------------
4565 PROCEDURE ResolveCurrentProdLine
4566 *--- TR 1082847 16-2-2015 VKK added pceiSPTH
4567 LPARAMETERS pceiSPTD, pceiSPTH
4568
4569 LOCAL llRetVal, lcSQL, lnOldSelect,lcTmp
4570
4571 llRetVal = .T.
4572 lnOldSelect = SELECT()
4573
4574 WITH THIS
4575 *--- TR 1050514 14-12-2010 VKK
4576 lcTmp = ""
4577 *=== TR 1050514 14-12-2010 VKK
4578
4579 *--- TR 1082847 16-2-2015 VKK
4580 *SELECT pkey,prod_num,open_seq as prod_line FROM (pceiSPTD) WHERE errs_flg_d <> 'Y' INTO CURSOR __tmpProdLine
4581 *--- TR 1085844 20-Apr-2015 Goutam. Added d.shpm_ref,d.cntr_num in select
4582 SELECT d.shpm_ref,d.cntr_num,h.asn_type, d.pkey,prod_num,open_seq as prod_line FROM (pceiSPTD) d ;
4583 JOIN (pceiSPTH) h ON h.pkey = d.fkey ;
4584 WHERE d.errs_flg_d <> 'Y' INTO CURSOR __tmpProdLine
4585 *=== TR 1082847 16-2-2015 VKK
4586
4587 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4588 *llRetVal = llRetVal AND .GenerateSQLTempTable("__tmpProdLine") AND .PopulateSQLTempTable("__tmpProdLine")
4589 .cSQLTempTable = ""
4590 IF .GenerateSQLTempTable("__tmpProdLine") AND .PopulateSQLTempTable("__tmpProdLine")
4591 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4592
4593 lcTmp = "#" + getuniquefileName()
4594 *--- TR 1082847 16-2-2015 VKK Added asn_type
4595 *--- TR 1085844 20-Apr-2015 Goutam. Added b.shpm_ref and b.cntr_num
4596 lcSQL = ;
4597 "SELECT b.asn_type, a.prod_line,a.open_seq, b.pkey,a.tree_seq,a.prod_num, b.shpm_ref, b.cntr_num INTO " + lcTmp + ;
4598 " FROM zzcordrd a " + ;
4599 " JOIN " + .cSQLTempTable + " b ON a.prod_num = b.prod_num AND a.prod_line = b.prod_line "
4600 llRetVal = llRetVal AND v_sqlexec(lcSQL)
4601
4602 *--- TR 1085844 20-Apr-2015 Goutam. Addeed zzmshpmh table
4603 lcSQL = ;
4604 " SELECT h.pkey,COALESCE((SELECT TOP 1 prod_line " + ;
4605 " FROM zzcordrd d " + ;
4606 " left join zzmshpmh mh on mh.shipment_num = d.shp_seq " +; &&*--- TR 1085844 20-Apr-2015 Goutam.
4607 " WHERE d.prod_num = h.prod_num " + ;
4608 " AND d.tree_Seq like RTRIM(h.tree_Seq) + '%' " + ;
4609 " and d.cntr_num = case when (h.asn_type = 'X2' and h.cntr_num > '') then h.cntr_num else d.cntr_num end " + ; &&*--- TR 1085844 20-Apr-2015 Goutam.
4610 " AND coalesce(mh.shpm_ref,'') = case when (h.asn_type = 'X2' and h.shpm_ref > '') then h.shpm_ref else coalesce(mh.shpm_ref,'') end " + ; &&*--- TR 1085844 20-Apr-2015 Goutam.
4611 " AND d.last_stage <> Case when h.asn_type NOT IN('X3') THEN 'Y' ELSE 'X' END " + ; && *--- TR 1082847 16-2-2015 VKK adde case
4612 " AND d.shp_ok <> Case when h.asn_type NOT IN('X2','X3') THEN 'Y' ELSE 'X' END " + ; && *--- TR 1082847 16-2-2015 VKK adde case
4613 " ORDER BY d.stage_num DESC, d.tree_Seq DESC),0) as new_prod_line " + ;
4614 " FROM " + lcTmp + " h "
4615
4616 llRetVal = llRetVal AND v_sqlexec(lcSQL,'tcNewProdLine')
4617
4618 IF llRetVal AND USED("tcNewProdLine")
4619
4620 UPDATE h ;
4621 SET open_seq = x.new_prod_line ;
4622 FROM (pceiSPTD) h ;
4623 JOIN tcNewProdLine x ON h.pkey = x.pkey WHERE x.new_prod_line > 0
4624
4625
4626 UPDATE h ;
4627 SET errs_flg_d = 'Y', ;
4628 errs_msg_d = 'Could not resolve PO line.' ;
4629 FROM (pceiSPTD) h ;
4630 JOIN tcNewProdLine x ON h.pkey = x.pkey WHERE x.new_prod_line = 0
4631
4632 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4633 USE IN SELECT("tcNewProdLine")
4634 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4635
4636 ENDIF
4637
4638 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4639 ENDIF
4640 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4641
4642 *USE IN SELECT("tcNewProdLine") && moved above --- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4643 USE IN SELECT("__tmpProdLine")
4644
4645 v_sqlexecnoerror("DROP TABLE " + .cSQLTempTable)
4646 v_sqlexecnoerror("DROP TABLE " + lcTmp)
4647
4648
4649 ENDWITH
4650
4651 SELECT (lnOldSelect)
4652 RETURN llRetVal
4653 ENDPROC
4654
4655 *------------------------------------------------------------
4656 PROCEDURE ImplodeCartonDetailByProdLine
4657 LPARAMETERS pceiSPTD
4658
4659 LOCAL llRetVal, lcSQL, lnOldSelect,lcTmp,lnProdNum,lnProdLine
4660
4661 llRetVal = .T.
4662 lnOldSelect = SELECT()
4663
4664 WITH THIS
4665 SELECT DISTINCT prod_num,open_seq as prod_line FROM (pceiSPTD) INTO CURSOR __ImpodePO WHERE errs_flg_d <> 'Y'
4666 llRetVal = llRetVal AND .GenerateSQLTempTable("__ImpodePO") AND .PopulateSQLTempTable("__ImpodePO")
4667
4668
4669 * Note for when moving to QA. Need to add logic to verify it is a range style or prepack and not just a blind assumption.
4670
4671 lcSQL = ;
4672 " SELECT d.prod_line,d.prod_num,u.upc_num + u.chk_digit as upc " + ;
4673 " FROM zzcordrd d " + ;
4674 " JOIN zzcordrh h ON d.fkey = h.pkey " + ;
4675 " JOIN zzxbuckt b ON 1 = 1 " + ;
4676 " JOIN zzeupcnr u ON d.division = u.division AND d.style = u.style AND d.color_code = u.color_code AND " + ;
4677 " d.lbl_code = u.lbl_code AND d.dimension = u.dimension AND u.sizebucket = b.size_num " + ;
4678 " JOIN zzxstylr st ON d.division = st.division AND d.style = st.style " + ;
4679 " join zzxscolr sc ON d.division = sc.division AND sc.style = sc.style AND d.color_code = sc.color_code AND " + ;
4680 " d.lbl_code = sc.lbl_code AND d.dimension = sc.dimension " + ;
4681 " JOIN zzxsizer sz ON st.division = sz.division AND st.size_code = sz.size_code " + ;
4682 " JOIN " + .cSQLTempTable + " x ON d.prod_num = x.prod_num AND d.prod_line = x.prod_line "
4683 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcPPK")
4684
4685 * Make sure there is only one upc per PO. If there is more than one, eliminate from results.
4686 DELETE FROM tcPPK WHERE prod_num IN (SELECT prod_num FROM tcPPK GROUP BY prod_num,prod_line HAVING COUNT(*) > 1)
4687
4688 SELECT CARTON_NUM,CKEY,CNTR_NUM,CTNKEY,DOC_NUM,FKEY,OKEY,OPEN_SEQ,SHPM_REF,p.PROD_NUM,MAX(PKEY) as pkey,SUM(QTY) as qty,p.upc;
4689 FROM (pceiSPTD) h ;
4690 JOIN tcPPK p ON h.prod_num = p.prod_num AND h.open_seq = p.prod_line ;
4691 GROUP BY CARTON_NUM,CKEY,CNTR_NUM,CTNKEY,DOC_NUM,FKEY,OKEY,OPEN_SEQ,SHPM_REF,p.PROD_NUM,p.upc;
4692 INTO CURSOR tcImploded
4693
4694
4695 SELECT tcImploded
4696 SCAN
4697 lnProdNum = tcImploded.prod_num
4698 lnProdLine= tcImploded.open_seq
4699
4700 DELETE FROM (pceiSPTD) WHERE prod_num = lnProdNum AND open_seq = lnProdLine AND CTNKEY = tcImploded.CTNKEY
4701
4702 ENDSCAN
4703
4704 SELECT tcImploded
4705 SCAN
4706
4707 SCATTER NAME loCtn MEMO
4708 SELECT (pceiSPTD)
4709 APPEND BLANK
4710 GATHER NAME loCtn MEMO
4711
4712 ENDSCAN
4713
4714 v_sqlexecnoerror("DROP TABLE " + .cSQLTempTable)
4715 USE IN SELECT("tcImploded")
4716 USE IN SELECT("tcPPK")
4717 USE IN SELECT("__ImpodePO")
4718 ENDWITH
4719
4720 SELECT (lnOldSelect)
4721 RETURN llRetVal
4722 ENDPROC
4723
4724
4725 *--------------------------------------------------------------------------
4726 * Instance level version of createSQL view. If we are not in passthrough mode, simply call DODEFAULT
4727 * If we are in passthrough mode, write viewname and definition to array. OPENTABLE will execute the SQL.
4728 FUNCTION CreateSQLView
4729 LPARAMETERS tcViewName, tcSqlStr, tcTable, tcOrderBy, tcPkey, tcViewDBCName
4730
4731 LOCAL llRetVal,lnArrayRow
4732 llRetVal = .T.
4733
4734
4735 IF NOT THIS.lUsePassThrough
4736 llRetVal = DODEFAULT(tcViewName, tcSqlStr, tcTable, tcOrderBy, tcPkey, tcViewDBCName)
4737 ELSE
4738 WITH THIS
4739 lnArrayRow = ALEN(.aViews,1)
4740
4741 tcOrderBy = IIF(EMPTY(tcOrderBy),"",tcOrderBy)
4742 tcOrderBy = IIF(UPPER(tcOrderBy)=="NOORDERBY","",tcOrderBy)
4743
4744 IF lnArrayRow > 1 OR NOT EMPTY(.aViews[1,1])
4745 lnArrayRow = lnArrayRow + 1
4746 DIMENSION .aViews[(lnArrayRow),3]
4747 ENDIF
4748
4749 .aViews[lnArrayRow,1] = LOWER(ALLTRIM(tcViewName))
4750 .aViews[lnArrayRow,2] = tcSqlStr
4751 .aViews[lnArrayRow,3] = tcOrderBy
4752
4753 ENDWITH
4754 ENDIF
4755
4756
4757 RETURN llRetVal
4758
4759 ENDFUNC
4760
4761 *-----------------------------------------------------------------------------------
4762 * This class no longer uses buffered views. To get around this, we created an instance
4763 * level version of this method. If using buffered views, then dodefault, otherwise read
4764 * the aViews array, and execute the SQL to build the cursor
4765 *
4766 FUNCTION OPENTABLE
4767 LPARAMETERS pcTable, plNotUpdatable, plNotNodata, ;
4768 pcPkey, pnCursorBuffer, pcTimeStamp, plOverWrite, plSelectOpenTable
4769
4770 LOCAL llRetVal,lnRow,lcSQL,lcOrderBy,lnX
4771 llRetVal = .T.
4772 lnRow = 0
4773 lcOrderBy = ""
4774
4775 IF NOT THIS.lUsePassThrough
4776 llRetVal = DODEFAULT(pcTable, plNotUpdatable, plNotNodata, ;
4777 pcPkey, pnCursorBuffer, pcTimeStamp, plOverWrite, plSelectOpenTable )
4778 ELSE
4779
4780 WITH THIS
4781
4782 pcTable = ALLTRIM(LOWER(pcTable))
4783
4784 * Using a FOR LOOP here. Will replace with better method later.
4785 FOR lnX = 1 TO ALEN(.aViews,1)
4786 IF pcTable == .aViews[lnX ,1]
4787 lnRow = lnX
4788 EXIT
4789 ENDIF
4790 ENDFOR
4791
4792 IF lnRow > 0
4793 * IF the view is not found, we do not error out, just do nothing.
4794
4795 IF NOT EMPTY(.aViews[lnRow,3])
4796 lcOrderBy = " ORDER BY " + .aViews[lnRow,3]
4797 ENDIF
4798 lcSQL = .aViews[lnRow,2] + lcOrderBy
4799
4800 IF NOT plNotNodata
4801 * Confusing variable, but being in this clause means we want only metadata back
4802 llRetVal = llRetVal AND v_sqlexec("SET FMTONLY ON")
4803 ENDIF
4804
4805 USE IN SELECT(pcTable)
4806 llRetVal = llRetVal AND v_sqlexec(lcSQL,pcTable)
4807
4808 IF llRetVal
4809 * This will turn buffering completely off.
4810 SELECT * INTO CURSOR (pcTable) READWRITE FROM (pcTable)
4811 ENDIF
4812
4813 IF plNotNodata
4814 llRetVal = llRetVal AND v_sqlexec("SET FMTONLY OFF")
4815 ENDIF
4816
4817 ENDIF
4818
4819 ENDWITH
4820
4821 ENDIF
4822
4823 RETURN llRetVal
4824
4825 ENDPROC
4826
4827
4828 *---------------------------------------------------------
4829 * Loop through the array of tables. Send to TableUpdateFromCursorOne
4830 FUNCTION TableUpdateFromCursor
4831 LPARAMETERS paTables
4832
4833 LOCAL llRetVal,lnTableCount,lnX,lcTable,lcView
4834 llRetVal = .T.
4835
4836 lnTableCount = ALEN(paTables,1)
4837 FOR lnX = 1 TO lnTableCount
4838 lcView = paTables[lnX]
4839 lcTable= SUBSTR(lcView,2,8)
4840 llRetVal = llRetVal AND THIS.TableUpdateFromCursorOne(lcTable,lcView)
4841 ENDFOR
4842
4843 RETURN llRetVal
4844
4845 ENDFUNC
4846
4847 *---------------------------------------------------------
4848 * Taken from AlloAval.prg. Insert all records from a cursor into a table.
4849 PROCEDURE TableUpdateFromCursorOne
4850 LPARAMETERS tcTarget, tcSource
4851 LOCAL llRetVal, lnSelect, lcSource, lcSQL
4852
4853 llRetVal = .T.
4854 lnSelect = SELECT()
4855
4856 IF EMPTY(tcSource)
4857 lcSource = ALIAS()
4858 ELSE
4859 lcSource = ALLTRIM(tcSource)
4860 ENDIF
4861
4862 IF USED(lcSource)
4863
4864 SELECT (lcSource)
4865 lcSQL = BuildInsertString(tcTarget,lcSource)
4866
4867 SELECT (lcSource)
4868 GO TOP
4869 SCAN WHILE llRetVal
4870 llRetVal = llRetVal AND v_SQLExec(lcSQL)
4871 ENDSCAN
4872
4873 ELSE
4874 llRetVal = .F.
4875 ENDIF
4876
4877 SELECT (lnSelect)
4878 RETURN llRetVal
4879 ENDPROC
4880
4881 *---------------------------------------------
4882 PROCEDURE GetNextCartonNum
4883 *--- TR 1082847 31-1-2015 VKK
4884 LPARAMETERS tcAsn_Type
4885 *=== TR 1082847 31-1-2015 VKK
4886
4887 LOCAL lcCartoNum,llRetVal,lnSelect,lcSQL, lcMfgId,lnMaxUCCNum,lnLenUCCNum,lnLenMfgId,lnUCC128
4888 lcCartoNum = ""
4889 lnSelect = SELECT()
4890 llRetVal = .T.
4891
4892 lcMfgId= ALLTRIM(goEnv.SV("856I_MFG_ID","999999"))
4893 lnLenMfgId = LEN(lcMfgId)
4894 *--- TechRec 1050514 01-Dec-2010 jisingh ---
4895 *lnMaxUCCNum= Iif(lnLenMfgId= 6, 999999999, 9999999)
4896 *lnLenUCCNum= Iif(lnLenMfgId= 6, 9, 7)
4897
4898 lnMaxUCCNum = INT(VAL(PADL("", 15 - lnLenMfgId, "9")))
4899 lnLenUCCNum = 15 - lnLenMfgId
4900 *=== TechRec 1050514 01-Dec-2010 jisingh ===
4901
4902 lcSQL = ;
4903 "bcsp_getmfgid " + SQLFormatChar(lcMfgId)+ ",0,"+ ;
4904 SQLFormatNum(lnMaxUCCNum)
4905
4906 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__next_carton")
4907 IF llRetVal
4908 lnUCC128 = __next_carton.UCC128
4909
4910 *--- TR 1082847 31-1-2015 VKK
4911 *lcCartoNum = Allt(lcMfgId) + Padl(lnUCC128, lnLenUCCNum, "0") && PL 01/10/02 30171- Expand mfgid to 8 digit
4912
4913 IF tcAsn_Type = "X1" && Fake Carton
4914 lnLenUCCNum = 15 - LEN(FAKE_CARTON_PREFIX)
4915 lcCartoNum = Allt(FAKE_CARTON_PREFIX) + Padl(lnUCC128, lnLenUCCNum, "0")
4916 ELSE
4917 lcCartoNum = Allt(lcMfgId) + Padl(lnUCC128, lnLenUCCNum, "0")
4918 ENDIF
4919 *=== TR 1082847 31-1-2015 VKK
4920
4921 lcCartoNum = lcCartoNum + This.UCCChkDigit(lcCartoNum)
4922 ENDIF
4923
4924 USE IN SELECT("__next_carton")
4925
4926 SELECT(lnSelect)
4927 RETURN lcCartoNum
4928
4929 ENDPROC
4930
4931 *--------------------------------------------------
4932 PROCEDURE ValidateProductionSku
4933 LPARAMETERS pceiSPTH, pceiSPTO, pceiSPTD
4934
4935 LOCAL llRetVal, lcSQL, lnOldSelect,lcTmp,lnProdNum,lnProdLine
4936
4937 *--- TR 1082596 11-Nov-2014 Goutam
4938 LOCAL lcSizeString, l_cBucketNum
4939 lcSizeString = ""
4940 *=== TR 1082596 11-Nov-2014 Goutam
4941
4942 llRetVal = .T.
4943 lnOldSelect = SELECT()
4944
4945 WITH THIS
4946 SELECT pkey,prod_num,open_seq as prod_line,style,color_code,lbl_code,dimension,sizebucket FROM (pceiSPTD) INTO CURSOR __sku WHERE errs_flg_d <> 'Y'
4947
4948 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4949 *llRetVal = llRetVal AND .GenerateSQLTempTable("__sku") AND .PopulateSQLTempTable("__sku")
4950 .cSQLTempTable = ""
4951 IF .GenerateSQLTempTable("__sku") AND .PopulateSQLTempTable("__sku") AND !EMPTY(.cSQLTempTable)
4952 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
4953
4954 * Note for when moving to QA. Need to add logic to verify it is a range style or prepack and not just a blind assumption.
4955
4956 *--- TR 1082596 11-Nov-2014 Goutam
4957 FOR lnTotalSizes = 1 TO goEnv.MaxBuckets - 1
4958 l_cBucketNum = TRANSFORM(lnTotalSizes, "@L 99")
4959 lcSizeString = lcSizeString + " WHEN " + l_cBucketNum + " THEN savl.call" + l_cBucketNum
4960 NEXT
4961 lcSizeString = lcSizeString + " else savl.call" + TRANSFORM(goEnv.MaxBuckets, "@L 99") + " end = 'Y'"
4962 *=== TR 1082596 11-Nov-2014 Goutam
4963
4964 *--- TR 1082596 11-Nov-2014 Goutam
4965*!* lcSQL = ;
4966*!* " SELECT x.pkey " + ;
4967*!* " FROM zzcordrd d " + ;
4968*!* " JOIN zzcordrh h ON d.fkey = h.pkey " + ;
4969*!* " JOIN zzxbuckt b ON 1 = 1 " + ;
4970*!* " JOIN " + .cSQLTempTable + " x " + ;
4971*!* " ON d.prod_num = x.prod_num " + ;
4972*!* " AND d.prod_line = x.prod_line " + ;
4973*!* " AND d.style = x.style " + ;
4974*!* " AND d.color_code = x.color_code " + ;
4975*!* " AND d.lbl_code = x.lbl_code " + ;
4976*!* " AND d.dimension = x.dimension " + ;
4977*!* " AND b.size_num = x.sizebucket " + ;
4978*!* " JOIN zzxscolr savl " + ;
4979*!* " ON savl.division = d.division " + ;
4980*!* " AND savl.style = d.style " + ;
4981*!* " AND savl.color_code = d.color_code " + ;
4982*!* " AND savl.lbl_code = d.lbl_code " + ;
4983*!* " AND savl.dimension = d.dimension " + ;
4984*!* " AND CASE b.size_num " + ;
4985*!* " WHEN 01 THEN savl.call01 WHEN 02 THEN savl.call02 " + ;
4986*!* " WHEN 03 THEN savl.call03 WHEN 04 THEN savl.call04 " + ;
4987*!* " WHEN 05 THEN savl.call05 WHEN 06 THEN savl.call06 " + ;
4988*!* " WHEN 07 THEN savl.call07 WHEN 08 THEN savl.call08 " + ;
4989*!* " WHEN 09 THEN savl.call09 WHEN 10 THEN savl.call10 " + ;
4990*!* " WHEN 11 THEN savl.call11 WHEN 12 THEN savl.call12 " + ;
4991*!* " WHEN 13 THEN savl.call13 WHEN 14 THEN savl.call14 " + ;
4992*!* " WHEN 15 THEN savl.call15 WHEN 16 THEN savl.call16 " + ;
4993*!* " WHEN 17 THEN savl.call17 WHEN 18 THEN savl.call18 " + ;
4994*!* " WHEN 19 THEN savl.call19 WHEN 20 THEN savl.call20 " + ;
4995*!* " WHEN 21 THEN savl.call21 WHEN 22 THEN savl.call22 " + ;
4996*!* " WHEN 23 THEN savl.call23 else savl.call24 end = 'Y' "
4997
4998
4999 lcSQL = ;
5000 " SELECT x.pkey " + ;
5001 " FROM zzcordrd d " + ;
5002 " JOIN zzcordrh h ON d.fkey = h.pkey " + ;
5003 " JOIN zzxbuckt b ON 1 = 1 " + ;
5004 " JOIN " + .cSQLTempTable + " x " + ;
5005 " ON d.prod_num = x.prod_num " + ;
5006 " AND d.prod_line = x.prod_line " + ;
5007 " AND d.style = x.style " + ;
5008 " AND d.color_code = x.color_code " + ;
5009 " AND d.lbl_code = x.lbl_code " + ;
5010 " AND d.dimension = x.dimension " + ;
5011 " AND b.size_num = x.sizebucket " + ;
5012 " JOIN zzxscolr savl " + ;
5013 " ON savl.division = d.division " + ;
5014 " AND savl.style = d.style " + ;
5015 " AND savl.color_code = d.color_code " + ;
5016 " AND savl.lbl_code = d.lbl_code " + ;
5017 " AND savl.dimension = d.dimension " + ;
5018 " AND CASE b.size_num " + ;
5019 lcSizeString
5020
5021 *=== TR 1082596 11-Nov-2014 Goutam
5022
5023 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcProdSku")
5024
5025 SELECT tcProdSku
5026 INDEX ON pkey TAG pkey
5027
5028 UPDATE d ;
5029 SET errs_flg_d = 'Y', errs_msg_d = 'Carton Detail does not match Production Line.' + CRLF ;
5030 FROM (pceiSPTD) d WHERE !INDEXSEEK(d.pkey,.f.,"tcProdSku","pkey") AND errs_flg_d <> 'Y'
5031
5032 *--- TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
5033 ENDIF
5034 *=== TR 1047821 17-JUN-2010 Goutam./MANI. Merge The changes
5035
5036 ENDWITH
5037
5038
5039 SELECT (lnOldSelect)
5040 RETURN llRetVal
5041
5042 ENDPROC
5043
5044*============================================================
5045*--- TechRec 1037787 24-Jun-2009 vkrishnamurthy ---
5046 FUNCTION InsertHistoryTables
5047 LPARAMETERS pcAsnCondition && *--- TR 1082847 31-1-2015 VKK
5048 LOCAL llRetVal, lnSelect , lcFieldList ,lcSQLString
5049
5050 llRetVal = true
5051 lnSelect = SELECT()
5052
5053 WITH This
5054 lcFieldList = Fieldlistfromservertable("ZZEISPHH" , "H")
5055 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
5056 lcSQLString = " Insert into zzeisphh " + ;
5057 " select " + lcFieldList + " FROM zzeispth H " +;
5058 " JOIN " + .cSqlTempTable + " h1 " + ;
5059 " ON h.pkey = h1.pkey " + ;
5060 " AND h.errs_flg_h <> 'Y'" +;
5061 pcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
5062 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
5063
5064 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5065
5066 lcFieldList = Fieldlistfromservertable("ZZEISPHD" , "D")
5067 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
5068 lcSQLString = " Insert into zzeisphd " + ;
5069 " select " + lcFieldList + " FROM zzeisptd d " +;
5070 " JOIN " + .cSqlTempTable + " h " + ;
5071 " ON d.fkey = h.pkey " + ;
5072 " AND h.errs_flg_h <> 'Y'" +;
5073 pcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
5074 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
5075 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5076
5077 lcFieldList = Fieldlistfromservertable("ZZEISPHN" , "D")
5078 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
5079 lcSQLString = " Insert into zzeisphn " + ;
5080 " select " + lcFieldList + " FROM zzeisptn d " +;
5081 " JOIN " + .cSqlTempTable + " h " + ;
5082 " ON d.fkey = h.pkey " + ;
5083 " AND h.errs_flg_h <> 'Y'" +;
5084 pcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
5085 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
5086 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5087
5088 lcFieldList = Fieldlistfromservertable("ZZEISPHC" , "D")
5089 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
5090 lcSQLString = " Insert into zzeisphc " + ;
5091 " select " + lcFieldList + " FROM zzeisptc d " +;
5092 " JOIN " + .cSqlTempTable + " h " + ;
5093 " ON d.fkey = h.pkey " + ;
5094 " AND h.errs_flg_h <> 'Y'" +;
5095 pcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
5096 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
5097 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5098
5099 lcFieldList = Fieldlistfromservertable("ZZEISPHO" , "D")
5100 &&--- TechRec 1067730 15-Jul-2013 vkrishnamurthy === Added And (h.warn_flg_h <> 'Y' Or ignore_warn = 'Y')
5101 lcSQLString = " Insert into zzeispho " + ;
5102 " select " + lcFieldList + " FROM zzeispto d " +;
5103 " JOIN " + .cSqlTempTable + " h " + ;
5104 " ON d.fkey = h.pkey " + ;
5105 " AND h.errs_flg_h <> 'Y'" +;
5106 pcAsnCondition + ; && *--- TR 1082847 31-1-2015 VKK
5107 " And (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y') "
5108 llRetVal = llRetVal AND v_SQLExec(lcSQLString)
5109
5110 ENDWITH
5111
5112 SELECT (lnSelect)
5113 RETURN llRetVal
5114 ENDFUNC
5115
5116*=== TechRec 1037787 24-Jun-2009 vkrishnamurthy ===
5117
5118*============================================================
5119
5120*--- TR 1050836 27-Jul-2011 Partha ---
5121
5122 Procedure LoadHeaderDetailNotes
5123 Parameter tcHNTFlatFile, tcTransHdrNotes, tcDocCount, tcNotesFrom
5124 *--- TR 1076260 21-Mar-2014 Goutam. Added above parameter tcNotesFrom
5125
5126 Local llRetVal, lnOldSelect, lcNotes, llHaveNotes, lcCurrDoc_num, lcCurrNote_type, lcUser_ID, ltLast_mod, lnSeq
5127
5128 *--- TR 1076260 21-Mar-2014 Goutam
5129 LOCAL lcCondition, lcCurrProd_Num, lcSourceHeader, lcAddrTable
5130 *--- TR 1076260 21-Mar-2014 Goutam
5131
5132 lcUser_ID = EDI_USER
5133 ltLast_mod = Datetime()
5134 lnSeq = 0
5135 llRetVal = .T.
5136 lnOldSelect = Select()
5137
5138 With This
5139 * Accumulate all notes per doc_num and write them in proper
5140 * Trans Header notes record
5141 If Reccount(tcHNTFlatFile)>0
5142 .oLog.LogEntry("Loading header notes.")
5143 lcNotes= ""
5144 lcCurrDoc_num= ""
5145 lcCurrNote_type = ""
5146 lcCurrProd_Num = "" && TR 1077026 28-May-2014 Partha
5147
5148 llHaveNotes= .F.
5149 Select (tcHNTFlatFile)
5150
5151 *--- TR 1076260 21-Mar-2014 Goutam
5152 *Index On doc_num + note_type Tag doc_num
5153 DO CASE
5154 CASE tcNotesFrom = 'H'
5155 Index On doc_num + note_type Tag doc_num
5156 lcSourceHeader = "Vzzeispth_iSPproc"
5157 lcAddrTable = "ZZEISPTH"
5158 CASE tcNotesFrom = 'O'
5159 Index On doc_num + prod_num + note_type Tag doc_num
5160 lcSourceHeader = "Vzzeispto_iSPproc"
5161 lcAddrTable = "ZZEISPTO"
5162 ENDCASE
5163 *=== TR 1076260 21-Mar-2014 Goutam
5164
5165 SCAN
5166
5167 *--- TR 1076260 21-Mar-2014 Goutam
5168 DO CASE
5169 CASE tcNotesFrom = 'H'
5170 lcCondition = "lcCurrDoc_num = doc_num And lcCurrNote_type = note_type"
5171 CASE tcNotesFrom = 'O'
5172 lcCondition = "lcCurrDoc_num = doc_num And lcCurrProd_Num = Prod_Num And lcCurrNote_type = note_type"
5173 ENDCASE
5174 *--- TR 1076260 21-Mar-2014 Goutam
5175
5176 *--- TR 1076260 21-Mar-2014 Goutam
5177 *If lcCurrDoc_num = doc_num And lcCurrNote_type = note_type
5178 IF &lcCondition
5179 *=== TR 1076260 21-Mar-2014 Goutam
5180
5181 If !Empty(Notes)
5182 lcNotes = lcNotes + Alltrim(Notes) + CRLF && Accumulate all notes lines
5183 llHaveNotes = .T.
5184 Endif
5185 Else
5186 *--- doc_num changed or note_type changed
5187 If llHaveNotes
5188 lnSeq = lnSeq + 1
5189 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
5190
5191 *--- TR 1076260 21-Mar-2014 Goutam
5192 *.WriteHdrSysNotes(lcCurrDoc_num, STR(VAL(lcCurrDoc_num)), ;
5193 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
5194 tcTransHdrNotes, "Vzzeispth_iSPproc", lnDoc_count )
5195
5196 .WriteHdrSysNotes(lcCurrDoc_num, STR(VAL(lcCurrDoc_num)), ;
5197 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
5198 tcTransHdrNotes, lcSourceHeader, lnDoc_count, lcAddrTable)
5199 *=== TR 1076260 21-Mar-2014 Goutam
5200
5201 Endif
5202
5203 If Not lcCurrDoc_num = doc_num
5204 lnSeq = 0
5205 Endif
5206
5207 lcCurrDoc_num= doc_num
5208 lcCurrNote_type = note_type
5209
5210 *--- 1078769 10-Jul-2014 Goutam
5211 *lcCurrProd_Num = prod_num && TR 1077026 28-May-2014 Partha
5212 IF tcNotesFrom = 'O'
5213 lcCurrProd_Num = prod_num && TR 1077026 28-May-2014 Partha
5214 ENDIF
5215 *=== 1078769 10-Jul-2014 Goutam
5216
5217 If !Empty(Notes)
5218 lcNotes = Alltrim(Notes) + CRLF && Accumulate all notes lines
5219 llHaveNotes= .T.
5220 Else
5221 llHaveNotes= .F.
5222 Endif
5223 Endif
5224 Endscan
5225 If llHaveNotes
5226 lnSeq = lnSeq + 1
5227 lnDoc_count = .GetDocNumCount(tcDocCount, lcCurrDoc_num)
5228
5229 *--- TR 1076260 21-Mar-2014 Goutam
5230 *.WriteHdrSysNotes(lcCurrDoc_num, STR(VAL(lcCurrDoc_num)) , ;
5231 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
5232 tcTransHdrNotes, "Vzzeispth_iSPproc", lnDoc_count)
5233
5234 .WriteHdrSysNotes(lcCurrDoc_num, STR(VAL(lcCurrDoc_num)) , ;
5235 lcCurrNote_type, lcNotes, lcUser_ID, ltLast_mod, lnSeq, ;
5236 tcTransHdrNotes, lcSourceHeader, lnDoc_count, lcAddrTable)
5237 *=== TR 1076260 21-Mar-2014 Goutam
5238 Endif
5239 Endif
5240
5241 Endwith
5242 Select(lnOldSelect)
5243 Return llRetVal
5244 Endproc
5245
5246*============================================================
5247
5248 Procedure GetDocNumCount
5249 Lparameters tcDocCount, tcDoc_num
5250
5251 Local lnDoc_count, lnOldSelect
5252 lnOldSelect = Select()
5253 lnDoc_count = 1
5254 If Not Empty(tcDocCount)
5255 Select (tcDocCount)
5256 If Seek(tcDoc_num)
5257 lnDoc_count = Doc_count
5258 Endif
5259 Endif
5260
5261 Select(lnOldSelect)
5262 Return lnDoc_count
5263 Endproc
5264
5265*============================================================
5266
5267 Procedure CreateDocStoreCursor
5268 Lparameters tcTransHeader, tcDocCount
5269 Local lnOldSelect, llRetVal
5270
5271 llRetVal = .T.
5272 lnOldSelect = Select()
5273
5274 Select doc_num, Count(*) As Doc_count From (tcTransHeader) Group By doc_num Into Cursor (tcDocCount)
5275 Index On doc_num Tag doc_num
5276
5277 Select(lnOldSelect)
5278 Return llRetVal
5279 Endproc
5280
5281*============================================================
5282
5283 *--- TR 1076260 21-Mar-2014 Goutam
5284 *Procedure WriteHdrSysNotes(tcDoc_num, tcExpr, tcNote_type, tcNotes, tcuser_id, ttLast_mod, tnSeq, tcTransHdrNotes, tcTransHdr, tnDocCount)
5285 Procedure WriteHdrSysNotes
5286 LPARAMETERS tcDoc_num, tcExpr, tcNote_type, tcNotes, tcuser_id, ttLast_mod, tnSeq, tcTransHdrNotes, tcTransHdr, tnDocCount, tcAddrTable
5287 *=== TR 1076260 21-Mar-2014 Goutam
5288
5289 Local lnOldSelect, llRetVal, lcHdrPkey, lcExpr, lnPKey
5290 Local lnMaxPkey
5291
5292 *--- TR 1076260 21-Mar-2014 Goutam
5293 LOCAL lnParentKey
5294 lnParentKey = 0
5295 *=== TR 1076260 21-Mar-2014 Goutam
5296
5297 lnOldSelect = Select()
5298 llRetVal = .T.
5299 lcExpr = tcExpr
5300
5301 Select (tcTransHdr)
5302 Set Order To Tag doc_num
5303 lnMaxPkey = v_nextPkey('sysnotes', tnDocCount)
5304 lnPKey = lnMaxPkey - tnDocCount
5305 Select (tcTransHdr)
5306 If Seek (lcExpr)
5307 Scan While doc_num = VAL(tcExpr)
5308 lcHdrPkey = pkey
5309
5310 *--- TR 1076260 21-Mar-2014 Goutam
5311 IF tcAddrTable = "ZZEISPTO"
5312 lnParentKey = fkey
5313 ENDIF
5314 *=== TR 1076260 21-Mar-2014 Goutam
5315
5316 lnPKey = lnPKey + 1
5317 Select(tcTransHdrNotes)
5318 Append Blank
5319 Scatter Name loHdrNotes Memo Blank
5320 *--- TR 1076260 21-Mar-2014 Goutam
5321 *loHdrNotes.table_Name = "ZZEISPTH"
5322 loHdrNotes.table_Name = tcAddrTable
5323 *=== TR 1076260 21-Mar-2014 Goutam
5324 loHdrNotes.fkey = lcHdrPkey
5325 loHdrNotes.note_type = Iif(Empty(tcNote_type),"EDI",tcNote_type)
5326 loHdrNotes.Notes = tcNotes
5327 loHdrNotes.Last_mod = ttLast_mod
5328 loHdrNotes.User_id = tcuser_id
5329 loHdrNotes.Seq = tnSeq
5330 loHdrNotes.pkey = lnPKey
5331 loHdrNotes.CascadeNote = 'N'
5332 loHdrNotes.Comment = "DEFAULT"
5333 loHdrNotes.note_date = ttLast_mod
5334
5335 IF tcAddrTable = "ZZEISPTO"
5336 loHdrNotes.parentkey = lnParentKey
5337 ENDIF
5338
5339 Gather Name loHdrNotes Memo
5340 Endscan
5341 Endif
5342 Select(lnOldSelect)
5343 Return llRetVal
5344 Endproc
5345
5346
5347*=== TR 1050836 27-Jul-2011 Partha ===
5348
5349*--- TechRec 1067730 17-May-2013 vkrishnamurthy ---
5350*============================================================
5351 FUNCTION ExplodeConsolidatedLines
5352 LPARAMETERS pceispTD,pceispTH
5353
5354 LOCAL llRetVal, lnSelect,loEiSPtd ,lcCursor,lcExplCursor ,lcSummCursor ,lcSQLString ,lnCount ,loExpl,lntolerance_pct ,;
5355 lnControl ,lnorig_qty ,lnBalance,lnProdLine ,lcSQLTempTable,lcProdCursor
5356
5357 *--- TR 1074657 18-Nov-2013 Goutam
5358 LOCAL lcDtlConsolLine, lnSplitQty, lnProd_Line, lnTolerance, lnTolrancePern, lnConKey, llTolCalculated, lcIgnoreWarnFlag
5359 LOCAL lnBforeFilterRecNo, lnTotalSplitQty, lnTotCount, lnTotSizeQty, llHaveWarn, lnSplit856i_qty, lnTDRecNo, lnTotSum
5360 *=== TR 1074657 18-Nov-2013 Goutam
5361
5362 llRetVal = true
5363 lnSelect = SELECT()
5364 lcCursor = GetUniqueFileName()
5365 lcExplCursor = GetUniqueFileName()
5366 lcSummCursor = GetUniqueFileName()
5367 lcOrigCursor = GetUniqueFileName()
5368 lcProdCursor = GetUniqueFileName()
5369 lnorig_qty = 0
5370 lnBalance = 0
5371 lnProdLine = 0
5372
5373 *--- TR 1074657 18-Nov-2013 Goutam. Deleted below line
5374*!* lcSQLString = " SELECT *,0*total_qty as totqty ,0*total_qty as size_qty , 'N' as orig_line FROM zzcordrd WHERE 1=2 "
5375*!* llRetVal = v_SQLExec(lcSQLString, lcExplCursor )
5376 *=== TR 1074657 18-Nov-2013 Goutam
5377
5378
5379 WITH This
5380 llRetVal = llRetVal AND .GenerateSQLTempTable(pceispTD) AND .PopulateSQLTempTable(pceispTD)
5381 lcSQLTempTable = .cSQLTempTable
5382
5383 *--- TR 1074657 18-Nov-2013 Goutam
5384 lcSqlString = "ALTER TABLE " + .cSQLTempTable + " ADD QtyTot INT"
5385 llRetVal = llRetVal And v_SqlExec(lcSqlString)
5386
5387 lcSqlString = "select prod_num, consol_prod_line, upc, sum(qty) totqty from " + lcSQLTempTable + " group by prod_num, consol_prod_line, upc"
5388 llRetVal = llRetVal And v_SqlExec(lcSqlString, "__tmpProdConsolCurs")
5389 SELECT __tmpProdConsolCurs
5390 INDEX on STR(prod_num) + consol_prod_line TAG consolprod
5391 *=== TR 1074657 18-Nov-2013 Goutam
5392
5393 llRetVal = llRetVal AND .GetProductionLines(lcSQLTempTable,lcProdCursor)
5394
5395 *--- TR 1074657 18-Nov-2013 Goutam
5396 lcSqlString = "update a " + ;
5397 " set a.tot_size_qty = b.size_qty " + ;
5398 " from " + lcProdCursor + " a " + ;
5399 " join (select prod_num, consol_prod_line, upc, sum(size_qty) size_qty from " + lcProdCursor + " group by prod_num, consol_prod_line, upc) b " + ;
5400 " on b.prod_num = a.prod_num " + ;
5401 " and b.consol_prod_line = a.consol_prod_line " + ;
5402 " and b.upc = a.upc"
5403
5404 llRetVal = llRetVal AND v_SQLExec(lcSQLString,,,true)
5405
5406 lcSqlString = "update a " + ;
5407 " set a.qty_856i = b.totqty, a.Split856i_qty = ROUND((a.size_qty/a.tot_size_qty)*b.totqty,0) " + ;
5408 " from " + lcProdCursor + " a " + ;
5409 " join __tmpProdConsolCurs b " + ;
5410 " on b.prod_num = a.prod_num " + ;
5411 " and b.consol_prod_line = a.consol_prod_line " + ;
5412 " and b.upc = a.upc"
5413
5414 llRetVal = llRetVal AND v_SQLExec(lcSQLString,,,true)
5415
5416 SELECT (lcProdCursor)
5417 INDEX on STR(prod_num) + consol_prod_line + upc+ balance TAG balance
5418 SET ORDER TO
5419 *=== TR 1074657 18-Nov-2013 Goutam
5420
5421 .cProdCursor = lcProdCursor
5422
5423 *--- TR 1074657 18-Nov-2013 Goutam
5424 lcDtlConsolLine = ""
5425 lcIgnoreWarnFlag = ""
5426
5427 lcSqlString = "select prod_num from " + pceispTD + ;
5428 " group by prod_num having COUNT(distinct fkey) > 1"
5429 llRetVal = llRetVal And v_SqlExec(lcSqlString, "__chkDuplicateCurs",,true)
5430 SELECT __chkDuplicateCurs
5431 INDEX on prod_num TAG prod_num
5432
5433 lcSQLString = "select a.*"+;
5434 " from " + .cProdCursor + " a " + ;
5435 " join __tmpProdConsolCurs b " + ;
5436 " on b.prod_num = a.prod_num " + ;
5437 " and b.consol_prod_line = a.consol_prod_line " + ;
5438 "where a.wip_total > 0 AND a.last_stage <> 'Y' AND a.shp_ok <> 'Y' "
5439
5440 llRetVal = llRetVal AND v_SQLExec(lcSQLString,lcCursor,,true)
5441
5442 SELECT (lcCursor)
5443 INDEX on STR(prod_num) + consol_prod_line TAG ProdConsol
5444
5445 SELECT (pceispTD)
5446
5447 GO top
5448
5449 DO While !EOF()
5450 SCATTER NAME loEiSPtd MEMO
5451
5452 llHaveWarn = false
5453
5454 IF SEEK(loEiSPtd.fkey, pceispTH, "PKEY")
5455 lcIgnoreWarnFlag = &pceispTH..Ignore_Warn
5456 IF EMPTY(lcIgnoreWarnFlag) AND SEEK(&pceispTH..control_key, "zzeispcr", "PKEY")
5457 lcIgnoreWarnFlag = zzeispcr.ignore_warn
5458 ENDIF
5459 ENDIF
5460
5461 IF !EMPTY(consol_prod_line) AND expl_ok <> 'Y' AND pkey > 0
5462 IF SEEK(loEiSPtd.prod_num, "__chkDuplicateCurs")
5463 Replace errs_flg_D WITH "Y", Errs_Msg_D WITH ALLTRIM(Errs_Msg_D) + "Duplicate Production Number Exists in Transaction."+ CRLF
5464 ELSE
5465 IF !SEEK(STR(loEiSPtd.prod_num)+loEiSPtd.consol_prod_line, lcCursor)
5466 Replace errs_flg_D WITH "Y", Errs_Msg_D WITH ALLTRIM(Errs_Msg_D) + "Invalid Consolidated Line Number."+ CRLF
5467 ELSE
5468 IF SEEK(STR(loEiSPtd.prod_num)+loEiSPtd.consol_prod_line+loEiSPtd.upc+"N", lcProdCursor, "BALANCE")
5469
5470 lnTolrancePern = 0
5471 IF SEEK(loEiSPtd.fkey, pceispTH, "PKEY")
5472 lnConKey = &pceispTH..control_key
5473 IF SEEK(lnConKey, "zzeispcr", "PKEY")
5474 lnTolrancePern = zzeispcr.tolerance_pct
5475 ENDIF
5476 ENDIF
5477
5478 llTolCalculated = true
5479 lnProd_Line = &lcProdCursor..Prod_Line
5480 lnTolerance = (ABS(&lcProdCursor..qty_856i-&lcProdCursor..tot_size_qty)/&lcProdCursor..tot_size_qty)*100
5481
5482 IF lnTolrancePern > 0 AND lnTolerance > 0 AND (lnTolerance > lnTolrancePern)
5483
5484 replace warn_flg_d WITH 'Y', ;
5485 warn_msg_d WITH 'Quantity Exceeds Tolerance', ;
5486 open_seq WITH lnProd_Line IN (pceispTD)
5487 llHaveWarn = true
5488 ENDIF
5489
5490 IF (llHaveWarn AND lcIgnoreWarnFlag = 'Y') OR !llHaveWarn
5491 SELECT (pceispTD)
5492 lnBforeFilterRecNo = RECNO()
5493 SET FILTER TO prod_num = loEiSPtd.prod_num and consol_prod_line = loEiSPtd.consol_prod_line and upc = loEiSPtd.upc
5494 Count to lnTotDetail
5495 replace ALL open_seq WITH 0
5496 GO TOP IN (pceispTD)
5497
5498 SELECT (lcProdCursor)
5499 SET FILTER TO prod_num = loEiSPtd.prod_num and consol_prod_line = loEiSPtd.consol_prod_line and upc = loEiSPtd.upc
5500 GO top
5501 lnTotSizeQty = tot_size_qty
5502 Count to lnTotCount
5503 SUM(Split856i_qty) to lnTotSplitQty
5504 GO BOTTOM in (lcProdCursor)
5505 lnQty_856i = Qty_856i
5506 IF (lnTotSplitQty > lnQty_856i)
5507 REPLACE Split856i_qty WITH (Split856i_qty - ABS(lnTotSplitQty - lnQty_856i)) IN (lcProdCursor)
5508 ENDIF
5509 IF (lnTotSplitQty < lnQty_856i)
5510 REPLACE Split856i_qty WITH (Split856i_qty + ABS(lnTotSplitQty - lnQty_856i)) IN (lcProdCursor)
5511 ENDIF
5512
5513 SELECT (pceispTD)
5514 lnProcess = 0
5515 SCAN FOR pkey > 0
5516 lnProcess = lnProcess + 1
5517 lnTotalSplitQty = 0
5518 SCATTER NAME loEiSPtd MEMO
5519 SELECT (lcProdCursor)
5520 GO TOP IN (lcProdCursor)
5521 lnSplit856i_qty = Split856i_qty
5522
5523 lnSplitQty = ROUND((size_qty/lnTotSizeQty)*loEiSPtd.Qty, 0)
5524 lnProd_Line = prod_line
5525 SELECT (pceispTD)
5526 lnTDRecNo = RECNO()
5527 SUM(qty) to lnTotSum for open_seq = lnProd_Line
5528 GOTO (lnTDRecNo)
5529
5530 IF lnTotSum < lnSplit856i_qty
5531
5532 IF (lnTotSum + lnSplitQty) > lnSplit856i_qty
5533 lnSplitQty = lnSplit856i_qty - lnTotSum
5534 ENDIF
5535
5536 replace qty WITH lnSplitQty, expl_ok WITH 'Y', open_seq WITH lnProd_Line IN (pceispTD)
5537 replace balance WITH 'Y' IN (lcProdCursor)
5538
5539 IF (lnProcess = lnTotDetail)
5540 SELECT (pceispTD)
5541 lnTDRecNo = RECNO()
5542 SUM(qty) to lnTotSum for open_seq = lnProd_Line
5543 GOTO (lnTDRecNo)
5544 IF (lnTotSum > lnSplit856i_qty)
5545 lnSplitQty = qty-ABS(lnTotSum-lnSplit856i_qty)
5546 replace qty WITH lnSplitQty IN (pceispTD)
5547 ENDIF
5548 IF (lnTotSum < lnSplit856i_qty)
5549 lnSplitQty = qty+ABS(lnTotSum-lnSplit856i_qty)
5550 replace qty WITH lnSplitQty IN (pceispTD)
5551 ENDIF
5552 ENDIF
5553 lnTotalSplitQty = lnTotalSplitQty + lnSplitQty
5554 ENDIF
5555
5556 IF lnTotCount > 1
5557 FOR lnCount = 2 TO lnTotCount
5558 SELECT (lcProdCursor)
5559 SKIP IN (lcProdCursor)
5560 lnSplit856i_qty = Split856i_qty
5561
5562 IF lnCount = lnTotCount
5563 lnSplitQty = loEiSPtd.Qty - lnTotalSplitQty
5564 ELSE
5565 lnSplitQty = ROUND((size_qty/lnTotSizeQty)*loEiSPtd.Qty, 0)
5566 ENDIF
5567
5568 lnProd_Line = prod_line
5569
5570 SELECT (pceispTD)
5571 lnRecNo = RECNO(pceispTD)
5572 SUM(qty) to lnTotSum for open_seq = lnProd_Line
5573 GOTO (lnRecNo)
5574
5575 IF lnTotSum < lnSplit856i_qty
5576
5577 IF (lnTotSum + lnSplitQty) > lnSplit856i_qty
5578 lnSplitQty = lnSplit856i_qty - lnTotSum
5579 ENDIF
5580
5581 SELECT (pceispTD)
5582 IF expl_ok = 'Y'
5583 APPEND BLANK IN (pceispTD)
5584 GATHER NAME loEiSPtd MEMO
5585 replace pkey WITH 0
5586 ENDIF
5587
5588 replace qty WITH lnSplitQty, expl_ok WITH 'Y', open_seq WITH lnProd_Line IN (pceispTD)
5589 replace balance WITH 'Y' IN (lcProdCursor)
5590
5591 IF (lnProcess = lnTotDetail)
5592 SELECT (pceispTD)
5593 lnTDRecNo = RECNO()
5594 SUM(qty) to lnTotSum for open_seq = lnProd_Line
5595 GOTO (lnTDRecNo)
5596 IF (lnTotSum > lnSplit856i_qty)
5597 lnSplitQty = qty-ABS(lnTotSum-lnSplit856i_qty)
5598 replace qty WITH lnSplitQty IN (pceispTD)
5599 ENDIF
5600 IF (lnTotSum < lnSplit856i_qty)
5601 lnSplitQty = qty+ABS(lnTotSum-lnSplit856i_qty)
5602 replace qty WITH lnSplitQty IN (pceispTD)
5603 ENDIF
5604 ENDIF
5605 lnTotalSplitQty = lnTotalSplitQty + lnSplitQty
5606
5607 GOTO (lnRecNo) IN (pceispTD)
5608 ENDIF
5609
5610 NEXT
5611 ENDIF
5612
5613 ENDSCAN
5614
5615 SELECT (lcProdCursor)
5616 SET FILTER TO
5617
5618 SELECT (pceispTD)
5619 SET FILTER TO
5620 GOTO (lnBforeFilterRecNo)
5621
5622 ENDIF
5623 ENDIF
5624 ENDIF
5625 ENDIF
5626 ENDIF
5627
5628 SELECT (pceispTD)
5629 lcDtlConsolLine = consol_prod_line
5630
5631 IF !llTolCalculated
5632 IF !EMPTY(lcDtlConsolLine) AND SEEK(loEiSPtd.fkey, pceispTH, "PKEY")
5633 lnConKey = &pceispTH..control_key
5634 IF SEEK(lnConKey, "zzeispcr", "PKEY")
5635 lnTolrancePern = zzeispcr.tolerance_pct
5636 IF SEEK(STR(loEiSPtd.prod_num)+loEiSPtd.consol_prod_line+loEiSPtd.upc+"N", lcProdCursor, "BALANCE")
5637 lnTolerance = (ABS(&lcProdCursor..Qty_856i-&lcProdCursor..tot_size_qty)/&lcProdCursor..tot_size_qty)*100
5638 IF lnTolrancePern > 0 AND lnTolerance > 0 AND (lnTolerance > lnTolrancePern)
5639 replace warn_flg_d WITH 'Y', ;
5640 warn_msg_d WITH 'Quantity Exceeds Tolerance' IN (pceispTD)
5641 ENDIF
5642 ENDIF
5643 ENDIF
5644 ENDIF
5645 ENDIF
5646
5647 SELECT (pceispTD)
5648 SKIP
5649 ENDDO
5650
5651 SELECT (pceispTD)
5652 count for PKey = 0 to lnCount
5653 lnPKey = v_NextPkey('ZZEISPTD',lnCount)
5654 SELECT (pceispTD)
5655 SCAN FOR PKey = 0
5656 lnCount = lnCount -1
5657 replace PKey With lnPKey - lnCount
5658 ENDSCAN
5659
5660 *=== TR 1074657 18-Nov-2013 Goutam
5661
5662*--- TR 1074657 18-Nov-2013 Goutam. Commented whole code and re-write in top
5663*!* SELECT (pceispTD)
5664*!* SCAN FOR !EMPTY(consol_prod_line) AND expl_ok <> 'Y'
5665*!* SCATTER NAME loEiSPtd
5666*!* IF .CheckDuplicates(loEiSPtd.prod_num,pceispTD)
5667*!* REplace errs_flg_D WITH "Y", Errs_Msg_D WITH ALLTRIM(Errs_Msg_D) + "Duplicate Production Number Exists in Transaction."+ CRLF
5668*!* Loop
5669*!* ENDIF
5670*!*
5671*!* IF NOT .CheckProductionLines(loEiSPtd.prod_num ,loEiSPtd.consol_prod_line,lcCursor)
5672*!* REplace errs_flg_D WITH "Y", Errs_Msg_D WITH ALLTRIM(Errs_Msg_D) + "Invalid Consolidated Line Number."+ CRLF
5673*!* ELSE
5674*!* SELECT(lcExplCursor )
5675*!* APPEND FROM DBF(lcCursor)
5676*!* Replace orig_line WITH 'Y' FOR prod_num = loEiSPtd.prod_num AND prod_line = VAL(SUBSTR(loEiSPtd.consol_prod_line,2))
5677*!*
5678*!* SELECT(lcCursor)
5679*!* LOCATE FOR prod_num = loEiSPtd.prod_num AND prod_line = VAL(SUBSTR(loEiSPtd.consol_prod_line,2))
5680*!* IF FOUND()
5681*!* lnProdLine = prod_line
5682*!* Replace open_seq WITH lnProdLine IN (pceispTD)
5683*!* ENDIF
5684*!* ENDIF
5685*!* .TableClose(lcCursor)
5686*!* ENDSCAN
5687*!*
5688*!*
5689*!* lcSQLString = " Select sum(size_qty) sztotal"+;
5690*!* " , prod_num, consol_prod_line "+;
5691*!* " from "+ lcExplCursor +;
5692*!* " where consol_prod_line <> '' "+;
5693*!* " group by prod_num, consol_prod_line"
5694*!* llRetVal = llRetVal AND v_sqlexec(lcSQLString,lcSummCursor,,true)
5695*!*
5696*!*
5697*!* lcSQLString = "update E "+;
5698*!* " set totqty = s.sztotal "+;
5699*!* " from " +lcExplCursor + " E "+;
5700*!* " join " +lcSummCursor + " S "+;
5701*!* " on e.consol_prod_line = s.consol_prod_line " + ;
5702*!* " and e.prod_num = s.prod_num "
5703*!* llRetVal = llRetVal AND v_sqlexec(lcSQLString,,,true)
5704
5705*!* lcSQLString = " Select * "+;
5706*!* " from "+ lcExplCursor + " with (BUFFERING = .T.) "
5707*!* llRetVal = llRetVal AND v_sqlexec(lcSQLString,lcOrigCursor,,true)
5708
5709*!* SELECT(lcOrigCursor)
5710*!* INDEX on ALLTRIM(STR(prod_num))+ ALLTRIM(consol_prod_line)+ ALLTRIM(STR(prod_line)) TAG Prodcnsln
5711*!*
5712*!* SELECT(lcExplCursor )
5713*!* lcconsol_prod_line = ' '
5714*!* lnProd_num = 0
5715
5716*!* lnOrigBal = 0
5717*!* lnNewQty = 0
5718*!* lnFkey = 0
5719*!*
5720*!* SCAN FOR orig_line <> 'Y'
5721*!* SCATTER NAME loExpl
5722*!* IF prod_num <> lnProd_num OR consol_prod_line <> lcconsol_prod_line
5723*!*
5724*!* IF lnBalance >0 AND lnBalance+ lnNewQty < lnorig_qty
5725*!* && Need to adjust in last line if possible
5726*!* SELECT (pceispTD)
5727*!* LOCATE FOR prod_num = lnProd_num AND consol_prod_line = lcconsol_prod_line AND open_seq = lnNewOpen_seq
5728*!* IF FOUND()
5729*!* Replace qty WITH qty+lnBalance
5730*!* ENDIF
5731*!* ENDIF
5732*!* SELECT (pceispTD)
5733*!* LOCATE FOR prod_num = loExpl.prod_num AND consol_prod_line = loExpl.consol_prod_line AND !EMPTY(pkey)
5734*!* lcconsol_prod_line = loExpl.consol_prod_line
5735*!* lnProd_num = Prod_num
5736*!* lnBalance = Qty
5737*!* lnOrigBal = Qty
5738*!* ENDIF
5739*!* SELECT (pceispTD)
5740*!* LOCATE FOR prod_num = loExpl.prod_num AND consol_prod_line = loExpl.consol_prod_line AND !EMPTY(pkey)
5741*!* IF FOUND()
5742*!* SCATTER NAME loEiSPtd MEMO
5743
5744*!* IF expl_ok <> 'Y'
5745*!* IF SEEK(ALLTRIM(STR(loEiSPtd.prod_num))+ ALLTRIM(loEiSPtd.consol_prod_line)+ ALLTRIM(STR(loEiSPtd.open_seq)),lcOrigCursor,'Prodcnsln')
5746*!* lnorig_qty = SysGetFieldValue(lcOrigCursor, "size_qty")
5747*!* ENDIF
5748*!* REPLACE qty WITH IIF(Int((lnorig_qty /loExpl.totqty) *qty) >0,Int((lnorig_qty /loExpl.totqty) *qty),qty) , expl_ok WITH 'Y' IN (pceispTD)
5749*!* lnBalance = lnBalance - qty
5750*!* ENDIF
5751
5752*!* IF lnBalance >0
5753*!* APPEND BLANK
5754*!* lnorig_qty = SysGetFieldValue(lcExplCursor , "size_qty")
5755*!* loEiSPtd.Open_seq = loExpl.prod_line
5756*!* loEiSPtd.pkey = 0
5757*!* loEiSPtd.Qty = IIF( INT((lnorig_qty / loExpl.totqty ) * lnOrigBal )>0 ,INT((lnorig_qty / loExpl.totqty ) * lnOrigBal ),loEiSPtd.Qty)
5758*!*
5759*!* lnNewQty = loEiSPtd.Qty
5760*!* lnNewOpen_seq = loEiSPtd.Open_seq
5761
5762*!* lnBalance = lnBalance - loEiSPtd.Qty
5763*!* IF lnBalance <0
5764*!* loEiSPtd.Qty = lnBalance + loEiSPtd.Qty
5765*!* ENDIF
5766*!* loEiSPtd.expl_ok = 'Y'
5767*!* GATHER NAME loEiSPtd MEMO
5768*!* ENDIF
5769*!* ENDIF
5770*!* ENDSCAN
5771*!*
5772*!* * Assigning Pkeys for Exploded lines
5773*!* SELECT (pceispTD)
5774*!* count for PKey = 0 to lnCount
5775*!* lnPKey = v_NextPkey('ZZEISPTD',lnCount)
5776*!* SELECT (pceispTD)
5777*!* scan for PKey = 0
5778*!* lnCount = lnCount -1
5779*!* replace PKey With lnPKey - lnCount
5780*!* ENDSCAN
5781
5782*!* ** Warning
5783*!* lntolerance_pct = 0
5784*!* lnControl = 0
5785*!* SELECT (pceispTD)
5786*!* *!* SCAN FOR !empty(consol_prod_line)
5787*!* SCAN
5788*!* SCATTER NAME loEiSPtd
5789*!* IF SEEK(loEiSPtd.fkey,pceispTH,'Pkey')
5790*!* lnControl = SysGetFieldValue(pceispTH , "Control_Key")
5791*!* SELECT('zzeispcr')
5792*!* LOCATE FOR pkey = lnControl
5793*!* IF FOUND()
5794*!* lntolerance_pct = tolerance_pct
5795*!* ENDIF
5796*!* IF SEEK(ALLTRIM(STR(loEiSPtd.prod_num))+ ALLTRIM(loEiSPtd.consol_prod_line)+ ALLTRIM(STR(loEiSPtd.open_seq)),lcOrigCursor,'Prodcnsln')
5797*!* lnorig_qty = SysGetFieldValue(lcOrigCursor, "size_qty")
5798*!* ENDIF
5799*!* SELECT (pceispTD)
5800*!* IF lntolerance_pct >0 AND lnorig_qty >0
5801*!* IF (ABS(qty-lnorig_qty )/lnorig_qty) > lntolerance_pct
5802*!* Replace warn_msg_d WITH "Quantity Exceeds Tolerance", warn_flg_d WITH 'Y' IN (pceispTD)
5803*!* ENDIF
5804*!* ENDIF
5805*!* ENDIF
5806*!* Endscan
5807*=== TR 1074657 18-Nov-2013 Goutam
5808
5809 .TableClose(.cProdCursor)
5810 .TableClose(lcExplCursor)
5811 .TableClose(lcOrigCursor)
5812
5813 *--- TR 1074657 18-Nov-2013 Goutam
5814 .TableClose(lcProdCursor)
5815 .TableClose("__chkDuplicateCurs")
5816 .TableClose("__tmpProdConsolCurs")
5817 .TableClose(lcCursor)
5818 *=== TR 1074657 18-Nov-2013 Goutam
5819
5820 ENDWITH
5821
5822 SELECT (lnSelect)
5823 RETURN llRetVal
5824 ENDFUNC
5825
5826*============================================================
5827
5828 FUNCTION GetProductionLines
5829 LPARAMETERS tctable ,tcCursor
5830 LOCAL llRetVal, lnSelect ,lcstr
5831
5832 llRetVal = true
5833 lnSelect = SELECT()
5834
5835 WITH This
5836
5837 lcstr = ''
5838 FOR l_nxx = 1 TO goEnv.MaxBuckets
5839 l_cBucket = TRANSFORM(l_nxx, "@L 99")
5840 lcstr = lcstr + IIF(!EMPTY(lcStr)," +","")+ " d.Wip"+l_cBucket+"_qty*sz"+l_cBucket
5841 ENDFOR
5842
5843 *--- TR 1074657 18-Nov-2013 Goutam
5844 *lcSQLString = "select d.*"+;
5845 " , 0*total_qty as totqty "+;
5846 " , ( " + lcstr + ;
5847 " ) as size_qty " + ;
5848 " , 'N' as orig_line "+ ;
5849 " from ZZCORDRD d"+;
5850 " join zzxbuckt "+;
5851 " on 1= 1"+;
5852 " join zzxstylr s "+;
5853 " on s.division = d.division "+;
5854 " and s.style = d.style"+;
5855 " join zzxsizer sz "+;
5856 " on sz.division = d.division "+;
5857 " and sz.size_code = s.size_code "+;
5858 " join "+ tctable + " t "+ ;
5859 " on d.prod_num = t.prod_num " + ;
5860 " and d.consol_prod_line = t.consol_prod_line " +;
5861 " where "+ lcstr +;
5862 " > 0 " + ;
5863 " and d.wip_total >0 " + ;
5864 " AND d.last_stage <> 'Y' AND d.shp_ok <> 'Y' and d.consol_prod_line <> ''" + ;
5865 " and d.prod_line = ( SELECT TOP 1 prod_line " + ;
5866 " FROM zzcordrd " + ;
5867 " WHERE pkey = d.pkey " + ;
5868 " AND tree_Seq like RTRIM(d.tree_Seq) + '%' " + ;
5869 " ORDER BY d.stage_num DESC, d.tree_Seq DESC) "
5870
5871 lcSQLString = "select d.pkey, bk.size_num as size_bk, r.upc, d.prod_num, d.prod_line, d.open_seq, d.consol_prod_line, d.wip_total, d.last_stage, d.shp_ok " + ;
5872 " , 0*total_qty as totqty " + ;
5873 " , ( " + lcstr + ;
5874 " ) as size_qty " + ;
5875 " , 'N' as orig_line " + ;
5876 " , 0 as tot_size_qty " + ;
5877 " , 0 as Split856i_qty " + ;
5878 " , 0 as qty_856i " + ;
5879 " , 'N' as balance " + ;
5880 " from ZZCORDRD d " + ;
5881 " join zzxbuckt bk " + ;
5882 " on 1= 1 " + ;
5883 " join zzxstylr s " + ;
5884 " on s.division = d.division " + ;
5885 " and s.style = d.style " + ;
5886 " join zzxsizer sz " + ;
5887 " on sz.division = d.division " + ;
5888 " and sz.size_code = s.size_code " + ;
5889 " join zveupcnr r " + ;
5890 " on r.division = d.division " + ;
5891 " and r.style = d.style " + ;
5892 " and r.color_code = d.color_code " + ;
5893 " and r.lbl_code = d.lbl_code " + ;
5894 " and r.dimension = d.dimension " + ;
5895 " and r.sizebucket = bk.size_num " + ;
5896 " where "+ lcstr +;
5897 " > 0 " + ;
5898 " and d.wip_total >0 " + ;
5899 " and d.last_stage <> 'Y' " + ;
5900 " and d.shp_ok <> 'Y' " + ;
5901 " and d.consol_prod_line > '' " + ;
5902 " and exists(SELECT 1 from "+ tctable + " t " + ;
5903 " where d.prod_num = t.prod_num " + ;
5904 " and d.consol_prod_line = t.consol_prod_line) " + ;
5905 " and d.prod_line = ( " + ;
5906 " select TOP 1 prod_line " + ;
5907 " from zzcordrd " + ;
5908 " where pkey = d.pkey " + ;
5909 " and tree_Seq like RTRIM(d.tree_Seq) + '%' " + ;
5910 " order by d.stage_num DESC, d.tree_Seq DESC)"
5911
5912
5913 *=== TR 1074657 18-Nov-2013 Goutam
5914
5915 llRetVal = llRetVal AND v_SQLExec(lcSQLString,tcCursor)
5916
5917
5918 ENDWITH
5919
5920 SELECT (lnSelect)
5921 RETURN llRetVal
5922 ENDFUNC
5923
5924*============================================================
5925
5926 FUNCTION CheckProductionLines
5927 LPARAMETERS pnProd_num ,tcconsol_prod_line,tcCursor
5928 LOCAL llRetVal, lnSelect ,lcSQLString
5929
5930 llRetVal = true
5931 lnSelect = SELECT()
5932
5933 WITH This
5934 lcSQLString = "select *"+;
5935 " from " + .cProdCursor + ;
5936 " where prod_num = " + sqlformatnum(pnProd_num) + ;
5937 " and consol_prod_line = " + sqlformatchar(tcconsol_prod_line) + ;
5938 " and wip_total >0 AND last_stage <> 'Y' AND shp_ok <> 'Y' "
5939
5940 llRetVal = llRetVal AND v_SQLExec(lcSQLString,tcCursor,,.T.) and RECCOUNT(tcCursor) >0
5941 ENDWITH
5942
5943 SELECT (lnSelect)
5944 RETURN llRetVal
5945 ENDFUNC
5946
5947*============================================================
5948
5949 FUNCTION CheckDuplicates
5950 LPARAMETERS pnProd_num ,pceispTD
5951 LOCAL llRetVal, lnSelect,lcCursor
5952
5953 llRetVal = true
5954 lnSelect = SELECT()
5955 lcCursor = GetUniqueFileName()
5956
5957 WITH This
5958 lcSQLString = "select Fkey "+;
5959 " from " + pceispTD + ;
5960 " where prod_num = " + sqlformatnum(pnProd_num) + ;
5961 " Group by Prod_num having count(distinct fkey) >1 "
5962
5963 llRetVal = llRetVal AND v_SQLExec(lcSQLString,lcCursor ,,.T.) and RECCOUNT(lcCursor) >0
5964
5965
5966 ENDWITH
5967
5968 SELECT (lnSelect)
5969 RETURN llRetVal
5970 ENDFUNC
5971
5972
5973*!* The records to be exploded are DTL lines that have consol_prod_line filled.
5974
5975*!* For each DTL line with consol_prod_line filled, locate zzcordrd lines with the same prod_num and consol_prod_line. If such order lines are not founds, mark this record with error flag - "Invalid Consolidated Line Number".
5976
5977*!* If such lines are found, explode the incoming line into those production lines:
5978
5979*!* - Exploded lines should have their open_seq field filled with the prod_line values from corresponding zzcordrd line.
5980
5981*!* - The incoming quantity should be distributed between exploded lines in the ratio of the quantities of matching production lines, rounded up to the whole number - see example in SMP. Sum of quantities of exploded lines should equal the incoming quantity.
5982
5983*=== TechRec 1067730 17-May-2013 vkrishnamurthy ===
5984*============================================================
5985
5986 *--- TR 1073515 22-Oct-2013 BNarayanan ---
5987 PROCEDURE ValidateEDIControl
5988 LPARAMETERS tcTransHeader
5989
5990 LOCAL lcErrs_Msg, llRetVal
5991 llRetVal = .t.
5992
5993 lcErrs_Msg = "Invalid Trading Partner Qualifier/Id." + CRLF
5994
5995 SELECT (tcTransHeader)
5996 Replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + lcErrs_Msg FOR control_key = 0
5997
5998 RETURN llRetVal
5999 *=== TR 1073515 22-Oct-2013 BNarayanan ===
6000
6001*============================================================
6002
6003 *--- TR 1076260 18-Mar-2014 Goutam
6004 PROCEDURE ValidateReplacementASN
6005 LPARAMETERS pceiSPTH, pceiSPTD, pcASNType
6006
6007 LOCAL llRetVal, lcSQL, lnOldSelect,lcTmp,lnProdNum,lnProdLine, lcMeaasge, lcTypeField
6008
6009 *--- TR 1082596 11-Nov-2014 Goutam
6010 LOCAL lcSizeString, l_cBucketNum
6011 lcSizeString = ""
6012 *=== TR 1082596 11-Nov-2014 Goutam
6013
6014 llRetVal = true
6015 lnOldSelect = SELECT()
6016
6017 lcTypeField = IIF(pcASNType = 'NO', "book_ok", "pretran_ok")
6018
6019 WITH THIS
6020 *--- TR 1078769 17-Jun-2014 Goutam. Added HdrPkey
6021 lcSQL = "SELECT h.pkey HdrPkey, d.pkey, d.prod_num, d.open_seq as prod_line, h.asn_type, h.book_num, h.asn_purpose, " + ;
6022 " style, color_code, lbl_code, dimension, sizebucket FROM " + pceiSPTD + " d " + ;
6023 " JOIN " + pceiSPTH + " h " + ;
6024 " ON h.pkey = d.fkey " + ;
6025 " WHERE d.errs_flg_d <> 'Y' and h.errs_flg_h <> 'Y'"
6026
6027 llRetVal = llRetVal And v_SqlExec(lcSQL,"__tmpProdType",,true)
6028
6029 .cSQLTempTable = ""
6030 IF .GenerateSQLTempTable("__tmpProdType") AND .PopulateSQLTempTable("__tmpProdType") AND !EMPTY(.cSQLTempTable)
6031
6032 *--- TR 1082596 11-Nov-2014 Goutam
6033 FOR lnTotalSizes = 1 TO goEnv.MaxBuckets
6034 l_cBucketNum = TRANSFORM(lnTotalSizes, "@L 99")
6035 lcSizeString = lcSizeString + " when t.sizebucket = " + l_cBucketNum + " then size" + l_cBucketNum + "_qty "
6036 NEXT
6037 lcSizeString = lcSizeString + " end > 0 "
6038 *=== TR 1082596 11-Nov-2014 Goutam
6039
6040 *--- TR 1082596 11-Nov-2014 Goutam. Removed when t.sizebucket = 1 then size01_qty ... upto 24 and replaced with lcSizeString
6041 lcSQL = ;
6042 "select t.pkey, t.book_num, t.asn_type "+;
6043 " from " + .cSQLTempTable + " t "+;
6044 " join zzcordrd cd "+;
6045 " on cd.prod_num = t.prod_num "+;
6046 " and cd.style = t.style "+;
6047 " and cd.color_code = t.color_code "+;
6048 " and cd.lbl_code = t.lbl_code "+;
6049 " and cd.dimension = t.dimension "+;
6050 " and cd.style = t.style"+;
6051 " join zzctyped td "+;
6052 " on td.division = cd.division "+;
6053 " and td.prod_type = cd.prod_type "+;
6054 " and cd.stage = td.stage "+;
6055 " where t.asn_purpose = '05' "+;
6056 " and case "+;
6057 lcSizeString +;
6058 " group by t.pkey"+;
6059 " , cd.division"+;
6060 " , cd.prod_type, t.book_num, t.asn_type "+;
6061 "having max(cd.stage_num) > case "+;
6062 " when exists( "+;
6063 " select stage_num "+;
6064 " from zzctyped "+;
6065 " where division = cd.division "+;
6066 " and prod_type = cd.prod_type "+;
6067 " and " + lcTypeField + " = 'Y') then ( "+;
6068 " select stage_num "+;
6069 " from zzctyped "+;
6070 " where division = cd.division "+;
6071 " and prod_type = cd.prod_type "+;
6072 " and " + lcTypeField + " = 'Y') "+;
6073 " else 0 end"
6074
6075 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6076
6077 SELECT __tmpProdBookType
6078 INDEX ON pkey TAG pkey
6079
6080 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6081
6082 lcMeaasge = "Production line(s) were moved from the booking stage."
6083 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot replace booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6084 FOR !EOF("__tmpProdBookType") AND !EMPTY(__tmpProdBookType.book_num) AND __tmpProdBookType.asn_type = 'NO' IN (pceiSPTD)
6085
6086 *--- TR 1078769 25-Juj-2014 Goutam. Not required as per new change request requirement for ASN_Type TH
6087*!* lcMeaasge = "Production line(s) were moved from the PreTransit stage."
6088*!* replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot replace booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6089*!* FOR !EOF("__tmpProdBookType") AND !EMPTY(__tmpProdBookType.book_num) AND __tmpProdBookType.asn_type = 'TH' IN (pceiSPTD)
6090
6091 SET RELATION TO
6092 USE IN SELECT("__tmpProdBookType")
6093
6094 *--- TR 1078769 25-Jul-2014 Goutam. Added t.asn_purpose
6095 *--- TR 1082596 11-Nov-2014 Goutam. Removed when t.sizebucket = 1 then size01_qty ... upto 24 and replaced with lcSizeString
6096 lcSQL = ;
6097 "select t.pkey, t.book_num, t.asn_type, t.asn_purpose "+;
6098 " , Coalesce(td.book_ok, '') as book_ok "+;
6099 " , Coalesce(td1.pretran_ok, '') as pretran_ok "+;
6100 " from " + .cSQLTempTable + " t "+;
6101 " join zzcordrd cd "+;
6102 " on cd.prod_num = t.prod_num "+;
6103 " and cd.style = t.style "+;
6104 " and cd.color_code = t.color_code "+;
6105 " and cd.lbl_code = t.lbl_code "+;
6106 " and cd.dimension = t.dimension "+;
6107 " and cd.style = t.style "+;
6108 " and cd.prod_line = t.prod_line "+;
6109 " left join zzctyped td "+;
6110 " on td.division = cd.division "+;
6111 " and td.prod_type = cd.prod_type "+;
6112 " and cd.stage = td.stage "+;
6113 " and td.book_ok = 'Y' "+;
6114 " left join zzctyped td1 "+;
6115 " on td1.division = cd.division "+;
6116 " and td1.prod_type = cd.prod_type "+;
6117 " and cd.stage = td1.stage "+;
6118 " and td1.pretran_ok = 'Y' "+;
6119 " where (t.asn_purpose = '03' OR t.asn_purpose = '05') "+;
6120 " and case "+;
6121 lcSizeString
6122
6123 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6124
6125 SELECT __tmpProdBookType
6126 INDEX ON pkey TAG pkey
6127
6128 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6129
6130 lcMeaasge = "Production line(s) not in booking stage."
6131 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot replace/cancel booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6132 FOR !EOF("__tmpProdBookType") AND __tmpProdBookType.book_ok <> 'Y' AND __tmpProdBookType.asn_type = 'NO' IN (pceiSPTD)
6133
6134
6135 *--- TR 1078769 25-Jul-2014 Goutam. Not required as per new change request requirement for ASN_Type TH
6136*!* lcMeaasge = "Production line(s) not in PreTransit stage."
6137*!* replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot replace/cancel booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6138*!* FOR !EOF("__tmpProdBookType") AND __tmpProdBookType.pretran_ok <> 'Y' AND __tmpProdBookType.asn_type = 'TH' IN (pceiSPTD)
6139
6140 lcMeaasge = "Production line(s) not in Booking/PreTransit stage."
6141 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot move/replace booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6142 FOR !EOF("__tmpProdBookType") AND (__tmpProdBookType.pretran_ok <> 'Y' AND __tmpProdBookType.book_ok <> 'Y') AND ;
6143 __tmpProdBookType.asn_purpose = '05' AND __tmpProdBookType.asn_type = 'TH' IN (pceiSPTD)
6144
6145 lcMeaasge = "Production line(s) not in PreTransit stage."
6146 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Cannot cancel booking # : " + ALLTRIM(__tmpProdBookType.book_num) + ". " + lcMeaasge + CRLF ;
6147 FOR !EOF("__tmpProdBookType") AND (__tmpProdBookType.pretran_ok <> 'Y') AND ;
6148 __tmpProdBookType.asn_purpose = '03' AND __tmpProdBookType.asn_type = 'TH' IN (pceiSPTD)
6149
6150 *=== TR 1078769 25-Jul-2014 Goutam.
6151
6152 SET RELATION TO
6153 USE IN SELECT("__tmpProdBookType")
6154
6155
6156 lcSQL = ;
6157 "select d.pkey "+;
6158 " from " + .cSQLTempTable + " d "+;
6159 " where d.asn_type = 'NO' "+;
6160 " and not exists( "+;
6161 " select 1 "+;
6162 " from " + .cSQLTempTable + " t "+;
6163 " join zzcordrd cd "+;
6164 " on cd.prod_num = t.prod_num "+;
6165 " and cd.style = t.style "+;
6166 " and cd.color_code = t.color_code "+;
6167 " and cd.lbl_code = t.lbl_code "+;
6168 " and cd.dimension = t.dimension "+;
6169 " and cd.style = t.style "+;
6170 " where t.asn_type = 'NO' "+;
6171 " and exists( "+;
6172 " select 1 "+;
6173 " from zzctyped "+;
6174 " where book_ok = 'Y' "+;
6175 " and division = cd.division "+;
6176 " and prod_type = cd.prod_type))"
6177
6178 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6179
6180 SELECT __tmpProdBookType
6181 INDEX ON pkey TAG pkey
6182
6183 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6184 lcMeaasge = "Production type not setup for booking stage."
6185
6186 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + lcMeaasge + CRLF ;
6187 FOR !EOF("__tmpProdBookType") IN (pceiSPTD)
6188 SET RELATION TO
6189 USE IN SELECT("__tmpProdBookType")
6190
6191 *--- TR 1078769 17-Jun-2014 Goutam. added condition prod_num = t.prod_num
6192 lcSQL = ;
6193 "select t.pkey"+;
6194 " , t.book_num "+;
6195 " from " + .cSQLTempTable + " t "+;
6196 " where t.asn_purpose = '00' "+;
6197 " and t.book_num > '' "+;
6198 " and exists( "+;
6199 " select 1 "+;
6200 " from zzcordrd "+;
6201 " where book_num = t.book_num and prod_num = t.prod_num)"
6202
6203 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6204
6205 SELECT __tmpProdBookType
6206 INDEX ON pkey TAG pkey
6207
6208 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6209 lcMeaasge = " already exists in production detail."
6210
6211 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Booking number [" + ALLTRIM(__tmpProdBookType.book_num) + "]" + lcMeaasge + CRLF ;
6212 FOR !EOF("__tmpProdBookType") IN (pceiSPTD)
6213 SET RELATION TO
6214 USE IN SELECT("__tmpProdBookType")
6215
6216 *--- 1078769 10-Jul-2014
6217*!* lcSQL = ;
6218*!* "select t.pkey"+;
6219*!* " , t.book_num "+;
6220*!* " from " + .cSQLTempTable + " t "+;
6221*!* " where (t.asn_purpose = '03' or t.asn_purpose = '05') "+;
6222*!* " and t.book_num > '' "+;
6223*!* " and exists( "+;
6224*!* " select 1 "+;
6225*!* " from zzcordrd "+;
6226*!* " where book_num = t.book_num "+;
6227*!* " and prod_num <> t.prod_num)"
6228
6229*!* llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6230
6231*!* SELECT __tmpProdBookType
6232*!* INDEX ON pkey TAG pkey
6233*!*
6234*!* llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6235*!* lcMeaasge = " already exists in production detail."
6236
6237*!* replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + "Booking number [" + ALLTRIM(__tmpProdBookType.book_num) + "]" + lcMeaasge + CRLF ;
6238*!* FOR !EOF("__tmpProdBookType") IN (pceiSPTD)
6239*!* SET RELATION TO
6240*!* USE IN SELECT("__tmpProdBookType")
6241 *=== 1078769 10-Jul-2014
6242
6243 lcSQL = ;
6244 "select d.pkey "+;
6245 " from " + .cSQLTempTable + " d "+;
6246 " where d.asn_type = 'TH' "+;
6247 " and not exists( "+;
6248 " select 1 "+;
6249 " from " + .cSQLTempTable + " t "+;
6250 " join zzcordrd cd "+;
6251 " on cd.prod_num = t.prod_num "+;
6252 " and cd.style = t.style "+;
6253 " and cd.color_code = t.color_code "+;
6254 " and cd.lbl_code = t.lbl_code "+;
6255 " and cd.dimension = t.dimension "+;
6256 " and cd.style = t.style "+;
6257 " where t.asn_type = 'TH' "+;
6258 " and exists( "+;
6259 " select 1 "+;
6260 " from zzctyped "+;
6261 " where pretran_ok = 'Y' "+;
6262 " and division = cd.division "+;
6263 " and prod_type = cd.prod_type))"
6264
6265 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6266
6267 SELECT __tmpProdBookType
6268 INDEX ON pkey TAG pkey
6269
6270 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "pkey", pceiSPTD, "pkey")
6271 lcMeaasge = "Production type not setup for PreTransit stage."
6272
6273 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + lcMeaasge + CRLF ;
6274 FOR !EOF("__tmpProdBookType") IN (pceiSPTD)
6275 SET RELATION TO
6276 USE IN SELECT("__tmpProdBookType")
6277
6278 *--- TR 1082596 11-Nov-2014 Goutam. Removed when t.sizebucket = 1 then size01_qty ... upto 24 and replaced with lcSizeString
6279 lcSQL = ;
6280 "select t.pkey "+;
6281 " from " + .cSQLTempTable + " t "+;
6282 " join zzcordrd cd "+;
6283 " on cd.prod_num = t.prod_num "+;
6284 " and cd.style = t.style "+;
6285 " and cd.color_code = t.color_code "+;
6286 " and cd.lbl_code = t.lbl_code "+;
6287 " and cd.dimension = t.dimension "+;
6288 " join zzctyped td "+;
6289 " on td.division = cd.division "+;
6290 " and td.prod_type = cd.prod_type "+;
6291 " and cd.stage = td.stage "+;
6292 " and cd.last_stage = 'Y' "+;
6293 " where case "+;
6294 lcSizeString
6295
6296 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdLastStage")
6297
6298 SELECT __tmpProdLastStage
6299 INDEX ON pkey TAG pkey
6300
6301 llRetVal = llRetVal And .SetRelation("__tmpProdLastStage", "pkey", pceiSPTD, "pkey")
6302
6303 lcMeaasge = "Production line(s) were moved to last stage." + CRLF
6304 replace errs_flg_d WITH 'Y', errs_msg_d WITH errs_msg_d + lcMeaasge ;
6305 FOR !EOF("__tmpProdLastStage") IN (pceiSPTD)
6306 SET RELATION TO
6307
6308 *--- TR 1078769 17-Jun-2014 Goutam.
6309 lcSQL = ;
6310 "select t.HdrPkey "+;
6311 " , t.book_num "+;
6312 " from " + .cSQLTempTable + " t "+;
6313 " where t.asn_purpose = '00' "+;
6314 " and t.asn_type = 'NO' " + ;
6315 " and t.book_num > '' "+;
6316 " and exists( "+;
6317 " select 1 "+;
6318 " from zzcordrd "+;
6319 " where book_num = t.book_num and prod_num = t.prod_num)"
6320
6321 llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6322
6323 SELECT __tmpProdBookType
6324 INDEX ON HdrPkey TAG HdrPkey
6325
6326 llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "HdrPkey", pceiSPTH, "pkey")
6327 lcMeaasge = " should not exist for this PO."
6328
6329 replace errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + "Booking number [" + ALLTRIM(__tmpProdBookType.book_num) + "]" + lcMeaasge + CRLF ;
6330 FOR !EOF("__tmpProdBookType") IN (pceiSPTH)
6331 SET RELATION TO
6332 USE IN SELECT("__tmpProdBookType")
6333
6334 *--- 1078769 10-Jul-2014
6335*!* lcSQL = ;
6336*!* "select t.HdrPkey "+;
6337*!* " , t.book_num "+;
6338*!* " from " + .cSQLTempTable + " t "+;
6339*!* " where not(t.asn_purpose = '00' "+;
6340*!* " and t.asn_type = 'NO') " + ;
6341*!* " and t.book_num > '' "+;
6342*!* " and not exists( "+;
6343*!* " select 1 "+;
6344*!* " from zzcordrd "+;
6345*!* " where book_num = t.book_num and prod_num = t.prod_num)"
6346
6347*!* llRetVal = llRetVal And v_SqlExec(lcSQL, "__tmpProdBookType")
6348
6349*!* SELECT __tmpProdBookType
6350*!* INDEX ON HdrPkey TAG HdrPkey
6351*!*
6352*!* llRetVal = llRetVal And .SetRelation("__tmpProdBookType", "HdrPkey", pceiSPTH, "pkey")
6353*!* lcMeaasge = " already exist for this PO."
6354*!*
6355*!* replace errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + "Booking number [" + ALLTRIM(__tmpProdBookType.book_num) + "]" + lcMeaasge + CRLF ;
6356*!* FOR !EOF("__tmpProdBookType") IN (pceiSPTH)
6357*!* SET RELATION TO
6358*!* USE IN SELECT("__tmpProdBookType")
6359 *=== 1078769 10-Jul-2014
6360
6361 *=== TR 1078769 17-Jun-2014 Goutam.
6362
6363 ENDIF
6364
6365 ENDWITH
6366
6367 USE IN SELECT("__tmpProdType")
6368 USE IN SELECT("__tmpProdBookType")
6369 USE IN SELECT("__tmpProdLastStage")
6370
6371 Select(lnOldSelect)
6372 Return llRetVal
6373 ENDPROC
6374
6375*============================================================
6376
6377 Procedure CreateDocOrderCursor
6378 Lparameters tcTransOrder, tcDocCount
6379 Local lnOldSelect, llRetVal, lcSql
6380
6381 llRetVal = true
6382 lnOldSelect = Select()
6383
6384 lcSql = "Select doc_num, prod_num, Count(*) As Doc_count " + ;
6385 " From " + tcTransOrder + ;
6386 " Group By doc_num, prod_num"
6387
6388 llRetVal = v_SqlExec(lcSql, tcDocCount,,true)
6389
6390 IF llRetVal
6391 SELECT (tcDocCount)
6392 Index On doc_num + prod_num Tag doc_num
6393 ENDIF
6394
6395 Select(lnOldSelect)
6396 Return llRetVal
6397 ENDPROC
6398
6399*============================================================
6400 PROCEDURE UpdatePODetail
6401 LPARAMETERS tceispTH, tceispTD, tceispTO, tcASNType
6402
6403 Local lnOldSelect, llRetVal, lcWorkAlias, lnProd_Num, lnProd_line, lnTDQty, lcHeading, lcstr, lnTotalQty, lcSql, ;
6404 lcProductionCursor, llValid, lnToStageNum, lnStageNum, lnOkey, lnPOHPkey, lnPODPkey, lcMessage
6405
6406 Local Array laProductionViews[1]
6407
6408 *--- TR 1081365 Goutam
6409 LOCAL lnTypeCount
6410 *=== TR 1081365 Goutam
6411ASSERT .f.
6412 PRIVATE pnProd_Num, pnOpen_seq
6413
6414 llRetVal = true
6415 lnOldSelect = Select()
6416 lcWorkAlias = GetUniqueFileName()
6417 lcProductionCursor = GetUniqueFileName()
6418
6419 *--- TR 1081365 Goutam
6420 lcProductionCursor2 = GetUniqueFileName()
6421 *=== TR 1081365 Goutam
6422
6423 WITH this
6424 .cNotesCursor = GetUniqueFileName()
6425 lcHeading = "Processing production lines"
6426 .oLog.LogMajorStage(lcHeading)
6427
6428 .UpdateThermoCaption(lcHeading + "...")
6429 .InitThermo(1)
6430 INKEY(0.01)
6431
6432 lcSql = "Select * from sysnotes where 1 =2"
6433 llRetVal = llRetVal AND v_SqlExec(lcSql, .cNotesCursor)
6434 SELECT (.cNotesCursor)
6435 INDEX on STR(fkey) + STR(parentkey) TAG fkey
6436
6437 .oLog.LogEntry("Fetching production data to move to next stage.")
6438 llRetVal = llRetVal AND .FetchTranRecords(tceispTH, tceispTD, tceispTO, lcWorkAlias)
6439 .oLog.LogEntry("Fetching production data to move to next stage " + IIF(llRetVal, 'completed.', 'failed.'))
6440
6441 SELECT (tcEiSPth)
6442 .nToProcess = RECCOUNT(tcEiSPth)
6443 COUNT TO .nProcessed FOR NOT (errs_flg_h == "Y") AND (warn_flg_h <> 'Y' OR ignore_warn = 'Y')
6444
6445 SELECT (tceispTD)
6446 SET ORDER TO prod_num
6447
6448 IF llRetVal AND USED(lcWorkAlias)
6449 SELECT (lcWorkAlias)
6450
6451 *--- TR 1081365 Goutam
6452 lnTypeCount = 1
6453 *SCAN
6454 DO WHILE !EOF()
6455 llRetVal = true
6456 lnProd_Num = Prod_Num
6457 lnTypeCount = IIF(((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num))) , 1,;
6458 IIF(asn_purpose = '03', 2, 3))
6459 *=== TR 1081365 Goutam
6460
6461 *--- TR 1081365 Goutam
6462 DO CASE
6463 CASE lnTypeCount = 1
6464 .oLog.LogEntry("Processing for ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (and not replace)))")
6465 lcSql = "Select * from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6466 " and ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num))) readwrite"
6467 llRetVal = llRetVal And v_SqlExec(lcSql,lcProductionCursor2,,true)
6468
6469 IF llRetVal AND RECCOUNT(lcProductionCursor2) > 0
6470 lcSql = "Delete from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6471 " and ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num)))"
6472 llRetVal = llRetVal And v_SqlExec(lcSql,,,true)
6473 GO TOP IN (lcWorkAlias)
6474 ENDIF
6475 CASE lnTypeCount = 2
6476 .oLog.LogEntry("Processing for cancel.")
6477 lcSql = "Select * from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6478 " and asn_purpose = '03' readwrite"
6479 llRetVal = llRetVal And v_SqlExec(lcSql,lcProductionCursor2,,true)
6480
6481 IF llRetVal AND RECCOUNT(lcProductionCursor2) > 0
6482 lcSql = "Delete from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6483 " and asn_purpose = '03'"
6484 llRetVal = llRetVal And v_SqlExec(lcSql,,,true)
6485 GO TOP IN (lcWorkAlias)
6486 ENDIF
6487 CASE lnTypeCount = 3
6488 .oLog.LogEntry("Processing for cancel and move to next once again (replacement).")
6489 *- 09/30/14 YIK TR 1081365 LOCAL ONLY
6490*!* lcSql = "Select * from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6491*!* " and ((asn_purpose = '05') AND asn_type <> 'TH' ) readwrite"
6492 lcSql = "Select * from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6493 " and NOT ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num))) "
6494
6495 llRetVal = llRetVal And v_SqlExec(lcSql,lcProductionCursor2,,true)
6496
6497 IF llRetVal AND RECCOUNT(lcProductionCursor2) > 0
6498 *- 09/30/14 YIK TR 1081365 LOCAL ONLY
6499*!* lcSql = "Delete from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6500*!* " and ((asn_purpose = '05') AND asn_type <> 'TH') "
6501 lcSql = "Delete from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + ;
6502 " and NOT ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num))) "
6503 llRetVal = llRetVal And v_SqlExec(lcSql,,,true)
6504 GO TOP IN (lcWorkAlias)
6505 ENDIF
6506 ENDCASE
6507 *=== TR 1081365 Goutam
6508
6509 *--- TR 1081365 Goutam
6510 SELECT (lcProductionCursor2)
6511 SCAN
6512 *=== TR 1081365 Goutam
6513
6514 llValid = true
6515 lnPOHPkey = fkey
6516 lnPODPkey = pkey
6517 lntotal_cubic = 0
6518 lntotal_weight = 0
6519 lncarton = 0
6520 lnTotalQty = 0
6521 lnProd_Num = prod_Num
6522 lnProd_line = prod_line
6523 llRetval = true && *--- TR 1078769 27-6-2014 VKK set llretval = true alwasy
6524
6525
6526 *--- TR 1081365 Goutam
6527 *lcSql = "Select * from " + lcWorkAlias + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + " and prod_line = " + ALLTRIM(STR(lnProd_line)) + " readwrite"
6528 IF .t. && lnTypeCount = 1
6529 lcSql = "Select * from " + lcProductionCursor2 + " readwrite"
6530 ELSE
6531 lcSql = "Select * from " + lcProductionCursor2 + " where prod_num = " + ALLTRIM(STR(lnProd_Num)) + " and prod_line = " + ALLTRIM(STR(lnProd_line)) + " readwrite"
6532 ENDIF
6533 llRetVal = llRetVal And v_SqlExec(lcSql,lcProductionCursor,,true)
6534 SELECT (lcProductionCursor)
6535 *- 10/06/14 YIK LOCAL ONLY
6536 *- Index has to be on STR()
6537 *-INDEX on prod_num+prod_line TAG prod_num
6538 INDEX on STR(prod_num) + STR(prod_line) TAG prod_num
6539
6540 SET ORDER TO
6541 *=== TR 1081365 Goutam
6542
6543 SELECT (tceispTD)
6544 IF SEEK(STR(lnProd_Num)+STR(lnProd_line))
6545
6546 lcstr = ""
6547 FOR l_nxx = 1 TO goEnv.MaxBuckets
6548 l_cBucket = TRANSFORM(l_nxx, "@L 99")
6549 lcstr = lcstr + IIF(!EMPTY(lcStr),",","")+ " size"+l_cBucket+"_qty with 0"
6550 ENDFOR
6551
6552 *--- TR 1081365 Goutam
6553 *lcstr = "replace " + lcstr + " in " + lcProductionCursor
6554 IF .t. && lnTypeCount = 1
6555 Replace ALL total_qty WITH 0 IN (lcProductionCursor)
6556 lcstr = "replace all " + lcstr + " in " + lcProductionCursor
6557 ELSE
6558 lcstr = "replace " + lcstr + " in " + lcProductionCursor
6559 ENDIF
6560 *--- TR 1081365 Goutam
6561
6562 &lcstr
6563
6564 *--- TR 1081365 Goutam
6565 *SCAN WHILE prod_num = lnProd_Num AND open_seq = lnProd_line
6566 IF .t. && lnTypeCount = 1
6567 lcCondition = " prod_num = lnprod_num"
6568 ELSE
6569 lcCondition = " prod_num = lnProd_Num AND open_seq = lnProd_line"
6570 ENDIF
6571 SCAN WHILE &lcCondition
6572 *=== TR 1081365 Goutam
6573
6574 lnTDQty = Qty
6575 lnOKey = OKey
6576
6577 *--- TR 1081365 Goutam
6578 *- 10/06/14 YIK LOCAL ONLY
6579 *- SEEK has to be on STR()
6580 *- SEEK(prod_num+open_seq,lcProductionCursor,"prod_num")
6581 IF SEEK(STR(prod_num) + STR(open_seq),lcProductionCursor,"prod_num")
6582
6583 lnPOHPkey = &lcProductionCursor..fkey
6584 *lnPODPkey = &lcProductionCursor..pkey
6585 lnPODPkey = &lcProductionCursor..prod_line
6586 *=== TR 1081365 Goutam
6587
6588 lcReplaceString = "Replace size" + TRANSFORM(sizebucket, "@L 99") + "_qty with " + STR(lnTDQty) + " in " + lcProductionCursor
6589 &lcReplaceString
6590
6591 lntotal_cubic = lntotal_cubic + total_cubic
6592 lntotal_weight = lntotal_weight + total_weight
6593 lncarton = lncarton + carton
6594 lnTotalQty = lnTotalQty + lnTDQty
6595
6596 IF SEEK(lnOKey, "tceispto_notes", "fkey") AND !SEEK(STR(lnPODPkey)+STR(lnPOHPkey), .cNotesCursor, "FKEY")
6597 SELECT tceispto_notes
6598 SCATTER NAME loONTNotes MEMO
6599 loONTNotes.pkey = v_NextPkey("SYSNOTES")
6600 loONTNotes.fkey = lnPODPkey
6601 loONTNotes.parentkey = lnPOHPkey
6602 loONTNotes.table_name = "ZZCORDRD"
6603
6604 SELECT (.cNotesCursor)
6605 APPEND BLANK
6606 GATHER NAME loONTNotes MEMO
6607 ENDIF
6608
6609 *--- TR 1081365 Goutam
6610 IF .t. && lnTypeCount = 1
6611 SELECT (lcProductionCursor)
6612 Replace total_qty WITH total_qty + lnTotalQty, ;
6613 total_cubic WITH total_cubic + lntotal_cubic, ;
6614 total_weight WITH total_weight + lntotal_weight, ;
6615 carton WITH carton + lncarton ;
6616 IN (lcProductionCursor)
6617
6618 lntotal_cubic = 0
6619 lntotal_weight = 0
6620 lncarton = 0
6621 lnTotalQty = 0
6622
6623 SELECT (tceispTD)
6624 ENDIF
6625 *=== TR 1081365 Goutam
6626 ENDIF
6627 ENDSCAN
6628
6629 *--- TR 1081365 Goutam COmmented Below
6630*!* Replace total_qty WITH lnTotalQty, ;
6631*!* total_cubic WITH lntotal_cubic, ;
6632*!* total_weight WITH lntotal_weight, ;
6633*!* carton WITH lncarton ;
6634*!* IN (lcProductionCursor)
6635 *=== TR 1081365 Goutam COmmented above
6636 ENDIF
6637
6638 .oProduction.cUnits_Cursor = lcProductionCursor
6639
6640 SELECT (lcProductionCursor)
6641
6642 *--- TR 1081365 Goutam
6643 GO top
6644 *=== TR 1081365 Goutam
6645
6646 lnStageNum = stage_num
6647 pnProd_Num = prod_num
6648 pnOpen_seq = prod_line
6649
6650 DO CASE
6651 CASE tcASNType = 'NO'
6652 lnToStageNum = BookOKStage
6653 CASE tcASNType = 'TH'
6654 lnToStageNum = PreTranStage
6655 ENDCASE
6656
6657 lcMessage = ""
6658
6659 DO CASE
6660 *--- TR 1078769 25-Jul-2014 Goutam. Requirement as per new change request for ASN_Type TH
6661 *CASE asn_purpose = '00' && Move to next stage
6662
6663 *--- TR 1081365 Goutam
6664 *CASE ((asn_purpose = '00') OR ((asn_purpose = '05') AND (asn_type = 'TH') AND (BookOKStage = stage_num))) && Move to next stage
6665 CASE lnTypeCount = 1
6666 *=== TR 1081365 Goutam
6667
6668 *=== TR 1078769 25-Jul-2014 Goutam.
6669
6670 .oLog.LogEntry("Moving production line to next stage.")
6671 llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, true, false, false, lnToStageNum, "")
6672 lcMessage = "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") moved to " + ;
6673 IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage."
6674
6675 .oLog.LogEntry("Moving production line to next stage " + IIF(llValid, "completed.", "failed."))
6676
6677 *--- TR 1081365 Goutam
6678 lcMessage = ""
6679 SELECT (lcProductionCursor)
6680 SCAN
6681 lnProd_line = prod_line
6682 *=== TR 1081365 Goutam
6683 lcMessage = lcMessage + "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") moved to " + ;
6684 IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage." + CRLF
6685
6686 *--- TR 1081365 Goutam
6687 ENDSCAN
6688 *=== TR 1081365 Goutam
6689
6690 *--- TR 1081365 Goutam
6691 *CASE asn_purpose = '03' && Cancel/delete current stage
6692 CASE lnTypeCount = 2
6693 *=== TR 1081365 Goutam
6694
6695 ** VKK 1081365
6696*!* .oLog.LogEntry("Cancelling/deleting production line.")
6697*!* .oProduction.nDeleteOpenSequence = open_seq
6698*!* llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, false, False, False, 0, "")
6699*!* lcMessage = "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") deleted from " + ;
6700*!* IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage."
6701*!*
6702*!* .oLog.LogEntry("Cancelling/deleting production line " + IIF(llValid, "completed.", "failed."))
6703
6704 .oLog.LogEntry("Sending production unit cursor to clsprod.prg to process cancel/single line.")
6705 llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, false, false, false, lnToStageNum, "", true)
6706 .oLog.LogEntry("Sending production unit cursor to clsprod.prg to process cancel/single line " + IIF(llValid,'completed','failed'))
6707
6708 lcMessage = ""
6709 SELECT (lcProductionCursor)
6710 SCAN
6711 lnProd_line = prod_line
6712 lcMessage = lcMessage + "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") deleted from " + ;
6713 IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage." + CRLF
6714
6715 ENDSCAN
6716
6717 ** VKK 1081365
6718
6719 *--- TR 1081365 Goutam
6720 *CASE asn_purpose = '05' && Replace current stage. First delete then move to next stage.
6721 CASE lnTypeCount = 3
6722 *=== TR 1081365 Goutam
6723
6724 ** VKK 1081365
6725*!* .oLog.LogEntry("Replacing current stage.")
6726*!* .oProduction.nDeleteOpenSequence = open_seq
6727*!* llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, false, False, False, 0, "")
6728*!* .oProduction.nDeleteOpenSequence = 0
6729*!*
6730*!* IF llValid
6731*!* Acopy(.oProduction.aProductionViews, laProductionViews)
6732*!* llRetVal = llRetVal AND .TableUpdateWithTransaction(@laProductionViews)
6733*!* SELECT (lcProductionCursor)
6734*!* LOCATE FOR pkey = lnPODPkey
6735*!* *--- TR 1080996 8-Sep-2014 Goutam. Changed from prod_line WITH prod_line-1 to prod_line WITH lastprod_line
6736*!* REPLACE next_prod_line WITH tdprod_line, prod_line WITH lastprod_line, pkey WITH lastpkey
6737*!* ENDIF
6738*!*
6739*!* IF llRetVal
6740*!* llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, true, false, false, lnStageNum, "")
6741*!* lcMessage = "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") replaced in " + ;
6742*!* IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage."
6743*!* ENDIF
6744*!*
6745*!* .oLog.LogEntry("Replacing current stage " + IIF(llValid, "completed.", "failed."))
6746
6747 .oLog.LogEntry("Sending production unit cursor to clsprod.prg to process replace line (next stage movement).")
6748 llValid = llValid AND .oProduction.ProcessProductionUnits(pnProd_Num, true, false, false, lnToStageNum, "", true)
6749 .oLog.LogEntry("Sending production unit cursor to clsprod.prg to process replace line (next stage movement) " + IIF(llValid,'completed','failed'))
6750
6751 lcMessage = ""
6752 SELECT (lcProductionCursor)
6753 SCAN
6754 lnProd_line = prod_line
6755 lcMessage = lcMessage + "Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + ") replaced in " + ;
6756 IIF(tcASNType = "NO","Booking","Pre-Transit") + " stage." + CRLF
6757
6758 ENDSCAN
6759
6760 ** VKK 1081365
6761
6762 ENDCASE
6763
6764 IF llValid
6765 Acopy(.oProduction.aProductionViews, laProductionViews)
6766
6767 lcProductionNotesView = .oProduction.cNotes_View
6768
6769 IF USED(.cNotesCursor) And Reccount(.cNotesCursor) > 0
6770 SELECT (.cNotesCursor)
6771 *--- 1081365 VKK
6772*!* Replace All FKey With .oProduction.nNextPKey , ;
6773*!* Seq With Recno(.cNotesCursor), ;
6774*!* line_seq With Recno(.cNotesCursor) ;
6775*!* In (.cNotesCursor)
6776
6777 SET ORDER TO
6778 SCAN
6779 SELECT (.cNotesCursor)
6780 * seek fkey as the parkey and replace it with pkey of that
6781 lnNotesProdLine = Fkey && we take prod_line as the fkey
6782 SELECT (lcProductionCursor)
6783 LOCATE FOR tdprod_line = lnNotesProdLine
6784 lnProdProdLine = Next_Prod_Line
6785 IF Seek(lnProdProdLine , .oProduction.cOrdrD_View, "Prod_Line")
6786 Select (.oProduction.cOrdrD_View)
6787 lnProdPkey = Pkey
6788 Replace FKey With lnProdPkey , ;
6789 Seq With Recno(.cNotesCursor), ;
6790 line_seq With Recno(.cNotesCursor) ;
6791 In (.cNotesCursor)
6792 ENDIF
6793 SELECT (.cNotesCursor)
6794 Endscan
6795 SET ORDER To fkey
6796 *=== 1081365 VKK
6797
6798 Select (lcProductionNotesView)
6799 Append From Dbf(.cNotesCursor) FOR NOT DELETED(.cNotesCursor) && *--- TR 1078769 27-6-2014 VKK added not deleted
6800 .TimeStampDocument(lcProductionNotesView, "ALL")
6801
6802 DELETE ALL IN (.cNotesCursor) && *--- TR 1078769 27-6-2014 VKK
6803 ENDIF
6804
6805 .oLog.LogEntry("Updating production line in database.")
6806 llRetVal = llRetVal AND .TableUpdateWithTransaction(@laProductionViews)
6807 .oLog.LogEntry("Updating production line in database " + IIF(llRetVal, "completed.", "failed."))
6808
6809 If Not llRetVal AND EMPTY(.oProduction.cFailedProductionMsg)
6810 .oProduction.cFailedProductionMsg = "Could not process production line."
6811 Endif
6812 ENDIF
6813
6814 llFailed = NOT llValid OR NOT llRetVal
6815
6816 IF llFailed
6817 llRetval = false
6818 lcMessage = "Processing Production Number/Line(" + ALLTRIM(STR(pnProd_Num)) + "/" + ALLTRIM(STR(lnProd_line)) + " failed : " + ;
6819 (.oProduction.cFailedProductionMsg)
6820
6821 *--- TR 1081365 Goutam
6822 SELECT (lcProductionCursor)
6823 SCAN
6824 IF SEEK(ispthpkey, tceispth, 'pkey')
6825 replace errs_flg_h WITH 'Y', errs_msg_h WITH 'Has error in detail' + CRLF IN (tceispth)
6826 ENDIF
6827 IF SEEK(isptdpkey, tceisptd, 'pkey')
6828 replace errs_flg_d WITH 'Y', errs_msg_d WITH .oProduction.cFailedProductionMsg + CRLF IN (tceisptd)
6829 ENDIF
6830 ENDSCAN
6831 *=== TR 1081365 Goutam
6832
6833 ENDIF
6834
6835 *=== 1081365 VKK
6836 *.oLog.LogEntry(lcMessage)
6837 DIMENSION laMsg[1]
6838 =StringToArray(lcMessage , @laMsg ,CRLF)
6839 FOR lnAcnt = 1 TO ALEN(laMsg,1)
6840 lcMsg = STRTRAN(laMsg[lnAcnt],CRLF, "")
6841 lcMsg = STRTRAN(lcMsg ,CHR(13), "")
6842 lcMsg = STRTRAN(lcMsg ,CHR(10), "")
6843 lcMsg = STRTRAN(lcMsg ,CHR(108), "")
6844 .oLog.LogEntry(lcMsg)
6845 NExt
6846 *=== 1081365 VKK
6847
6848 USE IN SELECT(lcProductionCursor)
6849
6850 *--- TR 1081365 Goutam
6851 IF .t. && lnTypeCount = 1
6852 EXIT
6853 ENDIF
6854 ENDSCAN
6855 lnTypeCount = lnTypeCount + 1
6856 SELECT (lcWorkAlias)
6857 *ENDSCAN
6858
6859 ENDDO
6860 *=== TR 1081365 Goutam
6861
6862 *--- TR 1081365 Goutam.
6863 SELECT (tcEiSPth)
6864 .nToProcess = RECCOUNT(tcEiSPth)
6865 COUNT TO .nProcessed FOR NOT (errs_flg_h == "Y") AND (warn_flg_h <> 'Y' OR ignore_warn = 'Y')
6866
6867 .oLog.LogEntry("Updating transaction header and detail...")
6868
6869 lcSql = "Select pkey from " + tceispth + " where errs_flg_h = 'Y'"
6870 llRetVal = v_SqlExec(lcSql,'__tmpISPTHPkey',,true)
6871
6872 lcSql = "Select pkey,errs_msg_d from " + tceisptd + " where errs_flg_d = 'Y'"
6873 llRetVal = v_SqlExec(lcSql,'__tmpISPTDPkey',,true)
6874
6875 IF RECCOUNT('__tmpISPTHPkey') > 0 OR RECCOUNT('__tmpISPTDPkey') > 0
6876 llBeganTransaction = THIS.BeginTransaction()
6877 .cSQLTempTable = ""
6878 IF llRetVal AND .GenerateSQLTempTable('__tmpISPTHPkey') AND .PopulateSQLTempTable('__tmpISPTHPkey') AND !EMPTY(.cSQLTempTable)
6879 lcSql = "Update h set h.errs_flg_h = 'Y', h.errs_msg_h = Convert(varchar(8000),h.errs_msg_h) + 'Has error in detail' + CHAR(10) " + ;
6880 " from zzeispth h join " + .cSQLTempTable + " t on t.pkey = h.pkey where h.errs_flg_h <> 'Y'"
6881 llRetVal = v_SqlExec(lcSql)
6882 ENDIF
6883 v_SqlExecNoError("drop table " + .cSQLTempTable)
6884
6885 .cSQLTempTable = ""
6886 IF llRetVal AND .GenerateSQLTempTable('__tmpISPTDPkey') AND .PopulateSQLTempTable('__tmpISPTDPkey') AND !EMPTY(.cSQLTempTable)
6887 lcSql = "Update h set h.errs_flg_d = 'Y', h.errs_msg_d = Convert(varchar(8000),h.errs_msg_d) + Convert(varchar(8000),t.errs_msg_d) + CHAR(10) " + ;
6888 " from zzeisptd h join " + .cSQLTempTable + " t on t.pkey = h.pkey where h.errs_flg_d <> 'Y'"
6889 llRetVal = v_SqlExec(lcSql)
6890 ENDIF
6891 v_SqlExecNoError("drop table " + .cSQLTempTable)
6892
6893 IF llRetVal
6894 IF llBeganTransaction
6895 THIS.EndTransaction()
6896 ENDIF
6897 ELSE
6898 IF llBeganTransaction
6899 THIS.RollbackTransaction()
6900 ENDIF
6901 ENDIF
6902 ENDIF
6903 USE IN SELECT('__tmpISPTHPkey')
6904 USE IN SELECT('__tmpISPTDPkey')
6905
6906 .oLog.LogEntry("Updating transaction header and detail " + IIF(llRetVal,'completed','failed'))
6907
6908 *=== TR 1081365 Goutam
6909
6910 *--- TR 1082847 31-1-2015 VKK Added M parameter
6911 *--- TR 1081365 Goutam
6912 *llRetVal = llRetVal AND .DeleteFromTransaction(tcEiSPth, "M")
6913 llRetVal = .DeleteFromTransaction(tcEiSPth, "M")
6914 *=== TR 1081365 Goutam
6915
6916 ENDIF
6917 ENDWITH
6918
6919 RELEASE pnProd_Num
6920
6921 *--- TR 1081365 Goutam
6922 USE IN SELECT(lcProductionCursor2)
6923 *=== TR 1081365 Goutam
6924
6925 USE IN SELECT(this.cNotesCursor)
6926 USE IN SELECT(lcWorkAlias)
6927 USE IN SELECT(lcProductionCursor)
6928 Select(lnOldSelect)
6929 Return llRetVal
6930 ENDPROC
6931
6932*============================================================
6933*--- TR 1082847 31-1-2015 VKK. Deleted whole
6934*!* FUNCTION AfterTableUpdateBeforeCommitHook
6935
6936*!* LOCAL llRetVal, lnSelect, lcSql, lncarton, lntotal_cubic, lntotal_weight
6937*!*
6938*!* *--- TR 1078769 7-Jul-2014 Goutam
6939*!* LOCAL lcShipto, ldShpdate, ldDue_date
6940*!* *=== TR 1078769 7-Jul-2014 Goutam
6941*!*
6942*!* llRetVal = true
6943*!* lnSelect = SELECT()
6944*!*
6945*!* WITH This
6946*!*
6947*!* SELECT (.oProduction.cUnits_Cursor)
6948*!* LOCATE FOR pkey = .oProduction.nCurrPKey
6949
6950*!* *--- TR 1078769 7-Jul-2014 Goutam
6951*!* lcShipto = Shipto
6952*!* ldShpdate = ShpDate
6953*!* ldDue_date = Due_date
6954*!* *=== TR 1078769 7-Jul-2014 Goutam
6955*!*
6956*!* lncarton = carton
6957*!* lntotal_cubic = total_cubic
6958*!* lntotal_weight = total_weight
6959*!*
6960*!* *--- TR 1078769 7-Jul-2014 Goutam. Added shipto,shpdate,due_date
6961*!* lcSql = "Update zzcordrd set carton = " + SqlFormatNum(lncarton) + ;
6962*!* ", total_cubic = " + SqlFormatNum(lntotal_cubic) + ;
6963*!* ", total_weight = " + SqlFormatNum(lntotal_weight) + ;
6964*!* ", book_num = " + SqlFormatChar(ISPHBook_Num) + ;
6965*!* ", Shipto = " + SqlFormatChar(lcShipto) + ;
6966*!* ", ShpDate = " + SqlFormatTS(ldShpdate) + ;
6967*!* ", Due_date = " + SqlFormatTS(ldDue_date) + ;
6968*!* " Where pkey = " + SqlFormatNum(.oProduction.nNextPKey)
6969*!*
6970*!* llRetVal = llRetVal and v_SqlExec(lcSql)
6971*!*
6972*!* ENDWITH
6973*!*
6974*!* SELECT (lnSelect)
6975*!* RETURN llRetVal
6976*!* ENDFUNC
6977
6978*============================================================
6979 FUNCTION FetchTranRecords
6980 *--- TR 1082847 31-1-2015 VKK Added tlReceive
6981 LPARAMETERS tceispTH, tceispTD, tceispTO, tcWorkAlias, tlReceive
6982
6983 LOCAL llRetval, lnSelect, lcSQLString ,lcJoinString , lcSelectFld, lcGroupFlds
6984
6985 *--- TR 1078769 19-Jun-2014 Goutam
6986 LOCAL lcSizes, lcAddlField
6987 *=== TR 1078769 19-Jun-2014 Goutam
6988
6989 llRetVal = true
6990 lnSelect = SELECT()
6991
6992 WITH THIS
6993
6994 *--- TR 1078769 7-Jul-2014 Goutam. Added tceispTO in the join. due_date, shpdate, shipto in select statement
6995 lcSQLString = "SELECT h.pkey fkey, d.pkey, d.prod_num, d.open_seq as prod_line, " + ;
6996 " h.asn_purpose, h.asn_type, h.book_num, o.due_date, o.shpdate, o.shipto , d.udfcordd1c, d.UDFCORDD2C, d.last_mod FROM " + tceiSPTD + " d " + ; &&FH LOCAL
6997 " JOIN " + tceiSPTH + " h " + ;
6998 " ON h.pkey = d.fkey " + ; && *--- TR 1085844 22-4-2015 VKK added 'X3' in the list along with X2
6999 IIF(tlReceive, " AND INLIST(h.asn_type,'X2','X3') ANd h.x_dock_flg = 'Y' ", " " ) + ; && *--- TR 1082847 31-1-2015 VKK 'DS' will be handled in GIT process tiself
7000 " JOIN " + tceiSPTO + " o " + ;
7001 " ON h.pkey = o.fkey and o.pkey = d.okey " + ;
7002 " WHERE (h.errs_flg_h <> 'Y' and (h.warn_flg_h <> 'Y' Or h.ignore_warn = 'Y'))"
7003
7004 llRetVal = llRetVal And v_SqlExec(lcSQLString,"__tmpProdType",,true)
7005
7006 .cSQLTempTable = ""
7007 IF .GenerateSQLTempTable("__tmpProdType") AND .PopulateSQLTempTable("__tmpProdType") AND !EMPTY(.cSQLTempTable)
7008
7009 *--- TR 1078769 19-Jun-2014 Goutam
7010 lcSizes = v_CreateSizesStru(,,,, goEnv.MaxBuckets)
7011 lcSizes = STRTRAN(lcSizes, ' I(4)', '')
7012
7013 lcAddlField = ",case when coalesce(t.due_date,'') > '' then t.due_date else cd.due_date end as due_date " + ;
7014 ",case when coalesce(t.shpdate,'') > '' then t.shpdate else cd.shpdate end as shpdate " + ;
7015 ",case when coalesce(t.shipto,'') > '' then t.shipto else cd.shipto end as shipto " + ;
7016 ",case when coalesce(t.udfcordd1c,'') > '' then t.udfcordd1c else cd.udfcordd1c end as udfcordd1c " +; &&FH LOCAL
7017 ",case when coalesce(t.UDFCORDD2C,'') > '' then t.UDFCORDD2C else cd.UDFCORDD2C end as UDFCORDD2C " &&FH LOCAL
7018
7019
7020 *--- TR 1082847 31-1-2015 VKK Added t.fkey as ISPTHPKey, t.pkey as ISPTDPKey, prod_type,numeric deleted, trans_date
7021 *- FH LOCAL - trans_date/ last_mod
7022 lcSelectFld = " t.last_mod as trans_date, t.fkey as ISPTHPKey, t.pkey as ISPTDPKey, cd.prod_num, cd.prod_line, cd.division, cd.style, cd.color_code, cd.lbl_code, cd.dimension, cd.pkey, cd.fkey, cd.total_qty, " + ;
7023 " cd.shipment_num, cd.cntr_num, cd.Cntr_usg, cd.Marker, cd.receipt_date, cd.Roll_num, cd.Lot, cd.cost , cd.pcomm_inv, cd.pbol_num, cd.location, "+ ; && FH LOCAL remove cd.udfcordd1c, 2c
7024 " cd.agent, cd.port_exit, cd.udfcordd5d, cd.udfcordd6d, cd.udfcordd7d, cd.udfcordd8d, cd.udfcordd9d, cd.udfcordd10d, " + ;
7025 " cd.total_cubic, cd.total_weight, cd.carton, cd.stage_num, cd.open_seq, cd.prod_type, t.last_mod, " + ;
7026 lcSizes + lcAddlField
7027 *=== TR 1078769 19-Jun-2014 Goutam
7028
7029 *--- TR 1078769 19-Jun-2014 Goutam. Removed cd.* and replaced with lcSelectFld
7030 *--- TR 1080996 8-Sep-2014 Goutam. Changed sql to get column lastpkey
7031 *--- TR 1080996 8-Sep-2014 Goutam. Added sql to get new column lastprod_line
7032 *--- TR 1082847 31-1-2015 VKK deleted as ISPHBook_Num. Kept only book_num, added IIF condition
7033 *--- TR 1082847 31-1-2015 VKK
7034 IF !tlReceive
7035 lcFldList = " ,(Select stage_num from zzctyped where division = ch.division and prod_type = ch.prod_type and book_ok = 'Y') as BookOKStage " + ;
7036 ",(Select stage_num from zzctyped where division = ch.division and prod_type = ch.prod_type and pretran_ok = 'Y') as PreTranStage " + ;
7037 ",(select max(pkey) from zzcordrd where prod_num = t.prod_num and open_seq = cd.open_seq and prod_line <> t.prod_line) as lastpkey "+ ;
7038 ",(select max(prod_line) from zzcordrd where prod_num = t.prod_num and open_seq = cd.open_seq and prod_line <> t.prod_line) as lastprod_line, "
7039 ELSE
7040 lcFldList = " , 0 BookOKStage , 0 PreTranStage , 0 lastpkey, 0 lastprod_line, "
7041 ENDIf
7042 *=== TR 1082847 31-1-2015 VKK
7043ASSERT .f.
7044 *--- TR 1082847 31-1-2015 VKK deleted as ISPHBook_Num. Kept only book_num, added IIF condition, added t.book_num as ISPHBook_Num
7045 lcSQLString = ;
7046 "select t.asn_purpose, t.prod_line as TDProd_Line, 0 as next_prod_line, t.book_num , t.asn_type " + ;
7047 lcFldList + ; && *--- TR 1082847 31-1-2015 VKK
7048 lcSelectFld + ;
7049 " from " + .cSQLTempTable + " t " + ;
7050 " join zzcordrd cd " + ;
7051 " on cd.prod_num = t.prod_num " + ;
7052 IIF(!tlReceive," and cd.prod_line = t.prod_line ", ; && *--- TR 1082847 31-1-2015 VKK
7053 " And cd.prod_line = (Select MAX(prod_line) from zzcordrd cd1 Where cd1.fkey = cd.fkey And ; && *--- TR 1082847 31-1-2015 VKK take max prod line for that line seq, expecting it to be the pre-revv stage prod line
7054 cd1.open_seq = (Select MAX(open_seq) from zzcordrd where prod_num = cd.prod_num and prod_line = t.prod_line) )") + ; && *--- TR 1082847 31-1-2015 VKK
7055 IIF(tlReceive, " and cd.last_stage <> 'Y' " , "") + ; && *--- TR 1085844 22-4-2015 VKK , ensure that itis not already receved
7056 " join zzcordrh ch " + ;
7057 " on cd.fkey = ch.pkey"
7058
7059 llRetVal = llRetVal And v_SqlExec(lcSQLString, "__tmpProdCurs")
7060
7061 *--- TR 1082847 31-1-2015 VKK Added readwrite
7062 lcSQLString = "Select * from __tmpProdCurs group by pkey readwrite"
7063 *=== TR 1082847 31-1-2015 VKK
7064
7065 llRetVal = llRetVal And v_SqlExec(lcSQLString,tcWorkAlias,,true)
7066
7067 ENDIF
7068
7069 ENDWITH
7070
7071 *--- TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7072 *- Added IF/ENDIF. We will need it later if tlReceive
7073 IF !tlReceive
7074 USE IN SELECT("__tmpProdCurs")
7075 ENDIF
7076 *=== TR 1085844 16-Apr-2015 Goutam *= YIK LOCAL ONLY
7077
7078 SELECT (lnSelect)
7079 RETURN llRetVal
7080 ENDFUNC
7081
7082*=========================================================
7083
7084 FUNCTION LoadProduction
7085 LOCAL llRetVal
7086
7087 WITH THIS
7088 SET PROCEDURE TO clsprod ADDITIVE
7089 SET PROCEDURE TO clspop ADDITIVE
7090 .oProduction = CREATEOBJECT("BPOProduction_ISP") && inherite locally
7091
7092 llRetVal = IsObject(.oProduction, true)
7093
7094 ENDWITH
7095 ENDFUNC
7096
7097*============================================================
7098 FUNCTION Destroy
7099
7100 WITH This
7101 IF IsObject(.oProduction, true)
7102 .oProduction.Destroy()
7103 .oProduction = NULL
7104 ENDIF
7105
7106 *--- TR 1104734 2-Sep-2017 Goutam
7107 IF IsObject(.oAutoSplitProcess, true)
7108 .oAutoSplitProcess.Destroy()
7109 .oAutoSplitProcess = NULL
7110 ENDIF
7111 *=== TR 1104734 2-Sep-2017 Goutam
7112
7113 DoDefault()
7114 ENDWITH
7115 RETURN true
7116 ENDFUNC
7117
7118*============================================================
7119 *--- TR 1078769 17-Jun-2014 Goutam. This function is not required . Deleting
7120*!* FUNCTION MoveOrderToNextStage
7121*!* LPARAMETERS tceispTH, tceispTD, tceispTO
7122*!* LOCAL llRetVal, lnSelect
7123*!*
7124*!* llRetVal = true
7125*!* lnSelect = SELECT()
7126*!*
7127*!* WITH This
7128*!*
7129*!*
7130*!* ENDWITH
7131*!*
7132*!* SELECT (lnSelect)
7133*!* RETURN llRetVal
7134*!* ENDFUNC
7135 *=== TR 1078769 17-Jun-2014 Goutam.
7136
7137 *=== TR 1076260 18-Mar-2014 Goutam
7138*============================================================
7139
7140 *--- TR 1076885 KISHORE 14-APR-2014
7141 PROCEDURE ValidateLot
7142 LPARAMETERS pceiSPTH, pceiSPTD
7143
7144 LOCAL llRetVal, lcSQL, lnOldSelect,lcTmp,lnProdNum,lnProdLine
7145
7146 llRetVal = .T.
7147 lnOldSelect = SELECT()
7148
7149 SELECT pkey,prod_num,open_seq as prod_line,lbl_code,upc,lot ;
7150 FROM (pceiSPTD) ;
7151 WHERE NOT EMPTY(upc) ;
7152 AND NOT (EMPTY(style) OR EMPTY(color_code) OR sizebucket = 0 OR EMPTY(size_desc) ) ;
7153 AND errs_flg_d <> 'Y' ;
7154 INTO CURSOR tmpCurs
7155
7156 WITH This
7157 .cSQLTempTable = ""
7158 IF .GenerateSQLTempTable("tmpCurs") AND .PopulateSQLTempTable("tmpCurs") AND !EMPTY(.cSQLTempTable)
7159
7160 TEXT TO lcSQL NOSHOW TEXTMERGE FLAGS 1
7161 SELECT t.pkey,t.lot
7162 FROM <<.cSQLTempTable>> t
7163 JOIN zzcordrd d
7164 ON d.prod_num=t.prod_num
7165 AND d.prod_line= t.prod_line
7166 JOIN zveupcnr u
7167 ON u.upc = t.upc
7168 AND u.lbl_code = d.lbl_code
7169 WHERE t.lot <> d.lot
7170 ENDTEXT
7171
7172 v_SQLExec(lcSQL, "errsCurs")
7173
7174 SELECT errsCurs
7175 INDEX ON pkey TAG pkey
7176
7177 UPDATE d ;
7178 SET errs_flg_d = 'Y', ;
7179 errs_msg_d = 'Dye Lot Received [' + ALLTRIM(d.lot) + '] does not match.' + CRLF ;
7180 FROM (pceiSPTD) d ;
7181 WHERE INDEXSEEK(d.pkey,.f.,"errsCurs","pkey")
7182
7183 USE IN errsCurs
7184 ENDIF
7185 ENDWITH
7186
7187 USE IN SELECT('tmpCurs')
7188 SELECT (lnOldSelect)
7189 RETURN llRetVal
7190
7191 ENDPROC
7192 *=== TR 1076885 KISHORE 14-APR-2014
7193
7194*============================================================
7195 *--- TR 1081057/1080996 9-Sep-2014 Goutam.
7196 FUNCTION ValidateGITLine
7197 LPARAMETERS tceiSPTH, tceiSPTD
7198 LOCAL llRetVal, lnSelect, lcTempCursor, lcSql
7199
7200 *--- TR 1080664 01-Dec-2014 Goutam.
7201 LOCAL lcError
7202 *=== TR 1080664 01-Dec-2014 Goutam.
7203
7204 llRetVal = true
7205 lnSelect = SELECT()
7206 lcTempCursor = GetUniqueFileName()
7207
7208 WITH This
7209 lcSql = "Select h.Control_Key, d.*, h.asn_type " +; && *--- TR 1082847 31-1-2015 VKK added h.asn_type
7210 " from " + tceiSPTH + " h join " + tceiSPTD + " d " +;
7211 " on d.fkey = h.pkey " +;
7212 " And NOT INLIST(h.asn_type,'X3','X2') AND GIT_Ind = 0" +; && *--- TR 1082847 31-1-2015 VKK
7213 "where d.errs_flg_d <> 'Y'"
7214
7215 llRetVal = llRetVal And v_SqlExec(lcSql,lcTempCursor,,true)
7216
7217 .cSQLTempTable = ""
7218 IF .GenerateSQLTempTable(lcTempCursor) AND .PopulateSQLTempTable(lcTempCursor) AND !EMPTY(.cSQLTempTable)
7219
7220 USE IN SELECT(lcTempCursor)
7221
7222 *--- TR 1080664 28-Nov-2014 Goutam. Added c.skip_opt_stage < 'Y'
7223 TEXT TO lcSql NOSHOW TEXTMERGE FLAGS 1
7224 select t.*
7225 from <<.cSQLTempTable>> t
7226 join zzcordrd d
7227 on d.Prod_Num = t.Prod_Num
7228 and d.Prod_line = t.open_seq
7229 join zzeispcr c
7230 on c.pkey = t.control_key
7231 and c.auto_gt = 'Y'
7232 and c.skip_opt_stage < 'Y'
7233 And t.asn_type not in ('X3','DS','X2','X1') -- *--- TR 1082847 31-1-2015 VKK for X1 it will be validated in next case
7234 join zzctyped typ
7235 on typ.division = d.division
7236 and typ.prod_type = d.prod_type
7237 and typ.Stage_num = d.Stage_num + 1
7238 where typ.shp_ok < 'Y' -- but the next stage is not GIT stage!
7239 ENDTEXT
7240
7241 llRetVal = llRetVal And v_SQLExec(lcSql, lcTempCursor)
7242
7243 SELECT (lcTempCursor)
7244 INDEX ON pkey TAG pkey
7245
7246 UPDATE d ;
7247 SET errs_flg_d = 'Y', ;
7248 errs_msg_d = 'Production line not in pre intransit stage.' + CRLF ;
7249 FROM (tceiSPTD) d ;
7250 WHERE INDEXSEEK(d.pkey,.f.,lcTempCursor,"pkey")
7251
7252 *--- TR 1080664 01-Dec-2014 Goutam.
7253 USE IN SELECT(lcTempCursor)
7254
7255 TEXT TO lcSql NOSHOW TEXTMERGE FLAGS 1
7256 select t.*
7257 from <<.cSQLTempTable>> t
7258 join zzcordrd d
7259 on d.Prod_Num = t.Prod_Num
7260 and d.Prod_line = t.open_seq
7261 join zzeispcr c
7262 on c.pkey = t.control_key
7263 and c.auto_gt = 'Y'
7264 and c.skip_opt_stage = 'Y'
7265 And t.asn_type not in ('X3','DS','X2') -- *--- TR 1082847 31-1-2015 VKK for X1 it has to validate still
7266 join zzctyped typ
7267 on typ.division = d.division
7268 and typ.prod_type = d.prod_type
7269 and typ.Stage_num > d.Stage_num
7270 and typ.Stage_num < (select stage_num from zzctyped where shp_ok = 'Y' and division = typ.division and prod_type = typ.prod_type)
7271 where typ.last_stage < 'Y' and typ.req_ok = 'Y' and typ.shp_ok < 'Y'
7272 ENDTEXT
7273
7274 llRetVal = llRetVal And v_SQLExec(lcSql, lcTempCursor)
7275
7276 SELECT (lcTempCursor)
7277 INDEX ON pkey TAG pkey
7278 INDEX ON fkey TAG fkey
7279
7280 UPDATE d ;
7281 SET errs_flg_d = 'Y', ;
7282 errs_msg_d = 'Production Line containing this item cannot be advanced, mandatory stages cannot be skipped.' + CRLF ;
7283 FROM (tceiSPTD) d ;
7284 WHERE INDEXSEEK(d.pkey,.f.,lcTempCursor,"pkey")
7285
7286 SELECT (lcTempCursor)
7287 llRetVal= llRetVal And .SetRelation(lcTempCursor, "FKEY", tceiSPTH, "PKEY")
7288
7289 lcError = ") cannot be advanced to the ‘In Transit Stage’, other mandatory stages cannot be skipped."
7290
7291 replace ALL errs_flg_h WITH 'Y', errs_msg_h WITH errs_msg_h + "Production lines for Production Order (" + ALLTRIM(STR(&lcTempCursor..prod_num)) + lcError + CRLF ;
7292 FOR !EOF(lcTempCursor) IN (tceiSPTH)
7293
7294 SET RELATION TO
7295 *=== TR 1080664 01-Dec-2014 Goutam.
7296
7297
7298 *--- TR 1082847 31-1-2015 VKK
7299 *For ‘X2’ – the Production order has to be on or after InTransit’ stage and there should be no mandatory
7300 *stages between the stage it is on and the RECEIVE stage.
7301 USE IN SELECT(lcTempCursor)
7302
7303 TEXT TO lcSql NOSHOW TEXTMERGE FLAGS 1
7304 select t.*, typ.Stage As Man_Stage
7305 from <<.cSQLTempTable>> t
7306 join zzcordrd d
7307 on d.Prod_Num = t.Prod_Num
7308 and d.Prod_line = t.open_seq
7309 join zzeispcr c
7310 on c.pkey = t.control_key
7311 and c.auto_gt = 'Y'
7312 And t.asn_type IN( 'X2' ,'X3') -- *--- TR 1085844 22-4-2015 VKK added X3
7313 join zzctyped typ
7314 on typ.division = d.division
7315 and typ.prod_type = d.prod_type
7316 and typ.stage_num > d.stage_num
7317 and d.Stage_num >= (select MIN(stage_num) from zzctyped where shp_ok = 'Y' and division = typ.division and prod_type = typ.prod_type)
7318 where typ.last_stage < 'Y' and typ.req_ok = 'Y'
7319 ENDTEXT
7320
7321 llRetVal = llRetVal And v_SQLExec(lcSql, lcTempCursor)
7322
7323 SELECT (lcTempCursor)
7324 INDEX ON pkey TAG pkey
7325 INDEX ON fkey TAG fkey
7326
7327 UPDATE d ;
7328 SET errs_flg_d = 'Y', ;
7329 errs_msg_d = TEXTMERGE("Invalid mandatory stage '<<&lcTempCursor..Man_Stage)>>' for Direct Ship('X2/X3').") + CRLF ; && *--- TR 1085844 22-4-2015 VKK added X3
7330 FROM (tceiSPTD) d ;
7331 WHERE INDEXSEEK(d.pkey,.t.,lcTempCursor,"pkey")
7332
7333 *For ‘DS’ – validate that there’s only one mandatory stage between the current stage
7334 *(presumably ‘CUT’ and the RECEIVE stage – and that is InTransit stage. If there are more mandatory stages – error out.
7335 * “Invalid mandatory stage ‘XXX’ for Direct Shipâ€
7336 USE IN SELECT(lcTempCursor)
7337
7338 TEXT TO lcSql NOSHOW TEXTMERGE FLAGS 1
7339 select t.*, typ.Stage As Man_Stage
7340 from <<.cSQLTempTable>> t
7341 join zzcordrd d
7342 on d.Prod_Num = t.Prod_Num
7343 and d.Prod_line = t.open_seq
7344 join zzeispcr c
7345 on c.pkey = t.control_key
7346 and c.auto_gt = 'Y'
7347 And t.asn_type = 'DS'
7348 join zzctyped typ
7349 on typ.division = d.division
7350 and typ.prod_type = d.prod_type
7351 and typ.stage_num > d.stage_num
7352 and (select MAX(stage_num)
7353 from zzctyped where last_stage <> 'Y' and req_ok = 'Y'
7354 and division = typ.division and prod_type = typ.prod_type)
7355 - d.Stage_num > 1
7356 where typ.last_stage < 'Y' and typ.req_ok = 'Y' and typ.shp_ok <> 'Y'
7357 ENDTEXT
7358
7359 llRetVal = llRetVal And v_SQLExec(lcSql, lcTempCursor)
7360
7361 SELECT (lcTempCursor)
7362 INDEX ON pkey TAG pkey
7363 INDEX ON fkey TAG fkey
7364
7365 UPDATE d ;
7366 SET errs_flg_d = 'Y', ;
7367 errs_msg_d = TEXTMERGE("Invalid mandatory stage '<<&lcTempCursor..Man_Stage)>>' for Direct Ship('DS').") + CRLF ;
7368 FROM (tceiSPTD) d ;
7369 WHERE INDEXSEEK(d.pkey,.t.,lcTempCursor,"pkey")
7370
7371 *=== TR 1082847 31-1-2015 VKK
7372 ENDIF
7373
7374 USE IN SELECT(lcTempCursor)
7375 ENDWITH
7376
7377 SELECT (lnSelect)
7378 RETURN llRetVal
7379 ENDFUNC
7380 *=== TR 1081057/1080996 9-Sep-2014 Goutam.
7381*============================================================
7382*--- TR 1082847 31-1-2015 VKK
7383*============================================================
7384 PROCEDURE CheckCrossDock
7385 LPARAMETERS pceiSPTH, pcASNType, pceiSPTO, pceiSPTN, pceiSPTD
7386
7387 LOCAL llRetVal, lnOldSelect, lcSql, llValidHeader
7388
7389 lnOldSelect = SELECT()
7390 llValidHeader = true
7391
7392 *--- TR 1082847 31-1-2015 VKK
7393 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + "Invalid ASN Type for Non-Cross Dock functionality." ;
7394 FOR inlist(asn_type ,'X1','X2','X3','DS') AND x_dock_flg <> 'Y' ;
7395 IN (pceiSPTH)
7396
7397 SELECT Distinct h.pkey, o.prod_type, o.division, x_dock_flg ;
7398 FROM (pceiSPTH) h ;
7399 JOIN (pceiSPTO) o ON h.pkey = o.fkey ;
7400 where h.errs_flg_h <> 'Y' ;
7401 AND h.x_dock_flg = 'Y' ;
7402 And INLIST(h.asn_type, 'DS','X1','X2','X3') ;
7403 INTO CURSOR __TmpTHCursor
7404
7405 WITH this
7406 .cSQLTempTable=""
7407
7408 IF RECCOUNT('__TmpTHCursor') > 0 AND .GenerateSQLTempTable('__TmpTHCursor') AND .PopulateSQLTempTable('__TmpTHCursor') AND !EMPTY(.cSQLTempTable)
7409
7410 * Cross Doc Prod type Validation
7411 .oLog.LogEntry("Validating Cross Dock in All Production Type.")
7412 lcProdTypeList = ""
7413 lcErrs_Msg = "Production Types {<<lcProdTypeList>>} is not set up for Cross Dock functionality." + CRLF
7414
7415 lcSql = "Select Distinct a.pkey, typ.prod_type from " + .cSQLTempTable + " a join zzctypeh typ on " + ;
7416 " typ.division = a.division" + ;
7417 " And typ.prod_type = a.prod_type" + ;
7418 " where a.x_dock_flg<> 'Y'"
7419 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
7420
7421 SELECT _tmpValidationCursor
7422 INDEX on PKey TAG Pkey
7423 SELECT (pceiSPTH)
7424 SCAN
7425 lnPkey = Pkey
7426 lcProdTypeList = ""
7427
7428 IF SEEK(lnPkey, "_tmpValidationCursor", "Pkey")
7429 SELECT _tmpValidationCursor
7430
7431 SCAN WHILE Pkey = lnPkey
7432 lcProdTypeList = lcProdTypeList + SQLFormatChar(ALLTRIM(Prod_Type)) + ","
7433 ENDSCAN
7434
7435 lcProdTypeList = RemoveLastdelimiter(lcProdTypeList)
7436
7437 ENDIF
7438
7439 IF NOT EMPTY(lcProdTypeList )
7440 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcErrs_Msg) IN (pceiSPTH)
7441 ENDIF
7442
7443 ENDSCAN
7444
7445 ENDIF
7446
7447 * Validation for Cross Dock Upc and ord and qty
7448 SELECT h.pkey, n.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.size_desc, d.upc, SUM(d.Qty) Qty ;
7449 FROM (pceiSPTH) h ;
7450 JOIN (pceiSPTn) n ON h.pkey = n.fkey ;
7451 JOIN (pceiSPTd) d ON h.pkey = d.fkey AND n.pkey = d.ctnkey ; && TR 1085844 26-MAr-2015 Goutam
7452 JOIN (pceiSPTo) o ON h.pkey = o.fkey ;
7453 where h.errs_flg_h <> 'Y' ;
7454 AND h.x_dock_flg = 'Y' ;
7455 And INLIST(h.asn_type, 'DS','X3') ;
7456 GROUP BY h.pkey, n.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.size_desc ;
7457 INTO CURSOR __TmpTHCursor
7458
7459 .cSQLTempTable=""
7460 IF RECCOUNT('__TmpTHCursor') > 0 AND .GenerateSQLTempTable('__TmpTHCursor') AND .PopulateSQLTempTable('__TmpTHCursor') AND !EMPTY(.cSQLTempTable)
7461
7462
7463 .oLog.LogEntry("Validating Cross Dock Order/UPC/Qty.")
7464 lcOrdList = ""
7465 lcOrdListErrs_Msg = "Cross Dock validation found invalid sales order numbers in ASN: <<lcOrdList>>." + CRLF
7466 lcUPCList = ""
7467 lcInvalidUPCErrs_Msg = "Cross Dock validation found invalid UPC in ASN: <<lcUPCList>>' "
7468 lcUPCOrdList = ""
7469 lcInvalidUPCOrdErrs_Msg = "Cross Dock validation found quantity in ASN greater than quantity on open " + ;
7470 "for the following UPC in ASN: <<lcUPCOrdList>>." + CRLF
7471
7472 TEXT TO lcSQL TEXTMERGE noshow
7473 SELECT a.Pkey, a.Ord_Num, a.upc
7474 ,Case When COALESCE(o.ord_num, 0) = 0 THEN 'Y' ELSE 'N' END As order_invalid
7475 ,Case When COALESCE((l.Qty), 0) >= (a.Qty) THEN 'Y' ELSE 'N' END As order_qty_Match
7476 ,Case When COALESCE((l.ord_num), 0) = 0 THEN 'Y' ELSE 'N' END As upc_invalid
7477 From <<.cSQLTempTable >> a
7478 left join (Select ord_num from zzoordrh where ord_status = 'O') O
7479 ON o.ord_num = a.ord_num
7480 left join (Select ord_num, division, style, color_code, lbl_code, dimension, size_desc , SUM(bk_qty) qty
7481 from zvoordrdv
7482 where line_status = 'O'
7483 Group By ord_num, division, style, color_code, lbl_code, dimension, size_desc
7484 ) L
7485 ON l.ord_num = a.ord_num
7486 And l.division = a.division
7487 And l.style = a.style
7488 And l.color_code = a.color_code
7489 And l.lbl_code = a.lbl_code
7490 And l.dimension = a.dimension
7491 And l.size_desc = a.size_Desc
7492 ENDTEXT
7493
7494 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
7495
7496 SELECT _tmpValidationCursor
7497 INDEX on PKey TAG Pkey
7498 SELECT (pceiSPTH)
7499 SCAN
7500 lnPkey = Pkey
7501 lcOrdList = ""
7502 lcUPCList = ""
7503 lcUPCOrdList = ""
7504
7505 IF SEEK(lnPkey, "_tmpValidationCursor", "Pkey")
7506 SELECT _tmpValidationCursor
7507
7508 SCAN WHILE Pkey = lnPkey
7509 lcOrdNum = ALLTRIM(STR(Ord_Num))
7510 lcUpc = ALLTRIM(upc)
7511 lcOrdUpc = lcOrdNum + "/" +lcUPC
7512 llValidOrder = (order_invalid = "N")
7513 llValidUPC = (upc_invalid = "N")
7514 llVAlidQty = (order_qty_Match = "Y")
7515
7516 IF NOT llValidOrder AND NOT (SQLFormatChar(lcOrdNum) + "," $ lcOrdList)
7517 lcOrdList= lcOrdList+ SQLFormatChar(lcOrdNum) + ","
7518 ENDIF
7519
7520 IF llValidOrder AND NOT llValidUPC AND NOT (SQLFormatChar(lcUpc) + "," $ lcUPCList)
7521 lcUPCList = lcUPCList + SQLFormatChar(lcUpc) + ","
7522 ENDIF
7523
7524 IF llValidOrder AND llValidUPC AND NOT llVAlidQty AND NOT (SQLFormatChar(lcOrdUpc) + "," $ lcUPCOrdList )
7525 lcUPCOrdList = lcUPCordList + SQLFormatChar(lcOrdUpc) + ","
7526 ENDIF
7527
7528 ENDSCAN
7529
7530 lcOrdList = RemoveLastdelimiter(lcOrdList)
7531 lcUPCList = RemoveLastdelimiter(lcUPCList )
7532 lcUPCOrdList = RemoveLastdelimiter(lcUPCOrdList )
7533
7534 ENDIF
7535
7536 IF NOT EMPTY(lcOrdList)
7537 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcOrdListErrs_Msg ) IN (pceiSPTH)
7538 ENDIF
7539
7540 IF NOT EMPTY(lcUPCList)
7541 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcInvalidUPCErrs_Msg) IN (pceiSPTH)
7542 ENDIF
7543
7544 IF NOT EMPTY(lcUPCOrdList )
7545 replace errs_flg_h with 'Y' , errs_msg_h with errs_msg_h + TEXTMERGE(lcInvalidUPCOrdErrs_Msg) IN (pceiSPTH)
7546 ENDIF
7547
7548 ENDSCAN
7549
7550 ENDIF
7551
7552
7553 USE IN __TmpTHCursor
7554 .tableclose('_tmpValidationCursor')
7555 ENDWITH
7556
7557 SELECT(lnOldSelect)
7558 RETURN llValidHeader
7559 ENDPROC
7560*============================================================
7561
7562*============================================================
7563
7564 FUNCTION MoveGoodsToReceive
7565 LPARAMETERS tceispTH, tceispTD, tceispTN, tceispTO, tceispTC, tlReceive
7566 LOCAL llRetVal, lnSelect, lcWorkAlias, lcProdAlais, lnLastStageNum, lcFkeyList, lcMessage
7567
7568 llRetVal = true
7569 lnSelect = SELECT()
7570 lcWorkAlias = GetUniqueFileName()
7571 lcProdAlias= GetUniqueFileName()
7572 lcProductionCursor = GetUniqueFileName()
7573 lcFkeyList = ""
7574
7575 WITH This
7576 *--- TR 1085844 16-Apr-2015 Goutam. Moving this under if condition else it is logging wrongly for all ASN type.
7577*!* lcHeading = "Moving production lines to receive stage"
7578*!* .oLog.LogMajorStage(lcHeading)
7579*!*
7580*!* .UpdateThermoCaption(lcHeading + "...")
7581*!* .InitThermo(1)
7582*!* INKEY(0.01)
7583 *=== TR 1085844 16-Apr-2015 Goutam
7584
7585 * Fetch Data from ISp Cursors
7586 llRetVal = llRetVal AND .FetchTranRecords(tceispTH, tceispTD, tceispTO, lcWorkAlias, tlReceive)
7587
7588 IF llRetVal AND USED(lcWorkAlias)
7589
7590 *--- TR 1085844 16-Apr-2015 Goutam
7591 lcHeading = "Moving production lines to receive stage"
7592 .oLog.LogMajorStage(lcHeading)
7593
7594 .UpdateThermoCaption(lcHeading + "...")
7595 .InitThermo(1)
7596 INKEY(0.01)
7597 *=== TR 1085844 16-Apr-2015 Goutam
7598
7599 TEXT TO lcSQL TEXTMERGE noshow
7600 SELECT prod_type, division, MAX(stage_num) stage_num
7601 From zzctyped
7602 Group by prod_type, division
7603 ENDTEXT
7604
7605 llRetVal = llRetVAl aND V_SQlExec(lcSQL, "__ProdTypeCur")
7606
7607 SELECT __ProdTypeCur
7608 INDEX on Prod_type + division TAG prod_div
7609
7610 SELECT (tceispTD)
7611 SET ORDER TO prod_num
7612
7613 *--- TR 1085844 17-Apr-2015 Goutam
7614 replace ALL prod_line WITH tdprod_line IN __tmpProdCurs
7615 SELECT * FROM __tmpProdCurs INTO CURSOR __tmpProdCurs2 readwrite
7616 SELECT prod_line, prod_num FROM __tmpProdCurs2 INTO CURSOR __tmpDtlPkeyUpdCurs
7617
7618 .cSQLTempTable = ""
7619 IF USED("__tmpDtlPkeyUpdCurs") AND .GenerateSQLTempTable('__tmpDtlPkeyUpdCurs') AND ;
7620 .PopulateSQLTempTable('__tmpDtlPkeyUpdCurs') AND !EMPTY(.cSQLTempTable)
7621
7622 USE IN SELECT("__tmpDtlPkeyUpdCurs")
7623
7624 lcSql = "Select distinct d.pkey, d.prod_line, d.prod_num " +;
7625 " from zzcordrd d " +;
7626 " join " + .cSQLTempTable + " t " +;
7627 " on t.prod_num = d.prod_num " +;
7628 " and t.prod_line = d.prod_line "
7629
7630 llRetVal = llRetVAl aND V_SQlExec(lcSQL, "__tmpDtlPkeyUpdCurs")
7631
7632 IF llRetVal AND RECCOUNT("__tmpDtlPkeyUpdCurs") > 0
7633 SELECT __tmpDtlPkeyUpdCurs
7634 INDEX on STR(prod_num) + STR(prod_line) TAG prod_num
7635
7636 llRetVal = llRetVal And .SetRelation("__tmpDtlPkeyUpdCurs", "prod_num", "__tmpProdCurs2", "STR(prod_num) + STR(prod_line)")
7637 IF llRetVal
7638 replace pkey WITH __tmpDtlPkeyUpdCurs.pkey FOR !EOF("__tmpDtlPkeyUpdCurs") IN __tmpProdCurs2
7639 SET FILTER TO
7640 ENDIF
7641 ENDIF
7642 USE IN SELECT("__tmpDtlPkeyUpdCurs")
7643 ENDIF
7644 *=== TR 1085844 17-Apr-2015 Goutam
7645
7646 *--- TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7647 *- lcSQL = "SELECT Distinct ISPTHPKey as Fkey, Prod_Num, Division, Prod_Type FROM " + lcWorkAlias + " Order by ISPTHPKey, Prod_Num "
7648 lcSQL = "SELECT Distinct ISPTHPKey as Fkey, Prod_Num, Division, Prod_Type FROM __tmpProdCurs2 Order by ISPTHPKey, Prod_Num "
7649 *=== TR 1085844 16-Apr-2015 Goutam
7650
7651 llRetVal = llRetVal AND v_SqlExec(lcSQL ,lcProdAlias,,true) And USED(lcProdAlias)
7652
7653 SELECT (lcProdAlias)
7654
7655 *--- TR 1085844 7-Apr-2015 Goutam.
7656 IF RECCOUNT(lcProdAlias) > 0
7657 .LogEntry("Moving Shipments[ASN TYPE(X2 or DS)] to receiving stage... ")
7658 ENDIF
7659 GO TOP IN (lcProdAlias)
7660 *=== TR 1085844 7-Apr-2015 Goutam
7661
7662 lnFkey = -9
7663 DO Whil NOT EOF()
7664 lnFkey = Fkey
7665 llRetVal = true
7666 .nProcessed = .nProcessed + 1
7667
7668
7669 Do WHILE Fkey = lnFkey AND NOT EOF()
7670 lnProd_Num = Prod_Num
7671 lcdivision = Division
7672 lcProdType = Prod_Type
7673
7674 lnLastStageNum = 0
7675
7676 IF SEEK(lcProdType + lcdivision, "__ProdTypeCur", "prod_div")
7677 lnLastStageNum = __ProdTypeCur.Stage_Num
7678 ENDIF
7679
7680 * Get all production lines for the fkey and prod #s
7681
7682 *--- TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7683 *- Select from __tmpProdCurs instead
7684*!* lcSql = "Select * from " + lcWorkAlias + " Where ISPTHPKey = " + ALLTRIM(STR(lnFkey)) + ;
7685*!* " And Prod_Num = " + ALLTRIM(STR(lnProd_Num)) + " readwrite"
7686
7687 *--- TR 1088958 28-Jul-2015 Goutam. Added tdprod_line in group by
7688 lcSql = "Select * from __tmpProdCurs2 Where ISPTHPKey = " + ALLTRIM(STR(lnFkey)) + ;
7689 " And Prod_Num = " + ALLTRIM(STR(lnProd_Num)) + " Group By ISPTHPKey, Prod_Num, tdprod_line readwrite"
7690 *=== TR 1085844 16-Apr-2015 Goutam *= YIK LOCAL ONLY
7691
7692 llRetVal = llRetVal And v_SqlExec(lcSql,lcProductionCursor,,true)
7693
7694 SELECT (lcProductionCursor)
7695 *--- TR 1088958 30-7-2015 VKK Added FOR 1= 1, for some reason "ALL" key words does not work with DEFAULT so forcing it
7696 BLANK FIELDS like Size??_qty, total_Qty DEFAULT ALL FOR 1 = 1
7697 INDEX on STR(prod_num) + STR(tdprod_line) TAG prod_num
7698
7699 SET ORDER TO
7700
7701 * From Detail table scan and replace this prodcursor for the entire prod #
7702 SELECT (tceispTD)
7703 IF SEEK(STR(lnProd_Num))
7704
7705 SCAN WHILE Prod_num = lnProd_Num
7706
7707 IF Fkey = lnFkey AND SEEK(STR(prod_num) + STR(open_seq),lcProductionCursor,"prod_num")
7708
7709 *--- TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7710 *- SUM up size qty as well
7711 *lcReplaceString = "Replace size" + TRANSFORM(sizebucket, "@L 99") + "_qty with " + ;
7712 STR(Qty) + ", Total_qty With total_qty + " + STR(Qty) + ;
7713 " in " + lcProductionCursor
7714
7715 lcReplaceString = "Replace size" + TRANSFORM(sizebucket, "@L 99") + "_qty with " + ;
7716 "size" + TRANSFORM(sizebucket, "@L 99") + "_qty + " + STR(Qty) + ", Total_qty With total_qty + " + STR(Qty) + ;
7717 " in " + lcProductionCursor
7718 *=== TR 1085844 16-Apr-2015 Goutam
7719
7720 &lcReplaceString
7721
7722 ENDIF
7723
7724 ENDSCAN
7725
7726 ENDIF
7727
7728 * Now we have data for all the prod # of the shipment header
7729 llRetVal = llRetVal AND .oProduction.CreateProductionCursor()
7730 SELECT (.oProduction.cUnits_Cursor)
7731 APPEND FROM DBF(lcProductionCursor)
7732
7733 .oProduction.lUpdateMode = true
7734 lnToStage = lnLastStageNum
7735 lcMessage = "Production Number(" + ALLTRIM(STR(lnProd_Num )) + ") moved to Receiving stage."
7736
7737 llRetVal = llRetVal AND .oProduction.ProcessProductionUnits(lnProd_Num , true, true) && force receiving stage
7738 .oProduction.lUpdateMode = false
7739
7740 IF NOT llRetVal
7741 lcMessage = "Moving Production Number(" + ALLTRIM(STR(lnProd_Num )) + ") to Receiving stage failed : " + ;
7742 (.oProduction.cFailedProductionMsg)
7743 ENDIf
7744
7745 .oLog.LogEntry(lcMessage )
7746 SELECT (lcProdAlias)
7747 Skip
7748 ENDdo
7749
7750 IF NOT llRetVal
7751 lcFkeyList = lcFkeyList + ALLTRIM(STR(lnFkey)) + ","
7752 ENDIF
7753 ENDDO
7754
7755 *--- TR 1085844 7-Apr-2015 Goutam.
7756 IF RECCOUNT(lcProdAlias) > 0
7757 .LogEntry("Moving Shipments[ASN TYPE(X2 or DS)] to receiving stage " + IIF(llRetVal,"successful.", "failed."))
7758 ENDIF
7759 *=== TR 1085844 7-Apr-2015 Goutam
7760
7761 * Stamp Failed records
7762 lcFkeyList = RemoveLastDelimiter(lcFkeyList)
7763
7764 IF NOT EMPTY(lcFkeyList)
7765 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
7766 UPDATE h
7767 SET git_ind = 3
7768 ,Errs_Flg_H = 'Y'
7769 ,Errs_Msg_H = 'Some of the production lines failed moving to receive stage.'
7770 From zzeispth h
7771 Where Pkey in (<<lcFkeyList>>)
7772 ENDTEXT
7773
7774 llRetVal = V_SQLExec(lcSQL)
7775 llRetVal = llRetval And .StampLocalHeaderCursorWithError(tceispTH)
7776 ENDIF
7777
7778 Endif
7779
7780 ENDWITH
7781
7782 *--- TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7783 USE IN SELECT("__tmpProdCurs")
7784 USE IN SELECT("__tmpProdCurs2")
7785 *=== TR 1085844 16-Apr-2015 Goutam *- 04/15/2015 YIK LOCAL ONLY
7786
7787 SELECT (lnSelect)
7788 RETURN llRetVal
7789 ENDFUNC
7790
7791
7792*============================================================
7793
7794 FUNCTION CalculateETA
7795 LPARAMETERS tcReclETA
7796 LOCAL lcReclETA, lcReturn
7797
7798 lcReturn = tcReclETA
7799 WITH This
7800 lcReclETA = CHRTRAN(tcReclETA, " ","")
7801 FOR lnChar = 1 TO LEN(lcReclETA)
7802 lcReturn = lcReturn + SUBSTR(lcReclETA, lnChar, 1) + "+"
7803 NEXT
7804 lcReturn = lcReturn + IIF(EMPTY(lcReturn),"","+0")
7805 ENDWITH
7806
7807 RETURN tcReclETA
7808 ENDFUNC
7809
7810*============================================================
7811
7812 FUNCTION PrepareFileForAutoPick
7813 LPARAMETERS tcTranHeader, tcTranCarton, tcTranDetail, tcTranOrder
7814 LOCAL llRetVal, lnSelect, lcTmpCursor, lcSQLString , lcordEtaCursor
7815
7816 llRetVal = true
7817 lnSelect = SELECT()
7818 lcTmpCursor = GetUniqueFileName()
7819 lcordEtaCursor = GetUniqueFileName()
7820
7821 WITH This
7822 *--- TR 1085844 17-Apr-2015 Goutam. Added shipper
7823 Select h.shipper, c.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket, d.size_desc, SUM(d.Qty) AS ISP_Qty ;
7824 from (tcTranHeader) h ;
7825 JOIN (tcTranCarton) c ;
7826 ON c.fkey = h.pkey ;
7827 join (tcTranDetail) d ;
7828 ON d.fkey = h.pkey ;
7829 JOIN (tcTranOrder) o ;
7830 ON o.fkey = h.pkey ;
7831 WHERE h.Errs_Flg_H <> "Y" ;
7832 AND INLIST(asn_type, "DS", "X3") ;
7833 Group By c.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket, d.size_desc ;
7834 INTO Cursor (lcTmpCursor)
7835
7836
7837 Select Distinct c.ord_num, h.eta_date, o.prod_num, o.division, .CalculateETA(h.recalc_eta) recalc_eta ,;
7838 h.pkey * 0 DAYS_TO_CNLDT, h.pkey * 0 as INTO_DC_CSHN, h.pkey * 0 as INTO_DC_DAYS,;
7839 h.pkey * 0 as TRAN_DAYS, h.pkey * 0 as VOYAGE_DAYS ;
7840 from (tcTranHeader) h ;
7841 JOIN (tcTranCarton) c ;
7842 ON c.fkey = h.pkey ;
7843 JOIN (tcTranOrder) o ;
7844 ON o.fkey = h.pkey ;
7845 WHERE h.Errs_Flg_H <> "Y" ;
7846 AND c.ord_num > 0 ;
7847 AND INLIST(asn_type, "DS", "X3") ;
7848 INTO Cursor (lcordEtaCursor) READWRITE
7849
7850 .cOrdersETA = "#" + GetUniqueFileName()
7851
7852 TEXT TO lcsql TEXTMERGE NOSHOW FLAGS 1
7853 Select o.pkey as ord_num, o.last_mod as eta_date, o.pkey as prod_num,
7854 o.division, CAST(' ' as Varchar(100)) recalc_eta,
7855 DAYS_TO_CNLDT,INTO_DC_CSHN,INTO_DC_DAYS,TRAN_DAYS,VOYAGE_DAYS
7856 Into <<.cOrdersETA>>
7857 from zzeispto o
7858 join zzctrtmr n on 1 = 1
7859 Where 1 = 2
7860 ENDTEXT
7861
7862 llRetVal = llRetVal AND v_sqlexec(lcSQL)
7863
7864 llRetVal = llRetVal AND .BulkInsertFromCursor(lcordEtaCursor,.cOrdersETA) && will be used later for zzxcbolr
7865
7866 .cSQLTempTable=""
7867
7868 IF RECCOUNT(lcTmpCursor) > 0 AND .GenerateSQLTempTable(lcTmpCursor) AND .PopulateSQLTempTable(lcTmpCursor) AND !EMPTY(.cSQLTempTable)
7869 lcSizes = v_CreateSizesStru("d.Size",,,"")
7870
7871 *--- TR 1085844 18-Apr-2015 Goutam. Added shipper
7872 TEXT TO lcSQLString TEXTMERGE NOSHOW FLAGS 1
7873 SELECT t.shipper, d.ord_num, d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.pkey, <<lcSizes>> , d.Total_qty,
7874 t.Isp_Qty, t.sizebucket
7875 From zzoordrd d
7876 Join <<.cSQLTempTable>> t
7877 On t.ord_num = d.ord_num
7878 And t.division = d.division
7879 and t.style = d.style
7880 and t.color_code = d.color_Code
7881 and t.lbl_code = d.lbl_code
7882 and t.dimension = d.dimension
7883 Where d.line_status = 'O'
7884 And d.Pkey = (Select MAX(pkey) --- To avoid duplciate line_seq if any
7885 From zzoordrd
7886 Where fkey = d.fkey
7887 And division = d.division
7888 and style = d.style
7889 and color_code = d.color_Code
7890 and lbl_code = d.lbl_code
7891 and dimension = d.dimension)
7892 Order By d.Pkey
7893 ENDTEXT
7894
7895 llRetVal = llRetVal And V_SQLExec(lcSQLString, "__OrderDetails")
7896
7897 *--- TR 1085844 18-Apr-2015 Goutam
7898 *IF llRetVal And .oAutoPickProcess.CreatePickCursor()
7899 IF llRetVal And .CreatePickCursorLocal()
7900 *=== TR 1085844 18-Apr-2015 Goutam
7901
7902 SELECT __OrderDetails
7903 *--- TR 1088958 30-7-2015 VKK Added FOR 1= 1, for some reason "ALL" key words does not work with DEFAULT so forcing it
7904 BLANK FIELDS like Size??_qty, total_Qty DEFAULT ALL FOR 1 = 1
7905
7906 DO WHILE NOT EOF()
7907 lnPkey = Pkey
7908 SCATTER NAME loDetail MEMO
7909
7910 SELECT (.oAutoPickProcess.cPick_Cursor)
7911 APPEND BLANK
7912 GATHER NAME loDetail MEMO
7913
7914 SELECT __OrderDetails
7915 DO WHILE pkey = lnPkey AND NOT EOF()
7916
7917 lcReplaceString = "Replace size" + TRANSFORM(__OrderDetails.sizebucket, "@L 99") + "_qty with " + ;
7918 STR(__OrderDetails.Isp_Qty) + ", Total_qty With total_qty + " + STR(__OrderDetails.Isp_Qty) + ;
7919 " in " + .oAutoPickProcess.cPick_Cursor
7920 &lcReplaceString
7921
7922 SKIP
7923 ENDDO
7924
7925 ENDDO
7926
7927 ENDIF
7928
7929 ENDIF
7930
7931 ENDWITH
7932
7933 SELECT (lnSelect)
7934 RETURN llRetVal
7935 ENDFUNC
7936
7937*============================================================
7938
7939 FUNCTION AutoPickPackedQty
7940 LOCAL llRetVal, lnSelect
7941
7942 llRetVal = true
7943 lnSelect = SELECT()
7944
7945 WITH This
7946 IF USED(.oAutoPickProcess.cPick_Cursor) AND RECCOUNT(.oAutoPickProcess.cPick_Cursor) > 0
7947 .cSQLTempTable = ""
7948 IF .GenerateSQLTempTable(.oAutoPickProcess.cPick_Cursor) AND .PopulateSQLTempTable(.oAutoPickProcess.cPick_Cursor) AND !EMPTY(.cSQLTempTable)
7949 .cOrdersPicked = .cSQLTempTable
7950 ENDIF
7951
7952 .oLog.LogMajorStage("Running the Auto Pick process.")
7953 .InitThermo(1)
7954 .UpdateThermoCaption("Running the Auto Pickprocess.")
7955
7956 .oAutoPickProcess.oLog = THIS.oLog
7957
7958*!* .oAutoPickProcess.lAutoInvoice = (.cAutoInvoice = 'Y')
7959*!* .oAutoPickProcess.lAutoInvoiceBasedonCustomerSales = !.oAutoPickProcess.lAutoInvoice
7960 .oAutoPickProcess.PickByStyleProcess("")
7961 .cMsgFromAutoPick= .oAutoPickProcess.cMessage
7962
7963 *--- TR 1085844 18-Apr-2015 Goutam.
7964 IF !EMPTY(.cOrdersPicked)
7965 lcSql = "update h"+;
7966 " set h.shipper = t.shipper"+;
7967 " from zzoordrh h"+;
7968 " join " + .cOrdersPicked + " t"+;
7969 " on t.ord_num = h.ord_num"+;
7970 " and h.ord_status = 'P'"+;
7971 " and t.shipper > ''"
7972 llRetVal = llRetVal And v_SqlExec(lcSql)
7973 ENDIF
7974 *=== TR 1085844 18-Apr-2015 Goutam.
7975
7976 .cMsgFromAutoPick= .cMsgFromAutoPick + ;
7977 "Auto Pick Ticket process " + ;
7978 IIF(llRetVal, "successfully completed.", "failed.") + CRLF + CRLF + ;
7979 ALLTRIM(STR(.oAutoPickProcess.nProcessOrders)) + " Orders were processed." + CRLF + ;
7980 ALLTRIM(STR(.oAutoPickProcess.nPickedOrders)) + " Orders were picked." + CRLF + ;
7981 ALLTRIM(STR(.oAutoPickProcess.nFailedOrders)) + " Orders failed validation."
7982
7983 IF !EMPTY(.cMsgFromAutoPick)
7984 .cMsgFromAutoPick= CRLF + "-- Auto Pick Process --" + CRLF + .cMsgFromAutoPick
7985 ENDIF
7986 .AdvanceThermoTotal(1)
7987 ELSE
7988 .cMessage = .cMessage + CRLF + "Nothing to process in the Auto Pick Process."
7989 ENDIF
7990 ENDWITH
7991
7992 SELECT (lnSelect)
7993 RETURN llRetVal
7994 ENDFUNC
7995
7996
7997*============================================================
7998
7999 FUNCTION AutoInvoice
8000 LOCAL llRetVal, lnSelect, lcAutoInv
8001
8002 llRetVal = true
8003 lnSelect = SELECT()
8004
8005 WITH This
8006 IF USED(.oAutoPickProcess.cPick_Cursor) AND RECCOUNT(.oAutoPickProcess.cPick_Cursor) > 0
8007 lcAutoInv = ""
8008 .oLog.LogMajorStage("Running the Auto Invoice process.")
8009 .InitThermo(1)
8010 .UpdateThermoCaption("Running the Auto Invoice process.")
8011
8012 .oAutoInvoiceProcess.oLog = THIS.oLog
8013
8014 lcFilter = " oh.pick_Batch = " + SqlFormatNum(.oAutoPickProcess.nPickBatch)
8015
8016 TEXT TO lcAutoInv TEXTMERGE noshow
8017 And 'Y' = COALESCE((Select top 1 auto_invoice
8018 FROM zzxcslsr
8019 WHERE customer = oh.customer AND
8020 (store = oh.store OR store = '') AND
8021 (department = oh.department OR department = '') AND
8022 (division = oh.division OR division = '') AND
8023 (ord_type = oh.ord_type OR ord_type = '')
8024 AND active_rec <> 'N'
8025 ORDER BY Rank_seq
8026 ), 'N')
8027 ENDTEXT
8028
8029 IF (.cAutoInvoice <> 'Y')
8030 lcFilter = lcFilter + lcAutoInv
8031 ENDIF
8032
8033 .oAutoInvoiceProcess.ProcessAutoInvoice(lcFilter)
8034 .cMsgFromAutoInvoice= .oAutoInvoiceProcess.cMessage
8035
8036
8037
8038 IF !EMPTY(.cMsgFromAutoInvoice)
8039 .cMsgFromAutoInvoice= CRLF + CRLF + "-- Auto Invoice Process --" + CRLF + .cMsgFromAutoInvoice
8040 ENDIF
8041 .AdvanceThermoTotal(1)
8042 ELSE
8043 .cMessage = .cMessage + CRLF + "Nothing to process in the Auto Invoice Process."
8044 ENDIF
8045 ENDWITH
8046
8047 SELECT (lnSelect)
8048 RETURN llRetVal
8049 ENDFUNC
8050
8051*============================================================
8052
8053
8054
8055 FUNCTION ConvertProductionCartonsIntoSales
8056 LPARAMETERS tcTranHeader, tcTranCarton, tcTranDetail, tcTranOrder, tcTranCntr
8057 *--- TR 1088958 28-Jul-2015 Goutam/Yuri. Added Parameter tcTranCntr above
8058 LOCAL llRetVal, lnSelect, llBeganTransaction, lcTmpCursor, lcCustomerShipmentInsert
8059 lcCustomerShipmentInsert = ""
8060 * Need the following infromation
8061 * List of Cartons to be updated
8062 * What will be the list of Order #
8063 **- Change carton class from 'P' to 'S'
8064 *- Change zzoctnph.fkey to point to zzoordsp.pkey of the corresponding pick#
8065 *- Assign SO# and line_seq to zzoctnpd.
8066 *- Set zzoordsp.cartons to 'Y'
8067
8068 *--- TR 1085844 17-4-2015 VKK
8069 LOCAL lcTmpTable
8070 lcTmpTable = ""
8071 *--- TR 1085844 17-4-2015 VKK
8072
8073 llRetVal = true
8074 lnSelect = SELECT()
8075 WITH This
8076 lcTmpCursor = GetUniqueFileName()
8077
8078 * FOR X3, we must find out the source of the fake carton and then update it in carton_Num back
8079
8080 *--- TR 1085844 21-Apr-2015 Goutam. Added "DS"
8081
8082 *--- TR 1088958 28-Jul-2015 Goutam/Yuri
8083 *- This SQL has wrong order of JOINs, so it creates cartesian. Fix it.
8084
8085 *Select c.carton_num, c.pkey, o.prod_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket ;
8086 from (tcTranHeader) h ;
8087 JOIN (tcTranCarton) c ;
8088 ON c.fkey = h.pkey ;
8089 JOIN (tcTranOrder) o ;
8090 ON o.fkey = h.pkey ;
8091 JOIN (tcTranDetail) d ;
8092 ON d.fkey = h.pkey ;
8093 WHERE h.Errs_Flg_H <> "Y" ;
8094 AND INLIST(asn_type, "X3", "DS") ;
8095 INTO Cursor (lcTmpCursor)
8096
8097 Select c.carton_num, c.pkey, o.prod_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket ;
8098 from (tcTranHeader) h ;
8099 JOIN (tcTranCntr) cntr ;
8100 ON h.pkey = cntr.fkey ;
8101 JOIN (tcTranOrder) o ;
8102 ON cntr.pkey = o.ckey ;
8103 JOIN (tcTranCarton) c ;
8104 ON o.pkey = c.okey ;
8105 JOIN (tcTranDetail) d ;
8106 ON d.ctnkey = c.pkey ;
8107 WHERE h.Errs_Flg_H <> "Y" ;
8108 AND INLIST(asn_type, "X3", "DS") ;
8109 INTO Cursor (lcTmpCursor)
8110 *=== TR 1088958 28-Jul-2015 Goutam/Yuri
8111
8112 .cSQLTempTable=""
8113
8114 *--- TR 1085844 17-4-2015 VKK
8115 IF RECCOUNT(lcTmpCursor) > 0 AND .GenerateSQLTempTable(lcTmpCursor) AND .PopulateSQLTempTable(lcTmpCursor) AND !EMPTY(.cSQLTempTable)
8116 lcTmpTable = .cSQLTempTable
8117 ENDIF
8118 *=== TR 1085844 17-4-2015 VKK
8119
8120 *--- TR 1085844 *- 04/16/2015 YIK LOCAL ONLY
8121 *- There will be no Fake Carton scenario. X1 will always have real cartons.
8122
8123*!* lcFakeCtn = FAKE_CARTON_PREFIX
8124*!* IF RECCOUNT(lcTmpCursor) > 0 AND .GenerateSQLTempTable(lcTmpCursor) AND .PopulateSQLTempTable(lcTmpCursor) AND !EMPTY(.cSQLTempTable)
8125*!*
8126*!* TEXT TO lcsql TEXTMERGE NOSHOW FLAGS 1
8127*!* SELECT Distinct t.*, d.carton_num as new_carton_num
8128*!* From <<.cSQLTempTable>> t
8129*!* join zzoctnpd d
8130*!* ON t.division = d.division
8131*!* and t.style = d.style
8132*!* and t.color_code = d.color_Code
8133*!* and t.lbl_code = d.lbl_code
8134*!* and t.dimension = d.dimension
8135*!* and t.sizebucket = d.sizebucket
8136*!* and t.prod_num = d.prod_num
8137*!* join zzoctnph h
8138*!* ON h.pkey = d.fkey
8139*!* and h.carton_cls = <<SQLFormatChar(CARTON_CLASS_PRODUCTION)>>
8140*!* and h.carton_num like '<<lcFakeCtn>>%'
8141*!* ENDTEXT
8142*!*
8143*!* llRetVal = llRetVal and V_SQLExec(lcSQL, "__NewCartonList")
8144*!*
8145*!* IF USED("__NewCartonList")
8146*!* SELECT "__NewCartonList"
8147*!* INDEX On pkey TAG Pkey
8148
8149*!* SELECT (tcTranCarton)
8150*!* replace carton_num with __NewCartonList.new_carton_num ;
8151*!* FOR INDEXSEEK(Pkey,.T., "__NewCartonList") ;
8152*!* AND NOT EMPTY(__NewCartonList.new_carton_num)
8153*!*
8154*!* ENDIF
8155*!*
8156*!* ENDIF
8157
8158 *--- TR 1088958 31-Jul-2015 Goutam/Yuri
8159 *- This SQL has wrong order of JOINs, so it creates cartesian. Fix it.
8160 *- There's no need to group by after that.
8161 * need to generete new carton # also
8162*!* Select h.shpm_ref,c.carton_num, c.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket ,;
8163*!* 'N' as auto_invoice , h.pkey * 0 as zzoctnph_fkey, h.pkey*0 as line_seq, h.pkey * 0 as zzoctnpd_pkey, ;
8164*!* SPACE(7) as customer;
8165*!* from (tcTranHeader) h ;
8166*!* JOIN (tcTranCarton) c ;
8167*!* ON c.fkey = h.pkey ;
8168*!* JOIN (tcTranOrder) o ;
8169*!* ON o.fkey = h.pkey ;
8170*!* JOIN (tcTranDetail) d ;
8171*!* ON d.fkey = h.pkey ;
8172*!* WHERE h.Errs_Flg_H <> "Y" ;
8173*!* AND INLIST(asn_type, "DS", "X3") ;
8174*!* Group By h.shpm_ref,c.carton_num, c.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension,d.sizebucket ;
8175*!* INTO Cursor (lcTmpCursor)
8176
8177 Select h.shpm_ref,c.carton_num, c.ord_num, o.division, d.style, d.color_code, d.lbl_code, d.dimension, d.sizebucket ,;
8178 'N' as auto_invoice , h.pkey * 0 as zzoctnph_fkey, h.pkey*0 as line_seq, h.pkey * 0 as zzoctnpd_pkey, ;
8179 SPACE(7) as customer;
8180 from (tcTranHeader) h ;
8181 JOIN (tcTranCntr) cntr ;
8182 ON h.pkey = cntr.fkey ;
8183 JOIN (tcTranOrder) o ;
8184 ON cntr.pkey = o.ckey ;
8185 JOIN (tcTranCarton) c ;
8186 ON o.pkey = c.okey ;
8187 JOIN (tcTranDetail) d ;
8188 ON d.ctnkey = c.pkey ;
8189 WHERE h.Errs_Flg_H <> "Y" ;
8190 AND INLIST(asn_type, "DS", "X3") ;
8191 INTO Cursor (lcTmpCursor)
8192 *=== TR 1088958 31-Jul-2015 Goutam/Yuri
8193
8194 .cSQLTempTable=""
8195
8196 IF RECCOUNT(lcTmpCursor) > 0 AND .GenerateSQLTempTable(lcTmpCursor) AND .PopulateSQLTempTable(lcTmpCursor) AND !EMPTY(.cSQLTempTable)
8197
8198
8199 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8200 UPDATE T
8201 SET zzoctnph_fkey = ordsp.Pkey
8202 ,Line_Seq = ordline.line_Seq
8203 , Customer = ordline.customer
8204 , zzoctnpd_pkey = pd.pkey
8205 From <<.cSQLTempTable>> t
8206 Join (Select sp.Pkey, sp.ord_num, sp.Pick_num -- Take the last genereated order's pick as the new pick
8207 From zzoordsp sp
8208 join zzoordrh oh
8209 ON oh.ord_num = sp.ord_num
8210 And oh.pick_num = sp.pick_num
8211 and oh.inv_num = sp.inv_num
8212 And oh.pick_Batch = <<SqlFormatNum(.oAutoPickProcess.nPickBatch)>>
8213 and sp.inv_num = 0 and oh.ord_status = 'P'
8214 ) ordsp
8215 ON ordsp.ord_num = t.ord_num
8216 join zzoctnph ph
8217 ON ph.carton_num = t.carton_num
8218 join (Select h.customer,d.ord_num, d.pick_num, d.division, d.style, d.color_code,
8219 d.lbl_code, d.dimension, d.size_bk as sizebucket , MAX(d.line_seq) line_Seq
8220 From zvoordrdv d
8221 join zzoordrh h
8222 ON h.pkey = d.fkey
8223 Where d.line_status = 'P'
8224 And h.pick_Batch = <<SqlFormatNum(.oAutoPickProcess.nPickBatch)>>
8225 Group by h.customer,d.ord_num, d.pick_num, d.division, d.style, d.color_code,
8226 d.lbl_code, d.dimension, d.size_bk) Ordline
8227 ON ordsp.ord_num = ordline.ord_num
8228 And ordsp.pick_num = ordline.pick_num
8229 and t.division = ordline.division
8230 and t.style = ordline.style
8231 and t.color_code = ordline.color_Code
8232 and t.lbl_code = ordline.lbl_code
8233 and t.dimension = ordline.dimension
8234 and t.sizebucket = ordline.sizebucket
8235 join zzoctnpd pd
8236 ON ph.pkey = pd.fkey
8237 and t.division = pd.division
8238 and t.style = pd.style
8239 and t.color_code = pd.color_Code
8240 and t.lbl_code = pd.lbl_code
8241 and t.dimension = pd.dimension
8242 and t.sizebucket = pd.sizebucket
8243 ENDTEXT
8244
8245 llRetVal = llRetVal and V_SqlExec(lcSQL)
8246
8247*--- TR 1085844 *- 04/16/2015 YIK LOCAL ONLY
8248*- No need to generate new carton#
8249*!* * now we can customer, so we can generate carton #
8250*!* lcSQL = " Select distinct carton_num, customer, division, SPACE(20) new_carton_Num From " + .cSQLTempTable
8251*!* llRetVal = llRetVal AND V_SQLExec(lcSQL, "__CartonList")
8252*!*
8253*!* IF llRetVal
8254*!* SELECT __CartonList
8255*!*
8256*!* SCAN
8257*!* lcUCC128= .GetNextUCCNum(Division, "", , Customer)
8258*!* Replace new_carton_Num WITH lcUCC128 IN __CartonList
8259*!* ENDSCAN
8260*!* lcOldTmpTable = .cSQLTempTable
8261*!*
8262*!* .cSQLTempTable = ""
8263*!* llRetVal = llRetVal And .GenerateSQLTempTable("__CartonList") AND .PopulateSQLTempTable("__CartonList") AND !EMPTY(.cSQLTempTable)
8264*!* lcNewCartonTable = .cSQLTempTable
8265*!* .cSQLTempTable = lcOldTmpTable
8266*!*
8267*!* ENDIF
8268
8269 llRetVal = llRetVal And .CreateCustomerShipments(@lcCustomerShipmentInsert)
8270
8271 llBeganTransaction = THIS.BeginTransaction()
8272
8273*--- TR 1085844 *- 04/16/2015 YIK LOCAL ONLY
8274*- No need to use new carton# table. Added Customer and division replacement
8275*- removed ", carton_num = tnew.new_carton_Num "
8276 * stamp zzoctnph.fkey, carton_cls
8277 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8278 UPDATE T
8279 SET Fkey = tmp.zzoctnph_fkey
8280 , carton_cls = <<SQLFormatChar(CARTON_CLASS_SALES)>>
8281 ,shipment_num = 0
8282 , customer = tmp.customer
8283 , division = tmp.division
8284 , User_id = <<SQLFormatChar(EDI_USER)>>
8285 ,Last_mod = <<SQLFormatTs(DATETIME())>>
8286 From zzoctnph t
8287 join <<.cSQLTempTable>> tmp
8288 ON tmp.carton_num = t.carton_num
8289 ENDTEXT
8290
8291 llRetVal = llRetVal and V_SqlExec(lcSQL)
8292
8293*--- TR 1085844 *- 04/16/2015 YIK LOCAL ONLY
8294*- No need to JOIN with new carton# table. Removed ", carton_num = tnew.new_carton_Num "
8295 * stamp zzoctnph.line_Seq
8296 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8297 UPDATE T
8298 SET line_Seq = tmp.line_Seq
8299 , prod_num = 0
8300 ,prod_line = 0
8301 , User_id = <<SQLFormatChar(EDI_USER)>>
8302 ,Last_mod = <<SQLFormatTs(DATETIME())>>
8303 From zzoctnpd t
8304 join <<.cSQLTempTable>> tmp
8305 ON tmp.zzoctnpd_pkey = t.pkey
8306 ENDTEXT
8307
8308 llRetVal = llRetVal and V_SqlExec(lcSQL)
8309
8310 * stampm zzoordsp.cartons, carton_cls
8311 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8312 UPDATE T
8313 SET cartons = 'Y'
8314 , carton_Seq = COALESCE((Select MAX(Carton_Seq) From zzoctnph where fkey = t.pkey), 0)
8315 , User_id = <<SQLFormatChar(EDI_USER)>>
8316 ,Last_mod = <<SQLFormatTs(DATETIME())>>
8317 From zzoordsp t
8318 join <<.cSQLTempTable>> tmp
8319 ON tmp.zzoctnph_fkey = t.pkey
8320 ENDTEXT
8321
8322 llRetVal = llRetVal and V_SqlExec(lcSQL)
8323
8324 *--- TR 1085844 17-4-2015 VKK
8325 * stampm zzoordsp.cartons, carton_cls
8326 IF !EMPTY(lcTmpTable)
8327 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8328 UPDATE T
8329 SET cartons = 'N'
8330 , carton_Seq = 0
8331 , User_id = <<SQLFormatChar(EDI_USER)>>
8332 ,Last_mod = <<SQLFormatTs(DATETIME())>>
8333 From zzoordsp t
8334 join <<lcTmpTable>> tmp
8335 ON tmp.prod_num = t.prod_num
8336 AND t.carton_cls = <<SQLFormatChar(CARTON_CLASS_PRODUCTION)>>
8337 AND NOT EXISTS(SELECT 1
8338 FROM zzoctnph h
8339 WHERE h.fkey = t.Pkey
8340 AND h.carton_Cls = <<SQLFormatChar(CARTON_CLASS_PRODUCTION)>>)
8341
8342 ENDTEXT
8343
8344 llRetVal = llRetVal and V_SqlExec(lcSQL)
8345 ENDIF
8346 *=== TR 1085844 17-4-2015 VKK
8347
8348 * Stamp Sales Order header
8349 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8350 UPDATE H
8351 SET carton = COALESCE(a.carton, 0)
8352 , ack_prn = 'R' -- this is needed for auto invoice process.
8353 , weight = COALESCE(a.Weight, 0)
8354 , User_id = <<SQLFormatChar(EDI_USER)>>
8355 ,Last_mod = <<SQLFormatTs(DATETIME())>>
8356 From zzoordrh h
8357 Left join (Select oh.pkey,COUNT(*) Carton, SUM(Carton_wgt) Weight
8358 From zzoordsp sp
8359 join zzoordrh oh
8360 ON oh.ord_num = sp.ord_num
8361 And oh.pick_num = sp.pick_num
8362 And oh.inv_num = sp.inv_num
8363 And oh.pick_batch = <<.oAutoPickProcess.nPickBatch>>
8364 join zzoctnph ph
8365 on ph.FKEY = sp.pkey
8366 Group by oh.Pkey )A
8367 ON h.pkey = a.Pkey
8368 Where h.pick_batch = <<.oAutoPickProcess.nPickBatch>>
8369 ENDTEXT
8370
8371 llRetVal = llRetVal and V_SqlExec(lcSQL)
8372
8373 IF NOT EMPTY(lcCustomerShipmentInsert)
8374 llRetVal = llRetVal and V_SqlExec(lcCustomerShipmentInsert)
8375 ENDIF
8376
8377 IF llRetVal
8378 IF llBeganTransaction
8379 THIS.EndTransaction()
8380 ENDIF
8381 ELSE
8382 IF llBeganTransaction
8383 THIS.RollbackTransaction()
8384 ENDIF
8385 ENDIF
8386
8387 IF llRetVal
8388 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8389 SELECT h.shpm_ref, SUM(Carton) Cartons
8390 From (Select distinct shpm_ref, ord_num from <<.cSQLTempTable>>) h
8391 join zzoordrh oh
8392 ON oh.ord_num = h.ord_num
8393 And oh.pick_batch = <<.oAutoPickProcess.nPickBatch>>
8394 Group by h.shpm_ref
8395 ENDTEXT
8396
8397 llRetVal = llRetVal and V_SqlExec(lcSQL, "__ShipCartons")
8398
8399 IF llRetVal AND RECCOUNT("__ShipCartons") > 0
8400
8401 SELECT __ShipCartons
8402 SUM Cartons TO .nTotalCartonsCreated
8403 GO top
8404 SCAN
8405 lcLog = TEXTMERGE("<<Cartons>> sales carton(s) created for shipment <<ALLTRIM(shpm_ref)>>.")
8406 .LogEntry(lcLog)
8407 ENDSCAN
8408
8409 .cMsgFromCartons= CRLF + ALLTRIM(STR(.nTotalCartonsCreated)) + " sales carton(s) created." + CRLF
8410 .LogEntry("")
8411 ENDIF
8412 ENDIF
8413 ENDIF
8414
8415 ENDWITH
8416
8417 SELECT (lnSelect)
8418 RETURN llRetVal
8419 ENDFUNC
8420
8421
8422*============================================================
8423
8424
8425
8426 FUNCTION CreateCustomerShipments
8427 LPARAMETERS tcSQLString
8428 LOCAL llRetVal, lnSelect, llBeganTransaction, lcTmpCursor, lcCBolTmpTable, lcStampData , lcSQLString
8429
8430 llRetVal = true
8431 lnSelect = SELECT()
8432 lcSQLString = ""
8433 WITH This
8434
8435
8436 lcStampData = "#" + GetUniqueFileName()
8437 lcCBolTmpTable = "#" + GetUniqueFileName()
8438 * stamp zzoctnph.fkey, carton_cls
8439 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8440 select t.pkey
8441 , min(md.depart_date) as depart_date
8442 , min(md.manifest_date) as manifest_date
8443 , MIN(mh.consol_group) as consol_group
8444 , MIN(t.bill_num) as bill_num
8445 , MIN(Checksum(t.bill_num)) as bol_group
8446 ,(COALESCE((SELECT TOP 1 xfer_loc
8447 FROM zzxicxfr x
8448 WHERE from_org = l.org_code
8449 AND to_org = t.org_code
8450 AND (customer = '' OR customer = t.customer)
8451 AND (store = '' OR (customer = t.customer and store = t.store))
8452 AND (from_loc = '' or from_loc = t.location)
8453 ORDER BY x.store desc,x.customer desc,from_loc desc),'')) as xfer_loc
8454 Into <<lcStampData>>
8455 from zzoordrh t
8456 join zzoupsib c
8457 on t.pick_num = c.pick_num
8458 left join zzxshipr sh
8459 on t.shipper = sh.shipper
8460 join zzyshmfh mh
8461 on mh.manifest_group = COALESCE(sh.manifest_group, '')
8462 and mh.location = t.location
8463 and mh.carr_code = COALESCE(sh.carr_code, '')
8464 join zzyshmfd md
8465 on md.fkey = mh.pkey
8466 JOIN zzxlocar l
8467 ON t.location = l.location
8468 where md.manifest_date = c.tb_dt_act
8469 and t.pick_batch = <<.oAutoPickProcess.nPickBatch>> And t.bill_num > ''
8470 group by t.pkey, t.ORG_CODE ,l.org_code,t.CUSTOMER,t.STORE,t.location
8471 ENDTEXT
8472
8473 llRetVal = llRetVal and V_SqlExec(lcSQL)
8474
8475 TEXT TO lcsql TEXTMERGE NOSHOW FLAGS 1
8476 UPDATE t
8477 SET DAYS_TO_CNLDT = COALESCE((m1.DAYS_TO_CNLDT),(m2.DAYS_TO_CNLDT), 0)
8478 , INTO_DC_CSHN= COALESCE((m1.INTO_DC_CSHN),(m2.INTO_DC_CSHN), 0)
8479 ,INTO_DC_DAYS= COALESCE((m1.INTO_DC_DAYS),(m2.INTO_DC_DAYS), 0)
8480 ,TRAN_DAYS = COALESCE((m1.TRAN_DAYS), (m2.TRAN_DAYS),0)
8481 ,VOYAGE_DAYS= COALESCE((m1.VOYAGE_DAYS),(m2.VOYAGE_DAYS), 0)
8482 From <<.cOrdersETA>> t
8483 Join zzcordrh h
8484 ON h.prod_num = t.prod_num
8485 And h.division = t.division
8486 Left join zzctrtmr m1
8487 ON m1.PORT_EXIT = h.PORT_EXIT
8488 AND m1.SHIPTO = h.Shipto
8489 And m1.SHIPPER = h.shipper
8490 And m1.CONTRACTOR = h.CONTRACTOR
8491 and m1.shipto = h.shipto
8492 Left join zzctrtmr m2
8493 ON m2.PORT_EXIT = h.PORT_EXIT
8494 AND m2.SHIPTO = h.Shipto
8495 And m2.SHIPPER = h.shipper
8496 And m2.CONTRACTOR = ''
8497 and m2.shipto = h.shipto
8498
8499 UPDATE <<.cOrdersETA>>
8500 SET recalc_eta = replace(replace(replace(replace(REPLACE(LTRIM(RTRIM((recalc_eta))),'A','A+'),'B','B+'), 'C','C+'),'D','D+'),'E','E+') + '0'
8501
8502 UPDATE <<.cOrdersETA>>
8503 SET recalc_eta = REPLACE(LTRIM(RTRIM(recalc_eta)),'B', LTRIM(RTRIM(CAST(DAYS_TO_CNLDT AS VARCHAR))))
8504
8505 UPDATE <<.cOrdersETA>>
8506 SET recalc_eta = REPLACE(LTRIM(RTRIM(recalc_eta)),'A', LTRIM(RTRIM(CAST(TRAN_DAYS AS VARCHAR))))
8507
8508 UPDATE <<.cOrdersETA>>
8509 SET recalc_eta = REPLACE(LTRIM(RTRIM(recalc_eta)),'C', LTRIM(RTRIM(CAST(VOYAGE_DAYS AS VARCHAR))))
8510
8511 UPDATE <<.cOrdersETA>>
8512 SET recalc_eta = REPLACE(LTRIM(RTRIM(recalc_eta)),'D', LTRIM(RTRIM(CAST(INTO_DC_DAYS AS VARCHAR))))
8513
8514 UPDATE <<.cOrdersETA>>
8515 SET recalc_eta = REPLACE(LTRIM(RTRIM(recalc_eta)),'E', LTRIM(RTRIM(CAST(INTO_DC_CSHN AS VARCHAR))))
8516
8517 ENDTEXT
8518
8519 llRetVal = llRetVal and V_SqlExec(lcSQL)
8520
8521 * Now we have all the formula ready, need to evaluate it, VFP is the best place
8522 lcSQL = " Select Ord_num, MAX(Eta_date) Eta_date, MAX(recalc_eta) recalc_eta From " + .cOrdersETA + ;
8523 " Group By Ord_Num "
8524
8525 llRetVal = llRetVal and V_SqlExec(lcSQL, "__ETAOrderCursor")
8526 IF llRetVal
8527 SELECT __ETAOrderCursor
8528 Replace ALL Eta_date WITH TTOD(Eta_date) + NVL(EVALUATE(recalc_eta), 0)
8529
8530 v_sqlexecnoerror('drop table ' + .cOrdersETA)
8531
8532 lcSQL = "CREATE TABLE " + .cOrdersETA + " (ord_Num INT, eta_date datetime, recalc_eta Varchar(100))"
8533
8534 llRetVal = llRetVal and V_SqlExec(lcSQL)
8535
8536 * Delete and insert it back
8537 llRetVal = llRetVal AND .BulkInsertFromCursor("__ETAOrderCursor",.cOrdersETA) && will be used later for zzxcbolr
8538 ENDIf
8539
8540 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8541 select ABS(CheckSum(H.BILL_NUM) ) as PKEY
8542 , H.BILL_NUM
8543 , H.CUSTOMER
8544 , max(A.S_EDI_SHIP_TO) as EDI_SHIP_TO
8545 , dbo.bcfn_ConvVicsBol('', MIN(H.DIVISION), H.BILL_NUM) as VICSBOL
8546 , max(H.FREIGHT_TRM) FREIGHT_TRM /* 1 as FREIGHT_TRM */
8547 , 1 as Carton_chk
8548 , max(H.Start_Date) as ACT_SHIP_DATE
8549 , case
8550 when min(H.END_DATE) = {ts '2999-01-01 00:00:00' } then {ts '1900-01-01 00:00:00' }
8551 else min(H.END_DATE)
8552 end as pub_ship_date
8553 , 1 as Pallet_Chk
8554 , 1 as Ship_Load
8555 , 2 as Ship_Count
8556 , min(H.SHIPPER) as SHIPPER
8557 , 0 as GOH_CHK
8558 , coalesce(MIN(s.scac_code), '') as scac_code
8559 , coalesce(MIN(s.Carr_Code), '') as Carr_Code
8560 , max(H.START_DATE) as UDFBOL1D
8561 , case
8562 when min(H.END_DATE) = {ts '2999-01-01 00:00:00' } then {ts '1900-01-01 00:00:00' }
8563 else min(H.END_DATE)
8564 end as Udfbol2d
8565 , max(h.location) as location
8566 , max(coalesce(r.store, c.customer, d.center_code, '')) as ship_to
8567 , min(coalesce(t1.depart_date,'')) as depart_date
8568 , min(coalesce(t1.manifest_date,'')) as ship_date
8569 , min(coalesce(t1.xfer_loc,'')) as xfer_loc
8570 , min(coalesce(t1.consol_group,'')) as consol_group
8571 , min(coalesce(t2.bill_num, '')) as bol_group
8572 , max(coalesce(bc.carton_cnt,0)) as carton_cnt
8573 , max(coalesce(bc.carton_wgt,0) ) as weight
8574 , max(coalesce(bc.carton_vol,0)) as cube
8575 , max(coalesce(o.Eta_date,'')) as Eta_Date
8576 INTO <<lcCBolTmpTable>>
8577 from (
8578 select DIVISION
8579 , BILL_NUM
8580 , CUSTOMER
8581 , ORD_NUM
8582 , PICK_NUM
8583 , INV_NUM
8584 , CNCL_NUM
8585 , START_DATE
8586 , LOCATION
8587 , H.SHIPPER
8588 , COALESCE(ST.FREIGHT_TRM
8589 , 1) FREIGHT_TRM, case
8590 when END_DATE <> {ts '1900-01-01 00:00:00' } then END_DATE
8591 else {ts '2999-01-01 00:00:00' }
8592 end as END_DATE, h.carton, h.weight, h.ord_volume
8593 from ZZOORDRH H
8594 left join ZZOSHPTR ST
8595 on H.SHIP_TERMS = ST.SHIP_TERMS
8596 and H.SHIP_TERMS > ' '
8597 where ord_status ='P' and pick_batch = <<.oAutoPickProcess.nPickBatch>> and bill_num > ''
8598 ) H
8599 join ZZORDAD2 A
8600 on H.ORD_NUM=A.ORD_NUM
8601 and H.PICK_NUM =A.PICK_NUM
8602 and H.INV_NUM =A.INV_NUM
8603 and H.CNCL_NUM = A.CNCL_NUM
8604 join <<.cOrdersETA>> o
8605 ON o.ord_num = h.ord_num
8606 join (
8607 select h.bill_num
8608 , SUM(CASE
8609 when mc.pkey is not null
8610 and mc.master_carton <> ch.carton_num then 0
8611 else 1 END) as carton_cnt, SUM(CASE
8612 when mc.pkey is not null
8613 and mc.master_carton <> ch.carton_num then 0
8614 else COALESCE(carton_vol, 0) END) as carton_vol, SUM(CASE
8615 when mc.pkey is not null
8616 and mc.master_carton <> ch.carton_num then 0
8617 else COALESCE(carton_wgt, 0) END) as carton_wgt
8618 from (
8619 select h.bill_num
8620 , s.pkey
8621 from zzoordrh h
8622 join zzoordsp s
8623 on h.ord_num = s.ord_num
8624 and h.pick_num = s.pick_num
8625 and h.inv_num = s.inv_num
8626 and ord_status ='P' and pick_batch = <<.oAutoPickProcess.nPickBatch>> and bill_num > ''
8627 ) h
8628 left join zzoctnph ch
8629 on h.pkey = ch.fkey
8630 left join zzymastd mc
8631 on ch.carton_num = mc.carton_num
8632 group by h.bill_num)BC
8633 on h.bill_num = bc.bill_num
8634 left join ZZXSTORR R
8635 on r.pkey = case
8636 when a.s_table = 'ZZXSTORR' then a.s_pkey
8637 else 0
8638 end
8639 left join zzxdistr d
8640 on d.pkey = case
8641 when a.s_table = 'ZZXDISTR' then a.s_pkey
8642 else 0
8643 end
8644 left join ZZXCUSTR C
8645 on c.pkey = case
8646 when a.s_table = 'ZZXCUSTR' then a.s_pkey
8647 else 0
8648 end
8649 left join ZZXSHIPR s
8650 on H.SHIPPER = S.SHIPPER
8651 left join <<lcStampData>> t1
8652 on t1.bill_num = h.bill_num
8653 left join (
8654 select bol_group
8655 , MIN(bill_num) as bill_num
8656 from <<lcStampData>>
8657 group by bol_group ) t2
8658 on t1.bol_group = t2.bol_group
8659 where not exists(
8660 select 1
8661 from zzxcbolr bol
8662 where bol.customer = h.customer
8663 and bol.bill_num = h.bill_num )
8664 group by H.BILL_NUM
8665 , H.CUSTOMER
8666 ENDTEXT
8667
8668 llRetVal = llRetVal and V_SqlExec(lcSQL)
8669
8670 WITH .oSB
8671 .SB_Reset()
8672 .cSB_Target = "ZZXCBOLR"
8673 .cSB_Source = lcCBolTmpTable
8674 .cSB_SourceAlias = "t"
8675 .SB_SetLiteralFieldValue("User_Id",SQLFormatChar(goenv.envlogin.cUserName))
8676 .SB_SetLiteralFieldValue("Last_Mod",SQLFormatTS(DATETIME()))
8677
8678 llRetVal = .SB_GenerateSQLInsertString()
8679 IF llRetVal
8680 lcSQLString = .cSQLString
8681 ENDIF
8682 ENDWITH
8683
8684 tcSQLString = lcSQLString
8685
8686 ENDWITH
8687
8688 SELECT (lnSelect)
8689 RETURN llRetVal
8690 ENDFUNC
8691
8692*============================================================
8693
8694 FUNCTION CheckProcessStatus
8695 LPARAMETERS tcEispth, tcEisptd, tcEisptn, tcEispto, tcEisptc, tcProcessType
8696 LOCAL llRetVal, lnSelect, lcSQL
8697 * tcProcessType
8698 * 1. "GIT" -> Git process done
8699 * 2. "PCK" -> Pick Process done
8700 llRetVal = true
8701 lnSelect = SELECT()
8702
8703 WITH This
8704
8705 DO Case
8706 CASE tcProcessType = "GIT"
8707
8708 Select Distinct h.Pkey, h.shipment_num, d.carton_num, asn_type from (tcEispth) h JOIN (tcEisptn) d ;
8709 ON d.fkey = h.pkey JOIN zzeispcr c ;
8710 ON h.Control_Key = c.pkey ;
8711 WHERE h.Errs_Flg_H <> "Y" AND ;
8712 (c.Auto_GT = 'Y' OR asn_type = 'DS' OR asn_type = 'X1') ;
8713 AND INLIST(asn_type, "", " ", "DS", "X1") AND git_ind = 1 ;
8714 INTO Cursor __GITProcesed
8715
8716 .cSQLTempTable=""
8717
8718 IF RECCOUNT("__GITProcesed") > 0 AND .GenerateSQLTempTable("__GITProcesed") AND .PopulateSQLTempTable("__GITProcesed") AND !EMPTY(.cSQLTempTable)
8719 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8720 UPDATE h
8721 SET git_ind = 2
8722 ,Errs_Flg_H = 'Y'
8723 ,Errs_Msg_H = 'Some of the carton(s) failed in GIT Process.'
8724 From zzeispth h
8725 Join <<.cSQLTempTable>> t
8726 ON t.pkey = h.pkey
8727 Where Exists(Select 1 From zzyrfshp
8728 where carton_num = t.carton_num
8729 And shipment_num = t.shipment_num)
8730 ENDTEXT
8731
8732 llRetVal = llRetval And V_SQLExec(lcSQL)
8733 llRetVal = llRetval And .StampLocalHeaderCursorWithError(tcEispth)
8734 ENDIF
8735
8736 CASE tcProcessType = "PCK"
8737
8738 Select Distinct h.Pkey, h.shpm_ref, d.ord_num from (tcEispth) h JOIN (tcEisptn) d ;
8739 ON d.fkey = h.pkey ;
8740 WHERE h.Errs_Flg_H <> "Y" ;
8741 AND INLIST(asn_type, "DS", "X3") ;
8742 INTO Cursor __GITProcesed
8743
8744 .cSQLTempTable=""
8745
8746 IF RECCOUNT("__GITProcesed") > 0 AND .GenerateSQLTempTable("__GITProcesed") AND .PopulateSQLTempTable("__GITProcesed") AND !EMPTY(.cSQLTempTable)
8747 TEXT TO lcSQL TEXTMERGE NOSHOW FLAGS 1
8748 UPDATE h
8749 SET git_ind = 4
8750 ,Errs_Flg_H = 'Y'
8751 ,Errs_Msg_H = 'Some of the Orders(s) failed in Auto Pick Process.'
8752 From zzeispth h
8753 Join <<.cSQLTempTable>> t
8754 ON t.pkey = h.pkey
8755 Where NOT Exists(Select 1 From zzoordrh
8756 where ord_num = t.ord_num
8757 And ord_status = 'P'
8758 And pick_batch = <<SqlFormatNum(.oAutoPickProcess.nPickBatch)>>)
8759 ENDTEXT
8760
8761 llRetVal = llRetval And V_SQLExec(lcSQL)
8762 llRetVal = llRetval And .StampLocalHeaderCursorWithError(tcEispth)
8763 ENDIF
8764 ENDCASE
8765
8766 ENDWITH
8767
8768 SELECT (lnSelect)
8769 RETURN llRetVal
8770 ENDFUNC
8771
8772
8773*============================================================
8774
8775 FUNCTION StampLocalHeaderCursorWithError
8776 LPARAMETERS tcEispth
8777 LOCAL llRetVal, lnSelect
8778
8779 llRetVal = true
8780 lnSelect = SELECT()
8781
8782 WITH This
8783 lcSql = "Select pkey from zzeispth Where Errs_flg_H = 'Y' "
8784 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
8785
8786 SELECT _tmpValidationCursor
8787 INDEX on PKey TAG Pkey
8788 SELECT (tcEispth)
8789 replace errs_flg_h with 'Y' ; && no need for error messgae here.
8790 FOR INDEXSEEK(Pkey,.F., "_tmpValidationCursor" ) AND errs_flg_h <> 'Y'
8791 ENDWITH
8792
8793 SELECT (lnSelect)
8794 RETURN llRetVal
8795 ENDFUNC
8796
8797
8798*============================================================
8799
8800 FUNCTION CalculateCounts
8801 LPARAMETERS tlInitial
8802 LOCAL llRetVal, lnSelect
8803
8804 llRetVal = true
8805 lnSelect = SELECT()
8806
8807 WITH This
8808 lcSql = "Select COUNT(*) Cnt from zzeispth h " + THIS.cFilterCriteria
8809 llRetVal = v_sqlexec(lcSql, '_tmpValidationCursor')
8810
8811 IF tlInitial
8812 .nToProcess = _tmpValidationCursor.Cnt
8813 ELSE
8814 .nProcessed = (.nToProcess - _tmpValidationCursor.Cnt)
8815 ENDIF
8816
8817 ENDWITH
8818
8819 SELECT (lnSelect)
8820 RETURN llRetVal
8821 ENDFUNC
8822
8823*=== TR 1082847 31-1-2015 VKK
8824*============================================================
8825*--- TR 1085844 18-Apr-2015 Goutam.
8826 Function CreatePickCursorLocal
8827 Lparameters pcCursor
8828 Local lcSizes, lcCommand, lcCursor, lcPickCursor
8829
8830 lcPickCursor = This.oAutoPickProcess.cPick_Cursor
8831 lcCursor = Iif(Empty(pcCursor), lcPickCursor, pcCursor)
8832
8833 lcSizes = v_CreateSizesStru(,,,"N(17,8)")
8834 lcCommand = "CREATE CURSOR " + lcCursor + ;
8835 " (ord_num i(4), line_Seq i(4), division c(3), shipper c(3), style c(50), " + ;
8836 " color_code c(50), lbl_code c(7), dimension c(5), " +;
8837 " pkey i(4), fkey i(4), total_qty n(17,8), " + ;
8838 " location C(6),"+ ;
8839 lcSizes + ")"
8840
8841 &lcCommand
8842
8843 INDEX On Pkey TAG Pkey
8844 INDEX on ord_num TAG Ord_Num
8845
8846 Return Used(lcCursor)
8847 Endfunc
8848*=== TR 1085844 18-Apr-2015 Goutam.
8849
8850 *--- TR 1104734 2-Sep-2017 Goutam
8851 FUNCTION BackFillProductionStage
8852 LPARAMETERS tceispTH, tceispTD, tceispTO, tceispCR
8853 LOCAL llRetVal, lnSelect, lcSql, lcSizeField, lcSizeRepl, lcWipField
8854
8855 llRetVal = true
8856 lnSelect = SELECT()
8857
8858 WITH This
8859 lcSql = "Select d.* from " + tceispTD + " d join " + tceispTH + " h on h.pkey = d.fkey " +;
8860 " join " + tceispCR + " c on c.pkey = h.Control_Key " +;
8861 " where h.Errs_Flg_H <> 'Y' and empty(h.asn_type) and c.backfill = 'Y' and c.Auto_GT = 'Y' " +;
8862 " order by d.prod_num, d.open_seq"
8863
8864 llRetVal = llRetVal And v_SqlExec(lcSql,'__ISPTDCurs',,true)
8865
8866 IF llRetVal and RECCOUNT('__ISPTDCurs') > 0
8867 .LogEntry("Back filling of production order started.")
8868
8869 lcSql = "Select h.contractor, d.* from zzcordrd d join zzcordrh h on h.pkey = d.fkey where 1=2"
8870 llRetVal = llRetVal And v_SqlExec(lcSql, '__Proddtl')
8871
8872 lcSql = "Select distinct prod_num, open_seq from __ISPTDCurs"
8873 llRetVal = llRetVal And v_SqlExec(lcSql, '__Proddtl2',,true)
8874
8875 .cSQLTempTable=""
8876 IF llRetVal AND RECCOUNT('__Proddtl2') > 0 AND .GenerateSQLTempTable('__Proddtl2') AND .PopulateSQLTempTable('__Proddtl2') AND !EMPTY(.cSQLTempTable)
8877 USE IN SELECT('__Proddtl2')
8878
8879 lcSql = ;
8880 "select h.contractor"+;
8881 " , d.* "+;
8882 " from zzcordrd d"+;
8883 " join zzcordrh h "+;
8884 " on h.pkey = d.fkey"+;
8885 " join " + .cSQLTempTable + " t "+;
8886 " on t.prod_num = d.prod_num "+;
8887 " and t.open_seq = d.prod_line "+;
8888 " where ( "+;
8889 " select sum(rd.total_qty) "+;
8890 " from zzcordrd rd"+;
8891 " join zzcordrh rh "+;
8892 " on rh.pkey = rd.fkey "+;
8893 " where rd.fkey = d.fkey "+;
8894 " and rd.stage_num = d.stage_num) >= ( "+;
8895 " select sum(rd.total_qty) "+;
8896 " from zzcordrd rd"+;
8897 " join zzcordrh rh "+;
8898 " on rh.pkey = rd.fkey"+;
8899 " join zzctyped td "+;
8900 " on td.division = rh.division "+;
8901 " and td.prod_type = rh.prod_type "+;
8902 " and td.res_ok = 'C' "+;
8903 " where rd.fkey = d.fkey "+;
8904 " and rd.stage_num = ( "+;
8905 " select max(stage_num) "+;
8906 " from zzcordrd "+;
8907 " where fkey = rd.fkey)) "+;
8908 " and exists( "+;
8909 " select 1 "+;
8910 " from zzcordrd rd"+;
8911 " join zzcordrh rh "+;
8912 " on rh.pkey = rd.fkey"+;
8913 " join zzctyped td "+;
8914 " on td.division = rh.division "+;
8915 " and td.prod_type = rh.prod_type "+;
8916 " and td.res_ok = 'C' "+;
8917 " where rd.fkey = d.fkey "+;
8918 " and rd.stage_num = ( "+;
8919 " select max(stage_num) "+;
8920 " from zzcordrd "+;
8921 " where fkey = rd.fkey) "+;
8922 " having count(1) > 1)"
8923
8924 llRetVal = llRetVal And v_SqlExec(lcSql, '__Proddtl2')
8925
8926 IF llRetVal AND RECCOUNT('__Proddtl2') > 0
8927
8928 lcSql = ;
8929 "select rd.pkey"+;
8930 " , rd.prod_num"+;
8931 " , rd.prod_line"+;
8932 " from zzcordrd rd"+;
8933 " join zzcordrh rh "+;
8934 " on rh.pkey = rd.fkey"+;
8935 " join zzctyped td "+;
8936 " on td.division = rh.division "+;
8937 " and td.prod_type = rh.prod_type "+;
8938 " and td.res_ok = 'C'"+;
8939 " join " + .cSQLTempTable + " tmp "+;
8940 " on tmp.prod_num = rh.prod_num "+;
8941 " where rd.prod_line = ( "+;
8942 " select max(prod_line) "+;
8943 " from zzcordrd "+;
8944 " where fkey = rd.fkey)"
8945
8946 llRetVal = llRetVal And v_SqlExec(lcSql, '__ProddtllastLineCurs')
8947 IF llRetVal
8948 SELECT __ProddtllastLineCurs
8949 INDEX on prod_num TAG prod_num
8950
8951 SELECT __Proddtl2
8952 INDEX on STR(prod_num) + STR(prod_line) TAG prod_num
8953 lcSizeField = ""
8954 lcWipField = ""
8955 FOR i = 1 TO goEnv.MaxBuckets
8956 lcSizeField = lcSizeField + "+" + 'Size' + Transform(i, "@L 99") + '_Qty'
8957 lcWipField = lcWipField + "+" + 'Wip' + Transform(i, "@L 99") + '_Qty'
8958 NEXT
8959 lcSizeField = SUBSTR(lcSizeField, 2)
8960 lcWipField = SUBSTR(lcWipField, 2)
8961 SELECT __ISPTDCurs
8962 GO top
8963 lnProd_num = 0
8964 DO WHILE !EOF()
8965 SCATTER NAME loISPTD MEMO
8966 IF (lnProd_num <> loISPTD.Prod_num)
8967 IF SEEK(STR(loISPTD.prod_num)+STR(loISPTD.open_seq), '__Proddtl2', 'prod_num')
8968 SELECT __Proddtl2
8969 SCATTER NAME loDtl MEMO
8970 loISPTD.pkey = loDtl.pkey
8971 loISPTD.fkey = loDtl.fkey
8972 SELECT __Proddtl
8973 APPEND BLANK
8974 BLANK
8975 GATHER NAME loDtl MEMO
8976 GATHER NAME loISPTD MEMO
8977 ENDIF
8978 ENDIF
8979 lcSizeRepl = "Replace size" + TRANSFORM(loISPTD.sizebucket, "@L 99") + "_qty with " + ALLTRIM(STR(loISPTD.qty)) + ", wip" + TRANSFORM(loISPTD.sizebucket, "@L 99") + "_qty with " + ALLTRIM(STR(loISPTD.qty)) + " in __Proddtl"
8980 &lcSizeRepl
8981 SELECT __ISPTDCurs
8982 lnProd_num = Prod_num
8983 SKIP
8984 IF lnProd_num <> Prod_num
8985 SELECT __Proddtl
8986 lcSizeRepl = "replace total_qty with " + lcSizeField
8987 lcWipRepl = "replace wip_total with " + lcWipField
8988 &lcSizeRepl
8989 &lcWipRepl
8990 ENDIF
8991 SELECT __ISPTDCurs
8992 ENDDO
8993 IF llRetVal
8994 .oAutoSplitProcess.cWorkAlias = '__Proddtl'
8995 .oAutoSplitProcess.cProddtllastLineCurs = '__ProddtllastLineCurs'
8996 .oAutoSplitProcess.lCalledFrom856Resize = true
8997 .oAutoSplitProcess.lSplitLineAdjustQty = false
8998 .oAutoSplitProcess.olog = .olog
8999 .oAutoSplitProcess.lScheduled = true
9000 llRetVal = .oAutoSplitProcess.ProcessProductionSplit()
9001 .oAutoSplitProcess.lCalledFrom856Resize = false
9002 .oAutoSplitProcess.cProddtllastLineCurs = ''
9003 ENDIF
9004 ENDIF
9005 ENDIF
9006 ENDIF
9007 ENDIF
9008
9009 ENDWITH
9010 loDtl = null
9011 loISPTD = null
9012 USE IN SELECT('__Proddtl2')
9013 USE IN SELECT('__ISPTDCurs')
9014 USE IN SELECT('__Proddtl1')
9015 USE IN SELECT('__ProddtllastLineCurs')
9016 SELECT (lnSelect)
9017 RETURN llRetVal
9018 ENDFUNC
9019 *=== TR 1104734 2-Sep-2017 Goutam
9020
9021ENDDEFINE
9022
9023*--- TR 1076260 31-3-2014 VKK
9024DEFINE CLASS BPOProduction_ISP AS BPOProduction
9025
9026lPartialCancelQuantity = true
9027
9028
9029ENDDEFINE
9030*=== TR 1076260 31-3-2014 VKK
9031
9032*--- OLD CheckUpc procedure
9033*!* PROCEDURE CheckUpc
9034*!* LPARAMETERS pceiSPTH, pceiSPTD
9035
9036*!* LOCAL llRetVal, lnOldSelect, loEiSPth, loEiSPtd, lcMssg, lcOldCust, lcOldItem, ;
9037*!* lcDivision, lcStyle, lcColor_code, lcLbl_code, lcDimension, lnSizeBucket, lcErrs_Msg, ;
9038*!* lnSize_desc
9039
9040*!* llRetVal = .T.
9041*!* lcErrs_Msg= ""
9042*!* lnOldSelect = SELECT()
9043
9044*!* SELECT d.upc, d.pkey ;
9045*!* FROM (pceiSPTH) h, (pceiSPTD) d ;
9046*!* WHERE NOT EMPTY(d.upc) ;
9047*!* AND (EMPTY(d.STYLE) OR EMPTY(d.color_code) OR EMPTY(d.sizebucket) OR EMPTY(d.size_desc) ) ;
9048*!* AND h.pkey = d.fkey ;
9049*!* ORDER BY h.doc_num, d.upc ;
9050*!* INTO CURSOR tmpCurs
9051
9052*!* lcOldCust = ""
9053*!* lcOldItem = ""
9054
9055*!* SELECT tmpCurs
9056*!* IF THIS.lUserInterface
9057*!* THIS.UpdateThermoCaption("Validating UPC(s)...")
9058*!* THIS.InitThermo(THIS.CountTotalRecs ('tmpCurs'))
9059*!* l_nThermoCnt = 0
9060*!* ENDIF
9061
9062*!* SCAN
9063*!* IF THIS.lUserInterface
9064*!* l_nThermoCnt = l_nThermoCnt + 1
9065*!* THIS.AdvanceThermo(l_nThermoCnt)
9066*!* ENDIF
9067
9068*!* lcErrs_Msg = ""
9069
9070*!* IF vl_upcnr(Left(tmpCurs.upc, 11),, "tmpUpcnr")
9071*!* lcDivision = tmpUpcnr.division
9072*!* lcStyle = tmpUpcnr.STYLE
9073*!* lcColor_code = tmpUpcnr.color_code
9074*!* lcLbl_code = tmpUpcnr.lbl_code
9075*!* lcDimension = tmpUpcnr.DIMENSION
9076*!* lnSizeBucket = tmpUpcnr.Sizebucket
9077*!* lnSize_desc = tmpUpcnr.size_desc
9078*!* ELSE
9079*!* lcErrs_Msg = "Invalid UPC." + CRLF
9080*!* STORE "" TO lcDivision, lcStyle, lcColor_code, ;
9081*!* lcLbl_code, lcDimension, lnSize_desc
9082*!* STORE 0 TO lnSizeBucket
9083*!* ENDIF
9084
9085*!* SELECT (pceiSPTD)
9086*!* lnWorkArea = SELECT()
9087*!* =SEEK(tmpCurs.pkey, lnWorkArea, "pkey")
9088*!* SCATTER NAME loEiSPtd MEMO
9089*!*
9090*!* IF !EMPTY(lcErrs_Msg)
9091*!* loEiSPtd.Errs_Msg_D = ALLTRIM(loEiSPtd.Errs_Msg_D) + lcErrs_Msg
9092*!* loEiSPtd.errs_flg_D = "Y"
9093*!* ENDIF
9094*!*
9095*!* IF !EMPTY(lcDivision)
9096*!* loEiSPtd.STYLE = lcStyle
9097*!* loEiSPtd.color_code = lcColor_code
9098*!* loEiSPtd.lbl_code = lcLbl_code
9099*!* loEiSPtd.DIMENSION = lcDimension
9100*!* loEiSPtd.Sizebucket = lnSizeBucket
9101*!* loEiSPtd.size_desc = lnSize_desc
9102*!* ENDIF
9103*!*
9104*!* GATHER NAME loEiSPtd MEMO
9105*!* ENDSCAN
9106
9107*!* USE IN tmpCurs
9108
9109*!* IF THIS.lUserInterface
9110*!* THIS.ResetThermo()
9111*!* ENDIF
9112
9113*!* IF USED("tmpUpcnr")
9114*!* USE IN tmpUpcnr
9115*!* ENDIF
9116
9117*!* SELECT(lnOldSelect)
9118*!* RETURN llRetVal
9119*!* ENDPROC