· 9 years ago · Feb 03, 2017, 08:06 PM
1*****************************************************************************************
2* Program....: clsoifpr.PRG
3* Date.......: 11/27/00
4* Abstract...: 810(o) factor process Process Business Object Class
5*****************************************************************************************
6#INCLUDE System.h
7#Include EDI.h
8#Define VFP_EMPTY_DATE_DEFAULT {01/01/1900}
9
10Define Class BPO810FactorProcess As BPOEDIBase
11 Name = "BPO810FactorProcess"
12 cTitle = "810(o) Factor Process"
13 lErrorState = .F.
14 oFrmOutput = Null && Object handle for print dialog form
15 cCaption = ""
16 lUserInterface= .F.
17
18 nInvoices= 0
19 nHistory= 0
20 nInterface= 0
21 nTransaction= 0
22
23 nTranHeader= 0
24 nTranDetail= 0
25 nTranComment= 0
26 nTranAddress= 0
27 nInterHeader= 0
28 nInterDetail= 0
29 nInterComment= 0
30 nInterAddress= 0
31
32 cInvcHeader= "Vzzoshprh_proc"
33 cInvcDetail= "Vzzoshprd_proc"
34 cTranHeader= "Vzzeoifth_proc"
35 cTranDetail= "Vzzeoiftd_proc"
36 cTranAddress= "Vzzeoifta_proc"
37 cInterHeader= "Vzzeoifih_proc"
38 cInterDetail= "Vzzeoifid_proc"
39 cInterAddress= "Vzzeoifia_proc"
40 cHistHeader= "Vzzeoifhh_proc"
41 cHistDetail= "Vzzeoifhd_proc"
42 cHistAddress= "Vzzeoifha_proc"
43 cWorkHeader= "tceoifth"
44 cWorkDetail= "tceoiftd"
45 cWorkAddress= "tceoifta"
46 c810FactorControl= "zzeoifcr"
47
48
49 *--- TR 1011593 NH
50 cSQLHDRTempTable = ""
51 *-=== TR 1011593 NH
52 *- 1010532 04/15/05 YIK
53 *- setup for Tie commerce. Requires different file names for different vendors
54 Tie_setup = .F.
55 BCEdi_Version = .F. && TR 1046497 APR-28-2010 BR
56 lBypassInv = .F. &&-TR 1018695 07-Nov-2006 CD - Bypass $0.00 values.
57
58 *--- TR 1021561 1/15/07 BR
59 lHasShipment = .F.
60 *=== TR 1021561 1/15/07 BR
61 lAllowConsolDiv = .T. && TR 1086775/1081474 4-JUN-2015 Venuk.
62 ************************************************************************************
63 * Init
64 ************************************************************************************
65 Procedure Init
66 Lparameters plUserInterface
67 This.lUserInterface = plUserInterface
68 This.lScheduled= !plUserInterface
69 *---TR 1018695 07-Nov-2006 CD ---
70 This.lBypassInv = (goEnv.sv('EDI810_BYPASS_ZERO_INVC','N') = 'Y')
71 *===TR 1018695 07-Nov-2006 CD ===
72 Local llRetVal
73 llRetVal= .T.
74 Return llRetVal
75 Endproc
76
77 ************************************************************************************
78 * ResetCounter
79 ************************************************************************************
80 Procedure ResetCounter
81 With This
82 .nInvoices= 0
83 .nHistory= 0
84 .nInterface= 0
85 .nTransaction= 0
86 .nTranHeader= 0
87 .nTranDetail= 0
88 .nTranComment= 0
89 .nTranAddress= 0
90 .nInterHeader= 0
91 .nInterDetail= 0
92 .nInterComment= 0
93 .nInterAddress= 0
94 Endwith
95 Endproc
96
97 ************************************************************************************
98 * 810(o) factor process
99 ************************************************************************************
100 Procedure OIFProcess
101 Parameters pcSQLFilterString, plNoScreenUI
102 Local lcSQLSelectString, llRetVal, lcFRX_Name, llBeganTransaction
103
104 * --- TR 1043955 12/04/09 CM
105 Local lnzzeoIFhh_Reccount
106 lnzzeoIFhh_Reccount = 0
107 * === TR 1043955 12/04/09 CM
108
109 llRetVal = .T.
110 With This
111 * path to SysLock directory on server (same place as Login.DBF)
112 lcSyslockTablePath = Addbs(goEnv.envLoginTablePath.Value)
113 If !v_SysLock( lcSyslockTablePath+"SYSLOCK", "OIF_PROCESS", goEnv.cCompany)
114 This.lProcessLocked = .T.
115 llRetVal= .F.
116 Else
117 *- 1009106 02/04/05 YIK
118 .oLog.OpenLog("OIF_PROCESS", I("OIF_PROCESS"), .lScheduled)
119 .oLog.LogProgram("clsoifpr.prg")
120 .oLog.LogEntry("Filter Criteria: " + pcSQLFilterString)
121 *=
122
123 * additional filter criteria
124 pcSQLFilterString = Iif(Empty(pcSQLFilterString), "", " And " + pcSQLFilterString)
125
126 .lNoDataFound = .F.
127 * create ProgressBar Form
128 *--- 36126 12/18/02 YIK
129 *- .CreateFormProgressBar(plNoScreenUI)
130 .CreateFormProgressBar(.lScheduled)
131 *===
132 .InitProgressBarTotal(15, "Total " + .cTitle)
133 .InitThermo(8)
134 .UpdateThermoCaption("Selecting invoices for 810(o) factor process...")
135ASSERT .f.
136 * Retrieve invoices
137 llHaveInvoicesToProcess= .RetrieveInvoices(pcSQLFilterString)
138
139 * Creating and Open all temporary views
140 .AdvanceThermoTotalWithCaptionPlus("Creating temporary views...")
141 llRetVal= llRetVal And .CreateTempViews()
142 SET ASSERTS ON
143 ASSERT .f.
144 *--- TR 1094625 1-Apr-2016 Goutam
145 IF vl_compr(,"use_decs") <> 'Y'
146 .AdvanceThermoTotalWithCaptionPlus("Changing quantity field type as per company setting in temporary views...")
147 llRetVal= llRetVal And .ChangeQtyfieldTypeInViews()
148 ENDIF
149 *=== TR 1094625 1-Apr-2016 Goutam
150 .AdvanceThermoTotalWithCaptionPlus("Opening temporary views...")
151 llRetVal= llRetVal And .OpenTempViews(pcSQLFilterString)
152
153 If Not llHaveInvoicesToProcess
154 .cMessage= 'There are no Invoices to process.'
155 .lNoDataFound = .T.
156 Else
157 This.lHasShipment = .T. && 1021561 1/15/07 BR
158 .AdvanceThermoTotalWithCaptionPlus("Deleting previous 810(o) factor transaction...")
159 llRetVal= llRetVal And .DeletePreviousTransaction()
160
161 * Creating 810 factor header from invoice header/detail
162 .AdvanceThermoTotalWithCaptionPlus("Creating 810(o) factor work record(s)...")
163 llRetVal= llRetVal And .Create810Factor()
164 *- 1009106 02/04/05 YIK
165 If llRetVal
166 .oLog.LogEntry("Create810Factor OK")
167 Else
168 .oLog.LogEntry("Create810Factor NOT OK")
169 Endif
170 * Populate sender/receiver id/qual from 810 factor control, factor_num from factor ref
171 .AdvanceThermoTotalWithCaptionPlus("Populate factor informations...")
172 llRetVal= llRetVal And .PopulatebyFactor(.cWorkHeader, .c810FactorControl)
173 *- 1009106 02/04/05 YIK
174 If llRetVal
175 .oLog.LogEntry("PopulatebyFactor OK")
176 Else
177 .oLog.LogEntry("PopulatebyFactor NOT OK")
178 Endif
179 *--- 34940 10/28/02 YIK
180 *- populate consol_inv from zzeoincr - 810 (Non-factored) control table
181 llRetVal= llRetVal And .PopulateConsolFlag(.cWorkHeader, "zzeoincr")
182 *- 1009106 02/04/05 YIK
183 If llRetVal
184 .oLog.LogEntry("PopulateConsolFlag OK")
185 Else
186 .oLog.LogEntry("PopulateConsolFlag NOT OK")
187 Endif
188
189 * Need to get 810 factor control sku_upc flag in PopulatebyFactor before
190 * cascading to all details in SyncHeaderDetailPfkey
191 llRetVal= llRetVal And .SyncHeaderDetailPFkey(.cWorkHeader, .cWorkDetail)
192 *- 1009106 02/04/05 YIK
193 If llRetVal
194 .oLog.LogEntry("SyncHeaderDetailPFkey OK")
195 Else
196 .oLog.LogEntry("SyncHeaderDetailPFkey NOT OK")
197 Endif
198
199 *--- 34940 10/28/02 YIK
200 *- Moved here from down below
201 * Populate invoice amount, terms, comp_name for each header
202 .AdvanceThermoTotalWithCaptionPlus("Calculating invoice amount and terms informations...")
203 llRetVal= llRetVal And .PopulateInvoices(.cWorkHeader)
204 *- 1009106 02/04/05 YIK
205 If llRetVal
206 .oLog.LogEntry("PopulateInvoices OK")
207 Else
208 .oLog.LogEntry("PopulateInvoices NOT OK")
209 Endif
210
211 .AdvanceThermoTotalWithCaptionPlus("Getting original, open, pick, invoice, cancel quantities...")
212 llRetVal= llRetVal And .GetOriginalSKUQty(.cWorkHeader, .cWorkDetail, .c810FactorControl)
213 *- 1009106 02/04/05 YIK
214 If llRetVal
215 .oLog.LogEntry("GetOriginalSKUQty OK")
216 Else
217 .oLog.LogEntry("GetOriginalSKUQty NOT OK")
218 ENDIF
219
220 llRetVal= llRetVal And .ConsolidateTransaction(.cWorkHeader, .cWorkDetail,, "zzeoincr")
221 *=== 34940 10/28/02 YIK
222 *- 1009106 02/04/05 YIK
223 If llRetVal
224 .oLog.LogEntry("ConsolidateTransaction OK")
225 Else
226 .oLog.LogEntry("ConsolidateTransaction NOT OK")
227 Endif
228
229 * validate UPC,SKU
230 .AdvanceThermoTotalWithCaptionPlus("Validating UPC, SKU...")
231 *- 1009106 04/02/05 YIK
232 *- Add llRetVal AND...
233 llRetVal= llRetVal And .CheckUPCSKU(.cWorkHeader, .cWorkDetail)
234 If llRetVal
235 .oLog.LogEntry("Validating UPC, SKU... OK")
236 Else
237 .oLog.LogEntry("Validating UPC, SKU... NOT OK")
238 Endif
239
240 .AdvanceThermoTotalWithCaptionPlus("Updating headers with detail in errors...")
241 *- 1009106 04/02/05 YIK
242 *- Use llRetVal AND...
243 *- llOKtoContinue= .MarkHeaderForDetailWithError(.cWorkHeader, .cWorkDetail)
244 llRetVal= llRetVal And .MarkHeaderForDetailWithError(.cWorkHeader, .cWorkDetail)
245 If llRetVal
246 .oLog.LogEntry("Updating headers with detail in errors... OK")
247 Else
248 .oLog.LogEntry("Updating headers with detail in errors... NOT OK")
249 Endif
250
251 *- 03/25/02 YIK TAN 31051. Populate style name
252 .AdvanceThermoTotalWithCaptionPlus("Populate style detail informations...")
253 llRetVal= llRetVal And .PopulateStyleSizeInfo(.cWorkHeader, .cWorkDetail, .c810FactorControl)
254 If llRetVal
255 .oLog.LogEntry("Populate style detail informations... OK")
256 Else
257 .oLog.LogEntry("Populate style detail informations... NOT OK")
258 Endif
259
260 *- 04/02/02 YIK TAN 31051, 31052 Populate EDI store and EDI center
261 .AdvanceThermoTotalWithCaptionPlus("Populate EDI Store...")
262 llRetVal= llRetVal And .PopulateEDI_Store(.cWorkHeader, .c810FactorControl)
263 If llRetVal
264 .oLog.LogEntry("Populate EDI Store... OK")
265 Else
266 .oLog.LogEntry("Populate EDI Store... NOT OK")
267 Endif
268
269 .AdvanceThermoTotalWithCaptionPlus("Populate EDI Center...")
270 llRetVal= llRetVal And .PopulateEDI_center(.cWorkHeader, .c810FactorControl)
271 If llRetVal
272 .oLog.LogEntry("Populate EDI Center... OK")
273 Else
274 .oLog.LogEntry("Populate EDI Center... NOT OK")
275 Endif
276
277 *--- 34940 10/28/02 YIK
278 *- Call this routine much higher to calculate all the info BEFORE consolidating of invoices
279 *!* * Populate invoice amount, terms, comp_name for each header
280 *!* .AdvanceThermoTotalWithCaptionPlus("Calculating invoice amount and terms informations...")
281 *!* llRetVal= llRetVal And .PopulateInvoices(.cWorkHeader)
282 *=== 34940 10/28/02 YIK
283 * Create vertical addresses include Shipto,Billto Phone number
284 * 4911- Laf148 EDI 810(o) Factor process support CIT
285 .AdvanceThermoTotalWithCaptionPlus("Resolve and populate address for each invoice...")
286 llRetVal= llRetVal And .Create810Addresses(.cWorkHeader, .cWorkAddress)
287 If llRetVal
288 .oLog.LogEntry("Resolve and populate address for each invoice... OK")
289 Else
290 .oLog.LogEntry("Resolve and populate address for each invoice... NOT OK")
291 Endif
292
293 *--- 34940 10/28/02 YIK
294 *- Call this routine much higher to calculate all the info BEFORE consolidating of invoices
295 *!* .AdvanceThermoTotalWithCaptionPlus("Getting original, open, pick, invoice, cancel quantities...")
296 *!* llRetVal= llRetVal And .GetOriginalSKUQty(.cWorkHeader, .cWorkDetail, .c810FactorControl)
297 *=== 34940 10/28/02 YIK
298 * Auto assign a sequential batch per factor
299 .AdvanceThermoTotalWithCaptionPlus("Assigning control number...")
300 llRetVal= llRetVal And .AssignBatchNumber(.cWorkHeader)
301 If llRetVal
302 .oLog.LogEntry("Assigning control number... OK")
303 Else
304 .oLog.LogEntry("Assigning control number... NOT OK")
305 Endif
306 *--- TR 1011539 NH : proc_810f will no longer be update through view update
307 *--- instead sql update will be used to update zzoshprh.proc_810f field.
308
309 * Flag all invoice as sended to factor in local invoice header view
310 *!* .AdvanceThermoTotalWithCaptionPlus("Updating 810(o) factor flag...")
311 *- 34940 10/30/02 YIK - All records are still in .cWorkHeader.
312 *- llRetVal= llRetVal And .UpdateInvoiceFactorFlag(.cTranHeader, .cInvcHeader)
313 *!* llRetVal= llRetVal AND .UpdateInvoiceFactorFlag(.cWorkHeader, .cInvcHeader)
314 *!* IF llRetVal
315 *!* .oLog.LogEntry("Updating 810(o) factor flag... OK")
316 *!* ELSE
317 *!* .oLog.LogEntry("Updating 810(o) factor flag... NOT OK")
318 *!* ENDIF
319
320
321 *!* llRetVal= llRetVal AND .UpdateConsolidateInvoiceFactorFlag(.cWorkHeader, .cInvcHeader)
322 *!* IF llRetVal
323 *!* .oLog.LogEntry("Updating 810(o) factor flag of consolidated invoices... OK")
324 *!* ELSE
325 *!* .oLog.LogEntry("Updating 810(o) factor flag of consolidated invoices... NOT OK")
326 *!* ENDIF
327
328 *--- create temp table to update proc_810f flat in invoice later on
329 *--- TR 1027444 NH 10/09/07
330 *llRetVal= llRetVal And .PrepareTempTableToUpdateFactorFlag(.cWorkHeader)
331 *=== TR 1027444 NH 10/09/07
332 *==== TR 1011539 NH
333
334 *= 34940
335 * moveRecords() require to know number of header,detail records
336 llRetVal= llRetVal And .CountTransactionAndInterface(.cWorkHeader, .cWorkDetail, "tcDummy", "tcDummy")
337 If llRetVal
338 This.lHasShipment = .T. && 1021561 1/15/07 BR
339 .oLog.LogEntry("Count Transaction And Interface records... OK")
340 Else
341 .oLog.LogEntry("Count Transaction And Interface records... NOT OK")
342 Endif
343
344 * move good transaction records to interface
345 .AdvanceThermoTotalWithCaptionPlus("Creating 810(o) factor interface tables...")
346 llRetVal= llRetVal And .MoveRecords(.cWorkHeader, .cWorkDetail, "tcDummy", .cWorkAddress,;
347 .cInterHeader, .cInterDetail, "tcDummy", .cInterAddress, ;
348 .nTranHeader, .nTranDetail, 0, .nTranAddress, ;
349 "Interface", [ !(tceoifTH.Errs_flg_H= "Y") ])
350
351 If llRetVal
352 .oLog.LogEntry("Creating 810(o) factor interface tables... OK")
353 Else
354 .oLog.LogEntry("Creating 810(o) factor interface tables... NOT OK")
355 Endif
356
357 * move all error transactions to view
358 .AdvanceThermoTotalWithCaptionPlus("Move transaction with errors to view...")
359 llRetVal= llRetVal And .MoveTransactionInError(.cWorkHeader , .cWorkDetail, "", "",;
360 .cTranHeader,.cTranDetail, "", "")
361 Endif
362 * move interface records to history for auto_proc='Y'
363 .AdvanceThermoTotalWithCaptionPlus("Move All Automatic process records from Interface to History...")
364 llRetVal= llRetVal And .MoveRecords(.cInterHeader,.cInterDetail, "tcDummy", .cInterAddress,;
365 .cHistHeader,.cHistDetail, "tcDummy", .cHistAddress,;
366 .nInterHeader, .nInterDetail, .nInterComment, .nInterAddress,;
367 "History", [ (vzzeoifih_Proc.auto_proc="Y") ]) && [ (vzzeoifih_Proc.auto_proc="Y") ]
368 If llRetVal
369 .oLog.LogEntry("Move All Automatic process records from Interface to History... OK")
370 Else
371 .oLog.LogEntry("Move All Automatic process records from Interface to History... NOT OK")
372 Endif
373
374 * Unload to flatfile
375
376 If This.lHasShipment && 1021561 1/15/07 BR
377
378 * --- TR 1043955 12/04/09 CM
379 * Here we'll mimic the 856 process determine if there are any history
380 * records before we try to output to the flat file.
381 lnzzeoIFhh_Reccount = .CountTotalRecs(.cHistHeader)
382 * === TR 1043955 12/04/09 CM
383
384 .AdvanceThermoTotalWithCaptionPlus("Creating flatfile...")
385 lcEDIPath = This.GetEDIFlatFileDirectory("Outbound")
386 lcOutBoundFlatFile = lcEDIPath + EDI_oIF_FILENAME
387 *- 1010532 04/15/05 YIK
388
389 *--- TechRec 1034000 08-Jun-2008 NSD ---
390 *This.Tie_setup = (goEnv.sv("TIE_SETUP","N") = 'Y')
391 This.Tie_setup = IIF(((goEnv.sv("TIE_SETUP","N") = 'N') OR (goEnv.sv("BC_EDI_VERSION","") = "5.2")), .F.,.T.)
392 *=== TechRec 1034000 08-Jun-2008 NSD ---
393
394 *--- TR 1046497 APR-28-2010 BR
395 This.BCEdi_Version = (goEnv.sv("BC_EDI_VERSION","") = "5.2")
396 *== TR 1046497 APR-28-2010 BR
397
398 * --- TR 1043955 12/04/09 CM
399 If This.lHasShipment AND lnzzeoIFhh_Reccount > 0
400 * === TR 1043955 12/04/09 CM
401
402 *---TR 1036975 NOV-14-08 TEJAS : This method now only captures fileNames that need to be created
403 llRetVal= llRetVal And .UnLoadToFlatFile(EDI_oIF_TRANSACTION, lcOutBoundFlatFile, ;
404 .cHistHeader, .cHistDetail, .cHistAddress, .c810FactorControl)
405 If llRetVal
406 .oLog.LogEntry("Unloading to Flat File... OK")
407 Else
408 .oLog.LogEntry("Unloading to Flat File... NOT OK")
409 Endif
410
411 *--- TR 1027444 NH 10/09/07
412 llRetVal = llRetVal And .PrepareTempTableToUpdateFactorFlag(.cHistHeader,"zzeoincr")
413 *=== TR 1027444 NH
414
415 * --- TR 1043955 12/04/09 CM
416 Endif
417 * === TR 1043955 12/04/09 CM
418
419 * Send all views to server
420 .AdvanceThermoTotalWithCaptionPlus("Sending all tables to server...")
421 llRetVal= llRetVal And .TableupdateAllViews()
422 If llRetVal
423 .oLog.LogEntry("Sending all tables to server... OK")
424 Else
425 .oLog.LogEntry("Sending all tables to server... NOT OK")
426 ENDIF
427 Endif && 1021561 1/15/07 BR
428
429 *---TR 1036975 NOV-14-08 TEJAS : Actual Unload of files whose names were Captured in unloadtoFlatFile
430 *- ADDED here to prevent flat file from being generated should TableUpdateWithTransaction fail
431
432 * --- TR 1043955 12/04/09 CM --- Added lnzzeoIFih_Reccount > 0
433 *IF llRetVal AND .lHasShipment
434 IF llRetVal AND .lHasShipment AND lnzzeoIFhh_Reccount > 0
435 * === TR 1043955 12/04/09 CM
436
437 SELECT __tcFlatFileList
438 SCAN
439 lcTempFlatfile = __tcFlatFileList.TempFlatfile
440 lcOutBoundFlatFile = __tcFlatFileList.OutBoundFlatFile
441 llRetVal = llRetVal AND this.CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
442 ENDSCAN
443 lcLogStr = "Flat Files created Successfully."
444 This.LogEntry(lcLogStr)
445 .UpdateMessage()
446 ELSE
447 IF !llRetVal
448 *--- If Tableupdate failed, TMP file was created. Delete it.
449 SELECT __tcFlatFileList
450 SCAN
451 lcTempFlatfile = __tcFlatFileList.TempFlatfile
452 DELETE FILE (lcTempFlatfile)
453 ENDSCAN
454 lcLogStr = "TABLE UPDATE FAILED! Flat File not created. Please check Error Log for More Info"
455 This.LogEntry(lcLogStr)
456 ENDIF
457 IF !llRetVal && TR 1043955 12/04/09 CM
458 .UpdateMessageError()
459
460 * --- TR 1043955 12/04/09 CM
461 ELSE
462 .UpdateMessage()
463 ENDIF
464 * === TR 1043955 12/04/09 CM
465
466 ENDIF
467 *===TR 1036975 NOV-14-08 TEJAS : Actual Unload of files whoes names were Captured in unloadtoFlatFile
468
469 *---TR 1036975 NOV-14-08 TEJAS : moved up, within IF..THEN ..ELSE.. ENDIF
470 *.UpdateMessage()
471 *===TR 1036975 NOV-14-08 TEJAS : moved up, within IF..THEN ..ELSE.. ENDIF
472 * cleanup, Release Syslock
473 .CloseAllViews()
474 *--- TR 1014356 12/12/05 NH : closelog() is added
475 .oLog.LogResult(llRetVal)
476 .oLog.CloseLog()
477 *=== TR 1014356 12/12/05 NH
478 v_SysUnLock( lcSyslockTablePath+"SYSLOCK", "OIF_PROCESS", goEnv.cCompany)
479 If This.lUserInterface
480 This.m_close()
481 Endif
482 .ResetCounter()
483 Endif
484 Endwith
485 Return llRetVal
486 Endproc
487
488 ************************************************************************************
489 *
490 ************************************************************************************
491 Procedure UpdateMessage
492 Local llRetVal, lcErrs_Msg, llUpdate
493 With This
494 llRetVal= .T.
495 .nTransaction= .CountTotalRecs(.cTranHeader)
496 .nInterface= .CountTotalRecs(.cInterHeader)
497 .nHistory= .CountTotalRecs(.cHistHeader)
498 .cMessage= Iif(!Empty(.cMessage), .cMessage + CRLF, "")
499 lcmsg1= Iif(.nInvoices>0, ;
500 ALLT(Str(.nInvoices)) + " Invoice(s) Found." + CRLF, "")
501 lcmsg2= Iif(.nTransaction> 0, ;
502 ALLT(Str(.nTransaction)) + " Invoice(s) have Errors." + CRLF ,"")
503 lcmsg3= Iif(.nInterface>0, ;
504 ALLT(Str(.nInterface)) + " Invoice(s) successfully processed and moved to Interface table." + CRLF ,"")
505 lcmsg4= Iif(.nHistory>0, ;
506 ALLT(Str(.nHistory)) + " Invoice(s) moved from Interface table to Flatfile." + CRLF,"")
507 *- 1043754 11/12/09 YIK
508 .oLog.LogEntry(.cMessage)
509 IF !EMPTY(lcmsg1)
510 .oLog.LogEntry(lcmsg1)
511 ENDIF
512 IF !EMPTY(lcmsg2)
513 .oLog.LogEntry(lcmsg2)
514 ENDIF
515 IF !EMPTY(lcmsg3)
516 .oLog.LogEntry(lcmsg3)
517 ENDIF
518 IF !EMPTY(lcmsg4)
519 .oLog.LogEntry(lcmsg4)
520 ENDIF
521 *==
522
523 .cMessage= .cMessage + (lcmsg1 + lcmsg2+ lcmsg3 + lcmsg4)
524 Endwith
525 Return llRetVal
526 Endproc
527
528 ************************************************************************************
529 * send all views to server
530 ************************************************************************************
531 Procedure TableupdateAllViews
532 Local llRetVal
533 llRetVal= .T.
534 *--- TR 1011539 NH
535 * Dime laTables[10]
536 Dime laTables[9]
537 *=== TR 1011539 NH
538 laTables[1]= .cTranHeader
539 laTables[2]= .cTranDetail
540 laTables[3]= .cTranAddress
541 laTables[4]= .cInterHeader
542 laTables[5]= .cInterDetail
543 laTables[6]= .cInterAddress
544 laTables[7]= .cHistHeader
545 laTables[8]= .cHistDetail
546 laTables[9]= .cHistAddress
547
548 *--- TR 1011539 NH : use sql update to set proc_810f value
549 * laTables[10]= .cInvcHeader
550
551 Local lcSQL, ltDatetime, lcUser_id
552 ltDatetime = Datetime()
553 lcUser_id = goEnv.envLogin.cUserName
554
555 llBeganTransaction = .BeginTransaction()
556 llRetVal = llBeganTransaction
557 llRetVal = llRetVal And .TableUpdateWithTransaction(@laTables)
558
559 Local lcSQL_SingleInv, lcSQL_ConsolidatedInv
560
561 lcSQL = " Update h set proc_810f = 'P', " + ;
562 " user_id = " + SQLFormatChar(lcUser_id) + "," + ;
563 " last_mod = " + SQLFormatTS(ltDatetime) + ;
564 " FROM zzoshprh h JOIN " + This.cSQLHDRTempTable + " X "
565
566 *--- TR 1015795 18-May-2006 Goutam
567 *lcSQL_SingleInv = lcSQL + " ON H.inv_num = X.inv_num and X.c_consol_inv <> 'Y' "
568 *lcSQL_ConsolidatedInv = lcSQL + " ON H.consol_num = X.inv_num and X.c_consol_inv = 'Y' "
569
570 lcSQL_SingleInv = lcSQL + " ON H.inv_num = X.inv_num and (X.c_consol_inv <> 'Y' AND X.c_consol_inv <> 'S') "
571
572 *- 1049199 FH 08/31/10 - changed x.inv_num to x.consol_num
573 lcSQL_ConsolidatedInv = lcSQL + " ON H.consol_num = X.consol_num and (X.c_consol_inv = 'Y' OR X.c_consol_inv = 'S') "
574
575 *=== TR 1015795 18-May-2006 Goutam
576 If Not Empty(This.cSQLHDRTempTable)
577 llRetVal = llRetVal And v_SQLExec(lcSQL_SingleInv)
578 llRetVal = llRetVal And v_SQLExec(lcSQL_ConsolidatedInv)
579 Endif
580
581 *=== TR 1011539 NH
582 If llBeganTransaction
583 If llRetVal
584 This.EndTransaction()
585 Else
586 This.RollbackTransaction()
587 Endif
588 Endif
589
590 *=== TR 1011539 NH
591
592 Return llRetVal
593 Endproc
594
595 ************************************************************************************
596 * send all views to server
597 ************************************************************************************
598 Procedure CloseAllViews
599 llRetVal= .T.
600 Dime laTables[11]
601 laTables[1]= .cTranHeader
602 laTables[2]= .cTranDetail
603 laTables[3]= .cTranAddress
604 laTables[4]= .cInterHeader
605 laTables[5]= .cInterDetail
606 laTables[6]= .cInterAddress
607 laTables[7]= .cHistHeader
608 laTables[8]= .cHistDetail
609 laTables[9]= .cHistAddress
610 laTables[10]= .cInvcHeader
611 laTables[11]= .cInvcDetail
612 .TableClose(@laTables, true)
613 .TableClose("tceoifth")
614 .TableClose("tceoiftd")
615 .TableClose("tceoifta")
616 .TableClose("zzeoifcr")
617 .TableClose("tcDummy")
618 .TableClose("__TmpCursor")
619 .TableClose("tcCommu")
620 .TableClose("tmpAddrs")
621 *--- TR 1067898 04-12-2013 RKI ---*
622 .TableClose("tmpBillAddrs")
623 *=== TR 1067898 04-12-2013 RKI ===*
624 Return llRetVal
625 Endproc
626
627 ************************************************************************************
628 * Return True when found some Invoices to process
629 * tcInvoiceHeader- all invoice headers match criteria to process
630 * tcInvoiceDetail- all invoice details match criteria to process (for terms calc)
631 * tc810Header- Views need for insert
632 * tc810Work- cursor need for process (--for get around buffer view)
633 * At end of process will append all record into tc810Header view for tableupdate
634 ************************************************************************************
635 Procedure RetrieveInvoices
636 Parameters tcSQLFilterString
637 Local llRetVal, lnOldSelect, lcSQLSelectString
638 llRetVal = .T.
639 lnOldSelect = Select()
640
641 With This
642 * all invoice headers for matching criteria and
643 * not yet send to factor (--proc_810f<>"P")
644 * and have active 810(o) control by Factor setup
645 lcSQLOrder = " h.factor,h.inv_num "
646
647 *--- TechRec 1065807 17-Jan-2013 vkrishnamurthy ---
648 LOCAL lcFldlist
649 lcFldlist = " h.ord_num, h.pick_num, h.inv_num, h.ord_status ,h.MultiFactor,h.fappv_amt, h.factor ,h.pkey ,h.last_mod "
650 lcFldlist = GetCommonFieldListWithAlias("h.", "zzoordrh", "zzeoifth") + " ,h.multifactor"
651 *=== TechRec 1065807 17-Jan-2013 vkrishnamurthy ===
652
653 *--- TR 1086626 26-May-2015 SMeenraja Retrieved multifactor flag
654 LOCAL lMultiFactor
655 lMultiFactor = (vl_compr(,"multifact_ok") = 'Y')
656 *=== TR 1086626 26-May-2015 SMeenraja Retrieved multifactor flag
657
658 *--- TR 1023114 20-Apr-2007 Partha ---
659 * need zsumnetprice from zvoordersh
660
661 *!* lcSQLSelect = "select h.* from zzoshprh h, zzeoifcr r where " + ;
662 *!* " h.proc_810f <> 'P' And inv_num>0 And " + ;
663 *!* " h.factor=r.factor and r.active_ok = 'Y' and h.factor_ok = 'Y' " + ; &&& 1015890 Added and h.factor_ok = 'Y'
664 *!* tcSQLFilterString
665
666 &&--- TechRec 1065807 17-Jan-2013 vkrishnamurthy === added lcFldlist
667 *- TR 1071134 FH 05/21/13 - changed to h.MultiFactor <> 'Y' in where clause to include when MultiFactor = ''
668 *- TR 1072287 FH 07/18/13 - took out check for h.autofact
669 *--- TR 1086626 26-May-2015 SMeenraja Avoided usage of zzofctrd when lMultiFactor is false
670 IF lMultiFactor
671 lcSQLSelect = "select "+ lcFldlist +", o.zsumnetprice " + ;
672 ", coalesce(fd.factor,'') as newfactor, coalesce(fd.fappv_amt - h.fappv_amt,0) as Net_Fappv_amt " + ; &&--- TR 1054799 14-Jul-2011 Goutam Added newfactor
673 " from zzoshprh h " + ;
674 " left JOIN zzofctrd fd " + ; && TR 1054799 14-Jul-2011 Goutam
675 " on h.pkey = fd.fkey " + ; && TR 1054799 14-Jul-2011 Goutam
676 "/* join zzeoifcr r " + ; && TR 1054799 14-Jul-2011 Goutam
677 " on r.factor = case when h.MultiFactor = 'N' THEN h.factor else fd.factor end */" + ; &&--- TR 1063840 10/10/12 JIJO - COmmented === && TR 1054799 14-Jul-2011 Goutam
678 "/* TR 1054799 join zzeoifcr r " + ;
679 " on " + ;
680 " h.factor = r.factor */" + ;
681 " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
682 " on h.pkey = o.pkey " + ;
683 "JOIN zzwcntrc cnti ON cnti.division = h.division " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
684 " where h.proc_810f <> 'P' And inv_num > 0 /*And r.active_ok = 'Y'*/ and h.factor_ok = 'Y' " + ; &&--- TR 1063840 10/10/12 JIJO - Commented "And r.active_ok = 'Y'" ===
685 + tcSQLFilterString + ;
686 " AND h.ord_status <> 'C' AND CASE WHEN h.MultiFactor <> 'Y' THEN h.factor ELSE fd.factor END <> " + SQLFormatChar(FACTOR_LC) + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
687 " AND h.factor_ok = 'Y' " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
688 " AND /*(fd.Pkey is NULL OR */" + ; &&--- TR 1063840 10/10/12 JIJO - Commented === &&--- TechRec 1054799 04-Jul-2011 jisingh ===
689 " ((fd.pkey is null and exists(select 1 from zzeoifcr where factor = h.factor and active_ok = 'Y')) OR " + ; &&-- TR 1063840 10/10/12 JIJO ===
690 " fd.pkey = (Select TOP 1 fd1.Pkey From zzofctrd fd1 " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
691 " Where fd1.fkey = fd.fkey " + ;
692 " /*AND r.factor = fd1.factor*/ " + ; && --- TR 1063840 09/10/12 JIJO - Commented ===
693 " and exists(Select 1 from zzeoifcr where factor = fd1.factor and active_ok = 'Y')" + ; && --- TR 1063840 09/10/12 JIJO ===
694 " ORDER BY fd1.factor_Seq)) " &&--- TechRec 1054799 04-Jul-2011 jisingh ===
695 ELSE
696 lcSQLSelect = "select "+ lcFldlist +", o.zsumnetprice " + ;
697 ", '' as newfactor, coalesce(h.fappv_amt,0) as Net_Fappv_amt " + ; &&--- TR 1054799 14-Jul-2011 Goutam Added newfactor
698 " from zzoshprh h " + ;
699 " join zzeoifcr r " + ;
700 " on " + ;
701 " h.factor = r.factor " + ;
702 " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
703 " on h.pkey = o.pkey " + ;
704 "JOIN zzwcntrc cnti ON cnti.division = h.division " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
705 " where h.proc_810f <> 'P' And inv_num > 0 And r.active_ok = 'Y' and h.factor_ok = 'Y' " + ; &&--- TR 1063840 10/10/12 JIJO - Commented "And r.active_ok = 'Y'" ===
706 + tcSQLFilterString + ;
707 " AND h.ord_status <> 'C' AND h.factor <> " + SQLFormatChar(FACTOR_LC) + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
708 " AND h.factor_ok = 'Y' " &&--- TechRec 1054799 04-Jul-2011 jisingh ===
709 ENDIF
710 *=== TR 1086626 26-May-2015 SMeenraja Avoided usage of zzofctrd when lMultiFactor is false
711
712*!* lcSQLSelect = "select h.*, o.zsumnetprice " + ;
713*!* " from zzoshprh h " + ;
714*!* " join zzeoifcr r " + ;
715*!* " on " + ;
716*!* " h.factor = r.factor " + ;
717*!* " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
718*!* " on h.pkey = o.pkey " + ;
719*!* " where h.proc_810f <> 'P' And inv_num > 0 And r.active_ok = 'Y' and h.factor_ok = 'Y' " + ;
720*!* + tcSQLFilterString
721
722 *=== TR 1023114 20-Apr-2007 Partha
723
724 llRetVal= llRetVal And This.CreateSQLView( .cInvcHeader, lcSQLSelect,, lcSQLOrder)
725
726
727 * all invoice details for matching criteria
728
729
730 *--- TR 1023114 20-Apr-2007 Partha ---
731 * need to include zsumnetprice from zvoordersh, so that the filter works
732
733 *!* lcSQLSelect = "select * from zzoshprd where fkey in (" +;
734 *!* "select h.pkey from zzoshprh h, zzeoifcr r where " + ;
735 *!* " h.proc_810f <> 'P' And inv_num>0 And " + ;
736 *!* " h.factor=r.factor and r.active_ok = 'Y' and h.factor_ok = 'Y' " + ; &&& 1015890 Added and h.factor_ok = 'Y'
737 *!* tcSQLFilterString+ ")"
738
739
740*!* lcSQLSelect = "select * " + ;
741*!* " from zzoshprd " + ;
742*!* " where fkey in (" +;
743*!* " select h.pkey " + ;
744*!* " from zzoshprh h " + ;
745*!* " join zzeoifcr r on h.factor=r.factor " + ;
746*!* " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
747*!* " on h.pkey = o.pkey " + ;
748*!* " where h.proc_810f <> 'P' And inv_num>0 And r.active_ok = 'Y' and h.factor_ok = 'Y' " + ;
749*!* tcSQLFilterString + ;
750*!* ")"
751 *--- TR 1086626 26-May-2015 SMeenraja Avoided usage of zzofctrd when lMultiFactor is false
752 IF lMultiFactor
753 lcSQLSelect = "select * " + ;
754 " from zzoshprd " + ;
755 " where fkey in (" +;
756 " select h.pkey " + ;
757 " from zzoshprh h " + ;
758 " LEFT JOIN zzofctrd fd ON h.pkey = fd.fkey " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
759 " /*JOIN zzeoifcr r ON CASE WHEN h.MultiFactor = 'N' THEN h.factor ELSE fd.factor END = r.factor*/ " + ; &&--- TR 1063840 10/10/12 JIJO-Commented === &&--- TechRec 1054799 04-Jul-2011 jisingh ===
760 " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
761 " on h.pkey = o.pkey " + ;
762 " where h.proc_810f <> 'P' And inv_num>0 /*And r.active_ok = 'Y'*/ and h.factor_ok = 'Y' " + ; &&--- TR 1063840 10/10/12 JIJO - Commented "And r.active_ok = 'Y'" ===
763 " AND /*(fd.Pkey is NULL OR */" + ; &&--- TR 1063840 10/10/12 JIJO - Commented === &&--- TechRec 1054799 04-Jul-2011 jisingh ===
764 " ((fd.pkey is null and exists(select 1 from zzeoifcr where factor = h.factor and active_ok = 'Y')) OR " + ; &&-- TR 1063840 10/10/12 JIJO ===
765 " fd.pkey = (Select TOP 1 fd1.Pkey From zzofctrd fd1 " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
766 " Where fd1.fkey = fd.fkey " + ;
767 " /*AND r.factor = fd1.factor*/ " + ; && --- TR 1063840 09/10/12 JIJO - Commented ===
768 " and exists(Select 1 from zzeoifcr where factor = fd1.factor and active_ok = 'Y')" + ; && --- TR 1063840 09/10/12 JIJO -
769 " ORDER BY fd1.factor_Seq)) " + ; &&--- TechRec 1054799 04-Jul-2011 jisingh ===
770 tcSQLFilterString + ;
771 ")"
772 ELSE
773 lcSQLSelect = "select * " + ;
774 " from zzoshprd " + ;
775 " where fkey in (" +;
776 " select h.pkey " + ;
777 " from zzoshprh h " + ;
778 " join zzeoifcr r on h.factor=r.factor " + ;
779 " join (select pkey, zsumnetprice from zvoordersh ) o " + ;
780 " on h.pkey = o.pkey " + ;
781 " where h.proc_810f <> 'P' And inv_num>0 And r.active_ok = 'Y' and h.factor_ok = 'Y' " + ;
782 tcSQLFilterString + ;
783 ")"
784 ENDIF
785 *=== TR 1086626 26-May-2015 SMeenraja Avoided usage of zzofctrd when lMultiFactor is false
786 *=== TR 1023114 20-Apr-2007 Partha ===
787
788
789 llRetVal= llRetVal And This.CreateSQLView( .cInvcDetail, lcSQLSelect)
790 llRetVal= llRetVal And .OpenTable(.cInvcHeader,,.T.)
791 llRetVal= llRetVal And .OpenTable(.cInvcDetail,,.T.)
792 llRetVal= llRetVal And .CountTotalRecs(.cInvcHeader)> 0
793 *--- TR 1027444 NH
794 THIS.LogEntry("Number of Invoices to process " + TRANSFORM(RECCOUNT(this.cInvcHeader)))
795 THIS.LogEntry("Number of Invoices detail to process " + TRANSFORM(RECCOUNT(this.cInvcDetail)))
796 *=== TR 1027444 NH
797 If llRetVal
798 .nInvoices= .CountTotalRecs(.cInvcHeader)
799 Select (.cInvcHeader)
800 CursorSetProp("BUFFERING", 3)
801 Index On pkey Tag pkey
802 CursorSetProp("BUFFERING", 5)
803 Select (.cInvcDetail)
804 CursorSetProp("BUFFERING", 3)
805 Index On fkey Tag fkey
806 CursorSetProp("BUFFERING", 5)
807 Endif
808
809 Endwith
810
811 Select(lnOldSelect)
812 Return llRetVal
813 Endproc
814
815 ************************************************************************************
816 *
817 ************************************************************************************
818 Procedure CreateTempViews
819 Parameters pcFilterCriteria
820 Local llRetVal, lcSQLSelect, lcSQLOrder, lcSQLSelect_O, lcSQLSelect_I
821 llRetVal= .T.
822
823 With This
824 l_nThermoCnt= 0
825 This.InitThermoWithCaption(@l_nThermoCnt, 11, "Creating all views to support 810(o) factor process...")
826
827 * create Transaction tables
828 This.AdvanceThermoPlus(@l_nThermoCnt)
829 lcSQLSelect = "select * from zzeoIFth"
830 This.CreateSQLView(.cTranHeader, lcSQLSelect)
831 This.AdvanceThermoPlus(@l_nThermoCnt)
832 lcSQLSelect = "select * from zzeoIFtd"
833 This.CreateSQLView(.cTranDetail, lcSQLSelect)
834 This.AdvanceThermoPlus(@l_nThermoCnt)
835 lcSQLSelect = "select * from zzeoIFta"
836 This.CreateSQLView(.cTranAddress, lcSQLSelect)
837
838 * create Interface tables
839 This.AdvanceThermoPlus(@l_nThermoCnt)
840 lcSQLSelect = "select * from zzeoIFih"
841 This.CreateSQLView(.cInterHeader, lcSQLSelect)
842 This.AdvanceThermoPlus(@l_nThermoCnt)
843 lcSQLSelect = "select * from zzeoIFid"
844 This.CreateSQLView(.cInterDetail, lcSQLSelect)
845 This.AdvanceThermoPlus(@l_nThermoCnt)
846 lcSQLSelect = "select * from zzeoIFia"
847 This.CreateSQLView(.cInterAddress, lcSQLSelect)
848
849 * create history tables
850 This.AdvanceThermoPlus(@l_nThermoCnt)
851 lcSQLSelect = "select * from zzeoIFhh"
852 This.CreateSQLView(.cHistHeader, lcSQLSelect)
853 This.AdvanceThermoPlus(@l_nThermoCnt)
854 lcSQLSelect = "select * from zzeoIFhd"
855 This.CreateSQLView(.cHistDetail, lcSQLSelect)
856 This.AdvanceThermoPlus(@l_nThermoCnt)
857 lcSQLSelect = "select * from zzeoIFha"
858 This.CreateSQLView(.cHistAddress, lcSQLSelect)
859
860 * get 810F(o) control reference
861 This.AdvanceThermoPlus(@l_nThermoCnt)
862 lcSQLString = "SELECT * FROM zzeoifcr"
863 llRetVal = llRetVal And v_SQLExec(lcSQLString, .c810FactorControl)
864 If llRetVal
865 Select (.c810FactorControl)
866 Index On factor Tag factor
867 Endif
868
869 *- 34940 10/30/02 YIK
870 *- Need to open 810(o) control to populate consol_inv flag (to consolidate invoices)
871 This.AdvanceThermoPlus(@l_nThermoCnt)
872 lcSQLString = "SELECT * FROM zzeoinCR"
873 *- 1005178 05/10/04 YIK
874 *- replace v_SqlPrep with v_SqlExec to return .T. if zzeoincr is empty
875 *- llRetVal = v_SqlPrep(lcSQLString, "zzeoincr")
876 llRetVal = v_SQLExec(lcSQLString, "zzeoincr")
877 *=
878 If llRetVal
879 Select zzeoincr
880 Index On customer Tag customer
881 *--- TR 1027444 NH
882 Index On customer+division Tag custDiv
883 *=== TR 1027444 NH
884 Index On division Tag division
885 Endif
886 *=== 34940
887
888 *- 37880 3/17/03 YIK
889 *- Open customer master
890 This.AdvanceThermoPlus(@l_nThermoCnt)
891 lcSQLString = "SELECT * FROM zzxcustr"
892 llRetVal = v_SqlPrep(lcSQLString, "zzxcustr")
893 If llRetVal
894 Select zzxcustr
895 Index On customer Tag customer
896 Endif
897 *= 37880
898 * dummy cursor with fkey
899 Create Cursor tcDummy (pkey I(4), fkey I(4))
900
901 Endwith
902
903 Return llRetVal
904 Endproc
905
906 ************************************************************************************
907 * Open all 870 views
908 ************************************************************************************
909 Procedure OpenTempViews
910 Parameters pcFilterCriteria
911 Local llRetVal, lcSQLSelect, lcSQLOrder
912 llRetVal = .T.
913 lnOldSelect = Select()
914 With This
915 lnCursorBuffer = DB_BUFOPTRECORD
916 If !(This.OpenTable(.cTranHeader,,.T.) And ;
917 This.OpenTable(.cTranDetail,,.T.) And ;
918 This.OpenTable(.cTranAddress,,.T.) And ;
919 This.OpenTable(.cInterHeader,,.T.) And ;
920 This.OpenTable(.cInterDetail,,.T.) And ;
921 This.OpenTable(.cInterAddress,,.T.) And ;
922 This.OpenTable(.cHistHeader) And ;
923 This.OpenTable(.cHistAddress) And ;
924 This.OpenTable(.cHistDetail))
925 llRetVal= .F.
926 Else
927 Select (.cTranHeader)
928 CursorSetProp("BUFFERING", 3)
929 Index On pkey Tag pkey
930 Index On Str(ord_num)+Str(inv_num) Tag Ord_Inv
931 CursorSetProp("BUFFERING", 5)
932
933 Select (.cTranDetail)
934 CursorSetProp("BUFFERING", 3)
935 Index On fkey Tag fkey
936 CursorSetProp("BUFFERING", 5)
937
938 Select (.cTranAddress)
939 CursorSetProp("BUFFERING", 3)
940 Index On fkey Tag fkey
941 CursorSetProp("BUFFERING", 5)
942
943
944 Select (.cInterHeader)
945 CursorSetProp("BUFFERING", 3)
946 Index On pkey Tag pkey
947
948 CursorSetProp("BUFFERING", 5)
949
950 .nInterface= .CountTotalRecs(.cInterHeader)
951
952 Select * From (This.cTranAddress) Into Cursor __eoifta
953 This.MakeCursorWritable("__eoifta", This.cWorkAddress)
954 This.TableClose("__eoifta")
955
956 Endif
957 Endwith
958 Select(lnOldSelect)
959 Return llRetVal
960 Endproc
961
962 ************************************************************************************
963 * Truncate all previous trans on server that match criterias
964 ************************************************************************************
965 Procedure DeletePreviousTransaction
966 Local llRetVal
967 llRetVal= .T.
968 *---TR: 1021561 1/24/07 BR -- Added Delete All In (.cInterHeader), Delete All In (.cInterDetail),
969 * -- laTables[3] = .cInterHeader, laTables[4] = .cInterDetail
970 With This
971 Delete All In (.cTranHeader)
972 Delete All In (.cTranDetail)
973 Delete All In (.cInterHeader)
974 Delete All In (.cInterDetail)
975 Dime laTables[4]
976 laTables[1]= .cTranHeader
977 laTables[2]= .cTranDetail
978 laTables[3] = .cInterHeader
979 laTables[4] = .cInterDetail
980 llRetVal= This.TableUpdateWithTransaction(@laTables)
981 Endwith
982 Return llRetVal
983 Endproc
984
985 ************************************************************************************
986 * creating 810 factor header with data from invoice header
987 * and assign pkey in batch
988 ************************************************************************************
989 Procedure Create810Factor
990 With This
991 lcInvoiceHeader= .cInvcHeader
992 lcInvoiceDetail= .cInvcDetail
993 lc810WorkHeader= .cWorkHeader
994 lc810WorkDetail= .cWorkDetail
995 Local llRetVal, lnOldSelect, lcSQLSelectString
996 llRetVal= .T.
997 llRetVal= .Create810FactorWorkHeader(lcInvoiceHeader, lc810WorkHeader)
998 llRetVal= llRetVal And .Create810FactorWorkDetail(lcInvoiceDetail, lc810WorkDetail)
999 Endwith
1000 Return llRetVal
1001 Endproc
1002
1003 ************************************************************************************
1004 *
1005 ************************************************************************************
1006 Procedure Create810FactorWorkHeader
1007 Lparameters tcInvoiceHeader, tc810WorkHeader
1008 Local llRetVal, lnOldSelect, lcSQLSelectString
1009 llRetVal = .T.
1010 lnOldSelect = Select()
1011
1012 Local lnCurrentHeaderPkey, lnCnt, lnMax, lnLast, lnCur
1013
1014 *--- TR 1054799 20-Jul-2011 Goutam
1015 LOCAL lcnewfactor, lnNet_Fappv_amt
1016 *=== TR 1054799 20-Jul-2011 Goutam
1017
1018 Select * From (This.cTranHeader) Into Cursor __eoifTH
1019 *- 34940 YIK 10/29/02
1020 *- Added consol_inv
1021 Create Cursor tcTemp (sku_upc c(1), c_consol_inv c(1), Net_Fappv_amt N(17,2), multifactor c(1)) && 1054799 Added Net_Fappv_amt, multifactor
1022 This.CreateCursorStructure( "__eoifTH", "tcTemp", tc810WorkHeader)
1023 .TableClose("tcTemp")
1024 .TableClose("__eoifTH")
1025
1026 Select (tc810WorkHeader)
1027 Index On pkey Tag pkey
1028 Index On Str(ord_num)+Str(inv_num) Tag Ord_Inv
1029 *- 34940 10/30/02 YIK
1030 Index On Str(consol_num) Tag consol_num
1031
1032 Select (tcInvoiceHeader)
1033 lnMax= This.CountTotalRecs(tcInvoiceHeader)
1034 lnLast= v_NextPkey("ZZEOIFTH", lnMax)
1035 lnCnt= 0
1036 Scan
1037
1038 *--- TR 1054799 20-Jul-2011 Goutam
1039 lcnewfactor = newfactor
1040 lnNet_Fappv_amt = Net_Fappv_amt
1041 *=== TR 1054799 20-Jul-2011 Goutam
1042
1043 lnCnt = lnCnt + 1
1044 lnCur = (lnLast - lnMax) + lnCnt
1045 llRetVal= This.CreateRecordWithPkey(tcInvoiceHeader, tc810WorkHeader,,,,lnCur)
1046
1047 *--- TR 1054799 20-Jul-2011 Goutam
1048 IF multifactor = 'Y'
1049 Replace Factor WITH lcnewfactor, Net_Fappv_Amt WITH lnNet_Fappv_amt, multifactor WITH 'Y' In (tc810WorkHeader)
1050 ENDIF
1051 *=== TR 1054799 20-Jul-2011 Goutam
1052
1053 If !llRetVal
1054 Exit
1055 Endif
1056 Endscan
1057
1058 Select(lnOldSelect)
1059 Return llRetVal
1060 Endproc
1061
1062 ************************************************************************************
1063 *
1064 ************************************************************************************
1065 Procedure Create810FactorWorkDetail
1066 Lparameters tcInvoiceDetail, tc810WorkDetail
1067 Local llRetVal, lnOldSelect, lcSQLSelectString
1068 llRetVal = .T.
1069 lnOldSelect = Select()
1070
1071 With This
1072 Select * From (.cTranDetail) Into Cursor __eoifTD
1073 Create Cursor tcTemp (sku_upc c(1),customer c(7) )
1074 This.CreateCursorStructure( "__eoifTD", "tcTemp", tc810WorkDetail)
1075
1076 Select (tc810WorkDetail)
1077 Scatt Memvar Memo Blank
1078 .TableClose("tcTemp")
1079 .TableClose("__eoifTD")
1080
1081 Select (tcInvoiceDetail)
1082 Scatt Memvar Memo Blank
1083 Select (tc810WorkDetail)
1084 Scatt Memvar Memo Blank
1085
1086 * Take ship detail and explode to vertical to TcVertDtl
1087 .CreateCursorStructure(tc810WorkDetail,,"tcVertDtl")
1088 .ExplodeDetailSizeToVertical(tcInvoiceDetail, "tcVertDtl")
1089
1090 If llRetVal
1091 Select tcVertDtl
1092 lnMax= .CountTotalRecs("tcVertDtl")
1093 lnLast= v_NextPkey("ZZEOIFTD", lnMax)
1094 lnCnt= 0
1095 Scan
1096 lnCnt = lnCnt + 1
1097 lnCur = (lnLast - lnMax) + lnCnt && Detail pkey
1098 llRetVal= This.CreateRecordWithPkey("tcVertDtl", tc810WorkDetail,,,,lnCur)
1099 If !llRetVal
1100 Exit
1101 Endif
1102 Endscan
1103 This.TableClose("tcVertDtl")
1104 Select (tc810WorkDetail)
1105 Index On pkey Tag pkey
1106 Index On fkey Tag fkey
1107 Index On sku Tag sku
1108 Index On Style+division Tag StyleDiv
1109 Endif
1110 Endwith
1111
1112 Select(lnOldSelect)
1113 Return llRetVal
1114 Endproc
1115
1116
1117 ***********************************************************************************
1118 * Sync all detail fkey with proper header pkey using ord_num,inv_num
1119 ***********************************************************************************
1120 Procedure SyncHeaderDetailPFkey
1121 Lparameter tcHeaderAlias, tcDetailAlias
1122 Local llRetVal, lnOldSelect, lcReplaceString, lnCurrentHeaderCkey, lnCurrentHeaderPkey
1123 llRetVal= .T.
1124 lnOldSelect= Select()
1125 llRetVal= .SetRelation(tcHeaderAlias, "Ord_Inv", tcDetailAlias, "Str(ord_num)+Str(inv_num)")
1126 If llRetVal
1127 Replace All fkey With &tcHeaderAlias..pkey, ;
1128 sku_upc With &tcHeaderAlias..sku_upc, ;
1129 customer With &tcHeaderAlias..customer ;
1130 In (tcDetailAlias)
1131 Set Relation To
1132 Endif
1133 Select(lnOldSelect)
1134 Return llRetVal
1135 Endproc
1136
1137 ************************************************************************************
1138 * populate by distinct list of factor
1139 ***********************************************************************************
1140 Procedure PopulatebyFactor
1141 Parameters tc810WorkHeader, tceoifcr
1142 Local llRetVal, lnOldSelect
1143
1144 llRetVal = .T.
1145 lnOldSelect = Select()
1146
1147 *- 31942 11/06/02 YIK
1148 *- Added h.division to get correct factor#
1149 Select Distinct c.*, h.division From (tc810WorkHeader) h, (tceoifcr) c ;
1150 Where h.factor= c.factor Order By c.factor Into Cursor _TcFactor
1151
1152 Select _TcFactor
1153 Scan
1154 *- 34942 11/06/02 YIK
1155 *- Added h.division since we now group by division
1156 * Populate sender/receiver id/qual from 810(o) factor control reference
1157
1158 *--- TR 1016180 28-Jun-2006 Added Curr_Conv WITH _TcFactor.Curr_Conv, ;
1159 Rate_Srce WITH _TcFactor.Rate_Srce with following statement.
1160 Replace vnd_id With _TcFactor.vnd_id, vnd_qual With _TcFactor.vnd_qual,;
1161 our_id With _TcFactor.our_id, our_qual With _TcFactor.our_qual, ;
1162 sku_upc With _TcFactor.sku_upc, auto_proc With _TcFactor.auto_proc, ;
1163 Curr_Conv With _TcFactor.Curr_Conv, Rate_Srce With _TcFactor.Rate_Srce ;
1164 FOR factor= _TcFactor.factor And division = _TcFactor.division In (tc810WorkHeader)
1165
1166 *--- 1063065 27-AUG-12 Venuk.
1167 llRetVal = vl_factr(_TcFactor.factor,, "_FactRef")
1168 If llRetVal And Used("_FactRef") And !Empty(_FactRef.mast_acct_num)
1169 Replace mst_factor_num With _FactRef.mast_acct_num ;
1170 For factor= _TcFactor.factor In (tc810WorkHeader)
1171 Endif
1172 *=== 1063065 27-AUG-12 Venuk.
1173
1174 * Populate factor_num from factor reference
1175 *- Use new file and valid to get a proper factor number
1176 *- llRetval= llRetval and vl_factr(_TcFactor.factor,, "_FactAcct")
1177 *--- TR 1027444 NH
1178 *llRetVal= llRetVal And vl_factn(_TcFactor.factor,, "_FactAcct", _TcFactor.division)
1179 llRetVal= vl_factn(_TcFactor.factor,, "_FactAcct", _TcFactor.division)
1180 *=== TR 1027444 NH
1181 *=== 34942
1182 *--- TechRec 1028482 09-Nov-2007 ykaganovsky ---
1183 If llRetVal And Used("_FactAcct") And !Empty(_FactAcct.factor_num)
1184 *=== TechRec 1028482 09-Nov-2007 ykaganovsky ===
1185 *- Added h.division since factor# is per division
1186 Replace factor_num With _FactAcct.factor_num ;
1187 For factor= _TcFactor.factor And division = _TcFactor.division In (tc810WorkHeader)
1188 *= 34942 YIK
1189 Else
1190 Replace Errs_msg_H With 'Factor Number not found for Factor ' + Alltrim(_TcFactor.factor) + ;
1191 ", division " + _TcFactor.division, Errs_Flg_H With 'Y' ;
1192 FOR factor = _TcFactor.factor And division = _TcFactor.division ;
1193 IN (tc810WorkHeader)
1194 *--- TR 1027444 NH/YIK : Rem out - Exit : caused huge problem
1195 *EXIT
1196 *=== TR 1027444 NH/YIK
1197 Endif
1198 Endscan
1199
1200 .TableClose("_TcFactor")
1201 .TableClose("_FactAcct")
1202 Select(lnOldSelect)
1203 *---TR: 1020320 11-14-06 BR
1204 *Procedure must always return true.
1205 Return .T.
1206 *===TR: 1020320 11-14-06 BR
1207 Endproc
1208
1209
1210 ************************************************************************************
1211 * scan per invoice header to populate
1212 * ie. invoice amnout, merch amount, terms infos, ...
1213 ***********************************************************************************
1214 Procedure PopulateInvoices
1215 Lparameters tc810WorkHeader
1216 *- 1002392 12/04/03 YIK
1217 *- Add Factor terms code and/or ITD segment elements
1218 *- 04/05/02 YIK 31243 - Added lnTerm_DueDays to be populated from PrepareTermsInfo()
1219 Local llRetVal, lnOldSelect, lnMerch_amt, lnTerm_rate, ;
1220 lnInv_amt, lcterm_basis, lcTerm_desc, lcTerm_type, lnTerm_dom, ;
1221 ldDsc_duedate, lnDsc_duedays, ldNet_duedate, lnNet_duedays, lnTermDscAmt, lnTerm_DueDays, ;
1222 lcFTerms_code, lcITD_TmType, lnITD_DueDays, lnITD_DiscPct, ;
1223 lnITD_DiscDays
1224
1225 llRetVal = .T.
1226 lnOldSelect = Select()
1227 *- 38901 4/21/03 YIK - Set relation to get excl_disc in 810 control table
1228 .SetRelation("zzeoincr", "customer", tc810WorkHeader, "customer")
1229 *=
1230ASSERT .f.
1231 l_nThermoCnt = 0
1232 This.InitThermoWithCaption(@l_nThermoCnt, This.CountTotalRecs(tc810WorkHeader), "Populate invoice informations...")
1233 Select (tc810WorkHeader)
1234 Scan For !(Errs_Flg_H= "Y") && Only for none good header
1235 This.AdvanceThermoPlus(@l_nThermoCnt)
1236 * reset
1237 Store 0 To lnMerch_amt, lnTerm_rate, lnTermDscAmt, ;
1238 lnDsc_duedays, lnNet_duedays, lnTerm_dom, lnDetailDiscount, ;
1239 lnTerm_DueDays, lnITD_DueDays, lnITD_DiscPct, lnITD_DiscDays
1240 Store "" To lcterm_basis, lcTerm_desc, lcTerm_type, lcFTerms_code, lcITD_TmType
1241 Store {//} To ldDsc_duedate, ldNet_duedate
1242
1243 * PL 4839- Franco - 810 Factor Process - Calculate and store Extended Line Discount Amount
1244
1245 *--- TR 1016180 19-Jun-2006 Goutam
1246 *lnDetailDiscount = OrderTotalDetailDiscount(ord_num, pick_num, inv_num, ord_status)
1247 lnDetailDiscount = This.OrderTotalDetailDiscountToFactor(ord_num, pick_num, inv_num, ord_status, Curr_Conv, Rate_Srce, tc810WorkHeader)
1248 *=== TR 1016180 19-Jun-2006 Goutam
1249
1250 If lnDetailDiscount> 0
1251 Replace TotLinDscAmt With lnDetailDiscount In (tc810WorkHeader)
1252 Endif
1253 * calculate invoice amount
1254 *--- 38901 4/18/03 YIK
1255 *- Pass discount based on excl_disc flag
1256 *- Add parameter to OrderNetExtended to define if exclude detail discounts
1257 If zzeoincr.excl_disc = "Y"
1258 *--- TR 1016180 20-Jun-2006 Goutam
1259 *lnInv_amt= OrderNetExtended(ord_num, pick_num, inv_num, ord_status, .T.,, .T.)
1260 lnInv_amt = This.OrderNetExtendedToFactor(ord_num, pick_num, inv_num, ord_status, .T.,, .T., Curr_Conv, Rate_Srce, tc810WorkHeader)
1261 *=== TR 1016180 20-Jun-2006 Goutam
1262 Else
1263 *=== 38901
1264 *--- TR 1016180 20-Jun-2006 Goutam
1265 *lnInv_amt= OrderNetExtended(ord_num, pick_num, inv_num, ord_status, .T.)
1266 lnInv_amt = This.OrderNetExtendedToFactor(ord_num, pick_num, inv_num, ord_status, .T., .F., .F., Curr_Conv, Rate_Srce, tc810WorkHeader)
1267 *=== TR 1016180 20-Jun-2006 Goutam
1268 ENDIF
1269
1270 *--- TR 1054799 16-8-2011 VKK
1271 IF MultiFactor = "Y"
1272 lnInv_Amt = lnInv_Amt + Net_Fappv_amt
1273 REPLACE disc_amt WITH 0,;
1274 insu_amt WITH 0,;
1275 misc_amt WITH 0,;
1276 tax_amt WITH 0,;
1277 frgt_amt WITH 0 IN(tc810WorkHeader)
1278 ENDIf
1279 *=== TR 1054799 16-8-2011 VKK
1280
1281 *-FH LOCAL
1282 *lnInv_amt = ROUND(lnInv_amt,2)
1283 IF lnInv_amt> 0
1284 Replace inv_amt With lnInv_amt In (tc810WorkHeader)
1285 ENDIF
1286
1287 * calculate terms info
1288 Select (tc810WorkHeader)
1289 *--- TR 1016180 20-Jun-2006 Goutam
1290 *lnMerch_amt= OrderGrossExtended(ord_num, pick_num, inv_num, ord_status)
1291 lnMerch_amt= This.OrderGrossExtendedToFactor(ord_num, pick_num, inv_num, ord_status, .F., .F., Curr_Conv, Rate_Srce)
1292 *=== TR 1016180 20-Jun-2006 Goutam
1293
1294 *- 1002392 12/04/03 YIK
1295 *- Retrieve ITD segment info from zzetermx
1296 If This.GetFactorTerms(tc810WorkHeader, @lnITD_DueDays, @lnITD_DiscPct, @lnITD_DiscDays, ;
1297 @lcFTerms_code, @lcITD_TmType)
1298
1299 Replace ITD_DueDays With lnITD_DueDays, ITD_DiscPct With lnITD_DiscPct, ;
1300 ITD_DiscDays With lnITD_DiscDays, ITD_Terms With lcFTerms_code, ;
1301 ITD_TmType With lcITD_TmType ;
1302 in (tc810WorkHeader)
1303 Endif
1304 *= 1002392 YIK
1305
1306 * Prepare Terms Infos in memvar (will populate from 3rd para down)
1307 * PL 09/04/01 26617 -Terms Discount is based on Gross, should be based on Net
1308 * like elsewhere in System. change 2nd. parameter to lnInv_amt from lnMerch_amt
1309 *- YIK 04/05/02 31243 Added @lnTerm_DueDays to get due days directly from term master
1310 If This.PrepareTermsInfo(tc810WorkHeader, lnInv_amt, @lcterm_basis, @lnTerm_rate,;
1311 @lcTerm_desc, @lcTerm_type, @lnTerm_dom, @ldDsc_duedate, @lnDsc_duedays,;
1312 @ldNet_duedate, @lnNet_duedays, @lnTermDscAmt, @lnTerm_DueDays)
1313 * Gentran cannot take " / / " - force {01/01/1900}
1314 If Empty(ldDsc_duedate)
1315 ldDsc_duedate= VFP_EMPTY_DATE_DEFAULT
1316 Endif
1317 If Empty(ldNet_duedate)
1318 ldNet_duedate= VFP_EMPTY_DATE_DEFAULT
1319 Endif
1320
1321 * write to invoice transaction header
1322 *- YIK 04/05/02 31243 Added Term_DueDays
1323 Replace merch_amt With lnMerch_amt, term_basis With lcterm_basis,;
1324 term_rate With lnTerm_rate, term_desc With lcTerm_desc, ;
1325 term_type With lcTerm_type, term_dom With lnTerm_dom, ;
1326 dsc_duedate With ldDsc_duedate, dsc_duedays With lnDsc_duedays, ;
1327 net_duedate With ldNet_duedate, net_duedays With lnNet_duedays, ;
1328 TermDscAmt With lnTermDscAmt, Term_DueDays With lnTerm_DueDays In (tc810WorkHeader)
1329 Else
1330 * problem in PrepareTermsInfo
1331 llRetVal= .F.
1332 Exit && scan loop
1333 Endif
1334 *- 37880 03/17/03 YIK
1335 *- Zero out freight if zzxcustr.frgt_excl = 'Y'
1336 If Seek(&tc810WorkHeader..customer, "zzxcustr") And zzxcustr.frgt_excl = 'Y'
1337 Replace Frgt_Amt With 0 In (tc810WorkHeader)
1338 Endif
1339 *= 37880 YIK
1340 * populate company name
1341 Replace comp_name With g_cCompany In (tc810WorkHeader)
1342 Endscan
1343 This.ResetThermoPlus()
1344 Select(lnOldSelect)
1345 Return llRetVal
1346 Endproc
1347
1348
1349 ************************************************************************************
1350 * Assign batch/submission/process seq number per factor
1351 ***********************************************************************************
1352 Procedure AssignBatchNumber
1353 Parameters tc810WorkHeader
1354 Local llRetVal, lnOldSelect
1355
1356 With This
1357 llRetVal = .T.
1358 lnOldSelect = Select()
1359
1360 * Only good header
1361 Select Distinct factor From (tc810WorkHeader) ;
1362 Order By factor Into Cursor _TcFactor Where !(Errs_Flg_H= "Y")
1363
1364 Select _TcFactor
1365 Scan
1366 lnControl_num= 0
1367 lnControl_num= v_NextSequence("zzeoifcr","control_num",;
1368 "factor= '" + _TcFactor.factor + "'")
1369
1370 If lnControl_num> 0
1371 Replace fact_batch_num With lnControl_num ;
1372 For factor= _TcFactor.factor In (tc810WorkHeader)
1373 Else
1374 llRetVal= .F.
1375 Exit
1376 Endif
1377 Endscan
1378
1379 .TableClose("_TcFactor")
1380 Select(lnOldSelect)
1381 Endwith
1382 Return llRetVal
1383 Endproc
1384
1385 ************************************************************************************
1386 * Assign batch/submission/process seq number per factor
1387 ***********************************************************************************
1388 Procedure UpdateInvoiceFactorFlag
1389 Parameters pcTranHeader, pcInvoiceHeader
1390 Local llRetVal , lnOldSelect, ltDatetime, lcUser_id
1391 llRetVal= .T.
1392 ltDatetime= Datetime()
1393 lcUser_id= goEnv.envLogin.cUserName
1394 lnOldSelect = Select()
1395
1396 If Used(pcTranHeader) And Used(pcInvoiceHeader)
1397 llRetVal= .SetRelation(pcTranHeader, "Ord_Inv", pcInvoiceHeader, "Str(ord_num)+Str(inv_num)")
1398 If llRetVal
1399 *- 34940 10/28/02 YIK - Added eof() because consolidated invoices (except for the 1st one) are
1400 *- not in (pcTranHeader) and shouldn't be marked as processed yet.
1401 *- All transactions are in trans. maint table and were not moved to interface table yet.
1402 *- This routine will mark the invoice with # matching consolidated invoice as processed
1403 *- (if the invoice is ok).
1404 Scan For !Eof(pcTranHeader) And !(&pcTranHeader..Errs_Flg_H= "Y") && None error trans header only
1405
1406 Replace Proc_810f With "P",;
1407 user_id With lcUser_id,;
1408 last_mod With ltDatetime In (pcInvoiceHeader)
1409 Endscan
1410 Set Relation To
1411 Endif
1412 Endif
1413
1414 Select(lnOldSelect)
1415 Return llRetVal
1416 Endproc
1417
1418 ************************************************************************************
1419 * UnloadToFlatFile
1420 ***********************************************************************************
1421 Procedure UnLoadToFlatFile
1422 Lparameters tcProcess, tcFlatFile, tcHeader, tcDetail, tcAddress, tceoifcr
1423 Local llRetVal, lcSQLString, lnHandle
1424 llRetVal= .F.
1425 With This
1426 *---TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1427 USE IN SELECT("__tcFlatFileList")
1428 Create Cursor __tcFlatFileList(TempFlatfile memo, OutBoundFlatFile memo)
1429 *===TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1430
1431 * get Metadata for vendor table
1432 If .GetTranslationDefinition(EDI_ALL_TRANSACTION, "tcEmVend")
1433 * get Metadata for a process
1434 If .GetTranslationDefinition(tcProcess, "tcEmData")
1435 * Create Metadata work tables
1436 .CreateMetaDataWorkTable("tcEmVend", "VENDOR", "tcoifmwV")
1437 .CreateMetaDataWorkTable("tcEmData", "HEADER", "tcoifmwH")
1438 .CreateMetaDataWorkTable("tcEmData", "DETAIL", "tcoifmwD")
1439 .CreateMetaDataWorkTable("tcEmData", "ADDRESS", "tcoifmwA")
1440 * Open Flatfile and append to it
1441
1442 * remove previous tmp text file
1443 *- 1010532 04/15/05 YIK
1444 *- setup for Tie commerce. Requires different file names for different vendors
1445 *-- lcTempFlatfile= StrTran(Upper(tcFlatFile), ".DAT", ".TMP")
1446 *-- delete file (lcTempFlatfile)
1447
1448 *-- lnHandle= .OpenFlatFile(lcTempFlatfile, True)
1449
1450 *-- If lnHandle> 0
1451
1452 lnHandle = 0
1453 If !.Tie_setup
1454 lcTempFlatfile= Strtran(Upper(tcFlatFile), ".DAT", ".TMP")
1455 Delete File (lcTempFlatfile)
1456
1457 lnHandle= .OpenFlatFile(lcTempFlatfile, true)
1458 Endif
1459 If .Tie_setup Or lnHandle> 0
1460 *=== 1010532
1461 * Populate data to metadata work header tables
1462 .ScatterGather(tcHeader, "tcoifmwH")
1463 * Populate data to metadata work detail tables
1464 .ScatterGather(tcDetail, "tcoifmwD")
1465 * Populate data to metadata work address tables
1466 .ScatterGather(tcAddress, "tcoifmwA")
1467
1468 SET ASSERTS ON
1469 ASSERT .f.
1470 *--- TR 1094625 4-Apr-2016 Goutam
1471 IF vl_compr(,"use_decs") = 'Y'
1472 llRetVal = .SuppressZeroFromQty("tcoifmwH", "tcoifmwD")
1473 ENDIF
1474 *=== TR 1094625 4-Apr-2016 Goutam
1475 * Mash/group all records to a single flatfile
1476 * If get here will return true if successfully create flatfile
1477 llRetVal= .CreateFlatfileFromMetadataWorkTalbes(tcProcess, "tcoifmwV",;
1478 "tcoifmwH", "tcoifmwD", "tcoifmwA", tceoifcr, lnHandle) &&
1479 *- 1010532 04/15/05 YIK
1480 *- Fclose(lnHandle)
1481 If !.Tie_setup
1482 Fclose(lnHandle)
1483 * append to 810.dat form 810.dat.tmp
1484 If llRetVal
1485 *---TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1486 *llRetVal=.CopyToFlatFile(lcTempFlatfile, tcFlatFile)
1487 * use 64K block append to .dat file from .tmp instead of
1488 * line by line append with CopytoFlatFile
1489 *llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile, tcFlatFile)
1490 INSERT INTO __tcFlatFileList(TempFlatfile,OutBoundFlatFile) VALUES (lcTempFlatfile, tcFlatFile)
1491 *===TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1492 Endif
1493 Endif
1494 *==
1495 Endif
1496 Endif
1497 Endif
1498 .TableClose('tcEmVend')
1499 .TableClose('tcEmData')
1500 .TableClose('tcoifmwV')
1501 .TableClose('tcoifmwH')
1502 .TableClose('tcoifmwD')
1503 .TableClose('tcoifmwA')
1504 Endwith
1505 Return llRetVal
1506 Endproc
1507
1508 ************************************************************************************
1509 * group all records from metadata work tables to a flat text file
1510 * level break vendor record by factor
1511 ***********************************************************************************
1512 Procedure CreateFlatfileFromMetadataWorkTalbes
1513 Lparameter tcProcess, tcWorkVendor, tcWorkHeader, tcWorkDetail, tcWorkAddress, tceoifcr, pnHandle
1514 Local llRetVal, lnOldSelect, lnCurrentPkey, llHaveComment, llHaveAddress, lcPreviousFactor,;
1515 lcMac, lcString, ll831Created, llPrevious831reqd, lc831String, lc831VNDString, lnNum_inv, ;
1516 ln831_inv_amt, ln831_TermDscAmt, loHeader, lcPreviousVendID, lcPreviousFNum
1517 llRetVal= .T.
1518 lcPreviousFactor= ""
1519 llHaveAddress= (This.CountTotalRecs(tcWorkAddress)>0)
1520 *--- TR 1014084 NH
1521 Local llFactorChanged, lcPrevVnd_id, llVndString_req
1522 llFactorChanged = .F.
1523 lcPrevVnd_id = ""
1524 llVndString_req = .F.
1525 *=== TR 1014084 NH
1526
1527 *- 1018542 08/11/06 YIK
1528 Local Array laBatch_amt[1]
1529 Store "0" To laBatch_amt[1]
1530 *= 1018542
1531
1532 lnOldSelect= Select()
1533 *- TAN 29573 YIK
1534 lcPreviousVendID = ""
1535 lcPreviousFNum = ""
1536 ll831Created = .F.
1537 llPrevious831reqd = .F.
1538 lc831String = ""
1539 Store 0 To ln831_inv_amt, ln831_TermDscAmt, lnNum_inv
1540
1541 With This
1542 Select (tcWorkHeader)
1543 *- 1010532 04/15/05 YIK
1544 Index On factor_num Tag factor_num && to open flat file for a factor only once
1545 INDEX on vnd_id TAG vnd_id && TR 1045924 MAY-25-2010 BR - file needs to open/close based on vnd_id
1546
1547 lcEDIPath = This.GetEDIFlatFileDirectory("Outbound")
1548 lnHandle = 0
1549 lnHandle_831 = 0
1550 *==
1551
1552 Scan
1553 * reset lcString
1554 lcString= ""
1555 llFactorChanged = Not (factor == lcPreviousFactor)
1556 ***********************************************On level break of Factor
1557 *- 34942 11/05/02 YIK
1558 *- Create an ISA per factor#
1559 *- If !(Factor == lcPreviousFactor)
1560
1561 * --- TR 1039113 3/10/09 CM
1562 * Create an ISA per factor, that way if 810 control does not exist we avoid duplicating
1563 * Invoices in the flat file.
1564 *If !(factor == lcPreviousFactor) Or !(factor_num == lcPreviousFNum)
1565
1566 *--- TR 1045924 MAY-25-2010 BR
1567 *If !(factor == lcPreviousFactor)
1568 IF !(vnd_id == lcPreviousVendID)
1569 *=== TR 1045924 MAY-25-2010 BR
1570 * === TR 1039113 3/10/09 CM
1571
1572 *- TAN 29573 YIK
1573 If llPrevious831reqd
1574 *- See if header record for this factor exists. If not - Create
1575 *- 831 header records with factor#, asgmnt#, asgmnt date and amounts
1576 Select tcoctmwH
1577 *--- TR 1045924 MAY-25-2010 BR
1578 *Locate For factor_num = lcPreviousFNum
1579 Locate For vnd_id = lcPreviousVendID
1580 *==== TR 1045924 MAY-25-2010 BR
1581 If !Found()
1582 Append Blank
1583 Gather Name loHeader
1584 Replace inv_amt With Trans(ln831_inv_amt, "99999999.99"), ;
1585 TermDscAmt With Trans(ln831_TermDscAmt, "99999999.99"), ;
1586 num_inv With Trans(lnNum_inv)
1587 Store 0 To ln831_inv_amt, ln831_TermDscAmt, lnNum_inv
1588 Else
1589 *- Update amount and number of invoices
1590 Replace inv_amt With Trans(Val(inv_amt) + ln831_inv_amt, "99999999.99"), ;
1591 TermDscAmt With Trans(Val(TermDscAmt) + ln831_TermDscAmt, "99999999.99"), ;
1592 num_inv With Trans(Val(num_inv) + lnNum_inv)
1593 Endif
1594 Endif
1595 llPrevious831reqd = .F.
1596 lcPreviousFactor= &tcWorkHeader..factor
1597 lcPreviousFNum = &tcWorkHeader..factor_num
1598 *- 1018542 08/11/06 YIK
1599 *--- TR 1045924 MAY-25-2010 BR
1600*!* Select Trans(Sum(Evaluate(inv_amt)), "9999999.99") ;
1601*!* From (tcWorkHeader) ;
1602*!* Where factor= Allt(lcPreviousFactor) ;
1603*!* AND factor_num = Allt(lcPreviousFNum) ;
1604*!* Into Array laBatch_amt
1605 Select * From (tceoifcr) Where factor= Allt(lcPreviousFactor) Into Cursor _oifcr
1606 lcPreviousVendID = _oifcr.vnd_id
1607
1608 Select Trans(Sum(Evaluate(inv_amt)), "9999999.99") ;
1609 From (tcWorkHeader) ;
1610 Where vnd_id= Allt(lcPreviousVendID) ;
1611 Into Array laBatch_amt
1612 *==== TR 1045924 MAY-25-2010 BR
1613 *= 1018542
1614
1615 If Used('_oifcr')
1616 If _oifcr.reqd_831 = 'Y'
1617 If !ll831Created
1618 *- The first factor that requires 831. Create meta tables for 831.
1619 If .GetTranslationDefinition('OCT', "tc831EmData")
1620 .CreateMetaDataWorkTable("tcEmVend", "VENDOR", "tcoctmwV")
1621 .CreateMetaDataWorkTable("tc831EmData", "HEADER", "tcoctmwH")
1622 Endif
1623 ll831Created = .T.
1624 Endif
1625 llPrevious831reqd = .T.
1626 *- Create vendor record for 831 process. Structure is the same as 810F
1627 *- Check if this factor code has been already processed.
1628 *- File tcoctmwV (VND) doesn't have factor code, so we check tcoctmwH (HDR)
1629 *- We need to separate factors with the same ID but different factor#
1630 *!* Select tcoctmwV
1631 *!* LOCATE FOR vnd_id = lcPreviousVendID
1632
1633 *--- TR 1054799 8-Aug-2012 Goutam. No vnd_id field in this table tcoctmwH. Crashing...
1634 *Select tcoctmwH
1635 Select tcoctmwV
1636 *=== TR 1054799 8-Aug-2012 Goutam
1637
1638 *--- TR 1045924 MAY-25-2010 BR
1639 *Locate For factor_num = lcPreviousFNum
1640 Locate For vnd_id = lcPreviousVendID
1641 *=== TR 1045924 MAY-25-2010 BR
1642 If !Found() && new factor requires new VND record.
1643 Select tcoctmwV
1644 Appen Blank
1645 Replace vnd_id With _oifcr.vnd_id, vnd_tran With 'OCT',;
1646 vnd_vers With _oifcr.vnd_vers In tcoctmwV
1647 Endif
1648 Select (tcWorkHeader)
1649 Scatter Name loHeader
1650 Endif
1651 *= TAN 29573 YIK
1652 Select (tcWorkVendor)
1653 Appen Blank
1654 Replace vnd_id With _oifcr.vnd_id, vnd_tran With tcProcess,;
1655 vnd_vers With _oifcr.vnd_vers In (tcWorkVendor)
1656 Select (tcWorkHeader)
1657 *- 1010532 04/15/05 YIK
1658 If .Tie_setup
1659 *- close previously opened file
1660 If lnHandle > 0
1661 *-- If FWRITE(lnHandle, lcString) = 0
1662 *-- lRetVal = .F.
1663 *-- Endif
1664 Fclose(lnHandle)
1665 If llRetVal
1666 *---TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1667 *llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
1668 INSERT INTO __tcFlatFileList(TempFlatfile,OutBoundFlatFile) VALUES (lcTempFlatfile, lcOutboundFlatFile)
1669 *---TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1670 Endif
1671
1672 Endif
1673 *- new flat file name
1674 lcOutBoundFlatFile = lcEDIPath + Alltrim(vnd_id) + "810F.DAT"
1675 lcTempFlatfile= Strtran(Upper(lcOutBoundFlatFile), ".DAT", ".TMP")
1676 Delete File (lcTempFlatfile)
1677
1678 lnHandle= .OpenFlatFile(lcTempFlatfile, .T.)
1679
1680 If lnHandle <= 0
1681 Loop
1682 Endif
1683 Endif
1684 *= 1010532
1685
1686 Else
1687 llRetVal= .F.
1688 Exit && scan
1689 Endif
1690 ************Output Vendor string ("VND",TradingPartnerID,Transaction,Version)
1691 * For GenTran find System template need VND- record
1692 * TradingPartnerID, EDI transaction set (810, 856..), Version (003060,004010...)
1693 *lcString = EDI_VENDOR_TAG + .ConvertRecordToText(tcWorkVendor)
1694 *- 1009713 3/3/05 YIK
1695 llDelimited = (_oifcr.EDI_Format = 'D')
1696 lcDelimiter = Iif(llDelimited, _oifcr.EDI_Delim, "")
1697 lcVNDString = EDI_VENDOR_TAG + lcDelimiter + .ConvertRecordToText(tcWorkVendor, llDelimited, lcDelimiter)
1698
1699
1700 Endif
1701 Select (tcWorkHeader)
1702 *output header string "HDR"
1703 *- 1009713 3/3/05 YIK
1704 *--- TR 1014084 NH
1705 *--- TR 1015001 NH remove special logic for VND string writing for TIE setup
1706 *!* llVndString_req = .f.
1707 *!* IF .Tie_setup
1708 *!* IF llFactorChanged OR lcPrevVnd_id <> EVALUATE(tcWorkVendor+ ".vnd_id")
1709 *!* llVndString_req = .t.
1710 *!* ENDIF
1711 *!* ELSE
1712 llVndString_req = .T.
1713 *!* ENDIF
1714 *=== TR 1015001 NH
1715 If llVndString_req
1716 lcString = lcString + lcVNDString
1717 Endif
1718 *- 1018542 08/11/06 YIK
1719 Replace batch_amt With laBatch_amt[1] In (tcWorkHeader)
1720
1721 lcString = lcString + EDI_HEADER_TAG + lcDelimiter + .ConvertRecordToText(tcWorkHeader, llDelimited, lcDelimiter)
1722 *=== TR 1014084 NH
1723 lnCurrentPkey= &tcWorkHeader..pkey
1724 *- TAN 29573 05/10/02 YIK
1725 If llPrevious831reqd
1726 ln831_inv_amt = ln831_inv_amt + Eval(inv_amt)
1727 ln831_TermDscAmt = ln831_TermDscAmt + Eval(TermDscAmt)
1728 lnNum_inv = lnNum_inv + 1
1729 Endif
1730 *= TAN 29573
1731 *output Addresses string "ADR"
1732 If llHaveAddress
1733 Select (tcWorkAddress)
1734 Scan For fkey = lnCurrentPkey
1735 *- 1009713 3/3/05 YIK
1736 lcString = lcString + EDI_ADDRESS_TAG + lcDelimiter + .ConvertRecordToText(tcWorkAddress, llDelimited, lcDelimiter)
1737 Endscan
1738 Endif
1739 *---TR 1018695 09-Nov-2006 CD ---
1740 *---Bypass invoices with 0.00 amount
1741 Local lnOldArea, lnInvAmt
1742 lnOldArea = Select()
1743 Select(tcWorkHeader)
1744 lnInvAmt = Alltrim(Evaluate(tcWorkHeader + ".inv_amt"))
1745 Select(lnOldArea)
1746 If This.lBypassInv = .T. And lnInvAmt = "0.00" Or Empty(lnInvAmt)
1747 lcString = ""
1748 Else
1749 *===TR 1018695 09-Nov-2006 CD ===
1750
1751 * output detail string "DTL"
1752 Select (tcWorkDetail)
1753 Scan For fkey = lnCurrentPkey
1754 *- 1009713 3/3/05 YIK
1755 lcString = lcString + EDI_DETAIL_TAG + lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
1756 Endscan
1757 Endif &&===TR 1018695 09-Nov-2006 CD ===
1758 If !Empty(lcString)
1759 .PrepareEmptyDateForGentran(@lcString)
1760 *- 1010532 04/15/05 YIK
1761 *-- If FWRITE(pnHandle, lcString) = 0
1762 *-- lRetVal = .F.
1763 *-- Endif
1764 If .Tie_setup
1765 If Fwrite(lnHandle, lcString) = 0
1766 lRetVal = .F.
1767 Endif
1768 Else
1769 If Fwrite(pnHandle, lcString) = 0
1770 lRetVal = .F.
1771 Endif
1772 Endif
1773 *== YIK
1774 Endif
1775 *--- TR 1014084 NH
1776 lcPrevVnd_id = Evaluate(tcWorkVendor + ".vnd_id")
1777 *=== TR 1014084 NH
1778 Endscan
1779 *- 1010532 04/15/05 YIK
1780 If .Tie_setup And lnHandle > 0
1781 *- close previously opened file
1782 *-- If FWRITE(lnHandle, lcString) = 0
1783 *-- lRetVal = .F.
1784 *-- Endif
1785 Fclose(lnHandle)
1786 If llRetVal
1787 *---TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1788 *llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
1789 INSERT INTO __tcFlatFileList(TempFlatfile,OutBoundFlatFile) VALUES (lcTempFlatfile, lcOutBoundFlatFile)
1790 *===TR 1036975 NOV-14-08 TEJAS : Capture file names that get created
1791 Endif
1792 Endif
1793 *==
1794
1795
1796 *- TAN 29573 05/10/02 YIK
1797 If llPrevious831reqd
1798 *- See if header record for this factor exists. If not - Create
1799 *- 831 header records with factor#, asgmnt#, asgmnt date and amounts
1800 Select tcoctmwH
1801 Locate For factor_num = lcPreviousFNum
1802
1803 If !Found()
1804 Append Blank
1805 Gather Name loHeader
1806 Replace inv_amt With Trans(ln831_inv_amt, "99999999.99"), ;
1807 TermDscAmt With Trans(ln831_TermDscAmt, "99999999.99"), ;
1808 num_inv With Trans(lnNum_inv)
1809 Else
1810 *- Update amount and number of invoices
1811 Replace inv_amt With Trans(Val(inv_amt) + ln831_inv_amt, "99999999.99"), ;
1812 TermDscAmt With Trans(Val(TermDscAmt) + ln831_TermDscAmt, "99999999.99"), ;
1813 num_inv With Trans(Val(num_inv) + lnNum_inv)
1814 ENDIF
1815 ENDIF && 1057315 - YIK/FH
1816
1817 *- 1063832 FH - move below
1818 *- Create a string from corresponding vendor and header records
1819*!* lc831String = ""
1820*!* Select tcoctmwV
1821*!* lnRecCnt = This.CountTotalRecs(Alias())
1822 *- 1063832 FH - move below
1823
1824 *IF lnRecCnt > 0 && 1057315 - YIK/FH - need to create 831.dat
1825 IF ll831Created && 1063832 FH
1826 *- 1063832 FH
1827 lc831String = ""
1828 Select tcoctmwV
1829 lnRecCnt = This.CountTotalRecs(Alias())
1830 *- 1063832 FH
1831
1832 *- 1010532 04/22/05 YIK
1833 *- Add laVND_ID
1834 Declare laV[lnRecCnt], laH[lnRecCnt], laVND_ID[lnRecCnt]
1835 lnCnt = 0
1836 Scan
1837 lnCnt = lnCnt + 1
1838 *- 1009713 3/3/05 YIK
1839
1840 laV[lnCnt] = EDI_VENDOR_TAG + lcDelimiter + .ConvertRecordToText("tcoctmwV", llDelimited, lcDelimiter)
1841 *- 1010532 04/22/05 YIK
1842 *- Add laVND_ID
1843 laVND_ID[lnCnt] = tcoctmwV.vnd_id
1844 Endscan
1845 Select tcoctmwH
1846 lnCnt = 0
1847 Scan
1848 lnCnt = lnCnt + 1
1849 *- 1009713 3/3/05 YIK
1850 laH[lnCnt] = EDI_HEADER_TAG + lcDelimiter + .ConvertRecordToText("tcoctmwH", llDelimited, lcDelimiter)
1851 Endscan
1852 For lnCnt = 1 To lnRecCnt
1853 lc831String = laV[lnCnt] + laH[lnCnt]
1854 If !Empty(lc831String)
1855 .PrepareEmptyDateForGentran(@lc831String)
1856 *- 1010532 04/22/05 YIK
1857 *- We need to open a new file for the 831
1858 *-- If FWRITE(pnHandle, lc831String) = 0
1859 *-- llRetVal = .F.
1860 *-- Endif
1861
1862 If .Tie_setup OR .BCEdi_Version && TR 1046497 APR-28-2010 BR - ADDED: .BCEdi_version
1863 *- close previously opened file
1864 If lnHandle_831 > 0
1865 Fclose(lnHandle_831)
1866 *-- If llRetVal
1867 *-- llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile_831, lcOutboundFlatFile_831)
1868 *-- Endif
1869 Endif
1870 *- new flat file name
1871 *-- TR 1046497 APR-28-2010 BR
1872 IF .BCEdi_Version
1873 lcOutboundFlatFile_831 = lcEDIPath + "831.DAT"
1874 lcTempFlatfile_831 = Strtran(Upper(lcOutboundFlatFile_831), ".DAT", ".TMP")
1875 ELSE
1876 lcOutboundFlatFile_831 = lcEDIPath + Alltrim(laVND_ID[lnCnt]) + "831.DAT"
1877 lcTempFlatfile_831 = Strtran(Upper(lcOutboundFlatFile_831), ".DAT", ".TMP")
1878 ENDIF
1879 *== TR 1046497 APR-28-2010 BR
1880
1881 Delete File (lcTempFlatfile_831)
1882
1883 lnHandle_831 = .OpenFlatFile(lcTempFlatfile_831, .T.)
1884
1885 If lnHandle_831 <= 0
1886 Loop
1887 Else
1888 llRetVal = (Fwrite(lnHandle_831, lc831String) > 0)
1889 llRetVal = llRetVal And Fclose(lnHandle_831)
1890 llRetVal = llRetVal And .CopyToFlatFileInBlock(lcTempFlatfile_831, lcOutboundFlatFile_831)
1891 Endif
1892 Else
1893 If Fwrite(pnHandle, lc831String) = 0
1894 llRetVal = .F.
1895 Endif
1896 Endif
1897 *= 1010532
1898
1899 Endif
1900 Endfor
1901 Endif
1902 If ll831Created
1903 .TableClose("tc831EmData")
1904 .TableClose("tcoctmwH")
1905 .TableClose("tcoctmwV")
1906 Endif
1907 *= TAN 29573
1908 .TableClose('_oifcr')
1909 Endwith
1910
1911 Select(lnOldSelect)
1912 Return llRetVal
1913 Endproc
1914
1915 ************************************************************************************
1916 *
1917 ***********************************************************************************
1918 Procedure GetOriginalSKUQty
1919 Lparameters pcTranHeader, pcTranDetail, pcTranControl
1920 Local llRetVal, lcSQLString, lnOldSelect
1921 llRetVal= .T.
1922 lnOldSelect= Select()
1923
1924 Select Distinct d.ord_num, d.line_seq, d.sizebucket ;
1925 From (pcTranHeader) h, (pcTranDetail) d, (pcTranControl) c ;
1926 Where h.factor= c.factor And ;
1927 !(h.Errs_Flg_H= "Y") And ; &&Empty(h.Errs_Msg_H)
1928 h.pkey= d.fkey And ;
1929 c.origitemqty= "Y" ;
1930 Order By d.ord_num, d.line_seq, d.sizebucket Into Cursor __TmpCursor
1931
1932 * PL 01/08/01 ATS 4911 Laf148 EDI 810(o) Factor process support CIT
1933 * reuse by calling with difference control keys --normal 810 division,customer
1934 * and 810 factor will be just factor
1935 llRetVal= This.CalcOriginalSKUQty(pcTranHeader, pcTranDetail, "__TmpCursor")
1936
1937 Select(lnOldSelect)
1938 Return llRetVal
1939 Endproc
1940
1941
1942 * 4911- Laf148 EDI 810(o) Factor process support CIT
1943 ************************************************************************************
1944 *
1945 ***********************************************************************************
1946 Procedure Create810Addresses
1947 Lparameters tc810WorkHeader, tc810WorkAddress
1948 Local llRetVal, lnOldSelect
1949 llRetVal = .T.
1950 lnOldSelect = Select()
1951 l_nThermoCnt = 0
1952 This.InitThermoWithCaption(@l_nThermoCnt, This.CountTotalRecs(tc810WorkHeader), "Creating Addresses...")
1953
1954 *--- TR 1067898 04-12-2013 RKI ---*
1955
1956 Select Distinct c.*, h.division From (tc810WorkHeader) h, (this.c810FactorControl) c ;
1957 Where h.factor= c.factor Order By c.factor Into Cursor _Tc810Factor
1958
1959 INDEX on factor TAG factor
1960 *=== TR 1067898 04-12-2013 RKI ===*
1961
1962 Select (tc810WorkHeader)
1963 Scan For !(Errs_Flg_H= "Y")
1964 This.AdvanceThermoPlus(@l_nThermoCnt)
1965 * Should optimize latter by comparing with previous keys
1966
1967
1968
1969 If Bcaddres(&tc810WorkHeader..customer,, "tmpAddrs", &tc810WorkHeader..Store, ;
1970 &tc810WorkHeader..ship_dc, &tc810WorkHeader..center_code, ;
1971 &tc810WorkHeader..consol_code, &tc810WorkHeader..ord_num, ;
1972 &tc810WorkHeader..division, &tc810WorkHeader..factor, ;
1973 &tc810WorkHeader..location)
1974 * Create Interface address record
1975 m.ord_num= &tc810WorkHeader..ord_num
1976 m.pick_num= &tc810WorkHeader..pick_num
1977 m.inv_num= &tc810WorkHeader..inv_num
1978 m.fkey= &tc810WorkHeader..pkey
1979 * PL TAN 26988- Crash with m.B_AccessNum not found could be optional
1980 * same error for S_AccessNum. Need to reset both to '' before GetContactPhone()
1981 Store '' To m.B_AccessNum, m.S_AccessNum
1982 If TmpAddrs.b_pkey>0
1983 m.B_AccessNum= GetContactPhone(TmpAddrs.b_pkey, TmpAddrs.b_table,,,"A")
1984 Endif
1985 If TmpAddrs.s_pkey>0
1986 m.S_AccessNum= GetContactPhone(TmpAddrs.s_pkey, TmpAddrs.s_table,,,"A")
1987 Endif
1988 *--- TR 1067898 04-12-2013 RKI ---*
1989 IF Seek(&tc810WorkHeader..factor, "_Tc810Factor","factor") And _Tc810Factor.bill_to = 'C'
1990 IF billtoAddressResolution(&tc810WorkHeader..customer,"tmpBillAddrs", &tc810WorkHeader..Store, ;
1991 &tc810WorkHeader..ship_dc, &tc810WorkHeader..center_code, ;
1992 &tc810WorkHeader..consol_code)
1993
1994 Replace b_pkey WITH tmpBillAddrs.Rpkey, b_table WITH tmpBillAddrs.rtbl, ;
1995 b_name WITH tmpBillAddrs.rname, b_addr1 WITH tmpBillAddrs.raddr1, ;
1996 b_addr2 WITH tmpBillAddrs.raddr2, b_city WITH tmpBillAddrs.rcity, ;
1997 b_state WITH tmpBillAddrs.rstate, b_zipcode WITH tmpBillAddrs.rzip, ;
1998 b_country WITH tmpBillAddrs.rcountry, b_dba WITH tmpBillAddrs.rdba, ;
1999 b_country_code WITH tmpBillAddrs.r_country_code In ("TmpAddrs")
2000
2001
2002 ENDIF
2003 endif
2004 *=== TR 1067898 04-12-2013 RKI ===*
2005
2006
2007 *---TR 1033490 MAY-16-2008 BR ADDED: "ZZEOIFTA" as 5th parameter to avoid 810f from assigning address pkeys from ZZEOSHIA
2008 If !This.CreateVerticalAddress("TmpAddrs", tc810WorkAddress, ;
2009 m.B_AccessNum, m.S_AccessNum, "ZZEOIFTA")
2010 llRetVal= .F.
2011 Exit
2012 Endif
2013 Else
2014 llRetVal= .F.
2015 Exit
2016 Endif
2017 Endscan
2018 This.ResetThermoPlus()
2019 USE IN SELECT("_Tc810Factor") && TR 1067898 04-12-2013 RKI
2020 Select(lnOldSelect)
2021 Return llRetVal
2022 Endproc
2023
2024 ************************************************************************************
2025 *- 34940 10/24/02 YIK
2026 *- Mark invoices used for consolidated invoices as processed
2027 ************************************************************************************
2028 Procedure UpdateConsolidateInvoiceFactorFlag
2029 Parameters pcTranHeader, pcInvoiceHeader
2030 Local llRetVal , lnOldSelect, ltDatetime, lcUser_id
2031 llRetVal= .T.
2032 ltDatetime= Datetime()
2033 lcUser_id= goEnv.envLogin.cUserName
2034 lnOldSelect = Select()
2035
2036 If Used(pcTranHeader) And Used(pcInvoiceHeader)
2037 llRetVal= .SetRelation(pcTranHeader, "consol_num", pcInvoiceHeader, "Str(consol_num)")
2038 If llRetVal
2039 Scan For((&pcTranHeader..c_consol_inv = 'Y') Or (&pcTranHeader..c_consol_inv = 'S')) And ; && Added "OR (&pcTranHeader..c_consol_inv = 'S')" TR:1018876 BR
2040 (!(&pcTranHeader..Errs_Flg_H= "Y") And &pcTranHeader..consol_num > 0) && None error trans header only
2041 Replace Proc_810f With "P",;
2042 user_id With lcUser_id,;
2043 last_mod With ltDatetime In (pcInvoiceHeader)
2044 Endscan
2045 Set Relation To
2046 Endif
2047 Endif
2048
2049 ************************************************************************************
2050 * PopulateConsolFlag
2051 ************************************************************************************
2052 Procedure PopulateConsolFlag
2053 Parameters pcWorkHeader, pceoincr
2054 Local llRetVal, lnOldSelect
2055
2056 llRetVal = .T.
2057 lnOldSelect = Select()
2058 *--- 1030155
2059*!* Select Distinct r.customer, r.division, r.consol_inv ; && added r.consol_inv TR:1018876 BR
2060*!* From (pceoincr) r ;
2061*!* JOIN (pcWorkHeader) h On h.customer=r.customer And h.division=r.division ; && 1025546 7/6/07 BR - REMOVED: And r.active_ok = 'Y'
2062*!* Where r.consol_inv = 'Y' Or r.consol_inv = 'S' ;
2063*!* INTO Cursor _tmpConsol
2064
2065*!* Scan
2066*!* Replace c_consol_inv With _tmpConsol.consol_inv ; && added _tmpConsol.consol_inv TR:1018876 BR
2067*!* For customer = _tmpConsol.customer And division = _tmpConsol.division And consol_num > 0 ;
2068*!* IN (pcWorkHeader)
2069*!* Endscan
2070 UPDATE h SET c_consol_inv = r.consol_inv ;
2071 FROM (pcWorkHeader) h inner Join (pceoincr) r On h.customer=r.customer And h.division=r.division ;
2072 WHERE h.consol_num > 0
2073
2074 *--- consolidate invoice when there is no corresponding 810 control ref record
2075 UPDATE h SET c_consol_inv = 'Y' ;
2076 FROM (pcWorkHeader) h WHERE h.consol_num > 0 ;
2077 AND not exists (select * from (pceoincr) r where h.customer=r.customer And h.division=r.division )
2078 *=== 1030155
2079
2080 If Used("_tmpConsol")
2081 Use In _tmpConsol
2082 Endif
2083 Select (lnOldSelect)
2084 Return llRetVal
2085 *=== 34940 10/30/02
2086
2087 *-------------------------------------------------------------------------------------------------------
2088 *--- TR 1011539 NH
2089 *--- TR 1027444 NH -- added param pceoincr
2090 Procedure PrepareTempTableToUpdateFactorFlag
2091 Parameters pcWorkHeader, pceoincr
2092 Local llRetVal, lnOldSelect, loDet, loHDR
2093 llRetVal = .T.
2094
2095 *--- TR 1027444 NH 10/09/07
2096 *!* Select inv_num, consol_num, c_consol_inv ;
2097 *!* FROM (pcWorkHeader) ;
2098 *!* WHERE !Errs_Flg_H= "Y" ;
2099 *!* INTO Cursor _HDRPkey
2100 This.LogEntry("Creating list of invoices that will be flagged as 810 factor processed.")
2101 Create Cursor _HDRPkey (inv_num I,consol_num I,c_consol_inv c(1))
2102 Local loHDR, lcMsg, lcOinCrMissing,lcOinCrAllMissing
2103 lcMsg = ""
2104 lcOinCrAllMissing = Sys(2015)
2105 lcOinCrMissing = Sys(2015)
2106 Select customer, division From (pceoincr) Where 1=2 Into Cursor _tempCursor
2107 This.MakeCursorWritable("_tempCursor",lcOinCrAllMissing)
2108 Select(pcWorkHeader)
2109 Scan
2110 Scatter Name loHDR
2111 If Seek(loHDR.customer+loHDR.division,pceoincr,'custDiv')
2112 Select(pceoincr)
2113 Scatter Name loeoincr
2114 *--- 1030155 NH
2115 IF loHdr.consol_num > 0
2116 Insert Into _HDRPkey (inv_num,consol_num, c_consol_inv) Values (loHDR.inv_num,loHDR.consol_num,loeoincr.consol_inv)
2117 ELSE
2118 Insert Into _HDRPkey (inv_num,consol_num, c_consol_inv) Values (loHDR.inv_num,loHDR.consol_num,'')
2119 ENDIF
2120 *=== 1030155 NH
2121 ELSE
2122 *--- 1030155 NH
2123 IF loHdr.consol_num > 0
2124 Insert Into _HDRPkey (inv_num,consol_num, c_consol_inv) Values (loHDR.inv_num,loHDR.consol_num,'Y')
2125 ELSE
2126 Insert Into _HDRPkey (inv_num,consol_num, c_consol_inv) Values (loHDR.inv_num,loHDR.consol_num,'')
2127 ENDIF
2128 *=== 1030155 NH
2129 Insert Into (lcOinCrAllMissing) (customer, division) Values (loHDR.customer,loHDR.division)
2130 Endif
2131 Endscan
2132 If Reccount(lcOinCrAllMissing) > 0
2133 Select Distinct customer, division From (lcOinCrAllMissing) Order By customer, division Into Cursor (lcOinCrMissing)
2134 Select(lcOinCrMissing)
2135 Scan
2136 lcMsg = lcMsg + "customer " + customer + " and division " + division + CRLF
2137 Endscan
2138 This.LogEntry("810 control record not found for following customer and division - ")
2139 This.LogEntry(lcMsg)
2140 Endif
2141 *=== TR 1027444 NH
2142
2143 With This
2144 .cSQLTempTable=""
2145 *--- TR 1014356 12/12/05 NH : check if _HDRPkey has any records before populate.
2146 If Reccount("_HDRPkey") > 0
2147 llRetVal = llRetVal And .GenerateSQLTempTable('_HDRPkey')
2148 llRetVal = llRetVal And .PopulateSQLTempTable('_HDRPkey')
2149 Endif
2150 .cSQLHDRTempTable = .cSQLTempTable
2151 Endwith
2152 If !llRetVal
2153 This.oLog.LogEntry(Program() + " failed.")
2154 Endif
2155 Return llRetVal
2156 Endproc
2157 *-------------------------------------------------------------------------------------------------------
2158 *=== TR 1011539 NH
2159
2160 *---TR 1016180 19-Jun-2006 Goutam
2161 *-------------------------------------------------------------------------------------------------------
2162 Procedure OrderTotalDetailDiscountToFactor
2163
2164 Lparameters tnOrd_num, tnPick_num, tnInv_num, tcOrd_status, tcCurr_conv, tcRate_srce, tc810WorkHeader
2165
2166 Local l_nOldSele, lcSQLString , lnTotalDetailDiscount, lcOrderHeaderAlias, lnDisc, ;
2167 lcCurr_Code, lnCurr_Rate
2168
2169 lnTotalDetailDiscount = 0
2170
2171 If !Empty(tnOrd_num)
2172 l_nOldSele = Select()
2173 tcOrd_status = Iif(Empty(tcOrd_status), "", tcOrd_status)
2174 tnPick_num = Iif(Empty(tnPick_num), 0, tnPick_num)
2175 tnInv_num = Iif(Empty(tnInv_num), 0, tnInv_num)
2176
2177 lcCurr_Code = ""
2178 lnCurr_Rate = 0
2179 lnTotalDetailDiscount = 0
2180 lcOrderHeaderAlias = Iif(tcOrd_status="I", "zzoshprh ", "zzoordrh ")
2181
2182 * get fields needed for calculation from order order detail lines
2183 lcSQLString = "SELECT Curr_code, Payee_Curr, Payee_Rate, " + ;
2184 " Div_Curr, Div_Rate, Co_Curr, Co_Rate, org_curr, " + ;
2185 " org_Rate " + ;
2186 " FROM " + lcOrderHeaderAlias + ;
2187 " WHERE ord_num = " + Str(tnOrd_num) + ;
2188 " And pick_num = " + Str(tnPick_num) + ;
2189 " And inv_num = " + Str(tnInv_num) + ;
2190 " And Ord_status = '" + tcOrd_status + "'"
2191
2192 llRetVal = v_SQLExec(lcSQLString , "TmpDisc")
2193
2194 If llRetVal
2195
2196 Do Case
2197 Case tcCurr_conv = 'Y' And tcRate_srce = 'P'
2198 lcCurr_Code = TmpDisc.Payee_Curr
2199 lnCurr_Rate = TmpDisc.Payee_Rate
2200 Case tcCurr_conv = 'Y' And tcRate_srce = 'D'
2201 lcCurr_Code = TmpDisc.Div_Curr
2202 lnCurr_Rate = TmpDisc.Div_Rate
2203 Case tcCurr_conv = 'Y' And tcRate_srce = 'C'
2204 lcCurr_Code = TmpDisc.Co_Curr
2205 lnCurr_Rate = TmpDisc.Co_Rate
2206 Case tcCurr_conv = 'Y' And tcRate_srce = 'O'
2207 lcCurr_Code = TmpDisc.Org_Curr
2208 lnCurr_Rate = TmpDisc.Org_Rate
2209 Endcase
2210 Endif
2211
2212 Replace Curr_Code With lcCurr_Code, CurrConv_Rate With lnCurr_Rate In (tc810WorkHeader)
2213
2214 If lnCurr_Rate > 0
2215 Update (This.cWorkDetail) Set ;
2216 Price = Round((Price * lnCurr_Rate), 2) ;
2217 WHERE ord_num = tnOrd_num ;
2218 AND pick_num = tnPick_num ;
2219 AND inv_num = tnInv_num ;
2220 And line_status = tcOrd_status
2221 Endif
2222
2223 Select * From (This.cWorkDetail) ;
2224 WHERE ord_num = tnOrd_num ;
2225 AND pick_num = tnPick_num ;
2226 AND inv_num = tnInv_num ;
2227 And line_status = tcOrd_status ;
2228 INTO Cursor _TmpDisc
2229
2230 If llRetVal
2231 Select _TmpDisc
2232 SCAN
2233 *--- TechRec 1099906 17-Nov-2016 MPerel --- round to 4 for eliminate rounding problem working with long decimals (see also TR 1087483)
2234 *--- TR 1088673 13-Sep-2015 Goutam
2235 *lnTotalDetailDiscount = lnTotalDetailDiscount + v_discamt(_TmpDisc.discount,'disc_perc',_TmpDisc.Total_qty,_TmpDisc.Price)
2236 lnTotalDetailDiscount = lnTotalDetailDiscount + ROUND(v_discamt(_TmpDisc.discount,'disc_perc',_TmpDisc.Total_qty,_TmpDisc.Price), 4)
2237 *=== TR 1088673 13-Sep-2015 Goutam
2238 Endscan
2239 Endif
2240 Use In TmpDisc
2241 Use In _TmpDisc
2242 Select (l_nOldSele)
2243 Endif
2244 Return lnTotalDetailDiscount
2245 Endproc
2246 *-------------------------------------------------------------------------------------------------------------------
2247
2248 Procedure OrderNetExtendedToFactor
2249 * ATS 1932 bug in OrderNet/GrosExt when have multi Picks/Invcs per Order
2250 * ATS 3591 New A New Parameter for new order header Bros that return
2251 * Open Amount, Invoice Amount, Picked Amount And Canceled Amount
2252 Lparameters tnOrd_num, tnPick_num, tnInv_num, tcOrd_status, llWithHeaderDiscount, ;
2253 tcCheckStatus, tcExcludeDetailDiscount, tcCurr_conv, tcRate_srce, tc810WorkHeader
2254
2255 Local l_nOldSele, lcSQLString , lnDetailNetExtended, lnOrderNetAmount, lnOrderNetExtended, lcFrgt_excl
2256 lnOrderNetAmount = 0
2257 lnOrderNetExtended = 0
2258
2259 lcFrgt_excl = ''
2260
2261 * prepare all work table names
2262 lcTempSourceDetail = "__TranD"
2263 * lcTempSourceHeader = "__TranH"
2264
2265 If !Empty(tnOrd_num)
2266 l_nOldSele = Select()
2267 tcOrd_status = Iif(Empty(tcOrd_status), "", tcOrd_status)
2268 tnPick_num = Iif(Empty(tnPick_num), 0, tnPick_num)
2269 tnInv_num = Iif(Empty(tnInv_num), 0, tnInv_num)
2270 tcCheckStatus = Iif(Empty(tcCheckStatus),"",tcCheckStatus)
2271
2272 Local lcOrderDetailAlias, lcOrderHeaderAlias, lcCurrRate
2273
2274 lcOrderDetailAlias = This.cWorkDetail
2275 lcOrderHeaderAlias = This.cWorkHeader
2276
2277 lcCurrRate = Str(SysGetFieldValue(tc810WorkHeader, "CurrConv_Rate"),10,2)
2278
2279 Select * From (This.cWorkDetail) ;
2280 WHERE ord_num = tnOrd_num ;
2281 AND pick_num = tnPick_num ;
2282 AND inv_num = tnInv_num ;
2283 And line_status = tcOrd_status ;
2284 INTO Cursor (lcTempSourceDetail)
2285
2286 * Got order detail lines
2287 * accumulate net order Extended
2288 Select (lcTempSourceDetail)
2289 Scan
2290 If tcExcludeDetailDiscount
2291 lnDetailNetExtended = DetailGrossExtended(lcTempSourceDetail, Price, Total_qty)
2292 Else
2293 lnDetailNetExtended = DetailNetExtended() && includes discount
2294 ENDIF
2295
2296 *--- TechRec 1099906 17-Nov-2016 MPerel --- round to 4 for eliminate rounding problem working with long decimals (see also TR 1087483)
2297 *--- TR 1088673 12-Sep-2015 Goutam
2298 lnOrderNetExtended = ROUND(lnOrderNetExtended, 4)
2299 *=== TR 1088673 12-Sep-2015 Goutam
2300
2301 lnOrderNetExtended= lnOrderNetExtended +lnDetailNetExtended
2302 Endscan
2303
2304 Select (tc810WorkHeader)
2305 lcFrgt_excl=vl_custr(customer,'frgt_excl')
2306
2307 If SysGetFieldValue(tc810WorkHeader, "CurrConv_Rate") > 0
2308 Replace disc_amt With Round((disc_amt * CurrConv_Rate), 2), ;
2309 insu_amt With Round((insu_amt * CurrConv_Rate), 2), ;
2310 misc_amt With Round((misc_amt * CurrConv_Rate), 2), ;
2311 tax_amt With Round((tax_amt * CurrConv_Rate), 2), ;
2312 Frgt_Amt With Round((Frgt_Amt * CurrConv_Rate), 2) ;
2313 IN (tc810WorkHeader)
2314 Endif
2315
2316 * return net order amount or Sum(net detail extended)
2317 If lcFrgt_excl = 'Y'
2318 lnOrderNetAmount = lnOrderNetExtended + Iif(llWithHeaderDiscount, ;
2319 ( disc_amt * -1 + insu_amt + misc_amt + tax_amt), 0)
2320 Else
2321 lnOrderNetAmount = lnOrderNetExtended + Iif(llWithHeaderDiscount, ;
2322 ( disc_amt * -1 + Frgt_Amt + insu_amt + misc_amt + tax_amt), 0)
2323 Endif
2324
2325 * Cleanup
2326 If Used(lcTempSourceDetail)
2327 Use In (lcTempSourceDetail)
2328 Endif
2329
2330 Select (l_nOldSele)
2331 Endif
2332 * same line with open amounts because we do not store the canl_num in the details.
2333 If (tcOrd_status = "C" And tcCheckStatus = "O") Or ;
2334 (tcOrd_status = "O" And tcCheckStatus = "C")
2335 lnOrderNetAmount=0
2336 Endif
2337
2338 Return lnOrderNetAmount
2339
2340 Endproc
2341
2342 *------------------------------------------------------------------------------------------------------------
2343 Procedure OrderGrossExtendedToFactor
2344
2345 * ATS 1932 bug in OrderNet/GrosExt when have multi Picks/Invcs per Order
2346 * ATS 3796 Add new parameter cncl_type to extract either house or Customer Cancel
2347 Lparameters tnOrd_num, tnPick_num, tnInv_num, tcOrd_status, tnPkey, tcCncl_type, tcCurr_conv, tcRate_srce
2348
2349 Local l_nOldSele, lcSQLString , lnGrossOrderExtended, lcPkeyStr, lcOrderDetailAlias, lcCancStr
2350 If !Empty(tnOrd_num)
2351 l_nOldSele = Select()
2352 tcOrd_status= Iif(Empty(tcOrd_status), "", tcOrd_status)
2353 tnPick_num= Iif(Empty(tnPick_num), 0, tnPick_num)
2354 tnInv_num= Iif(Empty(tnInv_num), 0, tnInv_num)
2355
2356 lcPkeyStr = Iif(Empty(tnPkey), "", " And fkey= " + Str(tnPkey))
2357 lcCancStr = Iif(!Empty(tcCncl_type), " AND cncl_type='" + tcCncl_type +"'","")
2358
2359 lcOrderDetailAlias = This.cWorkDetail
2360
2361 * get fields needed for calculation from order detail lines
2362
2363 *--- TechRec 1099906 17-Nov-2016 MPerel --- round to 4 for eliminate rounding problem working with long decimals (see also TR 1087483)
2364 *--- TR 1088673 12-Sep-2015 Goutam. added round to calculate price
2365 Select Sum(ROUND(Price * Total_qty, 4)) As 'gross_ext' From (This.cWorkDetail) ;
2366 WHERE ord_num = tnOrd_num ;
2367 AND pick_num = tnPick_num ;
2368 AND inv_num = tnInv_num ;
2369 And line_status = tcOrd_status + lcPkeyStr + lcCancStr ;
2370 INTO Cursor __GrsOrd
2371
2372 * Got order gross extended
2373
2374 lnGrossOrderExtended = Nvl(__GrsOrd.gross_ext,0)
2375
2376 * Cleanup
2377 If Used("__GrsOrd")
2378 Use In __GrsOrd
2379 Endif
2380 Select (l_nOldSele)
2381 Endif
2382 Return lnGrossOrderExtended
2383
2384 Endproc
2385 *-----------------------------------------------------------------------------------------------------------
2386 *---TR 1016180 19-Jun-2006 Goutam
2387
2388 *---TR 1036975 NOV-14-08 TEJAS : Message in case of TableUpdate Error
2389 ************************************************************************************
2390 PROCEDURE UpdateMessageError
2391 LOCAL llRetVal, lcErrs_Msg, llUpdate
2392 WITH THIS
2393 llRetVal= .T.
2394 .nTransaction= .CountTotalRecs(.cTranHeader)
2395 .nInterface= .CountTotalRecs(.cInterHeader)
2396 .nHistory= .CountTotalRecs(.cHistHeader)
2397 .cMessage= IIF(!Empty(.cMessage), .cMessage + CRLF, "")
2398 lcmsg1= "810F Outbound Process Failed!!" + CRLF + CRLF
2399 lcmsg2= IIF(.nInvoices>0, ALLT(STR(.nInvoices)) + " Invoice(s) Found." + CRLF,"")
2400 lcmsg3= " 0 Invoice(s) moved to Interface table." + CRLF
2401 lcmsg4= " 0 Invoice(s) moved from Interface table to Flatfile." + CRLF
2402 .cMessage= .cMessage + (lcmsg1 + lcmsg2+ lcmsg3 + lcmsg4)
2403 ENDWITH
2404 RETURN llRetVal
2405 ENDPROC
2406 *===TR 1036975 NOV-14-08 TEJAS : Message in case of Error
2407
2408*============================================================
2409 *--- TR 1094625 1-Apr-2016 Goutam
2410 FUNCTION ChangeQtyfieldTypeInViews
2411
2412 LOCAL llRetVal, lnSelect, lcTransHeader, lcTransDetail, cInterHeader, lcInterDetail, lcHistHeader, lcHistDetail
2413
2414 SET ASSERTS ON
2415 ASSERT .f.
2416 llRetVal = true
2417 lnSelect = SELECT()
2418
2419 WITH This
2420 lcTransHeader = .cTranHeader
2421 lcTransDetail = .cTranDetail
2422 lcInterHeader = .cInterHeader
2423 lcInterDetail = .cInterDetail
2424 lcHistHeader = .cHistHeader
2425 lcHistDetail = .cHistDEtail
2426
2427 llRetVal = llRetVal And DBSETPROP("&lcTransHeader..ord_qty", "FIELD", "DataType", "I")
2428 llRetVal = llRetVal And DBSETPROP("&lcTransDetail..total_qty", "FIELD", "DataType", "I")
2429 llRetVal = llRetVal And DBSETPROP("&lcTransDetail..cancelqty", "FIELD", "DataType", "I")
2430 llRetVal = llRetVal And DBSETPROP("&lcTransDetail..openpickqty", "FIELD", "DataType", "I")
2431 llRetVal = llRetVal And DBSETPROP("&lcTransDetail..invoiceqty", "FIELD", "DataType", "I")
2432
2433 llRetVal = llRetVal And DBSETPROP("&lcInterHeader..ord_qty", "FIELD", "DataType", "I")
2434 llRetVal = llRetVal And DBSETPROP("&lcInterDetail..total_qty", "FIELD", "DataType", "I")
2435 llRetVal = llRetVal And DBSETPROP("&lcInterDetail..cancelqty", "FIELD", "DataType", "I")
2436 llRetVal = llRetVal And DBSETPROP("&lcInterDetail..openpickqty", "FIELD", "DataType", "I")
2437 llRetVal = llRetVal And DBSETPROP("&lcInterDetail..invoiceqty", "FIELD", "DataType", "I")
2438
2439 llRetVal = llRetVal And DBSETPROP("&lcHistHeader..ord_qty", "FIELD", "DataType", "I")
2440 llRetVal = llRetVal And DBSETPROP("&lcHistDetail..total_qty", "FIELD", "DataType", "I")
2441 llRetVal = llRetVal And DBSETPROP("&lcHistDetail..cancelqty", "FIELD", "DataType", "I")
2442 llRetVal = llRetVal And DBSETPROP("&lcHistDetail..openpickqty", "FIELD", "DataType", "I")
2443 llRetVal = llRetVal And DBSETPROP("&lcHistDetail..invoiceqty", "FIELD", "DataType", "I")
2444 ENDWITH
2445
2446
2447 SELECT (lnSelect)
2448 RETURN llRetVal
2449 ENDFUNC
2450
2451*============================================================
2452 FUNCTION SuppressZeroFromQty
2453 LPARAMETERS tcoifmwH, tcoifmwD
2454 LOCAL llRetVal, lnSelect
2455
2456 llRetVal = true
2457 lnSelect = SELECT()
2458
2459 WITH This
2460
2461 REPLACE ALL ord_qty WITH STRTRAN(ALLTRIM(STRTRAN(TRANSFORM(ord_qty),"0"," "))," ","0") IN (tcoifmwH)
2462 REPLACE ALL ord_qty WITH left(ALLTRIM(ord_qty), LEN(ALLTRIM(ord_qty)) - 1) FOR INT(VAL(ord_qty)) = VAL(ord_qty) IN (tcoifmwH)
2463 REPLACE ALL ord_qty WITH "0" FOR EMPTY(ord_qty) IN (tcoifmwH)
2464 REPLACE ALL ord_qty WITH PADC(ALLTRIM(ord_qty),LEN(ord_qty), " ") IN (tcoifmwH)
2465
2466 REPLACE ALL total_qty WITH STRTRAN(ALLTRIM(STRTRAN(TRANSFORM(total_qty),"0"," "))," ","0") IN (tcoifmwD)
2467 REPLACE ALL total_qty WITH left(ALLTRIM(total_qty), LEN(ALLTRIM(total_qty)) - 1) FOR INT(VAL(total_qty)) = VAL(total_qty) IN (tcoifmwD)
2468 REPLACE ALL total_qty WITH "0" FOR EMPTY(total_qty) IN (tcoifmwD)
2469 REPLACE ALL total_qty WITH PADC(ALLTRIM(total_qty),LEN(total_qty), " ") IN (tcoifmwD)
2470
2471 REPLACE ALL openpickqty WITH STRTRAN(ALLTRIM(STRTRAN(TRANSFORM(openpickqty),"0"," "))," ","0") IN (tcoifmwD)
2472 REPLACE ALL openpickqty WITH left(ALLTRIM(openpickqty), LEN(ALLTRIM(openpickqty)) - 1) FOR INT(VAL(openpickqty)) = VAL(openpickqty) IN (tcoifmwD)
2473 REPLACE ALL openpickqty WITH "0" FOR EMPTY(openpickqty) IN (tcoifmwD)
2474 REPLACE ALL openpickqty WITH PADC(ALLTRIM(openpickqty),LEN(openpickqty), " ") IN (tcoifmwD)
2475
2476 REPLACE ALL cancelqty WITH STRTRAN(ALLTRIM(STRTRAN(TRANSFORM(cancelqty),"0"," "))," ","0") IN (tcoifmwD)
2477 REPLACE ALL cancelqty WITH left(ALLTRIM(cancelqty), LEN(ALLTRIM(cancelqty)) - 1) FOR INT(VAL(cancelqty)) = VAL(cancelqty) IN (tcoifmwD)
2478 REPLACE ALL cancelqty WITH "0" FOR EMPTY(cancelqty) IN (tcoifmwD)
2479 REPLACE ALL cancelqty WITH PADC(ALLTRIM(cancelqty),LEN(cancelqty), " ") IN (tcoifmwD)
2480
2481 REPLACE ALL Invoiceqty WITH STRTRAN(ALLTRIM(STRTRAN(TRANSFORM(Invoiceqty),"0"," "))," ","0") IN (tcoifmwD)
2482 REPLACE ALL Invoiceqty WITH left(ALLTRIM(Invoiceqty), LEN(ALLTRIM(Invoiceqty)) - 1) FOR INT(VAL(Invoiceqty)) = VAL(Invoiceqty) IN (tcoifmwD)
2483 REPLACE ALL Invoiceqty WITH "0" FOR EMPTY(Invoiceqty) IN (tcoifmwD)
2484 REPLACE ALL Invoiceqty WITH PADC(ALLTRIM(Invoiceqty),LEN(Invoiceqty), " ") IN (tcoifmwD)
2485 ENDWITH
2486
2487 SELECT (lnSelect)
2488 RETURN llRetVal
2489 ENDFUNC
2490
2491 *=== TR 1094625 1-Apr-2016 Goutam
2492
2493ENDDEFINE