· 9 years ago · Dec 20, 2016, 04:48 PM
1**********************************************************************************
2* Program....: clsoowpr.PRG
3* Author.....: Phu Luong, Mark Gestmann
4* Date.......: 08/01/01
5* Abstract...: 940(o) process Process Business Object Class
6* (OOW) - Warehouse shipping order
7* Get pick orders into transactions layer apply all validation base on flags from
8* Control Ref and create flatfile.
9* Notes: Only interface to single warehouse (--one 940(o) control ref)
10*****************************************************************************************
11#INCLUDE System.h
12#Include EDI.h
13
14*--- TR 1017241 11-JUL-2006 Goutam
15#Define SET_RANGE_TYPE "S"
16#Define RUN_RANGE_TYPE "R"
17*=== TR 1017241 11-JUL-2006 Goutam
18
19Define Class BPOoowProcess As BPOEDIBase
20 Name = "BPOoowProcess"
21 lErrorState = .F.
22 lUserInterface= .F.
23 cSQLFilterString= ""
24
25 nPickOrders= 0
26 nTranHeader= 0
27 nTranDetail= 0
28 nTranComment= 0
29 nTranAddress= 0
30 nInterHeader= 0
31 nInterDetail= 0
32 nInterComment= 0
33 nInterAddress= 0
34
35
36 *--- TR 1016915 - BD - 05/11/06 - Replace views with SQL pass-thru
37 *cPickHeader = "Vzzoordrh_proc"
38 *cPickDetail = "Vzzoordrd_proc"
39 *cPickComment= "Vzzoordcd_proc"
40 cPickHeader = "tcCurPickHeader"
41 cPickDetail = "tcCurPickDetail"
42 cPickComment = "tcCurcPickComment"
43 *=== TR 1016915 - BD - 05/11/06
44
45 cTranHeader = "Vzzeoowth_proc"
46 cTranDetail = "Vzzeoowtd_proc"
47 cTranComment= "Vzzeoowtc_proc"
48 cTranAddress= "Vzzeoowta_proc"
49 cInterHeader = "Vzzeoowih_proc"
50 cInterDetail = "Vzzeoowid_proc"
51 cInterComment= "Vzzeoowic_proc"
52 cInterAddress= "Vzzeoowia_proc"
53 cWorkHeader = "tceoowth"
54 cWorkDetail = "tceoowtd"
55 cWorkComment= "tceoowtc"
56 cWorkAddress= "tceoowta"
57 cWorkCarton = "tcoctnph"
58
59 *--- TechRec 1052941 14-Mar-2011 MANI. ---
60 cWorkWhsHdr = "tceooWhshdr"
61 cWorkWhsDtl = "tceooWhsdtl"
62 *=== TechRec 1052941 14-Mar-2011 MANI. ===
63
64 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ---
65*!* cControlReference= "zzeoowcr"
66 cControlReference= "zzeoowcr_expl"
67 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
68
69 cType ="" &&1009127 22-FEB-05 KA
70
71 lHaveSLN = .F. && 1011923 10/06/05 YIK
72
73 *--- TR 1014084 NH
74 Tie_setup = .F.
75 *=== TR 1014084 NH
76
77 *--- TR 1022506 - NH
78 lSQLPassThrough940 = .f.
79 cFlgOrdFor940Proc = ""
80 *=== TR 1022506 - NH
81
82 *--- TR 1040807 NSD 6/26/09
83 DIMENSION aViews[1,3]
84 *=== TR 1040807 NSD 6/26/09
85
86 *--- TR 1041685 NSD 8/11/09
87 cRollingTempTable = ""
88 *=== TR 1041685 NSD 8/11/09
89
90 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ---
91 cLocationGroupJoinString = ""
92 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
93
94
95 *- 1058729 FH
96 Dimension aBulkTables[1] && array to hold name of temp files
97 nCounter = 0 && counter for our array
98 *- 1058729 FH
99
100 *--- TR 1066790 18-Feb-2013 Partha ---
101 cWorkChrgHdr = "tceooChrgHdr"
102 cWorkChrgDtl = "tceooChrgDtl"
103 *=== TR 1066790 18-Feb-2013 Partha ===
104
105 *--- TR 1072649 8-8-2013 VKK
106 lBillTypeOrder = false
107 *=== TR 1072649 8-8-2013 VKK
108
109 cWhseSLN = "tcWhseSLN" && TR 1073471 KISHORE 19-SEP-2013
110
111 lSkipRangeConsolidation = false && TR 1078965 06-01-2014 RKI
112
113 ************************************************************************************
114 * Init
115 ************************************************************************************
116 Procedure Init
117 Lparameters plUserInterface
118 This.lUserInterface = plUserInterface
119 This.lScheduled= !plUserInterface
120 Local llRetVal
121
122 *--- TR 1014084 NH
123 *--- TechRec 1030445 16-May-2008 T.Shenbagavalli ---
124 *This.Tie_setup = (goEnv.sv("TIE_SETUP","N") = 'Y')
125 This.Tie_setup = IIF(((goEnv.sv("TIE_SETUP","N") = 'N') OR (goEnv.sv("BC_EDI_VERSION","") = "5.2")), .F.,.T.)
126
127 *=== TechRec 1030445 16-May-2008 T.Shenbagavalli ===
128 *=== TR 1017084 NH
129
130 *--- TR 1022506 NH
131 THIS.lSQLPassThrough940 = (goEnv.sv("940_PASSTHROUGH","N") = 'Y')
132 *=== TR 1022506 NH
133
134 *--- TR 1072649 8-8-2013 VKK
135 This.lBillTypeOrder = (goEnv.SV('RESOLVE_SPSBILL_CODE_FROM_SOH','N') = 'Y')
136 *=== TR 1072649 8-8-2013 VKK
137
138 *--- TR 1078965 06-01-2014 RKI ---*
139 This.lSkipRangeConsolidation = (goEnv.SV('940_SKIP_RANGE_CONSOLIDATION','N') = 'Y')
140 *=== TR 1078965 06-01-2014 RKI ===*
141
142 llRetVal= .T.
143 Return llRetVal
144 Endproc
145
146 ************************************************************************************
147 * Reset counters
148 ************************************************************************************
149 Procedure ResetCounter
150 With This
151 .nPickOrders= 0
152 .nHistory= 0
153 .nInterface= 0
154 .nTransaction= 0
155 .nTranHeader= 0
156 .nTranDetail= 0
157 .nTranComment= 0
158 .nTranAddress= 0
159 .nInterHeader= 0
160 .nInterDetail= 0
161 .nInterComment= 0
162 .nInterAddress= 0
163 Endwith
164 Endproc
165
166 ************************************************************************************
167 *
168 ************************************************************************************
169 Procedure UpdateMessage
170 Local llRetVal, lcErrs_Msg, llUpdate
171 With This
172 llRetVal= .T.
173 *- 41192 7/23/03 YIK
174 *- too late - everything is deleted. Do it in MoveRecords..
175 *!* Select (.cTranHeader)
176 *!* Count to .nTransaction for Errs_flg_H= 'Y'
177 *=
178 *.nTransaction= Recc(.cTranHeader)
179 * TAN 31891 - JAZ - 5/20/02
180 * .nInterface= Recc(.cInterHeader)
181 * .nHistory= Recc(.cInterHeader)
182 *- 41192 7/23/03 YIK
183 *- too late - everything is deleted. Do it in MoveRecords..
184 *- .nInterface= this.CountTotalRecs (.cInterHeader)
185 *- .nHistory= this.CountTotalRecs (.cInterHeader)
186 *=
187 * End TAN 31891 - JAZ - 5/20/02
188 .cMessage= Iif(!Empty(.cMessage), .cMessage + CRLF, "")
189 lcmsg1= Iif(.nPickOrders>0, ;
190 ALLT(Str(.nPickOrders)) + " Pick(s) Found." + CRLF, "")
191 lcmsg2= Iif(.nTransaction> 0, ;
192 ALLT(Str(.nTransaction)) + " Pick(s) have Errors." + CRLF ,"")
193 lcmsg3= Iif(.nInterface>0, ;
194 ALLT(Str(.nInterface)) + " Picks(s) successfully processed and moved to Interface table." + CRLF ,"")
195 lcmsg4= Iif(.nHistory>0, ;
196 ALLT(Str(.nHistory)) + " Pick(s) moved from Interface table to Flatfile." + CRLF,"")
197 .cMessage= .cMessage + (lcmsg1 + lcmsg2+ lcmsg3 + lcmsg4)
198 *- 1043754 11/12/09 YIK
199 .oLog.LogEntry(.cMessage)
200
201 Endwith
202 Return llRetVal
203 Endproc
204
205
206 ************************************************************************************
207 * 940(o) process
208 ************************************************************************************
209 Procedure OOWProcess
210 Parameters tcSQLFilterString
211 Local llRetVal
212 llRetVal = .T.
213
214 With This
215 .cSQLFilterString = Iif(Empty(tcSQLFilterString), "", " AND " + tcSQLFilterString)
216
217 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ---
218 IF "WHS_GRP" $ UPPER(.cSQLFilterString)
219 .cLocationGroupJoinString = " LEFT JOIN zzxwhsgd gd " + ;
220 " ON gd.location = h.location "
221 ELSE
222 .cLocationGroupJoinString = ''
223 ENDIF
224 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
225
226 *-llRetval= llRetval and .LockProcess("EDI940PROCESS")
227 lcSyslockTablePath = Addbs(goEnv.envLoginTablePath.Value)
228 llRetVal= .T. && 1024203 need to remove this later.. llRetVal And v_SysLock( lcSyslockTablePath+"SYSLOCK", "EDIOOWPROCESS", goEnv.EnvLogin.cCompany)
229 *--- TR 10122506 - NH
230 THIS.cFlgOrdFor940Proc = ""
231 *=== TR 10122506 - NH
232 *- 1013765 10/24/05 YIK
233 *- THIS.lProcessLocked means that someone else has it locked.
234 *- THIS.lProcessLocked = llRetVal
235 This.lProcessLocked = !llRetVal
236
237 If llRetVal = .F.
238 Return .F.
239 Endif
240
241 .lNoDataFound = .F.
242
243 .CreateFormProgressBar(.lScheduled)
244 .InitProgressBarTotal(12, "Total warehouse shipping order process")
245 Private vcLogName
246 vcLogName= lcSyslockTablePath+ "940.log"
247 .oLog.OpenLog("EDIOOWPROCESS", I("EDIOOWPROCESS"), .lScheduled)
248 .oLog.LogProgram("clsoowpr.prg")
249 .oLog.LogEntry("Filter Criteria: " + tcSQLFilterString)
250
251 *--- TR 1065007 14-Feb-2014 Goutam
252 .GetFromUOM()
253 .cWeightFieldForUOM = "weight"
254 .cVolumeFieldForUOM = "ord_volume"
255 *=== TR 1065007 14-Feb-2014 Goutam
256
257 llHavePickOrderToProcess= .RetrievePickOrders()
258 .AdvanceThermoTotal(1)
259
260 If Not llHavePickOrderToProcess
261 .cMessage= 'There are no pick tickets to process.'
262 .lNoDataFound = .T.
263 Else
264 llRetVal= llRetVal And .CreateTempViews()
265 .AdvanceThermoTotal(1)
266
267 *--- TR 1040807 NSD 6/26/09
268 * For pass-through, we are wiping it out before the query of transaction
269 IF .lSQLPassThrough940
270 llRetVal= llRetVal And .DeletePreviousTransaction()
271 .AdvanceThermoTotal(1)
272 ENDIF
273 *=== TR 1040807 NSD 6/26/09
274
275 llRetVal= llRetVal And .OpenTempViews()
276 .AdvanceThermoTotal(1)
277
278 *--- TR 1040807 NSD 6/26/09
279 * For backward compatibility
280 IF NOT .lSQLPassThrough940
281 llRetVal= llRetVal And .DeletePreviousTransaction()
282 .AdvanceThermoTotal(1)
283 ENDIF
284 *=== TR 1040807 NSD 6/26/09
285
286 llRetVal= llRetVal And .CreateTransactionVertical()
287 .AdvanceThermoTotal(1)
288
289 llRetVal= llRetVal And .ValidateTransaction()
290 .AdvanceThermoTotal(1)
291 llRetVal= llRetVal And .PopulateValidTransaction()
292 .AdvanceThermoTotal(1)
293
294 llRetVal= llRetVal And .FlagProcessOrders(.cWorkHeader, .cPickHeader)
295 .AdvanceThermoTotal(1)
296
297 llRetVal= llRetVal And .MoveRecordsToTransactionOrInterface()
298 .AdvanceThermoTotal(1)
299
300 llRetVal= llRetVal And .UnLoadInterfaceToFlatFile()
301 .AdvanceThermoTotal(1)
302
303 *--- TR 1022506 NH
304 IF NOT llRetVal
305 *--- clear 940 flag for order failed on flat file creation.
306 THIS.FlagProcessOrders(THIS.cWorkHeader,,.t.)
307 ENDIF
308 this.LogMajorStage("Update all work tables.")
309 *=== TR 1022506 NH
310
311
312 llRetVal= llRetVal And .TableupdateAllViews()
313 .AdvanceThermoTotal(1)
314
315 llRetVal= llRetVal And .UpdateMessage()
316 Endif
317
318 *- 06/21/04 1005887 YIK
319 *!* llRetval= llRetval And .ResetCounter()
320 *!* llRetval= llRetval And .CloseAllViews()
321 *!* llRetval= llRetval and .UnlockProcess("EDI940PROCESS")
322
323 *- 1058729 FH
324 .BulkDelete()
325 *- 1058729 FH
326
327 .ResetCounter()
328 .CloseAllViews()
329 *- 1013765 10/19/05 YIK
330 .oLog.LogResult(llRetVal)
331 .oLog.CloseLog()
332 *=
333 *--- TR 1026620 NH
334 *.UnlockProcess("EDI940PROCESS")
335 .UnlockProcess("EDIOOWPROCESS")
336 *=== TR 1026620 NH
337 *= YIK
338 .ResetFrmProgressBar()
339
340 Endwith
341 Return llRetVal
342 Endproc
343
344 ************************************************************************************
345 * Retrieve pick header, detail and comment for active 940(o) control ref
346 * Notes: ONLY interface to Single 3rd. party warehouse; 940(o) control referece
347 * have only SINGLE RECORD (--does not allow adding more than one).
348 * CARTESIAN JOIN to zzeoowcr is ok since we just have one control record
349 *- 1002240 01/02/04 YIK - allow multiple locations/warehouses.
350 ************************************************************************************
351 Procedure RetrievePickOrders
352 Local llRetVal, lnOldSelect, lcSQLSelectString, lcCallString, lcSizeString, lcNrfSizeString
353 *--- TechRec 1058522 04-Jan-2012 TShenbagavalli added , lcFieldList,lcSizeQtyString---
354 Local lcTmpLocRef, lcFieldList, lcSizeQtyString
355
356 *--- TR 1030786 15-Feb-2008 Goutam. Added following Local
357 LOCAL lcSQLSubFilterString
358
359 *--- TR 1066790 13-Feb-2013 Partha ---
360 LOCAL lcImagePickDetail
361 lcImagePickDetail = "#tmp" + GetUniqueFilename()
362 *=== TR 1066790 13-Feb-2013 Partha ===
363
364 *--- TR 1072649 8-8-2013 VKK
365 LOCAL lcBillOptString, lcBillOptJoin
366 STORE "" TO lcBillOptString, lcBillOptJoin
367 *=== TR 1072649 8-8-2013 VKK
368
369 llRetVal = .T.
370 lnOldSelect = Select()
371 With This
372 .InitThermo(1)
373 .UpdateThermoCaption('Retrieving pick order(s)...')
374
375 *-- all pick headers for matching criteria
376 * Join with shipper,
377 * CARTESIAN JOIN to zzeoowcr
378 *- 41192 7/23/03 YIK
379 *- Add check for new flag proc_940
380 lcSQLOrder = " h.pick_num "
381 *- 1002240 01/02/04 YIK - allow multiple locations/warehouses.
382 .oLog.LogEntry("Retrieving picked orders")
383
384 *--- TechRec 1058522 04-Jan-2012 TShenbagavalli ---
385 lcFieldList = .GetCommonFieldList("h.", "zzoordrh", "zzeoowth")
386 *=== TechRec 1058522 04-Jan-2012 TShenbagavalli ===
387
388 *- 1007750 12/20/04 YIK
389 *- added c.duns_req
390 *--- TR 1009127 02/25/05 KA
391 *Changed zzeoowcr to lcTmpLocRef to avoid duplicate header records.
392 *!* lcSQLSelect = "SELECT h.*, s.ship_name as s_ship_name, s.scac_code as s_scac_code, " +;
393 *!* "s.edishptype as s_trans_type, c.sku_upc, c.chk_shp, c.chk_wgt, c.chk_vol, c.chk_asn, c.duns_req " +;
394 *!* "FROM zzoordrh h LEFT OUTER JOIN zzxshipr s ON h.shipper= s.shipper " +;
395 *!* " JOIN zzeoowcr c ON h.location = c.ware_code And c.active_ok = 'Y' " + ;
396 *!* "Where h.ord_status= 'P' And h.proc_940 <> 'P' "
397
398 *--- TR 1016915 - BD - 05/11/06 - Replace view with SQL pass-thru - Add " order by "+ lcSQLOrder in SQL statement
399
400 *--- TR 1022913 15-Mar-2007 Partha ---
401 * added bill_optn from zzxshipr and handled null in from shipper fields
402
403*!* lcSQLSelect = "SELECT h.*, s.ship_name as s_ship_name, s.scac_code as s_scac_code, " +;
404*!* "s.edishptype as s_trans_type " +;
405*!* "FROM zzoordrh h WITH (NOLOCK) LEFT OUTER JOIN zzxshipr s WITH (NOLOCK) ON h.shipper= s.shipper " +;
406*!* " Where EXISTS(select ware_code from zzeoowcr WITH (NOLOCK) WHERE ware_code = h.location And active_ok = 'Y' ) " +;
407*!* " AND h.ord_status= 'P' And h.proc_940 <> 'P' " +;
408*!* .cSQLFilterString + " order by "+ lcSQLOrder
409
410 *--- 1025526 2-AUG-07 KISHOR (Added field cust_type and left join to zzxcustr)
411 *--- TR 1035520 NH - added column - cust_name
412 *--- TechRec 1048648 14-Sep-2010 jisingh Added column udfcus1c ===
413 * TR 1052815 21-MAR-2011 KISHORE - Added - ,COALESCE(cust.sps_acct,'') AS sps_acct
414 &&--- TechRec 1054554 10-Jun-2011 TShenbagavalli " ,COALESCE(cust.dba,'') AS customer_dba " ===
415 *--- TechRec 1058522 04-Jan-2012 TShenbagavalli removed h.* and added lcFieldList ---
416 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === Changed zzeoowcr to zzeoowcr_expl and added .cLocationGroupJoinString
417*!* lcSQLSelect = "SELECT " + lcFieldList + ;
418*!* " ,ISNULL(s.ship_name, '') as s_ship_name, ISNULL(s.scac_code, '') as s_scac_code, " + ;
419*!* " ISNULL(s.edishptype, '') as s_trans_type, ISNULL(s.bill_optn, '') as bill_optn, cust.cust_type " + ;
420*!* " ,coalesce(cust.cust_name,'') as cust_name, coalesce(cust.udfcus1c,'') as udfcus1c " + ;
421*!* " ,COALESCE(cust.dba,'') AS customer_dba " + ;
422*!* " ,COALESCE(cust.sps_acct,'') AS sps_acct " + IIF ( !EMPTY(.cLocationGroupJoinString),",coalesce(gd.whs_grp,'') as whs_grp ","")+ ;
423*!* "FROM zzoordrh h WITH (NOLOCK) LEFT OUTER JOIN zzxshipr s WITH (NOLOCK) ON h.shipper= s.shipper " + ;
424*!* "LEFT JOIN zzxcustr cust WITH (NOLOCK) " + ;
425*!* " ON cust.customer = h.customer " + ;
426*!* " Where EXISTS(select ware_code from zzeoowcr WITH (NOLOCK) WHERE ware_code = h.location And active_ok = 'Y' ) " + ;
427*!* " AND h.ord_status= 'P' And h.proc_940 <> 'P' " + ;
428*!* .cSQLFilterString + " order by "+ lcSQLOrder
429
430
431 *--- TR 1072649 8-8-2013 VKK
432 STORE "" TO lcBillOptString, lcBillOptJoin
433 IF .lBillTypeOrder
434 TEXT TO lcBillOptJoin TEXTMERGE NOSHOW PRETEXT 3
435 left join zzxstorr st WITH (Nolock)
436 On st.customer = h.customer
437 And st.store = h.store
438 ENDTEXT
439
440 lcBillOptString = " h.bill_optn as s_bill_optn, "
441 ELSE
442 TEXT TO lcBillOptJoin TEXTMERGE NOSHOW PRETEXT 3
443 left join zzxstorr st WITH (Nolock)
444 On st.customer = h.customer
445 And st.store = h.store
446
447 LEFT join zzxcslsr csls1
448 on csls1.customer = h.customer
449 and csls1.division = h.Division
450 and csls1.store = h.store
451 and csls1.department = h.department
452 and csls1.org_code = ''
453 and csls1.ord_type = ''
454 left join zzxcslsr csls2
455 on csls2.customer = h.customer
456 and csls2.division = h.Division
457 and csls2.store = h.store
458 and csls2.department = ''
459 and csls2.ord_type = ''
460 and csls2.org_code = ''
461 and csls1.pkey is NULL
462 left join zzxcslsr csls3
463 on csls3.customer = h.customer
464 and csls3.division = h.Division
465 and csls3.store = ''
466 and csls3.department = h.department
467 and csls3.ord_type = ''
468 and csls3.org_code = ''
469 and csls1.pkey IS NULL
470 and csls2.pkey IS NULL
471 left join zzxcslsr csls4
472 on csls4.customer = h.customer
473 and csls4.division = h.Division
474 and csls4.store = ''
475 and csls4.department = ''
476 and csls4.ord_type = ''
477 and csls4.org_code = ''
478 and csls1.pkey IS NULL
479 and csls2.pkey IS NULL
480 and csls3.pkey IS NULL
481 left join zzxcslsr csls5
482 on csls5.customer = h.customer
483 and csls5.division = ''
484 and csls5.store = h.store
485 and csls5.department = h.department
486 and csls5.ord_type = ''
487 and csls5.org_code = ''
488 and csls1.pkey IS NULL
489 and csls2.pkey IS NULL
490 and csls3.pkey IS NULL
491 and csls4.pkey IS NULL
492 left join zzxcslsr csls6
493 on csls6.customer = h.customer
494 and csls6.division = ''
495 and csls6.store = h.store
496 and csls6.department = ''
497 and csls6.ord_type = ''
498 and csls6.org_code = ''
499 and csls1.pkey IS NULL
500 and csls2.pkey IS NULL
501 and csls3.pkey IS NULL
502 and csls4.pkey IS NULL
503 and csls5.pkey IS NULL
504 left join zzxcslsr csls7
505 on csls7.customer = h.customer
506 and csls7.division = ''
507 and csls7.store = ''
508 and csls7.department = h.department
509 and csls7.ord_type = ''
510 and csls7.org_code = ''
511 and csls1.pkey IS NULL
512 and csls2.pkey IS NULL
513 and csls3.pkey IS NULL
514 and csls4.pkey IS NULL
515 and csls5.pkey IS NULL
516 and csls6.pkey IS NULL
517 left join zzxcslsr csls8
518 on csls8.customer = h.customer
519 and csls8.division = ''
520 and csls8.store = ''
521 and csls8.department = ''
522 and csls8.ord_type = ''
523 and csls8.org_code = ''
524 and csls1.pkey IS NULL
525 and csls2.pkey IS NULL
526 and csls3.pkey IS NULL
527 and csls4.pkey IS NULL
528 and csls5.pkey IS NULL
529 and csls6.pkey IS NULL
530 and csls7.pkey IS NULL
531 Endtext
532
533 TEXT TO lcBillOptString TEXTMERGE NOSHOW PRETEXT 3
534 CASE WHEN COALESCE(s.bill_optn,'') <> '' THEN s.bill_optn
535 WHEN COALESCE(csls1.Bill_optn,'') <> '' then csls1.Bill_optn
536 WHEN COALESCE(csls2.Bill_optn,'') <> '' then csls2.Bill_optn
537 WHEN COALESCE(csls3.Bill_optn,'') <> '' then csls3.Bill_optn
538 WHEN COALESCE(csls4.Bill_optn,'') <> '' then csls4.Bill_optn
539 WHEN COALESCE(csls5.Bill_optn,'') <> '' then csls5.Bill_optn
540 WHEN COALESCE(csls6.Bill_optn,'') <> '' then csls6.Bill_optn
541 WHEN COALESCE(csls7.Bill_optn,'') <> '' then csls7.Bill_optn
542 WHEN COALESCE(csls8.Bill_optn,'') <> '' then csls8.Bill_optn
543 WHEN COALESCE(st.bill_optn,'') <> '' THEN st.bill_optn
544 WHEN COALESCE(cust.bill_optn, '') <> '' THEN cust.bill_optn
545 ELSE '' END as s_bill_optn,
546
547 ENDTEXT
548
549 ENDIF
550 *=== TR 1072649 8-8-2013 VKK
551
552 *--- TR 1066381 KISHORE 19-FEB-2013 - Added populate_country
553 *--- TR 1072649 8-8-2013 VKK Replaced Billtopn claculation with lcBillOptstring & added lcBillOptJoin
554 *-FH 1086001 - taking out " ,ctr.whs_grp,ctr.populate_country " , remove join to zzeoowcr_expl, replace with Where EXISTS
555 *- join was giving duplicate records.
556
557 lcSQLSelect = "SELECT " + lcFieldList + ;
558 " ,ISNULL(s.ship_name, '') as s_ship_name, ISNULL(s.scac_code, '') as s_scac_code, " + ;
559 " ISNULL(s.edishptype, '') as s_trans_type, " + lcBillOptString + " cust.cust_type " + ; && TR 1059018 FH - changed bill_optn to s_bill_optn
560 " ,coalesce(cust.cust_name,'') as cust_name, coalesce(cust.udfcus1c,'') as udfcus1c " + ;
561 " ,COALESCE(cust.dba,'') AS customer_dba " + ;
562 " ,COALESCE(cust.langcode,'') AS langcode " + ;&&--- TechRec 1085802 31-Mar-2015 TSV===
563 " ,COALESCE(cust.invc_form,'') AS invc_form " + ;&&--- TechRec 1085802 31-Mar-2015 TSV===
564 " ,COALESCE(case when COALESCE(st.sps_acct,'') = '' then null else st.sps_acct end, cust.sps_acct,'') AS sps_acct " +; && *--- TR 1072649 8-8-2013 VKK modified sps logic
565 " , '' as populate_country " + ; && TR 1086001 FH
566 "FROM zzoordrh h WITH (NOLOCK) LEFT OUTER JOIN zzxshipr s WITH (NOLOCK) ON h.shipper= s.shipper " + ;
567 "LEFT JOIN zzxcustr cust WITH (NOLOCK) " + ;
568 " ON cust.customer = h.customer " + ;
569 .cLocationGroupJoinString + ;
570 lcBillOptJoin + ; && *--- TR 1072649 8-8-2013 VKK
571 " Where EXISTS(select ware_code from zzeoowcr_expl zeoowcr WITH (NOLOCK) WHERE ware_code = h.location And active_ok = 'Y' ) " + ;
572 " AND h.ord_status= 'P' And h.proc_940 <> 'P' " + ;
573 .cSQLFilterString + " order by "+ lcSQLOrder
574
575 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
576 *=== 1025526 2-AUG-07 KISHOR
577
578 *=== TR 1022913 15-Mar-2007 Partha ===
579
580 *=== TR 1016915 - BD - 05/11/06
581
582 *--- TR 1016915 - BD - 05/11/06 - Replace view with SQL pass-thru
583 *llRetVal= llRetVal And This.CreateSQLView( .cPickHeader, lcSQLSelect,, lcSQLOrder)
584 llRetVal=llRetVal And (v_SQLPrep(lcSQLSelect,.cPickHeader) or USED(.cPickHeader)) && TR 1017244 - BD - 05/24/06
585 *=== TR 1016915 - BD - 05/11/06
586 *--- TR 1022506 NH
587 IF llRetVal
588 this.logEntry("Pick header count # " + STR(RECCOUNT(.cPickHeader)))
589
590 *-TR 1059018 FH - replace empty bill_optn with s_bill_optn
591 SELECT (.cPickHeader)
592 Replace ALL bill_optn WITH s_bill_optn && *--- TR 1072649 8-8-2013 VKK removed emptyu conditon. replace alwsys
593 *-TR 1059018 FH - replace empty bill_optn with s_bill_optn
594 ENDIF
595 *=== TR 1022506 NH
596 If !llRetVal
597 .oLog.LogEntry("Retrieve Order headers - failed")
598 Endif
599 .AdvanceThermo(.2)
600
601 *-- all pick details for matching criteria
602 * Join zzxstylr, zzxscolr, zzxcolrr,
603 * CARTESIAN JOIN to zzeoowcr
604 lcSize_descString = v_SelectSizes('sz.size', '')
605 lcNrfSizeString = v_SelectSizes('dm.nrf_sz','')
606 *- 1002240 01/02/04 YIK - allow multiple locations/warehouses.
607
608
609 *-TR 1058568 FH
610 *--- TechRec 1058522 04-Jan-2012 TShenbagavalli commented and moved above local variable decaration---
611 *LOCAL lcFieldList,lcSizeQtyString
612 *lcFieldList = .GetCommonFieldList("d.")
613 lcFieldList = .GetCommonFieldList("d.", "zzoordrd", "zzeoowtd")
614 *=== TechRec 1058522 04-Jan-2012 TShenbagavalli ===
615
616 lcSizeQtyString = v_SelectSizes("d.size")
617 lcFieldList = lcFieldList + "," + lcSizeQtyString
618 *-TR 1058568 FH
619
620 *- 1010483 04/13/05 YIK
621 *- Change "INNER JOIN zzeoowcr c ON h.location = c.ware_code And c.active_ok = 'Y' "
622 *- to " Where EXISTS(select ware_code from zzeoowcr WHERE ware_code = h.location And active_ok = 'Y' ) "
623 *- to avoid duplicated details
624 *--- 1025526 2-AUG-07 KISHOR (Added left join to zzxcustr)
625 *--- TechRec 1030445 28-Apr-2008 T.Shenbagavalli added sc.Giftboxsku ---
626 *- TR 1052385 FH - added And h.proc_940 <> 'P'
627 *-TR 1058568 FH - add lcFieldList took out d.*
628 &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === changed zzeoowcr to zzeoowcr_expl and added .cLocationGroupJoinString
629
630 *--- TR 1086823 26-May-2015 Partha ---
631 * Added join with zzeoowcr_expl directly instead of where clause
632
633*!* lcSQLSelect = "SELECT " + lcFieldList + ;
634*!* " , st.size_code st_size_code, st.style_name st_style_name,"+;
635*!* "st.udfsty1c st_udfsty1c, st.udfsty2c st_udfsty2c, " +;
636*!* "sc.gar_wgt sc_gar_wgt, sc.cubic sc_cubic, " +;
637*!* "sc.inr_qty sc_inr_qty, sc.mst_qty sc_mst_qty, sc.ret_price sc_ret_price,"+;
638*!* "sc.udfsco1c sc_udfsco1c, sc.udfsco2c st_udfsco2c, sc.Giftboxsku, " +; && Tr 1030445 sc.Giftboxsku added
639*!* "cl.color_name cl_color_name, cl.nrf_color cl_nrf_color, " +;
640*!* lcNrfSizeString + "," + ;
641*!* lcSize_descString + ;
642*!* ", h.swc_num " + ; && TR 1067861 26-Apr-2013 Goutam
643*!* ", d.pkey dtl_pkey " + ; && TR 1066790 12-Feb-2013 Partha
644*!* "INTO " + lcImagePickDetail + ; && TR 1066790 12-Feb-2013 Partha
645*!* " FROM zzoordrh h WITH (NOLOCK) INNER JOIN zzoordrd d WITH (NOLOCK) ON h.pkey= d.fkey " +;
646*!* "INNER JOIN zzxcolrr cl WITH (NOLOCK) ON d.color_code= cl.color_code "+;
647*!* "INNER JOIN zzxstylr st WITH (NOLOCK) ON d.division= st.division and d.style= st.style "+;
648*!* "INNER JOIN zzxscolr sc WITH (NOLOCK) ON d.division= sc.division and d.style= sc.style and "+;
649*!* "d.color_code= sc.color_code and d.lbl_code= sc.lbl_code and d.dimension= sc.dimension "+;
650*!* "INNER JOIN zzxsizer sz WITH (NOLOCK) " + ;
651*!* "ON st.division = sz.division AND st.size_code = sz.size_code " + ;
652*!* "LEFT OUTER JOIN zzxdimer dm WITH (NOLOCK) " + ;
653*!* "ON sz.pkey = dm.fkey AND d.dimension = dm.dimension " + ;
654*!* "LEFT JOIN zzxcustr cust WITH (NOLOCK) " + ;
655*!* " ON cust.customer = h.customer " + ;
656*!* .cLocationGroupJoinString + ;
657*!* " Where EXISTS(select ware_code from zzeoowcr_expl WITH (NOLOCK) WHERE ware_code = h.location And active_ok = 'Y' ) " +;
658*!* " and h.ord_status= 'P' And h.proc_940 <> 'P' " +;
659*!* .cSQLFilterString
660
661 lcSQLSelect = "SELECT " + lcFieldList + ;
662 " , st.size_code st_size_code, st.style_name st_style_name,"+;
663 "st.udfsty1c st_udfsty1c, st.udfsty2c st_udfsty2c, " +;
664 "sc.gar_wgt sc_gar_wgt, sc.cubic sc_cubic, " +;
665 "sc.inr_qty sc_inr_qty, sc.mst_qty sc_mst_qty, sc.ret_price sc_ret_price,"+;
666 "sc.udfsco1c sc_udfsco1c, sc.udfsco2c st_udfsco2c, sc.Giftboxsku, " +; && Tr 1030445 sc.Giftboxsku added
667 "cl.color_name cl_color_name, cl.nrf_color cl_nrf_color, " +;
668 lcNrfSizeString + "," + ;
669 lcSize_descString + ;
670 ", h.swc_num " + ;
671 ", d.pkey dtl_pkey " + ;
672 ", ctr.incl_chg " + ;
673 "INTO " + lcImagePickDetail + ;
674 " FROM zzoordrh h WITH (NOLOCK) INNER JOIN zzoordrd d WITH (NOLOCK) ON h.pkey= d.fkey " +;
675 "INNER JOIN zzeoowcr_expl ctr WITH (NOLOCK) ON ctr.ware_code = h.location And ctr.active_ok = 'Y' " + ;
676 "INNER JOIN zzxcolrr cl WITH (NOLOCK) ON d.color_code= cl.color_code "+;
677 "INNER JOIN zzxstylr st WITH (NOLOCK) ON d.division= st.division and d.style= st.style "+;
678 "INNER JOIN zzxscolr sc WITH (NOLOCK) ON d.division= sc.division and d.style= sc.style and "+;
679 "d.color_code= sc.color_code and d.lbl_code= sc.lbl_code and d.dimension= sc.dimension "+;
680 "INNER JOIN zzxsizer sz WITH (NOLOCK) " + ;
681 "ON st.division = sz.division AND st.size_code = sz.size_code " + ;
682 "LEFT OUTER JOIN zzxdimer dm WITH (NOLOCK) " + ;
683 "ON sz.pkey = dm.fkey AND d.dimension = dm.dimension " + ;
684 "LEFT JOIN zzxcustr cust WITH (NOLOCK) " + ;
685 " ON cust.customer = h.customer " + ;
686 .cLocationGroupJoinString + ;
687 " Where h.ord_status= 'P' And h.proc_940 <> 'P' " +;
688 .cSQLFilterString
689
690 *=== TR 1086823 26-May-2015 Partha ===
691
692 *=== 1025526 2-AUG-07 KISHOR (Added left join to zzxcustr)
693
694 *--- TR 1066790 12-Feb-2013 Partha ---
695 * create temp pick detail cursor
696
697 *--- TR 1070910 08-May-2013 Partha Changed Prep to Exec---
698*!* llRetVal=llRetVal And v_SQLPrep(lcSQLSelect)
699
700 llRetVal=llRetVal And v_SQLExec(lcSQLSelect)
701 *=== TR 1070910 08-May-2013 Partha ===
702
703 * create charge detail cursor from temp pick detail cursor
704 lcSQLSelect = "SELECT c.Fkey, p.pkey dtl_pkey, " + ;
705 "ROW_NUMBER() OVER(PARTITION BY c.Fkey order by c.Fkey) AS Chrg_line, " + ;
706 "c.chrg_type, c.Chrg_Flag, " + ;
707 "CASE WHEN chrg_flag = 'F' THEN c.chrg_amt / p.total_qty " + ;
708 "WHEN chrg_flag IN ('P','N') THEN c.trx_pct_amt / p.total_qty " + ; &&--- TechRec 1075078 09-Jan-2014 jisingh Added N ===
709 "ELSE c.chrg_amt END chrg_amt, " + ;
710 " p.style, p.color_code, p.lbl_code, p.dimension, " + ;
711 " SPACE(14) upc, " + ;
712 " SPACE(22) sku, " + ;
713 " SPACE(14) ean, " + ;
714 " SPACE(10) size_desc, " + ;
715 " 0 sizebucket " + ;
716 "FROM zzxchrds c " + ;
717 "JOIN " + lcImagePickDetail + " p " + ;
718 " ON c.fkey = p.dtl_pkey " + ;
719 " WHERE p.Incl_chg='Y' " && TR 1086823 26-May-2015 Partha
720 llRetVal=llRetVal And v_SQLExec(lcSQLSelect, .cWorkChrgDtl)
721 IF llRetVal
722 SELECT (.cWorkChrgDtl)
723 INDEX ON dtl_pkey TAG dtl_pkey
724 GOTO TOP
725 ENDIF
726
727 * create charge header cursor from temp pick detail cursor
728 lcSQLSelect = ;
729 "SELECT c.pkey,c.pick_num,c.ord_num," + ;
730 "c.chrg_type,c.chrg_value chrg_amt,c.chrg_flag,c.notes " + ;
731 "FROM zzxchrgs c " + ;
732 "JOIN zzxchrtr r " + ;
733 " ON c.chrg_type = r.chrg_type " + ;
734 " AND r.chrg_hdrdtl = 'H' " + ;
735 "JOIN " + lcImagePickDetail + " p " + ;
736 " ON c.ord_num = p.ord_num " + ;
737 " AND c.pick_num = p.pick_num " + ;
738 " AND c.inv_num = p.inv_num " + ;
739 "WHERE p.Incl_chg='Y' " && TR 1086823 26-May-2015 Partha
740 llRetVal=llRetVal And v_SQLExec(lcSQLSelect,.cWorkChrgHdr )
741
742 lcSQLSelect = "SELECT * FROM " + lcImagePickDetail
743 *=== TR 1066790 12-Feb-2013 Partha ===
744
745 *--- TR 1016915 - BD - 05/16/06 - Replace view with SQL pass-thru
746 *llRetVal= llRetVal And This.CreateSQLView( .cPickDetail, lcSQLSelect)
747 llRetVal=llRetVal And (v_SQLPrep(lcSQLSelect,.cPickDetail) or USED(.cPickDetail)) && TR 1017244 - BD - 05/24/06
748 *=== TR 1016915 - BD - 05/16/06
749 If !llRetVal
750 .oLog.LogEntry("Retrieve order details - failed")
751 Endif
752
753 *--- TR 1066790 12-Feb-2013 Partha ---
754 * remove temp pick detail cursor
755 IF llRetVal
756 lcSQLSelect = "DROP TABLE " + lcImagePickDetail
757 ENDIF
758 *=== TR 1066790 12-Feb-2013 Partha ===
759
760 .AdvanceThermo(.3)
761
762 *--- TR 1030786 15-Feb-2008 Goutam.
763 lcSQLSubFilterString = STRTRAN(.cSQLFilterString, "H.", "")
764 *=== TR 1030786 15-Feb-2008 Goutam.
765
766 *--- TR 1016915 - BD - 05/11/06 - Replace view with SQL pass-thru - Add " order by "+ lcSQLOrder in SQL statement
767 *-- all order comment for matching criteria
768 * CARTESIAN JOIN to zzeoowcr
769 *- 1002240 01/02/04 YIK - allow multiple locations/warehouses.
770 lcSQLOrder = " h.ord_num "
771 *--- 1025526 2-AUG-07 KISHOR (Added left join to zzxcustr)
772
773 *--- TR 1027339 20-Nov-2007 Goutam. added c.cmt_code CommentType and " and charindex(cd.cmt_code,c.cmt_code ) > 0 " + ;
774 in the following select statement.
775 *--- TR 102733930-NOV-2007 VKK and subyery to filter uniqu order/commetns
776
777 *--- TR 1058512 31-Jan-12 SK Filtering list of pick_num (using IN clause) instead of max(pick_num) in sub query,
778 * To retrive comments for all the pick of a same order.
779 *--- TR 1030786 15-Feb-2008 Goutam. added lcSQLSubFilterString in the following query
780 &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === Changed zzeoowcr to zzeoowcr_expl and added .cLocationGroupJoinString
781 lcSQLSelect = "SELECT cd.*, c.cmt_code CommentType, h.pick_num " +; && TR 1026620 NH - need to keep pick_num also to link comment with pick_num instead of ord_num
782 "FROM zzoordrh h WITH (NOLOCK) INNER JOIN zzoordcd cd WITH (NOLOCK) ON h.ord_num= cd.ord_num " +;
783 "INNER JOIN zzeoowcr_expl c WITH (NOLOCK) ON h.location = c.ware_code And c.active_ok = 'Y' " + ;
784 " LEFT JOIN zzxcustr cust WITH (NOLOCK) " + ;
785 " ON cust.customer = h.customer " + ;
786 .cLocationGroupJoinString + ;
787 "Where h.ord_status= 'P' And c.active_ok = 'Y' " + ;
788 " and charindex(cd.cmt_code,c.cmt_code ) > 0 " + ;
789 " And pick_num IN (SELECT pick_num From zzoordrh where ord_num = h.ord_num " + lcSQLSubFilterString + " ) " + ;
790 .cSQLFilterString + " order by "+ lcSQLOrder
791 *=== 1025526 2-AUG-07 KISHOR (Added left join to zzxcustr)
792 *=== TR 1016915
793 *=== TR 1058512 31-Jan-12 SK
794
795 *--- TR 1016915 - BD - 05/16/06 - Replace view with SQL pass-thru
796 *llRetVal= llRetVal And This.CreateSQLView( .cPickComment, lcSQLSelect,, lcSQLOrder)
797 llRetVal=llRetVal And (v_SQLPrep(lcSQLSelect,.cPickComment) or USED(.cPickComment)) && TR 1017244 - BD - 05/24/06
798 *=== TR 1016915 - BD - 05/16/06
799 If !llRetVal
800 .oLog.LogEntry("Retrieve comments - failed")
801 Endif
802
803 .AdvanceThermo(.4)
804
805 *--- TR 1016915 - BD - 05/11/06 - Replace view with SQL pass-thru - Remove code below
806 *--Open Pick header, detail, comment view with DATA
807 *llRetVal= llRetVal And .OpenTable(.cPickHeader,,.T.)
808 *If !llRetVal
809 * .oLog.LogEntry("Open pick headers - failed")
810 *Endif
811 *=== TR 1016915 - BD - 05/11/06
812
813 .AdvanceThermo(.5)
814 *--- TR 1016915 - BD - 05/16/06 - Replace view with SQL pass-thru - Remove code below
815 *llRetVal= llRetVal And .OpenTable(.cPickDetail,,.T.)
816 *If !llRetVal
817 * .oLog.LogEntry("Open pick details - failed")
818 *ENDIF
819 *=== TR 1016915 - BD - 05/11/06
820
821 .AdvanceThermo(.8)
822 *--- TR 1016915 - BD - 05/16/06 - Replace view with SQL pass-thru - Remove code below
823 *llRetVal= llRetVal And .OpenTable(.cPickComment,,.T.)
824 *If !llRetVal
825 * .oLog.LogEntry("Open pick comments - failed")
826 *ENDIF
827 *=== TR 1016915 - BD - 05/11/06
828
829 .AdvanceThermo(.9)
830 * TAN 31891 - JAZ - 5/20/02
831 * llRetVal= llRetVal And RECC(.cPickHeader)> 0
832 * If llRetVal
833 * .nPickOrders= RECC(.cPickHeader)
834 llRetVal= llRetVal And This.CountTotalRecs (.cPickHeader)> 0
835 If llRetVal
836 .nPickOrders= This.CountTotalRecs (.cPickHeader)
837
838 *--- TR 1040807 NSD 6/26/09
839 * Create indexes on non-buffered views
840 IF THIS.lSQLPassThrough940
841
842 Select (.cPickHeader)
843 Index On pkey Tag pkey
844 Index On division Tag division
845
846 Select (.cPickDetail)
847 Index On fkey Tag fkey
848
849 SELECT(.cPickComment)
850 INDEX ON pick_num TAG PICK_NUM
851
852 ELSE
853 * End TAN 31891 - JAZ - 5/20/02
854 Select (.cPickHeader)
855 CursorSetProp("BUFFERING", 3)
856 Index On pkey Tag pkey
857 *- 1014229 11/16/05 YIK
858 Index On division Tag division
859
860 CursorSetProp("BUFFERING", 5)
861 Select (.cPickDetail)
862 CursorSetProp("BUFFERING", 3)
863 Index On fkey Tag fkey
864 CursorSetProp("BUFFERING", 5)
865 *--- TR 1026620 NH 02/04/08
866 SELECT(.cPickComment)
867 CURSORSETPROP("BUFFERING", 3)
868 INDEX ON pick_num TAG PICK_NUM
869 CURSORSETPROP("BUFFERING", 5)
870 *=== TR 1026620
871 ENDIF
872 *=== TR 1040807 NSD 6/26/09
873
874 Endif
875 .AdvanceThermo(1)
876 Endwith
877 Select(lnOldSelect)
878 *--- TR 1017244 - BD - 05/24/06
879 *If !llRetVal
880 * .oLog.LogEntry("Retrieve pick orders - failed")
881 *Endif
882 If !llRetVal
883 IF This.CountTotalRecs (.cPickHeader)> 0
884 .oLog.LogEntry("Retrieve pick orders - failed")
885 ELSE
886 .oLog.LogEntry("Retrieve pick orders - No picks to process found")
887 ENDIF
888 Endif
889 *=== TR 1017244
890
891 Return llRetVal
892 Endproc
893
894 ************************************************************************************
895 * Create temp views
896 ************************************************************************************
897 Procedure CreateTempViews
898 Local llRetVal, lcSQLSelect, lcSQLOrder
899 llRetVal= .T.
900 With This
901 .InitThermo(1)
902 .UpdateThermoCaption('Creating temporary views...')
903 .oLog.LogEntry("Creating temporary views")
904
905 *--Transaction views
906 lcSQLSelect = "select * from zzeoowth"
907 llRetVal= llRetVal And .CreateSQLView(.cTranHeader, lcSQLSelect,, 'NoOrderBy')
908 lcSQLSelect = "select * from zzeoowtd"
909 llRetVal= llRetVal And .CreateSQLView(.cTranDetail, lcSQLSelect,, 'NoOrderBy')
910 lcSQLSelect = "select * from zzeoowtc"
911 llRetVal= llRetVal And .CreateSQLView(.cTranComment, lcSQLSelect,, 'NoOrderBy')
912 lcSQLSelect = "select * from zzeoowta"
913 llRetVal= llRetVal And .CreateSQLView(.cTranAddress, lcSQLSelect,, 'NoOrderBy')
914 .AdvanceThermo(.4)
915
916 *--Interface views
917 lcSQLSelect = "select *,' ' AS whse_type from zzeoowih"
918 llRetVal= llRetVal And .CreateSQLView(.cInterHeader, lcSQLSelect,, 'NoOrderBy')
919 lcSQLSelect = "select * from zzeoowid"
920 llRetVal= llRetVal And .CreateSQLView(.cInterDetail, lcSQLSelect,, 'NoOrderBy')
921 lcSQLSelect = "select * from zzeoowic"
922 llRetVal= llRetVal And .CreateSQLView(.cInterComment, lcSQLSelect,, 'NoOrderBy')
923 lcSQLSelect = "select * from zzeoowia"
924 llRetVal= llRetVal And .CreateSQLView(.cInterAddress, lcSQLSelect,, 'NoOrderBy')
925 .AdvanceThermo(.8)
926
927 *--get 940(o) control reference -- Only interface with single warehouse package
928 &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === Changed zzeoowcr to zzeoowcr_expl
929 lcSQLString = "SELECT * FROM zzeoowcr_expl"
930 llRetVal = llRetVal And v_SqlExec(lcSQLString, .cControlReference)
931
932 *--- TR 1040807 NSD 6/26/09 Removed buffering. No need for it
933 *---TR 1035377 AUG-20-2008 BR
934 SELECT (.cControlReference)
935 *CursorSetProp("BUFFERING", 3)
936
937 *--- TechRec 1085802 06-Apr-2015 TSV---
938 INDEX on ware_code TAG ware_code
939 *=== TechRec 1085802 06-Apr-2015 TSV===
940
941 INDEX on ware_code+type TAG WCodeType
942 *CursorSetProp("BUFFERING", 5)
943 *===TR 1035377 AUG-20-2008 BR
944 *=== TR 1040807 NSD 6/26/09 Removed buffering. No need for it
945
946 .AdvanceThermo(1)
947
948 Endwith
949 If !llRetVal
950 .oLog.LogEntry("Create temp views - failed")
951 Endif
952
953 Return llRetVal
954 Endproc
955
956 ************************************************************************************
957 * Open all views
958 ************************************************************************************
959 Procedure OpenTempViews
960 Parameters tcSQLFilterString
961 Local llRetVal, lcSQLSelect, lcSQLOrder
962 llRetVal = .T.
963 lnOldSelect = Select()
964
965 With This
966 .InitThermo(1)
967 .UpdateThermoCaption('Opening temporary views...')
968 .oLog.LogEntry("Opening temporary views")
969
970 lnCursorBuffer = DB_BUFOPTRECORD
971 .AdvanceThermo(.1)
972
973 *--Open all Transaction and Interface views with DATA
974 If !(This.OpenTable(.cTranHeader,,.T.) And ;
975 THIS.OpenTable(.cTranDetail,,.T.) And ;
976 THIS.OpenTable(.cTranComment,,.T.) And ;
977 THIS.OpenTable(.cTranAddress,,.T.) And ;
978 THIS.OpenTable(.cInterHeader,,.T.) And ;
979 THIS.OpenTable(.cInterDetail,,.T.) And ;
980 THIS.OpenTable(.cInterComment,,.T.) And ;
981 THIS.OpenTable(.cInterAddress,,.T.))
982 llRetVal= .F.
983 Else
984 .AdvanceThermo(.5)
985
986 *--- TR 1040807 NSD 6/26/09
987 * create indexes on non buffered cursors
988 IF THIS.lSQLPassThrough940
989
990 Select (.cTranHeader)
991 Index On pkey Tag pkey
992
993 Select (.cTranDetail)
994 Index On pkey Tag pkey
995 Index On fkey Tag fkey
996
997 ELSE
998 Select (.cTranHeader)
999 CursorSetProp("BUFFERING", 3)
1000 Index On pkey Tag pkey
1001 CursorSetProp("BUFFERING", 5)
1002 Select (.cTranDetail)
1003 CursorSetProp("BUFFERING", 3)
1004 Index On pkey Tag pkey
1005 Index On fkey Tag fkey
1006 CursorSetProp("BUFFERING", 5)
1007 ENDIF
1008 *=== TR 1040807 NSD 6/26/09
1009
1010 .AdvanceThermo(.7)
1011
1012 *--Creating address (Vertical format) writable cursor
1013 Select * From (.cTranAddress) Into Cursor tcTemp
1014 .MakeCursorWritable("tcTemp", .cWorkAddress)
1015 .Tableclose("tcTemp")
1016
1017 *--Creating comment writable cursor
1018 Select * From (.cTranComment) Into Cursor tcTemp
1019 .MakeCursorWritable("tcTemp", .cWorkComment)
1020 .Tableclose("tcTemp")
1021
1022 *--Creating carton header writable cursor
1023 lcSQLString = "SELECT * FROM zzoctnph where 0=1"
1024 llRetVal = llRetVal And v_SqlExec(lcSQLString, "tcTemp")
1025 If llRetVal
1026 .MakeCursorWritable("tcTemp", .cWorkCarton)
1027 Endif
1028 .Tableclose("tcTemp")
1029
1030 Endif
1031 .AdvanceThermo(1)
1032 Endwith
1033 Select(lnOldSelect)
1034 If !llRetVal
1035 .oLog.LogEntry("Opening temporary views - failed")
1036 Endif
1037
1038 Return llRetVal
1039 Endproc
1040
1041 ************************************************************************************
1042 * Truncate all previous trans on server that match criterias
1043 ************************************************************************************
1044 Procedure DeletePreviousTransaction
1045 Local llRetVal
1046 llRetVal= .T.
1047 With This
1048 .InitThermo(1)
1049 .UpdateThermoCaption("Deleting previous 940(o) transactions...")
1050 .oLog.LogEntry("Deleting previous 940 ")
1051
1052 *--- TR 1040807 NSD 6/26/09
1053 * Do a delete statement.
1054 IF THIS.lSQLPassThrough940
1055 llRetVal = llRetVal AND v_sqlexec("DELETE FROM zzeoowth")
1056 llRetVal = llRetVal AND v_sqlexec("DELETE FROM zzeoowtd")
1057 llRetVal = llRetVal AND v_sqlexec("DELETE FROM zzeoowtc")
1058 llRetVal = llRetVal AND v_sqlexec("DELETE FROM zzeoowta")
1059 ELSE
1060 Delete All In (.cTranHeader)
1061 Delete All In (.cTranDetail)
1062 Delete All In (.cTranComment)
1063 Delete All In (.cTranAddress)
1064 .AdvanceThermo(.5)
1065 Dime laTables[4]
1066 laTables[1]= .cTranHeader
1067 laTables[2]= .cTranDetail
1068 laTables[3]= .cTranComment
1069 laTables[4]= .cTranAddress
1070 llRetVal= This.TableUpdateWithTransaction(@laTables)
1071 ENDIF
1072 *=== TR 1040807 NSD 6/26/09
1073
1074 .AdvanceThermo(1)
1075 Endwith
1076 If !llRetVal
1077 .oLog.LogEntry("Deleting previous 940 - failed")
1078 Endif
1079
1080 Return llRetVal
1081 Endproc
1082
1083 ************************************************************************************
1084 *
1085 ************************************************************************************
1086 Procedure CreateTransactionVertical
1087 Local llRetVal
1088 llRetVal = .T.
1089 With This
1090 .oLog.LogEntry("Creating Vertical transaction")
1091
1092 llRetVal= llRetVal And .CreateWorkHeader()
1093 If !llRetVal
1094 .oLog.LogEntry("Creating Work Header - failed")
1095 Endif
1096
1097 *--- TR 1046782
1098 THIS.LogEntry("Caching Data")
1099 llRetVal = llRetVal AND .CacheData()
1100 *=== TR 1046782
1101
1102 llRetVal= llRetVal And .CreateWorkVerticalDetail()
1103 If !llRetVal
1104 .oLog.LogEntry("Creating Work Detail - failed")
1105 Endif
1106
1107 llRetVal= llRetVal And .SyncHeaderDetailPrimaryKey()
1108 If !llRetVal
1109 .oLog.LogEntry("Syncronizing Work Header and detail - failed")
1110 Endif
1111
1112 Endwith
1113 If !llRetVal
1114 .oLog.LogEntry("Creating Vertical Transaction - failed")
1115 Endif
1116
1117 Return llRetVal
1118 Endproc
1119
1120 ************************************************************************************
1121 *
1122 ************************************************************************************
1123 Procedure CreateWorkHeader
1124 Local llRetVal, lnOldSelect, lcSQLSelectString
1125 llRetVal = .T.
1126 lnOldSelect = Select()
1127 Local lnCurrentHeaderPkey, lnCnt, lnMax, lnLast, lnCur
1128 *- 1014229 11/16/05 YIK
1129 Local lcDivision, lcDivName, lcSQLDivsR && TR 1037080 DEC-30-2008 BR - ADDED: lcSQLDivsR
1130
1131 With This
1132 .InitThermo(1)
1133 .UpdateThermoCaption("Creating transaction header...")
1134 .oLog.LogEntry("Creating Work Header ")
1135
1136 *--Create empty work header same structure as transaction view
1137 * plus flags in 940 control ref
1138 Select * From (This.cTranHeader) Into Cursor tcTemp
1139 *- 1009127 02/22/05 YIK/KA
1140 *- Add whse_type to WorkHeader
1141 *create cursor tcTemp1 (sku_upc c(1), chk_shp c(1), chk_wgt c(1), chk_vol c(1), chk_asn c(1))
1142
1143 *--- TR 1010079 VSS/SHAN 22-Apr-2005
1144 *!* create cursor tcTemp1 (sku_upc c(1), chk_shp c(1), chk_wgt c(1), chk_vol c(1), chk_asn c(1), whse_type c(1) )
1145 *- 1011923 10/05/05 YIK
1146 *- added sln_req
1147 *--- TR 1066381 KISHORE 20-FEB-2013 - Added populate_country c(1) ===
1148 Create Cursor tcTemp1 (sku_upc c(1), chk_shp c(1), chk_wgt c(1), chk_vol c(1), chk_asn c(1), ;
1149 whse_type c(1), proc_856 c(1), sln_req c(1), populate_country c(1) )
1150 *=== TR 1010079 VSS/SHAN 22-Apr-2005
1151
1152 This.CreateCursorStructure( "tcTemp", "tcTemp1", .cWorkHeader)
1153 Select (.cWorkHeader)
1154 Index On pkey Tag pkey
1155 INDEX on bill_num TAG bill_num && TR 1040807 NSD 6/26/09
1156 Index On Str(ord_num)+Str(pick_num) Tag OrdPick
1157 *---TR 1009127 02/24/05 KA
1158 Index On location + whse_type Tag location
1159
1160 *---TR 1037080 DEC-30-2008 BR
1161 lcSQLDivsR = "SELECT * FROM zzxdivsr "
1162 v_SQLExec(lcSQLDivsR, "zzxdivsr_local")
1163 SELECT zzxdivsr_local
1164 INDEX on division TAG divR ADDITIVE
1165 *===TR 1037080 DEC-30-2008 BR
1166
1167 *--Creating transaction work header from pick header with batch assigning pkey
1168 Select (.cPickHeader)
1169 * TAN 31891 - JAZ - 5/20/02
1170 * lnMax= Recc(.cPickHeader)
1171 lnMax= This.CountTotalRecs (.cPickHeader)
1172 *- 1014229 11/16/05 YIK
1173 *- Populate division name
1174 Set Order To division
1175 *---TR 1037080 DEC-30-2008 BR
1176 *---Replacing vl call with indexseek in the where clause.
1177 *---zzxdivsr_local is a local copy of the entire division reference table, joining on this instead of
1178 *---the result of the vl call -tmpdivsr- will ensure that no matter how many divisions are included in the transaction
1179 *---division name will output for all headers not just the first
1180 *---since there is no scan here vl_divsr was only working with the first record in .cPickHeader
1181
1182 *If vl_divsr(Evaluate(This.cPickHeader + ".division"),,"tmpdivsr")
1183 *Select Distinct p.division, d.div_name ;
1184 FROM (.cPickHeader) p Join tmpdivsr d ;
1185 ON p.division = d.division ;
1186 INTO Cursor __tmpDiv
1187 Select Distinct p.division, d.div_name ;
1188 FROM (.cPickHeader) p Join zzxdivsr_local d ;
1189 ON p.division = d.division ;
1190 WHERE INDEXSEEK(p.division, .F., "zzxdivsr_local", "divR");
1191 INTO Cursor __tmpDiv
1192 Index On division Tag division
1193 *ENDIF
1194 *===TR 1037080 DEC-30-2008 BR
1195
1196 lcDivision = ' '
1197
1198 * End TAN 31891 - JAZ - 5/20/02
1199 lcPickHeader= .cPickHeader
1200 lnLast= v_NextPkey("ZZEOOWTH", lnMax)
1201 lnCnt= 0
1202 Select (.cPickHeader)
1203 Scan
1204 lnCnt = lnCnt + 1
1205 lnCur = (lnLast - lnMax) + lnCnt
1206 llRetVal= This.CreateRecordWithPkey(.cPickHeader, .cWorkHeader,,,,lnCur)
1207 If llRetVal
1208 *- 1014229 11/16/05 YIK
1209 If !(division == lcDivision)
1210 lcDivision = division
1211 lcDivName = Iif(Seek(lcDivision, "__tmpDiv", "division"), __tmpDiv.div_name, "")
1212 Endif
1213 *--Left Outer Join will zzxshipr could have null
1214 *- added div_name
1215
1216 *--- TR 1022913 15-Mar-2007 Partha ---
1217 * populated bill_optn, edishptype
1218
1219*!* REPLACE SCAC_code WITH NVL(&lcPickHeader..s_scac_code, ''),;
1220*!* ship_name WITH NVL(&lcPickHeader..s_ship_name, ''),;
1221*!* Trans_type With Nvl(&lcPickHeader..s_Trans_type, ''), ;
1222*!* div_name With lcDivName ;
1223*!* IN (.cWorkHeader)
1224
1225 *--- TR 1066381 KISHORE 20-FEB-2013 - Added populate_country ===
1226 Replace SCAC_code With Nvl(&lcPickHeader..s_scac_code, ''),;
1227 ship_name With Nvl(&lcPickHeader..s_ship_name, ''),;
1228 Trans_type With Nvl(&lcPickHeader..s_Trans_type, ''), ;
1229 div_name With lcDivName, ;
1230 bill_optn WITH Nvl(&lcPickHeader..bill_optn, ''), ;
1231 edishptype With Nvl(&lcPickHeader..s_Trans_type, ''), ;
1232 populate_country WITH NVL(&lcPickHeader..populate_country, '') ;
1233 IN (.cWorkHeader)
1234
1235 *=== TR 1022913 15-Mar-2007 Partha ===
1236
1237 *= 1014229
1238 Else
1239 *--Exit when have problem creating transaction work header
1240 Exit
1241 Endif
1242 .AdvanceThermo(lnCnt/lnMax)
1243 Endscan
1244
1245
1246 .TimeStampDocument(.cWorkHeader, " All ")
1247 .Tableclose("tcTemp")
1248 .Tableclose("tcTemp1")
1249 Endwith
1250 Select(lnOldSelect)
1251 Return llRetVal
1252 Endproc
1253
1254 ************************************************************************************
1255 *
1256 ************************************************************************************
1257 Procedure CreateWorkVerticalDetail
1258 Lparameters tcSource, tcTarget
1259 Local llRetVal, lnOldSelect, lcSQLSelectString
1260 llRetVal = .T.
1261 lnOldSelect = Select()
1262
1263 *--- TR 1048196 21-Jul-2010 Goutam
1264 LOCAL lnWorkDetailRecNo, lnTotalWorkDetail
1265 *=== TR 1048196 21-Jul-2010 Goutam
1266
1267 With This
1268 .InitThermo(1)
1269 .UpdateThermoCaption("Creating transaction detail...")
1270 .oLog.LogEntry("Creating Work Detail")
1271
1272
1273 *--Create transaction work detail writable from structure merge of
1274 * transaction detail and pick detail
1275 *- 1007750 12/21/04 YIK
1276 *- Getting too many columns when trying to create WorkDetail
1277 *- Retrieve only non-repeating fields.
1278 *-Select * From (.cTranDetail) Into Cursor tcTemp
1279 *--- TR 1010923 NH
1280 *!*
1281 *!* Select * From (.cPickDetail) Into Cursor tcTemp
1282 *!* select (.cPickDetail)
1283 *!* copy structure extended to __PickTemp
1284 *!* select (.cTranDetail)
1285 *!* copy structure extended to __TranTemp
1286 *!* select * from __TranTemp ;
1287 *!* where field_name not in ;
1288 *!* (select field_name from __PickTemp) ;
1289 *!* into ARRAY aTempStru
1290 *!*
1291 *!* Create CURSOR tcTemp1 FROM ARRAY aTempStru
1292
1293 *!* use in __TranTemp
1294 *!* use in __PickTemp
1295 *!* *= 1007750
1296 *!* This.CreateCursorStructure( "tcTemp", "tcTemp1" , .cWorkDetail)
1297
1298*-TR 1073384 FH - added slntodtl, and SLN01
1299 Select (.cPickDetail)
1300 lcString = v_SelectSizes("size", "")
1301 lcString = lcString + "," + v_SelectSizes("nrf_sz","")
1302 lcString = lcString + ",st_size_code, st_style_name, st_udfsty1c, st_udfsty2c, sc_gar_wgt, sc_cubic, sc_inr_qty," + ;
1303 "sc_mst_qty,sc_ret_price,sc_udfsco1c,st_udfsco2c,cl_color_name,cl_nrf_color" + ;
1304 " , '" + SPACE(1) + "' As slntodtl "+;
1305 " , '" + Space(10) + "' AS SLN01 "
1306
1307 *--- TR 1067861 26-Apr-2013 Goutam
1308 lcString = lcString + ",dtl_pkey" && TR 1066790 11-Feb-2013 Partha
1309 lcString = lcString + ",dtl_pkey,swc_num"
1310 *--- TR 1067861 26-Apr-2013 Goutam
1311
1312 *--- TechRec 1085802 01-Apr-2015 TSV---
1313 lcString = lcString + ", '" + SPACE(10) + "' As tr_size_desc,"+;
1314 " '" + Space(35) + "' AS tr_style_name," + ;
1315 " '" + Space(250) + "' AS tr_style_desc," + ;
1316 " 0 AS customs_price "
1317 *=== TechRec 1085802 02-Apr-2015 TSV===
1318
1319 lcSQL = "SELECT " + lcString + " FROM " + .cPickDetail + " WHERE 1 = 2"
1320 llRetVal = llRetVal And v_SqlExec(lcSQL,"tcTemp",,.T.)
1321 If llRetVal
1322 This.CreateCursorStructure( .cTranDetail, "tcTemp",.cWorkDetail)
1323 Endif
1324 *=== TR 1010923 NH
1325
1326 *--- TR 1040807 NSD 6/26/09
1327 * Cached discount data
1328 v_sqlexec("SELECT * FROM zzxdiscr","zzxdiscr_local")
1329 SELECT zzxdiscr_local
1330 INDEX ON discount TAG discount
1331
1332 IF .lSQLPassThrough940
1333 * This way is doing less scans of the cursors
1334 *--Creating vertical transaction detail from pick details
1335 llRetVal= llRetVal And .CreateCursorStructure(.cWorkDetail,,"tcVertDtl")
1336 llRetVal= llRetVal And .ExplodeDetailSizeToVertical(.cPickDetail, .cWorkDetail)
1337
1338 SELECT (.cWorkDetail)
1339
1340 *--- TR 1048196 21-Jul-2010 Goutam
1341 lnTotalWorkDetail = This.CountTotalRecs (.cWorkDetail)
1342 *=== TR 1048196 21-Jul-2010 Goutam
1343
1344 lnMax= This.CountTotalRecs ("tcVertDtl")
1345 * End TAN 31891 - JAZ - 5/20/02
1346 *- 41192 7/23/03 YIK
1347 *- lnLast= v_NextPkey("ZZEOIFTD", lnMax)
1348 lnLast= v_NextPkey("ZZEOOWTD", lnMax)
1349 lnCnt= 0
1350
1351 Scan
1352 lnCnt = lnCnt + 1
1353 lnCur = (lnLast - lnMax) + lnCnt && Detail pkey
1354
1355 lcNRFSizeDesc = Eval("nrf_sz" + Trans(sizebucket, "@L 99"))
1356 lcSizeDesc = Eval("size" + Trans(sizebucket, "@L 99"))
1357 lnSizeNetExt= DetailNetExtended(,price,total_qty,discount,,"zzxdiscr_local")
1358
1359 SELECT (.cWorkDetail)
1360 replace pkey WITH lnCur,;
1361 size_code With st_size_code,;
1362 style_name With st_style_name,;
1363 udfsty1c With st_udfsty1c,;
1364 udfsty2c With st_udfsty2c,;
1365 gar_wgt With sc_gar_wgt,;
1366 cubic With sc_cubic,;
1367 inr_qty With sc_inr_qty,;
1368 mst_qty With sc_mst_qty,;
1369 ret_price With sc_ret_price,;
1370 udfsco1c With sc_udfsco1c,;
1371 udfsco2c With st_udfsco2c,;
1372 color_name With cl_color_name,;
1373 nrf_color With cl_nrf_color,;
1374 size_desc With Nvl(lcSizeDesc, ''), ;
1375 nrf_size With Nvl(lcNRFSizeDesc, ''), ;
1376 SizNetExt With lnSizeNetExt,;
1377 net_price WITH lnSizeNetExt/total_qty, ; && TR 1066790 12-Feb-2013 Partha
1378 user_id WITH goenv.cUser,;
1379 last_mod WITH DATETIME()
1380
1381 *--- TR 1046782
1382 *--- TR 1048196 21-Jul-2010 Goutam. Added "(RECNO(.cWorkDetail) <= lnTotalWorkDetail) AND" in the following If condition
1383 If (RECNO(.cWorkDetail) <= lnTotalWorkDetail) AND .GetCartonNum_local(.cWorkDetail, "_TmpCtnNum")
1384 lcWorkDetail = .cWorkDetail
1385 lnCount = .CountTotalRecs("_TmpCtnNum")
1386
1387 *--- TR 1048196 21-Jul-2010 Goutam
1388 lnWorkDetailRecNo = IIF(EOF(.cWorkDetail), 0, RECNO(.cWorkDetail))
1389 *=== TR 1048196 21-Jul-2010 Goutam
1390
1391 If lnCount = 1 And &lcWorkDetail..total_qty = _TmpCtnNum.total_qty
1392 Replace carton_num With _TmpCtnNum.carton_num In (.cWorkDetail)
1393 Else && split
1394 .Split(.cWorkDetail, "_TmpCtnNum", lnCount)
1395 ENDIF
1396
1397 *--- TR 1048196 21-Jul-2010 Goutam
1398 IF lnWorkDetailRecNo <> 0
1399 GOTO lnWorkDetailRecNo IN (.cWorkDetail)
1400 ENDIF
1401 *=== TR 1048196 21-Jul-2010 Goutam
1402
1403 If Used("_TmpCtnNum")
1404 Use In _TmpCtnNum
1405 Endif
1406 Endif
1407 *=== TR 1046782
1408
1409 ENDSCAN
1410
1411 ELSE
1412
1413 *--Creating vertical transaction detail from pick details
1414 llRetVal= llRetVal And .CreateCursorStructure(.cWorkDetail,,"tcVertDtl")
1415 llRetVal= llRetVal And .ExplodeDetailSizeToVertical(.cPickDetail, "tcVertDtl")
1416 If llRetVal
1417 Select tcVertDtl
1418 * TAN 31891 - JAZ - 5/20/02
1419 * lnMax= Recc("tcVertDtl")
1420 lnMax= This.CountTotalRecs ("tcVertDtl")
1421 * End TAN 31891 - JAZ - 5/20/02
1422 *- 41192 7/23/03 YIK
1423 *- lnLast= v_NextPkey("ZZEOIFTD", lnMax)
1424 lnLast= v_NextPkey("ZZEOOWTD", lnMax)
1425 lnCnt= 0
1426 Scan
1427 lnCnt = lnCnt + 1
1428 lnCur = (lnLast - lnMax) + lnCnt && Detail pkey
1429 llRetVal= This.CreateRecordWithPkey("tcVertDtl", .cWorkDetail,,,,lnCur)
1430 If llRetVal
1431 *--Write to transaction detail infos from stylr, scolr, dimer
1432 * left outer join with dimer could have null (not true dimension it is
1433 * a prepack instead)
1434 lcNRFSizeDesc = Eval("nrf_sz" + Trans(sizebucket, "@L 99"))
1435 *- Added size_desc for cartoncheck
1436 lcSizeDesc = Eval("size" + Trans(sizebucket, "@L 99"))
1437
1438 *--- TR 1027339 20-Nov-2007 Goutam. Added Retail1 WITH tcVertDtl.Retail1 in following Replace statement.
1439 Replace size_code With st_size_code,;
1440 style_name With st_style_name,;
1441 udfsty1c With st_udfsty1c,;
1442 udfsty2c With st_udfsty2c,;
1443 gar_wgt With sc_gar_wgt,;
1444 cubic With sc_cubic,;
1445 inr_qty With sc_inr_qty,;
1446 mst_qty With sc_mst_qty,;
1447 ret_price With sc_ret_price,;
1448 udfsco1c With sc_udfsco1c,;
1449 udfsco2c With st_udfsco2c,;
1450 color_name With cl_color_name,;
1451 nrf_color With cl_nrf_color,;
1452 size_desc With Nvl(lcSizeDesc, ''), ;
1453 nrf_size With Nvl(lcNRFSizeDesc, ''), ;
1454 Retail1 WITH tcVertDtl.Retail1 ;
1455 IN (.cWorkDetail)
1456
1457 *--Calculate Detail Net Ext for each sizebucket
1458 lnSizeNetExt= DetailNetExtended()
1459 Replace SizNetExt With lnSizeNetExt In (.cWorkDetail)
1460 Replace net_price WITH lnSizeNetExt/total_qty In (.cWorkDetail) && TR 1066790 12-Feb-2013 Partha
1461 .TimeStampDocument(.cWorkDetail)
1462
1463 *--- TR 1016915 - BD - 05/19/06 - Remove following block of code as requested by Yuri (not in use anymore)
1464 *- 41192 7/22/03 YIK
1465 *If .GetCartonNum(.cWorkDetail, "_TmpCtnNum")
1466 * lcWorkDetail = .cWorkDetail
1467 * lnCount = .CountTotalRecs("_TmpCtnNum")
1468 * If lnCount = 1 And &lcWorkDetail..total_qty = _TmpCtnNum.total_qty
1469 * Replace carton_num With _TmpCtnNum.carton_num In (.cWorkDetail)
1470 * Else && split
1471 * .Split(.cWorkDetail, "_TmpCtnNum", lnCount)
1472 * Endif
1473 * If Used("_TmpCtnNum")
1474 * Use In _TmpCtnNum
1475 * Endif
1476 *Endif
1477 *=
1478 *=== TR 1016915
1479 Else
1480 *--Exit when have problem creating transaction work detail
1481 Exit
1482 Endif
1483 .AdvanceThermo(lnCnt/lnMax)
1484 ENDSCAN
1485 ENDIF
1486 ENDIF
1487
1488 *--Replace transaction validation sku_upc from 940(o) control ref (--Single record)
1489 * TAN 31891 - JAZ - 5/20/02
1490 * If llRetval and Recc(.cControlReference)>0
1491 If llRetVal And This.CountTotalRecs (.cControlReference)>0
1492 * End TAN 31891 - JAZ - 5/20/02
1493 lcControlReference= .cControlReference
1494 *- 1011923 10/05/05 YIK
1495 *- Add sln_req, change macro to EVAL
1496 Replace All sku_upc With Evaluate(lcControlReference + ".sku_upc"), ;
1497 sln_req With Evaluate(lcControlReference + ".sln_req"), ;
1498 errs_flg_D With "N" ; && PL 09/26/01 set to "N" and have no detail validation
1499 In (.cWorkDetail)
1500 Endif
1501
1502 * Moved this in tho the loop.
1503 *.TimeStampDocument(.cWorkDetail, " All ")
1504 .Tableclose("tcTemp")
1505 .Tableclose("tcTemp1")
1506 .Tableclose("tcVertDtl")
1507 Select (.cWorkDetail)
1508
1509 Index On pkey Tag pkey
1510 Index On fkey Tag fkey
1511 Index On sku Tag sku
1512 Index On Style+division Tag StyleDiv
1513 *- 1011923 10/05/05 YIK
1514 *- add indexes needed for prepack SLN explosion and
1515 *- Populate sln_req, sku_upc and SkipPpkUpc to details
1516 *- NO range style SLNs for the 940. Whse does not need the range style.
1517
1518 *--- TR 1017241 10-JUL-2006 Goutam. Removed comment from below line.
1519 Index on rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk)+ Str(pick_num)+line_status tag RangeSKU
1520
1521 Index On division+Style+color_code+lbl_code+Dimension+line_status Tag OurSKU
1522 *--- TR 1014085 NH
1523 Index On customer+division+Style+color_code+lbl_code+Dimension Tag CustSKU
1524 *=== TR 1014085 NH
1525
1526 USE IN SELECT("zzxdiscr_local")
1527 *=== TR 1040807 NSD 6/26/09
1528
1529 Endwith
1530
1531 Select(lnOldSelect)
1532 Return llRetVal
1533 Endproc
1534
1535 ***********************************************************************************
1536 * Sync all detail fkey with header pkey using ord_num,pick_num
1537 ***********************************************************************************
1538 Procedure SyncHeaderDetailPrimaryKey
1539 Local llRetVal, lnOldSelect, lcReplaceString, lnCurrentHeaderCkey, lnCurrentHeaderPkey
1540 llRetVal= .T.
1541 lnOldSelect= Select()
1542 With This
1543 .oLog.LogEntry("Syncronizing Work Header and Detail")
1544
1545 lcWorkHeader= .cWorkHeader
1546 lcWorkDetail= .cWorkDetail
1547 llRetVal= .SetRelation(lcWorkHeader, "OrdPick", lcWorkDetail, "Str(ord_num)+Str(pick_num)")
1548 If llRetVal
1549 Replace All fkey With &lcWorkHeader..pkey, ;
1550 customer With &lcWorkHeader..customer ;
1551 IN (lcWorkDetail)
1552 Set Relation To
1553 Endif
1554 Endwith
1555 Select(lnOldSelect)
1556 Return llRetVal
1557 Endproc
1558
1559
1560 ************************************************************************************
1561 * 1. Validate SKU/UPC
1562 * 2. Check for empty weight
1563 * 3. Check for empty volume
1564 * 4. Check for empty shipper
1565 * 5. Check for ASN carton
1566 * 6. set header error to "Y"es when one detail fail
1567 ************************************************************************************
1568 Procedure ValidateTransaction
1569 Local llRetVal, lnOldSelect
1570
1571 llRetVal = .T.
1572 lnOldSelect = Select()
1573 With This
1574 .InitThermo(1)
1575 .UpdateThermoCaption('Validating SKU/UPC, Weight, Volume, Shipper and ASN cartons...')
1576 .oLog.LogEntry("Validating Transaction")
1577
1578*!* *--- TR 1046782 Moved to earlier in process
1579*!* THIS.LogEntry("Caching Data")
1580*!* llRetVal = llRetVal AND .CacheData()
1581*!* *=== TR 1046782 Moved to earlier in process
1582
1583 *--- TR 1009127 22-FEB-05 KA
1584 * Check Type in the Control Reference
1585 llRetVal = .CheckTypeInControlRef()
1586 If !llRetVal
1587 .oLog.LogEntry("Checking Type in 940 Control Refrence - failed")
1588 Endif
1589
1590 llRetVal = llRetVal And .CheckTypeInDetail()
1591 If !llRetVal
1592 .oLog.LogEntry("Checking Type in Detail data - failed")
1593 Endif
1594
1595 llRetVal = llRetVal And .UpdateEDIControlFlags()
1596 If !llRetVal
1597 .oLog.LogEntry("Update EDI Control Flags - failed")
1598 Endif
1599 *=== TR 1009127 22-FEB-05 /KA
1600
1601 *--- TR 1067861 03/27/13 JIJO ===
1602 llRetVal= llRetVal And .ConsolidatePickTickets("tceoowth", "tceoowtd")
1603 *=== TR 1067861 03/27/13 JIJO ===
1604
1605 *--- TR 1017241 10-JUN-2006 Goutam, YIK
1606 IF NOT .lSkipRangeConsolidation && *--- TR 1078965 3-6-2014 VKK
1607 llRetVal= llRetVal And .ConsolidatePrepackByRangeSKU("tceoowth", "tceoowtd")
1608 .AdvanceThermoTotal(1)
1609 ENDIF && *--- TR 1078965 3-6-2014 VKK
1610 *=== TR 1017241 10-JUN-2006 Goutam, YIK
1611
1612 *--- TR 1039378 31-Mar-2009 Partha ---
1613 llRetVal= llRetVal And .RetrieveColor("tceoowth", "tceoowtd")
1614 *=== TR 1039378 31-Mar-2009 Partha ===
1615
1616 *--- TR 1065007 14-Feb-2014 Goutam
1617 llRetVal = llRetVal And .ValidateOutboundUOM("tceoowth", .cControlReference, "LOC")
1618 *=== TR 1065007 14-Feb-2014 Goutam
1619
1620 *- 1011923 10/05/05 YIK
1621 *-- Populate Prepack SLNs
1622 .oLog.LogEntry("Populating Prepack SLNs")
1623 llRetVal = llRetVal And .GetPrepackInfos("tceoowth", "tceoowtd", "tcSLN")
1624
1625 If Used("tcSLN") And This.CountTotalRecs ("tcSLN")> 0
1626 .AdvanceThermoTotalWithCaptionPlus("Validating PrePack components UPC/SKU...")
1627 .oLog.LogEntry("Validating PrePack components UPC/SKU...")
1628 llRetVal = llRetVal And .CheckSLNUPCSKU("tceoowth", "tceoowtd", "tcSLN", "tcCustSLN", "tcItemSLN")
1629 Endif
1630
1631 *- 1017241 07/25/06 YIK
1632 IF USED("tcRangeSLN") AND THIS.CountTotalRecs ("tcRangeSLN")> 0
1633 .AdvanceThermoTotalWithCaptionPlus("Validating Range Style components UPC/SKU...")
1634 llRetVal= llRetVal AND .CheckRangeSLNUPCSKU("tceoowth", "tceoowtd", "tcRangeSLN", "tcRItemSLN")
1635 llRetVal= llRetVal AND .MergeRangeSLNsToSLNs("tcRItemSLN", "tcItemSLN")
1636 ENDIF
1637 *=== 1017241
1638
1639 llRetVal= .CheckUPCSKU(.cWorkHeader, .cWorkDetail)
1640 If !llRetVal
1641 .oLog.LogEntry("Checking UPC and SKU - failed")
1642 Endif
1643
1644 *--- TR 1036614 10-Jun-2009 Goutam
1645 IF llRetVal AND USED("tcItemSLN")
1646 llRetVal = .GetPOHistSLN("tceoowth", "tceoowtd", "tcItemSLN")
1647 IF !llRetVal
1648 .oLog.LogEntry("Checking Item SLN- failed")
1649 ENDIF
1650 ENDIF
1651 *=== TR 1036614 10-Jun-2009 Goutam
1652
1653 .AdvanceThermo(.55)
1654
1655 lcErrs_Msg= "Missing Order Weight."
1656 Replace All Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" ;
1657 IN (.cWorkHeader) For Empty(weight) And chk_wgt = 'Y'
1658 .AdvanceThermo(.65)
1659
1660 lcErrs_Msg= "Missing Order Volume."
1661 Replace All Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" ;
1662 IN (.cWorkHeader) For Empty(ord_volume) And chk_vol = 'Y'
1663 .AdvanceThermo(.75)
1664
1665 lcErrs_Msg= "Missing Shipper."
1666 Replace All Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" ;
1667 IN (.cWorkHeader) For Empty(shipper) And chk_shp = 'Y'
1668 .AdvanceThermo(.85)
1669
1670 *--- TR 1041685 NSD 8/11/09 Commented out
1671 *--- TR 1039378 31-Mar-2009 Partha ---
1672 *llRetVal= llRetVal And .SwapColor("tceoowtd")
1673 *=== TR 1039378 31-Mar-2009 Partha ===
1674 *=== TR 1041685 NSD 8/11/09
1675
1676 *- Use CartonCheck() instead. Taken from clsoshpr
1677 *- llRetVal= .CheckASN()
1678 llRetVal = llRetVal And .CartonCheck(.cWorkHeader, .cWorkDetail)
1679 If !llRetVal
1680 .oLog.LogEntry("Checking cartons - failed")
1681 Endif
1682 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ---
1683*!* llRetVal = llRetVal And .CheckDUNS(.cWorkHeader, "zzeoowcr")
1684 llRetVal = llRetVal And .CheckDUNS(.cWorkHeader, "zzeoowcr_expl")
1685 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
1686 If !llRetVal
1687 .oLog.LogEntry("Checking DUNS - failed")
1688 Endif
1689
1690 IF goEnv.SV("940_VALIDATE_GIFTBOXSKU","Y") <> "Y"
1691 .oLog.LogEntry("Parameter: 940_VALIDATE_GIFTBOXSKU <> Y. Not Validating Gift Box SKU")
1692 ELSE
1693 .oLog.LogEntry("Parameter: 940_VALIDATE_GIFTBOXSKU = Y. Validating Gift Box SKU")
1694 *--- TechRec 1033545 25-Jun-2008 T.Shenbagavalli ---
1695 llRetVal = llRetVal And .CheckGiftBoxSKU(.cWorkDetail)
1696 *=== TechRec 1033545 25-Jun-2008 T.Shenbagavalli ===
1697 ENDIF
1698
1699 .AdvanceThermo(.95)
1700
1701 *- 1011923 10/05/05 YIK
1702 *- Explosion - move SLNs (prepack components) to DTLs.
1703 *- we don't need to get any history fields since we are not doing
1704 *-- .AdvanceThermoTotalWithCaptionPlus("Prepack components explosion...")
1705 *-- llRetVal = llRetVal And .PrepackExplosion("tceoowtd", "tcItemSLN")
1706 *= 1011923 YIK
1707
1708 llRetVal = llRetVal And .MarkHeaderForDetailWithError(.cWorkHeader, .cWorkDetail)
1709 If !llRetVal
1710 .oLog.LogEntry("Marking Header for Details with error - failed")
1711 Endif
1712
1713 .AdvanceThermo(1)
1714 Endwith
1715 .Tableclose('tcStyCol')
1716 Select(lnOldSelect)
1717 If !llRetVal
1718 .oLog.LogEntry("Validating Transaction - failed")
1719 Endif
1720
1721 Return llRetVal
1722 Endproc
1723
1724 ************************************************************************************
1725 *
1726 ************************************************************************************
1727 Procedure CheckASN
1728 Local llRetVal, lnOldSelect, lnCnt, lnMax
1729 llRetVal = .T.
1730 lnOldSelect = Select()
1731 With This
1732 .InitThermo(1)
1733 .UpdateThermoCaption("Verify ASN cartons...")
1734 .oLog.LogEntry("Checking ASN cartons")
1735
1736 lcErrs_Msg= "Missing ASN cartons."
1737 Select (.cWorkHeader)
1738 * TAN 31891 - JAZ - 5/20/02
1739 * lnMax= Recc(.cWorkHeader)
1740 lnMax= This.CountTotalRecs (.cWorkHeader)
1741 * End TAN 31891 - JAZ - 5/20/02
1742 lnCnt= 0
1743 *--When control ref chk_asn set, make sure have carton(s)
1744 Scan For chk_asn= 'Y'
1745 lnCnt = lnCnt + 1
1746
1747 *--- TR 1010079 VSS/SHAN 22-Apr-2005
1748 *!* lcCarton_num= vl_ctnph(ord_num, 'carton_num' , 'tcCrtHdr', pick_num, inv_num)
1749 If pro_856 = 'Y'
1750 lcCarton_num= vl_ctnsh(ord_num, 'carton_num' , 'tcCrtHdr', pick_num, inv_num)
1751 Else
1752 lcCarton_num= vl_ctnph(ord_num, 'carton_num' , 'tcCrtHdr', pick_num, inv_num)
1753 Endif
1754 *=== TR 1010079 VSS/SHAN 22-Apr-2005
1755
1756 If Empty(lcCarton_num)
1757 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" ;
1758 IN (.cWorkHeader)
1759 Endif
1760 .AdvanceThermo(lnCnt/lnMax)
1761 Endscan
1762
1763 Endwith
1764 Select(lnOldSelect)
1765 Return llRetVal
1766 Endproc
1767
1768 ************************************************************************************
1769 *
1770 ************************************************************************************
1771 Procedure PopulateValidTransaction
1772 Local llRetVal, lnOldSelect, tcTempPOH && Added tcTempPOH - TR 1011894 11Jul.05 - AS
1773 llRetVal = .T.
1774 lnOldSelect = Select()
1775 With This
1776 .InitThermo(1)
1777 .UpdateThermoCaption('Populating order net amount, order comments and resolve addresses...')
1778 .oLog.LogEntry("Populating valid transaction")
1779
1780 *--Getting EDI store
1781
1782 *---TR 1011894 11Jul.2005 AS
1783 *llRetVal= llRetVal and .PopulateEDI_Store(.cWorkHeader)
1784 llRetVal= llRetVal And .PopulateEDI_Store_Class_Type(.cWorkHeader)
1785 *===TR 1011894 11Jul.2005 AS
1786
1787 If !llRetVal
1788 .oLog.LogEntry("Populating EDI store - failed")
1789 Endif
1790
1791 *---TR 1011894 11Jul.2005 AS
1792
1793 *--Getting EDI Department Name
1794 llRetVal= llRetVal And .PopulateDeptInfo(.cWorkHeader)
1795
1796 If !llRetVal
1797 .oLog.LogEntry("Populating Department - failed")
1798 Endif
1799
1800 If Used('tcTempPOH')
1801 Use In tcTempPOH
1802 Endif
1803
1804 *--- TR 1077941 04/18/14 ATHIRUNAVU Modified method name to PopulateHistoryHeader
1805 *llRetVal= This.PopulatePromotionInfo(.cWorkHeader)
1806 llRetVal= This.PopulateHistoryHeader(.cWorkHeader)
1807 *=== TR 1077941 04/18/14 ATHIRUNAVU
1808
1809 If !llRetVal
1810 .oLog.LogEntry("Populating Promotion - failed")
1811 Endif
1812
1813 *===TR 1011894 11Jul.2005 AS
1814
1815 *--- TR 1027339 21-Nov-2007 Goutam
1816 llRetVal= This.PopulateTerms(.cWorkHeader)
1817 If !llRetVal
1818 .oLog.LogEntry("Populating Terms - failed")
1819 Endif
1820 *--- TR 1027339 21-Nov-2007 Goutam
1821
1822 *--- TR 1036614 19-Mar-2010 Goutam
1823 llRetVal= llRetVal And This.PopulateFromHistoryDetail(.cWorkHeader, .cWorkDetail)
1824 If !llRetVal
1825 .oLog.LogEntry("Populating from history detail - failed")
1826 Endif
1827 *--- TR 1036614 19-Mar-2010 Goutam
1828
1829 *--Getting EDI center
1830 llRetVal= llRetVal And .PopulateEDI_center(.cWorkHeader)
1831 If !llRetVal
1832 .oLog.LogEntry("Populating EDI Center - failed")
1833 Endif
1834
1835 *--Calculating order net extend
1836 llRetVal= llRetVal And .PopulateOrderNetExtended()
1837 If !llRetVal
1838 .oLog.LogEntry("Populating Order Net extended - failed")
1839 Endif
1840
1841 *--Creating comments in interface only for valid transaction
1842
1843 llRetVal= llRetVal And .CreateOrderComments(.cWorkHeader, .cPickComment, .cInterComment)
1844 If !llRetVal
1845 .oLog.LogEntry("Creating Order Comments - failed")
1846 Endif
1847
1848 *--Creating vertical addresses in interface only for valid transaction
1849 *--- TR 1022506 NH
1850 IF this.lSQLPassThrough940
1851 llRetVal = llRetVal AND .ResolveVerticalAddressesFromCursor(.cWorkHeader, .cWorkAddress)
1852 ELSE
1853 llRetVal= llRetVal And .ResolveVerticalAddresses(.cWorkHeader, .cWorkAddress)
1854 ENDIF
1855 *=== TR 1022506 NH
1856 If !llRetVal
1857 .oLog.LogEntry("Resolving Vertical addresses - failed")
1858 ENDIF
1859
1860 *--- TR 1066381 KISHORE 21-FEB-2013
1861 llRetVal = llRetVal AND .PopulateCountryISO2(.cWorkHeader, .cWorkAddress)
1862 IF !llRetVal
1863 .oLog.LogEntry("Populate Country ISO Code2 - failed")
1864 ENDIF
1865 *=== TR 1066381 KISHORE 21-FEB-2013
1866
1867 *--- TR 1053650 18-4-2011 VKK ---
1868 llRetVal= llRetVal And .ResolveZipCode(.cWorkAddress)
1869
1870 If !llRetVal
1871 .oLog.LogEntry("Resolving Zip Code - failed")
1872 Endif
1873 *=== TR 1053650 18-4-2011 VKK ===
1874
1875 *- 1020999 12/26/06 YIK
1876 *- Populate Retail price from the zzxcsthr if needed.
1877 IF goEnv.SV("940_RETAIL_SOURCE","S") = "C"
1878 .oLog.LogEntry("Resolving retail price from Customer Style")
1879 llRetVal= llRetVal And .ResolvRetailFromCustStyle(.cWorkDetail)
1880 ENDIF
1881 *=
1882
1883 *--- TechRec 1039850 21-Apr-2009 vkrishnamurthy ---
1884 llRetVal = llRetVal And .MarkBatchWithError(.cWorkHeader)
1885 If !llRetVal
1886 .oLog.LogEntry("Marking Header for Bill Number with error - failed")
1887 Endif
1888 *=== TechRec 1039850 21-Apr-2009 vkrishnamurthy ===
1889
1890 *--- TechRec 1052941 14-Mar-2011 MANI. ---
1891 llRetVal= llRetVal And .CreateWhsData(.cWorkHeader, .cWorkDetail)
1892 IF !llRetVal
1893 .oLog.LogEntry("Creating Data Warehouse - failed")
1894 ENDIF
1895 *=== TechRec 1052941 14-Mar-2011 MANI. ===
1896
1897 *--- TR 1066790 18-Feb-2013 Partha ---
1898 llRetVal= llRetVal And .PopulateChargeDetail(.cWorkDetail, .cWorkChrgDtl)
1899 IF !llRetVal
1900 .oLog.LogEntry("Populating Charge Detail - failed")
1901 ENDIF
1902 *=== TR 1066790 18-Feb-2013 Partha ===
1903
1904 *--- TR 1073471 KISHORE 20-SEP-2013
1905 llRetVal = llRetVal AND .PopulateDataWhseSLN(.cWorkHeader, .cWorkDetail, .cControlReference, "tcItemSLN", .cWhseSLN)
1906 *=== TR 1073471 KISHORE 20-SEP-2013
1907
1908 *--- TechRec 1085802 31-Mar-2015 TSV---
1909 llRetVal = llRetVal AND .PopulateTranslatedSizeDesc(.cWorkHeader, .cWorkDetail, .cControlReference)
1910 llRetVal = llRetVal AND .PopulateTranslatedStyle(.cWorkHeader, .cWorkDetail, .cControlReference)
1911 llRetVal = llRetVal AND .PopulateCustomsPrice(.cWorkHeader, .cWorkDetail, .cControlReference)
1912 *=== TechRec 1085802 31-Mar-2015 TSV===
1913
1914 Endwith
1915 Select(lnOldSelect)
1916 If !llRetVal
1917 .oLog.LogEntry("Populating Valid Transaction - failed")
1918 Endif
1919
1920 Return llRetVal
1921 Endproc
1922
1923 *--- TR 1022506 - NH
1924 *********************************************************************************
1925 PROCEDURE ResolveVerticalAddressesFromCursor
1926 LPARAMETERS tcWorkHeader, tcWorkAddress
1927 LOCAL llRetVal, lnOldSelect
1928 LOCAL lnMaxPkey, lnStartPkey, lnRowCount
1929 llRetVal = .t.
1930 lnOldSelect = SELECT()
1931 lnRowCount = 0
1932 this.LogEntry("Resolving Vertical addresses")
1933 *--- Get vertical address
1934 llRetVal = llRetVal AND this.GetAddressCursor(tcWorkHeader, "tmpAddrs")
1935 *--- Get Pkeys for zzeoowia
1936 this.LogEntry("Address cursor generation " + IIF(llRetVal,"completed.","failed."))
1937
1938 IF USED("tmpAddrs")
1939 lnRowCount = RECCOUNT("tmpAddrs")
1940 ENDIF
1941
1942 IF llRetVal AND lnRowCount > 0
1943 lnMaxPkey = v_nextPkey("ZZEOOWIA",lnRowCount)
1944 lnStartPkey = lnMaxPkey - lnRowCount
1945 lcLast_Mod = sqlFormatTs(DATETIME())
1946 lcUser_id = goEnv.cUser
1947
1948 * --- 1024360 7/17/07 BR
1949 *--- TR 1045025 21-Jan-2010 JK ---
1950*!* SELECT * FROM ("tmpAddrs") ;
1951*!* WHERE addr_type = 'ST' AND (EMPTY(address1) OR EMPTY(city) OR EMPTY(state) OR EMPTY(zipcode)) ;
1952*!* INTO CURSOR tmpAddrs1
1953
1954 llRetVal = llRetVal AND v_SqlExec("SELECT * FROM zzxcntyr","zzxcntyr_local")
1955
1956 *- TR 1057421 YIK/FH - added c.state_reqd, c.zip_reqd to select list, and include a.address2 to where clause
1957*!* SELECT a.* FROM ("tmpAddrs") a ;
1958*!* JOIN zzxcntyr_local c ON a.country = c.country ;
1959*!* WHERE a.addr_type = 'ST' AND (EMPTY(a.address1) OR EMPTY(a.city) OR ;
1960*!* (c.state_reqd = 'Y' AND EMPTY(a.state)) OR ;
1961*!* (c.zip_reqd = 'Y' AND EMPTY(a.zipcode))) ;
1962*!* INTO CURSOR tmpAddrs1
1963
1964
1965 SELECT a.*, c.state_reqd, c.zip_reqd FROM ("tmpAddrs") a ;
1966 JOIN zzxcntyr_local c ON a.country = c.country ;
1967 WHERE a.addr_type = 'ST' AND ((EMPTY(a.address1) AND EMPTY(a.address2)) OR EMPTY(a.city) OR ;
1968 (c.state_reqd = 'Y' AND EMPTY(a.state)) OR ;
1969 (c.zip_reqd = 'Y' AND EMPTY(a.zipcode))) ;
1970 INTO CURSOR tmpAddrs1
1971
1972 *- TR 1057421 YIK/FH
1973
1974 USE IN SELECT("zzxcntyr_local")
1975 *=== TR 1045025 21-Jan-2010 JK ===
1976
1977 SELECT tmpAddrs1
1978 SCAN
1979 IF SEEK(fkey,tcWorkHeader,'Pkey')
1980 *--- TechRec 1052460 24-Feb-2011 MPerel --- see also TR 1028867
1981*!* Check both Address 1 and 2. If both blank, then place in trans maintenance.
1982*!* IF EMPTY(tmpAddrs1.address1)
1983*!* lcErrs_Msg= "Invalid Ship to Address 1"
1984 IF EMPTY(tmpAddrs1.address1) AND EMPTY(tmpAddrs1.address2)
1985 lcErrs_Msg= "Invalid Ship to Address 1 and Address 2"
1986 *=== TechRec 1052460 24-Feb-2011 MPerel ===
1987 REPLACE Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcWorkHeader)
1988 Endif
1989
1990 IF EMPTY(tmpAddrs1.city)
1991 lcErrs_Msg= "Invalid Ship to City"
1992 REPLACE Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcWorkHeader)
1993 Endif
1994
1995 IF EMPTY(tmpAddrs1.state) AND tmpAddrs1.state_reqd = 'Y' && TR 1057421 YIK/FH - added stated_reqd check
1996 lcErrs_Msg= "Invalid Ship to State"
1997 REPLACE Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcWorkHeader)
1998 Endif
1999
2000 IF EMPTY(tmpAddrs1.zipcode) AND tmpAddrs1.zip_reqd = 'Y' && TR 1057421 YIK/FH - added zip_reqd check
2001 lcErrs_Msg= "Invalid Ship to Zip Code"
2002 REPLACE Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcWorkHeader)
2003 ENDIF
2004 ENDIF
2005 ENDSCAN
2006 * ==== 1024360 7/17/07 BR
2007
2008 *--- Insert into tcWorkAddress
2009 &&--- TechRec 1074985 21-Jan-2014 TShenbagavalli added email in below list ===
2010 &&--- TechRec 1085802 31-Mar-2015 TSV added address3, address4 in below list ===
2011 INSERT INTO (tcWorkAddress) ;
2012 (pick_num, ord_num, addr_type, cust_name, address1, address2, address3, address4, city, state, zipcode, country, accessnum, email, notes, user_id, last_mod, pkey, fkey) ;
2013 SELECT pick_num, ord_num, addr_type, cust_name, address1, address2, address3, address4, city, state, zipcode, country, accessnum, email, notes, lcUser_id , lcLast_mod , pkey_I + lnStartPkey, fkey ;
2014 FROM tmpAddrs
2015 ENDIF
2016 this.LogEntry("Resolving Vertical addresses " + IIF(llRetVal,"completed.","failed."))
2017 SELECT(lnOldSelect)
2018 RETURN llRetVal
2019 ENDPROC
2020 *********************************************************************************
2021
2022 PROCEDURE GetAddressCursor
2023 LPARAMETERS tcWorkHeader, tcAddrs
2024 LOCAL llRetVal, lnOldSelect, lcMsg, lcTmpAddr, lcVertAddr
2025 LOCAL llUpdatePhEmail && TR 1073762 20-Nov-2013 Partha
2026
2027 llRetVal = .t.
2028 lnOldSelect = SELECT()
2029 lcMsg = ""
2030 lcTmpAddr = ""
2031 *--- find address for cursor __eoshAddr1
2032 SELECT DISTINCT ord_num,pick_num,inv_num,0 as cncl_num, pkey as fkey ;
2033 From (tcWorkHeader) Where !(Errs_flg_h= "Y") ;
2034 Into Cursor __eoshAddr1 ;
2035 Order by inv_num, pick_num, ord_num
2036
2037 *--- create server temp table for __eoshAddr1
2038 IF RECCOUNT("__eoshAddr1") > 0
2039 lcTempAddrTable = "#" + getUniqueFilename()
2040
2041 lcSQL = "CREATE TABLE " + lcTempAddrTable + ;
2042 "(ord_num INT,pick_num INT,inv_num INT, cncl_num INT, fkey INT)"
2043 llRetVal = llRetVal and V_SQLEXEC(lcSQL)
2044 lcMsg = IIF(NOT llRetVal AND EMPTY(lcMsg), "Could not create temporary table to store Invoice Keys to Pull Address. Using Legacy mode.", lcMsg)
2045 IF llRetVal AND NOT THIS.BulkInsertFromCursor("__eoshAddr1",lcTempAddrTable)
2046 lcMsg = "Could not Bulk Insert Invoice Keys to Pull Address Information. Using Legacy Mode."
2047 v_sqlexec("DROP TABLE " + lcTempAddrTable )
2048 llRetVal = .f. && TR 1022506 NH : Address cursor creation failed.
2049 ELSE
2050 llRetVal = llRetVal and v_sqlexec("select COUNT(*) AddrRowCount from " + lcTempAddrTable,"tcAddrRowCount")
2051 IF llRetVal AND tcAddrRowCount.AddrRowCount <> RECCOUNT("__eoshAddr1")
2052 v_sqlexec("DROP TABLE " + lcTempAddrTable )
2053 lcMsg = IIF(NOT llRetVal AND EMPTY(lcMsg), "The count of addresses received versus addresses expected does not match. Using Legacy Mode.", lcMsg)
2054 llRetVal = .f. && TR 1022506 NH : Address cursor creation failed.
2055 ELSE
2056 lcTmpAddr = "#" + getUniqueFilename()
2057 lcJoinClause = " JOIN " + lcTempAddrTable + " tmp " + ;
2058 " ON h.ord_num = tmp.ord_num " + ;
2059 " AND h.pick_num = tmp.pick_num " + ;
2060 " AND h.inv_num = tmp.inv_num "
2061
2062 lcVerticalAddressSQL = THIS.GetVerticalAddressSQL(lcJoinClause)
2063 lcVerticalAddressSQL = "SELECT * INTO " + lcTmpAddr + " FROM (" + lcVerticalAddressSQL + " ) a ORDER BY a.inv_num,a.addr_seq"
2064 llRetVal = llRetVal and v_sqlexec(lcVerticalAddressSQL)
2065 *--- add identity columns pkey_I
2066 llRetVal = llRetVal and v_sqlexec("ALTER TABLE " + lcTmpAddr + " ADD pkey_i int not null identity(1,1)")
2067 llRetval = llRetVal and v_sqlexec("SELECT * FROM " + lcTmpAddr ,tcAddrs)
2068 ENDIF
2069 ENDIF
2070 lcMsg = IIF(NOT llRetVal AND EMPTY(lcMsg), "Failed to Retrieve Addresses from Invoice Keys. Using Legacy Mode.", lcMsg)
2071
2072 *--- need to do this data fix at server time
2073 IF llRetVal
2074 SELECT (tcAddrs)
2075 SCAN
2076 IF EVALUATE(tcAddrs+ ".addr_type") = "SF"
2077 lcAccessNum = EVALUATE(tcAddrs + ".accessnum")
2078 lnChrsRet = AT("@", lcAccessNum)
2079 lnChrsRet = IIF(lnChrsRet = 0, LEN(lcAccessNum), lnChrsRet - 1)
2080 lcAccessNum = SUBSTR(lcAccessNum , 1, lnChrsRet)
2081 lcAccessNum = STRTRAN(STRTRAN(lcAccessNum , "/"), "-")
2082 REPLACE accessnum WITH lcAccessNum
2083 ENDIF
2084
2085 *--- TR 1073762 20-Nov-2013 Partha ---
2086 llUpdatePhEmail = llRetval
2087 *=== TR 1073762 20-Nov-2013 Partha ===
2088
2089 ENDSCAN
2090 INDEX ON STR(ord_num)+STR(pick_num)+STR(inv_num) TAG addr
2091 ENDIF
2092 ENDIF
2093
2094 *--- TR 1073762 20-Nov-2013 Partha ---
2095 IF (llUpdatePhEmail )
2096 This.UpdatePhEmail(tcAddrs)
2097 ENDIF
2098 *=== TR 1073762 20-Nov-2013 Partha ===
2099
2100 IF NOT EMPTY(lcMsg)
2101 this.LogEntry(lcMsg)
2102 ENDIF
2103
2104 SELECT(lnOldSelect)
2105 RETURN llRetVal
2106 ENDPROC
2107
2108 *-----------------------------------------------------------------------------------------------
2109 * Build a SQL statement to pivot zzordad2 by address type. There are currently 7 addresses
2110 PROCEDURE GetVerticalAddressSQL
2111 LPARAMETERS lcJoinFilter, tcOrderBy
2112
2113 LOCAL lcRetVal,lcOneTime,lcOrderBy
2114
2115 WITH THIS
2116 lcOrderBy = IIF(EMPTY(tcOrderBy),"",tcOrderBy)
2117 lcRetVal = ""
2118 lcOneTime = GoEnv.sv("EDI_ADDRESS_TYPE_ONETIME", "OT")
2119
2120 lcRetVal = .GetVerticalAddressSQLOne("B","BT",lcJoinFilter,1) + " UNION ALL "
2121 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("S","ST",lcJoinFilter,2) + " UNION ALL "
2122 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("M","MK",lcJoinFilter,3) + " UNION ALL "
2123 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("R","RE",lcJoinFilter,4) + " UNION ALL "
2124 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("L","SF",lcJoinFilter,5) + " UNION ALL "
2125 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("O","OT",lcJoinFilter,6) + " UNION ALL "
2126 lcRetVal = lcRetVal + .GetVerticalAddressSQLOne("D","DV",lcJoinFilter,7)
2127
2128 *--- TechRec 1059998 05-Apr-2012 jisingh ---
2129 &&--- TechRec 1085802 31-Mar-2015 TSV added h.address3, h.address4 ===
2130 lcRetVal = lcRetVal + " UNION ALL " + ;
2131 " SELECT h.ord_num, tmp.pick_num, tmp.inv_num, h.addr_type, h.cust_name, " + ;
2132 " h.address1, h.address2, h.address3, h.address4, h.city, h.state, h.zipcode, h.country, " + ;
2133 " ' ' AS notes, h.user_id, h.last_mod, '' AS email, '' AS accessnum, " + ;
2134 " h.pkey, tmp.fkey AS fkey, 8 AS addr_seq " + ;
2135 " FROM zzootadr h " + SUBSTR(lcJoinFilter,1,AT("tmp",lcJoinFilter)+3) + ;
2136 " ON h.ord_num = tmp.ord_num "
2137 *=== TechRec 1059998 05-Apr-2012 jisingh ===
2138
2139 lcRetVal = lcRetVal + lcOrderBy
2140
2141 ENDWITH
2142
2143 RETURN lcRetVal
2144
2145 ENDPROC
2146
2147 *-----------------------------------------------------------------------------------------------
2148 * Used for pivoting zzordad2. This will return a select statement for one type of address
2149 PROCEDURE GetVerticalAddressSQLOne
2150
2151 LPARAMETERS lcPrefix,lcAddrType,lcJoinFilter,lnOrder
2152
2153 LOCAL lcRetVal,lcAccessnum,lcEmail,lcOrder
2154 lcRetVal = ""
2155 lcOrder = TRANSFORM(lnOrder)
2156 lcAccessnum = ",'' as accessnum "
2157 lcEmail = ",'' as email "
2158 IF lcPrefix = "L"
2159 lcEmail = ;
2160 ",dbo.bcfn_vl_commu(h.l_table,h.l_pkey,'e-mail') as EMAIL"
2161
2162 lcAccessNum = ;
2163 ",dbo.bcfn_vl_commu(h.l_table,h.l_pkey,'') as ACCESSNUM"
2164 ENDIF
2165
2166
2167
2168 lcRetVal = ;
2169 " SELECT h.ord_num,h.pick_num,h.inv_num,'"+lcAddrType+"' as addr_type," + ;
2170 lcPrefix + "_NAME as cust_name," + ;
2171 lcPrefix + "_ADDR1 as address1," + ;
2172 lcPrefix + "_ADDR2 as address2," + ;
2173 lcPrefix + "_ADDR3 as address3," + ; &&--- TechRec 1085802 31-Mar-2015 TSV===
2174 lcPrefix + "_ADDR4 as address4," + ; &&--- TechRec 1085802 31-Mar-2015 TSV===
2175 lcPrefix + "_CITY as city," + ;
2176 lcPrefix + "_STATE as state," + ;
2177 lcPrefix + "_ZIPCODE as zipcode," + ;
2178 lcPrefix + "_COUNTRY as country," + ;
2179 "' ' as notes,h.user_id,h.last_mod" + lcEmail + lcAccessnum + ",h.pkey,tmp.fkey as fkey," + lcOrder + " as addr_seq " + ;
2180 " FROM zzordad2 h " + lcJoinFilter + " "
2181
2182
2183 RETURN lcRetVal
2184
2185 ENDPROC
2186
2187 *=== TR 1022506 - NH
2188
2189 ************************************************************************************
2190 *
2191 ************************************************************************************
2192 Procedure PopulateOrderNetExtended
2193 Local llRetVal, lnOldSelect, lnMerch_amt, lnTerm_rate, ;
2194 lnOrderNetExt, lcterm_basis, lcTerm_desc, lcTerm_type, lnTerm_dom, ;
2195 ldDsc_duedate, lnDsc_duedays, ldNet_duedate, lnNet_duedays, lnTermDscAmt
2196 llRetVal = .T.
2197 lnOldSelect = Select()
2198 With This
2199 .InitThermo(1)
2200 .UpdateThermoCaption('Populating order net amount...')
2201 * TAN 31891 - JAZ - 5/20/02
2202 * lnMax= Recc(.cWorkHeader)
2203 lnMax= This.CountTotalRecs (.cWorkHeader)
2204 * End TAN 31891 - JAZ - 5/20/02
2205 lnCnt= 0
2206
2207 *--- TR 1040807 NSD 6/26/09
2208 * Cache data
2209 LOCAL lnPickNum
2210 v_sqlexec("SELECT * FROM zzxcustr","zzxcustr_local")
2211 INDEX ON customer TAG customer
2212 v_sqlexec("SELECT * FROM zzxdiscr","zzxdiscr_local")
2213 INDEX on discount TAG discount
2214 *=== TR 1040807 NSD 6/26/09
2215
2216 *--- TechRec 1085802 06-Apr-2015 TSV---
2217 SELECT d.fkey, SUM(total_Qty*price) as merch_amt ;
2218 FROM (.cWorkDetail) d ;
2219 GROUP BY d.fkey ;
2220 INTO CURSOR tcMerchAmt
2221
2222 llRetVal = llRetVal AND USED("tcMerchAmt")
2223
2224 If llRetVal
2225 Select tcMerchAmt
2226 Index On fkey Tag fkey
2227 llRetVal= .SetRelation("tcMerchAmt", "fkey", .cWorkHeader, "pkey")
2228
2229 If llRetVal
2230 Replace All merch_amt With tcMerchAmt.merch_amt In (.cWorkHeader)
2231
2232 Set Relation To
2233 Use In tcMerchAmt
2234 Endif
2235 Endif
2236 *=== TechRec 1085802 06-Apr-2015 TSV===
2237
2238 Select (.cWorkHeader)
2239 *--Only for valid transaction header (no error)
2240 Scan For !(Errs_Flg_H= "Y")
2241 *--calculate order net ext
2242
2243 *--- TR 1040807 NSD 6/26/09
2244 * Get order data from cached order info. Pass that to order net ext to avoid expensive server calls.
2245 IF .lSQLPassThrough940
2246 lnPickNum = pick_num
2247
2248 USE IN SELECT ("__Ordrd")
2249 USE IN SELECT ("__Ordrh")
2250
2251 SELECT * FROM __ordnetext_hdr WHERE pick_num = lnPickNum INTO CURSOR __Ordrh
2252 SELECT * FROM __ordnetext_dtl WHERE pick_num = lnPickNum INTO CURSOR __Ordrd
2253
2254 Select (.cWorkHeader)
2255 lnOrderNetExt= OrderNetExtended(ord_num, pick_num, inv_num, ord_status, .T., , ,,"zzxdiscr_local","zzxcustr_local","__Ordrh","__Ordrd")
2256
2257 ELSE
2258 lnOrderNetExt= OrderNetExtended(ord_num, pick_num, inv_num, ord_status, .T., , ,,"zzxdiscr_local","zzxcustr_local")
2259 ENDIF
2260 *=== TR 1040807 NSD 6/26/09
2261
2262 If lnOrderNetExt> 0
2263 Replace ordnetext With lnOrderNetExt In (.cWorkHeader)
2264 Endif
2265 lnCnt = lnCnt + 1
2266 .AdvanceThermo(lnCnt/lnMax)
2267 ENDSCAN
2268
2269 *--- TR 1040807 NSD 6/26/09
2270 USE IN SELECT("zzxcustr_local")
2271 USE IN SELECT("zzxdiscr_local")
2272 *=== TR 1040807 NSD 6/26/09
2273
2274 Endwith
2275 Select(lnOldSelect)
2276 Return llRetVal
2277 Endproc
2278
2279 ************************************************************************************
2280 *
2281 ***********************************************************************************
2282 Procedure ResolveVerticalAddresses
2283 Lparameters tcHeader, tcAddress
2284 Local llRetVal, lnOldSelect
2285 llRetVal = .T.
2286 lnOldSelect = Select()
2287
2288 With This
2289 .InitThermo(1)
2290 .UpdateThermoCaption('Resolving and Creating addresses...')
2291 .oLog.LogEntry("Resolving Vertical address")
2292
2293 * TAN 31891 - JAZ - 5/20/02
2294 * lnMax= Recc(tcHeader)
2295 lnMax= This.CountTotalRecs (tcHeader)
2296 * End TAN 31891 - JAZ - 5/20/02
2297 lnCnt= 0
2298 Select (tcHeader)
2299
2300 *--Only for valid transaction header (no error)
2301 * resolve addresses
2302 Scan For !(Errs_Flg_H= "Y")
2303 If Bcaddres(&tcHeader..customer,, "tmpAddrs", &tcHeader..Store, ;
2304 &tcHeader..ship_dc, &tcHeader..center_code, ;
2305 &tcHeader..consol_code, &tcHeader..ord_num, ;
2306 &tcHeader..division, &tcHeader..factor, ;
2307 &tcHeader..location)
2308 *--Creating vertical address records
2309 m.ord_num= &tcHeader..ord_num
2310 m.pick_num= &tcHeader..pick_num
2311 m.inv_num= &tcHeader..inv_num
2312 m.fkey= &tcHeader..pkey
2313 *- 1014440 11/30/05 YIK
2314 *- 1014229 11/16/05 YIK
2315 *-m.Ship_To = tmpAddrs.S_EDI_SHIP_TO
2316 m.EDI_ShipTo = tmpAddrs.S_EDI_SHIP_TO
2317 *= 1014440
2318
2319 *- 1010624 Correct ZZEOOWIC to ZZEOOWIA
2320 *- If !This.CreateVerticalAddress("TmpAddrs", tcAddress,,,"ZZEOOWIC")
2321 If !This.CreateVerticalAddress("TmpAddrs", tcAddress,,,"ZZEOOWIA")
2322 llRetVal= .F.
2323 .oLog.LogEntry("Create Vertical address - failed")
2324
2325 Exit
2326 ENDIF
2327 *- 1014440 11/16/05 YIK
2328 REPLACE EDI_ShipTo WITH m.EDI_ShipTo IN (tcHeader)
2329
2330 * --- 1020355 01/11/2007 HNISAR
2331
2332 * --- TR 1028867 NSD 11/27/07
2333 * Check both Address 1 and 2. If both blank, then place in trans maintenance.
2334 *IF EMpty(TmpAddrs.S_addr1)
2335 IF EMPTY(TmpAddrs.S_addr1) AND EMPTY(TmpAddrs.S_addr2)
2336 *lcErrs_Msg= "Invalid Ship to Address 1"
2337 lcErrs_Msg= "Invalid Ship to Address 1 and Address 2"
2338 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcHeader)
2339 ENDIF
2340 * === TR 1028867 NSD 11/27/07
2341
2342 IF EMPTY(TmpAddrs.s_city)
2343 lcErrs_Msg= "Invalid Ship to City"
2344 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcHeader)
2345 Endif
2346
2347 IF EMPTY(TmpAddrs.s_state)
2348 lcErrs_Msg= "Invalid Ship to State"
2349 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcHeader)
2350 Endif
2351
2352 IF EMPTY(TmpAddrs.s_ZIPCODE)
2353 lcErrs_Msg= "Invalid Ship to Zip Code"
2354 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" IN (tcHeader)
2355 Endif
2356
2357
2358 * ==== 1020355 01/11/2007 HNISAR
2359
2360 *--- TechRec 1059998 05-Apr-2012 jisingh ---
2361 .CreateOTAddress(&tcHeader..ord_num, "ZZEOOWIA", tcAddress)
2362 *=== TechRec 1059998 05-Apr-2012 jisingh ===
2363 Else
2364 llRetVal= .F.
2365 .oLog.LogEntry("BCAddres - failed")
2366
2367 Exit
2368 Endif
2369 lnCnt = lnCnt + 1
2370 .AdvanceThermo(lnCnt/lnMax)
2371 Endscan
2372 Endwith
2373
2374 Select(lnOldSelect)
2375 If !llRetVal
2376 .oLog.LogEntry("Resolving Vertical address - failed")
2377 Endif
2378
2379 Return llRetVal
2380 Endproc
2381
2382 ***************************************************************************************
2383 * Creating Interface comment (--for unload to flatfile) only for none error transaction
2384 ***************************************************************************************
2385 Procedure CreateOrderComments
2386 Lparameters tcPickHeader, tcPickComment, tcInterComment
2387 Local llRetVal, lnOldSelect
2388 llRetVal = .T.
2389 lnOldSelect = Select()
2390 *--- TR 1026620 NH : following mod is not related with TR 1026620 issue but for optimization -
2391 LOCAL lcScmtr, lcCcmtr, loPickHeader
2392 lcScmtr = "zzxscmtr" + SYS(2015)
2393 lcCcmtr = "zzxccmtr" + SYS(2015)
2394 llRetVal = llRetVal and v_sqlexec("select * from zzxscmtr", lcScmtr)
2395 llRetVal = llRetVal and v_sqlexec("select * from zzxccmtr", lcCcmtr)
2396 IF llRetVal
2397 SELECT (lcScmtr)
2398 INDEX on customer+store TAG CustStCmt && TR 1035377 AUG-20-2008 BR: REMOVED: +cmt_code
2399 SELECT (lcCcmtr)
2400 INDEX on customer TAG CustCmt && TR 1035377 AUG-20-2008 BR: REMOVED: +cmt_code
2401 ENDIF
2402 *=== TR 1026620
2403
2404 *---TR 1035377 AUG-20-2008 BR
2405 LOCAL lcCmtCode, lcOrdLocation, lcStoreCmtCode, lcCustomerCmtCode, lcWhseType
2406 lcOrdLocation = ""
2407 lcCmtCode = ""
2408 lcStoreCmtCode = ""
2409 lcCustomerCmtCode = ""
2410 lcWhseType = ""
2411 *===TR 1035377 AUG-20-2008 BR
2412
2413 With This
2414 .InitThermo(1)
2415 .UpdateThermoCaption('Creating order comments...')
2416
2417 Select (tcPickComment)
2418 * End TAN 31891 - JAZ - 5/20/02
2419 * lnMax= Recc(tcPickComment)
2420 lnMax= This.CountTotalRecs (tcPickComment)
2421 * End TAN 31891 - JAZ - 5/20/02
2422 lnLast= v_NextPkey("ZZEOOWIC", lnMax)
2423 lnCnt= 0
2424 Select (tcPickHeader)
2425 *--Only for valid transaction header (no error)
2426 Scan For !(Errs_Flg_H= "Y") And llRetVal
2427 SCATTER NAME loPickHeader && TR 1026620
2428 lnCnt = lnCnt + 1
2429 lnCur = (lnLast - lnMax) + lnCnt
2430 lnCurHeaderPkey = loPickHeader.pkey && &tcPickHeader..pkey - TR 1026620
2431 lnCurOrd_Num = loPickHeader.ord_num && &tcPickHeader..ord_num - TR 1026620
2432 lnCurPick_num = loPickHeader.pick_num && &tcPickHeader..pick_num - TR 1026620
2433 *- 1010624 04/22/05 YIK
2434 lnCurCustomer = loPickHeader.customer && &tcPickHeader..customer - TR 1026620
2435 lnCurStore = loPickHeader.STORE && &tcPickHeader..STORE - TR 1026620
2436 lcOrdLocation = loPickHeader.location && TR 1035377 AUG-20-2008 BR
2437 lcWhseType = loPickHeader.whse_type && TR 1035377 AUG-20-2008 BR
2438 *=
2439
2440 *---TR 1035377 AUG-20-2008 BR
2441 IF llRetVal AND SEEK(lcOrdLocation+lcWhseType,.cControlReference,'WCodeType')
2442 SELECT (.cControlReference)
2443 lcCmtCode = cmt_code
2444 ELSE
2445 IF llRetVal AND SEEK(lcOrdLocation+'B',.cControlReference,'WCodeType')
2446 SELECT (.cControlReference)
2447 lcCmtCode = cmt_code
2448 ENDIF
2449 ENDIF
2450 *===TR 1035377 AUG-20-2008 BR
2451
2452 *--- TR 1026620 NH
2453 IF llRetVal AND SEEK(lnCurPick_num,tcPickComment,'PICK_NUM')
2454 Select (tcPickComment)
2455 *Scan For (ord_num= lnCurOrd_Num And llRetVal)
2456 SCAN WHILE PICK_NUM = lnCurPick_num
2457 llRetVal= llRetVal and This.CreateRecordWithPkey(tcPickComment, tcInterComment,,,,lnCur)
2458 If llRetVal
2459*!* Replace fkey With lnCurHeaderPkey, ;
2460*!* pick_num With lnCurPick_num In (tcInterComment)
2461 REPLACE fkey WITH lnCurHeaderPkey IN (tcInterComment)
2462 Endif
2463 ENDSCAN
2464 ENDIF
2465 *=== TR 1026620 NH
2466
2467 *- 1010624 04/22/05 YIK
2468 *- 1010916 05/10/05 YIK
2469 *- Check for empty store in which case the comment file is not created
2470 *- Added ..AND USED("__StoreCmt")
2471 *--- TR 1026620 NH
2472*!* If VL_STORPC(lnCurCustomer, , "__StoreCmt", lnCurStore, 'P') And Used("__StoreCmt")
2473*!* Select __StoreCmt
2474*!* Scan For !Empty(Alltrim(cmmnt))
2475
2476 IF SEEK(lnCurCustomer+lnCurStore,lcScmtr,'CustStCmt') &&TR 1035377 AUG-20-2008 BR REMOVED: +'P'
2477
2478 SELECT (lcScmtr)
2479 *---TR 1035377 AUG-20-2008 BR
2480 *SCAN WHILE customer+store+cmt_code == lnCurCustomer+lnCurStore+'P'
2481 SCAN WHILE customer+store == lnCurCustomer+lnCurStore
2482 lcStoreCmtCode = cmt_code
2483 *===TR 1035377 AUG-20-2008 BR
2484
2485 IF !EMPTY(ALLTRIM(cmmnt)) AND lcStoreCmtCode $ lcCmtCode
2486 *llRetVal= THIS.CreateRecordWithPkey("__StoreCmt", tcInterComment, "ZZEOOWIC")
2487 llRetVal= llRetVal and THIS.CreateRecordWithPkey(lcScmtr, tcInterComment, "ZZEOOWIC")
2488 *=== TR 1026620 NH
2489 If llRetVal
2490 Replace fkey With lnCurHeaderPkey, ;
2491 pick_num With lnCurPick_num, ;
2492 ord_num With lnCurOrd_Num ;
2493 IN (tcInterComment)
2494 ENDIF
2495 ENDIF && TR 1026620 NH
2496 Endscan
2497 Endif
2498 *- 1010916 05/10/05 YIK
2499 *- Check the comment file is created
2500 *- Added .. AND USED("__CustCmt")
2501 *--- TR 1026620 NH
2502*!* If VL_CUSTPC(lnCurCustomer, , "__CustCmt", 'P') And Used("__CustCmt")
2503*!* Select __CustCmt
2504*!* Scan For !Empty(Alltrim(cmmnt))
2505
2506 IF SEEK(lnCurCustomer,lcCcmtr,'CustCmt') &&TR 1035377 AUG-20-2008 BR REMOVED: +'P'
2507 SELECT(lcCcmtr)
2508
2509 *---TR 1035377 AUG-20-2008 BR
2510 *SCAN WHILE customer+cmt_code == lnCurCustomer+'P'
2511 SCAN WHILE customer == lnCurCustomer
2512 lcCustomerCmtCode = cmt_code
2513 *===TR 1035377 AUG-20-2008 BR
2514
2515 IF !EMPTY(ALLTRIM(cmmnt)) AND lcCustomerCmtCode $ lcCmtCode
2516 *llRetVal= THIS.CreateRecordWithPkey("__CustCmt", tcInterComment, "ZZEOOWIC")
2517 llRetVal = llRetVal and THIS.CreateRecordWithPkey(lcCcmtr, tcInterComment, "ZZEOOWIC")
2518 *=== TR 1026620 NH
2519 If llRetVal
2520 Replace fkey With lnCurHeaderPkey, ;
2521 pick_num With lnCurPick_num, ;
2522 ord_num With lnCurOrd_Num ;
2523 IN (tcInterComment)
2524 Endif
2525 ENDIF && TR 1026620 NH
2526 Endscan
2527 Endif
2528 *== 1010624
2529
2530 .AdvanceThermo(lnCnt/lnMax)
2531 Endscan
2532 Endwith
2533
2534 Select(lnOldSelect)
2535 Return llRetVal
2536 Endproc
2537
2538
2539 ************************************************************************************
2540 * Move Valid Records from transaction to interface and remove from transaction
2541 ***********************************************************************************
2542 Procedure MoveRecordsToTransactionOrInterface
2543 Local llRetVal
2544 llRetVal= .T.
2545 With This
2546 .InitThermo(1)
2547 .UpdateThermoCaption('Preparing valid records for export...')
2548 .oLog.LogEntry("Moving records to transaction or interface")
2549
2550
2551 *--Counting number of records in header,detail,comment,address
2552 * require for .MoveRecords()
2553 llRetVal = llRetVal And .CountTransactionAndInterface(.cWorkHeader, .cWorkDetail, ;
2554 .cWorkComment, .cWorkAddress)
2555 If !llRetVal
2556 .oLog.LogEntry("Counting - failed")
2557 Endif
2558
2559 .AdvanceThermo(1/4)
2560
2561 *--- TR 1040807 NSD 6/26/09
2562 * Use Fox SQL to move to interface or transaction tables instead of slow framework.
2563 IF .lSQLPassThrough940
2564
2565
2566 SELECT pkey FROM tceoowth WHERE tceoowth.Errs_flg_H <> "Y" INTO CURSOR __valid_trx
2567 INDEX ON pkey TAG pkey
2568
2569 SELECT pkey FROM tceoowth WHERE tceoowth.Errs_flg_H = "Y" INTO CURSOR __bad_trx
2570 INDEX ON pkey TAG pkey
2571
2572 LOCAL lcSQL
2573
2574 * Interface Header
2575 lcSQL = ;
2576 "INSERT INTO Vzzeoowih_proc (" + createfieldListFromCursor("Vzzeoowih_proc") + ")" + ;
2577 " SELECT " + createfieldListFromCursor("Vzzeoowih_proc","H") + ;
2578 " FROM tceoowth H" + ;
2579 " JOIN __valid_trx V ON H.PKEY = V.PKEY "
2580 &lcSQL
2581
2582 * Interface Detail
2583 lcSQL = ;
2584 "INSERT INTO Vzzeoowid_proc (" + createfieldListFromCursor('Vzzeoowid_proc') + ")" + ;
2585 " SELECT " + createfieldListFromCursor('Vzzeoowid_proc',"D") + ;
2586 " FROM tceoowtd D" + ;
2587 " JOIN __valid_trx V ON D.FKEY = V.PKEY "
2588 &lcSQL
2589
2590 * Interface Comment
2591 lcSQL = ;
2592 "INSERT INTO Vzzeoowic_proc (" + createfieldListFromCursor('Vzzeoowic_proc') + ")" + ;
2593 " SELECT " + createfieldListFromCursor('Vzzeoowic_proc',"D") + ;
2594 " FROM tceoowtc D" + ;
2595 " JOIN __valid_trx V ON D.FKEY = V.PKEY "
2596 &lcSQL
2597
2598 * Interface Address
2599 lcSQL = ;
2600 "INSERT INTO Vzzeoowia_proc (" + createfieldListFromCursor('Vzzeoowia_proc') + ")" + ;
2601 " SELECT " + createfieldListFromCursor('Vzzeoowia_proc',"D") + ;
2602 " FROM tceoowta D" + ;
2603 " JOIN __valid_trx V ON D.FKEY = V.PKEY "
2604 &lcSQL
2605
2606 .AdvanceThermo(2/3)
2607
2608 * Transaction Header
2609 lcSQL = ;
2610 "INSERT INTO Vzzeoowth_proc (" + createfieldListFromCursor('Vzzeoowth_proc') + ")" + ;
2611 " SELECT " + createfieldListFromCursor('Vzzeoowth_proc',"H") + ;
2612 " FROM tceoowth H" + ;
2613 " JOIN __bad_trx V ON H.PKEY = V.PKEY "
2614 &lcSQL
2615
2616 * Transaction Detail
2617 lcSQL = ;
2618 "INSERT INTO Vzzeoowtd_proc (" + createfieldListFromCursor('Vzzeoowtd_proc') + ")" + ;
2619 " SELECT " + createfieldListFromCursor('Vzzeoowtd_proc',"D") + ;
2620 " FROM tceoowtD D" + ;
2621 " JOIN __bad_trx V ON D.FKEY = V.PKEY "
2622 &lcSQL
2623
2624 * Transaction Comment
2625 lcSQL = ;
2626 "INSERT INTO Vzzeoowtc_proc (" + createfieldListFromCursor('Vzzeoowtc_proc') + ")" + ;
2627 " SELECT " + createfieldListFromCursor('Vzzeoowtc_proc',"D") + ;
2628 " FROM tceoowtC D" + ;
2629 " JOIN __bad_trx V ON D.FKEY = V.PKEY "
2630 &lcSQL
2631
2632 * Transaction Address
2633 lcSQL = ;
2634 "INSERT INTO Vzzeoowta_proc (" + createfieldListFromCursor('Vzzeoowta_proc') + ")" + ;
2635 " SELECT " + createfieldListFromCursor('Vzzeoowta_proc',"D") + ;
2636 " FROM tceoowtA D" + ;
2637 " JOIN __bad_trx V ON D.FKEY = V.PKEY "
2638 &lcSQL
2639
2640 .AdvanceThermo(3/3)
2641
2642 ELSE
2643
2644 *--Move valid transactions header,detail,comment,address from work to interface views
2645 llRetVal= llRetVal And .MoveRecords(.cWorkHeader, .cWorkDetail, .cWorkComment, .cWorkAddress,;
2646 .cInterHeader, .cInterDetail, .cInterComment, .cInterAddress, ;
2647 .nTranHeader, .nTranDetail, .nTranAddress, .nTranAddress, ;
2648 "Interface", [ !(tceoowth.Errs_flg_H= "Y") ])
2649 If !llRetVal
2650 .oLog.LogEntry("Moving - failed")
2651 Endif
2652
2653 .AdvanceThermo(2/3)
2654
2655 *--Move all error transactions from work to transaction views
2656 llRetVal= llRetVal And .MoveTransactionInError(.cWorkHeader , .cWorkDetail, "", "",;
2657 .cTranHeader,.cTranDetail, "", "")
2658 If !llRetVal
2659 .oLog.LogEntry("Moving transactions in error - failed")
2660 Endif
2661
2662 .AdvanceThermo(3/3)
2663 ENDIF
2664 *=== TR 1040807 NSD 6/26/09
2665
2666 Select (.cTranHeader)
2667 Count To .nTransaction For Errs_Flg_H= 'Y'
2668 .nInterface= This.CountTotalRecs (.cInterHeader)
2669 .nHistory= This.CountTotalRecs (.cInterHeader)
2670
2671 Endwith
2672 If !llRetVal
2673 .oLog.LogEntry("Moving to Transaction or Interface - failed")
2674 Endif
2675 Return llRetVal
2676
2677 Endproc
2678
2679 ************************************************************************************
2680 * Prepare Unload to flat file and then call Unload to flat file
2681 ***********************************************************************************
2682 Procedure UnLoadInterfaceToFlatFile
2683 Local llRetVal
2684 llRetVal= .T. && TR 1046076 BR
2685 With This
2686 .InitThermo(1)
2687 .UpdateThermoCaption('Preparing to unload to flat file...')
2688 .oLog.LogEntry("Preparing to unload to flat file")
2689
2690 lcEDIPath = This.GetEDIFlatFileDirectory("Outbound")
2691 lcOutBoundFlatFile = lcEDIPath + EDI_OOW_FILENAME
2692 *--Creating flatfile from Interface views
2693 *- 1011923 10/05/05 YIK
2694 *- Added "tcItemSLN"
2695
2696 *-- TR 1046076 BR
2697 IF RECCOUNT(.cInterDetail) > 0 AND RECCOUNT(.cInterHeader) > 0
2698 llRetVal = .UnLoadToFlatFile(EDI_OOW_TRANSACTION, lcOutBoundFlatFile, ;
2699 .cInterHeader, .cInterDetail, .cInterComment, .cInterAddress, "tcItemSLN", ;
2700 .cWorkWhsHdr,.cWorkWhsDtl, ;
2701 .cWorkChrgHdr,.cWorkChrgDtl ; && TR 1066790 18-Feb-2013 Partha added .cWorkChrgHdr, .cWorkChrgDtl
2702 ,.cWhseSLN)
2703 * TR 1073471 KISHORE 19-SEP-2013 added .cWhseSLN
2704 &&--- TechRec 1052941 15-Mar-2011 MANI. Added .cWorkWhsHdr,.cWorkWhsDtl parameters ===
2705 ELSE
2706 .oLog.LogEntry("Records not moved to interface table - flat file not created.")
2707 ENDIF
2708 *== TR 1046076 BR
2709
2710 If !llRetVal
2711 .oLog.LogEntry("Unloading to flat file - failed")
2712 Endif
2713
2714 *--For sucessfull creation of flatfile remove all records in Interface views
2715 * there is no history views; use timestamp flatfile for history.
2716 *--- TR 1022506 NH : Use sql delete to clear interface tables.
2717*!* If llRetVal
2718*!* Delete All In (.cInterHeader)
2719*!* Delete All In (.cInterDetail)
2720*!* Delete All In (.cInterComment)
2721*!* Delete All In (.cInterAddress)
2722*!* Endif
2723 *=== TR 1022506 NH
2724 .AdvanceThermo(1)
2725 Endwith
2726 Return llRetVal
2727 Endproc
2728
2729 ************************************************************************************
2730 * UnloadToFlatFile
2731 ***********************************************************************************
2732 Procedure UnLoadToFlatFile
2733 Lparameters tcProcess, tcFlatFile, tcInterfaceHeader, tcInterfaceDetail, ;
2734 tcInterfaceComment, tcInterfaceAddress, tcFinalSLN, tcWhsHdr, tcWhsDtl, ;
2735 tcChrgHdr, tcChrgDtl, ; && TR 1066790 18-Feb-2013 Partha added tcChrgHdr, tcChrgDtl
2736 tcInterfaceWhseSLN
2737 * TR 1073471 KISHORE 19-SEP-2013 added tcInterfaceWhseSLN
2738 *--- TechRec 1052941 15-Mar-2011 MANI. Added tcWhsHdr, tcWhsDtl ===
2739 Local llRetVal, lcSQLString
2740 *--- TR 1014084 NH 2005/11/18
2741 Local lnHandle
2742 lnHandle = 0
2743 *=== TR 1014084 NH 2005/11/18
2744 llRetVal= .F.
2745 *--- TR 1022506 - NH
2746 lcLocalFlatFile = SYS(5) + CURDIR() + SYS(2015) + JUSTFNAME(tcFlatFile)
2747 *=== TR 1022506 - NH
2748
2749
2750 *--- 1026397
2751 LOCAL lcServerTempFile
2752 lcServerTempFile = ""
2753 *=== 1026397
2754
2755 With This
2756 *--Get Metadata for vendor table
2757 If .GetTranslationDefinition(EDI_ALL_TRANSACTION, "tcEmVend")
2758 *--Get Metadata for a process
2759 If .GetTranslationDefinition(tcProcess, "tcEmData")
2760 *--Creating Metadata work tables
2761 .CreateMetaDataWorkTable("tcEmVend", "VENDOR", "tcoowVND")
2762 .CreateMetaDataWorkTable("tcEmData", "HEADER", "tcoowHDR")
2763 .CreateMetaDataWorkTable("tcEmData", "CARTON", "tcoowCRT")
2764 .CreateMetaDataWorkTable("tcEmData", "COMMENT", "tcoowCMT")
2765 .CreateMetaDataWorkTable("tcEmData", "ADDRESS", "tcoowADR")
2766 .CreateMetaDataWorkTable("tcEmData", "DETAIL", "tcoowDTL")
2767 *- 1011923 10/05/05 YIK
2768 *- Add SLNs
2769 .CreateMetaDataWorkTable("tcEmData", "SLN", "tcoowSLN")
2770 *=
2771 *--- TR 1015369 NH : Added file HDRNOTES
2772 .CreateMetaDataWorkTable("tcEmData", "HDRNOTES", "tcoowHNT")
2773 *=== TR 1015369 NH
2774
2775 *--- TechRec 1024842 09-Oct-2007 jjanand ---
2776 .CreateMetaDataWorkTable("tcEmData", "DNT", "tcoowDNT")
2777 *=== TechRec 1024842 09-Oct-2007 jjanand ===
2778
2779 *--- TechRec 1052941 15-Mar-2011 MANI. ---
2780 .CreateMetaDataWorkTable("tcEmData", "EDIH", "tcoowEDIH")
2781 .CreateMetaDataWorkTable("tcEmData", "EDID", "tcoowEDID")
2782 *=== TechRec 1052941 15-Mar-2011 MANI. ===
2783
2784 *--- TR 1073471 KISHORE 19-SEP2-2013
2785 .CreateMetaDataWorkTable("tcEmData", "EDIS", "tcoowEDIS")
2786 SELECT tcoowEDIS
2787 INDEX ON fkey+sln_line TAG sln_line
2788 *=== TR 1073471 KISHORE 19-SEP2-2013
2789
2790 *--- TR 1066790 13-Feb-2013 Partha ---
2791 .CreateMetaDataWorkTable("tcEmData", "CHGH", "tcoowCHGH")
2792 .CreateMetaDataWorkTable("tcEmData", "CHGD", "tcoowCHGD")
2793 *=== TR 1066790 13-Feb-2013 Partha ===
2794
2795 * remove previous tmp text file
2796 *--- TR 1014084 NH 2005/11/18
2797 *--- TR 1066223 01-08-2013 RKI ---*
2798*!* If Not .Tie_setup
2799*!* *--- TR 1022506 - NH
2800*!* *lcTempFlatfile= STRTRAN(UPPER(tcFlatFile), ".DAT", ".TMP")
2801*!* lcTempFlatfile = Strtran(Upper(lcLocalFlatFile),".DAT", ".TMP")
2802*!* *=== TR 1022506 - NH
2803*!* Delete File (lcTempFlatfile)
2804*!* lnHandle= .OpenFlatFile(lcTempFlatfile, True)
2805 lnHandle=0
2806*!* ENDIF
2807 *=== TR 1066223 01-08-2013 RKI ===*
2808 *=== TR 1014084 NH
2809 *--- TR 1066223 01-08-2013 RKI ---*
2810*!* If .Tie_setup Or lnHandle> 0
2811 *=== TR 1066223 01-08-2013 RKI ===*
2812 *--Populating data to metadata work detail tables from interface views
2813 .ScatterGather(tcInterfaceHeader, "tcoowHDR")
2814 .ScatterGather(tcInterfaceDetail, "tcoowDTL")
2815 .ScatterGather(tcInterfaceComment, "tcoowCMT")
2816 .ScatterGather(tcInterfaceAddress, "tcoowADR")
2817 *--- TR 1015369 NH
2818 .GetHDRNotesFromSysNotes(tcInterfaceHeader,"tcoowHNT")
2819 *=== TR 1015369 NH
2820
2821 *--- TechRec 1024842 09-Oct-2007 jjanand ---
2822 .GetDNTNotesFromSysNotes(tcInterfaceDetail,"tcoowDNT")
2823 *=== TechRec 1024842 09-Oct-2007 jjanand ===
2824
2825 *- 1011923 10/05/05 YIK
2826 If Used(tcFinalSLN)
2827 .ScatterGather(tcFinalSLN, "tcOOWSLN")
2828 ENDIF
2829
2830 *--- TechRec 1052941 15-Mar-2011 MANI. ---
2831 IF USED(tcWhsHdr)
2832 .ScatterGather(tcWhsHdr, "tcoowEDIH")
2833 ENDIF
2834
2835 IF USED(tcWhsDtl)
2836 .ScatterGather(tcWhsDtl, "tcoowEDID")
2837 ENDIF
2838 *=== TechRec 1052941 15-Mar-2011 MANI. ===
2839
2840 *--- TR 1066790 13-Feb-2013 Partha ---
2841 IF USED(tcChrgDtl)
2842 .ScatterGather(tcChrgDtl, "tcoowCHGD")
2843 ENDIF
2844 IF USED(tcChrgHdr)
2845 .ScatterGather(tcChrgHdr, "tcoowCHGH")
2846 ENDIF
2847 *=== TR 1066790 13-Feb-2013 Partha ===
2848
2849 *--- TR 1073471 KISHORE 19-SEP-2013
2850 IF USED(tcInterfaceWhseSLN)
2851 .ScatterGather(tcInterfaceWhseSLN, "tcoowEDIS")
2852 ENDIF
2853 *=== TR 1073471 KISHORE 19-SEP-2013
2854
2855 *--Creating temp flatfile (940.TMP)
2856 *--- TR 1015369 02/03/06 NH : Added param "tcoowHNT"
2857 *--- TechRec 1024842 10-Oct-2007 jjanand --- Added param "tcoowDNT"
2858*!* llRetVal= .CreateFlatfileFromMetadata(tcProcess, .cControlReference,;
2859*!* "tcoowVND", "tcoowHDR", "tcoowDTL", "tcoowCMT", "tcoowADR", ;
2860*!* "tcoowCRT", "tcoowSLN", lnHandle,"tcoowHNT") &&
2861
2862 llRetVal= .CreateFlatfileFromMetadata(tcProcess, .cControlReference,;
2863 "tcoowVND", "tcoowHDR", "tcoowDTL", "tcoowCMT", "tcoowADR", ;
2864 "tcoowCRT", "tcoowSLN", lnHandle,"tcoowHNT","tcoowDNT", ;
2865 "tcoowEDIH", "tcoowEDID", ; && *--- TechRec 1052941 15-Mar-2011 MANI. Added tcoowEDIH, tcoowEDIH parameters ===
2866 "tcoowCHGH", "tcoowCHGD" ; && TR 1066790 13-Feb-2013 Partha added "tcoowCHGH", "tcoowCHGD"
2867 ,"tcoowEDIS" ; && TR 1073471 KISHORE 19-SEP-2013
2868 )
2869 *=== TechRec 1024842 10-Oct-2007 jjanand ===
2870
2871 *--- TR 1014084 NH
2872 IF lnHandle > 0
2873 Fclose(lnHandle)
2874 ENDIF
2875 *=== TR 1014084 NH
2876 If !llRetVal
2877 .oLog.LogEntry("Creating Flat file from Metadata - failed")
2878 Endif
2879 *--Appending 940.TMP to live 940.dat file
2880 *--- TR 1066223 01-16-2013 RKI ---*
2881*!* If Not .Tie_setup AND llRetVal
2882 IF llRetVal
2883 *=== TR 1066223 01-16-2013 RKI ===*
2884 *--- TR 1022506 - NH
2885 *--- TR 1026397 NH
2886 *IF FILE(tcFlatFile)
2887 *COPY FILE (tcFlatFile) TO (lcLocalFlatFile)
2888 *ENDIF
2889 *.LogEntry("Copy file from " + tcFlatFile + " to " + lcLocalFlatFile + " completed.")
2890 *llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile, tcFlatFile)
2891 *llRetVal=.CopyToFlatFileInBlock(lcTempFlatfile, lcLocalFlatFile)
2892 *.LogEntry("Copying to flat file in block from " + lcTempFlatfile + " to " + lcLocalFlatFile + IIF(llRetVal," completed."," failed."))
2893 *=== TR 1022506 - NH
2894*!* If !llRetVal
2895*!* .oLog.LogEntry("Copying to flat file - failed")
2896*!* ENDIF
2897*!* lcServerTempFile = STRTRAN(UPPER(tcFlatFile),".DAT",".TMP")
2898*!* lcServerTempFile = STRTRAN(UPPER(lcOutBoundFlatFile),".DAT",".TMP")
2899*!* llRetVal = llRetVal and this.AppendToServerFlatFile(lcTempFlatfile,tcFlatFile,lcServerTempFile)
2900 *--- TR TR 1066223 01-16-2013 RKI ---*
2901
2902*!* lcServerTempFile = STRTRAN(UPPER(tcFlatFile),".DAT",".TMP")
2903*!* llRetVal = llRetVal and this.AppendToServerFlatFile(lcTempFlatfile,tcFlatFile,lcServerTempFile)
2904 *=== TR 1066223 01-16-2013 RKI ===*
2905 .LogEntry("Copy flat file to server " + IIF(llRetVal, "completed.","failed."))
2906 *--- TR 1022506 - NH
2907 *COPY FILE (lcLocalFlatFile) TO (tcFlatFile)
2908 *.LogEntry("Copy file from " + lcLocalFlatFile + " to " + tcFlatFile + " completed.")
2909 *=== TR 1022506 - NH
2910 *=== TR 1026397 NH
2911 Endif
2912*!* Endif && TR 1066223 01-08-2013 RKI
2913 Endif
2914 Endif
2915 .Tableclose('tcEmVend')
2916 .Tableclose('tcEmData')
2917 .Tableclose('tcoowVND')
2918 .Tableclose('tcoowHDR')
2919 .Tableclose('tcoowDTL')
2920 .Tableclose('tcoowCMT')
2921 .Tableclose('tcoowADR')
2922 .Tableclose('tcoowCRT')
2923 *- 1011923 10/05/05 YIK
2924 .Tableclose('tcoowSLN')
2925
2926 *- 1017241 07/25/06 YIK
2927 .Tableclose("tcCustSLN")
2928 .Tableclose("tcItemSLN")
2929 .Tableclose("tcSLN")
2930
2931 *--- TechRec 1052941 15-Mar-2011 MANI. ---
2932 .TableClose("tcoowEDIH")
2933 .TableClose("tcoowEDID")
2934 *=== TechRec 1052941 15-Mar-2011 MANI. ===
2935
2936 Endwith
2937 If !llRetVal
2938 .oLog.LogEntry("Unloading to flat file - failed")
2939 Endif
2940
2941 Return llRetVal
2942 Endproc
2943
2944 *--- TR 1026397 NH
2945
2946 ************************************************************************************
2947
2948 PROCEDURE AppendToServerFlatFile
2949 LPARAMETERS tcLocalFiles, tcServerFlatFile,tcServerTempFile
2950
2951 LOCAL llRetval
2952 llRetval = .T.
2953 IF FILE("AppendToServerFlatFile.prg") OR FILE("AppendToServerFlatFile.fxp")
2954 AppendToServerFlatFile(tcLocalFiles, tcServerFlatFile, tcServerTempFile)
2955 ELSE
2956 llRetVal = .f.
2957 ENDIF
2958
2959 RETURN llRetval
2960 ENDPROC
2961
2962 *=== TR 1026397 NH
2963
2964 *--- TR 1015369 02/03/06 NH
2965 ***********************************************************************************
2966
2967 PROCEDURE GetHDRNotesFromSysNotes
2968 LPARAMETERS tcInterfaceHeader,tcHNT
2969 LOCAL llRetVal, lnOldSelect, lcSQL, lcHNT
2970 lnOldSelect = SELECT()
2971 llRetVal = .t.
2972 this.oLog.LogEntry("Starting program : " + PROGRAM())
2973 CREATE CURSOR tcHdrPkey (pkey i, ORD_NUM i, PICK_NUM I)
2974 SELECT(tcInterfaceHeader)
2975 SCAN
2976 SCATTER FIELDS pkey, ORD_NUM, PICK_NUM memvar
2977 SELECT("tcHdrPkey")
2978 APPEND BLANK
2979 GATHER memvar
2980 ENDSCAN
2981 WITH THIS
2982 .cSQLTempTable = ""
2983 this.oLog.LogEntry(IIF(RECCOUNT("tcHdrPkey")>0,transform(RECCOUNT("tcHdrPkey")),"No ") + " Header Notes found.")
2984 IF RECCOUNT("tcHdrPkey") > 0
2985 .cSQLTempTable = ""
2986 lcHNT_tmp = SYS(2015)
2987 IF .GenerateSQLTempTable('tcHdrPkey') AND .PopulateSQLTempTable('tcHdrPkey')
2988
2989 *--- TechRec 1024842 11-Oct-2007 jjanand ---
2990*!* lcSQL = "SELECT t.pkey as fkey_940, t.pick_num, n.* " +;
2991 " from sysnotes n inner join zzoordrh h on h.ord_num = n.ord_num and n.table_name = 'ZZOORDRH'" +;
2992 " INNER JOIN " + .cSQLTempTable + " t ON h.ord_num = t.ord_num and h.pick_num = t.pick_num "
2993 &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === Changed zzeoowcr to zzeoowcr_expl
2994 lcSQL = "select tc.pkey as fkey_940, p.pick_num, p.ord_num, n.Notes, n.Note_type " +;
2995 " from ZZOORDRH p " +;
2996 " join " + .cSQLTempTable + " tc ON p.ord_num = tc.ord_num and p.pick_num = tc.pick_num " +;
2997 " join SysNotes n " +;
2998 " on n.Table_Name = 'ZZOORDRH' " +;
2999 " and n.ord_num = p.ord_num " +;
3000 " and n.line_seq = 0 " +;
3001 " join zzxNoTyp t " +;
3002 " on t.Note_Type = n.Note_Type " +;
3003 " join zzeoowcr_expl w " +;
3004 " on w.ware_code = p.location " +;
3005 " and w.active_ok = 'Y' " +;
3006 " and ((w.HDR_notes = 'E' and t.EDI_Note = 'Y') or w.HDR_notes = 'Y') "
3007
3008 *=== TechRec 1024842 11-Oct-2007 jjanand ===
3009
3010 llRetVal = llRetVal and .vSQLExec(lcSQL, lcHNT_tmp)
3011 .ConvertMultiLineNotesToRows(lcHNT_tmp,tcHNT)
3012 IF llRetVal
3013 SELECT(tcHNT)
3014 INDEX ON fkey TAG fkey
3015 ENDIF
3016 ELSE
3017 .oLog.LogEntry("Warning: Unable to create header notes temp table.")
3018 ENDIF
3019 ENDIF
3020 .oLog.LogEntry("Header notes preparation " + IIF(llRetVal,"successful.","failed."))
3021 ENDWITH
3022
3023 SELECT(lnOldSelect)
3024 RETURN llRetVal
3025 ENDPROC
3026
3027 PROCEDURE ConvertMultiLineNotesToRows
3028 LPARAMETERS tcSrc, tcDest
3029 LOCAL llRetVal, lnOldSelect, lcNotes
3030 lnOldSelect = SELECT()
3031 llRetVal = .t.
3032 SELECT(tcSrc)
3033 SCAN
3034 SCATTER memvar memo
3035 m.fkey = m.fkey_940
3036 lcNotes = m.Notes
3037 SELECT(tcDest)
3038 FOR lnNoteCnt = 1 TO MEMLINES(lcNotes)
3039 m.Notes = MLINE(lcNotes,lnNoteCnt)
3040 IF NOT EMPTY(m.Notes)
3041 APPEND BLANK
3042 GATHER MEMVAR memo
3043 ENDIF
3044 ENDFOR
3045 ENDSCAN
3046 SELECT(lnOldSelect)
3047 RETURN llRetVal
3048 ENDPROC
3049
3050 *=== TR 1015369 02/03/06 NH
3051
3052 ************************************************************************************
3053 * group all records from metadata work tables to a flat text file
3054 * break header record by division
3055 ***********************************************************************************
3056 *--- TR 1015369 02/03/06 NH added param tcWorkHNT
3057 Procedure CreateFlatfileFromMetadata
3058 Lparameter tcProcess, tcControl, tcWorkVendor, tcWorkHeader, tcWorkDetail, tcWorkComment,;
3059 tcWorkAddress, tcWorkCarton, tcWorkSLN, pnHandle, tcWorkHNT , tcWorkDNT, ; && 1011923 10/05/05 YIK - added tcWorkSLN
3060 tcWhsHdr, tcWhsDtl, ; &&--- TechRec 1052941 15-Mar-2011 MANI. Added tcWhsHdr, tcWhsDtl parameter ===
3061 tcChrgHdr, tcChrgDtl, ; && TR 1066790 13-Feb-2013 Partha added tcChrgHdr, tcChrgDtl
3062 tcFinalEDIS && TR 1073471 KISHORE 19-SEP-2013
3063 *--- TechRec 1024842 10-Oct-2007 jjanand ---Added param tcWorkDNT
3064
3065 *--- TR 1010079 VSS/SHAN 22-Apr-2005
3066 *-- Added local variable lcProc_856
3067 Local llRetVal, lnOldSelect, lcPreviousDivision, lcMac, lcString, lcVendorStr, lcOrd_num,lnPicknum, lcProc_856
3068 llRetVal= .T.
3069
3070 *--- TR 1014084 NH
3071 Local lnHandle, lcEDIPath,lcTempFlatfile, lcOutBoundFlatFile
3072 Store "" To lcTempFlatfile, lcOutBoundFlatFile
3073 lcEDIPath = This.GetEDIFlatFileDirectory("Outbound")
3074 lnHandle = 0
3075 *--- TR 1066223 01-16-2013 RKI ---*
3076 lcOutBoundFlatFile = lcEDIPath + EDI_OOW_FILENAME
3077 *=== TR 1066223 01-16-2013 RKI ===*
3078* lcOutBoundFlatFile = lcEDIPath + EDI_OOW_FILENAME
3079 *--- TechRec 1024842 17-Oct-2007 jjanand ---
3080 LOCAL lcCurrDNTItemPkey, lcHdrord_num , lnDtlPkey
3081 *--- TechRec 1052941 15-Mar-2011 MANI. Added lcHdrord_num, lnDtlPkey ===
3082 *=== TechRec 1024842 17-Oct-2007 jjanand ===
3083
3084
3085 LOCAL llLocationChanged, lcPrevLocation, lcPrevWhse_type, lcPrevVnd_id
3086 llLocationChanged = .f.
3087 lcPrevLocation = ""
3088 lcPrevWhse_type = ""
3089 lcPrevVnd_id = ""
3090 *=== TR 1014084 NH
3091
3092 LOCAL llHaveChrgDetail,llHaveChrgHeader && TR 1066790 13-Feb-2013 Partha
3093
3094 * TAN 31891 - JAZ - 5/20/02
3095 * llHaveAddress= (recc(tcWorkAddress)>0)
3096 * llHaveComment= (recc(tcWorkComment)>0)
3097 llHaveAddress= (This.CountTotalRecs (tcWorkAddress)>0)
3098 llHaveComment= (This.CountTotalRecs (tcWorkComment)>0)
3099 * End TAN 31891 - JAZ - 5/20/02
3100 *- 1011923 10/05/05 YIK
3101 If Used(tcWorkSLN)
3102 .lHaveSLN = (This.CountTotalRecs (tcWorkSLN)>0)
3103 Endif
3104 *=
3105
3106 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3107 IF USED(tcWhsHdr)
3108 llHaveWhsHDr = (This.CountTotalRecs (tcWhsHdr) > 0)
3109 ENDIF
3110
3111 IF USED(tcWhsDtl)
3112 llHaveWhsDtl = (This.CountTotalRecs (tcWhsDtl) > 0)
3113 ENDIF
3114 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3115
3116 *--- TR 1066790 13-Feb-2013 Partha ---
3117 IF USED(tcChrgDtl)
3118 llHaveChrgDetail = (This.CountTotalRecs (tcChrgDtl) > 0)
3119 ENDIF
3120 IF USED(tcChrgHdr)
3121 llHaveChrgHeader = (This.CountTotalRecs (tcChrgHdr) > 0)
3122 ENDIF
3123 *=== TR 1066790 13-Feb-2013 Partha ===
3124
3125 *--- TR 1073471 KISHORE 19-SEP-2013
3126 LOCAL llHaveEDIS
3127 IF USED(tcFinalEDIS)
3128 llHaveEDIS = USED(tcFinalEDIS) AND (This.CountTotalRecs(tcFinalEDIS) > 0)
3129 ENDIF
3130 *=== TR 1073471 KISHORE 19-SEP-2013
3131
3132 Store "" To lcPreviousDivision, lcString
3133 lnOldSelect= Select()
3134
3135 Select (tcWorkComment)
3136 Index On fkey Tag fkey
3137 Select (tcWorkAddress)
3138 Index On fkey Tag fkey
3139 Select (tcWorkDetail)
3140 Index On fkey Tag fkey
3141 *- 1011923 10/10/05 YIK
3142 Select (tcWorkSLN)
3143 Index On ITM_pkey Tag pkey
3144 *=
3145
3146 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3147 SELECT (tcWhsHdr)
3148 INDEX ON Ord_Num TAG Ord_Num
3149 SELECT (tcWhsDtl)
3150 INDEX ON Fkey TAG WhsDtlTag
3151 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3152
3153 *--- TR 1066790 18-Feb-2013 Partha ---
3154 SELECT (tcChrgHdr)
3155 INDEX ON Ord_num + Pick_num TAG ordpick
3156 SELECT (tcChrgDtl)
3157 INDEX ON fkey TAG fkey
3158 *=== TR 1066790 18-Feb-2013 Partha ===
3159
3160 *--- TR 1066223 01-08-2013 RKI ---*
3161 LOCAL lcAltFileName, lcPrevAltFileName
3162 lcAltFileName = ""
3163 lcPrevAltFileName = ""
3164 *=== TR 106622301-08-2013 RKI ===*
3165
3166 LOCAL lcHdrOrdPick_num, lcDtl_Pkey && TR 1066790 13-Feb-2013 Partha
3167
3168 With This
3169 .InitThermo(1)
3170 .UpdateThermoCaption("Unloading data to flat file...")
3171 .oLog.LogEntry("Creating flat file from metadata")
3172
3173 *--Output Vendor string ("VND",TradingPartnerID,Transaction,Version)
3174 * TAN 31891 - JAZ - 5/20/02
3175 * If Used(tcControl) and Recc(tcWorkHeader)>0 && something to output
3176 If Used(tcControl) And This.CountTotalRecs (tcWorkHeader)>0 && something to output
3177 * End TAN 31891 - JAZ - 5/20/02
3178 *!* Appen blank
3179 *!* Replace vnd_tran with tcProcess,vnd_id with &tcControl..vnd_id, ;
3180 *!* vnd_vers with &tcControl..vnd_vers In (tcWorkVendor)
3181
3182 *!* * TAN 29385 EAC 11/21/01 - 940 Metadata must write 1 VND record for each Order
3183 *!* *lcString = lcString + EDI_VENDOR_TAG + .ConvertRecordToText(tcWorkVendor)
3184 *!* lcVendorStr = EDI_VENDOR_TAG + .ConvertRecordToText(tcWorkVendor)
3185 lcString = ""
3186 * TAN 29385 End
3187
3188 Select (tcWorkHeader)
3189
3190 *--- TR 1040807 NSD 6/26/09
3191 * Process sorts by location + whse type when outputting for TIE.
3192 *Index On location Tag location
3193 Index On location+whse_type Tag location
3194 *=== TR 1040807 NSD 6/26/09
3195
3196 * TAN 31891 - JAZ - 5/20/02
3197 * lnMax= Recc(tcWorkHeader)
3198 lnMax= This.CountTotalRecs (tcWorkHeader)
3199 * End TAN 31891 - JAZ - 5/20/02
3200 lnCnt= 0
3201 Scan
3202 *---TR 1009127 22-FEB-05 KA
3203 *l_cSQLString = "SELECT * FROM zzeoowcr WHERE ware_code = '" + &tcWorkHeader..location + "'"
3204 *- 1010168 03/28/05 YIK
3205 *- We do not need to re-resolve prepack here.
3206 *- We populated header field whse_type with .cType in CheckTypeInDetail()
3207 *- Added whse_type to zzemdata.
3208 *- lnPicknum = VAL(pick_num)
3209 *- llRetval = .ResolvePrePack(lnPicknum)
3210 *- l_cSQLString = "SELECT * FROM zzeoowcr WHERE ware_code = '" + &tcWorkHeader..location + "'" +;
3211 * " AND type ='"+.cType+"'"
3212 *===TR 1009127 22-FEB-05 KA
3213 *--- TR 1014084 NH 2005/11/18
3214 llLocationChanged = not (lcPrevLocation == EVALUATE(tcWorkHeader + ".location"))
3215 *--- TR 1066223 01-16-2013 RKI ---* && Added lcAltFileName condition
3216 IF NOT (lcPrevLocation == EVALUATE(tcWorkHeader + ".location") AND lcPrevWhse_type == Evaluate(tcWorkHeader + ".whse_type") ;
3217 or !(lcAltFileName == lcPrevAltFileName))
3218
3219 lcPrevLocation = EVALUATE(tcWorkHeader + ".location")
3220 lcPrevWhse_type = Evaluate(tcWorkHeader + ".whse_type")
3221 *=== TR 1014084 NH
3222
3223 *--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ---
3224*!* l_cSQLString = "SELECT * FROM zzeoowcr WHERE ware_code = '" + &tcWorkHeader..location + "'" +;
3225*!* " AND (type = '" + Evaluate(tcWorkHeader + ".whse_type") + "' OR type = 'B')"
3226
3227 l_cSQLString = "SELECT * FROM zzeoowcr_expl WHERE ware_code = '" + &tcWorkHeader..location + "'" +;
3228 " AND (type = '" + Evaluate(tcWorkHeader + ".whse_type") + "' OR type = 'B')"
3229 *=== TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
3230
3231 *= 1010168
3232 =v_SqlExec(l_cSQLString, "_oowcr")
3233
3234 *--- TR 1066223 01-08-2013 RKI ---*
3235 lcAltFileName = ALLTRIM(UPPER(_oowcr.alt_file_Name))
3236 *=== TR 1066223 01-16-2013 RKI ===*
3237 If Used("_oowcr")
3238 Select (tcWorkVendor)
3239 Appen Blank
3240 Replace vnd_tran With tcProcess,vnd_id With _oowcr.vnd_id, ;
3241 vnd_vers With _oowcr.vnd_vers In (tcWorkVendor)
3242 Select (tcWorkHeader)
3243 ENDIF
3244
3245 *--- TR 1065007 14-Feb-2014 Goutam
3246 .UpdateUOMHeader(tcWorkHeader, "_oowcr")
3247 *=== TR 1065007 14-Feb-2014 Goutam
3248
3249 *--- Create file handle
3250 *--- TR 1010899 NH
3251 If .Tie_setup
3252 If lnHandle > 0
3253 Fclose(lnHandle)
3254 *--- TR 1026397 NH
3255 *--- Make a local temp file instead of sever temp file.
3256 *lcTempFlatfile = STRTRAN(lcOutBoundFlatFile,".DAT",".TMP")
3257 *--- Write to local temp file.
3258 *--- copy the local temp file to server
3259 *--- delete local temp file.
3260 *--- append server temp file to vnd_id940.dat
3261 *=== TR 1026397 NH
3262 *lcTempFlatfile= Strtran(Upper(lcOutBoundFlatFile), ".DAT", ".TMP")
3263*!* llRetVal = llRetVal and .CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
3264*!* this.LogEntry("Copy in blocks from " + lcTempFlatfile + " file to " + lcOutBoundFlatFile) && TR 1022506 NH
3265 lcServerTempFile = STRTRAN(lcOutBoundFlatFile, ".DAT",".TMP")
3266 llRetVal = llRetVal and this.AppendToServerFlatFile(lcTempFlatfile,lcOutBoundFlatFile,lcServerTempFile)
3267 Endif
3268
3269 *- new flat file name
3270 *--- TR 1022506 - NH
3271 lcOutBoundFlatFile = lcEDIPath + Alltrim(Evaluate(tcWorkVendor + ".vnd_id")) + "940.DAT"
3272 *lcOutBoundFlatFile = SYS(5) + CURDIR() + SYS(2015) + Alltrim(Evaluate(tcWorkVendor + ".vnd_id")) + "940.DAT"
3273 *=== TR 1022506 - NH
3274 *--- TR 1026397
3275 *--- lcOutBoundFlatFile
3276 *lcTempFlatfile = Strtran(Upper(lcOutBoundFlatFile), ".DAT", ".TMP")
3277 lcTempFlatfile = SYS(5) + CURDIR() + JUSTFNAME(lcOutBoundFlatFile)
3278 lcTempFlatfile = STRTRAN(lcTempFlatfile,".DAT",".TMP")
3279 *=== TR 1026397
3280 *--- making sure lcTempFlatfile does not exists
3281 Delete File (lcTempFlatfile)
3282 lnHandle = .OpenFlatFile(lcTempFlatfile, .T.)
3283 If lnHandle <= 0
3284 Loop
3285 Endif
3286
3287 *--- TR 1066223 01-16-2013 RKI ---*
3288 ELSE
3289 If lnHandle > 0
3290 * A file is open. close it. add it to flat file list.
3291 FClose(lnHandle)
3292 If llRetVal
3293
3294 IF !(lcAltFileName == lcPrevAltFileName)
3295 lcServerTempFile = STRTRAN(lcOutBoundFlatFile, ".DAT",".TMP")
3296 llRetVal = llRetVal and this.AppendToServerFlatFile(lcTempFlatfile,lcOutBoundFlatFile,lcServerTempFile)
3297 ELSE
3298 llRetVal = llRetVal and .CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
3299 ENDIF
3300 EndIf
3301 EndIf
3302
3303 IF EMPTY(lcAltFileName)
3304 lcOutBoundFlatFile = lcEDIPath + EDI_OOW_FILENAME
3305 *lcTempFlatfile= Strtran(Upper(lcOutBoundFlatFile), ".DAT", ".TMP")
3306 ELSE
3307 *- new flat file name
3308 lcOutBoundFlatFile = lcEDIPath + ALLTRIM(UPPER(lcAltFileName)) +".DAT"
3309 *lcTempFlatfile= Strtran(Upper(lcOutBoundFlatFile), ".DAT", ".TMP")
3310 ENDIF
3311 lcOutBoundFlatFile = UPPER(ALLTRIM(lcOutBoundFlatFile))
3312 lcTempFlatfile = SYS(5) + CURDIR() + JUSTFNAME(UPPER(ALLTRIM(lcOutBoundFlatFile)))
3313 lcTempFlatfile = STRTRAN(lcTempFlatfile,".DAT",".TMP")
3314 *- TR 1086421 FH - took out if statement. read dev note.
3315 *IF !(lcAltFileName == lcPrevAltFileName)
3316 Delete File (lcTempFlatfile)
3317 *endif
3318 lnHandle = .OpenFlatFile(lcTempFlatfile, .T.)
3319 If lnHandle <= 0
3320 Loop
3321 ENDIF
3322 *=== TR 1066223 01-16-2013 RKI ===*
3323 ENDIF && TR 1014084 NH
3324 *=== TR 1010899 NH
3325
3326 ENDIF && TR 1014084 NH
3327
3328 * TAN 29385 EAC 11/21/01 - 940 Metadata must write 1 VND record for each Order
3329 *lcString = lcString + EDI_VENDOR_TAG + .ConvertRecordToText(tcWorkVendor)
3330 *- 1009713 3/3/05 YIK
3331 *- lcVendorStr = EDI_VENDOR_TAG + .ConvertRecordToText(tcWorkVendor)
3332 llDelimited = (_oowcr.EDI_Format = 'D')
3333 lcDelimiter = Iif(llDelimited, _oowcr.EDI_Delim, "")
3334 lcVendorStr = EDI_VENDOR_TAG + lcDelimiter + .ConvertRecordToText(tcWorkVendor, llDelimited, lcDelimiter)
3335 *==
3336
3337 * TAN 29385 EAC 11/21/01 - 940 Metadata must write 1 VND record for each Order
3338 *--- TR 1015001 NH remove special logic for VND string writing for TIE setup
3339*!* IF .Tie_setup
3340*!* IF (lcPrevVnd_id <> Evaluate(tcWorkVendor + ".vnd_id")) or llLocationChanged
3341*!* lcString = lcString + lcVendorStr
3342*!* ENDIF
3343*!* ELSE
3344 lcString = lcString + lcVendorStr
3345*!* ENDIF
3346 *=== TR 1015001 NH
3347
3348 *--Output Header string ("HDR"..)
3349 *- 1009713 3/3/05 YIK
3350 *- lcString = lcString + EDI_HEADER_TAG + .ConvertRecordToText(tcWorkHeader)
3351 lcString = lcString + EDI_HEADER_TAG + lcDelimiter + .ConvertRecordToText(tcWorkHeader, llDelimited, lcDelimiter)
3352 lnCurrentPkey= &tcWorkHeader..pkey
3353
3354 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3355 lcHdrord_num = &tcWorkHeader..Ord_num
3356 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3357
3358 *--- TR 1066790 18-Feb-2013 Partha ---
3359 lcHdrOrdPick_num = lcHdrord_num + &tcWorkHeader..Pick_num
3360 *=== TR 1066790 18-Feb-2013 Partha ===
3361
3362 *--Output Comment string "CMT"
3363 If llHaveComment
3364 Select (tcWorkComment)
3365 Scan For fkey = lnCurrentPkey
3366 *- 1009713 03/25/05 YIK
3367 *- lcString = lcString + EDI_COMMENT_TAG + .ConvertRecordToText(tcWorkComment)
3368 lcString = lcString + EDI_COMMENT_TAG + lcDelimiter + .ConvertRecordToText(tcWorkComment, llDelimited, lcDelimiter)
3369 Endscan
3370 Endif
3371
3372 *--- TR 1015369 02/03/06 NH
3373 Select (tcWorkHNT)
3374 IF SEEK(lnCurrentPkey)
3375 SCAN WHILE fkey == lnCurrentPkey
3376 lcString = lcString + "HNT" + lcDelimiter + .ConvertRecordToText(tcWorkHNT, llDelimited, lcDelimiter)
3377 ENDSCAN
3378 ENDIF
3379 *=== TR 1015369 02/03/06 NH
3380
3381 *--Output Addresses string "ADR"
3382 If llHaveAddress
3383 Select (tcWorkAddress)
3384 Scan For fkey = lnCurrentPkey
3385 *- 1009713 03/25/05 YIK
3386 *-lcString = lcString + EDI_ADDRESS_TAG + .ConvertRecordToText(tcWorkAddress)
3387 lcString = lcString + EDI_ADDRESS_TAG + lcDelimiter + .ConvertRecordToText(tcWorkAddress, llDelimited, lcDelimiter)
3388 Endscan
3389 Endif
3390 *- 41192 7/22/03 YIK
3391
3392 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3393 IF llHaveWhsHDr
3394 SELECT (tcWhsHdr)
3395 IF SEEK(lcHdrord_num)
3396 SCAN WHILE ord_num == lcHdrord_num
3397 lcString = lcString + "EDIH" + lcDelimiter + .ConvertRecordToText(tcWhsHdr, llDelimited, lcDelimiter)
3398 ENDSCAN
3399 ENDIF
3400 ENDIF
3401 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3402
3403 *--- TR 1066790 13-Feb-2013 Partha ---
3404 IF llHaveChrgHeader
3405 SELECT (tcChrgHdr)
3406 IF SEEK(lcHdrOrdPick_num)
3407 SCAN FOR ord_num + pick_num == lcHdrOrdPick_num
3408 lcString = lcString + "CHGH" + lcDelimiter + .ConvertRecordToText(tcChrgHdr, llDelimited, lcDelimiter)
3409 ENDSCAN
3410 ENDIF
3411 ENDIF
3412 *=== TR 1066790 13-Feb-2013 Partha ===
3413
3414
3415 *--- TR 1040807 NSD 6/26/09 Convert to Seek/Scan While
3416 Select (tcWorkDetail)
3417 IF SEEK(lnCurrentPkey,tcWorkDetail,"fkey")
3418 Scan WHILE fkey = lnCurrentPkey
3419 IF !Empty(carton_num)
3420 LOOP
3421 ENDIF
3422
3423 *--- TR 1065007 14-Feb-2014 Goutam
3424 .UpdateUOMDetail(tcWorkHeader, tcWorkDetail, "_oowcr")
3425 *=== TR 1065007 14-Feb-2014 Goutam
3426
3427 *- 1009713 03/25/05 YIK
3428 *- lcString = lcString + EDI_ITEM_TAG+ .ConvertRecordToText(tcWorkDetail)
3429
3430 *- 1017241 07/25/06 YIK - Populate PPk/Range indicator:
3431 *- lcString = lcString + EDI_ITEM_TAG+ lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
3432 If .lHaveSLN
3433 lnOldSelect= Select()
3434 lcCurrItemPkey= Evaluate(tcWorkDetail + ".pkey")
3435 *- Select (tcWorkSLN)
3436 If Seek(lcCurrItemPkey, tcWorkSLN, "pkey")
3437 lcPPk_Code = EVALUATE(tcWorkSLN + ".ppk_code")
3438 *- New field ppk_ind in zzemdata DTL
3439 REPLACE PPK_Ind WITH IIF(EMPTY(lcPPk_Code), "R", "P") IN (tcWorkDetail)
3440 lcString = lcString + EDI_ITEM_TAG+ lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
3441 Select (tcWorkSLN)
3442 Scan While ITM_pkey = lcCurrItemPkey
3443 lcString = lcString + EDI_SLN_TAG+ lcDelimiter + .ConvertRecordToText(tcWorkSLN, llDelimited, lcDelimiter)
3444 ENDSCAN
3445 ELSE
3446 lcString = lcString + EDI_ITEM_TAG+ lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
3447 Endif
3448 Select(lnOldSelect)
3449 ELSE
3450 lcString = lcString + EDI_ITEM_TAG+ lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
3451 ENDIF
3452 *==== 1017241
3453
3454 *--- TechRec 1024842 10-Oct-2007 jjanand ---
3455 lcCurrDNTItemPkey= Evaluate(tcWorkDetail + ".pkey")
3456 Select (tcWorkDNT)
3457 IF SEEK(lcCurrDNTItemPkey)
3458 SCAN WHILE fkey == lcCurrDNTItemPkey
3459 lcString = lcString + "DNT" + lcDelimiter + .ConvertRecordToText(tcWorkDNT, llDelimited, lcDelimiter)
3460 ENDSCAN
3461 ENDIF
3462 *=== TechRec 1024842 10-Oct-2007 jjanand ===
3463
3464 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3465 lnDtlPkey = Evaluate(tcWorkDetail + ".pkey")
3466 IF llHaveWhsDtl AND SEEK(lnDtlPkey, tcWhsDtl, 'WhsDtlTag')
3467 SELECT (tcWhsDtl)
3468 SCAN WHILE Fkey == lnDtlPkey
3469 lcString = lcString + "EDID" + lcDelimiter + .ConvertRecordToText(tcWhsDtl, llDelimited, lcDelimiter)
3470 ENDSCAN
3471 ENDIF
3472 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3473
3474 *--- TR 1073471 KISHORE 20-SEP2-13
3475 lnDtlPkey = Evaluate(tcWorkDetail + ".pkey")
3476 IF llHaveEDIS AND SEEK(lnDtlPkey, tcFinalEDIS, 'sln_line')
3477 SELECT (tcFinalEDIS)
3478 SCAN WHILE Fkey == lnDtlPkey
3479 lcString = lcString + "EDIS" + lcDelimiter + .ConvertRecordToText(tcFinalEDIS, llDelimited, lcDelimiter)
3480 ENDSCAN
3481 ENDIF
3482 *=== TR 1073471 KISHORE 20-SEP2-13
3483
3484 *--- TR 1066790 13-Feb-2013 Partha ---
3485 IF llHaveChrgDetail
3486 lcDtl_Pkey = Evaluate(tcWorkDetail + ".Dtl_pkey")
3487 SELECT (tcChrgDtl)
3488 IF SEEK(lcDtl_Pkey)
3489 SCAN FOR fkey == lcDtl_Pkey
3490 lcString = lcString + "CHGD" + lcDelimiter + .ConvertRecordToText(tcChrgDtl, llDelimited, lcDelimiter)
3491 ENDSCAN
3492 ENDIF
3493 ENDIF
3494 *=== TR 1066790 13-Feb-2013 Partha ===
3495
3496 ENDSCAN
3497 ENDIF
3498
3499 *--Output Cartons string "ITM" only when chk_ASN is set.
3500 *- NO, ALWAYS! 41192 YIK
3501 lnOrd_num= &tcWorkHeader..ord_num
3502 lnPick_num= &tcWorkHeader..pick_num
3503 lcChk_ASN= &tcWorkHeader..chk_asn
3504 *- llRetVal= llRetVal and vl_ctnph(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0)
3505 *--- TR 1010079 VSS/SHAN 22-Apr-2005
3506 *!* If llRetVal and vl_ctnph(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0) AND Used('tcCrtHdr')
3507
3508 *--- TR 1040807 NSD 6/26/09
3509 * Check if cached cursor exists. if so use it to avoid a call to order header.
3510 IF USED("tcPickPrePack") AND SEEK(VAL(lnPick_num),"tcPickPrePack","pick_num")
3511 lcProc_856 = ALLTRIM(tcPickPrePack.proc_856)
3512 ELSE
3513 lcProc_856 = vl_ordhdr(lnOrd_num, "proc_856",, lnPick_num, 0)
3514 ENDIF
3515 *=== TR 1040807 NSD 6/26/09
3516
3517
3518 If lcProc_856 = 'Y'
3519 *- 1010624 04/28/05 YIK
3520 *- We cannot update llRetVal
3521 *-llRetVal = llRetVal AND vl_ctnsh(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0) AND Used('tcCrtHdr')
3522
3523 *--- TR 1040807 NSD 6/26/09
3524 * Carton data may be cached. Use it
3525 IF USED("__zzoctnsh_cache")
3526 USE IN SELECT("tcCrtHdr")
3527 SELECT * FROM __zzoctnsh_cache WHERE pick_num = VAL(lnPick_num) INTO CURSOR tcCrtHdr
3528 ELSE
3529 = vl_ctnsh(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0) And Used('tcCrtHdr')
3530 ENDIF
3531 *=== TR 1040807 NSD 6/26/09
3532
3533 Else
3534 *- llRetVal = llRetVal AND vl_ctnph(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0) AND Used('tcCrtHdr')
3535
3536 *--- TR 1040807 NSD 6/26/09
3537 * Carton data may be cached. Use it
3538 IF USED("__zzoctnph_cache")
3539 USE IN SELECT("tcCrtHdr")
3540 SELECT * FROM __zzoctnph_cache WHERE pick_num = VAL(lnPick_num) INTO CURSOR tcCrtHdr
3541 ELSE
3542 = vl_ctnph(lnOrd_num,, 'tcCrtHdr', lnPick_num, 0) And Used('tcCrtHdr')
3543 ENDIF
3544 *=== TR 1040807 NSD 6/26/09
3545
3546 Endif
3547
3548 If llRetVal
3549 *=== TR 1010079 VSS/SHAN 22-Apr-2005
3550
3551 This.ScatterGather('tcCrtHdr', tcWorkCarton)
3552 Select (tcWorkCarton)
3553 Scan
3554 lcCarton_num = carton_num
3555 *- 1009713 03/25/05 YIK
3556 *- lcString = lcString + EDI_PACK_TAG + .ConvertRecordToText(tcWorkCarton)
3557 lcString = lcString + EDI_PACK_TAG + lcDelimiter + .ConvertRecordToText(tcWorkCarton, llDelimited, lcDelimiter)
3558 *- 41192 7/22/03 YIK
3559 *--Output Detail string - change "DTL" to "ITM"
3560 Select (tcWorkDetail)
3561
3562 *--- TR 1040807 NSD 6/26/09 Convert to SEEK/SCANWHILE
3563 IF SEEK(lnCurrentPkey ,tcWorkDetail,"fkey")
3564 Scan WHILE fkey = lnCurrentPkey
3565 IF carton_num = lcCarton_num
3566 *- lcString = lcString + EDI_DETAIL_TAG+ .ConvertRecordToText(tcWorkDetail)
3567 *- 1009713 03/25/05 YIK
3568 *- lcString = lcString + EDI_ITEM_TAG+ .ConvertRecordToText(tcWorkDetail)
3569 lcString = lcString + EDI_ITEM_TAG + lcDelimiter + .ConvertRecordToText(tcWorkDetail, llDelimited, lcDelimiter)
3570
3571 *--- TechRec 1052941 15-Mar-2011 MANI. ---
3572 lnDtlPkey = pkey
3573 IF llHaveWhsDtl AND SEEK(lnDtlPkey, tcWhsDtl, 'WhsDtlTag')
3574 SELECT (tcWhsDtl)
3575 SCAN WHILE Fkey == lnDtlPkey
3576 lcString = lcString + "EDID" + lcDelimiter + .ConvertRecordToText(tcWhsDtl, llDelimited, lcDelimiter)
3577 ENDSCAN
3578 ENDIF
3579 *=== TechRec 1052941 15-Mar-2011 MANI. ===
3580
3581 *--- TR 1073471 KISHORE 20-SEP2-13
3582 IF llHaveEDIS AND SEEK(lnDtlPkey, tcFinalEDIS, 'sln_line')
3583 SELECT (tcFinalEDIS)
3584 SCAN WHILE Fkey == lnDtlPkey
3585 lcString = lcString + "EDIS" + lcDelimiter + .ConvertRecordToText(tcFinalEDIS, llDelimited, lcDelimiter)
3586 ENDSCAN
3587 ENDIF
3588 *=== TR 1073471 KISHORE 20-SEP2-13
3589
3590 *--- TR 1070910 13-5-2013 VKK
3591 IF llHaveChrgDetail
3592 lcDtl_Pkey = Evaluate(tcWorkDetail + ".Dtl_pkey")
3593 SELECT (tcChrgDtl)
3594 IF SEEK(lcDtl_Pkey)
3595 SCAN FOR fkey == lcDtl_Pkey
3596 lcString = lcString + "CHGD" + lcDelimiter + .ConvertRecordToText(tcChrgDtl, llDelimited, lcDelimiter)
3597 ENDSCAN
3598 ENDIF
3599 ENDIF
3600 *=== TR 1070910 13-5-2013 VKK
3601
3602 ENDIF
3603 ENDSCAN
3604 ENDIF
3605 *=
3606 Endscan
3607 If Used(tcWorkCarton)
3608 Delete All In (tcWorkCarton)
3609 Endif
3610 Else
3611 .oLog.LogEntry("Cannot get cartons")
3612 Endif
3613
3614 *- 41192 7/22/03 YIK
3615 *- moved higher
3616 *--Output Detail string "DTL"
3617 *!* Select (tcWorkDetail)
3618 *!* Scan For fkey = lnCurrentPkey
3619 *!* lcString = lcString + EDI_DETAIL_TAG+ .ConvertRecordToText(tcWorkDetail)
3620 *!* Endscan
3621 *=
3622 If !Empty(lcString)
3623 *- 1002313 12/30/03 YIK
3624 .PrepareEmptyDateForGentran(@lcString)
3625 *=
3626 *--- TR 1014084 NH : Writes all info of each header into flat file
3627 *--- TR 1066223 01-16-2013 RKI ---*
3628*!* If NOT .Tie_setup
3629*!* lnHandle = pnHandle
3630*!* ENDIF
3631 *=== TR 1066223 01-16-2013 RKI ===*
3632 If Fwrite(lnHandle, lcString) = 0
3633 lRetVal = .F.
3634 Exit
3635 ENDIF
3636 lcString = ""
3637 *=== TR 1014084 NH
3638 ENDIF
3639 *--- TR 1014084 NH
3640 lcPrevVnd_id = Evaluate(tcWorkVendor + ".vnd_id")
3641 *=== TR 1014084 NH
3642 *--- TR 1063532 09-10-2012 Neil/RKI ---*
3643 lcPrevAltFileName = ALLTRIM(UPPER(lcAltFileName))
3644 *=== TR 1063532 09-10-2012 Neil/RKI ===*
3645 lnCnt= lnCnt + 1
3646 .AdvanceThermo(lnCnt/lnMax)
3647 ENDSCAN
3648
3649 *--- TR 1014084 NH
3650 *--- following copytoflatfileInBlock is need because program will exit scan before
3651 *--- adding last tempfile header record to .dat file
3652 *--- TR 1066223 01-08-2013 RKI ---*
3653*!* If .Tie_setup And lnHandle > 0
3654 IF lnHandle > 0
3655 *=== TR 1066223 01-08-2013 RKI ===*
3656 *- close previously opened file
3657 Fclose(lnHandle)
3658 If llRetVal
3659 *--- TR 1026397 NH
3660 lcServerTempFile = STRTRAN(lcOutBoundFlatFile, ".DAT",".TMP")
3661 llRetVal = llRetVal and this.AppendToServerFlatFile(lcTempFlatfile,lcOutBoundFlatFile,lcServerTempFile)
3662 *llRetVal = .CopyToFlatFileInBlock(lcTempFlatfile, lcOutBoundFlatFile)
3663 *=== TR 1026397 NH
3664 Endif
3665 Endif
3666 *=== TR 1014084 NH
3667
3668*!* llRetVal= llRetVal And !Empty(lcString) And .PrepareEmptyDateForGentran(@lcString)
3669*!* llRetVal= llRetVal And (Fwrite(pnHandle, lcString)> 0)
3670 Endif
3671 .Tableclose('tcoqgcr')
3672 Endwith
3673 Select(lnOldSelect)
3674 If !llRetVal
3675 .oLog.LogEntry("Creating flat file - failed")
3676 Endif
3677
3678 Return llRetVal
3679 Endproc
3680
3681 *--- TR 1015369 NH
3682 ************************************************************************************
3683 Procedure ConvertSysNotesRecordToText
3684 Lparameter tcTable, tcDelimited
3685
3686 LOCAL lnCnt, lcString, lcOldSele, lcNoteLinePrefix, lcValues, lnMemoCnt, lcMemoLine, lcStringRest
3687 lcDelimited = IIF(EMPTY(tcDelimited),"",tcDelimited)
3688 lcOldSele = Select()
3689 lcString = "HNT"
3690 lcValues = ""
3691 For lnCnt = 1 TO FCOUNT(tcTable)
3692 lcValues = EVAL(FIELD(lnCnt, tcTable))
3693 lcString = lcString + lcDelimited + IIF(EMPTY(lcDelimited), lcValues, TRIM(lcValues))
3694 ENDFOR
3695 Select(lcOldSele)
3696 Return lcString
3697 ENDPROC
3698
3699 *=== TR 1015369 NH
3700 ************************************************************************************
3701 * send all views to server
3702 ************************************************************************************
3703 Procedure TableupdateAllViews
3704 Local llRetVal
3705 llRetVal= .T.
3706 .InitThermo(1)
3707 .UpdateThermoCaption('Sending data to server...')
3708 .oLog.LogEntry("Sending data to server")
3709
3710 *--- TR 1016915 - BD - Use SQL pass-thru instead of views - Remove .cPickHeader from view list
3711 *- 41192 7/23/03 YIK
3712 *- Update SO header.
3713 *--- TR 1022506 NH
3714 *Dime laTables[8]
3715 Dime laTables[4]
3716 laTables[1] = .cTranHeader
3717 laTables[2] = .cTranDetail
3718 laTables[3] = .cTranComment
3719 laTables[4] = .cTranAddress
3720 *--- TR 1022506 NH
3721*!* laTables[5] = .cInterHeader
3722*!* laTables[6] = .cInterDetail
3723*!* laTables[7] = .cInterComment
3724*!* laTables[8] = .cInterAddress
3725 *laTables[9] = .cPickHeader
3726 *=== TR 1016915
3727 IF llRetVal
3728 llBeganTransaction = THIS.BeginTransaction()
3729 IF llBeganTransaction
3730
3731 *--- TR 1040807 NSD 6/26/09
3732 * If using cursors, use cursor tableupdate.
3733 IF .lSQLPassThrough940
3734 llRetVal= llRetVal And .TableUpdateFromCursor(@laTables)
3735 ELSE
3736 llRetVal= llRetVal And .TableUpdateWithTransaction(@laTables)
3737 ENDIF
3738 *--- TR 1040807 NSD 6/26/09
3739
3740 llRetVal = llRetVal and v_sqlexec("delete from zzeoowid " )
3741 llRetVal = llRetVal and v_sqlexec("delete from zzeoowic " )
3742 llRetVal = llRetVal and v_sqlexec("delete from zzeoowia " )
3743 llRetVal = llRetVal and v_sqlexec("delete from zzeoowih " )
3744 IF llRetVal
3745 THIS.EndTransaction()
3746 this.LogEntry("Tranaction Successfully completed.")
3747 ELSE
3748 THIS.RollbackTransaction()
3749 this.LogEntry("Transaction Roll backed")
3750 ENDIF
3751 ELSE
3752 this.LogEntry("Open transaction failed.")
3753 llRetVal = .f.
3754 ENDIF
3755 ENDIF
3756 .AdvanceThermo(1)
3757
3758 this.LogEntry("Sending data to server " + IIF(llRetVal,"completed.","failed."))
3759*!* IF !llRetVal
3760*!* .oLog.LogEntry("Sending data to server - failed")
3761*!* ENDIF
3762 *=== TR 1022506 NH
3763
3764 Return llRetVal
3765 Endproc
3766
3767 ************************************************************************************
3768 * Close all views
3769 ************************************************************************************
3770 Procedure CloseAllViews
3771 llRetVal= .T.
3772
3773 *--- TR 1016915 - BD - Use SQL pass-thru instead of views - Remove .cPickHeader from view list
3774 Dime laTables[8]
3775 laTables[1] = .cTranHeader
3776 laTables[2] = .cTranDetail
3777 laTables[3] = .cTranComment
3778 laTables[4] = .cTranAddress
3779 laTables[5] = .cInterHeader
3780 laTables[6] = .cInterDetail
3781 laTables[7] = .cInterComment
3782 laTables[8] = .cInterAddress
3783 *laTables[9] = .cPickHeader
3784 *laTables[10] = .cPickDetail
3785 *laTables[11] = .cPickComment
3786 *=== TR 1016915
3787 With This
3788 .Tableclose(@laTables, True)
3789 .Tableclose("tceoowth")
3790 .Tableclose("tceoowtd")
3791 .Tableclose("tceoowtc")
3792 .Tableclose("tceoowta")
3793 .Tableclose("zzeoowcr_expl") &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy ===
3794 .Tableclose("tcDummy")
3795 .Tableclose("__TmpCursor")
3796 .Tableclose("tcCommu")
3797 .Tableclose("tmpAddrs")
3798 *--- TR 1016915 - BD - Use SQL pass-thru instead of views - Close .cPickHeader cursor
3799 .Tableclose(.cPickHeader)
3800 .Tableclose(.cPickDetail)
3801 .Tableclose(.cPickComment)
3802 *=== TR 1016915
3803 Endwith
3804 Return llRetVal
3805 Endproc
3806
3807 *- 41192 7/22/03 YIK
3808 Procedure GetCartonNum
3809 Lparameters tcWorkDetail, tcCursor
3810 Local lcStyle, lcColor_code, lcLbl_Code, lcDimension, lnSizeBucket, lcSQLString, llRetVal, ;
3811 lnSelected, lnOrd_num, lnPicknum, lnInvNum, lcDivision, lnline_seq
3812
3813 lnSelected = Select()
3814 lnOrd_num = &tcWorkDetail..ord_num
3815 lnPicknum = &tcWorkDetail..pick_num
3816 lnInvNum = &tcWorkDetail..inv_num
3817 lcDivision = &tcWorkDetail..division
3818 lnline_seq = &tcWorkDetail..line_seq
3819 lcStyle = &tcWorkDetail..Style
3820 lcColor_code = &tcWorkDetail..color_code
3821 lcLbl_Code = &tcWorkDetail..lbl_code
3822 lcDimension = &tcWorkDetail..Dimension
3823 lnSizeBucket = &tcWorkDetail..sizebucket
3824
3825 lcSQLString = "SELECT d.* FROM zzoctnpd d, zzoctnph h, zzoordsp s " + ;
3826 " WHERE s.ord_num = " + SQLFormatNum(lnOrd_num) + ;
3827 " AND s.pick_num = " + SQLFormatNum(lnPicknum) + ;
3828 " AND s.inv_num = " + SQLFormatNum(lnInvNum) + ;
3829 " AND d.division = '" + lcDivision + "'" + ;
3830 " AND d.style = '" + lcStyle + "'" + ;
3831 " AND d.color_code = '" + lcColor_code + "'" + ;
3832 " AND d.lbl_code = '" + lcLbl_Code + "'" + ;
3833 " AND d.dimension = '" + lcDimension + "'" + ;
3834 " AND d.line_seq = " + SQLFormatNum(lnline_seq) + ;
3835 " AND d.sizebucket = " + SQLFormatNum(lnSizeBucket) + ;
3836 " AND s.pkey = h.fkey " + ;
3837 " AND h.pkey = d.fkey"
3838
3839 llRetVal = v_SQLPrep(lcSQLString, tcCursor)
3840 Select (lnSelected)
3841 If !llRetVal
3842 This.oLog.LogEntry("Carton number for pick " + Trans(lnPicknum) + " style " + Alltr(lcStyle) + ;
3843 " color " + Alltr(lcColor_code) + " dim/pk " + Alltr(lcDimension) + " bucket " + ;
3844 TRANS(lnSizeBucket, "99") + " is not found.")
3845 Endif
3846
3847 Return llRetVal
3848 Endproc
3849
3850 *--- 1046782
3851 Procedure GetCartonNum_local
3852 Lparameters tcWorkDetail, tcCursor
3853 Local lcStyle, lcColor_code, lcLbl_Code, lcDimension, lnSizeBucket, lcSQLString, llRetVal, ;
3854 lnSelected, lnOrd_num, lnPicknum, lnInvNum, lcDivision, lnline_seq
3855
3856 lnSelected = Select()
3857 llRetVal = .F.
3858
3859 SELECT (tcWorkDetail)
3860 lnOrd_num = ord_num
3861 lnPicknum = pick_num
3862 lnInvNum = inv_num
3863 lcDivision = division
3864 lnline_seq = line_seq
3865 lcStyle = Style
3866 lcColor_code = color_code
3867 lcLbl_Code = lbl_code
3868 lcDimension = Dimension
3869 lnSizeBucket = sizebucket
3870
3871 USE IN SELECT(tcCursor)
3872
3873 SELECT * FROM __zzoctnpd_cache ;
3874 WHERE pick_num = lnPicknum ;
3875 AND division = lcDivision ;
3876 AND line_seq = lnLine_seq ;
3877 AND style = lcStyle ;
3878 AND color_code = lcColor_code ;
3879 AND lbl_code = lcLbl_Code ;
3880 AND dimension = lcDimension ;
3881 AND sizebucket = lnSizeBucket INTO CURSOR (tcCursor) READWRITE
3882
3883 llRetVal = (USED(tcCursor) AND RECCOUNT(tcCursor)>0)
3884
3885 Select (lnSelected)
3886 If !llRetVal
3887 This.oLog.LogEntry("Carton number for pick " + Trans(lnPicknum) + " style " + Alltr(lcStyle) + ;
3888 " color " + Alltr(lcColor_code) + " dim/pk " + Alltr(lcDimension) + " bucket " + ;
3889 TRANS(lnSizeBucket, "99") + " is not found.")
3890 Endif
3891
3892 Return llRetVal
3893 Endproc
3894 *=== 1046782
3895
3896 Procedure Split
3897 Lparameters tcWorkDetail, tcCursor, tcCount
3898 Local lnTotQty, loDetail, loNewDetail
3899 lnSelected = Select()
3900 Select (tcWorkDetail)
3901 Scatter Name loDetail
3902 lnTotQty = loDetail.total_qty
3903 Select (tcCursor)
3904 lnCounter = 0
3905 lnQty = 0
3906 *- 1005822 06/17/04 YIK
3907 *- All throughout the routine replace lnRatio with total_qty/lnTotQty for the scan
3908 *- and with (lnTotQty - lnQty)/lnTotQty - in the IF later
3909 Scan
3910 lnCounter = lnCounter + 1
3911 lnRatio = &tcCursor..total_qty/lnTotQty
3912 lnTempQty = &tcCursor..total_qty
3913 Select (tcWorkDetail)
3914 If lnCounter = 1
3915 lnQty = &tcCursor..total_qty
3916 Replace total_qty With total_qty*lnQty/lnTotQty, ;
3917 gar_wgt With gar_wgt*lnQty/lnTotQty, ;
3918 cubic With cubic*lnQty/lnTotQty, ;
3919 SizNetExt With SizNetExt*lnQty/lnTotQty, ;
3920 carton_num With &tcCursor..carton_num
3921 Else && create new detail
3922 Append Blank
3923 Gather Name loDetail
3924 Replace pkey With v_NextPkey("ZZEOOWTD"), ;
3925 total_qty With total_qty*lnTempQty/lnTotQty, ;
3926 gar_wgt With gar_wgt*lnTempQty/lnTotQty, ;
3927 cubic With cubic*lnTempQty/lnTotQty, ;
3928 SizNetExt With SizNetExt*lnTempQty/lnTotQty, ;
3929 carton_num With &tcCursor..carton_num
3930 Endif
3931 lnQty = lnQty + total_qty
3932 Select (tcCursor)
3933 Endscan
3934 If lnQty < lnTotQty && not all qty is packed. Add one w/o carton#
3935 lnRatio = (lnTotQty - lnQty)/lnTotQty
3936 Select (tcWorkDetail)
3937 Append Blank
3938 Gather Name loDetail
3939 Replace pkey With v_NextPkey("ZZEOOWTD"), ;
3940 total_qty With total_qty* (lnTotQty - lnQty)/lnTotQty, ;
3941 gar_wgt With gar_wgt*(lnTotQty - lnQty)/lnTotQty, ;
3942 cubic With cubic*(lnTotQty - lnQty)/lnTotQty, ;
3943 SizNetExt With SizNetExt*(lnTotQty - lnQty)/lnTotQty
3944 *= 1005822
3945 Endif
3946 Select (lnSelected)
3947 Endproc
3948
3949 *****************************************************************************************
3950 *--- added param pcFlg 1022506 NH
3951 Procedure FlagProcessOrders
3952 Parameters pcWorkHeader, pcPickHeader, plUnFlg
3953 Local llRetVal , lnOldSelect, ltDatetime, lcUser_id
3954 *--- TR 1016915 - BD - Use SQL pass-thru instead of views
3955 LOCAL lcLast_Mod,lcSQLString
3956 *=== TR 1016915
3957 This.oLog.LogEntry("Flagging Processed Orders")
3958 *--- TR 10122506 - NH
3959
3960 llRetVal= .T.
3961 *ltDatetime= Datetime()
3962 lcLast_Mod = SQLFormatTS(DATETIME())
3963 lcUser_id= "'" + goEnv.EnvLogin.cUserName + "'"
3964 lnOldSelect = Select()
3965*!* If Used(pcWorkHeader) And Used(pcPickHeader)
3966*!* llRetVal= This.SetRelation(pcWorkHeader, "OrdPick", pcPickHeader, "Str(ord_num)+Str(pick_num)")
3967*!* If llRetVal
3968*!* Scan For !(&pcWorkHeader..Errs_Flg_H= "Y") && None error trans header only
3969*!* *--- TR 1016915 - BD - Use SQL pass-thru instead of views - Send a SQL pass-thru update SQL statement
3970*!* *Replace Proc_940 With "P", ;
3971*!* * user_id With lcUser_id, ;
3972*!* * last_mod With ltDatetime In (pcPickHeader)
3973*!* SELECT(pcWorkHeader)
3974*!* lcSQLString = "Update zzoordrh set Proc_940='P' "+;
3975*!* ",user_id= " + SQLFormatChar(lcUser_id) +;
3976*!* ",last_mod= " +lcLast_Mod +;
3977*!* " Where ord_num="+SQLFormatNum(ord_num)+" and pick_num="+SQLFormatNum(pick_num)
3978*!* llRetVal = llRetVal And v_SQLExec(lcSQLString)
3979*!* *=== TR 1016915
3980*!* Endscan
3981*!* Set Relation To
3982*!* Endif
3983*!* Endif
3984
3985 IF plUnFlg
3986 *--- this.cFlgOrdFor940Proc temp table will be created in the first pass of this routine FlagProcessOrders where plUnFlg would be .f.
3987 IF NOT EMPTY(this.cFlgOrdFor940Proc)
3988 lcSql = "UPDATE h SET Proc_940 = '' FROM zzoordrh h INNER JOIN " + this.cFlgOrdFor940Proc + " f " + ;
3989 " ON h.ord_num = f.ord_num and h.pick_num = f.pick_num "
3990 llRetVal = llRetVal AND v_sqlexec(lcSql)
3991
3992 *--- TR 1067861 19-Apr-2013 Goutam
3993 lcSql = "UPDATE h SET Proc_940 = '' FROM zzoordrh h INNER JOIN " + this.cFlgOrdFor940Proc + " f " + ;
3994 " ON h.swc_num = f.swc_num WHERE f.swc_num > 0 and h.swc_num > 0"
3995 llRetVal = llRetVal AND v_sqlexec(lcSql)
3996 *=== TR 1067861 19-Apr-2013 Goutam
3997
3998 THIS.LogEntry("Clear 940 flag for unprocessed orders " + IIF(llRetVal,"completed.","failed."))
3999 ENDIF
4000 ELSE
4001 IF USED(pcWorkHeader)
4002 *- 02/27/07 YIK
4003 *- Replaced ..WHERE Errs_Flg_H = "Y" to WHERE Errs_Flg_H < "Y"!!!
4004 *--- TR 1067861 19-Apr-2013 Goutam. Added swc_num
4005 SELECT ord_num, pick_num, swc_num INTO CURSOR WrkHdr FROM (pcWorkHeader) WHERE Errs_Flg_H < "Y"
4006 this.cSQLTempTable = ""
4007 IF RECCOUNT("WrkHdr") > 0 AND this.GenerateSQLTempTable('WrkHdr') AND this.PopulateSQLTempTable('WrkHdr')
4008 this.cFlgOrdFor940Proc = this.cSQLTempTable
4009 *--- TechRec 1058522 21-Dec-2011 TShenbagavalli added sent_940 ---
4010 lcSql = "UPDATE h SET Proc_940 = 'P', sent_940 = " + lcLast_Mod + ", user_id = " + lcUser_id + ", last_mod = " + lcLast_Mod + ;
4011 " FROM zzoordrh h INNER JOIN " + this.cFlgOrdFor940Proc + " f " + ;
4012 " ON h.ord_num = f.ord_num and h.pick_num = f.pick_num "
4013 llRetVal = llRetVal AND v_sqlexec(lcSql)
4014
4015 *--- TR 1067861 19-Apr-2013 Goutam
4016 lcSql = "UPDATE h SET Proc_940 = 'P', sent_940 = " + lcLast_Mod + ", user_id = " + lcUser_id + ", last_mod = " + lcLast_Mod + ;
4017 " FROM zzoordrh h INNER JOIN " + this.cFlgOrdFor940Proc + " f " + ;
4018 " ON h.swc_num = f.swc_num WHERE f.swc_num > 0 and h.swc_num > 0"
4019 llRetVal = llRetVal AND v_sqlexec(lcSql)
4020 *=== TR 1067861 19-Apr-2013 Goutam
4021
4022 ENDIF
4023 THIS.LogEntry("Flag processed orders " + IIF(llRetVal,"completed.","failed."))
4024 ENDIF
4025 ENDIF
4026
4027 Select(lnOldSelect)
4028*!* If !llRetVal
4029*!* This.oLog.LogEntry("Flagging Processed Orders - failed")
4030*!* Endif
4031 *=== TR 10122506 - NH
4032 Return llRetVal
4033 Endproc
4034
4035 Procedure CartonCheck
4036 Lparameters pcTransHeader, pcShipDetail
4037 Local llRetVal, lnOldSelect, lcOldCustomer, lcOldDivision, llRequireBill_num, ;
4038 llRequireSCAC_Code
4039 llRetVal = .T.
4040 lnOldSelect = Select()
4041 If !llRetVal
4042 This.oLog.LogEntry("Carton check")
4043 Endif
4044
4045 lcOldCustomer= ""
4046 lcOldDivision= ""
4047 lnOldOrd_num= 0
4048 lnOldPick_num= 0
4049 lnOldInv_num= 0
4050
4051 *--- TR 1010079 VSS/SHAN 22-Apr-2005
4052 *!* Select distinct division,customer,ord_num,pick_num,inv_num From (pcTransHeader) ;
4053 *!* WHERE chk_asn = 'Y' ;
4054 *!* Order by 1,2,3,4,5 Into Cursor tmpCurs
4055 Select Distinct division,customer,ord_num,pick_num,inv_num, proc_856 From (pcTransHeader) ;
4056 WHERE chk_asn = 'Y' ;
4057 ORDER By 1,2,3,4,5 Into Cursor tmpCurs
4058 *=== TR 1010079 VSS/SHAN 22-Apr-2005
4059
4060 Select tmpCurs
4061 l_nThermoCnt = 0
4062 This.InitThermoWithCaption(@l_nThermoCnt, This.CountTotalRecs ('TmpCurs'), "Validating Orders and Cartons ...")
4063
4064 Scan
4065 This.AdvanceThermoPlus(@l_nThermoCnt)
4066
4067 If !(tmpCurs.customer== lcOldCustomer And tmpCurs.division == lcOldDivision And ;
4068 tmpCurs.ord_num== lcOldOrd_num And tmpCurs.pick_num== lcOldPick_num And ;
4069 tmpCurs.inv_num== lcOldInv_num )
4070 lcOldCustomer = tmpCurs.customer
4071 lcOldDivision = tmpCurs.division
4072 lcOldOrd_num = tmpCurs.ord_num
4073 lcOldPick_num = tmpCurs.pick_num
4074 lcOldInv_num = tmpCurs.inv_num
4075
4076 * reset error msg, SKU, UPC
4077 lcErrs_Msg= ""
4078
4079 *--- TR 1010079 VSS/SHAN 22-Apr-2005
4080 *!* * get lattest cartons from server
4081 *!* llRetVal= vl_ctnph(TmpCurs.ord_num,,'tcCtnph',TmpCurs.pick_num, TmpCurs.inv_num)
4082 *!* If llRetVal
4083 *!* llRetVal=vl_ctnpd(TmpCurs.ord_num,,'tcCtnpd',TmpCurs.pick_num, TmpCurs.inv_num)
4084 *!* Endif
4085 * get lattest cartons from server
4086 If proc_856 = 'Y'
4087 llRetVal = vl_ctnsh(tmpCurs.ord_num,,'tcCtnph',tmpCurs.pick_num, tmpCurs.inv_num)
4088
4089 If llRetVal
4090 llRetVal = vl_ctnsd(tmpCurs.ord_num,,'tcCtnpd',tmpCurs.pick_num, tmpCurs.inv_num)
4091 Endif
4092 Else
4093 llRetVal= vl_ctnph(tmpCurs.ord_num,,'tcCtnph',tmpCurs.pick_num, tmpCurs.inv_num)
4094
4095 If llRetVal
4096 llRetVal=vl_ctnpd(tmpCurs.ord_num,,'tcCtnpd',tmpCurs.pick_num, tmpCurs.inv_num)
4097 Endif
4098 Endif
4099 *=== TR 1010079 VSS/SHAN 22-Apr-2005
4100
4101 If !llRetVal
4102 lcErrs_Msg= "No cartons found for pick# " + Alltr(Str(tmpCurs.pick_num))
4103 This.oLog.LogEntry("No cartons found for pick# " + Alltr(Str(tmpCurs.pick_num)))
4104 Endif
4105
4106 If llRetVal
4107
4108 Select ord_num, pick_num, inv_num, line_seq, division, ;
4109 STYLE, color_code, lbl_code, Dimension, size_desc,sizebucket, ;
4110 sub_style, sub_color, sub_lbl, sub_dimens, sub_code, ;
4111 SUM(total_qty) As Size_qty From (pcShipDetail) ;
4112 GROUP By 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ;
4113 WHERE ord_num= lcOldOrd_num And pick_num= lcOldPick_num And inv_num= lcOldInv_num ;
4114 INTO Cursor tcTemp
4115 .MakeCursorWritable("tcTemp", "tcDtlVer")
4116 Use In Select("tcTemp")
4117 Select tcDtlVer
4118 Scan For (sub_code='O' Or sub_code='A')
4119 Replace Style With sub_style, color_code With sub_color, ;
4120 lbl_code With sub_lbl, Dimension With sub_dimens In tcDtlVer
4121 Endscan
4122 Go Top
4123
4124 Set Procedure To clsctnch Additive
4125 loCartonCheck = Createobject("BPOCartonCheck", 'tcDtlVer', 'tcCtnph', 'tcCtnpd', ;
4126 tmpCurs.ord_num, ;
4127 tmpCurs.pick_num, ;
4128 tmpCurs.inv_num, ;
4129 tmpCurs.division, ;
4130 tmpCurs.customer)
4131
4132 llComplete = loCartonCheck.CheckCartons()
4133 lcErrs_Msg= loCartonCheck.cErrorText
4134 Endif
4135 Endif
4136
4137 *-If llRetVal
4138 Select (pcTransHeader)
4139 If !Empty(lcErrs_Msg)
4140 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg, Errs_Flg_H With "Y" ;
4141 IN (pcTransHeader) For ord_num= lcOldOrd_num And pick_num= lcOldPick_num And ;
4142 inv_num= lcOldInv_num
4143 Endif
4144 *-Endif
4145
4146 * Write carton_code from zzoctnph into tran header
4147 *!* If llRetval and Used('tcCtnph') and !Empty(tcCtnph.carton_code)
4148 *!* Replace carton_code with tcCtnph.carton_code ;
4149 *!* In (pcTransHeader) For ord_num= lcOldOrd_num and pick_num= lcOLdPick_num and ;
4150 *!* inv_num= lcOldInv_num
4151 *!* Endif
4152
4153 Endscan
4154
4155 Use In tmpCurs
4156 If Used("tcDtlVer")
4157 Use In tcDtlVer
4158 Endif
4159 If Used("tcCtnph")
4160 Use In tcCtnph
4161 Endif
4162 If Used("tcCtnpd")
4163 Use In tcCtnpd
4164 Endif
4165
4166 This.ResetThermoPlus()
4167 Select(lnOldSelect)
4168 *- alwys return .T., because cartons may not exist - just error message
4169 Return .T.
4170 Endproc
4171 *=== 41192 7/23/03 YIK
4172
4173 ************************************************************************************
4174 * 1007750 12/20/04 YIK
4175 * Validate DUNS from division ref.
4176 ***********************************************************************************
4177 Procedure CheckDUNS
4178 Lparameters pceoowTH, pceoowcr
4179 Local llRetVal, lnOldSelect, lcSCAC_code
4180 llRetVal = .T.
4181 lnOldSelect = Select()
4182 * Check for DUNS_num require [DUNS_req="Y"]
4183 Select Distinct h.division,h.customer From (pceoowTH) h, (pceoowcr) c ;
4184 WHERE h.location= c.ware_code And c.DUNS_req="Y" ;
4185 ORDER By h.division, h.customer Into Cursor tcDUNS
4186 Select tcDUNS
4187 If This.lUserInterface
4188 This.InitThermo(This.CountTotalRecs ('tcDUNS'))
4189 l_nThermoCnt = 0
4190 Endif
4191 lcDUNS_num=""
4192 Scan
4193 If This.lUserInterface
4194 l_nThermoCnt = l_nThermoCnt + 1
4195 This.AdvanceThermo(l_nThermoCnt)
4196 Endif
4197 llRetVal= vl_divsr(tcDUNS.division,, "_Divsr")
4198 If llRetVal And !Empty(_Divsr.DUNS_num)
4199 Replace DUNS_num With _Divsr.DUNS_num ;
4200 FOR division= tcDUNS.division And customer= tcDUNS.customer In (pceoowTH)
4201 Else
4202 Replace Errs_Msg_H With Errs_Msg_H + "Missing DUNS number." + CRLF, ;
4203 Errs_Flg_H With "Y" In (pceoowTH) ;
4204 FOR division= tcDUNS.division And customer= tcDUNS.customer
4205 Endif
4206 Endscan
4207
4208 Use In tcDUNS
4209 If Used('_Divsr')
4210 Use In _Divsr
4211 Endif
4212 If This.lUserInterface
4213 This.ResetThermo()
4214 Endif
4215 Select(lnOldSelect)
4216 Return llRetVal
4217 Endproc
4218
4219 ************************************************************************************
4220 * 1009127 22-FEB-05 KA
4221 * Validate Type in Control ref.
4222 ***********************************************************************************
4223 Procedure CheckTypeInControlRef
4224 Lparameters pcErrorMsg
4225 Local llRetVal, lnOldSelect, lcVal, lcErrs_Msg, lnOrderNum, lcLocation, lcErrMsg , lcErrorMsg1 , lcErrorMsg2
4226
4227 llRetVal = True
4228 lnOldSelect = Select()
4229
4230 With This
4231
4232 lcErrorMsg1 = "Only one record with type (Open ('O') or Prepack Lines('P')) cannot " + CRLF + ;
4233 "exist for a Location in Control Reference."
4234
4235 lcErrorMsg2 = "Mixed Type 'B' cannot exist with other types (Open or Prepack) " + CRLF + ;
4236 "for location in Control Reference."
4237
4238 Select Distinct c.ware_code, c.Type ;
4239 FROM (.cControlReference) c ,(.cWorkHeader) h ;
4240 WHERE c.ware_code = h.location ;
4241 ORDER By c.ware_code ;
4242 INTO Cursor tcTemp
4243
4244 Select ware_code, Count(Type) As TypeCnt, Max(Type) As MaxType, Min(Type) As MinType;
4245 FROM tcTemp ;
4246 GROUP By ware_code ;
4247 INTO Cursor tcControl
4248
4249 Select tcControl
4250 Scan
4251 Do Case
4252 Case TypeCnt = 1 And MinType <> "B"
4253 lcErrMsg = lcErrorMsg1
4254 Case TypeCnt = 3 Or (TypeCnt = 2 And (MinType = "B"))
4255 lcErrMsg = lcErrorMsg2
4256 Otherwise
4257 lcErrMsg = ""
4258 Endcase
4259 If !Empty(lcErrMsg)
4260 Replace All Errs_Msg_H With Errs_Msg_H + lcErrMsg + CRLF, Errs_Flg_H With "Y" ;
4261 IN (.cWorkHeader) For location = tcControl.ware_code
4262 Endif
4263 Endscan
4264 Endwith
4265
4266 If Used('tcTemp')
4267 Use In tcTemp
4268 Endif
4269 If Used('tcControl')
4270 Use In tcControl
4271 Endif
4272
4273 Select(lnOldSelect)
4274 Return llRetVal
4275 Endproc
4276
4277 ************************************************************************************
4278 * 1009127 22-FEB-05 KA
4279 * CheckTypeInDetail
4280 ***********************************************************************************
4281 Procedure CheckTypeInDetail
4282 Lparameters pcErrorMsg
4283 Local llRetVal, lnOldSelect, lnOrdNum, lcLocation, lcErrs_Msg
4284
4285 llRetVal = True
4286 lnOldSelect = Select()
4287 lcErrs_Msg = ""
4288 Local loControlReference
4289
4290 With This
4291 Select(.cWorkHeader)
4292 Scan
4293
4294 lnPicknum = pick_num
4295 lcLocation = location
4296
4297 *--- TR 1040807 NSD 6/26/09
4298 * Use cached data.
4299 IF .lSQLPassThrough940
4300 IF SEEK(lnPicknum,"tcPickPrePack","pick_num")
4301 .cType = ALLTRIM(tcPickPrePack.is_ppk)
4302 ENDIF
4303 ELSE
4304 llRetVal = llRetVal And .ResolvePrePack(lnPicknum)
4305 ENDIF
4306 *=== TR 1040807 NSD 6/26/09
4307
4308 Replace whse_type With .cType In (.cWorkHeader)
4309
4310 If llRetVal
4311
4312 lcErrs_Msg = ""
4313
4314 Select(.cControlReference)
4315 *- 1010168 03/28/05 YIK
4316 *- If the pick details are all prepacks or Open and the 940 control is set up to "B"
4317 *- this LOCATE fails. We need to check additionally for type = 'B' which is fine for
4318 *- all types of picks (open, ppk or mixed)
4319 *- LOCATE FOR ware_code =lcLocation AND type = .cType
4320 Locate For ware_code =lcLocation And (Type = .cType Or Type = "B")
4321 *=
4322 If Not Found()
4323
4324 Do Case
4325 Case .cType = 'B'
4326 lcErrs_Msg = "Mixed lines not allowed, 940 Control not set up for type 'B' "
4327 Case .cType = 'O'
4328 lcErrs_Msg = "940 Control not set up for type 'O' "
4329 Case .cType = 'P'
4330 lcErrs_Msg = "940 Control not set up for type 'P' "
4331 Otherwise
4332 lcErrs_Msg = "940 Control not set up for location: "+lcLocation
4333 Endcase
4334 *--- TR 1012643 NH : skiping out of scan loop on error as replace has all and for clause
4335 *--- we as in scan loop of order work table no need for replace all or for
4336 *!* REPLACE All Errs_Msg_H WITH Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H WITH "Y" ;
4337 *!* IN (.cWorkHeader) FOR pick_num =lnPickNum AND location =lcLocation
4338 Replace Errs_Msg_H With Errs_Msg_H + lcErrs_Msg + CRLF, Errs_Flg_H With "Y" ;
4339 IN (.cWorkHeader)
4340 *=== tr 1012643 NH:
4341 Else
4342 *--- TR 1012612 NH : populate vnd_id, vnd_qual, our_id, our_qual in work header
4343 Scatter Name loControlReference
4344 Replace our_id With loControlReference.our_id, our_qual With loControlReference.our_qual ;
4345 , vnd_id With loControlReference.vnd_id, vnd_qual With loControlReference.vnd_qual ;
4346 IN (.cWorkHeader)
4347 *=== TR 1012612 NH
4348 Endif
4349 Endif
4350 Endscan
4351
4352 Endwith
4353
4354 Select(lnOldSelect)
4355 Return llRetVal
4356 Endproc
4357
4358 ************************************************************************************
4359 * 1009127 22-FEB-05 KA
4360 * ResolvePrePack
4361 ************************************************************************************
4362 Procedure ResolvePrePack
4363 Lparameters pnPickNum
4364 Local llRetVal, lnOldSelect,lcSQLString, lnPrePack
4365
4366 llRetVal = True
4367 lnOldSelect = Select()
4368
4369 lcSQLString = " SELECT sc.ppack_ok "+;
4370 " FROM zzxscolr sc INNER JOIN zzoordrd d " + ;
4371 " ON sc.division= d.division "+;
4372 " AND sc.style= d.style "+;
4373 " AND sc.color_code= d.color_code " +;
4374 " AND sc.lbl_code= d.lbl_code " + ;
4375 " AND sc.dimension= d.dimension "+;
4376 "WHERE d.pick_num = "+SQLFormatNum(pnPickNum)
4377
4378 llRetVal = llRetVal And v_SqlExec(lcSQLString, "tcPrePack")
4379
4380 With This
4381 If llRetVal
4382
4383 If Used("tcPrePack") And Reccount("tcPrePack") > 0
4384 * Count the Prepack records
4385 Count To lnPrePack For ppack_ok = 'Y'
4386
4387 Do Case
4388 Case Reccount() = lnPrePack
4389 .cType = 'P'
4390 Case lnPrePack = 0
4391 .cType = 'O'
4392 Other
4393 .cType = 'B'
4394 Endcase
4395 Endif
4396
4397 Endif
4398 Endwith
4399
4400 If Used("tcPrePack")
4401 Use In "tcPrePack"
4402 Endif
4403
4404 Select(lnOldSelect)
4405 Return llRetVal
4406
4407 Endproc
4408
4409 Procedure UpdateEDIControlFlags
4410 Local llRetVal, lnOldSelect, lcLocation, lcType, lo_CR
4411
4412 llRetVal = .T.
4413 lnOldSelect = Select()
4414 With This
4415 *- Now, when we have proper whse_type in .cWorkHeader
4416 *- we need to re-populate flags from the 940 control
4417 *- based on proper whse/whse_type combo
4418 Select(.cControlReference)
4419 *- 1010576 4/21/05 YIK
4420 *- SCAN all records, select workheader to avoid replacing in EOF() work area
4421 Scan && FOR type <> "B" && don't need to update if there's a single record "B"
4422 Scatter Name lo_CR
4423 lcLocation = lo_CR.ware_code
4424 lcType = lo_CR.Type
4425
4426 Select (.cWorkHeader)
4427 *- 1011923 10/05/05 YIK
4428 *- Add sln_req
4429 *- 1013910 10/27/05 YIK
4430 *- Use different FOR expressions to properly update picks with whse_type O or P
4431 *- if the 940 control is set to 'B'
4432 *- FH 1086001 - added whs_grp, populate_country
4433
4434 If lcType <> 'B'
4435 Replace sku_upc With lo_CR.sku_upc, chk_shp With lo_CR.chk_shp, chk_wgt With lo_CR.chk_wgt, ;
4436 chk_vol With lo_CR.chk_vol, chk_asn With lo_CR.chk_asn, sln_req With lo_CR.sln_req ;
4437 , whs_grp WITH lo_CR.whs_grp, populate_country WITH lo_CR.populate_country ;
4438 FOR location = lcLocation And whse_type = lcType
4439 Else
4440 Replace sku_upc With lo_CR.sku_upc, chk_shp With lo_CR.chk_shp, chk_wgt With lo_CR.chk_wgt, ;
4441 chk_vol With lo_CR.chk_vol, chk_asn With lo_CR.chk_asn, sln_req With lo_CR.sln_req ;
4442 , whs_grp WITH lo_CR.whs_grp, populate_country WITH lo_CR.populate_country ;
4443 FOR location = lcLocation
4444 Endif
4445 *= 1013910
4446 Endscan
4447 *= 1010576
4448 llRetVal= .SetRelation(.cWorkHeader, "pkey", .cWorkDetail, "fkey")
4449 If llRetVal
4450 Select (.cWorkDetail)
4451 Scan
4452 Replace sku_upc With Evaluate(.cWorkHeader + ".sku_upc"), ;
4453 sln_req With Evaluate(.cWorkHeader + ".sln_req")
4454 Endscan
4455 Endif
4456 Set Relation To
4457 Endwith
4458
4459 Select(lnOldSelect)
4460 Return llRetVal
4461
4462 Endproc
4463
4464 *---TR 1011894 11Jul.2005 AS
4465 Procedure PopulateEDI_Store_Class_Type
4466 Lparameters pcHeader
4467 Local llRetVal, lnOldSelect, tcStorr, tcTempCur
4468 llRetVal= .T.
4469 lnOldSelect= Select()
4470
4471 Select Distinct customer, Store From (pcHeader) Where !(Errs_Flg_H= "Y") ;
4472 INTO Cursor tcTempCur
4473 Select tcTempCur
4474 With This
4475 .cSQLTempTable=""
4476 If .GenerateSQLTempTable('tcTempCur')
4477
4478 If .PopulateSQLTempTable('tcTempCur')
4479
4480 If !Empty(.cSQLTempTable)
4481 *--- TechRec 1054554 10-Jun-2011 TShenbagavalli added , s.dba ---
4482 lcSQLString= "Select s.customer, s.store, s.edi_store, " +;
4483 " s.class_code, s.store_type, s.dba " +;
4484 " from zzxstorr s, " + .cSQLTempTable + " t " +;
4485 "Where s.customer= t.customer and s.store= t.store"
4486 llRetVal = v_SqlExec(lcSQLString, "tcStorr")
4487
4488 If llRetVal
4489 Select tcStorr
4490 Index On customer+Store Tag CustStore
4491 llRetVal= .SetRelation("tcStorr", "CustStore", pcHeader, ;
4492 "customer+store")
4493
4494 If llRetVal
4495 &&--- TechRec 1054554 10-Jun-2011 TShenbagavalli added store_dba ===
4496 Replace All EDI_Store With tcStorr.EDI_Store, ;
4497 Class_Code With tcStorr.Class_Code, ;
4498 store_dba With tcStorr.dba, ;
4499 Store_Type With tcStorr.Store_Type In (pcHeader) ;
4500 FOR !Empty(tcStorr.customer)
4501 Set Relation To
4502 Use In tcStorr
4503 Endif
4504 Endif
4505 Endif
4506 Endif
4507 Endif
4508 Endwith
4509 If Used("tcTempCur")
4510 Use In tcTempCur
4511 Endif
4512 Select(lnOldSelect)
4513 Return llRetVal
4514 Endproc
4515
4516 Procedure PopulateDeptInfo
4517 Lparameters pcHeader
4518 Local llRetVal, lnOldSelect, tcStorr, tcTempCur
4519 llRetVal= .T.
4520 lnOldSelect= Select()
4521
4522 Select Distinct customer, Department From (pcHeader) Where !(Errs_Flg_H= "Y") ;
4523 INTO Cursor tcTempCur
4524 Select tcTempCur
4525 With This
4526 .cSQLTempTable=""
4527 If .GenerateSQLTempTable('tcTempCur')
4528
4529 If .PopulateSQLTempTable('tcTempCur')
4530
4531 If !Empty(.cSQLTempTable)
4532 lcSQLString= "Select s.customer, s.department, s.dept_name " +;
4533 " from zzxcdepr s, " + .cSQLTempTable + " t " +;
4534 "Where s.customer = t.customer and s.department = t.department"
4535 llRetVal = v_SqlExec(lcSQLString, "tcDeptr")
4536
4537 If llRetVal
4538 Select tcDeptr
4539 Index On customer + Department Tag CustDept
4540 llRetVal= .SetRelation("tcDeptr", "CustDept", pcHeader, ;
4541 "customer+department")
4542
4543 If llRetVal
4544 Replace All Dept_Name With tcDeptr.Dept_Name In (pcHeader) ;
4545 FOR !Empty(tcDeptr.customer)
4546 Set Relation To
4547 Use In tcDeptr
4548 Endif
4549 Endif
4550 Endif
4551 Endif
4552 Endif
4553 Endwith
4554 If Used("tcTempCur")
4555 Use In tcTempCur
4556 Endif
4557 Select(lnOldSelect)
4558 Return llRetVal
4559 Endproc
4560
4561 *--- TR 1077941 04/18/14 ATHIRUNAVU Modified method name to PopulateHistoryHeader
4562 *Procedure PopulatePromotionInfo
4563 Procedure PopulateHistoryHeader
4564 *=== TR 1077941 04/18/14 ATHIRUNAVU
4565 Lparameters pcHeader
4566 Local llRetVal, lnOldSelect, tcStorr, tcTempCur
4567 llRetVal= .T.
4568 lnOldSelect= Select()
4569
4570 Select Distinct customer, ord_num From (pcHeader) Where !(Errs_Flg_H= "Y") ;
4571 INTO Cursor tcTempCur
4572 Select tcTempCur
4573
4574 With This
4575 .cSQLTempTable=""
4576 If .GenerateSQLTempTable('tcTempCur')
4577
4578 If .PopulateSQLTempTable('tcTempCur')
4579
4580 If !Empty(.cSQLTempTable)
4581 *--- TR 1048927 24-SEP-2010 HNISAR && Added s.merch_type_desc
4582 *--- TR 1077941 04/18/14 ATHIRUNAVU Added fob_code
4583 lcSQLString= "Select s.customer, s.ord_num, s.promotion , s.merch_type_desc, s.fob_code " + ;
4584 " from zzeipohh s, " + .cSQLTempTable + " t " + ;
4585 "Where s.customer = t.customer and s.ord_num = t.ord_num"
4586 llRetVal = v_SqlExec(lcSQLString, "tcPromor")
4587
4588 If llRetVal
4589 Select tcPromor
4590 Index On customer + Alltrim(Str(ord_num)) Tag CustOrd
4591 llRetVal= .SetRelation("tcPromor", "CustOrd", pcHeader, ;
4592 "customer+ALLTRIM(STR(Ord_Num))")
4593
4594 If llRetVal
4595 *--- TR 1048927 24-SEP-2010 HNISAR && Added tcPromor.merch_type_desc
4596 *--- TR 1077941 04/18/14 ATHIRUNAVU Replace fob_code
4597 Replace All Promotion With tcPromor.Promotion ,;
4598 fob_code WITH tcPromor.fob_code, ;
4599 merch_type_desc WITH tcPromor.merch_type_desc In (pcHeader) ;
4600 FOR !Empty(tcPromor.customer)
4601 Set Relation To
4602 Use In tcPromor
4603 Endif
4604 Endif
4605 Endif
4606 Endif
4607 Endif
4608 Endwith
4609 If Used("tcTempCur")
4610 Use In tcTempCur
4611 Endif
4612 Select(lnOldSelect)
4613 Return llRetVal
4614 Endproc
4615 *===TR 1011894 11Jul.2005 AS
4616
4617 *--- TR 1036614 19-Mar-2010 Goutam
4618Procedure PopulateFromHistoryDetail
4619 Lparameters pcHeader, pcDetail
4620
4621 Local llRetVal, lnOldSelect, tcStorr, tcTempCur
4622 llRetVal= .T.
4623 lnOldSelect= Select()
4624
4625 Select Distinct d.pkey, d.line_seq, d.sizebucket, h.ord_num From (pcHeader) h ;
4626 JOIN (pcDetail) d ON d.fkey = h.pkey ;
4627 Where !(h.Errs_Flg_H= "Y") ;
4628 INTO Cursor tcTempCur
4629
4630 Select tcTempCur
4631
4632 With This
4633 .cSQLTempTable=""
4634 If .GenerateSQLTempTable('tcTempCur')
4635 If .PopulateSQLTempTable('tcTempCur')
4636 If !Empty(.cSQLTempTable)
4637
4638 *- TR 1059018 FH - added d.po1_line
4639 *- TR 1072138 07/11/2013 - FH added EDIPO4UDF1/2/3
4640 *- TR 1073384 FH 01/01/14 - sln01, slntodtl
4641 lcSqlString= "Select t.pkey, t.ord_num, d.assortment, d.assort_qty, d.sln01, d.slntodtl, d.po1_line " +;
4642 ", d.EDIPO4UDF1, d.EDIPO4UDF2, d.EDIPO4UDF3 " +;
4643 "From zzeipohd d, " + .cSQLTempTable + " t " +;
4644 "Where d.ord_num= t.ord_num and d.line_seq= t.line_seq and d.sizebucket= t.sizebucket"
4645
4646 llRetVal = v_SqlExec(lcSQLString, "__tcHistDtl")
4647
4648 *- TR 1073384 FH - added replace fields sln01, slntodtl
4649 If llRetVal
4650 Select __tcHistDtl
4651 Index On Pkey Tag Pkey
4652 llRetVal= llRetVal And .SetRelation("__tcHistDtl", "pkey", pcDetail, "pkey")
4653 If llRetVal
4654 Replace All assortment With __tcHistDtl.assortment, ;
4655 assort_qty WITH __tcHistDtl.assort_qty ;
4656 , po1_line WITH __tcHistDtl.po1_line ; && TR 1059018 FH - added d.po1_line
4657 , EDIPO4UDF1 WITH __tcHistDtl.EDIPO4UDF1 ; && TR 1072138 07/11/2013 - FH
4658 , EDIPO4UDF2 WITH __tcHistDtl.EDIPO4UDF2 ; && TR 1072138 07/11/2013 - FH
4659 , EDIPO4UDF3 WITH __tcHistDtl.EDIPO4UDF3 ; && TR 1072138 07/11/2013 - FH
4660 , slntodtl WITH __tcHistDtl.slntodtl ;
4661 , sln01 WITH __tcHistDtl.sln01 ;
4662 In (pcDetail) ;
4663 FOR __tcHistDtl.Pkey> 0
4664
4665 Set Relation To
4666 Use In __tcHistDtl
4667 Endif
4668 Endif
4669 Endif
4670 Endif
4671 Endif
4672 Endwith
4673 If Used("tcTempCur")
4674 Use In tcTempCur
4675 Endif
4676 Select(lnOldSelect)
4677 Return llRetVal
4678 Endproc
4679 *=== TR 1036614 19-Mar-2010 Goutam
4680
4681 *--- TR 1027339 20-Nov-2007 Goutam
4682 Procedure PopulateTerms
4683 Lparameters pcHeader
4684 Local llRetVal, lnOldSelect, tcStorr, tcTempCur
4685 llRetVal= .T.
4686 lnOldSelect= Select()
4687
4688 Select Distinct terms, ord_num, pick_num From (.cPickHeader) INTO Cursor tcTempCur
4689 Select tcTempCur
4690 With This
4691 .cSQLTempTable=""
4692 If .GenerateSQLTempTable('tcTempCur')
4693
4694 If .PopulateSQLTempTable('tcTempCur')
4695
4696 If !Empty(.cSQLTempTable)
4697 *--- TR 1039239 22-Jul-2009 Goutam. Added s.term_type, s.terms_xref in the following sql
4698 lcSQLString= "Select s.term_desc, t.terms, s.term_type, s.terms_xref " + ;
4699 " from zzxtermr s, " + .cSQLTempTable + " t " + ;
4700 "Where s.terms = t.terms"
4701 llRetVal = v_SqlExec(lcSQLString, "tcTerms")
4702
4703 If llRetVal
4704 Select tcTerms
4705 Index On terms Tag terms
4706 llRetVal= .SetRelation("tcTerms", "terms", pcHeader, "terms")
4707 If llRetVal
4708 *--- TR 1039239 22-Jul-2009 Goutam. Added term_type, terms_xref in the following replace statement
4709 Replace All term_desc With tcTerms.term_desc ;
4710 term_type WITH tcTerms.term_type, ;
4711 terms_xref WITH tcTerms.terms_xref ;
4712 In (pcHeader) ;
4713 FOR !Empty(tcTerms.Terms)
4714 Set Relation To
4715 Use In tcTerms
4716 Endif
4717 ENDIF
4718 .cSQLTempTable = ""
4719 Endif
4720 Endif
4721 Endif
4722 Endwith
4723 If Used("tcTempCur")
4724 Use In tcTempCur
4725 Endif
4726 Select(lnOldSelect)
4727 Return llRetVal
4728 Endproc
4729 *=== TR 1027339 20-Nov-2007 Goutam
4730
4731 *--- TR 1014900 20-Mar-2006 Goutam
4732 ****Local instance of CheckSLNUPCSKU from clsedi for only 940 process.
4733
4734 Procedure CheckSLNUPCSKU
4735
4736 Lparameters pcTransHeader, pcTransDetail, pcSLNPrePack, pcFinalSLNPrepack, ;
4737 pcLineSLNPrepack
4738 Local llRetVal, lnOldSelect
4739
4740 llRetVal = .T.
4741 lnOldSelect = Select()
4742
4743 With This
4744
4745 * Prepare SLNPrepack per customer require for customer style & UPC validation
4746 * eventhought UPC does not require customer since, could potential have "B"oth
4747 * UPC and SKU validation for all EXPLODED COMPONENTS. Therefore, need to split
4748 * UCP by customer (--Batch validate UPC without customer).
4749 * Creating cursor pcFinalSLNPrepack
4750 *--- TR 1046782 13-Jul-2010 Goutam. Added d.aux_sku ====
4751
4752 Select distinct h.customer, d.aux_sku, p.* ;
4753 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
4754 Where h.Pkey = d.Fkey and d.division= p.division and d.style= p.PPK_style and ;
4755 d.color_code= p.PPK_color and d.Lbl_code= p.PPK_label and ;
4756 d.dimension= p.PPK_dimension and h.sku_upc<> "N" ;
4757 Order by 1,2,3,4,5,6,7 Into Cursor _CustSLNPrepack
4758
4759 .MakeCursorWritable("_CustSLNPrepack", pcFinalSLNPrepack)
4760 .TableClose("_CustSLNPrepack")
4761 * index for optimizing
4762 If Used(pcFinalSLNPrepack)
4763 Select (pcFinalSLNPrepack)
4764 Index on customer+division+PPK_style+PPK_color+PPK_label+PPK_dimension tag CustSKU
4765 Index on customer+division+style+color_code+Lbl_code+dimension+Str(sizebucket) tag CustSKU
4766 Endif
4767
4768 * Find ALL Component SKUs for Prepack SLN explosion.
4769 * Populate SKU into pcFinalSLNPrepack
4770 Select distinct h.customer, p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
4771 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, ;
4772 h.sku_upc ;
4773 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
4774 Where h.Pkey = d.Fkey and d.division= p.division and d.style= p.PPK_style and ;
4775 d.color_code= p.PPK_color and d.Lbl_code= p.PPK_label and ;
4776 d.dimension= p.PPK_dimension ;
4777 AND (h.sku_upc= "S" or h.sku_upc= "A" ) ; &&TR 1073064 30-Aug-13 Venuk
4778 Order by 1,2,3,4,5,6,7 Into Cursor __TmpCursor
4779
4780 .cSQLTempTable=""
4781 If .GenerateSQLTempTable('__TmpCursor')
4782 If .PopulateSQLTempTable('__TmpCursor')
4783 If !Empty(.cSQLTempTable)
4784 llRetVal= llRetVal and .CheckOutboundSLNSKU(pcTransHeader, pcTransDetail, ;
4785 pcFinalSLNPrepack, .cSQLTempTable, '__TmpCursor')
4786 *--- TR 1073064 30-Aug-13 Venuk. commented
4787 *llRetVal= llRetVal and .CheckOutboundSLNUPC(pcTransHeader, pcTransDetail, ;
4788 * pcFinalSLNPrepack, .cSQLTempTable, '__TmpCursor')
4789 *llRetVal= llRetVal and .CheckOutboundSLNEAN(pcTransHeader, pcTransDetail, ;
4790 * pcFinalSLNPrepack, .cSQLTempTable, '__TmpCursor')
4791 *=== TR 1073064 30-Aug-13 Venuk. commented
4792 Endif
4793 Endif
4794 Endif
4795 .TableClose('__TmpCursor')
4796 *--- TR 1073064 30-Aug-13 Venuk
4797 Select distinct h.customer, p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
4798 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, ;
4799 h.sku_upc ;
4800 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
4801 Where h.Pkey = d.Fkey and d.division= p.division and d.style= p.PPK_style and ;
4802 d.color_code= p.PPK_color and d.Lbl_code= p.PPK_label and ;
4803 d.dimension= p.PPK_dimension ;
4804 AND (h.sku_upc= "U" or h.sku_upc= "B" OR h.sku_upc= "R" or h.sku_upc= "A" ) ; &&TR 1073064 30-Aug-13 Venuk
4805 Order by 1,2,3,4,5,6,7 Into Cursor __TmpCursor
4806
4807 .cSQLTempTable=""
4808 If .GenerateSQLTempTable('__TmpCursor')
4809 If .PopulateSQLTempTable('__TmpCursor')
4810 If !Empty(.cSQLTempTable)
4811 llRetVal= llRetVal and .CheckOutboundSLNUPC(pcTransHeader, pcTransDetail, ;
4812 pcFinalSLNPrepack, .cSQLTempTable, '__TmpCursor')
4813 Endif
4814 Endif
4815 Endif
4816 .TableClose('__TmpCursor')
4817
4818 Select distinct h.customer, p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
4819 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, ;
4820 h.sku_upc ;
4821 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
4822 Where h.Pkey = d.Fkey and d.division= p.division and d.style= p.PPK_style and ;
4823 d.color_code= p.PPK_color and d.Lbl_code= p.PPK_label and ;
4824 d.dimension= p.PPK_dimension ;
4825 AND (h.sku_upc= "E" or h.sku_upc= "R" or h.sku_upc= "A" ) ;
4826 Order by 1,2,3,4,5,6,7 Into Cursor __TmpCursor
4827
4828 .cSQLTempTable=""
4829 If .GenerateSQLTempTable('__TmpCursor')
4830 If .PopulateSQLTempTable('__TmpCursor')
4831 If !Empty(.cSQLTempTable)
4832 llRetVal= llRetVal and .CheckOutboundSLNEAN(pcTransHeader, pcTransDetail, ;
4833 pcFinalSLNPrepack, .cSQLTempTable, '__TmpCursor')
4834 Endif
4835 Endif
4836 Endif
4837 .TableClose('__TmpCursor')
4838 *=== TR 1073064 30-Aug-13 Venuk
4839
4840
4841 Endwith
4842
4843 * Per Order detail line SLNPrepack
4844 * Creating pcLineSLNPrepack from previous result of pcFinalSLNPrepack and detail pkey
4845 * for latter link to output base on detail pkey+customer in flatfile output
4846 *- Added ..and h.customer = p.customer, otherwise if the same prepack sent to
4847 *- two different customers, the join creates duplicated SLNs
4848 Select d.Pkey as ITM_Pkey, p.* ;
4849 From (pcTransHeader) h, (pcTransDetail) d, (pcFinalSLNPrepack) p ;
4850 Where h.Pkey = d.Fkey and d.division= p.division and d.style= p.PPK_style and ;
4851 d.color_code= p.PPK_color and d.Lbl_code= p.PPK_label and ;
4852 d.dimension= p.PPK_dimension and h.customer = p.customer ;
4853 Into Cursor (pcLineSLNPrepack) READWRITE && *--- TR 1036614 16-3-2010 Goutam Added READWRITE
4854
4855
4856 If Used(pcLineSLNPrepack)
4857 Select (pcLineSLNPrepack)
4858 Index on ITM_Pkey tag ITM_Pkey
4859 Endif
4860
4861 Select(lnOldSelect)
4862 Return llRetVal
4863
4864 Endproc
4865
4866*********************************
4867 Procedure ValidateOutboundSLNUPC
4868 Lparameters pcTransHeader, pcTransDetail, pcSLNPrePack, pcSQLTempTable, pcLocalSQLTempTable
4869 Local llRetVal, lnOldSelect, lcSQLString, lcSQLString1
4870 PRIVATE pcLocalDivRef
4871 llRetVal = .T.
4872 lnOldSelect = Select()
4873 pcLocalDivref = GetUniqueFileName()
4874
4875 * PrePackSKU order
4876 Select (pcTransDetail)
4877 Set Order to OurSku
4878
4879 With This
4880 * list of all missing UPC group by PrePackSKU
4881
4882 *--- We need Local Division Reference.
4883 lcSQLString= "Select division,Prod_ID from zzxdivsr"
4884 llRetVal= llRetVal And v_SQLExec(lcSQLString,pcLocalDivRef)
4885
4886 *--->Added Prod_ID from zzxdivsr because now UPC check is Division specific
4887 lcSQLString1= "Select distinct t.division, t.style, t.color_code," +;
4888 "t.lbl_code, t.dimension, t.sizebucket, t.size_desc, "+;
4889 "t.PPK_style, t.PPK_color,t.PPK_label, t.PPK_dimension "+;
4890 "From " + pcLocalSQLTempTable + " s, " + pcSLNPrePack + " t, " + pcLocalDivRef + " d " +;
4891 "Where s.division= t.division and " +;
4892 "s.division= d.division and " +;
4893 "s.style= t.style and s.color_code= t.color_code and " +;
4894 "s.lbl_code= t.lbl_code and s.dimension= t.dimension and " +;
4895 "s.sizebucket= t.sizebucket and t.upc='' and (d.Prod_ID = 'U' or d.Prod_ID = 'B') " +; && TR 1073064 30-Aug-13 Venuk. Added d.Prod_ID = 'B
4896 " and (s.sku_upc = 'U' or s.sku_upc = 'R' or s.sku_upc = 'A') " + ; && TR 1073064 30-Aug-13 Venuk. Added s.sku_upc = 'R' or s.sku_upc = 'A'
4897 "order by t.division,t.PPK_style, t.PPK_color,t.PPK_label, t.PPK_dimension"
4898 llRetVal= llRetVal and v_SQLexec(lcSQLString1, "tcNoUPC",, True)
4899 .TableClose(pcLocalDivRef)
4900
4901 * Consolidate all missing UPC components for same PrePackSKU together in lcErrs_Msg
4902 If llRetVal
4903 Select tcNoUPC
4904 Index on division + PPK_style + PPK_color + PPK_label + PPK_dimension ;
4905 Tag PPackSKU
4906 Do while llRetVal and !EOF('tcNoUPC')
4907 lcCurPPackSKU= division + PPK_style + PPK_color + PPK_label + PPK_dimension
4908 lcErrs_Msg= "Missing Prepack component UPC : "+ CRLF
4909 Scan while division + PPK_style + PPK_color + PPK_label + PPK_dimension == ;
4910 lcCurPPackSKU
4911 lcErrs_Msg= lcErrs_Msg + "Div:" + division + " Style: " + style + ;
4912 " Color: " + color_code + "Label: " + Lbl_code + "Dm/Pk:" + dimension +;
4913 " Size: " + Str(sizebucket) + CRLF
4914 Endscan
4915 * after accumulate all missing UPC components for same PrePackSKU
4916 * seek for all detail lines that use that PrePackSKU and append proper
4917 * error message/flag.
4918 Select (pcTransDetail)
4919 If Seek(lcCurPPackSKU, pcTransDetail, "OurSKU" )
4920 scan while division+ style+ color_code+ Lbl_code+ dimension == lcCurPPackSKU
4921 Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With "Y" ;
4922 In (pcTransDetail)
4923 Endscan
4924 Endif
4925 Select tcNoUPC
4926 Enddo
4927 Endif
4928 .TableClose('tcNoUPC')
4929 Endwith
4930 Select(lnOldSelect)
4931 Return llRetVal
4932 Endproc
4933*********************************
4934 Procedure ValidateOutboundSLNSKU
4935 Lparameters pcTransHeader, pcTransDetail, pcSLNPrePack, pcSQLTempTable, pcLocalSQLTempTable
4936 Local llRetVal, lnOldSelect
4937 llRetVal = .T.
4938 lnOldSelect = Select()
4939
4940 * PrePackSKU order
4941 Select (pcTransDetail)
4942 Set Order to OurSku
4943
4944 With This
4945 * list of all missing SKU group by PrePackSKU
4946 lcSQLString1= "Select distinct t.customer,t.division, t.style, t.color_code," +;
4947 "t.lbl_code, t.dimension, t.sizebucket, t.size_desc, "+;
4948 "t.PPK_style, t.PPK_color,t.PPK_label, t.PPK_dimension "+;
4949 "From " + pcLocalSQLTempTable + " s, " + pcSLNPrePack + " t " +;
4950 "Where s.division= t.division and " +;
4951 "s.style= t.style and s.color_code= t.color_code and " +;
4952 "s.lbl_code= t.lbl_code and s.dimension= t.dimension and " +;
4953 "s.sizebucket= t.sizebucket and t.sku='' " +;
4954 " and (s.sku_upc = 'S' or s.sku_upc = 'A')" + ; && TR 1073064 30-Aug-13 Venuk. Added s.sku_upc = 'A'
4955 "order by t.customer,t.division,t.PPK_style, t.PPK_color,t.PPK_label, t.PPK_dimension"
4956 llRetVal= llRetVal and v_SQLexec(lcSQLString1, "_NoSKU",, True) &&local
4957
4958 * Consolidate all missing SKU components for same PrePackSKU together in lcErrs_Msg
4959 If llRetVal
4960 Select _NoSKU
4961 Index on customer + division + PPK_style + PPK_color + PPK_label + PPK_dimension ;
4962 Tag PPackSKU
4963 Do while llRetVal and !EOF('_NoSKU')
4964 lcCurPPackSKU= customer + division + PPK_style + PPK_color + PPK_label + PPK_dimension
4965 lcErrs_Msg= "Missing Prepack component for Customer Style: "+ CRLF
4966 Scan while customer + division + PPK_style + PPK_color + PPK_label + PPK_dimension == ;
4967 lcCurPPackSKU
4968 lcErrs_Msg= lcErrs_Msg + "Cust:" + customer + "Div:" + division + ;
4969 " Style: " + style + " Color: " + color_code + "Label: " + Lbl_code +;
4970 "Dm/Pk:" + dimension + " Size: " + Str(sizebucket) + CRLF
4971 Endscan
4972 * after accumulate all missing SKU components for same PrePackSKU
4973 * seek for all detail lines that use that PrePackSKU and append proper
4974 * error message/flag.
4975 Select (pcTransDetail)
4976 If Seek(lcCurPPackSKU, pcTransDetail, "CustSKU" )
4977 scan while customer + division+ style+ color_code+ Lbl_code+ dimension == lcCurPPackSKU
4978 Replace Errs_Msg_D with Errs_Msg_D + lcErrs_Msg, Errs_Flg_D With "Y" ;
4979 In (pcTransDetail)
4980 Endscan
4981 Endif
4982 Select _NoSKU
4983 Enddo
4984 Endif
4985 .TableClose('_NoSKU')
4986 Endwith
4987 Select(lnOldSelect)
4988 Return llRetVal
4989
4990 Endproc
4991
4992 *=== TR 1014900 20-Mar-2006 Goutam
4993
4994 *--- TR 1017241 10-JUL-2006 Goutam
4995 Procedure ConsolidatePrepackByRangeSKU
4996 Lparameters pcTransHeader, pcTransDetail
4997 Local llRetVal, lnOldSelect, lnRangeDtlPkey, lcCurRangeSKU,;
4998 lcRng_style, lcRng_color, lcRng_lbl, lcRng_pack, loRecord, lcReplaceStr
4999 Local lcCurRangeDtlSKU, llFound && TR 1013140 NH 2005-09-19
5000 llRetVal= .T.
5001 lnOldSelect= Select()
5002 With This
5003 *- 1017241 07/25/06 YIK Added .. , ph.pkey AS itm_pkey
5004 lcSQLString = "Select ph.ppk_desc, ph.pack_qty, ph.mulcllb_ok, pd.*, " + ;
5005 " s.style, s.style as PPK_Style, s.color_code as PPK_Color, " + ;
5006 " s.lbl_code as PPK_Label,s.dimension as PPK_Dimension, " + ;
5007 "'" + Space(12) + "' as UPC," + "'" + Space(27) + "' as SKU, " +;
5008 "'" + Space(14) + "' as EAN, " +;
5009 "999999 as PPSize_qty , 999 as Sizebucket ,"+;
5010 "'" + Space(5) + "' AS Size_Desc, ph.pkey AS itm_pkey " +;
5011 " from zzxppakh ph, zzxppakd pd, zzxscolr s " + ;
5012 " Where 0 = 1 "
5013
5014 llRetVal= llRetVal And v_sqlexec(lcSQLString, "__RangeSLN")
5015 *- 1018323 07/31/06 YIK
5016 *- Create another writable cursor for the SLNs for the current range style
5017 LOCAL ARRAY laRangeStru[1]
5018 = AFIELDS(laRangeStru, "__RangeSLN")
5019 *=
5020 .MakeCursorWritable("__RangeSLN", "tcRangeSLN")
5021 .TableClose("__RangeSLN")
5022 *- 1018323 07/31/06 YIK
5023 lcSQLString = "SELECT * FROM zzxrangH where rng_type = 'P'"
5024 llRetVal = v_SQLExec(lcSQLString, "zzxrangH")
5025 SELECT zzxrangH
5026 INDEX ON rng_style + rng_color + rng_lbl + rng_pack + STR(rng_bk) TAG RangeSKU
5027 SELECT (pcTransDetail)
5028 SCAN FOR Errs_Flg_D <> "Y" AND rng_style = ' '
5029 lcSKU = style + color_code + lbl_code + DIMENSION + STR(sizebucket)
5030 IF SEEK(lcSKU, "zzxrangH", "RangeSKU")
5031 REPLACE rng_style WITH zzxrangH.rng_style, ;
5032 rng_color WITH zzxrangH.rng_color, ;
5033 rng_lbl WITH zzxrangH.rng_lbl, ;
5034 rng_pack WITH zzxrangH.rng_pack, ;
5035 rng_bk WITH zzxrangH.rng_bk, ;
5036 rng_type WITH 'P', ;
5037 rng_qty WITH zzxrangH.rng_qty ;
5038 IN (pcTransDetail)
5039 ENDIF
5040 ENDSCAN
5041
5042 Select Distinct pick_num, rng_style, rng_color, rng_lbl, rng_pack, ;
5043 rng_bk, rng_qty, rng_type, Sum(total_qty) As total_qty ;
5044 From (pcTransDetail) ;
5045 Where Errs_Flg_D<> "Y" And rng_style<> '' ;
5046 Group By rng_style, rng_color, rng_lbl, rng_pack, ;
5047 rng_bk, rng_qty, rng_type, pick_num ;
5048 Into Cursor tcTemp
5049 *= 1018323 YIK
5050
5051 lcErrs_Msg= "Sum of units for the same range style must be divisible by "
5052 lcCurRangeSKU= ""
5053 Select tcTemp
5054 Scan
5055 lcCurRangeSKU= rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk) + Str(pick_num)
5056 lnCurTotal_qty= total_qty
5057
5058 * For "S"et range type when Mod(total_qty, rng_qty)> 0 -- Invalid range qty
5059 *- Add type 'R' which is to be rolled up in a single line but w/o qty conversion.
5060 If rng_type = SET_RANGE_TYPE Or rng_type = RUN_RANGE_TYPE
5061 * Mark group of trans. detail for same Range style with error
5062 * when Sum(total_qty) not divisible by rng_qty for "S"et range style
5063
5064 *- Added ..AND rng_type = SET_RANGE_TYPE - qty conversion only for 'S'et
5065 If Mod(tcTemp.total_qty, tcTemp.rng_qty) > 0 And tcTemp.rng_qty> 0 And rng_type = SET_RANGE_TYPE
5066 Replace Errs_Msg_D With Errs_Msg_D + lcErrs_Msg + ;
5067 allt(Str(tcTemp.rng_qty)) + CRLF, Errs_Flg_D With "Y" ;
5068 For rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk) +;
5069 Str(pick_num)= lcCurRangeSKU In (pcTransDetail)
5070 Else
5071 * Consolidate group of trans. detail for same range style
5072 If Seek(lcCurRangeSKU, pcTransDetail, "RangeSKU")
5073 Select (pcTransDetail)
5074 Scatter Name loRecord
5075 * Switch s,c,l,d,sz with range s,c,l,d,sz
5076 loRecord.Style= loRecord.rng_style
5077 loRecord.color_code= loRecord.rng_color
5078 loRecord.lbl_code= loRecord.rng_lbl
5079 loRecord.Dimension= loRecord.rng_pack
5080 loRecord.sizebucket= loRecord.rng_bk
5081 If rng_type = SET_RANGE_TYPE
5082 loRecord.total_qty= lnCurTotal_qty/ loRecord.rng_qty && rollup total qty by range SKU
5083 Else
5084 loRecord.total_qty= lnCurTotal_qty
5085 Endif
5086 * reset range SKU; only want to consolidate once
5087 loRecord.rng_style= ''
5088 loRecord.rng_color= ''
5089 loRecord.rng_lbl= ''
5090 loRecord.rng_pack= ''
5091 loRecord.rng_bk= 0
5092 loRecord.rng_qty= 0
5093
5094 *- TR 1078951 FH - get Range style name
5095 llRetVal = vl_stylr(loRecord.division,, "tmpStylr", loRecord.Style)
5096 loRecord.style_name = tmpStylr.style_name
5097 USE in select("tmpStylr")
5098 *- TR 1078951 FH - get Range style name
5099
5100 * Get range style price
5101 llRetVal= vl_rangr(loRecord.division,, 'tcRangh', loRecord.Style, ;
5102 loRecord.color_code, loRecord.lbl_code, loRecord.Dimension)
5103 lcPrice_code= Iif(Empty(&pcTransDetail..price_code), 'a', &pcTransDetail..price_code)
5104 lnPrice= Eval("tcRangh." + lcPrice_code + "_price")
5105 *- 1020999 12/26/06 YIK
5106 *- Side mod: Populate Range Style retail price from zzxrangh
5107 loRecord.ret_price = tcRangh.sell_price
5108
5109 loRecord.price= lnPrice
5110 loRecord.org_price= lnPrice
5111
5112 * Remove all trans detail with same range SKU and replace with
5113 * rollup level of range SKU
5114 *- Insert range style components into tcRangeSLN (structure of pcTransDetail)
5115 *!* llRetVal= vl_rangd1(loRecord.division, "", 'tcRangd', style, Color_code, Lbl_code, dimension)
5116 *--- bring range style all details
5117 llRetVal = llRetVal And vl_rangd(loRecord.division, "", 'tcRangd', loRecord.Style, ;
5118 loRecord.color_code, loRecord.lbl_code, loRecord.Dimension)
5119
5120 This.oLog.LogEntry("Range style detail components query " + Iif(llRetVal, "completed.","failed."))
5121 lcCurRangeDtlSKU = ""
5122 llFound = .F.
5123
5124 SELECT (pcTransDetail)
5125 lnPkey = loRecord.pkey
5126 Scan For rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk)+ ;
5127 Str(pick_num) = lcCurRangeSKU And sln_req = 'Y'
5128 lnItemPkey = pkey
5129 *--- TR 1013140 NH 2005-09-19
5130 *-- get to the matching rangd record
5131 lcCurRangeDtlSKU = Style + color_code + lbl_code + Dimension
5132 Select tcRangd
5133 Locate For Style + color_code + lbl_code + Dimension = lcCurRangeDtlSKU
5134 llFound = Found()
5135 Select (pcTransDetail)
5136 If Not llFound
5137 .oLog.LogEntry("SKU " + lcCurRangeDtlSKU + " does not exists for range style " +;
5138 rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk))
5139 llRetVal = .F.
5140 Endif
5141 *=== TR 1013140 NH 2005-09-19
5142
5143 If llRetVal
5144 lcQtyFld = "SIZE" + Trans(sizebucket, "@L 99") + "_qty"
5145 lnppsize_qty = Eval('tcRangd.' + lcQtyFld)
5146 lnPack_total = tcRangd.total_qty
5147 Else
5148 lnppsize_qty = 0
5149 lnPack_total = 0
5150 ENDIF
5151 lcReplaceStr = "Replace pack_qty with tcRangh.rng_qty, " + ;
5152 "ppsize_qty with lnppsize_qty, Pack_total with lnPack_total, " + ;
5153 "PPK_style with rng_style, PPK_color with rng_color, " + ;
5154 "PPK_label with rng_lbl, PPK_dimension with rng_pack " + ;
5155 ", itm_pKey with lnpkey"
5156 .ScatterGather(pcTransDetail, "tcRangeSLN", ;
5157 lcReplaceStr, lnItemPkey)
5158
5159 ENDSCAN
5160 Delete For rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk)+ ;
5161 Str(pick_num) = lcCurRangeSKU In (pcTransDetail)
5162 Append Blank
5163 Gather Name loRecord
5164 SELECT tcRangeSLN
5165 GO top
5166 Endif
5167 Endif
5168 ELSE
5169 CREATE CURSOR pcCurrentSLNs FROM ARRAY laRangeStru
5170 .PopulateSLNsForRangeP(lcCurRangeSKU, pcTransDetail, "pcCurrentSLNs")
5171 Endif
5172
5173 Endscan
5174 Use In Select("tcTemp")
5175 Endwith
5176
5177 Select(lnOldSelect)
5178 Return llRetVal
5179
5180 *- 1017241 07/25/06 YIK
5181 *- Need local version to populate sku_upc in __TmpCursor
5182 Procedure CheckRangeSLNUPCSKU
5183 Lparameters pcTransHeader, pcTransDetail, pcSLNPrePack, pcLineSLNPrepack
5184 Local llRetVal, lnOldSelect
5185 llRetVal = .T.
5186 lnOldSelect = Select()
5187 With This
5188 *--- TR 1052482 21-Feb-11 SK Added d.aux_sku
5189 Select distinct h.customer, d.aux_sku, p.* ;
5190 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
5191 Where h.Pkey = d.Fkey AND d.pkey = p.itm_pkey and h.sku_upc<> "N" ;
5192 Order by 1,2,3,4,5,6,7 Into Cursor _CustSLNPrepack
5193
5194 .MakeCursorWritable("_CustSLNPrepack", pcLineSLNPrepack)
5195 .TableClose("_CustSLNPrepack")
5196 * index for optimizing
5197 If Used(pcLineSLNPrepack)
5198 Select (pcLineSLNPrepack)
5199 Index on customer+division+PPK_style+PPK_color+PPK_label+PPK_dimension tag CustSKU
5200 Index on customer+division+style+color_code+Lbl_code+dimension+Str(sizebucket) tag CustSKU
5201 Endif
5202
5203 * Find ALL Component SKUs for Prepack SLN explosion.
5204 * Populate SKU into pcLineSLNPrepack
5205 *--- TR 1073064 30-Aug-13 Venuk. Added OR h.sku_upc= "A" ===
5206 Select distinct h.customer, p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
5207 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, h.sku_upc ;
5208 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
5209 Where h.Pkey = d.Fkey AND d.pkey = p.itm_pkey AND ;
5210 (h.sku_upc= "S" or h.sku_upc= "B" OR h.sku_upc= "A" ) ; && require component SKUs
5211 Order by 1,2,3,4,5,6,7 Into Cursor __TmpCursor
5212
5213 .cSQLTempTable=""
5214 If .GenerateSQLTempTable('__TmpCursor')
5215 If .PopulateSQLTempTable('__TmpCursor')
5216 If !Empty(.cSQLTempTable)
5217 llRetVal= llRetVal and .CheckOutboundSLNSKU(pcTransHeader, pcTransDetail, ;
5218 pcLineSLNPrepack, .cSQLTempTable, '__TmpCursor')
5219 Endif
5220 Endif
5221 Endif
5222 .TableClose('__TmpCursor')
5223
5224 * Find ALL Component UPCs for Prepack SLN explosion
5225 * Populate UPC into pcLineSLNPrepack
5226 *- ADDED , h.sku_upc
5227 *--- TR 1073064 30-Aug-13 Venuk. Added or h.sku_upc= "R" or h.sku_upc= "A" ===
5228 Select distinct p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
5229 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, h.sku_upc ;
5230 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
5231 Where h.Pkey = d.Fkey AND d.pkey = p.itm_pkey AND ;
5232 (h.sku_upc= "U" or h.sku_upc= "B" or h.sku_upc= "R" or h.sku_upc= "A" ) ; && require component UPCs
5233 Order by 1,2,3,4,5,6 Into Cursor __TmpCursor
5234
5235 .cSQLTempTable=""
5236 If .GenerateSQLTempTable('__TmpCursor')
5237 If .PopulateSQLTempTable('__TmpCursor')
5238 If !Empty(.cSQLTempTable)
5239 llRetVal= llRetVal and .CheckOutboundSLNUPC(pcTransHeader, pcTransDetail, ;
5240 pcLineSLNPrepack, .cSQLTempTable, '__TmpCursor')
5241 *llRetVal= llRetVal and .CheckOutboundSLNEAN(pcTransHeader, pcTransDetail, ; &&TR 1073064 30-Aug-13 Venuk. Commented
5242 * pcLineSLNPrepack, .cSQLTempTable, '__TmpCursor') &&TR 1073064 30-Aug-13 Venuk. Commented
5243 Endif
5244 Endif
5245 Endif
5246 .TableClose('__TmpCursor')
5247 *--- TR 1073064 30-Aug-13 Venuk.
5248 Select distinct p.division, p.style, p.color_code, p.Lbl_code, p.dimension,;
5249 p.sizebucket, p.PPK_style, p.PPK_color, p.PPK_label, p.PPK_dimension, h.sku_upc ;
5250 From (pcTransHeader) h, (pcTransDetail) d, (pcSLNPrePack) p ;
5251 Where h.Pkey = d.Fkey AND d.pkey = p.itm_pkey AND ;
5252 (h.sku_upc= "E" or h.sku_upc= "R" or h.sku_upc= "A" ) ; && require component UPCs
5253 Order by 1,2,3,4,5,6 Into Cursor __TmpCursor
5254
5255 .cSQLTempTable=""
5256 If .GenerateSQLTempTable('__TmpCursor')
5257 If .PopulateSQLTempTable('__TmpCursor')
5258 If !Empty(.cSQLTempTable)
5259 llRetVal= llRetVal and .CheckOutboundSLNEAN(pcTransHeader, pcTransDetail, ;
5260 pcLineSLNPrepack, .cSQLTempTable, '__TmpCursor')
5261 Endif
5262 Endif
5263 Endif
5264 .TableClose('__TmpCursor')
5265 *=== TR 1073064 30-Aug-13 Venuk.
5266 Endwith
5267
5268 If Used(pcLineSLNPrepack)
5269 Select (pcLineSLNPrepack)
5270 Index on ITM_Pkey tag ITM_Pkey
5271 Endif
5272
5273 Select(lnOldSelect)
5274 Return llRetVal
5275 Endproc
5276 *= 1017241
5277
5278 *- 1018323 08/01/06 YIK
5279 Procedure PopulateSLNsForRangeP
5280 LPARAMETERS pcCurRangeSKU, pcTransDetail, pcCurrentSLNs
5281 LOCAL lnOldSelect, llRetVal, lnCount, loRecord, lnOrigPkey, lnPkey
5282
5283 lnOldSelect = Select()
5284 With This
5285 * Consolidate group of trans. detail for same range style
5286 Select (pcTransDetail)
5287 If Seek(pcCurRangeSKU, pcTransDetail, "RangeSKU") and sln_req = 'Y'
5288 lcOrder = SET("ORDER")
5289 SET ORDER TO TAG RangeSKU
5290
5291 lnOrigPkey = PKey
5292 Scatter Name loRecord
5293
5294 *- Get all components for this range style
5295 lcSQLString = "select d.Division, d.Style, d.Color_code, d.Lbl_Code, d.Dimension, Size_Num as Size_Bk, " + ;
5296 "d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " + ;
5297 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " + ;
5298 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " + ;
5299 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " + ;
5300 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " + ;
5301 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " + ;
5302 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " + ;
5303 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " + ;
5304 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " + ;
5305 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " + ;
5306 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " + ;
5307 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 as Qty, " + ;
5308 "d.a_price, d.b_price, d.c_price, d.d_price, d.e_price " + ;
5309 "from zzxrangd d " + ;
5310 "cross join zzxbuckt b " + ;
5311 "where d.Size01_Qty*Sz01 + d.Size02_Qty*Sz02+ " + ;
5312 "d.Size03_Qty*Sz03 + d.Size04_Qty*Sz04+ " + ;
5313 "d.Size05_Qty*Sz05 + d.Size06_Qty*Sz06+ " + ;
5314 "d.Size07_Qty*Sz07 + d.Size08_Qty*Sz08+ " + ;
5315 "d.Size09_Qty*Sz09 + d.Size10_Qty*Sz10+ " + ;
5316 "d.Size11_Qty*Sz11 + d.Size12_Qty*Sz12+ " + ;
5317 "d.Size13_Qty*Sz13 + d.Size14_Qty*Sz14+ " + ;
5318 "d.Size15_Qty*Sz15 + d.Size16_Qty*Sz16+ " + ;
5319 "d.Size17_Qty*Sz17 + d.Size18_Qty*Sz18+ " + ;
5320 "d.Size19_Qty*Sz19 + d.Size20_Qty*Sz20+ " + ;
5321 "d.Size21_Qty*Sz21 + d.Size22_Qty*Sz22+ " + ;
5322 "d.Size23_Qty*Sz23 + d.Size24_Qty*Sz24 > 0 " + ;
5323 " AND Division = " + SQLFormatChar(loRecord.Division) + ;
5324 " AND rng_style = " + SQLFormatChar(loRecord.rng_style) + ;
5325 " AND rng_color = " + SQLFormatChar(loRecord.rng_color) + ;
5326 " AND rng_lbl = " + SQLFormatChar(loRecord.rng_lbl) + ;
5327 " AND rng_pack = " + SQLFormatChar(loRecord.rng_pack)
5328
5329 v_SQLExec(lcSQLString, "tcRangVert")
5330
5331 lnCount = RecCount("tcRangVert")
5332
5333 *-lnPkey = v_NextPKey(lcPkeySource, lnCount)
5334 *-lnCount = lnCount - 1
5335 *- lnPkey = lnPkey - lnCount && Starting pKey
5336 SELECT tcRangVert
5337 SCAN
5338 loRecord.style = tcRangVert.style
5339 loRecord.color_code = tcRangVert.color_code
5340 loRecord.lbl_code = tcRangVert.lbl_code
5341 loRecord.dimension = tcRangVert.dimension
5342 loRecord.sizebucket = tcRangVert.size_bk
5343 loRecord.total_qty = tcRangVert.qty
5344 loRecord.orig_qty= loRecord.total_qty
5345 lcPrice_code= iif(Empty(loRecord.price_code), 'a', loRecord.price_code)
5346 lnPrice= EVAL("tcRangVert." + lcPrice_code + "_price")
5347 loRecord.price= lnPrice
5348 loRecord.org_price= lnPrice
5349 *- loRecord.pkey = lnPKey
5350 lnPack_Total = loRecord.total_qty
5351 lnPack_Qty = loRecord.rng_qty
5352
5353 If !(used("tmpStylr") And (tmpStylr.division= loRecord.division And tmpStylr.style= loRecord.style))
5354 vl_stylr(loRecord.division,, "tmpStylr", loRecord.Style)
5355 Endif
5356 loRecord.style_name = tmpStylr.style_name
5357 loRecord.po4_uom = tmpStylr.uom
5358 * in getsizedesc also compare for current temp cursor size_code
5359 loRecord.size_desc = This.getSizeDesc(loRecord.division, tmpStylr.size_code, loRecord.sizebucket)
5360 IF vl_colrr(loRecord.Color_code,,"tmpcolrr")
5361 loRecord.color_name = tmpcolrr.color_name
5362 ENDIF
5363
5364 IF loRecord.sln_req = 'Y' && sln_req = 'Y' doesn't work for "P". itm_pkey is defined later...
5365 lnPPsize_qty = loRecord.total_qty
5366 SELECT tcRangeSLN
5367 Append Blank
5368 Gather Name loRecord
5369 Replace itm_pkey WITH lnOrigPkey, ;
5370 PPsize_qty WITH lnPPsize_qty, ;
5371 Pack_total WITH lnPack_total, ;
5372 Pack_qty WITH lnPack_qty, ;
5373 PPK_style with loRecord.rng_style, ;
5374 PPK_color with loRecord.rng_color, ;
5375 PPK_label with loRecord.rng_lbl, ;
5376 PPK_dimension with loRecord.rng_pack
5377
5378 *- This cursor contains the set of SLNs for the current pcCurRangeSKU
5379 SELECT pcCurrentSLNs
5380 Append Blank
5381 Gather Name loRecord
5382 Replace itm_pkey WITH lnOrigPkey, ;
5383 PPsize_qty WITH lnPPsize_qty, ;
5384 Pack_total WITH lnPack_total, ;
5385 Pack_qty WITH lnPack_qty, ;
5386 PPK_style with loRecord.rng_style, ;
5387 PPK_color with loRecord.rng_color, ;
5388 PPK_label with loRecord.rng_lbl, ;
5389 PPK_dimension with loRecord.rng_pack
5390 ELSE
5391 SELECT (pcTransDetail)
5392 Append Blank
5393 Gather Name loRecord
5394 ENDIF
5395 *-lnPkey = lnPkey + 1
5396 SELECT tcRangVert
5397 ENDSCAN
5398 Select (pcTransDetail)
5399 SCAN WHILE rng_style+ rng_color+ rng_lbl+ rng_pack+ Str(rng_bk) + Str(pick_num) = pcCurRangeSKU
5400 IF Sln_req = "Y"
5401 SELECT pcCurrentSLNs
5402 SCAN
5403 SCATTER NAME loSLN
5404 loSLN.itm_pkey = EVALUATE(pcTransDetail + ".PKey")
5405 SELECT tcRangeSLN
5406 Append Blank
5407 Gather Name loSLN
5408 ENDSCAN
5409 ENDIF
5410 ENDSCAN
5411 SET ORDER TO &lcOrder
5412 EndIF
5413 EndWith
5414 EndProc
5415 *= 1018323
5416
5417*============================================================
5418 *- 1020999 12/26/06 YIK
5419 *- If the system parameter "940_RETAIL_SOURCE" is set to "C" - populate retail price
5420 *- from the Customer Style, even if zero.
5421 *- If no record found in the Customer Style - keep the retail price from the Style Master.
5422 FUNCTION ResolvRetailFromCustStyle
5423 LPARAMETERS tcWorkDetail
5424 LOCAL llRetVal, lnSelect
5425
5426 llRetVal = .T.
5427 lnSelect = SELECT()
5428 WITH This
5429 SELECT DISTINCT Customer, Style, color_code, lbl_code, dimension ;
5430 FROM (tcWorkDetail) ;
5431 INTO CURSOR __TmpCursor
5432 .cSQLTempTable=""
5433 If .GenerateSQLTempTable('__TmpCursor')
5434 If .PopulateSQLTempTable('__TmpCursor')
5435 If !Empty(.cSQLTempTable)
5436 lcSQLString = "SELECT DISTINCT d.Customer, d.Style, d.color_code, " + ;
5437 "d.lbl_code, d.dimension, cst.Retail_Price " + ;
5438 "FROM " + .cSQLTempTable + " d " + ;
5439 "JOIN zzxcsthr cst ON " + ;
5440 "d.Style = cst.Style AND d.color_code = cst.color_code AND " + ;
5441 "d.lbl_code = cst.lbl_code AND d.dimension = cst.dimension "
5442
5443 llRetVal = v_SqlExec(lcSQLString, "tcCstPrice")
5444 If llRetVal
5445 Select tcCstPrice
5446 Index on Customer + style + color_code + Lbl_code + dimension tag OurSku
5447 llRetVal= .SetRelation("tcCstPrice", "OurSku", tcWorkDetail, ;
5448 "Customer + style + color_code + Lbl_code + dimension")
5449 If llRetVal
5450 REPLACE ALL ret_price WITH tcCstPrice.retail_price ;
5451 FOR !EMPTY(tcCstPrice.style) ;
5452 IN (tcWorkDetail)
5453 Set Relation to
5454 Endif
5455 Use In tcCstPrice
5456 ENDIF
5457 Endif
5458 Endif
5459 Endif
5460 .TableClose('__TmpCursor')
5461 ENDWITH
5462
5463 SELECT (lnSelect)
5464 RETURN llRetVal
5465 ENDFUNC
5466
5467 *--- 1022506 NH
5468 *********************************************************************************
5469
5470 *- TR 1058729 FH - we have two BulkInsertFromCursor methods. commenting this one
5471*!* PROCEDURE BulkInsertFromCursor
5472*!* LPARAMETERS tcSource,tcTarget
5473*!*
5474*!* WITH THIS
5475*!*
5476*!* LOCAL llRetVal,lnSelect,lcSource,lcSQL,lcFile,lcDirectory
5477*!* llRetVal = .T.
5478*!* lnSelect = SELECT()
5479*!* * lcDirectory = ADDBS(goEnv.sv("ALLOC_RESULTSAVE_BULKUNC",""))
5480*!* lcDirectory = This.GetEDIFlatFileDirectory("Inbound")
5481*!* lcDirectory = convertMapDrivePathToUnc(lcDirectory)
5482*!* * Convert map drive to UNC if necessary
5483*!*
5484*!* IF NOT DIRECTORY(lcDirectory)
5485*!* llRetVal = .F.
5486*!* .oLog.LogEntry("Could not locate Bulk Insert Save Location")
5487*!* ELSE
5488*!* lcFile = lcDirectory + GetUniqueFileName() + ".txt"
5489*!*
5490*!* IF EMPTY(tcSource)
5491*!* lcSource = ALIAS()
5492*!* ELSE
5493*!* lcSource = ALLTRIM(tcSource)
5494*!* ENDIF
5495
5496*!* IF NOT USED(lcSource)
5497*!* .LogEntry("Source Cursor is not found: " + lcSource)
5498*!* llRetVal = .F.
5499*!* ELSE
5500*!* SELECT (lcSource)
5501*!*
5502*!* * Output File to Server
5503*!* .LogEntry("BULK_INSERT: Creating Delimited file " + lcFile)
5504*!* COPY TO (lcFile) TYPE DELIMITED WITH "" WITH CHARACTER "|"
5505*!*
5506*!* IF NOT FILE(lcFile)
5507*!* llRetVal = .F.
5508*!* .LogEntry("BULK_INSERT: Failed to create delimited file. Consult Error log.")
5509*!* ELSE
5510*!* .LogEntry("BULK_INSERT: Successfully created delimited file")
5511*!* ENDIF
5512*!*
5513*!* IF llRetVal
5514*!* * Call Bulk Insert
5515*!* .LogEntry("BULK_INSERT: Performing Bulk Insert")
5516*!* lcSQL = "BULK INSERT " + tcTarget + ;
5517*!* " FROM '" + lcFile + "' WITH (FIELDTERMINATOR = '|') "
5518*!* llRetVal = v_sqlexec(lcSQL)
5519*!* ENDIF
5520*!*
5521*!* * Clean up the file when completed. We may want to leave a debugging option
5522*!* IF FILE(lcFile)
5523*!* DELETE FILE (lcFile)
5524*!* ENDIF
5525*!* ENDIF
5526*!* ENDIF
5527*!*
5528*!* ENDWITH
5529*!*
5530*!* SELECT (lnSelect)
5531*!* RETURN llRetVal
5532
5533*!* ENDPROC
5534 *- TR 1058729 FH - we have two BulkInsertFromCursor methods. commenting this one
5535 *********************************************************************************
5536 *======== TR 1022506
5537
5538*==============================================================================================================
5539 *--- TechRec 1024842 09-Oct-2007 jjanand ---
5540 PROCEDURE GetDNTNotesFromSysNotes
5541 LPARAMETERS tcInterfaceDetail,tcDNT
5542 LOCAL llRetVal, lnOldSelect, lcSQL, lcDNT
5543
5544 lnOldSelect = SELECT()
5545 llRetVal = .t.
5546
5547 this.oLog.LogEntry("Starting program : " + PROGRAM())
5548
5549 CREATE CURSOR tcDNTPkey (pkey i, ORD_NUM i, PICK_NUM I, line_seq i)
5550
5551 SELECT(tcInterfaceDetail)
5552
5553 SCAN
5554 SCATTER FIELDS pkey, ORD_NUM, PICK_NUM, line_seq memvar
5555 SELECT("tcDNTPkey")
5556 APPEND BLANK
5557 GATHER memvar
5558 ENDSCAN
5559
5560
5561 WITH THIS
5562 .cSQLTempTable = ""
5563 this.oLog.LogEntry(IIF(RECCOUNT("tcDNTPkey")>0,transform(RECCOUNT("tcDNTPkey")),"No ") + " Detail Notes found.")
5564
5565 IF RECCOUNT("tcDNTPkey") > 0
5566
5567 .cSQLTempTable = ""
5568 lcDNT_tmp = SYS(2015)
5569 &&--- TechRec 1057932 16-Dec-2011 vkrishnamurthy === Changed zzeoowcr to zzeoowcr_expl
5570 IF .GenerateSQLTempTable('tcDNTPkey') AND .PopulateSQLTempTable('tcDNTPkey')
5571 lcSQL = "select tc.pkey as fkey_940, p.pick_num, p.ord_num, n.Notes, n.Note_type,p.line_seq " +;
5572 " from ZZOORDRD p " +;
5573 " join " + .cSQLTempTable + " tc ON p.ord_num = tc.ord_num and p.pick_num = tc.pick_num and p.line_seq = tc.line_seq " +;
5574 " join SysNotes n " +;
5575 " on n.Table_Name = 'ZZOORDRD' " +;
5576 " and n.ord_num = p.ord_num " +;
5577 " and n.line_seq = p.line_seq " +;
5578 " join zzxNoTyp t " +;
5579 " on t.Note_Type = n.Note_Type " +;
5580 " join zzeoowcr_expl w " +;
5581 " on w.ware_code = p.location " +;
5582 " and w.active_ok = 'Y' " +;
5583 " and ((w.DTL_notes = 'E' and t.EDI_Note = 'Y') or w.DTL_notes = 'Y') "
5584
5585 llRetVal = llRetVal and .vSQLExec(lcSQL, lcDNT_tmp)
5586
5587 .ConvertMultiLineNotesToRows(lcDNT_tmp,tcDNT)
5588
5589 IF llRetVal
5590 SELECT(tcDNT)
5591 INDEX ON fkey TAG fkey
5592 ENDIF
5593
5594 ELSE
5595 .oLog.LogEntry("Warning: Unable to create detail notes temp table.")
5596 ENDIF
5597
5598 ENDIF
5599
5600 .oLog.LogEntry("Detail notes preparation " + IIF(llRetVal,"successful.","failed."))
5601 ENDWITH
5602
5603 SELECT(lnOldSelect)
5604 RETURN llRetVal
5605 ENDPROC
5606 *=== TechRec 1024842 09-Oct-2007 jjanand ===
5607*==============================================================================================================
5608
5609*--- TechRec 1033545 25-Jun-2008 T.Shenbagavalli ---
5610************************************************************************************
5611 * Validate GIFTBOXSKU *
5612***********************************************************************************
5613 PROCEDURE CheckGiftBoxSku
5614 LPARAMETERS pceoowTD
5615 Local llRetVal, lnOldSelect
5616 llRetVal = True
5617 lnOldSelect = Select()
5618
5619 SELECT(pceoowtD)
5620
5621 .PushRecordSet()
5622
5623 Replace All Errs_Flg_D With "Y", ;
5624 Errs_Msg_D with "No Gift Box SKU assigned to Style." ;
5625 For edipo4udf1 > 0 and EMPTY(giftboxsku) In (pceoowTD )
5626
5627 .PopRecordSet()
5628
5629 SELECT(lnOldSelect)
5630 RETURN llRetVal
5631 ENDPROC
5632*=== TechRec 1033545 25-Jun-2008 T.Shenbagavalli ===
5633
5634*============================================================
5635*--- TechRec 1039850 21-Apr-2009 vkrishnamurthy ---
5636 FUNCTION MarkBatchWithError
5637 LPARAMETERS tcWorkHeader
5638 *--- TR 1040737 23-Oct-2009 Partha added lcwave_num, lnBadRecords ---
5639 LOCAL llRetVal, lnSelect ,lcbill_num, lcwave_num, lnBadRecords
5640 *'Other picks for the same BOL have errors'
5641
5642 *--- TR 1040737 02-Sep-2009 Partha ---
5643 * If any one of the pick nums is bad, All the picks in the same WAVE will be marked as bad.
5644 * We are shifting the grouping from BILL_NUM to WAVE_NUM
5645 llRetVal = true
5646 lnSelect = SELECT()
5647
5648 *--- TR 1040737 02-Sep-2009 Partha ---
5649*!* Select Distinct bill_num From (tcWorkHeader) Where !Empty(Errs_Msg_H) AND !EMPTY(Bill_NUM) Into Cursor tcBadOrders
5650
5651 *- 23-Oct-2009 - wave number validation should be in addition with bill_num validation
5652 Select Distinct bill_num From (tcWorkHeader) Where !Empty(Errs_Msg_H) AND !EMPTY(Bill_NUM) Into Cursor tcBadBillOrders
5653
5654 Select Distinct wave_num From (tcWorkHeader) Where !Empty(Errs_Msg_H) AND !EMPTY(WAVE_NUM) Into Cursor tcBadWaveOrders
5655 *=== TR 1040737 02-Sep-2009 Partha ===
5656
5657 *--- TR 1040737 23-Oct-2009 Partha ---
5658*!* Select tcBadOrders
5659 *=== TR 1040737 23-Oct-2009 Partha ===
5660
5661 *--- TR 1040737 02-Sep-2009 Partha ---
5662*!* INDEX on bill_num TAG bill_num
5663
5664 Select tcBadBillOrders
5665 INDEX on bill_num TAG bill_num
5666
5667 Select tcBadWaveOrders
5668 INDEX on wave_num TAG wave_num
5669 *=== TR 1040737 02-Sep-2009 Partha ===
5670
5671 If This.lUserInterface
5672 * Init Thermometer
5673
5674 *--- TR 1040737 23-Oct-2009 Partha ---
5675*!* This.InitThermo(Recc('tcBadOrders'))
5676
5677 lnBadRecords = RECCOUNT('tcBadWaveOrders')
5678 lnBadRecords = IIF(lnBadRecords > 0, lnBadRecords, RECCOUNT('tcBadBillOrders'))
5679 This.InitThermo(lnBadRecords )
5680 *=== TR 1040737 23-Oct-2009 Partha ===
5681
5682 l_nThermoCnt = 0
5683 Endif
5684
5685 *--- TechRec 1040057 29-Apr-2009 vkrishnamurthy ---
5686*!* SCAN
5687*!* If This.lUserInterface
5688*!* * Advance progress bar, if we're using one.
5689*!* l_nThermoCnt = l_nThermoCnt + 1
5690*!* This.AdvanceThermo(l_nThermoCnt)
5691*!* Endif
5692
5693*!* Select (tcWorkHeader)
5694*!* Locate For bill_num = tcBadOrders.bill_num And Empty(Errs_Msg_H)
5695*!* If Found()
5696*!* Replace Errs_Msg_H With "Other Picks for the same BOL have errors." + CRLF, Errs_flg_H With "Y";
5697*!* In (tcWorkHeader)
5698*!* Endif
5699*!* ENDSCAN
5700
5701 *--- TR 1040807 NSD 6/26/09
5702 IF THis.lSQLPassThrough940
5703
5704 *--- TR 1040737 02-Sep-2009 Partha ---
5705*!* UPDATE h SET ;
5706*!* Errs_Msg_H = "Other Picks for the same BOL has errors." + CRLF,;
5707*!* errs_flg_H = "Y" ;
5708*!* FROM (tcWorkHeader) h ;
5709*!* JOIN tcBadOrders b ON h.bill_num = b.bill_num ;
5710*!* WHERE h.errs_flg_h <> "Y"
5711
5712 * 23-Oct-2009 Partha - wave_num validation is in addition to bill_num
5713 UPDATE h SET ;
5714 Errs_Msg_H = "Other Picks for the same WAVE has errors." + CRLF,;
5715 errs_flg_H = "Y" ;
5716 FROM (tcWorkHeader) h ;
5717 JOIN tcBadWaveOrders b ON h.wave_num = b.wave_num ;
5718 WHERE h.errs_flg_h <> "Y"
5719
5720 UPDATE h SET ;
5721 Errs_Msg_H = "Other Picks for the same BOL has errors." + CRLF,;
5722 errs_flg_H = "Y" ;
5723 FROM (tcWorkHeader) h ;
5724 JOIN tcBadBillOrders b ON h.bill_num = b.bill_num ;
5725 WHERE h.errs_flg_h <> "Y"
5726
5727 *=== TR 1040737 02-Sep-2009 Partha ===
5728
5729 ELSE
5730
5731 *--- TR 1040737 02-Sep-2009 Partha ---
5732 Select (tcWorkHeader)
5733 SCAN FOR Empty(Errs_Msg_H)
5734 lcwave_num = wave_num
5735 If This.lUserInterface
5736 * Advance progress bar, if we're using one.
5737 l_nThermoCnt = l_nThermoCnt + 1
5738 This.AdvanceThermo(l_nThermoCnt)
5739 Endif
5740
5741 Select tcBadWaveOrders
5742 Locate For wave_num = lcwave_num
5743 If Found()
5744 Replace Errs_Msg_H With "Other Picks for the same WAVE has errors." + CRLF, Errs_flg_H With "Y";
5745 In (tcWorkHeader)
5746 ENDIF
5747
5748 ENDSCAN
5749 *=== TR 1040737 02-Sep-2009 Partha ===
5750
5751 Select (tcWorkHeader)
5752
5753 SCAN FOR Empty(Errs_Msg_H)
5754 lcbill_num = bill_num
5755 If This.lUserInterface
5756 * Advance progress bar, if we're using one.
5757 l_nThermoCnt = l_nThermoCnt + 1
5758 This.AdvanceThermo(l_nThermoCnt)
5759 Endif
5760
5761 *--- TR 1040737 23-Oct-2009 Partha changed ---
5762*!* Select tcBadOrders
5763 Select tcBadBillOrders
5764 *=== TR 1040737 23-Oct-2009 Partha ===
5765
5766 Locate For bill_num = lcbill_num
5767 If Found()
5768 Replace Errs_Msg_H With "Other Picks for the same BOL has errors." + CRLF, Errs_flg_H With "Y";
5769 In (tcWorkHeader)
5770 ENDIF
5771
5772 ENDSCAN
5773
5774 ENDIF
5775 *=== TR 1040807 NSD 6/26/09
5776
5777 *=== TechRec 1040057 29-Apr-2009 vkrishnamurthy ===
5778
5779 *--- TR 1040737 23-Oct-2009 Partha ---
5780*!* Use In tcBadOrders
5781 Use In tcBadBillOrders
5782 Use In tcBadWaveOrders
5783 *=== TR 1040737 23-Oct-2009 Partha ===
5784
5785 IF This.lUserInterface
5786 * Reset Thermometer
5787 This.ResetThermo()
5788 ENDIF
5789
5790 SELECT (lnSelect)
5791 RETURN llRetVal
5792 ENDFUNC
5793*=== TechRec 1039850 21-Apr-2009 vkrishnamurthy ===
5794*============================================================
5795
5796
5797 *--- TR 1039378 31-Mar-2009 Partha ---
5798
5799*============================================================
5800 FUNCTION RetrieveColor
5801 LPARAMETERS pcTransHeader, pcTransDetail
5802 LOCAL llRetVal, lnSelect , lcSQLString ,lcDeatil ,lcErrs_Msg , lnPrePack ,lnPkey ,lcHeader, lcDetail ,;
5803 lnTotal_qty
5804
5805 llRetVal = true
5806 lnSelect = SELECT()
5807 WITH This
5808
5809 lcSQLString = " SELECT d.pkey,h.ent_date,d.division,d.style,d.color_code,d.lbl_code,d.dimension " + ;
5810 " FROM " + pcTransDetail + " d " + ;
5811 " JOIN " + pcTransHeader + " H " + ;
5812 " ON H.pkey = d.fkey " + ;
5813 " WHERE d.Errs_flg_d <> 'Y' " + ;
5814 " AND d.org_color = ' ' "
5815
5816 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc",,.T.)
5817
5818 IF USED("__RollingUpc") AND RECCOUNT("__RollingUpc") > 0
5819 llRetVal = .GenerateSQLTempTable("__RollingUpc") AND .PopulateSQLTempTable("__RollingUpc")
5820 lcDeatil = .cSQLTempTable
5821
5822 lcSQLString = " Select t.*, h.color_code AS new_color " + ;
5823 " FROM " + lcDeatil + " t " + ;
5824 " JOIN zzxrupcd d " + ;
5825 " ON d.division= t.division " + ;
5826 " and d.style= t.style " + ;
5827 " and d.new_color = t.color_code " + ;
5828 " and d.lbl_code = t.lbl_code " + ;
5829 " and d.dimension = t.dimension " + ;
5830 " JOIN zzxrupch h on h.pkey = d.fkey " + ;
5831 " WHERE h.active_ok = 'Y' " + ;
5832 " AND d.active_color = 'Y' "
5833
5834 llRetVal = llRetVal AND V_SqlExec( lcSQLString ,"__RollingUpc") AND USED("__RollingUpc")
5835
5836 IF llRetVal
5837 Select("__RollingUpc")
5838 INDEX on Pkey TAG Pkey
5839 .SetRelation("__RollingUpc", "pkey", pcTransDetail, "pkey")
5840
5841 REPLACE ALL org_Color WITH __RollingUpc.New_Color ;
5842 FOR NOT EOF("__RollingUpc") IN (pcTransDetail)
5843
5844 Set Relation To
5845 GOTO TOP
5846
5847 ENDIF
5848
5849 .TableClose("__RollingUpc")
5850
5851 ENDIF
5852
5853 *--- TR 1041685 NSD 8/11/09
5854 *llRetVal = llRetVal AND .SwapColor(pcTransDetail)
5855 IF llRetVAl
5856 SELECT distinct division,style,color_code,lbl_code,dimension,org_Color FROM (pcTransDetail) WHERE NOT EMPTY(org_color) INTO CURSOR __rollingupc2
5857 llREtVAl = llretVAl AND .GenerateSQLTempTable("__rollingupc2")
5858 IF llRetVAl
5859 .PopulateSQLTempTAble("__rollingupc2")
5860 .cRollingTempTable = .cSQLTempTable
5861 ENDIF
5862
5863 ENDIF
5864 use in select("__rollingupc2")
5865 *=== TR 1041685 NSD 8/11/09
5866
5867 ENDWITH
5868
5869 SELECT (lnSelect)
5870 RETURN true
5871 ENDFUNC
5872
5873*============================================================
5874
5875 FUNCTION SwapColor
5876 LPARAMETERS pcTransDetail,tcSQLTable,tlOrig
5877
5878 LOCAL llRetVal, lnSelect, lcTempColor
5879
5880 llRetVal = true
5881 lnSelect = SELECT()
5882
5883 WITH This
5884
5885 SELECT (pcTransDetail)
5886 .PushRecordSet()
5887 SET ORDER TO
5888 GOTO TOP
5889 SCAN FOR !EMPTY(org_color) AND !DELETED()
5890 lcTempColor = color_code
5891 REPLACE color_code WITH org_color, org_color WITH lcTempColor
5892 ENDSCAN
5893 .PopRecordSet()
5894
5895 IF NOT EMPTY(.cRollingTempTable) AND NOT EMPTY(tcSQLTable)
5896 llRetVal = llRetVal AND v_sqlexec(;
5897 "UPDATE d " + ;
5898 " SET color_code = t." + IIF(tlOrig,"org_color","color_code") + ;
5899 " FROM " + tcSQLTable + " d " + ;
5900 " JOIN " + .cRollingTempTable + " t " + ;
5901 " ON d.division = t.division " + ;
5902 " AND d.style = t.style " + ;
5903 " AND d.color_code = t." + IIF(tlOrig,"color_code","org_color") + ;
5904 " AND d.lbl_code = t.lbl_code " + ;
5905 " AND d.dimension = t.dimension ")
5906 ENDIF
5907
5908
5909 ENDWITH
5910
5911 SELECT (lnSelect)
5912 RETURN true
5913 ENDFUNC
5914*============================================================
5915
5916
5917 *--- TR 1040807 NSD 6/26/09
5918 *--------------------------------------------------------------------------
5919 * Instance level version of createSQL view. If we are not in passthrough mode, simply call DODEFAULT
5920 * If we are in passthrough mode, write viewname and definition to array. OPENTABLE will execute the SQL.
5921 FUNCTION CreateSQLView
5922 LPARAMETERS tcViewName, tcSqlStr, tcTable, tcOrderBy, tcPkey, tcViewDBCName
5923
5924 LOCAL llRetVal,lnArrayRow
5925 llRetVal = .T.
5926
5927
5928 IF NOT THIS.lSQLPassThrough940
5929 llRetVal = DODEFAULT(tcViewName, tcSqlStr, tcTable, tcOrderBy, tcPkey, tcViewDBCName)
5930 ELSE
5931 WITH THIS
5932 lnArrayRow = ALEN(.aViews,1)
5933
5934
5935 tcOrderBy = IIF(UPPER(tcOrderBy)=="NOORDERBY","",tcOrderBy)
5936
5937 IF lnArrayRow > 1 OR NOT EMPTY(.aViews[1,1])
5938 lnArrayRow = lnArrayRow + 1
5939 DIMENSION .aViews[(lnArrayRow),3]
5940 ENDIF
5941
5942 .aViews[lnArrayRow,1] = LOWER(ALLTRIM(tcViewName))
5943 .aViews[lnArrayRow,2] = tcSqlStr
5944 .aViews[lnArrayRow,3] = tcOrderBy
5945
5946 ENDWITH
5947 ENDIF
5948
5949
5950 RETURN llRetVal
5951
5952 ENDFUNC
5953
5954 *-----------------------------------------------------------------------------------
5955 * This class no longer uses buffered views. To get around this, we created an instance
5956 * level version of this method. If using buffered views, then dodefault, otherwise read
5957 * the aViews array, and execute the SQL to build the cursor
5958 *
5959 FUNCTION OPENTABLE
5960 LPARAMETERS pcTable, plNotUpdatable, plNotNodata, ;
5961 pcPkey, pnCursorBuffer, pcTimeStamp, plOverWrite, plSelectOpenTable
5962
5963 LOCAL llRetVal,lnRow,lcSQL,lcOrderBy,lnX
5964 llRetVal = .T.
5965 lnRow = 0
5966 lcOrderBy = ""
5967
5968 IF NOT THIS.lSQLPassThrough940
5969 llRetVal = DODEFAULT(pcTable, plNotUpdatable, plNotNodata, ;
5970 pcPkey, pnCursorBuffer, pcTimeStamp, plOverWrite, plSelectOpenTable )
5971 ELSE
5972
5973 WITH THIS
5974
5975 pcTable = ALLTRIM(LOWER(pcTable))
5976
5977 * Using a FOR LOOP here. Will replace with better method later.
5978 FOR lnX = 1 TO ALEN(.aViews,1)
5979 IF pcTable == .aViews[lnX ,1]
5980 lnRow = lnX
5981 EXIT
5982 ENDIF
5983 ENDFOR
5984
5985 IF lnRow > 0
5986 * IF the view is not found, we do not error out, just do nothing.
5987
5988 IF NOT EMPTY(.aViews[lnRow,3])
5989 lcOrderBy = " ORDER BY " + .aViews[lnRow,3]
5990 ENDIF
5991 lcSQL = .aViews[lnRow,2] + lcOrderBy
5992
5993 IF NOT plNotNodata
5994 * Confusing variable, but being in this clause means we want only metadata back
5995 llRetVal = llRetVal AND v_sqlexec("SET FMTONLY ON")
5996 ENDIF
5997
5998 USE IN SELECT(pcTable)
5999 llRetVal = llRetVal AND v_sqlexec(lcSQL,pcTable)
6000
6001 IF llRetVal
6002 * This will turn buffering completely off.
6003 SELECT * INTO CURSOR (pcTable) READWRITE FROM (pcTable)
6004 ENDIF
6005
6006 IF plNotNodata
6007 llRetVal = llRetVal AND v_sqlexec("SET FMTONLY OFF")
6008 ENDIF
6009
6010 ENDIF
6011
6012 ENDWITH
6013
6014 ENDIF
6015
6016 RETURN llRetVal
6017
6018 ENDPROC
6019
6020
6021 *---------------------------------------------------------
6022 * Loop through the array of tables. Send to TableUpdateFromCursorOne
6023 FUNCTION TableUpdateFromCursor
6024 LPARAMETERS paTables
6025
6026 LOCAL llRetVal,lnTableCount,lnX,lcTable,lcView
6027 llRetVal = .T.
6028
6029 lnTableCount = ALEN(paTables,1)
6030 FOR lnX = 1 TO lnTableCount
6031 lcView = paTables[lnX]
6032 lcTable= SUBSTR(lcView,2,8)
6033 llRetVal = llRetVal AND THIS.TableUpdateFromCursorOne(lcTable,lcView)
6034 ENDFOR
6035
6036 RETURN llRetVal
6037
6038 ENDFUNC
6039
6040 *---------------------------------------------------------
6041 * Taken from AlloAval.prg. Insert all records from a cursor into a table.
6042 PROCEDURE TableUpdateFromCursorOne
6043 LPARAMETERS tcTarget, tcSource
6044 LOCAL llRetVal, lnSelect, lcSource, lcSQL
6045
6046 llRetVal = .T.
6047 lnSelect = SELECT()
6048
6049 IF EMPTY(tcSource)
6050 lcSource = ALIAS()
6051 ELSE
6052 lcSource = ALLTRIM(tcSource)
6053 ENDIF
6054
6055 IF USED(lcSource)
6056
6057 SELECT (lcSource)
6058 lcSQL = BuildInsertString(tcTarget,lcSource)
6059
6060 SELECT (lcSource)
6061 GO TOP
6062 SCAN WHILE llRetVal
6063 llRetVal = llRetVal AND v_SQLExec(lcSQL)
6064 ENDSCAN
6065
6066 ELSE
6067 llRetVal = .F.
6068 ENDIF
6069
6070 SELECT (lnSelect)
6071 RETURN llRetVal
6072 ENDPROC
6073
6074 * Very simple. If the cursor provided is not a buffered view, then do a bulk insert
6075 FUNCTION PopulateSQLTempTable && ATS 3828 Server side joins
6076 LPARAMETER pcDataSource
6077 LOCAL lnSelect,llRetVal
6078 lnSelect = SELECT()
6079
6080 SELECT (pcDataSource)
6081 llRetVal = .T.
6082 IF CURSORGETPROP("Buffering") = 5 OR ;
6083 NOT THIS.BulkInsertFromCursor(pcDataSource,THIS.cSQLTempTable)
6084 llRetVal = DODEFAULT(pcDataSource)
6085 ENDIF
6086
6087 SELECT (lnSelect)
6088 RETURN llRetVal
6089
6090 ENDFUNC
6091
6092 * This will create a pipe delimited file and then do a SQL bulk insert into a table.
6093 PROCEDURE BulkInsertFromCursor
6094 LPARAMETERS tcSource,tcTarget
6095
6096 WITH THIS
6097
6098 LOCAL llRetVal,lnSelect,lcSource,lcSQL,lcFile,lcDirectory
6099 llRetVal = .T.
6100 lnSelect = SELECT()
6101
6102* lcDirectory = ADDBS(goEnv.sv("ALLOC_RESULTSAVE_BULKUNC",""))
6103 lcDirectory = This.GetEDIFlatFileDirectory("Inbound")
6104 lcDirectory = convertMapDrivePathToUnc(lcDirectory)
6105 * Convert map drive to UNC if necessary
6106
6107 IF NOT DIRECTORY(lcDirectory)
6108 llRetVal = .F.
6109 .oLog.LogEntry("Could not locate Bulk Insert Save Location")
6110 ELSE
6111 lcFile = lcDirectory + GetUniqueFileName() + this.class + ".txt" &&*- 1058729 FH
6112
6113 IF EMPTY(tcSource)
6114 lcSource = ALIAS()
6115 ELSE
6116 lcSource = ALLTRIM(tcSource)
6117 ENDIF
6118
6119 IF NOT USED(lcSource)
6120 .oLog.LogEntry("Source Cursor is not found: " + lcSource)
6121 llRetVal = .F.
6122 ELSE
6123
6124 * IF LEFT(tcTarget,1) = "#"
6125 * SELECT * FROM (lcSource) INTO CURSOR (lcSource) READWRITE
6126 * * Temp table, make sure NULLS are not possible
6127 * .GiveTempTableDefaults(tcTarget,lcSource)
6128 * ENDIF
6129
6130
6131 SELECT (lcSource)
6132
6133 * Output File to Server
6134 *.olog.LogEntry("BULK_INSERT: Creating Delimited file " + lcFile)
6135 COPY TO (lcFile) TYPE DELIMITED WITH "" WITH CHARACTER "|"
6136
6137 IF NOT FILE(lcFile)
6138 llRetVal = .F.
6139 *.oLog.LogEntry("BULK_INSERT: Failed to create delimited file. Consult Error log.")
6140 ELSE
6141 *.olog.LogEnty("BULK_INSERT: Successfully created delimited file")
6142 *- 1058729 FH - adds temp file path to array. The array is always full, we increment it's size only when we need to
6143 this.nCounter = this.nCounter + 1
6144 DIMENSION this.aBulkTables[this.nCounter]
6145 this.aBulkTables[this.nCounter] = lcFile
6146 *- 1058729 FH
6147 ENDIF
6148
6149 IF llRetVal
6150 *- TR 1101105 FH - support for different date formats
6151 lcSQLdateFormat=""
6152 lcSQLdateFormat=GetSqlCurrentDateFormat() && reset it back afterwards
6153 lcSQL = ""
6154 lcDateFormat = getDateFormat(EDI_USER)
6155 DO case
6156 CASE INLIST(lcDateFormat, 'BRITISH','FRENCH','GERMAN','ITALIAN','DMY')
6157 lcSQL = " SET DATEFORMAT DMY "
6158 CASE INLIST(lcDateFormat, 'JAPAN','TAIWAN','ANSI','YMD')
6159 lcSQL = " SET DATEFORMAT YMD "
6160 OTHERWISE && otherwise leave lcSQL empty, assume it's MDY
6161 ENDCASE
6162 *-TR 1101105 FH
6163
6164 * Call Bulk Insert
6165 *.olog.LogEntry("BULK_INSERT: Performing Bulk Insert")
6166 lcSQL = lcSQL + "BULK INSERT " + tcTarget + ; && FH 1101105 - added lcSQL before
6167 " FROM '" + lcFile + "' WITH (FIELDTERMINATOR = '|') "
6168
6169 llRetVal = v_sqlexec(lcSQL)
6170
6171 *- TR 1101105 FH
6172 If !Empty(lcSQLdateFormat)
6173 lcSQL = " SET DATEFORMAT "+lcSQLdateFormat+" "
6174 llRetVal = llRetVal And v_sqlExec(lcSQL)
6175 Endif
6176 *- TR 1101105 FH
6177 ENDIF
6178 IF llRetVal
6179 .RemoveCharNullFromTempTable(tcTarget)
6180 endif
6181
6182 * Clean up the file when completed. We may want to leave a debugging option
6183 IF FILE(lcFile)
6184 *- TR 1058729 FH
6185 *DELETE FILE (lcFile)
6186 sysnoerror("DELETE FILE " + lcFile)
6187 ENDIF
6188 ENDIF
6189 ENDIF
6190
6191 ENDWITH
6192
6193 SELECT (lnSelect)
6194 RETURN llRetVal
6195
6196 ENDPROC
6197
6198 PROCEDURE CreateSQLTableStructureString
6199 LPARAMETER taDetail
6200 EXTERNAL ARRAY taDetail
6201
6202 LOCAL lcRetVal, lnX
6203
6204 lcRetVal = "("
6205 FOR lnX = 1 TO ALEN(taDetail, 1)
6206 lcFieldName = taDetail[lnX, 1] + " "
6207
6208 IF taDetail[lnX, 2] = "M"
6209 * No Note fields
6210 LOOP
6211 ENDIF
6212
6213 lcDataType = UPPER(VFPToSQLDataType(taDetail[lnX, 2]))
6214
6215 lcFieldSize = This.GetDataFieldSize(taDetail[lnX, 2], taDetail[lnX, 3], taDetail[lnX, 4])
6216
6217 lcRetVal = lcRetVal + lcFieldName + lcDataType + lcFieldSize + ","
6218 ENDFOR
6219 lcRetVal = This.RemoveLastDelimiter(lcRetVal, ",") + ")"
6220 RETURN lcRetVal
6221 ENDPROC
6222
6223 *---------------------------------------------------------------
6224 PROCEDURE GiveTempTableDefaults
6225 LPARAMETERS lcTmpTable,lcSource
6226
6227 LOCAL lcSQL,lcField,lcDataType,lcFieldSize ,llRetVal,lcDefault,lcRepl
6228 llRetVal = .T.
6229
6230 =SQLCOLUMNS(g_nHandle,lcTmpTable,"FOXPRO","tcTmpFields")
6231 SELECT tcTmpFields
6232 SCAN
6233 lcField = ALLTRIM(tcTmpFields.field_name)
6234 lcDataType = UPPER(VFPToSQLDataType(tcTmpFields.field_type))
6235 lcFieldSize = This.GetDataFieldSize(tcTmpFields.field_type,;
6236 tcTmpFields.field_len,tcTmpFields.field_dec)
6237
6238 DO CASE
6239 CASE INLIST(lcDataType ,'C','M','CHAR','TEXT','BIT','VARCHAR','CLOB','VARG')
6240 lcDefault= SQLFormatChar("")
6241 CASE INLIST(lcDataType ,'I','N','MONEY','INT','INTEGER','BIGINT','SMALLINT','TINYINT','FLOAT','NUMERIC','REAL','SMALLMONEY')
6242 lcDefault= SQLFormatNum(0)
6243 CASE INLIST(lcDataType ,'T','D','DATETIME','SMALLDATETIME','TIMESTMP','DATE')
6244 lcDefault= SQLFormatTS(DATE(1900,1,1))
6245 ENDCASE
6246
6247
6248 lcSQL = ;
6249 "ALTER TABLE " + lcTmpTable + " ALTER COLUMN " + lcField + ;
6250 " " + lcDataType + " " + lcFieldSize + " NOT NULL "
6251 llRetVal = llRetVal AND v_sqlexec(lcSQL)
6252
6253 lcSQL = ;
6254 "ALTER TABLE " + lcTmpTable + " ADD CONSTRAINT " + lcField + ;
6255 "_" + getuniquefilename() + "_def DEFAULT "+lcDefault+" FOR " + lcField
6256 llRetVal = llRetVal AND v_sqlexec(lcSQL)
6257
6258 ENDSCAN
6259
6260
6261
6262
6263 RETURN llRetVal
6264
6265 ENDPROC
6266
6267
6268 PROCEDURE RemoveCharNullFromTempTable
6269 LPARAMETERS lcTmpTable
6270
6271 LOCAL lcSQL,lcField,lcDataType,lcFieldSize ,llRetVal,lcDefault
6272 llRetVal = .T.
6273
6274 =SQLCOLUMNS(g_nHandle,lcTmpTable,"FOXPRO","tcTmpFields")
6275 SELECT tcTmpFields
6276 SCAN
6277 lcField = ALLTRIM(tcTmpFields.field_name)
6278 lcDataType = UPPER(VFPToSQLDataType(tcTmpFields.field_type))
6279
6280 DO CASE
6281 CASE INLIST(lcDataType ,'C','M','CHAR','TEXT','BIT','VARCHAR','CLOB','VARG')
6282 lcSQL = " UPDATE " + lcTmpTable + " SET " + lcField + " = '' WHERE " + lcField + " IS NULL "
6283 llRetVal = llRetVal AND v_sqlexec(lcSQL)
6284 OTHERWISE
6285 ENDCASE
6286
6287 ENDSCAN
6288
6289
6290 RETURN llRetVal
6291
6292 ENDPROC
6293
6294 PROCEDURE CacheData
6295
6296 LOCAL llRetVal,lnSelect
6297 llRetVal = .T.
6298 lnSelect = SELECT()
6299
6300 WITH THIS
6301 IF .lSQLPassThrough940
6302 LOCAL lcSQL
6303 SELECT ord_num,pick_num FROM (.cWorkHeader) INTO CURSOR __pick_1
6304 IF .GenerateSQLTempTable('__pick_1') AND .PopulateSQLTempTable('__pick_1')
6305 lcSQL = ;
6306 "SELECT d.pick_num, CASE WHEN MAX(ppack_ok) <> 'Y' THEN 'O' " + ;
6307 " WHEN MAX(ppack_ok) = 'Y' AND MIN(ppack_ok) = 'Y' THEN 'P' " + ;
6308 " ELSE 'B' END as is_ppk " + ;
6309 " ,MAX(proc_856) as proc_856 " + ;
6310 " FROM zzoordrd d " + ;
6311 " JOIN " + .cSQLTempTable + " t ON d.pick_num = t.pick_num " + ;
6312 " JOIN zzoordrh h ON d.fkey = h.pkey " + ;
6313 " JOIN zzxscolr sc " + ;
6314 " ON sc.division= d.division " + ;
6315 " AND sc.style= d.style " + ;
6316 " AND sc.color_code= d.color_code " + ;
6317 " AND sc.lbl_code= d.lbl_code " + ;
6318 " AND sc.dimension= d.dimension " + ;
6319 " GROUP BY d.pick_num "
6320
6321 llRetVal = llRetVal AND v_sqlexec(lcSQL,"tcPickPrePack")
6322 IF llRetVal
6323
6324 SELECT tcPickPrePack
6325 INDEX ON ALLTRIM(proc_856) TAG proc_856
6326 INDEX On pick_num TAG pick_num
6327
6328 ENDIF
6329
6330 * get pre asn cartons
6331 lcSQL = ;
6332 "SELECT s.pick_num,h.* FROM zzoctnph h WITH (NOLOCK) "+;
6333 " JOIN zzoordsp s WITH (NOLOCK) ON s.pkey = h.fkey " + ;
6334 " JOIN " + .cSQLTempTable + " t " + ;
6335 " ON s.ord_num = t.ord_num " + ;
6336 " AND s.pick_num = t.pick_num " + ;
6337 " AND s.inv_num = 0 " + ;
6338 " AND s.carton_cls = 'S'"
6339 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__zzoctnph_cache")
6340 IF llRetVal
6341 SELECT __zzoctnph_cache
6342 INDEX ON pick_num TAG pick_num
6343 ENDIF
6344
6345
6346 lcSQL = ;
6347 "SELECT s.pick_num,d.* FROM zzoctnph h WITH (NOLOCK) "+;
6348 " JOIN zzoctnpd d WITH (NOLOCK) ON h.pkey = d.fkey " + ;
6349 " JOIN zzoordsp s WITH (NOLOCK) ON s.pkey = h.fkey " + ;
6350 " JOIN " + .cSQLTempTable + " t " + ;
6351 " ON s.ord_num = t.ord_num " + ;
6352 " AND s.pick_num = t.pick_num " + ;
6353 " AND s.inv_num = 0 " + ;
6354 " AND s.carton_cls = 'S'"
6355 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__zzoctnpd_cache")
6356 IF llRetVal
6357 SELECT __zzoctnpd_cache
6358 INDEX ON pick_num TAG pick_num
6359 ENDIF
6360
6361 IF SEEK("Y","tcPickPrePack","proc_856")
6362 * Get post asn cartons
6363 lcSQL = ;
6364 "SELECT s.pick_num,h.* FROM zzoctnsh h WITH (NOLOCK) "+;
6365 " JOIN zzoordsp s WITH (NOLOCK) ON s.pkey = h.fkey " + ;
6366 " JOIN " + .cSQLTempTable + " t " + ;
6367 " ON s.ord_num = t.ord_num " + ;
6368 " AND s.pick_num = t.pick_num " + ;
6369 " AND s.inv_num = 0 " + ;
6370 " AND s.carton_cls = 'S'"
6371 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__zzoctnsh_cache")
6372 IF llRetVal
6373 SELECT __zzoctnsh_cache
6374 INDEX ON pick_num TAG pick_num
6375 ENDIF
6376
6377 ENDIF
6378
6379 * Order Net Extended Cursors
6380 * Header
6381 *- TR 1057421/1056244 FH - added h.tax_empt to select
6382 lcSQL = ;
6383 "Select h.ord_num, h.pick_num, h.inv_num, h.disc_amt, h.frgt_amt, h.insu_amt, h.misc_amt, h.tax_amt, h.customer, h.tax_empt " + ;
6384 " From zzoordrh h " + ;
6385 " JOIN " + .cSQLTempTable + " t " + ;
6386 " ON h.ord_num = t.ord_num " + ;
6387 " AND h.pick_num = t.pick_num " + ;
6388 " AND h.ord_status = 'P' "
6389 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__ordnetext_hdr")
6390 IF llRetVal
6391 SELECT __ordnetext_hdr
6392 INDEX ON pick_num TAG pick_num
6393 ENDIF
6394
6395 * Detail
6396 lcSQL = ;
6397 " Select d.ord_num, d.pick_num, d.inv_num, d.line_seq, d.price, d.total_qty, d.discount " + ;
6398 " From zzoordrd d" + ;
6399 " JOIN " + .cSQLTempTable + " t " + ;
6400 " ON d.ord_num = t.ord_num " + ;
6401 " AND d.pick_num = t.pick_num " + ;
6402 " AND d.line_status = 'P' "
6403 llRetVal = llRetVal AND v_sqlexec(lcSQL,"__ordnetext_dtl")
6404 IF llRetVal
6405 SELECT __ordnetext_dtl
6406 INDEX ON pick_num TAG pick_num
6407 ENDIF
6408
6409 ENDIF
6410 v_sqlexecnoerror("DROP TABLE " + .cSQLTempTable)
6411 USE IN SELECT("__pick_1")
6412 ENDIF
6413 ENDWITH
6414
6415 SELECT(lnSelect)
6416 RETURN llRetVal
6417
6418 ENDPROC
6419 *=== TR 1040807 NSD 6/26/09
6420
6421 *-------------------------------------------------
6422 Procedure CheckOutboundUPC
6423 Lparameters pcTransHeader, pcTransDetail, pcSQLTempTable, plNotOverwriteSizeDesc, pcSkipPpkUpc
6424
6425 LOCAL llRetVal
6426 llRetVal = .T.
6427
6428
6429 llRetVal = llRetVal AND THIS.SwapColor(pcTransDetail,pcSQLTempTable,.T.)
6430 llRetVal = llRetVal AND DODEFAULT(pcTransHeader, pcTransDetail, pcSQLTempTable, plNotOverwriteSizeDesc, pcSkipPpkUpc)
6431 llRetVal = llRetVal AND THIS.SwapColor(pcTransDetail,pcSQLTempTable,.F.)
6432
6433 RETURN llRetVal
6434
6435 ENDPROC
6436
6437 *--- TechRec 1052941 16-Mar-2011 MANI. ---
6438 *=================================================================================
6439 *-- Function : CreateWhsData
6440 *-- Synozis : Create warehouse EDIH, EDID datas from zzedatawhse table
6441 *-- Parameter: tcHdr - WorkHeader, tcDtl - Work Detail
6442 *=================================================================================
6443 FUNCTION CreateWhsData
6444 LPARAMETERS tcHdr, tcDtl
6445 LOCAL llRetVal, lnSelect, lcTmpIntHdr, lcTmpIntDtl, lcTmpIntSlnToDtl, lcSqlUnion ,lcSqlDtl && TR 1073384 FH- lcTmpIntSlnToDtl, lcSqlUnion, lcSqlDtl
6446
6447 llRetVal = True
6448 lnSelect = SELECT()
6449
6450 WITH This
6451 SELECT ord_num, location FROM (tcHdr) oh JOIN (.cControlReference);
6452 ctr ON ctr.ware_code = oh.location AND ;
6453 ctr.Active_ok = 'Y' AND ctr.Data_Whse = 'Y' ;
6454 INTO CURSOR __TmpIntHdr
6455
6456 *- TR 1073384 FH - shouldn't set llRetVal base on PopulateSQLTempTable (PopulateSQLTempTable returns .F. if source is empty
6457 *- We don't want to fail the process
6458
6459*!* llRetVal = llRetVal AND .GenerateSQLTempTable('__TmpIntHdr') AND .PopulateSQLTempTable('__TmpIntHdr')
6460*!* lcTmpIntHdr = .cSQLTempTable
6461 IF .GenerateSQLTempTable('__TmpIntHdr') AND .PopulateSQLTempTable('__TmpIntHdr')
6462 lcTmpIntHdr = .cSQLTempTable
6463 endif
6464
6465 SELECT pod.ord_num, pod.line_seq, ;
6466 pod.Sizebucket, pod.location, pod.pkey ;
6467 FROM (tcDtl) pod JOIN (.cControlReference);
6468 ctr ON ctr.ware_code = pod.location AND ;
6469 ctr.Active_ok = 'Y' AND ctr.Data_Whse = 'Y' ;
6470 INTO CURSOR __TmpIntDtl
6471
6472 *- TR 1073384 FH - shouldn't set llRetVal base on PopulateSQLTempTable (PopulateSQLTempTable returns .F. if source is empty
6473 *- We don't want to fail the process
6474*!* llRetVal = llRetVal AND .GenerateSQLTempTable('__TmpIntDtl') AND .PopulateSQLTempTable('__TmpIntDtl')
6475*!* lcTmpIntDtl = .cSQLTempTable
6476 If .GenerateSQLTempTable('__TmpIntDtl') AND .PopulateSQLTempTable('__TmpIntDtl')
6477 lcTmpIntDtl = .cSQLTempTable
6478 ENDIF
6479
6480 *- TR 1073384 FH - when we are using slntodtl
6481 SELECT pod.ord_num, pod1.line_seq, ; && line_seq is min(line_seq) group by (ord_num, assortment, po1_line)
6482 pod.Sizebucket, pod.location, pod.pkey, pod.assortment, pod.sln01 ;
6483 FROM (tcDtl) pod ;
6484 JOIN (SELECT ord_num, assortment, po1_line, MIN(line_seq) as line_seq ;
6485 FROM (tcDtl) GROUP BY ord_num, assortment, po1_line) pod1 ;
6486 ON pod.ord_num = pod1.ord_num ;
6487 and pod.assortment = pod1.assortment ;
6488 AND pod.po1_line = pod1.po1_line;
6489 JOIN (.cControlReference);
6490 ctr ON ctr.ware_code = pod.location AND ;
6491 ctr.Active_ok = 'Y' AND ctr.Data_Whse = 'Y' ;
6492 WHERE pod.slntodtl IN ('Y','I') ;
6493 INTO CURSOR __TmpIntSlnToDtl
6494
6495 IF .GenerateSQLTempTable('__TmpIntSlnToDtl') AND .PopulateSQLTempTable('__TmpIntSlnToDtl')
6496 lcTmpIntSlnToDtl = .cSQLTempTable
6497 endif
6498 *- TR 1073384 FH - when we are using slntodtl
6499
6500 *-- Header Record (EDIH) population
6501 IF llRetVal AND NOT EMPTY(lcTmpIntHdr)
6502
6503 lcSql = " SELECT Wsh.Pkey, " + ;
6504 " Wsh.Ord_Num, " + ;
6505 " Wsh.Segment, " + ;
6506 " Wsh.Element, " + ;
6507 " Wsh.Qualifier, " + ;
6508 " Wsh.Value " + ;
6509 " FROM zzedatawhse Wsh WITH (NOLOCK) " + ;
6510 " JOIN "+ lcTmpIntHdr + " Oh ON oh.ord_num = Wsh.ord_num " + ;
6511 " AND Wsh.table_name = 'ZZOORDRH' "
6512
6513*-- If need to export only 2 records to the flat file we need to add the following query
6514* " AND Wsh.element = '02'"+ ;
6515 " AND Wsh.segment = 'REF'" + ;
6516 " AND Wsh.qualifier = '19'" + ;
6517 " AND Wsh.pkey = (SELECT MAX(w1.pkey) FROM zzedatawhse w1 WITH (NOLOCK) " + ;
6518 " WHERE w1.ord_num = Wsh.ord_num "+ ;
6519 " AND w1.table_name = 'ZZOORDRH' " + ;
6520 " AND w1.element = '02' " + ;
6521 " AND w1.segment = 'REF'" + ;
6522 " AND w1.qualifier = '19')" + ;
6523 " UNION ALL " + ;
6524 " SELECT Wsh.Pkey, " + ;
6525 " Wsh.Ord_Num, " + ;
6526 " Wsh.Segment, " + ;
6527 " Wsh.Element, " + ;
6528 " Wsh.Qualifier, " + ;
6529 " Wsh.Value " + ;
6530 " FROM zzedatawhse Wsh WITH (NOLOCK) " + ;
6531 " JOIN "+ lcTmpIntHdr + " Oh ON oh.ord_num = Wsh.ord_num " + ;
6532 " AND Wsh.table_name = 'ZZOORDRH' "+ ;
6533 " AND Wsh.element = '02'"+ ;
6534 " AND Wsh.segment = 'N1'" + ;
6535 " AND Wsh.qualifier = 'BT'" + ;
6536 " AND Wsh.pkey = (SELECT MAX(w1.pkey) FROM zzedatawhse w1 WITH (NOLOCK) " + ;
6537 " WHERE w1.ord_num = Wsh.ord_num "+ ;
6538 " AND w1.table_name = 'ZZOORDRH' " + ;
6539 " AND w1.element = '02' " + ;
6540 " AND w1.segment = 'N1'" + ;
6541 " AND w1.qualifier = 'BT')"
6542
6543 llRetVal = llRetVal AND v_sqlexec(lcSQL, .cWorkWhsHdr)
6544 ENDIF && llRetVal AND NOT EMPTY(lcTmpIntHdr)
6545
6546 *-- Detail Record (EDID) population
6547 *IF llRetVal AND NOT EMPTY(lcTmpIntDtl) &&1073384 FH
6548 IF llRetVal AND NOT(EMPTY(lcTmpIntDtl) AND EMPTY(lcTmpIntSlnToDtl)) &&1073384 FH
6549
6550
6551
6552 *- TR 1073384 FH
6553*!* lcSql = " SELECT Wvs.Pkey, " + ;
6554*!* " pod.pkey as fkey," + ;
6555*!* " Wvs.Ord_Num, " + ;
6556*!* " Wvs.Line_seq, " + ;
6557*!* " Wvs.sizebucket, " + ;
6558*!* " Wvs.Segment, " + ;
6559*!* " Wvs.Element, " + ;
6560*!* " Wvs.Qualifier, " + ;
6561*!* " Wvs.Value " + ;
6562*!* " FROM zzedatawhse Wvs WITH (NOLOCK)" + ;
6563*!* " JOIN " + lcTmpIntDtl + " pod ON pod.ord_num = Wvs.ord_num " + ;
6564*!* " AND Wvs.line_seq = pod.line_seq AND Wvs.sizebucket = pod.sizebucket " + ;
6565*!* " AND Wvs.table_name = 'ZZOORDRD'"
6566
6567
6568 IF NOT EMPTY(lcTmpIntDtl) && let's separate the UNION
6569 lcSqlDtl = " SELECT Wvs.Pkey, " + ;
6570 " pod.pkey as fkey," + ;
6571 " Wvs.Ord_Num, " + ;
6572 " Wvs.Line_seq, " + ;
6573 " Wvs.sizebucket, " + ;
6574 " Wvs.Segment, " + ;
6575 " Wvs.Element, " + ;
6576 " Wvs.Qualifier, " + ;
6577 " Wvs.Value " + ;
6578 " FROM zzedatawhse Wvs WITH (NOLOCK)" + ;
6579 " JOIN " + lcTmpIntDtl + " pod ON pod.ord_num = Wvs.ord_num " + ;
6580 " AND Wvs.line_seq = pod.line_seq AND Wvs.sizebucket = pod.sizebucket " + ;
6581 " AND Wvs.table_name = 'ZZOORDRD' "
6582 ENDIF
6583 *- TR 1073384 FH
6584
6585*-- If need to export only 2 records to the flat file we need to add the following query
6586* " AND Wvs.segment = 'PID' " + ;
6587 " AND Wvs.element = '05' AND Wvs.qualifier = '74' " + ;
6588 " AND Wvs.pkey = (SELECT MAX(w1.pkey) FROM zzedatawhse w1 " + ;
6589 " WHERE w1.ord_num = Wvs.ord_num AND w1.table_name = 'ZZOORDRD' " + ;
6590 " AND W1.line_seq = pod.line_seq AND W1.sizebucket = pod.sizebucket " + ;
6591 " AND w1.segment = 'PID' AND w1.element = '05' AND w1.qualifier = '74') " + ;
6592 " UNION ALL " + ;
6593 " SELECT Wvs.Pkey, " + ;
6594 " pod.pkey as fkey," + ;
6595 " Wvs.Ord_Num, " + ;
6596 " Wvs.Line_seq, " + ;
6597 " Wvs.sizebucket, " + ;
6598 " Wvs.Segment, " + ;
6599 " Wvs.Element, " + ;
6600 " Wvs.Qualifier, " + ;
6601 " Wvs.Value " + ;
6602 " FROM zzedatawhse Wvs WITH (NOLOCK)" + ;
6603 " JOIN " + lcTmpIntDtl + " pod ON pod.ord_num = Wvs.ord_num " + ;
6604 " AND Wvs.line_seq = pod.line_seq AND Wvs.sizebucket = pod.sizebucket " + ;
6605 " AND Wvs.table_name = 'ZZOORDRD' AND Wvs.segment = 'PID' " + ;
6606 " AND Wvs.element = '05' AND Wvs.qualifier = 'GEN' " + ;
6607 " AND Wvs.pkey = (SELECT MAX(w1.pkey) FROM zzedatawhse w1 " + ;
6608 " WHERE w1.ord_num = Wvs.ord_num AND w1.table_name = 'ZZOORDRD' " + ;
6609 " AND W1.line_seq = pod.line_seq AND W1.sizebucket = pod.sizebucket " + ;
6610 " AND w1.segment = 'PID' AND w1.element = '05' AND w1.qualifier = 'GEN') "
6611
6612
6613
6614 *-TR 1073384 FH
6615 IF NOT EMPTY(lcTmpIntSlnToDtl)
6616
6617 lcSqlUnion = " SELECT Wvs.Pkey, " + ;
6618 " pod.pkey as fkey," + ;
6619 " Wvs.Ord_Num, " + ;
6620 " Wvs.Line_seq, " + ;
6621 " Wvs.sizebucket, " + ;
6622 " Wvs.Segment, " + ;
6623 " Wvs.Element, " + ;
6624 " Wvs.Qualifier, " + ;
6625 " Wvs.Value " + ;
6626 " FROM zzedatawhse Wvs WITH (NOLOCK)" + ;
6627 " Join " + lcTmpIntSlnToDtl + " pod on " + ;
6628 " Wvs.ord_num = pod.ord_num " + ;
6629 " and Wvs.line_seq = pod.line_seq " + ; && this would be the min(line_seq) already
6630 " and Wvs.sizebucket = pod.sizebucket " + ;
6631 " and Wvs.sln_line = pod.sln01 " + ; && we need sln01 to match the right EDIS
6632 " and Wvs.table_name = 'ZZEIPOHS' "
6633
6634 ENDIF
6635 *-TR 1073384 FH
6636
6637 lcSQL = IIF(EMPTY(lcSqlDtl),"",lcSqlDtl) + IIF(EMPTY(lcSqlDtl),"", IIF(EMPTY(lcSqlUnion),"","UNION ALL")) + IIF(EMPTY(lcSqlUnion),"",lcSqlUnion)
6638 llRetVal = llRetVal AND v_sqlexec(lcSQL, .cWorkWhsDtl)
6639
6640 ENDIF && llRetVal AND NOT EMPTY(lcTmpIntDtl)
6641
6642 ENDWITH
6643
6644 *--Drop Temp table which are created here
6645*!* v_sqlexecnoerror("DROP TABLE " + lcTmpIntHdr)
6646*!* v_sqlexecnoerror("DROP TABLE " + lcTmpIntDtl)
6647 *- 1073384 FH these tables can be .F. if data warehouse flag is set to N
6648 IIF(EMPTY(lcTmpIntHdr),"",v_sqlexecnoerror("DROP TABLE " + lcTmpIntHdr))
6649 IIF(EMPTY(lcTmpIntDtl),"",v_sqlexecnoerror("DROP TABLE " + lcTmpIntDtl))
6650 IIF(EMPTY(lcTmpIntSlnToDtl),"",v_sqlexecnoerror("DROP TABLE " + lcTmpIntSlnToDtl))
6651
6652 SELECT (lnSelect)
6653 RETURN llRetVal
6654 ENDFUNC
6655 *=================================================================================
6656 *=== TechRec 1052941 16-Mar-2011 MANI. ===
6657
6658 *--- TR 1053650 18-4-2011 VKK
6659 FUNCTION ResolveZipCode
6660 LPARAMETERS tcAddress
6661 LOCAL llRetVal, lnSelect
6662
6663 llRetVal = true
6664 lnSelect = SELECT()
6665
6666 WITH This
6667 &&--- TechRec 1053650 28-Jul-2011 TShenbagavalli changed condition >= 9 to > 9 ===
6668 SELECT (tcAddress)
6669 REPLACE ALL ;
6670 zipcode_ext WITH zipcode, ;
6671 zipcode WITH IIF(LEN(ALLTRIM(zipcode)) > 9 AND SUBSTR(zipcode,6,1) = "-", LEFT(zipcode,5) + SUBSTR(zipcode,7),zipcode)
6672
6673 ENDWITH
6674
6675 SELECT (lnSelect)
6676 RETURN llRetVal
6677 ENDFUNC
6678 *=== TR 1053650 18-4-2011 VKK
6679
6680*-TR 1058568 FH
6681 *--- TechRec 1058522 04-Jan-2012 TShenbagavalli commented below and changed the method to handle any table ---
6682*!* FUNCTION GetCommonFieldList
6683*!* LPARAMETERS tcAlias
6684*!* LOCAL llRetVal, lnSelect, lcSQLString, lcCursor, lcPickDetailFieldList,lcTransDetailFieldList,;
6685*!* laPickDetailColumn[1] ,laTransDetailColumn[1] ,lcColumn ,lnRow,lcCommonFieldList
6686*!*
6687*!* lcCommonFieldList = ""
6688*!* llRetVal = true
6689*!* lnSelect = SELECT()
6690*!* lcCursor = GetUniqueFileName()
6691
6692
6693*!* WITH This
6694*!* lcSQLString = " Select * from zzoordrd where 1=2 "
6695*!* llRetVal = .vSqlExec(lcSQLString,lcCursor)
6696*!*
6697*!* IF llRetVal
6698*!* lcPickDetailFieldList = CreateFieldListFromCursor(lcCursor)
6699*!* ENDIF
6700*!*
6701*!* lcSQLString = " Select * from zzeoowtd where 1=2 "
6702*!* llRetVal = llRetVal AND .vSqlExec(lcSQLString,lcCursor)
6703
6704*!* IF llRetVal
6705*!* lcTransDetailFieldList= CreateFieldListFromCursor(lcCursor)
6706*!*
6707*!* ParseArr(@laPickDetailColumn,lcPickDetailFieldList,1,",")
6708*!*
6709*!* ParseArr(@laTransDetailColumn,lcTransDetailFieldList,1,",")
6710*!*
6711*!* FOR I = 1 TO ALEN(laPickDetailColumn, 1)
6712*!* lcColumn = laPickDetailColumn[I]
6713*!*
6714*!* lnRow = AFindRow(@laTransDetailColumn, lcColumn )
6715*!* IF lnRow >0
6716*!* lcCommonFieldList = lcCommonFieldList + IIF(!EMPTY(lcCommonFieldList) ,",","")+ tcAlias + lcColumn
6717*!* ENDIF
6718*!* ENDFOR
6719*!* ENDIF
6720*!* .TableClose(lcCursor)
6721*!* ENDWITH
6722*!*
6723*!* SELECT (lnSelect)
6724*!* RETURN lcCommonFieldList
6725*!* ENDFUNC
6726 FUNCTION GetCommonFieldList
6727 LPARAMETERS tcAlias, tcSource, tcTarget
6728 LOCAL llRetVal, lnSelect, lcSQLString, lcCursor, lcSourceFieldList,lcTargetFieldList,;
6729 laSourceColumn[1] ,laTargetColumn[1] ,lcColumn ,lnRow,lcCommonFieldList
6730
6731 lcCommonFieldList = ""
6732 llRetVal = true
6733 lnSelect = SELECT()
6734 lcCursor = GetUniqueFileName()
6735
6736 WITH This
6737 lcSQLString = " Select * from " + tcSource + " where 1=2 "
6738 llRetVal = .vSqlExec(lcSQLString,lcCursor)
6739
6740 IF llRetVal
6741 lcSourceFieldList = CreateFieldListFromCursor(lcCursor)
6742 ENDIF
6743
6744 lcSQLString = " Select * from " + tcTarget + " where 1=2 "
6745 llRetVal = llRetVal AND .vSqlExec(lcSQLString,lcCursor)
6746
6747 IF llRetVal
6748 lcTargetFieldList= CreateFieldListFromCursor(lcCursor)
6749
6750 ParseArr(@laSourceColumn, lcSourceFieldList, 1, ",")
6751
6752 ParseArr(@laTargetColumn, lcTargetFieldList, 1, ",")
6753
6754 FOR I = 1 TO ALEN(laSourceColumn, 1)
6755 lcColumn = laSourceColumn[I]
6756
6757 lnRow = AFindRow(@laTargetColumn, lcColumn )
6758 IF lnRow >0
6759 lcCommonFieldList = lcCommonFieldList + IIF(!EMPTY(lcCommonFieldList) ,",","")+ tcAlias + lcColumn
6760 ENDIF
6761 ENDFOR
6762 ENDIF
6763 .TableClose(lcCursor)
6764 ENDWITH
6765
6766 SELECT (lnSelect)
6767 RETURN lcCommonFieldList
6768 ENDFUNC
6769 *=== TechRec 1058522 04-Jan-2012 TShenbagavalli ===
6770 *-TR 1058568 FH
6771
6772 *- 1058729 FH - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
6773 Procedure BulkDelete
6774 LOCAL lnCount, lnX ,lcFile
6775
6776 IF VARTYPE(this.aBulkTables) <> "C" && sometimes aBulkTables doesn't get initialized so it's .F. we exit, dont need to do anything
6777 return
6778 endif
6779 *- lets log all the files before we delete
6780
6781 FOR lnX = 1 TO This.nCounter
6782 lcFile = this.aBulkTables[lnX]
6783 .LogEntry("Files : " + lcFile)
6784 ENDFOR
6785 *-
6786 FOR lnX = 1 TO This.nCounter
6787 lcFile = this.aBulkTables[lnX]
6788 IF File(lcFile)
6789 .LogEntry("Bulk Deleting : " + lcFile)
6790 sysnoerror("DELETE FILE " + lcFile)
6791 Endif
6792 IF FILE(lcFile)
6793 .LogEntry("Failed to initial delete : " + lcFile)
6794
6795 lnCnt = 0
6796 DO WHILE File(lcFile) AND lnCnt < 5
6797 .LogEntry("Bulk Deleting in while : " + lcFile)
6798 sysnoerror("DELETE FILE " + lcFile)
6799 INKEY(1) && wait, we can change, this right now it's 1 seconds * 5 so 5 secs
6800 lnCnt = lnCnt + 1
6801 ENDDO
6802 IF FILE(lcFile)
6803 .LogEntry("Failed to delete : " + lcFile)
6804 ENDIF
6805 endif
6806 ENDFOR
6807
6808 *reset
6809 DIMENSION This.aBulkTables[1]
6810 this.aBulkTables = .F.
6811 this.nCounter = 0
6812
6813 ENDPROC
6814 *- 1058729 FH -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6815
6816 *--- TechRec 1059998 05-Apr-2012 jisingh ---
6817 PROCEDURE CreateOTAddress
6818 PARAMETERS pnOrdNum, pcPkeyTag, pcInterAddress
6819 LOCAL llRetVal, lnSelect, lnPkey, lcSQLString
6820
6821 lnSelect = SELECT()
6822 llRetVal = true
6823
6824 WITH This
6825 lcSQLString = " SELECT * FROM ZZOOTADR " + ;
6826 " WHERE ord_num = " + SQLFormatNum(pnOrdNum)
6827
6828 llRetVal = llRetVal AND v_SQLExec(lcSQLString, "tcOTAddress") AND USED("tcOTAddress")
6829
6830 IF llRetVal AND RECCOUNT("tcOTAddress") > 0
6831 SELECT tcOTAddress
6832 SCAN
6833 lnPkey = v_NextPkey(pcPkeyTag)
6834 IF !EMPTY(lnPkey)
6835 SELECT (pcInterAddress)
6836 APPEND BLANK
6837 GATHER MEMVAR MEMO
6838
6839 REPLACE addr_type WITH tcOTAddress.addr_type, ;
6840 cust_name WITH tcOTAddress.cust_name, ;
6841 address1 WITH tcOTAddress.address1, ;
6842 address2 WITH tcOTAddress.address2, ;
6843 address3 WITH tcOTAddress.address3, ;&&--- TechRec 1085802 01-Apr-2015 TSV===
6844 address4 WITH tcOTAddress.address4, ;&&--- TechRec 1085802 01-Apr-2015 TSV===
6845 city WITH tcOTAddress.city, ;
6846 state WITH tcOTAddress.state, ;
6847 zipcode WITH tcOTAddress.zipcode, ;
6848 country WITH tcOTAddress.country, ;
6849 pkey WITH lnPkey IN (pcInterAddress)
6850
6851 .TimeStampDocument()
6852 ELSE
6853 llRetVal = false
6854 ENDIF
6855 SELECT tcOTAddress
6856 ENDSCAN
6857 ENDIF
6858 .TableClose("tcOTAddress")
6859 ENDWITH
6860
6861 SELECT (lnSelect)
6862 RETURN llRetVal
6863 ENDPROC
6864 *=== TechRec 1059998 05-Apr-2012 jisingh ===
6865
6866 *--- TR 1066790 18-Feb-2013 Partha ---
6867 *=================================================================================
6868
6869 FUNCTION PopulateChargeDetail
6870 LPARAMETERS tcDtl, tcChrgDtl
6871 LOCAL llRetVal, lnSelect
6872
6873 llRetVal = True
6874 lnSelect = SELECT()
6875
6876 WITH This
6877 SELECT (tcChrgDtl)
6878 INDEX on fkey TAG fkey
6879 SELECT (tcDtl)
6880 INDEX on dtl_pkey TAG dtl_pkey
6881 GOTO TOP
6882 SCAN
6883 SCATTER NAME oDtl FIELDS dtl_pkey,sku,upc,ean,size_desc,sizebucket
6884 SELECT (tcChrgDtl)
6885 IF SEEK(oDtl.dtl_pkey)
6886 SCAN WHILE fkey= oDtl.dtl_pkey
6887 GATHER NAME oDtl FIELDS sku,upc,ean,size_desc,sizebucket
6888 ENDSCAN
6889 ENDIF
6890 RELEASE oDtl
6891 ENDSCAN
6892
6893 ENDWITH
6894
6895 SELECT (lnSelect)
6896 RETURN llRetVal
6897 ENDFUNC
6898 *=================================================================================
6899
6900 *=== TR 1066790 18-Feb-2013 Partha ===
6901
6902 *--- TR 1066381 KISHORE 20-FEB-2013
6903 * replaces country code with iso_code_2 if available else country code remains
6904 PROCEDURE PopulateCountryISO2
6905 PARAMETERS tcWorkHeader, tcWorkAddress
6906 LOCAL llRetVal, lnSelect
6907 llRetVal = .t.
6908 lnSelect = SELECT()
6909
6910 * update country code with iso_code_2
6911 llRetVal = llRetVal AND v_SqlExec("SELECT * FROM zzxcntyr","zzxcntyr_local")
6912 IF llRetVal
6913 SELECT zzxcntyr_local
6914 INDEX ON country TAG country
6915
6916 SELECT (tcWorkAddress)
6917 SCAN FOR NOT EMPTY(country)
6918 IF SEEK(fkey,tcWorkHeader,'pkey') AND EVALUATE(tcWorkHeader + '.populate_country') == 'Y'
6919
6920 lcISOCountry = ''
6921 *--- TechRec 1085802 01-Apr-2015 TSV---
6922 lcISOCode2 = ''
6923 lcISOCodeNum = ''
6924 lcISOCodeChar = ''
6925 *=== TechRec 1085802 01-Apr-2015 TSV===
6926
6927 SELECT zzxcntyr_local
6928 SEEK EVALUATE(tcWorkAddress + '.country')
6929 IF FOUND()
6930 lcISOCountry = iso_code_2
6931
6932 *--- TechRec 1085802 01-Apr-2015 TSV---
6933 lcISOCode2 = iso_code_2
6934 lcISOCodeNum = iso_code_num
6935 lcISOCodeChar = iso_code_char
6936 *=== TechRec 1085802 01-Apr-2015 TSV===
6937
6938 IF NOT EMPTY(lcISOCountry)
6939 REPLACE country WITH lcISOCountry IN (tcWorkAddress)
6940 ENDIF
6941
6942 *--- TechRec 1085802 01-Apr-2015 TSV---
6943 REPLACE iso_code_2 WITH lcISOCode2, ;
6944 iso_code_num WITH lcISOCodeNum, ;
6945 iso_code_char WITH lcISOCodeChar IN (tcWorkAddress)
6946 *=== TechRec 1085802 01-Apr-2015 TSV===
6947
6948 ENDIF
6949 ENDIF
6950 ENDSCAN
6951
6952 USE IN SELECT('zzxcntyr_local')
6953 ENDIF
6954
6955 SELECT (lnSelect)
6956 RETURN llRetVal
6957 ENDPROC
6958 *=== TR 1066381 KISHORE 20-FEB-2013
6959
6960 *------------------------------------------------------------------------------------------------------
6961 *--- TR 1067861 19-Apr-2013 Goutam/Jijo
6962 PROCEDURE ConsolidatePickTickets
6963 LPARAMETERS pcTransHeader, pcTransDetail
6964
6965 LOCAL llRetVal, lnSelect, loConsolH, loConsolD, lnNewTHPkey
6966 lnSelect = SELECT()
6967 llRetVal = true
6968
6969 WITH This
6970 *-- Mark records as invalid if swc_num is crossed customer/division
6971 SELECT DISTINCT swc_num ;
6972 FROM (pcTransHeader) h ;
6973 WHERE (EXISTS(SELECT swc_num FROM (pcTransHeader) WHERE swc_num =h.swc_num GROUP BY swc_num HAVING COUNT(DISTINCT customer) > 1) ;
6974 OR ;
6975 EXISTS(SELECT swc_num from (pcTransHeader) WHERE swc_num =h.swc_num GROUP BY swc_num HAVING COUNT(DISTINCT division) > 1)) ;
6976 AND swc_num > 0 ;
6977 INTO CURSOR tcConflicts
6978
6979 SELECT tcConflicts
6980 SCAN
6981 REPLACE errs_msg_h WITH errs_msg_h + "Pick consolidation across customers/divisions is not allowed." + CRLF, errs_flg_h WITH "Y";
6982 IN (pcTransHeader) FOR swc_num = tcConflicts.swc_num
6983 ENDSCAN
6984
6985 SELECT h.customer, h.division, h.swc_num, COUNT(pick_num) AS cnt ;
6986 FROM (pcTransHeader) h ;
6987 WHERE h.swc_num > 0 ;
6988 AND NOT EXIST(SELECT 1 FROM (pcTransHeader) WHERE swc_num = h.swc_num AND errs_flg_h = 'Y') ;
6989 GROUP BY h.customer, h.division, h.swc_num ;
6990 HAVING COUNT(pick_num) > 1 ;
6991 INTO CURSOR tcConsolLst
6992
6993 IF _Tally > 0
6994 .AdvanceThermoTotalWithCaptionPlus("Consolidating Pick Tickets")
6995 ENDIF
6996
6997 SELECT tcConsolLst
6998 SCAN
6999 *-- Aggrgate header by swc_num
7000 SELECT SUM(ord_qty) AS ord_qty, ;
7001 SUM(weight) AS weight, ;
7002 SUM(carton) AS carton, ;
7003 SUM(frgt_amt) AS frgt_amt,;
7004 SUM(disc_amt) AS disc_amt, ;
7005 SUM(misc_amt) AS misc_amt, ;
7006 SUM(tax_amt) AS tax_amt, ;
7007 SUM(insu_amt) AS insu_amt, ;
7008 SUM(totlindscamt) AS totlindscamt, ;
7009 SUM(merch_amt) AS merch_amt, ;
7010 SUM(termdscamt) AS termdscamt, ;
7011 MAX(pkey) AS pkey, ;
7012 MAX(swc_num) AS swc_num ;
7013 FROM (pcTransHeader) ;
7014 WHERE swc_num = tcConsolLst.swc_num;
7015 INTO CURSOR tcConsolHdr
7016
7017 *MAX(ord_num) AS ord_num, ;
7018
7019 *-- Aggrgate detail by UPC/EAN
7020 SELECT d.division, style, color_code, lbl_code, dimension, size_desc, ;
7021 SUM(d.total_qty) AS total_qty, ;
7022 SUM(d.orig_qty) AS orig_qty, ;
7023 SUM(d.cancelqty) AS cancelqty, ;
7024 SUM(d.invoiceqty) AS invoiceqty,;
7025 SUM(d.openpickqty) AS openpickqty ;
7026 FROM (pcTransDetail) d ;
7027 JOIN (pcTransHeader) h ;
7028 ON d.fkey = h.pkey ;
7029 WHERE h.swc_num = tcConsolLst.swc_num;
7030 GROUP BY style, color_code, lbl_code, dimension, size_desc ;
7031 INTO CURSOR tcConsolDtl
7032
7033 lnNewTHPkey = v_NextPkey("ZZEOOWTH")
7034
7035 *-- Delete old records from detail table and insert consolidated records
7036 SELECT tcConsolDtl
7037 SCAN
7038 SELECT(pcTransDetail)
7039 *-- Just locate the top most record for that SKU
7040
7041 LOCATE FOR swc_num = tcConsolHdr.swc_num AND ;
7042 division = tcConsolDtl.division AND ;
7043 style = tcConsolDtl.style AND color_code = tcConsolDtl.color_code AND ;
7044 lbl_code = tcConsolDtl.lbl_code AND dimension = tcConsolDtl.dimension AND size_desc = tcConsolDtl.size_desc
7045
7046 SCATTER NAME loConsolD MEMO
7047
7048 DELETE d ;
7049 FROM (pcTransDetail) d ;
7050 JOIN (pcTransHeader) h ;
7051 ON d.fkey = h.pkey ;
7052 WHERE h.swc_num = tcConsolLst.swc_num AND ;
7053 d.division = tcConsolDtl.division AND ;
7054 style = tcConsolDtl.style AND color_code = tcConsolDtl.color_code AND ;
7055 lbl_code = tcConsolDtl.lbl_code AND dimension = tcConsolDtl.dimension AND size_desc = tcConsolDtl.size_desc
7056
7057 SELECT tcConsolDtl
7058 SCATTER NAME loConsolD MEMO ADDITIVE
7059
7060 WITH loConsolD
7061 .Pkey = v_NextPkey("ZZEOOWTD")
7062 .Fkey = lnNewTHPkey
7063 .Pick_Num = tcConsolLst.swc_num
7064 .Line_Seq = 0 && 0 out line_seq
7065 ENDWITH
7066
7067 SELECT(pcTransDetail)
7068 APPEND BLANK
7069 GATHER NAME loConsolD MEMO
7070 ENDSCAN
7071
7072 *-- Delete old records from header table and insert consolidated record
7073 SELECT(pcTransHeader)
7074 LOCATE FOR swc_num = tcConsolLst.swc_num
7075 SCATTER NAME loConsolH MEMO
7076
7077 DELETE FOR swc_num = tcConsolLst.swc_num
7078
7079 SELECT tcConsolHdr
7080 SCATTER NAME loConsolH MEMO ADDITIVE
7081 loConsolH.Pkey = lnNewTHPkey
7082 loConsolH.Pick_Num = tcConsolLst.swc_num
7083
7084 SELECT(pcTransHeader)
7085 APPEND BLANK
7086 GATHER NAME loConsolH MEMO
7087
7088 ENDSCAN
7089
7090 .TableClose("tcConflicts")
7091 .TableClose("tcConsolLst")
7092 .TableClose("tcConsolHdr")
7093 ENDWITH
7094 SELECT(lnSelect)
7095
7096 RETURN llRetVal
7097 ENDPROC
7098 *=== TR 1067861 19-Apr-2013 Goutam/Jijo
7099
7100 *--- TR 1073471 KISHORE 19-SEP-2013
7101 FUNCTION PopulateDataWhseSLN
7102 LPARAMETERS pceTransHeader, pceTransDetail, pceControl, pcItemSLN, pcWhseSLN
7103 LOCAL llRetVal, lnSelect, lcSqlString, lcItemSLN
7104
7105 llRetVal = true
7106 lnSelect = SELECT()
7107 lcItemSLN = ""
7108
7109 WITH This
7110 IF USED(pcItemSLN) AND RECCOUNT(pcItemSLN) > 0
7111 .cSQLTempTable = ""
7112 IF .GenerateSQLTempTable(pcItemSLN) AND .PopulateSQLTempTable(pcItemSLN) AND !EMPTY(.cSQLTempTable)
7113 lcItemSLN = .cSQLTempTable
7114 ENDIF
7115 ENDIF
7116
7117 SELECT DISTINCT h.ord_num, d.assortment, d1.line_seq, d.po1_line, d.sizebucket, d.pkey, d.fkey ;
7118 FROM (pceTransHeader) h ;
7119 JOIN (pceTransDetail) d ON h.pkey = d.fkey ;
7120 JOIN (SELECT ord_num, assortment, po1_line, MIN(line_seq) AS line_seq ;
7121 FROM (pceTransDetail) ;
7122 GROUP BY ord_num, assortment, po1_line)d1 ;
7123 ON d1.ord_num = d.ord_num AND d1.assortment = d.assortment AND d1.po1_line = d.po1_line ;
7124 JOIN (pceControl) c ON h.location = c.ware_code ;
7125 WHERE c.data_whse = 'Y' AND c.active_ok = 'Y' ;
7126 INTO CURSOR __TmpCursor
7127
7128 IF !EMPTY(lcItemSLN) AND USED("__TmpCursor") AND RECCOUNT("__TmpCursor") > 0
7129 .cSQLTempTable = ""
7130 IF .GenerateSQLTempTable('__TmpCursor') AND .PopulateSQLTempTable('__TmpCursor') AND !EMPTY(.cSQLTempTable)
7131
7132 lcSqlString = "SELECT s.itm_pkey AS pkey, s.sfkey, s.aux_sku, t.ord_num, t.line_seq, s.sizebucket " + ;
7133 "FROM " + lcItemSLN + " s, " + .cSQLTempTable + " t " + ;
7134 "WHERE s.itm_pkey = t.pkey "
7135
7136 llRetVal = llRetVal AND v_SQLExec(lcSqlString, "__TmpCursor")
7137
7138 IF llRetVal AND USED("__TmpCursor") AND RECCOUNT("__TmpCursor") > 0
7139 .cSQLTempTable = ""
7140 IF .GenerateSQLTempTable("__TmpCursor") AND .PopulateSQLTempTable("__TmpCursor") AND !EMPTY(.cSQLTempTable)
7141
7142 lcSqlString = "SELECT s.pkey, s.ord_num, s.line_seq, s.sln_line, s.sizebucket, s.segment, " + ;
7143 " s.element, s.qualifier, s.value, MIN(t.aux_sku) AS aux_sku, t.pkey AS fkey " + ;
7144 "FROM zzedatawhse s, " + .cSQLTempTable + " t " + ;
7145 "WHERE s.ord_num = t.ord_num " + ;
7146 " AND s.line_seq = t.line_seq " + ;
7147 " AND s.sizebucket = t.sizebucket " + ;
7148 " AND s.table_name = 'ZZEIPOHS' " + ;
7149 " GROUP BY s.pkey, s.ord_num, s.line_seq, s.sln_line, s.sizebucket, s.segment, " + ;
7150 " s.element, s.qualifier, s.value, t.pkey "
7151
7152 llRetVal = llRetVal AND v_SQLExec(lcSqlString, "tcWhse")
7153
7154 .MakeCursorWritable("tcWhse", pcWhseSLN)
7155 ENDIF
7156 ENDIF
7157 ENDIF
7158 * update sfkey with pkey in SLN
7159 REPLACE ALL sfkey WITH itm_pkey IN (pcItemSLN)
7160 ENDIF
7161 .TableClose("tcWhse")
7162 .TableClose("__TmpCursor")
7163 ENDWITH
7164
7165 SELECT (lnSelect)
7166 RETURN llRetVal
7167 ENDFUNC
7168 *=== TR 1073471 KISHORE 19-SEP-2013
7169
7170*============================================================
7171 *--- TR 1065007 14-Feb-2014 Goutam
7172
7173 PROCEDURE UpdateUOMHeader
7174 PARAMETERS pcTranHeader, pcControl
7175
7176 LOCAL llRetVal, lnSelect, lcDivision, lcCustomer, lcLocation, lnConvValue, lcUOM_Volume, lcUOM_Weight
7177
7178 lnSelect = SELECT()
7179 llRetVal = true
7180
7181 WITH THIS
7182 SELECT (pcTranHeader)
7183 lcLocation = location
7184 lcUOM_Volume = vl_locar(lcLocation, "uom_volume",, "W")
7185 lcUOM_Weight = vl_locar(lcLocation, "uom_weight",, "W")
7186
7187 IF &pcControl..UOM_Recal = 'Y'
7188 IF !EMPTY(&pcTranHeader..ord_volume) AND !EMPTY(lcUOM_Volume)
7189 lnConvValue = vl_suomc(.cFromUOMVolume,"uom_factor",,lcUOM_Volume)
7190 replace ord_volume WITH PADL((VAL(ord_volume)*lnConvValue),10) IN (pcTranHeader)
7191 ENDIF
7192 IF !EMPTY(&pcTranHeader..weight) AND !EMPTY(lcUOM_Weight)
7193 lnConvValue = vl_suomc(.cFromUOMWeight,"uom_factor",,lcUOM_Weight)
7194 replace weight WITH PADL((VAL(weight)*lnConvValue),10) IN (pcTranHeader)
7195 ENDIF
7196 ENDIF
7197 ENDWITH
7198
7199 SELECT (lnSelect)
7200 RETURN llRetVal
7201 ENDPROC
7202
7203 PROCEDURE UpdateUOMDetail
7204 PARAMETERS pcTranHeader, pcTranDetail, pcControl
7205
7206 LOCAL llRetVal, lnSelect, lcLocation, lnConvValue, lcUOM_Volume, lcUOM_Weight
7207
7208 lnSelect = SELECT()
7209 llRetVal = true
7210
7211 WITH THIS
7212 SELECT (pcTranHeader)
7213 lcLocation = location
7214 lcUOM_Volume = vl_locar(lcLocation, "uom_volume",, "W")
7215 lcUOM_Weight = vl_locar(lcLocation, "uom_weight",, "W")
7216
7217 IF &pcControl..UOM_Recal = 'Y'
7218 IF !EMPTY(&pcTranDetail..cubic) AND !EMPTY(lcUOM_Volume)
7219 lnConvValue = vl_suomc(.cFromUOMVolume,"uom_factor",,lcUOM_Volume)
7220 replace cubic WITH PADL((VAL(cubic)*lnConvValue),15) IN (pcTranDetail)
7221 ENDIF
7222 IF !EMPTY(&pcTranDetail..gar_wgt) AND !EMPTY(lcUOM_Weight)
7223 lnConvValue = vl_suomc(.cFromUOMWeight,"uom_factor",,lcUOM_Weight)
7224 replace gar_wgt WITH PADL((VAL(gar_wgt)*lnConvValue),15) IN (pcTranDetail)
7225 ENDIF
7226 ENDIF
7227 ENDWITH
7228
7229 SELECT (lnSelect)
7230 RETURN llRetVal
7231 ENDPROC
7232
7233 *=== TR 1065007 14-Feb-2014 Goutam
7234
7235*============================================================
7236
7237*--- TechRec 1085802 31-Mar-2015 TSV---
7238 FUNCTION PopulateTranslatedSizeDesc
7239 LPARAMETERS pcHeader, pcDetail, pcControl
7240
7241 Local llRetVal, lnSelect
7242 llRetVal = .T.
7243 lnSelect = Select()
7244
7245 With This
7246
7247 SELECT Distinct d.location, d.customer, d.division, d.size_code, d.style ;
7248 FROM (pcDetail) d ;
7249 JOIN (pcControl) c ON d.location = c.ware_code ;
7250 WHERE c.template = 'BARTH' AND c.active_ok = 'Y' ;
7251 AND !(d.Errs_Flg_D) = "Y" ;
7252 INTO Cursor tcTempCur
7253
7254 .cSQLTempTable=""
7255
7256 If .GenerateSQLTempTable('tcTempCur')
7257
7258 If .PopulateSQLTempTable('tcTempCur')
7259
7260 If !Empty(.cSQLTempTable)
7261
7262 lcSzStr = " case b.size_num " + GetSzbktStrForMultiple(""," "," when ",,," then z.size") + " end as tr_size_desc, "
7263
7264 lcSQLString = " select t.location, t.customer, " + ;
7265 " z.*, " + lcSzStr + ;
7266 " b.size_num as sizebucket " + ;
7267 " from zzxcustr c " + ;
7268 " join " + .cSQLTempTable + " t " + ;
7269 " on t.customer = c.customer " + ;
7270 " join zvallsiz_r z " + ;
7271 " on c.country = z.country " + ;
7272 " and t.size_code = z.size_code " + ;
7273 " and t.division = z.division " + ;
7274 " and t.style = z.style " + ;
7275 " cross join zzxbuckt b "
7276
7277 llRetVal = v_SqlExec(lcSQLString, "tcTransSize")
7278
7279 If llRetVal
7280 Select tcTransSize
7281 Index On location+customer+division+style+size_code+STR(sizebucket) Tag LocSize
7282 llRetVal= llRetVal AND .SetRelation("tcTransSize", "LocSize", pcDetail, "location+customer+division+style+size_code+STR(sizebucket)")
7283
7284 If llRetVal
7285
7286 REPLACE all tr_Size_desc with tcTransSize.tr_Size_desc In (pcdetail) ;
7287 For !Empty(tcTransSize.customer) AND !Empty(tcTransSize.location)
7288
7289 Set Relation To
7290 Use In tcTransSize
7291 Endif
7292
7293 Endif
7294 Endif
7295 Endif
7296 Endif
7297 Endwith
7298 If Used("tcTempCur")
7299 Use In tcTempCur
7300 Endif
7301 Select(lnSelect)
7302 RETURN llRetVal
7303 ENDFUNC
7304*============================================================
7305 FUNCTION PopulateTranslatedStyle
7306 LPARAMETERS pcHeader, pcDetail, pcControl
7307
7308 Local llRetVal, lnSelect
7309 llRetVal = .T.
7310 lnSelect = Select()
7311
7312 With This
7313
7314 SELECT distinct d.division, d.style, d.location, d.customer ;
7315 FROM (pcDetail) d ;
7316 JOIN (pcControl) c ON d.location = c.ware_code ;
7317 WHERE c.template = 'BARTH' AND c.active_ok = 'Y' ;
7318 AND !(d.Errs_Flg_D) = "Y" ;
7319 INTO Cursor tcTempCur
7320
7321 .cSQLTempTable = ""
7322
7323 If .GenerateSQLTempTable('tcTempCur')
7324
7325 If .PopulateSQLTempTable('tcTempCur')
7326
7327 If !Empty(.cSQLTempTable)
7328 lcSQLString = " select t.division, t.style, t.location, t.customer, c.langcode, " + ;
7329 " coalesce(ct.translated_content, st.style_desc) as tr_style_desc, " + ;
7330 " coalesce(ct1.translated_content, st.style_name) as tr_style_name " +;
7331 " from zzxcustr c " + ;
7332 " join " + .cSQLTempTable + " t " + ;
7333 " on t.customer = c.customer " + ;
7334 " join zzxstylr st " + ;
7335 " on t.division = st.division " + ;
7336 " and t.style = st.style " + ;
7337 " left join zzxtrnsl ct " + ;
7338 " on c.langcode = ct.langcode " + ;
7339 " and ct.fkey = st.pkey " + ;
7340 " and ct.field_name = 'style_desc' " +;
7341 " and ct.table_name = 'zzxstylr' " + ;
7342 " left join zzxtrnsl ct1 " + ;
7343 " on c.langcode = ct1.langcode " + ;
7344 " and ct1.fkey = st.pkey " + ;
7345 " and ct1.field_name = 'style_name' " +;
7346 " and ct1.table_name = 'zzxstylr' "
7347
7348 llRetVal = v_SqlExec(lcSQLString, "tcTransStyle")
7349
7350 If llRetVal
7351 Select tcTransStyle
7352 Index On location+customer+division+style Tag locstyle
7353 llRetVal= .SetRelation("tcTransStyle", "locstyle", pcDetail, "location+customer+division+style")
7354
7355 If llRetVal
7356 Replace All tr_style_name With tcTransStyle.tr_style_name, ;
7357 tr_style_desc With tcTransStyle.tr_style_desc In (pcDetail) ;
7358 FOR !Empty(tcTransStyle.customer) AND !EMPTY(tcTransStyle.location)
7359
7360 Set Relation To
7361 Use In tcTransStyle
7362 Endif
7363 Endif
7364 Endif
7365 Endif
7366 Endif
7367 Endwith
7368 If Used("tcTempCur")
7369 Use In tcTempCur
7370 Endif
7371 Select(lnSelect)
7372 RETURN llRetVal
7373 ENDFUNC
7374
7375*============================================================
7376 FUNCTION PopulateCustomsPrice
7377 LPARAMETERS pcHeader, pcDetail, pcControl
7378
7379 Local llRetVal, lnSelect, llIsEdi, lnPrice, lnPkey
7380 llRetVal = .T.
7381 llIsEdi = .T.
7382 llIsEdi940 = .T.
7383 lnPrice = 0
7384 lnSelect = Select()
7385
7386 With This
7387
7388 SELECT (pcControl)
7389 llRetVal= llRetVal AND .SetRelation(pcControl, "ware_code", pcDetail, "location")
7390
7391 If llRetVal
7392 lcStr = "Replace All customs_price With " + (pcDetail) + ".price In " + (pcDetail) +;
7393 " FOR " + (pcControl) + ".template = 'BARTH' and " + ;
7394 (pcControl) + ".active_ok = 'Y' AND " + (pcDetail) + ".price <>0"
7395 &lcStr
7396 Set Relation To
7397 Endif
7398
7399 *--- TR 1086845 4-MAY-2015 VENUK. Added d.end_date , d.ord_num ===
7400 SELECT 'A' as price_Code, h.curr_code, h.season, h.ord_type, h.Customer, ;
7401 d.pkey, d.Division, d.Style, d.Color_Code, d.Lbl_Code, d.Dimension, d.start_date ;
7402 ,d.end_date, d.ord_num ;
7403 FROM (pcHeader) h ;
7404 JOIN (pcDetail) d ;
7405 ON h.pkey = d.fkey ;
7406 JOIN (pcControl) c ON h.location = c.ware_code ;
7407 WHERE c.template = 'BARTH' AND c.active_ok = 'Y' ;
7408 AND d.price = 0 AND !(d.Errs_Flg_D) = "Y" ;
7409 INTO Cursor tcTempCur
7410
7411 SELECT tcTempCur
7412 SCAN
7413 lnPkey = pkey
7414 lnPrice = 0
7415
7416 *--- TR 1086845 4-MAY-2015 VENUK
7417 ** = vl_dtprs(Customer,Division, Style, Color_Code, Lbl_Code, ;
7418 Dimension, Start_Date, Curr_Code, llIsEdi, , @lnPrice, , "tcTempCur", llIsEdi940 )
7419
7420 = vl_dtprc(Customer,Division, Style, Color_Code, Lbl_Code, ;
7421 Dimension, Start_Date, Curr_Code, llIsEdi, , @lnPrice, , "tcTempCur", llIsEdi940, end_Date )
7422 *=== TR 1086845 4-MAY-2015 VENUK
7423
7424 IF SEEK(lnPkey, (pcDetail), "Pkey")
7425 REPLACE customs_price WITH lnPrice IN (pcDetail)
7426 ENDIF
7427
7428 ENDSCAN
7429
7430 ENDWITH
7431
7432 If Used("tcTempCur")
7433 Use In tcTempCur
7434 Endif
7435 Select(lnSelect)
7436 RETURN llRetVal
7437 ENDFUNC
7438*============================================================
7439*=== TechRec 1085802 31-Mar-2015 TSV===
7440
7441Enddefine