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