Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **********************************************************************************************
- * Program....: clsIpopr_CreateOrder.PRG
- * Author.....: Nasim Huq
- * Date.......: March, 2009
- * Notice.....: Copyright (c) 2005 CGS, Inc., All Rights Reserved.
- * Techreq....: 1033062
- * Abstract...: EDI 850 inbound Create open order
- * Changes....:
- ***********************************************************************************************
- #include edi.h
- #include system.h
- #Define LARGEST_DATE {^2999-01-01}
- #Define EDI_NOT_PROCESSORIGINAL_MSG "Control Flag set to Not Process Original EDI orders into Live Table."
- #Define EDI_NOT_PROCESSCONFIRM_MSG "Control Flag set to Not Process Confirm EDI orders into Live Table."
- #Define EDI_NOT_PROCESSDUPLICATE_MSG "Control Flag set to Not Process Duplicate EDI orders into Live Table."
- #Define NOT_YET_PROCESS "Not yet process."
- #Define NO_UOM_CONVERSION_REF "Require Style UOM."
- #Define UOM_NOT_DIVISIBLE "Total Units must be divisible by "
- #Define NO_UOM_CONVERSION_FACTOR "No conversion factor."
- #Define NO_PREPACK "Unable to determine Prepack code."
- #Define EDI_BULK_ORDER "BK"
- #Define EDI_BLANKET_ORDER "BL"
- #Define EDI_DISCOUNT_CODE "EDI"
- Define Class clsIpopr_CreateOrder As clsIpopr_delegatebase
- *--- trans cursor
- ceipoTH = ""
- ceipoTD = ""
- ceipoTH_nt = ""
- ceipoTD_nt = ""
- ceipoTC = ""
- ceipoTA = ""
- ceipoTS = ""
- ceipoTR = "" &&--- charges
- ceiPOtsac = ""
- *--- trans work tables
- cZzeipoTH = ""
- cZzeipoTD = ""
- cZzeipoTH_nt = ""
- cZzeipoTD_nt = ""
- cZzeipoTC = ""
- cZzeipoTA = ""
- cZzeipoTS = ""
- cZzeipoTDExt = ""
- cZzeipoTR = "" &&-- Charges
- cZzeiPOtsac = ""
- *--- trans history work tables
- cZzeipoHH = ""
- cZzeipoHD = ""
- cZzeipoHA = ""
- cZzeipoHC = ""
- cZzeipoHH_nt = ""
- cZzeipoHD_nt = ""
- cZzeipoHS = ""
- *--- order work tables
- cZzoordrh = ""
- cZzoordrd = ""
- cZzoordsp = ""
- cZzoordad = ""
- cZzootadr = ""
- cZzoordcd = ""
- cZzoordrh_nt = ""
- cZzoordrd_nt = ""
- cZzoordrdExt = ""
- cZzoordrd_chrg = ""
- cZzoordsac = ""
- cZzoordrh_cncl = ""
- cZzoordrd_cncl = ""
- cZzoordrh_del = ""
- cZzoordrd_del = ""
- cZzoordsp_del = ""
- cZzoordrh_Open = ""
- cZzoordrd_Open = ""
- ** TR 1050538 FH 11/10/10
- ceiPOcr = ""
- cZzeipoCr = ""
- *--- bulk nibbler
- cZzoordwh = ""
- cZzoordwd = ""
- cZzxniblr = ""
- *--- TechRec 1054619 08-Jun-2011 MANI. ---
- ceiPOtWHSE = ""
- czzedatawhse = ""
- cZzeiPOtWHSE = ""
- *=== TechRec 1054619 08-Jun-2011 MANI. ===
- DIMENSION aOrdTbls[1]
- nOrdTbls = 0
- *--- 1044208
- oAfterUpdate = NULL
- oBulk = NULL
- oBulkMatch = NULL
- *--- 1044208
- *--- TR 1075041 9-12-2013 VKK
- oSB = NULL
- *=== TR 1075041 9-12-2013 VKK
- *------------------------------------------------------------------------
- PROCEDURE INIT
- Lparameters toHostProcess
- DODEFAULT(toHostProcess)
- this.oCopyUtil = NULL
- SET PROCEDURE TO copyutil ADDITIVE
- this.ocopyutil = CREATEOBJECT("IPO_CopyUtil")
- *--- TR 1075041 9-12-2013 VKK
- this.oSB = NEWOBJECT("SQLStringBuilder","clsgnstr.fxp")
- *=== TR 1075041 9-12-2013 VKK
- ENDPROC
- PROCEDURE DESTROY
- this.oAfterUpdate = NULL
- this.oBulk = NULL
- this.oBulkMatch = NULL
- *--- TR 1075041 9-12-2013 VKK
- this.oSB = NULL
- *=== TR 1075041 9-12-2013 VKK
- RETURN DODEFAULT()
- ENDPROC
- *--------------------------------------------------------------------------
- *-- [Main Process]
- PROCEDURE CreateOrders
- LOCAL llRetVal, lnOldSelect
- llRetVal = .t.
- lnOldSelect = SELECT()
- *#--- Send data to Server
- WITH this
- .LogMajorStage("Sales Order Creation.")
- Local l_nThermoCnt
- l_nThermoCnt = 0
- CREATE CURSOR curTabDrop (tabname CHAR(100))
- *--- 1044208
- .oAfterUpdate = NEWOBJECT("clsIpoPr_AfterUpdateBeforeCommit","clsIpoPr_AfterUpdateBeforeCommit.fxp",null,this.oHostPROCESS,this)
- .oBulk = NEWOBJECT("clsIpoPr_BulkNibbler","clsIpopr_BulkNibbler.fxp",null,this.oHostProcess,this)
- .oBulkMatch = NEWOBJECT("clsipopr_EdiBulkMatching","clsipopr_EdiBulkMatching.fxp","",null,this.oHostProcess)
- *=== 1044208
- *=-=-=-=-=-=-=--=-=-=-=-=-===-
- this.cFilterCriteria = " WHERE h.pkey IN (SELECT pkey FROM " + this.oHostProcess.cFilterTempTable + ")"
- *=-=-=-=-=-=-=--=-=-=-=-=-===-
- .AdvanceThermoTotalWithCaptionPlus("Creating single orders.", vcLogName)
- This.InitThermoWithCaption(@l_nThermoCnt, 10, "Sending transaction data to server...")
- llRetVal = llRetVal and .SendDataToTransWorkTables()
- .LogEntry("Send transaction data to server work tables " + IIF(llRetVal,"completed.","failed."))
- *--- TR 1044017 07-JAN-2010 HNISAR
- *!* This.AdvanceThermoPlus(@l_nThermoCnt,"Update 850 transaction server tables")
- This.AdvanceThermoPlus(@l_nThermoCnt,"Update " + This.oHostProcess.cProcessNo +" transaction server tables")
- *=== TR 1044017 07-JAN-2010 HNISAR
- llRetVal = llRetVal and .UpdateTransactionTables()
- *--- TR 1044017 07-JAN-2010 HNISAR
- *!* .LogEntry("Update 850 transaction server tables " + IIF(llRetVal,"completed.","failed."))
- .LogEntry("Update " + This.oHostProcess.cProcessNo +" transaction server tables " + IIF(llRetVal,"completed.","failed."))
- *=== TR 1044017 07-JAN-2010 HNISAR
- This.AdvanceThermoPlus(@l_nThermoCnt,"Remove error records from transaction work tables")
- llRetVal = llRetVal and .DeleteErrorRecordsFromTransWorkTables()
- .LogEntry("Remove error records from transaction work tables " + IIF(llRetVal,"completed.","failed."))
- This.AdvanceThermoPlus(@l_nThermoCnt)
- llRetVal = llRetVal and .CreateOrderWorkTables()
- llRetVal = llRetVal and .PopulateOrderWorkTables()
- .LogEntry("Populate order work tables " + IIF(llRetVal,"completed.","failed."))
- This.AdvanceThermoPlus(@l_nThermoCnt,"Populate order work tables")
- llRetVal = llRetVal and .PrepareOrderForUpdate()
- .LogEntry("Prepare order data for update " + IIF(llRetVal,"completed.","failed."))
- This.AdvanceThermoPlus(@l_nThermoCnt,"Prepare order data for update")
- llRetVal = llRetVal and .PopuldateTransHistoryWorkTables()
- .LogEntry("Populate data in transaction history work tables " + IIF(llRetVal,"completed.","failed."))
- This.AdvanceThermoPlus(@l_nThermoCnt,"Populate data in transaction history work tables")
- *llRetVal = llRetVal and .StampTimeAndUserID()
- llRetVal = llRetVal and .UpdateAllTables()
- .LogEntry("Sales Order Creation " + IIF(llRetVal,"completed.","failed."))
- This.AdvanceThermoPlus(@l_nThermoCnt)
- ** Populate Allocation tables based on Data warehouse
- llRetVal = llRetVal AND InsertAllocationRuleFromEDIWarehouse(this.czzedatawhse)
- IF llRetVal AND USED("curTabDrop")
- SELECT curTabDrop
- SCAN
- v_sqlexecnoerror("DROP TABLE " + ALLTRIM(curTabDrop.tabname))
- ENDSCAN
- ENDIF
- USE IN SELECT("curTabDrop")
- *--- 1044208
- .oAfterUpdate = NULL
- .oBulk = NULL
- .oBulkMatch = NULL
- *--- 1044208
- *#--- Prepare Date before order Creation
- *#--- Create order headers
- *#--- Create Order Header Notes
- *#--- create order Sp
- *##-- credit card
- *--- TR 1012711 17-OCT-2005 RG
- * For credit card transaction, update Credit Card table and factor infor in Sales Order table.
- *THIS.CreateCreditRecord('O','vzzoordrd',loRecordset.pkey,.T.)
- *#-- Create Order Detail - Newline logic -
- *--- Create Order Detail Notes
- *#-- FRM
- *--- Create FRM records
- *--- Copy_UDF_Data(This.nOldHeaderPKey, This.nNewHeaderPkey)
- *#-- Multi discount
- *--- create multi discount - tcSACDetail - m.pkey = v_nextPkey('zzoordsac')
- *#--- create transaction history header
- *#--- create transaction history detail
- *#-- set credit card encription
- *--- encription - loeipoth_ccard.cc_number = XP_ENCRYPT(loeipoth_ccard.CardNo)
- *#-- Charge
- *--- set fappv_amt With ChargeAmt, fexpn_date With ftran_date + facExpir_days
- *#--- ResolveTax - exists
- *#--- split order detail line base on detail start_date and end_date
- *--- create SAC records (ZZOORDSAC)
- *--- Customer Price - This.oBPOSalesOrder.GetCustomerPrice(Evaluate(pceipoTH + ".customer"), lcDivision, ;
- *--- RollUpCanceledBuckets("tcUnavail", "tcCanceled")
- *--- lnFKey = CreateCancelHdr(tcOrderHeader, lnCancQty, tcHistHeader)
- *--- CreateCancelDtl("tcCanceled", tcOrderDetail, lnFKey, lcCancType, lcCancRsn)
- *--- CreateCancelDtlHist("tcUnAvail", tcHistDetail, lnFKey, lcCancType, lcCancRsn)
- *--- llUseBulkMatch - This.InheritDataFromBulk(lnCurrOrderHeaderPkey, Evaluate(pceipoTH + ".rr_pkey"), ;
- tcOrderHeader, tcOrderDetail,"tcBulkMatch",tcOrderh_notes,tcOrderD_notes,@llHeaderNotes)
- *#--- Comments
- *--- Create order comment - ZZOORDCD
- *--- Create order Address - 'OT' - ZZOORDAD
- *--- Create order Address - 'BT' - ZZOOTADR
- *--- Create order Address - 'SO' - ZZOOTADR
- *#--- BULK
- *--- Create bulk nibbler Trx records
- *--- If llRetVal And .GetNibblerTrxNumsAndPkeys(This.CountTotalRecs (tcOrderHeader), This.CountTotalRecs (tcOrderDetail),;
- *--- @lnStrZZXNIBLR, @lnStrZZOORDWH, @lnStrZZOORDWD)
- * recording work records for AutoBulkReduction when have some bulk for this customer
- *--- This.oBPOSalesOrder.CreateNibblerQueuesForAddModeOnly
- * recording work records for nibbler summary
- *--- This.oBPOSalesOrder.CreateNibblerQueuesForAddModeOnly(;
- *#--- resolve Terms
- *--- 1009014 02/05 CB - Resolve the merchandise code on the sales order detail table:
- *--- Resolve MultiCurrency - exists
- ENDWITH
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetTransTables
- LPARAMETERS pceipoTH, pceipoTD, pceipoTC, pceipoTA,pceipoTS, pceipoTR, pceiPOtsac, pceiPOcr, pceipotWHSE
- *--- TechRec 1054619 08-Jun-2011 MANI. Added pceipotWHSE ===
- * TR 1050538 FH 11/10/10 - added pceiPOcr to parameter
- LOCAL llRetVal
- llRetVal = .t.
- this.ceipoTH = pceipoTH
- this.ceipoTD = pceipoTD
- this.ceipoTC = pceipoTC
- this.ceipoTA = pceipoTA
- this.ceipoTS = pceipoTS
- this.ceipoTR = pceipoTR &&--- Charges
- this.ceiPOtsac = pceiPOtsac
- this.ceiPOcr = pceiPOcr && * TR 1050538 FH
- *--- TechRec 1054619 08-Jun-2011 MANI. ---
- This.ceiPOtWHSE = pceipotWHSE
- *=== TechRec 1054619 08-Jun-2011 MANI. ===
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SendDataToTransWorkTables
- LOCAL llRetVal, lcUnique, lcSql
- llRetVal = .t.
- lcUnique = SYS(2015)
- WITH this
- .cZzeipoTH = "#zzeipoth" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceipoTH, this.cZzeipoTH)
- lcSql = "create index pkey on " + this.cZzeipoTH + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *---- trans detail
- LOCAL lcZzeipoTD
- lcZzeipoTD = "#zzeipotdTmp" + lcUnique
- .cZzeipoTD = "#zzeipotd" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceipoTD, lcZzeipoTD)
- *--- add a order detail link pkey field - which will be poupulated when order detail is created from tran detail
- lcSql = "select *, pkey as zzoordrd_pkey into " + this.cZzeipoTD + " from " + lcZzeipoTD
- llRetVal = llRetVal and v_sqlexec(lcSql)
- IF llRetVal
- .RegisterTable(this.cZzeipoTD)
- ENDIF
- lcSql = "create index pkey on " + this.cZzeipoTD + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "create index fkey on " + this.cZzeipoTD + " (fkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "create index zzoordrd_pkey on " + this.cZzeipoTD + " (zzoordrd_pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- .cZzeipoTA = "#zzeipota" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceipoTA, this.cZzeipoTA)
- .cZzeipoTC = "#zzeipotc" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceipoTC, this.cZzeipoTC)
- *--- TechRec 1052693 20-Apr-2011 asharma ---
- lcSql = "create index " + This.cZzeipoTC + "_pkey on " + This.cZzeipoTC + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TechRec 1052693 20-Apr-2011 asharma ===
- .cZzeipoTH_nt = "#zzeipoth_nt" + lcUnique
- lcSql = "Select n.* into " + this.cZzeipoTH_nt + " from sysnotes n inner join " + this.cZzeipoTH + " h on h.pkey = n.fkey " + ;
- " and n.table_name = 'ZZEIPOTH'"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *--- TechRec 1052693 20-Apr-2011 asharma ---
- lcSql = "create index " + this.cZzeipoTH_nt + "_pkey on " + this.cZzeipoTH_nt + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TechRec 1052693 20-Apr-2011 asharma ===
- IF llRetVal
- .RegisterTable(this.cZzeipoTH_nt )
- ENDIF
- *--- trans detail notes
- .cZzeipoTD_nt = "#zzeipotd_nt" + lcUnique
- lcSql = "Select n.*, n.fkey as zzoordrd_pkey into " + this.cZzeipotd_nt + " from sysnotes n inner join " + this.cZzeipotd + " d on d.pkey = n.fkey " + ;
- " and n.table_name = 'ZZEIPOTD'"
- *--- add a order detail link pkey field - which will be poupulated when order detail is created from tran detail
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *--- TechRec 1052693 20-Apr-2011 asharma ---
- lcSql = "create index " + this.cZzeipotd_nt + "_pkey on " + this.cZzeipotd_nt + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TechRec 1052693 20-Apr-2011 asharma ===
- IF llRetVal
- .RegisterTable(this.cZzeipotd_nt )
- ENDIF
- *--- trans extender table
- .cZzeipoTDExt = "#zzzUdfDt_ipo" + lcUnique
- lcSql = "select zzzUdfDt.*, HdrFKey as OldHdrFKey, DtlFKey as OldDtlFKey, g.UDF_Field " + ;
- " ,u.Grp_T_Key, Grp_O_Key " + ;
- " into " + .cZzeipoTDExt + ;
- " from zzzUdfDt inner join " + .cZzeipoTH + " h on zzzUdfDt.HdrFKey = h.PKey " + ;
- " inner join zzzUdfCR c on c.PKey = zzzUdfDt.GrpFKey and c.Module = 'ZZEIPOTH' " + ;
- " inner join zzzUdfGd g on g.PKey = zzzUdfDt.UdfFKey " + ;
- " inner join ( select u.UDF_Field, ci.PKey as Grp_I_Key, ct.PKey as Grp_T_Key, co.PKey as Grp_O_Key " + ;
- " from zzzUdfGD u join zzzUdfGH g on g.PKey = u.FKey " + ;
- " join zzzUdfCr ci on ci.FKey = g.PKey and ci.Module = 'ZZEIPOIH' and ci.Link_Table = 'ZZEIPOID' " + ;
- " join zzzUdfCr ct on ct.FKey = g.PKey and ct.Module = 'ZZEIPOTH' and ct.Link_Table = 'ZZEIPOTD' " + ;
- " join zzzUdfCr co on co.FKey = g.PKey and co.Module = 'ZZOORDRH' and co.Link_Table = 'ZZOORDRD') u " + ;
- " on u.Udf_field = g.Udf_field "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- IF llRetVal
- .RegisterTable(this.cZzeipoTDExt )
- ENDIF
- *--- charges
- .cZzeipoTR = "#ZzeipoTR" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceipoTR, this.cZzeipoTR)
- *--- add field hasChrgs to trans detail (zzeipotd) - it is need in rollup - ipotd => oordrd
- lcSql = "alter table " + this.cZzeipotd + " add hasCharges char(1) DEFAULT(' ') not null "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "Update d Set hasCharges = 'Y' FROM " + this.cZzeipotd + " d INNER JOIN " + this.cZzeipotr + ;
- " r on r.fkey = d.pkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *--- multi discount
- .cZzeiPOtsac = "#ZzeiPOtsac" + SYS(2015)
- lcSql = llRetval and this.oCopyUtil.SendCursorToSqlTbl(.ceiPOtsac,.cZzeiPOtsac)
- *--- TR 1044485
- * SLN
- .cZzeipoTS = "#ZzeiPOts" + SYS(2015)
- lcSql = llRetval and this.oCopyUtil.SendCursorToSqlTbl(.ceipoTS,.cZzeipoTS)
- *=== TR 1044485
- *--- TechRec 1052693 20-Apr-2011 asharma ---
- lcSql = "create index " + .cZzeipoTS + "_pkey on " + .cZzeipoTS + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TechRec 1052693 20-Apr-2011 asharma ===
- * TR 1050538 FH 11/10/10
- .cZzeipoCr = "#zzeipocr" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceiPOcr, this.cZzeipoCr)
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- .cZzeiPOtWHSE = "#ZzeiPOtWHSE" + lcUnique
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(this.ceiPOtWHSE, this.cZzeiPOtWHSE)
- *--- TechRec 1056973 08-Dec-2011 jisingh Commented ---
- *llRetVal = llRetVal and this.PrepareDataForWhse()
- *=== TechRec 1056973 08-Dec-2011 jisingh ===
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE UpdateTransactionTables
- LOCAL llRetVal, lcSql_update, lcSql_dtl_update, lcSql_delete, lcSql_Dtl_delete, lcSql_insert, lcSql_Dtl_insert, llNotExists
- LOCAL lcSql_update_zzeipotsac, lcSql_insert_zzeipotsac, lcSql_delete_zzeipotsac
- LOCAL lcSQL_update_zzeipots, lcSQL_insert_zzeipots, lcSQL_delete_zzeipots,lcSqlInsert_zzeipoWhse, lcSqlDelete_zzeipoWhse
- *--- TR 1059065 01-Feb-12 SK ===
- LOCAL lcSqlUpdate_zzeipotwhse
- *--- TechRec 1056973 18-Nov-2011 jisingh Added lcSqlDelete_zzeipoWhse ===
- &&--- TechRec 1054619 29-Sep-2011 MANI. Added variable lcSqlInsert_zzeipoWhse ===
- llRetVal = .t.
- llNotExists = .t.
- STORE " " TO lcSql_update, lcSql_dtl_update, lcSql_delete, lcSql_Dtl_delete, lcSql_insert, lcSql_Dtl_insert
- STORE " " TO lcSql_update_zzeipotr, lcSql_insert_zzeipotr, lcSql_delete_zzeipotr
- STORE " " TO lcSql_update_zzeipotsac, lcSql_insert_zzeipotsac, lcSql_delete_zzeipotsac
- STORE " " TO lcSQL_update_zzeipots, lcSQL_insert_zzeipots, lcSQL_delete_zzeipots, lcSqlInsert_zzeipoWhse, lcSqlDelete_zzeipoWhse
- *--- TR 1059065 01-Feb-12 SK ===
- STORE " " TO lcSqlUpdate_zzeipotwhse
- *--- TechRec 1056973 18-Nov-2011 jisingh Added lcSqlDelete_zzeipoWhse ===
- &&--- TechRec 1054619 29-Sep-2011 MANI. Added variable lcSqlInsert_zzeipoWhse ===
- *--- transaction temp tables
- lcZzeipoth = this.cZzeipoTH
- lcZzeipotd = this.cZzeipoTD
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSql_update,this.cZzeipoth,"zzeipoth")
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSql_dtl_update,this.cZzeipotd,"zzeipotd")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql_Insert,this.cZzeipoth,"zzeipoth")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql_dtl_Insert,this.cZzeipotd,"zzeipotd")
- llRetVal = llRetVal and this.oCopyUtil.GetDeleteSql(@lcSql_Delete,this.cZzeipoth,"zzeipoth",.t.,this.cFilterCriteria,"d","h")
- llRetVal = llRetVal and this.GetDeleteSql_TransDtl(@lcSql_dtl_Delete)
- *--- charges
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSql_update_zzeipotr,this.cZzeipotR,"zzeipotr","'pkey'")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql_insert_zzeipotr,this.cZzeipotR,"zzeipotr","'pkey'")
- * llRetVal = llRetVal and this.oCopyUtil.GetDeleteSql(@lcSql_delete_zzeipotr,this.cZzeipotR,"zzeipotr",.t.)
- llRetVal = llRetVal and this.GetDeleteSQL_TransCharges(@lcSql_delete_zzeipotr)
- *--- multi discount
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSql_update_zzeipotsac,this.cZzeipotsac,"zzeipotsac")
- *- TR 1059993 FH/YIK 03/09/12
- *--- TR 1045120 FEB-18-2010 BR
- *!* llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql_insert_zzeipotsac,this.cZzeipotsac,"zzeipotsac",,,,.t.)
- *!* llRetVal = llRetVal and this.oCopyUtil.GetDeleteSql(@lcSql_delete_zzeipotsac,this.cZzeipotsac,"zzeipotsac",,this.cFilterCriteria,,,"zzeipoth","hfkey","h")
- *=== TR 1045120 FEB-18-2010 BR
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql_insert_zzeipotsac,this.cZzeipotsac,"zzeipotsac")
- llRetVal = llRetVal and this.oCopyUtil.GetDeleteSql(@lcSql_delete_zzeipotsac,this.cZzeipotsac,"zzeipotsac",.T.,this.cFilterCriteria,,,"zzeipoth","hfkey","h")
- *- TR 1059993 FH/YIK 03/09/12
- *- update - address, comment, notes
- LOCAL lcSqlUpdate_zzeipota, lcSqlUpdate_zzeipotc,lcSqlUpdate_zzeipoth_nt,lcSqlUpdate_zzeipotd_nt
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSqlUpdate_zzeipota,this.cZzeipota,"zzeipota")
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSqlUpdate_zzeipotc,this.cZzeipotc,"zzeipotc")
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSqlUpdate_zzeipoth_nt,this.cZzeipoth_nt,"sysnotes")
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSqlUpdate_zzeipotd_nt,this.cZzeipotd_nt,"sysnotes")
- * llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSql_update_zzeipotr,this.cZzeipotr,"zzeipotr")
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSQL_update_zzeipots,this.cZzeipots,"zzeipots")
- *--- TR 1059065 01-Feb-12 SK Creating update string for zzeipotwhse (warehouse) table.
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@lcSqlUpdate_zzeipotwhse,this.cZzeipotWhse,"zzeipotwhse")
- *=== TR 1059065 01-Feb-12 SK
- *- insert - address, comment, notes
- LOCAL lcSqlInsert_zzeipota, lcSqlInsert_zzeipotc,lcSqlInsert_zzeipoth_nt,lcSqlInsert_zzeipotd_nt
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSqlInsert_zzeipota,this.cZzeipota,"zzeipota")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSqlInsert_zzeipotc,this.cZzeipotc,"zzeipotc")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSqlInsert_zzeipoth_nt,this.cZzeipoth_nt,"sysnotes")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSqlInsert_zzeipotd_nt,this.cZzeipotd_nt,"sysnotes")
- * llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSql_insert_zzeipotr,this.cZzeipotr,"zzeipotr")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSQL_insert_zzeipots,this.cZzeipotS,"zzeipots")
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSqlInsert_zzeipoWhse,this.cZzeipotWhse,"zzeipotwhse")
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- LOCAL lcSqlDelete_zzeipota, lcSqlDelete_zzeipotc,lcSqlDelete_zzeipoth_nt,lcSqlDelete_zzeipotd_nt
- llRetVal = llRetVal and this.GetDeleteSQL_TransAddr(@lcSqlDelete_zzeipota)
- llRetVal = llRetVal and this.GetDeleteSQL_TransCmt(@lcSqlDelete_zzeipotc)
- llRetVal = llRetVal and this.GetDeleteSQL_TransHdrNotes(@lcSqlDelete_zzeipoth_nt)
- llRetVal = llRetVal and this.GetDeleteSQL_TransDtlNotes(@lcSqlDelete_zzeipotd_nt)
- llRetVal = llRetVal and this.GetDeleteSQL_TransSLN(@lcSQL_delete_zzeipots)
- *--- TechRec 1056973 18-Nov-2011 jisingh ---
- llRetVal = llRetVal and this.GetDeleteSQL_TransEDIS(@lcSqlDelete_zzeipoWhse)
- *=== TechRec 1056973 18-Nov-2011 jisingh ===
- Local llBeganTransaction,lnTranErrCount,lcTranFailedMsg
- llBeganTransaction = This.BeginTransaction()
- lnTranErrCount = 0
- lcTranFailedMsg = ""
- If llBeganTransaction And llRetVal
- &&*--- TR 1044017 07-JAN-2010 HNISAR && REplace 850 WITH " + This.oHostProcess.cProcessNo + " in All the statements below
- this.SqlExecInTran(lcSql_update, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction header failed.")
- this.SqlExecInTran(lcSql_dtl_update, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction detail failed.")
- this.SqlExecInTran(lcSqlUpdate_zzeipota, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction address failed.")
- this.SqlExecInTran(lcSqlUpdate_zzeipotc, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction comment failed.")
- this.SqlExecInTran(lcSqlUpdate_zzeipoth_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction header notes failed.")
- this.SqlExecInTran(lcSqlUpdate_zzeipotd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction detail notes failed.")
- this.SqlExecInTran(lcSql_update_zzeipotr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction detail charges failed.")
- this.SqlExecInTran(lcSql_update_zzeipotsac, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction multi discount failed.")
- this.SqlExecInTran(lcSQL_update_zzeipots, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction sln failed.")
- *--- TR 1059065 01-Feb-12 SK Executing update string for warehouse table
- this.SqlExecInTran(lcSqlUpdate_zzeipotwhse, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Update " + This.oHostProcess.cProcessNo + " transaction address failed.")
- *=== TR 1059065 01-Feb-12 SK
- this.SqlExecInTran(lcSql_delete, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction header failed.")
- this.SqlExecInTran(lcSql_Dtl_delete, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction detail failed.")
- this.SqlExecInTran(lcSqlDelete_zzeipota, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction address failed.")
- this.SqlExecInTran(lcSqlDelete_zzeipotc, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction comment failed.")
- this.SqlExecInTran(lcSqlDelete_zzeipoth_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction header notes failed.")
- this.SqlExecInTran(lcSqlDelete_zzeipotd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction detail notes failed.")
- this.SqlExecInTran(lcSql_delete_zzeipotr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction detail charges failed.")
- *--- TechRec 1056973 18-Nov-2011 jisingh ---
- this.SqlExecInTran(lcSqlDelete_zzeipoWhse, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction edis failed.")
- *=== TechRec 1056973 18-Nov-2011 jisingh ===
- this.SqlExecInTran(lcSQL_delete_zzeipots, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction sln failed.")
- *--- multi discount
- this.SqlExecInTran(lcSql_delete_zzeipotsac, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete " + This.oHostProcess.cProcessNo + " transaction multi discount failed.")
- this.SqlExecInTran(lcSql_insert, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction header failed.")
- this.SqlExecInTran(lcSql_Dtl_insert, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction detail failed.")
- this.SqlExecInTran(lcSqlInsert_zzeipota, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction address failed.")
- this.SqlExecInTran(lcSqlInsert_zzeipotc, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction comment failed.")
- this.SqlExecInTran(lcSqlInsert_zzeipoth_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction header notes failed.")
- this.SqlExecInTran(lcSqlInsert_zzeipotd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction detail notes failed.")
- this.SqlExecInTran(lcSql_insert_zzeipotr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction detail charges failed.")
- this.SqlExecInTran(lcSql_insert_zzeipotsac, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction multi discount failed.")
- this.SqlExecInTran(lcSql_insert_zzeipots, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction sln failed.")
- *--- TR 1059065 01-Feb-12 SK Executing Insert string for warehouse table
- this.SqlExecInTran(lcSqlInsert_zzeipoWhse, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert " + This.oHostProcess.cProcessNo + " transaction warehouse failed.")
- *=== TR 1059065 01-Feb-12 SK
- If llRetVal
- This.EndTransaction()
- This.LogEntry(" " + This.oHostProcess.cProcessNo + " Transaction successful.")
- *--- increase toProcess vaulue for new transaction records.
- Else
- This.RollbackTransaction()
- This.LogEntry("---------------------------------------------")
- This.LogEntry(lcTranFailedMsg)
- This.LogEntry(" " + This.oHostProcess.cProcessNo + " Transaction rolled back.")
- This.LogEntry("=============================================")
- Endif
- Else
- If llRetVal && and not llBeganTransaction
- *--- LogEntry : unable to open Transaction
- This.LogEntry("Fatal error : Fail to open transaction.")
- Endif
- Endif
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL_TransAddr
- LPARAMETERS pcSql
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- lcSQL = "delete d from zzeipota d inner join zzeipoth h on h.pkey = d.fkey " + lcFilter + ;
- " not exists ( select td.pkey from " + this.cZzeipota + " td where td.pkey = d.pkey )"
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *-------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL_TransSLN
- LPARAMETERS pcSQL
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- lcSQL = "delete d from zzeipots s inner join zzeipotd d on d.pkey = s.fkey join zzeipoth h on d.fkey = h.pkey " + lcFilter + ;
- " not exists ( select * from " + this.cZzeipots + " td where td.pkey = s.pkey )"
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--- TechRec 1056973 18-Nov-2011 jisingh ---
- *-------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL_TransEDIS
- LPARAMETERS pcSQL
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- *--- TR 1059065 01-Feb-12 SK deleting only EDIS records by filtering sfkey > 0
- *!* lcSQL = "delete w from zzeipotwhse w join zzeipoth h on w.hfkey = h.pkey " + lcFilter + ;
- *!* " not exists ( select * from " + this.cZzeipots + " td where td.pkey = w.sfkey ) " + ;
- *!* " and h.errs_flg_h <> 'Y' and (h.warn_flg_h <> 'Y' " + ;
- *!* " or (h.warn_flg_h = 'Y' and h.ignore_warn = 'Y'))"
- lcSQL = "delete w from zzeipotwhse w join zzeipoth h on w.hfkey = h.pkey " + lcFilter + ;
- " w.sfkey > 0 and not exists ( select * from " + this.cZzeipots + " td where td.pkey = w.sfkey ) " + ;
- " and h.errs_flg_h <> 'Y' and (h.warn_flg_h <> 'Y' " + ;
- " or (h.warn_flg_h = 'Y' and h.ignore_warn = 'Y'))"
- *--- TR 1059065 01-Feb-12 SK
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *=== TechRec 1056973 18-Nov-2011 jisingh ===
- *--------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL_TransCmt
- LPARAMETERS pcSql
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- lcSQL = "delete d from zzeipotc d inner join zzeipoth h on h.pkey = d.fkey " + lcFilter + ;
- " not exists ( select td.pkey from " + this.cZzeipotc + " td where td.pkey = d.pkey )"
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *--- TR 1052729 / 1044208 10-Mar-11 SK Procedure was missedout when retrofits the TR 1044208
- PROCEDURE GetDeleteSQL_TransCharges
- LPARAMETERS pcSQL
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- lcSQL = "delete s from zzeipotr s inner join zzeipotd d on d.pkey = s.fkey join zzeipoth h on d.fkey = h.pkey " + lcFilter + ;
- " not exists ( select * from " + this.cZzeipotr + " td where td.pkey = s.pkey )"
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *=== TR 1052729 / 1044208 10-Mar-11 SK
- PROCEDURE GetDeleteSQL_TransHdrNotes
- LPARAMETERS pcSql, plExists
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- IF plExists
- lcSQL = "delete d from sysnotes d inner join " + this.cZzeipoTh_nt + " h on h.pkey = d.pkey and d.table_name = 'ZZEIPOTH' "
- ELSE
- *--- need to join with original transaction header to apply filter
- lcSQL = "delete d from sysnotes d inner join zzeipoth h on h.pkey = d.fkey and d.table_name = 'ZZEIPOTH' " +;
- lcFilter + " not exists ( select td.pkey from " + this.cZzeipoTh_nt + " td where td.pkey = d.pkey )"
- ENDIF
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL_TransDtlNotes
- LPARAMETERS pcSql, plExists
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- IF plExists
- lcSQL = " delete n from sysnotes n inner join " + this.cZzeipoTd_nt + " td on td.pkey = n.pkey and n.table_name = 'ZZEIPOTD' "
- ELSE
- lcSQL = " delete n from sysnotes n inner join zzeipotd td on td.pkey = n.fkey and n.table_name = 'ZZEIPOTD' " + ;
- " inner join zzeipoth h on h.pkey = td.fkey " +;
- lcFilter + " not exists ( select td.pkey from " + this.cZzeipoTd_nt + " tn where tn.pkey = n.pkey )"
- ENDIF
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetDeleteSql_TransDtl
- LPARAMETERS pcSql
- LOCAL llRetVal, lcSQL, lcFilter
- llRetVal = .t.
- IF EMPTY(this.cFilterCriteria)
- lcFilter = "Where "
- ELSE
- lcFilter = IIF(AT("WHERE", UPPER(this.cFilterCriteria)) > 0, "","Where") + this.cFilterCriteria + " and "
- ENDIF
- lcSQL = "delete d from zzeipotd d inner join zzeipoth h on h.pkey = d.fkey " + lcFilter + ;
- " not exists ( select * from " + this.cZzeipotd + " td where td.pkey = d.pkey )"
- pcSql = lcSql
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE DeleteErrorRecordsFromTransWorkTables
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- *!* *--- 1010206 12/05/2005 Ilya: Add check for the warning flags
- *!* Select customer, division, po_num, pkey From (pceipoTH) ;
- *!* WHERE Errs_flg_h= "N" And (warn_flg_h <> 'Y' Or ignore_warn = 'Y') ;
- *!* ORDER By customer, division, po_num ;
- *!* INTO Cursor tcOrdList
- *--- detail notes
- this.LogEntry("Delete Error Records from Trans started...")
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete dnt from " + this.cZzeipotd_nt + " dnt inner join " + this.cZzeipoTd + " d " + ;
- " on d.pkey = dnt.fkey inner join " + this.cZzeipoTh + " h on h.pkey = d.fkey " + ;
- " where (h.Errs_flg_h = 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete detail notes " + IIF(llRetVal, "completed.","failed."))
- *--- SLN
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete s from " + this.cZzeipots + " s inner join " + this.cZzeipotd + " d on d.pkey = s.fkey " + ;
- " inner join " + this.cZzeipoth + " h ON h.pkey = d.fkey " + ;
- " where (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete sln " + IIF(llRetVal, "completed.","failed."))
- *--- detail
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete d from " + this.cZzeipoTh + " h inner join " + this.cZzeipoTd + " d " + ;
- " on h.pkey = d.fkey WHERE (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete details " + IIF(llRetVal, "completed.","failed."))
- *--- address
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete d from " + this.cZzeipoTh + " h inner join " + this.cZzeipoTa + " d " + ;
- " on h.pkey = d.fkey WHERE (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete address " + IIF(llRetVal, "completed.","failed."))
- *--- comment
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete d from " + this.cZzeipoTh + " h inner join " + this.cZzeipoTc + " d " + ;
- " on h.pkey = d.fkey WHERE (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete comments " + IIF(llRetVal, "completed.","failed."))
- *--- header notes
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete d from " + this.cZzeipoTh + " h inner join " + this.cZzeipoTh_nt + " d " + ;
- " on h.pkey = d.fkey WHERE (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete header notes " + IIF(llRetVal, "completed.","failed."))
- *--- TR 1059065 23-Jan-12 SK Deleting warning records only h.ignore_warn = 'N' instead of h.ignore_warn = 'Y'
- *--- TechRec 1054619 10-Jun-2011 MANI. ---
- *- TR 1061758 FH - removed join on doc_num, and replace with h.pkey, wh.hfkey
- *-- Remove error record from ware house transaction table.
- lcSql = "delete wh from " + this.cZzeipoTh + " h inner join " + this.czzeipotwhse + " wh " + ;
- " on h.pkey = wh.hfkey WHERE (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete Ware house record" + IIF(llRetVal, "completed.","failed."))
- *=== TechRec 1054619 10-Jun-2011 MANI. ===
- *=== TR 1059065 23-Jan-12 SK
- *--- multi discount
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete d from " + this.cZzeipotsac + " d inner join " + this.cZzeipoth + " h on h.pkey = d.hfkey " + ;
- " where (h.Errs_flg_h= 'Y' or (h.warn_flg_h = 'Y' and h.ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete multi notes " + IIF(llRetVal, "completed.","failed."))
- *--- TechRec 1055684 27-Jul-2011 jjanand === Changed h.ignore_warn = 'Y' to h.ignore_warn = 'N'
- lcSql = "delete h from " + this.cZzeipoTh + " h WHERE (Errs_flg_h = 'Y' or (warn_flg_h = 'Y' and ignore_warn = 'N'))"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("delete header " + IIF(llRetVal, "completed.","failed."))
- *--- extender - zzzUdfDt
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderWorkTables
- LOCAL llRetVal
- WITH this
- llRetVal = .t.
- llRetVal = llRetVal and .PopulateOrderWorkHeader()
- llRetVal = llRetVal and .PopulateOrderWorkDetail()
- llRetVal = llRetVal and .PopulateOrderWorkAddress()
- llRetVal = llRetVal and .PopulateOrderWorkComment()
- llRetVal = llRetVal and .PopulateOrderHeaderWorkNotes()
- llRetVal = llRetVal and .PopulateOrderDtlWorkNotes()
- llRetVal = llRetVal and .PopulateOrderExtender()
- llRetVal = llRetVal and .PopulateOrderCharges()
- llRetVal = llRetVal and .PopulateOrderDiscount()
- *--- TR 1053708 19-05-2011 RKI ---*
- *--- TR 1056306 09-13-2011 RKI ---*
- *Commented here. Because at this stage div_rate is not updated in order header.
- *!* llRetVal = llRetVal and setbased_calculateweightedprodcostorstd(.czzoordrd)
- *=== TR 1056306 09-13-2011 RKI ===*
- *=== TR 1053708 19-05-2011 RKI ===*
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderExtender
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- *--- this.cZzeipotd.zzoordrd_pkey still have transaction detail pkey - but
- *--- repeated with same pkey for sizebuckets rows those are suppose to be rollup for order detail
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,this.cZzeipoTDExt, this.cZzoordrdExt,,,,.t.,"dex")
- lcSql = lcSql + " where exists ( " + ;
- " select d.zzeipotd_pkey from " + this.cZzoordrd + " d " + ;
- " where d.zzeipotd_pkey = dex.oldDtlFkey )"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderCharges
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- *--- this.cZzeipotd.zzoordrd_pkey still have transaction detail pkey - but
- *--- repeated with same pkey for sizebuckets rows those are suppose to be rollup for order detail
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,this.cZzeipoTR, this.cZzoordrd_chrg,,,,.t.,"ch")
- lcSql = lcSql + " where exists ( " + ;
- " select d.zzeipotd_pkey from " + this.cZzoordrd + " d " + ;
- " where d.zzeipotd_pkey = ch.fkey )"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderDiscount
- LOCAL llRetVal, lcSql, lcSql_d
- llRetVal = .t.
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,this.cZzeiPOtsac, this.cZzoordsac,,,,.t.,"md")
- *--- get header multi discount
- lcSql_h = lcSql + " where exists ( " + ;
- " select h.zzeipoth_pkey from " + this.cZzoordrh + " h " + ;
- " where h.zzeipoth_pkey = md.hfkey ) and md.line_seq = 0 "
- llRetVal = llRetVal and v_sqlexec(lcSql_h)
- *--- get detail multi discount
- lcSql_d = lcSql + " where exists ( " + ;
- " select d.zzeipotd_pkey from " + this.cZzoordrd + " d " + ;
- " where d.zzeipotd_pkey = md.dfkey ) and md.line_seq > 0 "
- llRetVal = llRetVal and v_sqlexec(lcSql_d)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderWorkHeader
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSQL,.cZzeipoTH,.cZzoordrh,"'zzeipoth_pkey'","zzeipoth_pkey","h.pkey")
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE CreateOrderWorkTables
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- LOCAL lcUnique
- lcUnique = SYS(2015)
- *--- SO order work tables
- .cZzoordrh = "#zzoordrh" + lcUnique
- *--- create link field between order hearder and transaction header
- lcSql = "select *, pkey as zzeipoth_pkey into " + .cZzoordrh + " from zzoordrh where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrh)
- lcSql = "Create Index pkey on " + .cZzoordrh+ " (pkey ) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "Create Index zzeipoth_pkey on " + .cZzoordrh+ " (zzeipoth_pkey ) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *--- order detail
- .cZzoordrd = "#zzoordrd" + lcUnique
- lcSql = "select *, pkey as zzeipotd_pkey into " + .cZzoordrd + " from zzoordrd where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrd)
- lcSql = "Create Index pkey on " + .cZzoordrd + " (pkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "Create Index fkey on " + .cZzoordrd + " (fkey) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "Create Index man_bulk_seq on " + .cZzoordrd + " (man_bulk,bulk_seq ) "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- .cZzoordsp = "#zzoordsp" + lcUnique
- lcSql = "select * into " + .cZzoordsp + " from zzoordsp where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordsp)
- *--- One time addresses
- .cZzoordad = "#zzoordad" + lcUnique
- lcSql = "select * into " + .cZzoordad + " from zzoordad where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordad)
- .cZzootadr = "#zzootadr" + lcUnique
- lcSql = "select * into " + .cZzootadr + " from zzootadr where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzootadr)
- .cZzoordcd = "#zzoordcd" + lcUnique
- lcSql = "select * into " + .cZzoordcd + " from zzoordcd where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordcd)
- *--- Notes
- .cZzoordrh_nt = "#zzoordrh_nt" + lcUnique
- lcSql = "select * into " + .cZzoordrh_nt + " from sysnotes where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrh_nt)
- .cZzoordrd_nt = "#zzoordrd_nt" + lcUnique
- lcSql = "select * into " + .cZzoordrd_nt + " from sysnotes where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrd_nt)
- *--- Extender object
- *--- trans extender table
- .cZzoordrdExt = "#zzzUdfDt_ordrd" + lcUnique
- lcSql = "select * into " + .cZzoordrdExt + " from " + .cZzeipoTDExt + " where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrdExt)
- *--- charges
- .cZzoordrd_chrg = "#zzxChrDS_ordrd" + lcUnique
- lcSql = "select * into " + .cZzoordrd_chrg + " from zzxchrds where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal AND v_sqlexec("ALTER TABLE " + .cZzoordrd_chrg + " DROP COLUMN pkey ")
- llRetVal = llRetVal AND v_sqlexec("ALTER TABLE " + .cZzoordrd_chrg + " ADD pkey INT ")
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordrd_chrg)
- *--- multi discount (orig TR 1018184)
- .cZzoordsac = "#Zzoordsac" + lcUnique
- lcSql = "select *, pkey as hfkey, pkey as dfkey into " + .cZzoordsac + " from zzoordsac where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzoordsac)
- *--- Transaction history tables
- .cZzeipoHH = "#zzeipohh" + lcUnique
- lcSql = "select * into " + .cZzeipoHH + " from zzeipohh where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHH)
- .cZzeipoHD = "#zzeipohd" + lcUnique
- lcSql = "select * into " + .cZzeipoHD + " from zzeipohd where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHD)
- .cZzeipoHC = "#zzeipohc" + lcUnique
- lcSql = "select * into " + .cZzeipoHC + " from zzeipohc where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHC)
- .cZzeipoHA = "#zzeipoha" + lcUnique
- lcSql = "select * into " + .cZzeipoHA + " from zzeipoha where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHA)
- .cZzeipoHH_nt = "#zzeipohh_nt" + lcUnique
- lcSql = "select * into " + .cZzeipoHH_nt + " from sysnotes where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHH_nt)
- .cZzeipoHD_nt = "#zzeipohd_nt" + lcUnique
- lcSql = "select * into " + .cZzeipoHD_nt + " from sysnotes where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHD_nt)
- .cZzeipoHS = "#zzeipots" + lcUnique
- lcSql = "select * into " + .cZzeipoHS + " from zzeipohs where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.cZzeipoHS)
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- *--- EDID/EIDH Records czzedatawhse
- .czzedatawhse = "#zzedatawhse" + lcUnique
- lcSql = "select * into " + .czzedatawhse + " from zzedatawhse where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.AddToOrdTbls(.czzedatawhse)
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE AddToOrdTbls
- LPARAMETERS pcTblName
- WITH this
- .nOrdTbls = .nOrdTbls + 1
- DIMENSION .aOrdTbls[.nOrdTbls]
- .aOrdTbls[.nOrdTbls]= pcTblName
- .RegisterTable(pcTblName)
- ENDWITH
- RETURN .t.
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopuldateTransHistoryWorkTables
- LOCAL llRetVal
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.PopulateTransHdrHistory()
- llRetVal = llRetVal and this.PopulateTransDtlHistory()
- llRetVal = llRetVal AND this.PopulateTransSLNHistory()
- llRetVal = llRetVal and this.PopulateTransAddressHistory()
- llRetVal = llRetVal and this.PopulateTransCommentHistory()
- llRetVal = llRetVal and this.PopulateTransHdrNotesHistory()
- llRetVal = llRetVal and this.PopulateTransDtlNotesHistory()
- *--- update pkey
- llRetVal = llRetVal and this.SetPkey_TransHistory()
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransHdrHistory
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTH,.cZzeipoHH,,,,.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransSLNHistory
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and v_sqlexec(;
- "UPDATE s set line_seq = d.line_seq, dtl_pkey = d.zzoordrd_pkey, ord_num = d.ord_num FROM " + .cZzeipoTS + " s JOIN " + .cZzeipoTD + " d ON s.fkey = d.pkey ")
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTS,.cZzeipoHS,,,,.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- *--- TechRec 1056973 08-Dec-2011 jisingh ---
- llRetVal = llRetVal and this.PrepareDataForWhse()
- *=== TechRec 1056973 08-Dec-2011 jisingh ===
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransDtlHistory
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTD,.cZzeipoHD,,,,.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransAddressHistory
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- lcFlds = ""
- lcValues = ""
- lcExcludeFlds = ""
- lcCalFlds = ""
- lcCalFldsValues = ""
- llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, .cZzeipoHA, .cZzeipota, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'d')
- lcSql = " INSERT INTO " + .cZzeipoHA + " ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + .cZzeipoTA + " d where ADDR_TYPE in ('OT','BT','SO')"
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransCommentHistory
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTC,.cZzeipoHC,,,,.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransHdrNotesHistory
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTH_nt,.cZzeipoHH_nt,"'table_name'","table_name","'ZZEIPOHH'",.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateTransDtlNotesHistory
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- WITH this
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTD_nt,.cZzeipoHD_nt,"'table_name'","table_name","'ZZEIPOHD'",.t.)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetPkey_TransHistory
- Local llRetVal, lnOldSelect,lcUnique, lcSQL
- llRetVal = .T.
- lnOldSelect = Select()
- *--- TR 1043347
- this.oHostProcess.FixBcSysNumForEDI850()
- *=== TR 1043347
- DECLARE laOrdDtls[6,4]
- laOrdDtls[1,1] = this.cZzeipohd
- laOrdDtls[1,2] = "fkey" && update field of detail table
- laOrdDtls[1,3] = "fkey" && relation field of Detail table
- laOrdDtls[1,4] = "pkey" && relation field of Header table
- laOrdDtls[2,1] = this.cZzeipoha
- laOrdDtls[2,2] = "fkey" && update field of detail table
- laOrdDtls[2,3] = "fkey" && relation field of Detail table
- laOrdDtls[2,4] = "pkey" && relation field of Header table
- laOrdDtls[3,1] = this.cZzeipohc
- laOrdDtls[3,2] = "fkey" && update field of detail table
- laOrdDtls[3,3] = "fkey" && relation field of Detail table
- laOrdDtls[3,4] = "pkey" && relation field of Header table
- laOrdDtls[4,1] = this.cZzeipohh_nt
- laOrdDtls[4,2] = "fkey" && update field of detail table
- laOrdDtls[4,3] = "fkey" && relation field of Detail table
- laOrdDtls[4,4] = "pkey" && relation field of Header table
- laOrdDtls[5,1] = this.cZzeipohd_nt
- laOrdDtls[5,2] = "parentKey" && update field of detail table
- laOrdDtls[5,3] = "parentKey" && relation field of Detail table
- laOrdDtls[5,4] = "pkey" && relation field of Header table
- laOrdDtls[6,1] = this.cZzeipohs
- laOrdDtls[6,2] = "hfkey" && update field of detail table
- laOrdDtls[6,3] = "hfkey" && relation field of Detail table
- laOrdDtls[6,4] = "pkey" && relation field of Header table
- lcSQL = "SELECT count(*) newCount from " + this.cZzeipohh
- llRetVal = llRetVal and v_sqlexec(lcSQL,"HdrRecord")
- IF llRetVal AND HdrRecord.newCount > 0
- lnMaxPkey = v_nextPkey("ZZEIPOHH",HdrRecord.newCount)
- llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzeipohh,"pkey",@laOrdDtls,lnMaxPkey,HdrRecord.newCount,;
- "pkey_I")
- ENDIF
- llRetVal = llRetVal and this.SetPkey_TransDtlHistory()
- llRetVal = llRetVal and this.SetPkey(this.cZzeipoha,'zzeipoha')
- llRetVal = llRetVal and this.SetPkey(this.cZzeipohc,'zzeipohc')
- llRetVal = llRetVal and this.SetPkey(this.cZzeipohh_nt,'sysnotes')
- llRetVal = llRetVal and this.SetPkey(this.cZzeipohd_nt,'sysnotes')
- SELECT(lnOldselect)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetPkey_TransDtlHistory
- Local llRetVal, lnOldSelect,lcSQL
- llRetVal = .T.
- lnOldSelect = Select()
- DECLARE laOrdDtls[2,4]
- laOrdDtls[1,1] = this.cZzeipohd_nt
- laOrdDtls[1,2] = "fkey" && update field of detail table
- laOrdDtls[1,3] = "fkey" && relation field of Detail table
- laOrdDtls[1,4] = "pkey" && relation field of Header table
- laOrdDtls[2,1] = this.cZzeipohs
- laOrdDtls[2,2] = "fkey" && update field of detail table
- laOrdDtls[2,3] = "fkey" && relation field of Detail table
- laOrdDtls[2,4] = "pkey" && relation field of Header table
- lcSQL = "SELECT count(*) newCount from " + this.cZzeipohd
- llRetVal = llRetVal and v_sqlexec(lcSQL,"HdrRecord")
- IF llRetVal AND HdrRecord.newCount > 0
- lnMaxPkey = v_nextPkey("ZZEIPOHD",HdrRecord.newCount)
- llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzeipohd,"pkey",@laOrdDtls,lnMaxPkey,HdrRecord.newCount,;
- "pkey_I")
- ENDIF
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderWorkDetail
- LOCAL llRetVal, lcTrnsDtl_hor, lcSQL, lcUnique
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- *--- create trans detail horizontal
- lcTrnsDtl_hor = ""
- llRetVal = llRetVal and this.GetHorizontalTransDetail(@lcTrnsDtl_hor)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSQL(@lcSQL,lcTrnsDtl_hor,.cZzoordrd)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderWorkAddress
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- lcSql = ""
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTA ,.cZzoordad,,,,,"h")
- lcSQL = lcSQL + " and h.addr_type = 'OT'"
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTA,.cZzootadr,,,,,"h")
- *--- TechRec 1056973 22-Nov-2011 jisingh ---
- *lcSQL = lcSQL + " and h.addr_type in ('BT','SO') "
- lcSQL = lcSQL + " and h.addr_type not in ('OT') "
- *=== TechRec 1056973 22-Nov-2011 jisingh ===
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- *--- TechRec 1054619 13-Jun-2011 MANI. ---
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeiPOtWHSE,.czzedatawhse,,,,,"h")
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- *=== TechRec 1054619 13-Jun-2011 MANI. ===
- *-TR 1059065 FH
- llRetVal = llRetVal and .UpdateWarehouseSizebucket(.czzedatawhse, .cZzeipoTD)
- llRetVal = llRetVal and .UpdateWarehouseSLNSizebucket(.czzedatawhse, .cZzeipoTS)
- *-TR 1059065 FH
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderWorkComment
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- *--- set line seq for trans comments
- llRetVal = llRetVal and this.SetLineSeqInTransComment()
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTC,.cZzoordcd)
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderHeaderWorkNotes
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH THIS
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,.cZzeipoTh_nt,.cZzoordrh_nt,"'table_name'","table_name","'ZZOORDRH'")
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PopulateOrderDtlWorkNotes
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- *--- First group by field zzoodrd_pkey ( this field currently contain trans detail pkey
- *--- but can be repeated when multiple trans detail line becomes one order detail line )
- LOCAL lcZzeipoTd_nt
- lcZzeipoTd_nt = "#Zzeipoth_nt" + SYS(2015)
- .RegisterTable(lcZzeipoTd_nt)
- llRetVal = llRetVal and this.RollupTransDtlNotes(@lcZzeipoTd_nt)
- llRetVal = llRetVal and this.SetDtlNotesLineSeqFromOrderDtl(lcZzeipoTd_nt)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcSql,lcZzeipoTd_nt,.cZzoordrd_nt,"'TABLE_NAME'","TABLE_NAME","'ZZOORDRD'")
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE RollupTransDtlNotes
- LPARAMETERS pcZzeipotd_nt
- *--- First group by field zzoodrd_pkey ( this field currently contain trans detail pkey
- *--- but can be repeated when multiple trans detail line becomes one order detail line )
- LOCAL llRetVal, lcZzeipotd_nt_cur, lnOldSelect
- lnOldSelect = SELECT()
- lcZzeipotd_nt = IIF(EMPTY(pcZzeipotd_nt),"#zzeipotd_nt" + SYS(2015),pcZzeipotd_nt)
- lcZzeipotd_nt_cur = "Dtl_nt" + SYS(2015)
- llRetVal = .t.
- *--- bring transaction detail notes to client cursor for rollup on order detail line
- lcSql = "select * from " + this.cZzeipotd_nt
- llRetVal = llRetVal and v_sqlexec(lcSql, lcZzeipotd_nt_cur)
- LOCAL lnZzoordrd_pkey, lcNotes, lcZzeipotd_nt_Rolled, lont, lnSeq, lnParentKey, lcNote_type, lontPrev
- lnZzoordrd_pkey = 0
- lcNotes = ""
- lcZzeipotd_nt_Rolled = "Dtl_ntOut" + SYS(2015)
- lnSeq = 0
- lnParentKey = 0
- lcNote_type = ""
- *-- create rolled up holding cursor
- SELECT * FROM (lcZzeipotd_nt_cur) WHERE 1=2 INTO CURSOR (lcZzeipotd_nt_Rolled) readwrite
- IF llRetVal
- SELECT (lcZzeipotd_nt_cur)
- INDEX on STR(zzoordrd_pkey) + note_type tag ord_pkey
- SELECT(lcZzeipotd_nt_cur)
- SCAN
- SCATTER NAME lont memo
- IF lnZzoordrd_pkey = lont.zzoordrd_pkey AND lcNote_Type = lont.Note_Type
- *-TR 1078653 FH - lets check if the note does not exist already (non-opt does this)
- IF Not (lont.notes $ &lcZzeipotd_nt_Rolled..notes )
- replace notes WITH notes + lont.notes IN (lcZzeipotd_nt_Rolled)
- endif
- ELSE
- lnSeq = lnSeq + 1
- lont.Seq = lnSeq
- lont.fkey = lont.zzoordrd_pkey
- SELECT(lcZzeipotd_nt_Rolled)
- APPEND BLANK
- GATHER name lont memo
- ENDIF
- IF lnZzoordrd_pkey <> lont.zzoordrd_pkey
- lnSeq = 0
- ENDIF
- lnZzoordrd_pkey = lont.zzoordrd_pkey
- lcNote_Type = lont.Note_Type
- ENDSCAN
- ENDIF
- *--- send cursor data back to server temp table
- llRetVal = llRetVal and this.oCopyUtil.SendCursorToSqlTbl(lcZzeipotd_nt_Rolled, lcZzeipotd_nt)
- IF EMPTY(pcZzeipotd_nt)
- pcZzeipotd_nt = lcZzeipotd_nt
- ENDIF
- SELECT(lnOldSelect)
- RETURN llRetval
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetDtlNotesLineSeqFromOrderDtl
- LPARAMETERS pcZzeipoTd_nt
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- *--- get the line_seq from the order detail
- lcSql = "Update nt set line_seq = d.line_seq from " + pcZzeipoTd_nt + " nt " + ;
- " inner join " + this.cZzoordrd + " d on d.pkey = nt.fkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetHorizontalTransDetail
- LPARAMETERS pcTrnsDtl_hor
- *--- TechRec 1062694 26-Jul-2012 jjanand === Added lcSelectLst
- LOCAL llRetVal, lcTrnsDtl_hor, lcUnique, lcGrpFlds
- llRetVal = .t.
- lcUnique = SYS(2015)
- lcTrnsDtl_hor = "#zzeipotd_hor" + lcUnique
- lcTrnsDtl_Grp = "#zzeipotd_grp" + lcUnique
- *!* llNewLine = m.Set_ID # lcSet_ID Or;
- *!* llDupeUPCs Or !llMan_bulk_match;
- *!* or lcPreviousPO1_SKU # m.po1_sku;
- *!* or lcPreviousPO1_UPC # m.po1_upc;
- *!* or lnPreviousPrice # m.price;
- *!* or lnPreviousOrg_Price # m.org_price;
- *!* or lcPreviousStyle # m.Style;
- *!* or lcPreviousColor_code # m.color_code;
- *!* or lcPreviousLbl_code # m.lbl_code;
- *!* or lcPreviousDimension # m.Dimension;
- *!* or lcPreviousRng_Style # m.Rng_Style;
- *!* or lcPreviousRng_Color # m.Rng_color;
- *!* or lcPreviousRng_Lbl # m.Rng_Lbl;
- *!* or lcPreviousRng_Pack # m.Rng_pack;
- *!* or lcPreviousStart_Date # Dtos(m.start_date);
- *!* or lcPreviousEnd_Date # Dtos(m.end_date);
- *!* or lcPreviousAssortment # m.Assortment ;
- *!* or (This.lExtD And Empty(m.Set_ID) And Reccount("vzzeIPOTE_FKey")>0);
- *!* or (This.lHaveChrgs And Reccount("vzzeIPOTR_FKey")>0)
- *--- Extender logic - if extender exists for zzeipotd and zzeipotd.Set_id field is blank then it is a new order detail line (per sizebucket)
- *--- - if extender exists for zzeipotd and zzeipotd.Set_id field differ between sizebucket line then it is a new order detail line (per sizebucket)
- *--- - if extender does not exists then ignore this field
- LOCAL lcZzeipotd_OrigSet_id
- llRetVal = llRetVal and this.SetUniqueSet_id(this.cZzeipoTD, @lcZzeipotd_OrigSet_id)
- *--- Multi discount - in group by we need to group by on sac_code, sac_rate
- llRetVal = llRetVal and this.SetSac_IDandRate(this.cZzeipoTD,this.cZzeiPOtsac)
- llRetVal = llRetVal and this.SetDupeUpc(this.cZzeipoTH,this.cZzeipoTD) &&--- TechRec 1063128 04-Sep-2012 jjanand ===
- *--- max group field limit in sql 2005 is 16 fields
- *--- TechRec 1063128 04-Sep-2012 jjanand === Added ,dupeUpcSeq
- lcGrpFlds = "fkey, price, org_price, division, style, color_code, lbl_code, dimension, rng_style" + ;
- ", rng_color, rng_pack, start_date, end_date, Assortment, Set_id, hasCharges, man_bulk, sac_id, sac_rate, dupeUpcSeq "
- lcGrpFlds = STRTRAN(lcGrpFlds, " ", "")
- * --- TR 1044713 01/07/10 CM
- *--- TR 1049551 BR - ADDED price, org_price, hasCharges, man_bulk, sac_id
- *--- TechRec 1063128 04-Sep-2012 jjanand === Added ,dupeUpcSeq
- lcOrderBy = "fkey, division, style, color_code, lbl_code, dimension, rng_style, rng_color, rng_pack" + ;
- ", start_date, end_date, Assortment, Set_id, sac_rate, price, org_price, hasCharges, man_bulk, sac_id, dupeUpcSeq "
- *--- TechRec 1062694 26-Jul-2012 jjanand ---
- *--- TechRec 1063128 04-Sep-2012 jjanand === Added ,dupeUpcSeq
- lcSelectLst = ", division, style, color_code, lbl_code, dimension, rng_style, rng_color, rng_pack" + ;
- ", start_date, end_date, Assortment, Set_id, sac_rate, price, org_price, hasCharges, man_bulk, sac_id, dupeUpcSeq "
- *=== TechRec 1062694 26-Jul-2012 jjanand ===
- lcOrderBy = STRTRAN(lcOrderBy, " ", "")
- * === TR 1043394 01/07/10 CM
- *pcSrcDtl, pcDtl_hor, pcGrpFlds, pcPkeyFld, pcSizebkFld, pcSize_qtyFld, pcTotal_qtyFld
- * --- TR 1043394 01/07/10 CM --- Changed lcGrpFlds to lcOrderBy
- llRetVal = llRetVal and this.oCopyUtil.GetHorizontalDetail(this.cZzeipoTD,lcTrnsDtl_Grp,lcOrderBy,"pkey","sizebucket","total_qty","total_qty")
- lcSql = "select d.*, dg.pkey as zzeipotd_pkey " + ;
- " ,dg.size01_qty,dg.size02_qty,dg.size03_qty,dg.size04_qty,dg.size05_qty,dg.size06_qty,dg.size07_qty,dg.size08_qty,dg.size09_qty,dg.size10_qty " + ;
- " ,dg.size11_qty,dg.size12_qty,dg.size13_qty,dg.size14_qty,dg.size15_qty,dg.size16_qty,dg.size17_qty,dg.size18_qty,dg.size19_qty,dg.size20_qty " + ;
- " ,dg.size21_qty,dg.size22_qty,dg.size23_qty,dg.size24_qty " + ;
- " into " + lcTrnsDtl_hor + ;
- " from " + this.cZzeipoTD + " d inner join " + lcTrnsDtl_Grp + " dg on d.pkey = dg.pkey " + ;
- " order by d.fkey, d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.rng_style, d.start_date "
- llRetval = llRetVal and v_sqlexec(lcSql)
- .RegisterTable(lcTrnsDtl_hor)
- .RegisterTable(lcTrnsDtl_Grp)
- *--- put back original set_id value in trans detail and horizontal trans detail
- llRetVal = llRetVal and this.ResetOriginalSet_id(lcZzeipotd_OrigSet_id,this.cZzeipoTD)
- llRetVal = llRetVal and this.ResetOriginalSet_id(lcZzeipotd_OrigSet_id,lcTrnsDtl_hor)
- *--- update grouped pkey field
- * --- TR 1043394 01/07/10 CM --- Changed lcGrpFlds to lcOrderBy
- llRetVal = llRetVal and this.SetTransDetailNotesLinkFld(lcTrnsDtl_Grp,lcOrderBy)
- *--- UPDATE total qty
- lcSql = "update d set total_qty = dg.total_qty from " + lcTrnsDtl_hor + " d inner join " + lcTrnsDtl_Grp + " dg on d.pkey = dg.pkey "
- llRetval = llRetVal and v_sqlexec(lcSql)
- * --- TR 1043394 01/07/10 CM
- *llRetVal = llRetVal and this.oCopyUtil.SetLineSeq(lcTrnsDtl_hor, "line_seq", "fkey", "fkey, pkey", "d", "")
- *--- TechRec 1058326 15-Dec-2011 jisingh Added STRTRAN with lcOrderBy (Existing Issue) ===
- *--- TechRec 1062694 26-Jul-2012 jjanand ==== Added lcSelectLst and set paramater plUseRowNum to .T.
- llRetVal = llRetVal and this.oCopyUtil.SetLineSeq(lcTrnsDtl_hor, "line_seq", "fkey", "fkey, pkey" + lcSelectLst, "d", "", .F., STRTRAN(lcOrderBy,"fkey","d.fkey"),.T.)
- * === TR 1043394 01/07/10 CM
- pcTrnsDtl_hor = lcTrnsDtl_hor
- *- 1041844 YIK 08/04/09
- *- Assign Line sequence to this.cZzeipoTD
- *- Use set of fields from original 850 to determine detail break
- *-- lcipotd_temp = '#impotd_temp' + lcUnique
- *-- lcSQL = 'Select * into ' + lcipotd_temp + ' from ' + this.cZzeipoTD + ;
- *-- " order by fkey, division, style, color_code, lbl_code, dimension, rng_style, start_date "
- *-- llRetval = llRetVal and v_sqlexec(lcSql)
- *--- TR 1052428 1-Nov-2011 Goutam. Order by must be same to create line seq for transaction detail table and order detail table. Commented following line.
- * lcOrderBy = 'd.fkey, d.division, d.style, d.color_code, d.lbl_code, d.dimension, d.rng_style, d.start_date'
- *=== TR 1052428 1-Nov-2011 Goutam
- *- added parameter to select distinct and order by (= .T.)
- *--- TechRec 1058326 15-Dec-2011 jisingh Added STRTRAN with lcOrderBy (Existing Issue) ===
- *--- TechRec 1061494 18-May-2012 jjanand === set paramater plUseRowNum to .T.
- llRetVal = llRetVal and this.oCopyUtil.SetLineSeq(this.cZzeipoTD, "line_seq", "fkey", lcGrpFlds, "d", "", .T., STRTRAN(lcOrderBy,"fkey","d.fkey"),.T.)
- llRetval = llRetVal and v_sqlexec(lcSql)
- *===
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetTransDetailNotesLinkFld
- LPARAMETERS pcTrnsDtl_Grp,pcGrpFlds
- LOCAL llRetVal, lcTrnsDtl_Grp,lcGrpFlds
- llRetVal = .t.
- lcTrnsDtl_Grp = pcTrnsDtl_Grp
- lcGrpFlds = pcGrpFlds
- dimension laFlds[1]
- LOCAL lnIndex, lcJoin, lcFld
- lcJoin = ""
- this.oCopyUtil.StringToArray(lcGrpFlds,@laFlds)
- FOR lnIndex = 1 TO ALEN(laFlds)
- lcFld = laFlds[lnIndex]
- lcJoin = lcJoin + " d." + lcFld + " = g." + lcFld + " and "
- ENDFOR
- lcJoin = this.oCopyUtil.RemoveLastChar(lcJoin, " and")
- lcSql = " update d Set zzoordrd_pkey = g.pkey from " + this.cZzeipoTD + " d inner join " + lcTrnsDtl_Grp + " g " + ;
- " on " + lcJoin
- llRetval = llRetVal and v_sqlexec(lcSql)
- *--- update link pkey field in transaction detail notes
- lcSql = " update dnt Set zzoordrd_pkey = d.zzoordrd_pkey from " + this.cZzeipoTD + " d inner join " + this.cZzeipoTD_nt + " dnt " + ;
- " on d.pkey = dnt.fkey "
- llRetval = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *--- TechRec 1063128 04-Sep-2012 jjanand ---
- PROCEDURE SetDupeUpc
- LPARAMETERS pcZzeipoTH, pcZzeipoTD
- LOCAL llRetVal, lcSql
- llRetVal = .T.
- lcSql = " alter table " + pcZzeipoTD + " add dupe_upc char(1) not null default('N')"
- llRetval = llRetVal and v_sqlexec(lcSql)
- lcSql = " alter table " + pcZzeipoTD + " add dupeUpcSeq int not null default(0)"
- llRetval = llRetVal and v_sqlexec(lcSql)
- lcSql = " Update d Set dupe_upc = h. dupe_upc From " + pcZzeipoTH + " h join " + pcZzeipoTD + " d on d.fkey = h.pkey "
- llRetval = llRetVal and v_sqlexec(lcSql)
- lcSql = " Update " + pcZzeipoTD + " set dupeUpcSeq = case when dupe_upc = 'Y' then line_Seq else 0 end"
- llRetval = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *=== TechRec 1063128 04-Sep-2012 jjanand ===
- PROCEDURE PopulateOrderWorkSp
- LOCAL llRetVal, lcSql
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- llRetVal = .t.
- WITH this
- lcFlds = ""
- lcValues = ""
- lcExcludeFlds = ""
- lcCalFlds = ""
- lcCalFldsValues = ""
- llRetVal = llRetVal And .oCopyUtil.GetFldsValues(@lcFlds, @lcValues, .cZzoordsp, .cZzoordrh , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'h')
- lcSql = " INSERT INTO " + .cZzoordsp + " ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + .cZzoordrh + " h "
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- llRetVal = llRetVal and this.SetPkey(.cZzoordsp,"ZZOORDSP")
- lcSql = "Update sp SET cartons = 'N', carton_seq = 0, carton_cls = 'S', packs = 'N' from " + .cZzoordsp + " sp "
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareOrderForUpdate
- LOCAL llRetVal
- llRetVal = .t.
- this.LogEntry("Setting Pkey for all tables...")
- *--- set new pkey for order header
- llRetVal = llRetVal and this.SetPkey_OrderHeader()
- *--- set new order number
- llRetVal = llRetVal and this.SetOrderNumber()
- *--- set registration
- llRetVal = llRetval and this.SetRegistrationNumber()
- *--- set new pkey for order detail
- llRetVal = llRetVal and this.SetPkey_OrderDetail()
- llRetVal = llRetVal and this.SetPkey(this.cZzoordad,'ZZOORDAD')
- llRetVal = llRetVal and this.SetPkey(this.cZzootadr,'ZZOOTADR')
- llRetVal = llRetVal and this.SetPkey(this.cZzoordcd,'ZZOORDCD')
- llRetVal = llRetVal and this.SetPkey(this.cZzoordrh_nt,'sysnotes')
- llRetVal = llRetVal and this.SetPkey(this.cZzoordrd_nt,'sysnotes')
- llRetVal = llRetVal and this.SetPkey(this.cZzoordsac,'Zzoordsac')
- llRetVal = llRetVal and this.SetPkey(this.cZzoordrd_chrg,'zzxchrds')
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- llRetVal = llRetVal and this.SetPkey(this.czzedatawhse,'ZZEDATAWHSE')
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- .LogEntry("Setting Pkey for all Tables " + IIF(llRetVal,"completed.","failed."))
- llRetVal = llRetVal and this.PrepareDataAfter_OrderHeader()
- llRetVal = llRetVal and this.PrepareDataAfter_OrderDetail()
- ASSERT .f.
- llRetVal = llRetVal and this.PopulateOrderWorkSp()
- llRetVal = llRetVal and this.PrepareOrderExtender()
- llRetVal = llRetVal and this.PrepareOrderDiscount()
- *--- TR 1044208 Used object obulkmatch amd obulk instead of variable. puts us in better control of destroying it.
- *LOCAL loEdiBulkMatch
- *llRetval = llRetVal and this.GetInstance_EDIBulkMatching(@loEdiBulkMatch)
- llRetVal = llRetVal and .oBulkMatch.RegisterFinalOrdTbls(this.cZzoordrh,this.cZzoordrd)
- llRetVal = llRetVal and .oBulkMatch.RegisterBulkCursor("tcBulkMatch")
- llRetVal = llRetVal and .oBulkMatch.RegisterCreateOrderObject(this)
- llRetVal = llRetVal and .oBulkMatch.PrepareBulkMatch()
- *LOCAL loBulkNibbler
- *llRetVal = llRetVal and this.GetInstance_BulkNibbler(@loBulkNibbler)
- llRetVal = llRetVal and .oBulk.RegisterOrdTbls(this.cZzoordrh,this.cZzoordrd)
- llRetVal = llRetVal and .oBulk.CreateNibblerQueuesForAddMode()
- *=== TR 1044208 Used object obulkmatch amd obulk instead of variable. puts us in better control of destroying it.
- llRetVal = llRetVal and this.SetUserIdAndTimeStampForAllTbls()
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetUserIdAndTimeStampForAllTbls
- LOCAL llRetVal
- llRetVal = .t.
- WITH this
- LOCAL lnIndex
- FOR lnIndex = 1 TO .nOrdTbls
- llRetVal = llRetVal and this.SetUserIdAndTimeStamp(.aOrdTbls[lnIndex])
- ENDFOR
- ENDWITH
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetUserIdAndTimeStamp(pcTbl)
- Local llRetVal, lcSQL
- llRetVal = .T.
- lcSQL = "UPDATE h SET last_mod = convert(datetime,convert(char,getdate(),120))," + ;
- " user_id = '" + goEnv.cUser + "' FROM " + pcTbl + " h "
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetPkey_OrderDetail
- LOCAL llRetVal, lnOldSelect
- llRetVal = .t.
- lnOldSelect = SELECT()
- DECLARE laOrdDtls[3,4]
- laOrdDtls[1,1] = this.cZzoordrd_nt
- laOrdDtls[1,2] = "fkey" && update field of detail table
- laOrdDtls[1,3] = "fkey" && relation field of Detail table
- laOrdDtls[1,4] = "pkey" && relation field of Header table
- laOrdDtls[2,1] = this.cZzoordrd_chrg
- laOrdDtls[2,2] = "fkey" && update field of detail table
- laOrdDtls[2,3] = "fkey" && relation field of Detail table
- laOrdDtls[2,4] = "pkey" && relation field of Header table
- *--- multi discount
- laOrdDtls[3,1] = this.cZzoordsac
- laOrdDtls[3,2] = "dFkey" && update field of detail table
- laOrdDtls[3,3] = "dFkey" && relation field of Detail table
- laOrdDtls[3,4] = "pkey" && relation field of Header table
- lcSQL = "SELECT count(*) newCount from " + this.cZzoordrd
- llRetVal = llRetVal and v_sqlexec(lcSQL,"HdrRecord")
- IF llRetVal AND HdrRecord.newCount > 0
- lnMaxPkey = v_nextPkey("ZZOORDRD",HdrRecord.newCount)
- llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzoordrd,"pkey",@laOrdDtls,lnMaxPkey,HdrRecord.newCount,;
- "pkey_I")
- ENDIF
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE CreateFrmCode
- LOCAL llRetVal
- llRetVal = .t.
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetPkey_OrderHeader
- Local llRetVal, lnOldSelect,lcUnique, lcSQL
- llRetVal = .T.
- lnOldSelect = Select()
- DECLARE laOrdDtls[10,4] &&--- TechRec 1054619 09-Jun-2011 MANI. Changed from 9 to 10 ===
- laOrdDtls[1,1] = this.cZzoordrd
- laOrdDtls[1,2] = "fkey" && update field of detail table
- laOrdDtls[1,3] = "fkey" && relation field of Detail table
- laOrdDtls[1,4] = "pkey" && relation field of Header table
- *--- one time address
- laOrdDtls[2,1] = this.cZzoordad
- laOrdDtls[2,2] = "fkey" && update field of detail table
- laOrdDtls[2,3] = "fkey" && relation field of Detail table
- laOrdDtls[2,4] = "pkey" && relation field of Header table
- laOrdDtls[3,1] = this.cZzootadr
- laOrdDtls[3,2] = "fkey" && update field of detail table
- laOrdDtls[3,3] = "fkey" && relation field of Detail table
- laOrdDtls[3,4] = "pkey" && relation field of Header table
- laOrdDtls[4,1] = this.cZzootadr
- laOrdDtls[4,2] = "fkey" && update field of detail table
- laOrdDtls[4,3] = "fkey" && relation field of Detail table
- laOrdDtls[4,4] = "pkey" && relation field of Header table
- laOrdDtls[5,1] = this.cZzoordcd
- laOrdDtls[5,2] = "fkey" && update field of detail table
- laOrdDtls[5,3] = "fkey" && relation field of Detail table
- laOrdDtls[5,4] = "pkey" && relation field of Header table
- laOrdDtls[6,1] = this.cZzoordrh_nt
- laOrdDtls[6,2] = "fkey" && update field of detail table
- laOrdDtls[6,3] = "fkey" && relation field of Detail table
- laOrdDtls[6,4] = "pkey" && relation field of Header table
- *--- detail notes
- laOrdDtls[7,1] = this.cZzoordrd_nt
- laOrdDtls[7,2] = "Parentkey" && update field of detail table
- laOrdDtls[7,3] = "Parentkey" && relation field of Detail table
- laOrdDtls[7,4] = "pkey" && relation field of Header table
- *--- detail charges
- laOrdDtls[8,1] = this.cZzoordrd_chrg
- laOrdDtls[8,2] = "hdrFkey" && update field of detail table
- laOrdDtls[8,3] = "hdrFkey" && relation field of Detail table
- laOrdDtls[8,4] = "pkey" && relation field of Header table
- *--- multi discount
- laOrdDtls[9,1] = this.cZzoordsac
- laOrdDtls[9,2] = "hFkey" && update field of detail table
- laOrdDtls[9,3] = "hFkey" && relation field of Detail table
- laOrdDtls[9,4] = "pkey" && relation field of Header table
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- *--- data Warehouse
- laOrdDtls[10,1] = this.czzedatawhse
- laOrdDtls[10,2] = "Hfkey" && update field of detail table
- laOrdDtls[10,3] = "Hfkey" && relation field of Detail table
- laOrdDtls[10,4] = "pkey" && relation field of Header table
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- lcSQL = "SELECT count(*) newCount from " + this.cZzoordrh
- llRetVal = llRetVal and v_sqlexec(lcSQL,"HdrRecord")
- IF llRetVal AND HdrRecord.newCount > 0
- lnMaxPkey = v_nextPkey("ZZOORDRH",HdrRecord.newCount)
- llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzoordrh,"pkey",@laOrdDtls,lnMaxPkey,HdrRecord.newCount,;
- "pkey_I")
- ENDIF
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetOrderNumber
- Local llRetVal, lnOldSelect,lcUnique, lcSQL, lnNewOrdCount
- llRetVal = .T.
- lnOldSelect = Select()
- lnNewOrdCount = 0
- lcSQL = " select COUNT(*) as NewOrderCount FROM " + this.cZzoordrh + " h "
- llRetVal = llRetVal and v_sqlexec(lcSQL,"NewOrderCount")
- IF USED("NewOrderCount")
- lnNewOrdCount = NewOrderCount.NewOrderCount
- USE IN NewOrderCount
- ENDIF
- IF NOT (llRetVal AND lnNewOrdCount > 0)
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDIF
- *--- update order number in order detail
- DECLARE laOrdDtls[12,4] &&--- TechRec 1054619 09-Jun-2011 MANI. Changed from 11 to 12 ===
- laOrdDtls[1,1] = this.cZzoordrd
- laOrdDtls[1,2] = "ord_num" && update field of detail table
- laOrdDtls[1,3] = "fkey" && relation field of Detail table
- laOrdDtls[1,4] = "pkey" && relation field of Header table
- *--- update order number in transaction header
- laOrdDtls[2,1] = this.cZzeipoTH
- laOrdDtls[2,2] = "ord_num" && update field of detail table
- laOrdDtls[2,3] = "pkey" && relation field of Detail table
- laOrdDtls[2,4] = "zzeipoth_pkey" && relation field of Header table
- *--- update order number in transaction detail
- laOrdDtls[3,1] = this.cZzeipoTD
- laOrdDtls[3,2] = "ord_num" && update field of detail table
- laOrdDtls[3,3] = "fkey" && relation field of Detail table
- laOrdDtls[3,4] = "zzeipoth_pkey" && relation field of Header table
- *--- update order number for one time address
- laOrdDtls[4,1] = this.cZzoordad
- laOrdDtls[4,2] = "ord_num" && update field of detail table
- laOrdDtls[4,3] = "fkey" && relation field of Detail table
- laOrdDtls[4,4] = "pkey" && relation field of Header table
- laOrdDtls[5,1] = this.cZzootadr
- laOrdDtls[5,2] = "ord_num" && update field of detail table
- laOrdDtls[5,3] = "fkey" && relation field of Detail table
- laOrdDtls[5,4] = "pkey" && relation field of Header table
- *--- update order number in comment
- laOrdDtls[6,1] = this.cZzoordcd
- laOrdDtls[6,2] = "ord_num" && update field of detail table
- laOrdDtls[6,3] = "fkey" && relation field of Detail table
- laOrdDtls[6,4] = "pkey" && relation field of Header table
- laOrdDtls[7,1] = this.cZzoordrh_nt
- laOrdDtls[7,2] = "ord_num" && update field of detail table
- laOrdDtls[7,3] = "fkey" && relation field of Detail table
- laOrdDtls[7,4] = "pkey" && relation field of Header table
- laOrdDtls[8,1] = this.cZzoordrd_nt
- laOrdDtls[8,2] = "ord_num" && update field of detail table
- laOrdDtls[8,3] = "parentkey" && relation field of Detail table
- laOrdDtls[8,4] = "pkey" && relation field of Header table
- laOrdDtls[9,1] = this.cZzoordrd_chrg
- laOrdDtls[9,2] = "ord_num" && update field of detail table
- laOrdDtls[9,3] = "hdrfkey" && relation field of Detail table
- laOrdDtls[9,4] = "pkey" && relation field of Header table
- *--- multi discount
- laOrdDtls[10,1] = this.cZzoordsac
- laOrdDtls[10,2] = "ord_num" && update field of detail table
- laOrdDtls[10,3] = "hFkey" && relation field of Detail table
- laOrdDtls[10,4] = "pkey" && relation field of Header table
- *--- multi discount
- laOrdDtls[11,1] = this.cZzeipoTS
- laOrdDtls[11,2] = "ord_num" && update field of detail table
- laOrdDtls[11,3] = "hFkey" && relation field of Detail table
- laOrdDtls[11,4] = "pkey" && relation field of Header table
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- *--- update order number for ware house
- laOrdDtls[12,1] = this.czzedatawhse
- laOrdDtls[12,2] = "ord_num" && update field of detail table
- laOrdDtls[12,3] = "Hfkey" && relation field of Detail table
- laOrdDtls[12,4] = "pkey" && relation field of Header table
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- *--- Set ord_num to new order header
- lnMaxOrd_num = v_NextId('ZZXCOMPR','ORD_NUM', lnNewOrdCount)
- llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzoordrh,"ord_num",@laOrdDtls,lnMaxOrd_num,lnNewOrdCount,;
- "Ord_Num_I")
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareDataAfter_OrderHeader
- Local llRetVal, lnOldSelect, lcSQL, lcAssign
- llRetVal = .T.
- lnOldSelect = Select()
- llRetVal = llRetval and this.SetDefaultDate_OrderHeader()
- llRetVal = llRetVal and this.ClearShippingFields(this.cZzoordrh)
- * TR 1050538 FH 11/10/10 - UpdateTerms
- llRetVal = llRetVal and this.UpdateTerms(this.cZzoordrh,this.cZzeipoTH, this.cZzeipoCr)
- *--- set order status
- lcAssign = ""
- lcAssign = lcAssign + ",ack_prn = 'N'"
- lcAssign = lcAssign + ",AR_POST = 'N'"
- lcAssign = lcAssign + ",bulk_red = 'Y'"
- lcAssign = lcAssign + ",ENT_USER = '" + EDI_USER + "'"
- lcAssign = lcAssign + ",Bulk_num = case when h.Conf_type = 'B' THEN h.Ord_num ELSE h.Bulk_num End"
- *--- TR 1075041 9-12-2013 VKK
- lcAssign = lcAssign + ",fappv_amt = case when h.factor like 'CC_%' THEN " + ;
- " Coalesce((Select Top 1 ChargeAmt From " + this.czzeipoth + " where pkey = h.zzeipoth_pkey), 0) ELSE h.fappv_amt End"
- lcAssign = lcAssign + ",fexpn_date = case when h.factor like 'CC_%' THEN h.ftran_date + h.facExpir_days ELSE h.fexpn_date End"
- *=== TR 1075041 9-12-2013 VKK
- lcSql = "Update h Set ord_status = 'O'" + lcAssign + ;
- " from " + this.cZzoordrh + " h "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- llRetVal = llRetVal and this.SetDefaultsFromCustomerMaster()
- *--- TechRec 1048804 23-Aug-2010 TShenbagavalli ---
- llRetVal = llRetVal and this.SetSpsBillOptn()
- *=== TechRec 1048804 23-Aug-2010 TShenbagavalli ===
- *--- Set hasnotes field
- lcSql = "Update h Set hasnotes = case when hn.pkey is null then 'N' else 'Y' END from " +;
- this.cZzoordrh + " h left outer join " + this.cZzoordrh_nt + " hn " + ;
- " on hn.ord_num = h.ord_num and hn.Table_name = 'ZZOORDRH'"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("Prepare Order Header " + IIF(llRetVal,"completed.","failed."))
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *--------------------------------------------------------------------------
- * TR 1050538 FH 11/10/10 - Update terms to be org_terms if control ref, has term_deft=E and accept_TCode <> Y
- PROCEDURE UpdateTerms
- LPARAMETERS pcOrderTbl, pcTranTbl, pcControlTbl
- LOCAL lcTerms, lcUnique, lcZzeIPOcr, lcSql, llRetVal
- llRetVal = .T.
- lcSql = "update h "+;
- " set terms = t.org_terms "+;
- " from " + pcOrderTbl + " h"+;
- " join " + pcTranTbl + " t "+;
- " on h.ord_num = t.ord_num"+;
- " join " + pcControlTbl+ " c "+;
- " on c.customer = h.customer "+;
- " and c.division = h.division "+;
- " where c.term_deft = 'E' "+;
- " and c.accept_TCode <> 'Y' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetDefaultDate_OrderHeader
- LOCAL llRetVal, lcSql, lcDefaultDate, lcCurDate
- llRetVal = .t.
- lcDefaultDate = SQLFormatTS({//})
- lcCurDate = SQLFormatTS(TTOD(ServerDatetime()))
- *--- TR 1071867 06/24/13 ATHIRUNAVU Set default date for isr_Start_date
- lcSql = "Update h Set Act_ship_date = " + lcDefaultDate + ;
- ", FEXPN_DATE = " + lcDefaultDate + ;
- ", ISSUE_DATE = " + lcDefaultDate + ;
- ", POST_DATE = " + lcDefaultDate + ;
- ", ROUT_OBT_DATE = " + lcDefaultDate + ;
- ", ROUT_REQ_DATE = " + lcDefaultDate + ;
- ", SENT_856 = " + lcDefaultDate + ;
- ", TRANS_DATE = " + lcDefaultDate + ;
- ", ENT_DATE = " + lcCurDate + ;
- ", ISR_START_DATE = " + lcDefaultDate + ;
- " FROM " + this.cZzoordrh + " h "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetDefaultsFromCustomerMaster
- LOCAL llRetVal, lcSql, lcAssign
- llRetVal = .t.
- *--- take any value came through 850 flat file first, only if that is empty then take exempted flag from customer
- lcAssign = ", tax_empt = case when h.tax_empt = '' then r.tax_empt else h.tax_empt end"
- *--- original TR 1029370 - PopulateBkordInvAlloc("Vzzoordrh_iPOproc")
- lcAssign = lcAssign + ",Invc_Bkord_Cncl = r.Invc_Bkord_Cncl"
- lcAssign = lcAssign + ",Invc_Cncl_Type = r.Invc_Cncl_Type"
- lcAssign = lcAssign + ",Invc_Cncl_Rsn = r.Invc_Cncl_Rsn"
- lcAssign = lcAssign + ",Alc_Bkord_Cncl = r.Alc_Bkord_Cncl"
- lcAssign = lcAssign + ",Alc_Cncl_Type = r.Alc_Cncl_Type"
- lcAssign = lcAssign + ",Alc_Cncl_Rsn = r.Alc_Cncl_Rsn"
- * TR 1070508- only stamp org code if it is empty on source table
- lcSql = "Update h Set org_code = CASE WHEN h.org_code = '' THEN r.org_code ELSE h.org_code END " + lcAssign + " from " + this.cZzoordrh + " h inner join zzxcustr r (nolock) " + ;
- " on h.customer = r.customer where r.active_ok = 'Y' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareDataAfter_OrderDetail
- Local llRetVal, lnOldSelect, lcSQL
- llRetVal = .T.
- lnOldSelect = Select()
- *--- update on hasnotes field
- lcSql = " update d Set hasnotes = case when n.pkey is null then 'N' ELSE 'Y' end from " + this.cZzoordrd + " d " + ;
- " left outer join " + this.cZzoordrd_nt + " n on n.ord_num = d.ord_num and n.line_seq = d.line_seq "
- llRetVal = llRetVal and V_sqlexec(lcSql)
- llRetval = llRetVal and this.SetOrderDtlLot()
- llRetVal = llRetVal and this.SetDefaultDate_OrderDetail()
- *--- cascade fields from order header to detail
- llRetVal = llRetval and this.CascadeFldsHdrToDtl()
- llRetVal = llRetVal and this.SetDefault_OrderDetail()
- *--- update order header with detail fields
- llRetVal = llRetval and this.UpdateHdrFromDtl()
- this.LogEntry("Prepare Order Detail " + IIF(llRetVal,"completed.","failed."))
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *---------------------------------------------------------------------------
- PROCEDURE SetDefault_OrderDetail
- LOCAL llRetVal, lcSql, lcAssign
- llRetVal = .t.
- lcAssign = "price = case when r.price_flg = 'E' then d.org_price else d.price end "
- lcSql = "Update d Set " + lcAssign + " from " + this.cZzoordrd + " d inner join " + ;
- this.cZzoordrh + " h on h.pkey = d.fkey " + ;
- " inner join zzeipocr r on r.customer = h.customer and r.division = d.division "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *!* Select (pceipoTD)
- *!* lnPrice= Iif(tceIPOcr.price_flg = "E", org_price, price)
- *!* *=
- *!* * --- 1009014 02/05 CB - Resolve the merchandise code on the sales order detail table:
- *!* If This.lResl_Mchm
- *!* lnSelect = Select()
- *!* lcSQLString = ;
- *!* "SELECT Merch_Code FROM zzxmchmr " + ;
- *!* " WHERE " + SQLFormatTS(&pceipoTD..start_date) + ;
- *!* " BETWEEN From_Date AND To_Date"
- *!* llRetVal = llRetVal And v_sqlExec(lcSQLString, "tcMerchResl")
- *!* If Used("tcMerchResl") And Reccount("tcMerchResl") > 0
- *!* Replace Merch_Code With tcMerchResl.Merch_Code In (tcOrderDetail)
- *!* Endif
- *!* Use In Select("tcMerchResl")
- *!* Select (lnSelect)
- *!* Endif
- lcSql = "Update d Set Merch_code = r.Merch_Code from " + this.cZzoordrd + " d inner join " + ;
- " zzxmchmr r on d.start_date between r.from_date and r.to_date"
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *!* * --- 1009844 05/05 CB - Moved the following code to clsSlsDf:
- *!* *!* * --- 1009014 02/05 CB - Resolves the Delivery Code from the Season table.
- *!* *--- TAN 37141 02/14/03 PL & HH - Modify the automated bulk order reduction logic
- *!* * to allow for correct matching of distro orders
- *!* Replace fkey With lnCurrOrderHeaderPkey,; && ord_num with tnOrd_num,
- *!* total_qty With 0, price With lnPrice,; &¬ proper price in transdetail
- *!* line_seq With lnLine_seq, ; &¬ proper line_seq when explode range style
- *!* line_status With "O", ;
- *!* bulk_red With "Y" In (tcOrderDetail) && , notes with lcNotes
- *=== TAN 37141 02/14/03
- *--- TR 1034971 29-Sep-2008 Partha ---
- *!* Replace STAGE_UD WITH IIF(EMPTY(lcSTAGE_UD), lcShpst_Code, lcStage_UD) ;
- *!* In (tcOrderDetail)
- Return llRetVal
- ENDPROC
- *---------------------------------------------------------------------------
- PROCEDURE SetOrderDtlLot
- LOCAL llRetVal, lcSql, llFill_lot
- llRetval = .t.
- IF PEMSTATUS(this.oHostProcess,"lFill_Lot",5)
- llFill_lot = this.oHostProcess.lFill_Lot
- ELSE
- llFill_Lot = goEnv.SV("850_FILL_LOT", "N") = 'Y'
- ENDIF
- *!* If This.lFill_Lot And !Empty(m.UDFOORDD6C)
- *!* m.Lot = Transform(tnOrd_num, "@L 9999999") +;
- *!* Transform(lnLine_seq, "@L 999")
- *!* Endif
- IF llFill_Lot
- lcSql = " Update d Set lot = a.lot from " + this.cZzoordrd + " d " + ;
- " inner join ( " + ;
- " select pkey, stuff('0000000',7 - len(ord_num) + 1,len(ord_num), ord_num) + " + ;
- " stuff('000', 3 - len(line_seq) + 1, len(line_seq), line_seq) as lot " + ;
- " from ( select pkey, left(ltrim(str(ord_num)),7) ord_num, left(ltrim(str(line_seq)),3) line_seq " + ;
- " from " + this.cZzoordrd + " where UDFOORDD6C > '' ) a ) a " + ;
- " on a.pkey = d.pkey " + ;
- " where d.UDFOORDD6C > '' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- ENDIF
- Return llRetVal
- ENDPROC
- *---------------------------------------------------------------------------
- PROCEDURE CascadeFldsHdrToDtl
- Local llRetVal, lnOldSelect, lcSQL, lcAssign, lcfac
- llRetVal = .T.
- lnOldSelect = Select()
- LOCAL lcOrderDtl
- lcOrderDtl = "tcOrdDtl" + SYS(2015)
- lcSql = " select * from " + this.cZzoordrd + " where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderDtl)
- LOCAL lcFlds
- DIMENSION laFlds[1]
- AFIELDS(laFlds,lcOrderDtl)
- lcDeli = ","
- lcFlds = this.GetFldList(@laFlds,lcDeli)
- lcAssign = " "
- lcAssign = lcAssign + ",discount = case when d.discount > ' ' then d.discount else h.discount end "
- lcAssign = lcAssign + ",bulk_red = h.bulk_red "
- lcfac = ",facclient_num = h.facclient_num,facExpir_basis = h.facExpir_basis,facExpir_days = h.facExpir_days" + ;
- ",fact_Bulk = h.fact_Bulk, fact_status = h.fact_status, factor = h.factor, factor_ok = h.factor_ok " && TR 1061569 FH - added factor, factor_ok
- lcAssign = lcAssign + lcfac
- lcAssign = lcAssign + ",location = case when d.location > ' ' then d.location else h.location end "
- * --- TR 1040687 6/3/09 CM --- Added hold_rsn,priority, Also Added Slsperson 1-4 and Commission 1-4
- *lcAssign = lcAssign + ",hold_code = h.hold_code"
- *--- TR 1076947 16-May-2014 BNarayanan cascade only when column is empty ---
- *lcAssign = lcAssign + ",hold_code = h.hold_code,hold_rsn = h.hold_rsn,priority = h.priority"
- *lcAssign = lcAssign + ",Slsperson1 = h.Slsperson1,Slsperson2 = h.Slsperson2,Slsperson3 = h.Slsperson3,Slsperson4 = h.Slsperson4"
- *lcAssign = lcAssign + ",Comm1 = h.Comm1,Comm2 = h.Comm2,Comm3 = h.Comm3,Comm4 = h.Comm4"
- lcAssign = lcAssign + ",hold_code = h.hold_code,hold_rsn = h.hold_rsn"
- lcAssign = lcAssign + ",priority = case when d.priority > ' ' then d.priority else h.priority end "
- lcAssign = lcAssign + ",Slsperson1 = case when d.Slsperson1 > ' ' then d.Slsperson1 else h.Slsperson1 end"
- lcAssign = lcAssign + ",Slsperson2 = case when d.Slsperson2 > ' ' then d.Slsperson2 else h.Slsperson2 end"
- lcAssign = lcAssign + ",Slsperson3 = case when d.Slsperson3 > ' ' then d.Slsperson3 else h.Slsperson3 end"
- lcAssign = lcAssign + ",Slsperson4 = case when d.Slsperson4 > ' ' then d.Slsperson4 else h.Slsperson4 end"
- lcAssign = lcAssign + ",Comm1 = case when d.Comm1 > ' ' then d.Comm1 else h.Comm1 end"
- lcAssign = lcAssign + ",Comm2 = case when d.Comm2 > ' ' then d.Comm2 else h.Comm2 end"
- lcAssign = lcAssign + ",Comm3 = case when d.Comm3 > ' ' then d.Comm3 else h.Comm3 end"
- lcAssign = lcAssign + ",Comm4 = case when d.Comm4 > ' ' then d.Comm4 else h.Comm4 end"
- *=== TR 1076947 16-May-2014 BNarayanan ===
- * === TR 1040687 6/3/09 CM
- lcAssign = lcAssign + ",FTRAN_DATE = h.FTRAN_DATE"
- *!* Replace ord_num With tnOrd_num,; && make it to live/hist-detail.
- *!* bulk_num With Iif(&pceipoTH..conf_type= "B" ,tnOrd_num, 0), ;
- *!* comm_calc WITH 'N' ;
- *!* IN (pceipoTD)
- *--- TR 1077221 03/18/14 ATHIRUNAVU Populated PRI_DATE from header if it is empty
- lcAssign = lcAssign + ",PRI_DATE = case when d.PRI_DATE > {ts '1900-01-01 00:00:00' } then d.PRI_DATE else h.PRI_DATE end "
- *=== TR 1077221 03/18/14 ATHIRUNAVU
- lcAssign = lcAssign + ",ord_num = h.ord_num "
- lcAssign = lcAssign + ",bulk_num = case when h.conf_type = 'B' then h.ord_num else 0 end "
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "comm_calc","'N'",",")
- *--- cascaded fields - should we take it from short builder
- LOCAL lcCasacade
- this.oCopyUtil.GetCascadedAssignsql(@lcCasacade, this.cZzoordrh, this.cZzoordrd, "_CASCADED",'h')
- lcAssign = lcAssign + "," + lcCasacade
- lcSql = "Update d set line_status = h.ord_status " + lcAssign + " from " + this.cZzoordrd + ;
- " d inner join " + this.cZzoordrh + " h on h.pkey = d.fkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *--- TR 1074921 9-JUN-14 Venuk
- lcSql = "Update d set orig_ord_type = h.ord_type from " + this.cZzoordrd + ;
- " d inner join " + this.cZzoordrh + " h on h.pkey = d.fkey " + ;
- " join zzocntrc c on h.division = c.division and c.dtl_ord_type_edit ='Y' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TR 1074921 9-JUN-14 Venuk
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE UpdateHdrFromDtl
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- lcSql = " Update h Set ord_qty = d.ord_qty, next_line = d.next_line + 1 from " + this.cZzoordrh + " h inner join " + ;
- " (select di.fkey, SUM(di.total_qty) as ord_qty, MAX(line_seq) as next_line from " + this.cZzoordrd + ;
- " di group by di.fkey) d on h.pkey = d.fkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetRegistrationNumber
- Local llRetVal, lnOldSelect, lcSQL, lnNewOrdCount
- llRetVal = .T.
- lnOldSelect = Select()
- *- FH 1060901 - rewrite how to set registaration number.
- LOCAL lcUnique, lcTempGroupByPo
- lcUnique = SYS(2015)
- lcTempGroupByPo = "#zzoordrh_GroupByPo" + lcUnique
- lcSQL = "SELECT DISTINCT PO_NUM into " + lcTempGroupByPo + " from " + this.cZzoordrh + " WHERE REG_NUM = 0 ORDER BY PO_NUM"
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- this.oCopyUtil.AddIdentityColumn(lcTempGroupByPo, "Po_Num_I")
- lnNewOrdCount = 0
- lcSQL = " select COUNT(*) as NewOrderCount FROM " + lcTempGroupByPo + " h "
- llRetVal = llRetVal and v_sqlexec(lcSQL,"NewOrderCount")
- IF USED("NewOrderCount")
- lnNewOrdCount = NewOrderCount.NewOrderCount
- USE IN NewOrderCount
- ENDIF
- IF NOT (llRetVal AND lnNewOrdCount > 0)
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDIF
- LOCAL lnMaxReg_num, lnStartNum
- lnMaxReg_num = v_NextID('ZZXCOMPR', "REG_NUM", lnNewOrdCount)
- lnStartNum = lnMaxReg_num - lnNewOrdCount
- lcSQL = "UPDATE H SET REG_NUM = D.PO_NUM_I + " + STR(LNSTARTNUM) + ;
- " FROM " + this.cZzoordrh + " H "+ ;
- " JOIN " + lcTempGroupByPo + " D "+;
- " ON D.PO_NUM = H.PO_NUM " +;
- " WHERE H.REG_NUM = 0 "
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- *-update this table as well
- lcSQL = "UPDATE H SET REG_NUM = D.PO_NUM_I + " + STR(LNSTARTNUM) +;
- " FROM " + this.cZzeipoTH + " H"+;
- " JOIN " + lcTempGroupByPo + " D "+;
- " ON D.PO_NUM = H.PO_NUM "+;
- " WHERE H.REG_NUM = 0"
- llRetVal = llRetVal and v_sqlexec(lcSQL)
- *!* lnNewOrdCount = 0
- *!* lcSQL = " select COUNT(*) as NewOrderCount FROM " + this.cZzoordrh + " h "
- *!* llRetVal = llRetVal and v_sqlexec(lcSQL,"NewOrderCount")
- *!*
- *!* IF USED("NewOrderCount")
- *!* lnNewOrdCount = NewOrderCount.NewOrderCount
- *!* USE IN NewOrderCount
- *!* ENDIF
- *!* 0
- *!* IF NOT (llRetVal AND lnNewOrdCount > 0)
- *!* SELECT(lnOldSelect)
- *!* RETURN llRetVal
- *!* ENDIF
- *!* *--- update order number in order detail
- *!* DECLARE laOrdDtls[1,4]
- *!* laOrdDtls[1,1] = this.cZzeipoTH
- *!* laOrdDtls[1,2] = "reg_num" && update field of detail table
- *!* laOrdDtls[1,3] = "pkey" && relation field of Detail table
- *!* laOrdDtls[1,4] = "zzeipoth_pkey" && relation field of Header table
- *!*
- *!* LOCAL lnMaxReg_num
- *!* lnMaxReg_num = v_NextID('ZZXCOMPR', "REG_NUM", lnNewOrdCount)
- *!* llRetVal = llRetVal and this.oCopyUtil.HdrDtlNumKeyFldUpdate(this.cZzoordrh,"REG_NUM",@laOrdDtls,lnMaxReg_num,lnNewOrdCount,;
- *!* "Reg_Num_I")
- *-TR 1060901 FH
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE UpdateAllTables
- LOCAL llRetVal, lnOldSelect
- llRetVal = .t.
- lnOldSelect = SELECT()
- Local lcInsertSQL_zzoordrh, lcInsertSQL_zzoordrd, lcInsertSQL_zzoordSP
- Local lcInsertSQL_zzoordad, lcInsertSQL_zzootadr, lcInsertSQL_zzoordcd, lcInsertSQL_zzedatawhse &&--- TechRec 1054619 09-Jun-2011 MANI. Added lcInsertSQL_zzedatawhse ===
- LOCAL lcDeleteSQL_zzeipotwhse && TR 1059065 01-Feb-12 SK
- LOCAL lcInsertSQL_zzoordrh_nt, lcInsertSQL_zzoordrd_nt
- Local lcInsertSQL_zzoordwh, lcInsertSQL_zzoordwd, lcInsertSQL_zzxniblr
- LOCAL lcUpdate_Zzzudfdt
- LOCAL lcInsert_Zzxchrds, lcInsert_Zzoordsac
- LOCAL lcInsertSQL_Zzeipohh,lcInsertSQL_Zzeipohd, lcInsertSQL_Zzeipoha, lcInsertSQL_Zzeipohc, lcInsertSQL_Zzeipohh_nt, lcInsertSQL_Zzeipohd_nt
- Local lcInsertSQL_zzoordrh_cncl, lcInsertSQL_zzoordrd_cncl
- Local lcDeleteSQL_zzoordrh, lcDeleteSQL_zzoordrd, lcDeleteSQL_zzoordSP
- LOCAL lcInsertSQL_Zzeipoth,lcInsertSQL_Zzeipotd
- LOCAL lcUpdateSQL_Zzeipoth,lcUpdateSQL_Zzeipotd
- LOCAL lcDeleteSQL_Zzeipoth,lcDeleteSQL_Zzeipotd
- LOCAL lcDeleteSQL_Zzeipota,lcDeleteSQL_Zzeipotc
- LOCAL lcDeleteSQL_Zzeipoth_nt, lcDeleteSQL_Zzeipotd_nt
- LOCAL lcDeleteSQL_Zzeipotr, lcDelete_Zzeipotsac
- LOCAL lcDeleteSQL_Zzeipots,lcInsertSQL_Zzeipohs
- *--- TR 1075041 9-12-2013 VKK
- LOCAL lcInsertCreditCardSQL
- STORE "" TO lcInsertCreditCardSQL
- *=== TR 1075041 9-12-2013 VKK
- STORE " " to lcInsertSQL_zzoordrh, lcInsertSQL_zzoordrd, lcInsertSQL_zzoordSP
- STORE " " TO lcInsertSQL_zzoordad, lcInsertSQL_zzootadr, lcInsertSQL_zzoordcd, lcInsertSQL_zzedatawhse &&--- TechRec 1054619 09-Jun-2011 MANI. lcInsertSQL_zzedatawhse ===
- STORE " " TO lcDeleteSQL_zzeipotwhse && TR 1059065 01-Feb-12 SK
- STORE " " TO lcInsert_Zzxchrds, lcInsert_Zzoordsac
- STORE " " TO lcUpdate_Zzzudfdt
- STORE " " TO lcInsertSQL_Zzeipohh, lcInsertSQL_Zzeipohd, lcInsertSQL_Zzeipoha, lcInsertSQL_Zzeipohc, lcInsertSQL_Zzeipohh_nt, lcInsertSQL_Zzeipohd_nt
- STORE " " TO lcDeleteSQL_Zzeipotr, lcDelete_Zzeipotsac
- STORE " " to lcInsertSQL_Zzeipoth, lcInsertSQL_Zzeipotd
- STORE " " to lcUpdateSQL_Zzeipoth, lcUpdateSQL_Zzeipotd
- STORE " " to lcDeleteSQL_Zzeipoth, lcDeleteSQL_Zzeipotd
- STORE " " TO lcDeleteSQL_Zzeipota,lcDeleteSQL_Zzeipotc
- STORE " " TO lcDeleteSQL_Zzeipoth_nt,lcDeleteSQL_Zzeipotd_nt
- STORE " " TO lcInsertSQL_zzoordrh_nt, lcInsertSQL_zzoordrd_nt
- STORE " " TO lcInsertSQL_zzoordwh, lcInsertSQL_zzoordwd, lcInsertSQL_zzxniblr
- STORE " " TO lcInsertSQL_zzoordrh_cncl, lcInsertSQL_zzoordrd_cncl
- STORE " " TO lcDeleteSQL_zzoordrh, lcDeleteSQL_zzoordrd, lcDeleteSQL_zzoordSP
- STORE " " TO lcDeleteSQL_Zzeipots,lcInsertSQL_Zzeipohs
- *--- TR 1044208
- * Do not use this object to a variable. the object will be a class property now.
- *LOCAL loAfterUpdateBeforeCommit
- *loAfterUpdateBeforeCommit = null
- *llRetVal = llRetVal and this.GetInstance_AfterUpdateBeforeCommit(@loAfterUpdateBeforeCommit)
- ASSERT .f.
- *--- create order sql
- llRetVal = llRetVal And this.GetOrderInsertSQL(@lcInsertSQL_zzoordrh, @lcInsertSQL_zzoordrd, @lcInsertSQL_zzoordSP ;
- , @lcInsertSQL_zzoordad, @lcInsertSQL_zzootadr, @lcInsertSQL_zzoordcd, @lcInsertSQL_zzoordrh_nt, @lcInsertSQL_zzoordrd_nt, @lcInsertSQL_zzedatawhse) &&--- TechRec 1054619 09-Jun-2011 MANI. Added @lcInsertSQL_zzedatawhse ===
- *--- create transaction history sql
- llRetVal = llRetVal And this.GetTransHistoryInsertSQL(@lcInsertSQL_Zzeipohh, @lcInsertSQL_Zzeipohd, @lcInsertSQL_Zzeipoha ;
- , @lcInsertSQL_Zzeipohc, @lcInsertSQL_Zzeipohh_nt,@lcInsertSQL_Zzeipohd_nt,@lcInsertSQL_Zzeipohs)
- *--- create transaction delete sql
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipoth,this.cZzeipoTH,"zzeipoth")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipotd,this.cZzeipoTD,"zzeipotd")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipotc,this.cZzeipoTC,"zzeipotc")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipota,this.cZzeipoTA,"zzeipota")
- *--- TR 1059065 01-Feb-12 SK Creating delete string for warehouse table
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_zzeipotwhse,this.cZzeiPOtWHSE,"zzeipotwhse")
- *=== TR 1059065 01-Feb-12 SK
- *llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipotr,this.cZzeipoTR,"zzeipotr")
- lcDeleteSQL_Zzeipotr = "DELETE FROM zzeipotr where hdrfkey IN (SELECT pkey FROM " + this.cZzeipoTH + ")"
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDelete_Zzeipotsac,this.cZzeipotsac,"Zzeipotsac")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzeipots,this.cZzeipots,"Zzeipots")
- llRetVal = llRetVal and this.GetDeleteSQL_TransHdrNotes(@lcDeleteSQL_Zzeipoth_nt,.t.)
- llRetVal = llRetVal and this.GetDeleteSQL_TransDtlNotes(@lcDeleteSQL_Zzeipotd_nt,.t.)
- llRetVal = llRetVal and this.GetUpdateSQL_OrderExtender(@lcUpdate_Zzzudfdt)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsert_Zzxchrds,this.cZzoordrd_chrg,'zzxchrds',"'pkey'",,,.t.)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsert_Zzoordsac,this.cZzoordsac,'zzoordsac')
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsertSQL_zzxniblr,this.cZzxniblr,"zzxniblr",,,,.t.)
- *--- 1070384 04/22/13 Ilya: trx_pkey is now identity key, so exclude it from the sql query
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsertSQL_zzoordwh,this.cZzoordwh,"zzoordwh","'trx_pkey'",,,.t.)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsertSQL_zzoordwd,this.cZzoordwd,"zzoordwd","'trx_pkey'",,,.t.)
- *=== 1070384 04/22/13 Ilya.
- *--- create cancel orders
- IF !EMPTY(this.cZzoordrh_cncl)
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsertSQL_zzoordrh_cncl,this.cZzoordrh_cncl,"zzoordrh",,,,.t.)
- lcInsertSQL_zzoordrh_cncl = lcInsertSQL_zzoordrh_cncl + " where sql_action = 'I'"
- llRetVal = llRetVal and this.oCopyUtil.GetInsertSql(@lcInsertSQL_zzoordrd_cncl,this.cZzoordrd_cncl,"zzoordrd",,,,.t.)
- lcInsertSQL_zzoordrd_cncl = lcInsertSQL_zzoordrd_cncl + " where sql_action = 'I'"
- *--- delete open orders
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzoordrh,this.cZzoordrh_del,"zzoordrh")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzoordrd,this.cZzoordrd_del,"zzoordrd")
- llRetVal = llRetVal And this.oCopyUtil.GetDeleteSQL(@lcDeleteSQL_Zzoordsp,this.cZzoordsp_del,"zzoordsp")
- ENDIF
- *--- TR 1075041 9-12-2013 VKK
- llRetVal = llRetVal AND This.GetInsertSQLForCreditCard(@lcInsertCreditCardSQL)
- *=== TR 1075041 9-12-2013 VKK
- LOCAL lcAfterCommitErrorCursor
- Local llBeganTransaction,lnTranErrCount,lcTranFailedMsg
- llBeganTransaction = This.BeginTransaction()
- lnTranErrCount = 0
- lcTranFailedMsg = ""
- If llBeganTransaction And llRetVal
- this.SqlExecInTran(lcInsertSQL_zzoordrh, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order header failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordrd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order detail failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordSP, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order carton link records creation failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordad, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order address failed.")
- this.SqlExecInTran(lcInsertSQL_zzootadr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order one time address failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordcd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order comment failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordrh_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order header notes failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordrd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order detail notes failed.")
- this.SqlExecInTran(lcUpdate_Zzzudfdt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order detail extender failed.")
- this.SqlExecInTran(lcInsert_Zzxchrds, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order detail charges failed.")
- this.SqlExecInTran(lcInsert_Zzoordsac, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create order multi discount failed.")
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- this.SqlExecInTran(lcInsertSQL_zzedatawhse, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create data warehouse failed.")
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- IF !EMPTY(lcInsertSQL_zzoordrh_cncl)
- this.SqlExecInTran(lcInsertSQL_zzoordrh_cncl, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create cancel order header failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordrd_cncl, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Create cancel order detail failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzoordrh, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete open order header failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzoordrd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete open order detail failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzoordsp, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete open order sp failed.")
- ENDIF
- *--- insert transaction data to history
- this.SqlExecInTran(lcInsertSQL_Zzeipohh, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction header history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipohd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction detail history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipoha, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction address history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipohc, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction comment history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipohh_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction header notes history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipohd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction detail notes history failed.")
- this.SqlExecInTran(lcInsertSQL_Zzeipohs, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert transaction detail sln history failed.")
- *--- TR 1075041 9-12-2013 VKK
- this.SqlExecInTran(lcInsertCreditCardSQL, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert credit card failed.")
- *=== TR 1075041 9-12-2013 VKK
- *--- delete transaction that are good, at this point all records in this.cZzeipoTH are good
- this.SqlExecInTran(lcDeleteSQL_Zzeipoth, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction header failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipotd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction detail failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipota, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction address failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipotc, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction comment failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipoth_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction header notes failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipotd_nt, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction detail notes failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipotr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction detail charges failed.")
- this.SqlExecInTran(lcDeleteSQL_Zzeipots, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction detail slns failed.")
- this.SqlExecInTran(lcDelete_Zzeipotsac, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction SACs failed.")&& TR 1046111
- *-- TR 1059065 01-Feb-12 SK Executing the delete string for warehouse table
- this.SqlExecInTran(lcDeleteSQL_zzeipotwhse, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Delete transaction warehouse failed.")
- *=== TR 1059065 01-Feb-12 SK
- *--- bulk nibbler
- this.SqlExecInTran(lcInsertSQL_zzxniblr, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert nibbler failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordwh, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert nibbler work header failed.")
- this.SqlExecInTran(lcInsertSQL_zzoordwd, @llRetVal, @lnTranErrCount, @lcTranFailedMsg, "Insert nibbler work detail failed.")
- *--- TR 1044208
- *llRetVal = llRetVal and loAfterUpdateBeforeCommit.AfterUpdateBeforeCommit(@lcAfterCommitErrorCursor)
- llRetVal = llRetVal and .oAfterUpdate.AfterUpdateBeforeCommit(@lcAfterCommitErrorCursor)
- *=== TR 1044208
- If llRetVal
- This.EndTransaction()
- This.LogEntry("Transaction successful.")
- *--- increase toProcess vaulue for new transaction records.
- *this.IncreaseToProcessCount(lcZzeipcth_new)
- Else
- This.RollbackTransaction()
- This.LogEntry("---------------------------------------------")
- This.LogEntry(lcTranFailedMsg)
- This.LogEntry("Transaction rolled back.")
- This.LogEntry("=============================================")
- ENDIF
- llRetVal = llRetVal and this.LogAfterUpdateBeforeCommitError(lcAfterCommitErrorCursor)
- Else
- If llRetVal && and not llBeganTransaction
- *--- LogEntry : unable to open Transaction
- This.LogEntry("Fatal error : Fail to open transaction.")
- Endif
- Endif
- llRetVal = llRetVal and this.UpdateProcessStatus()
- Select(lnOldSelect)
- RETURN llRetVal
- ENDPROC
- *--- TR 1075041 9-12-2013 VKK
- *============================================================
- FUNCTION GetInsertSQLForCreditCard
- LPARAMETERS tcInsertCreditCardSQL
- LOCAL llRetVal, lnSelect
- llRetVal = true
- lnSelect = SELECT()
- WITH This
- IF vl_compr(,"creditcard_ok") = "Y"
- lcEncAlogorithm = goEnv.sv("CC_XP_CRYPT_ENCRYPTION_MODE")
- lcCrypt_password = 'üÇPOôqa?¦d--(ä¦' && (suggested password)
- lcCrypt_key = '@¡å®–¥§©' && (suggested key)
- *!* lcSQLString = " SELECT c.address1, c.address2, c.city, c.state, c.zipcode, c.country, c.customer, c.card_type, " + ;
- *!* " c.card_name, c.cc_number, c.expirationdate AS cc_expirationdate, c.cc_cvv, oh.pkey " + ;
- *!* " FROM " + .cZzoordrh + " oh " + ;
- *!* " JOIN zzwfactr f " + ;
- *!* " ON f.factor = oh.factor " + ;
- *!* " AND f.ccard_ok = 'Y' " + ;
- *!* " JOIN zzxccard c " + ;
- *!* " ON c.customer = oh.customer " + ;
- *!* " AND c.card_type = CASE WHEN oh.factor = 'CC_A' THEN 'A' " + ;
- *!* " WHEN oh.factor = 'CC_V' THEN 'V' " + ;
- *!* " WHEN oh.factor = 'CC_M' THEN 'M' " + ;
- *!* " WHEN oh.factor = 'CC_D' THEN 'D' " + ;
- *!* " WHEN oh.factor = 'CC_O' THEN 'O' END " + ;
- *!* " AND c.pkey = (SELECT MIN(pkey) FROM zzxccard " + ;
- *!* " WHERE customer = c.customer " + ;
- *!* " AND card_type = c.card_type) " + ;
- *!* " WHERE oh.conf_type = 'A' " + ;
- *!* " AND oh.autofact <> 'Y' "
- *!* lcTmpTable = SQLTableFromQuery(lcSQLString)
- IF llRetVal
- WITH .oSB
- .SB_Reset()
- .cSB_Target = "zzocrdcr"
- .cSB_Source = this.czzeipoth
- .cSB_SourceAlias = "h"
- .cSB_FROMExpandedString = " Join " + this.czzoordrh + " ordh " + ;
- " on ordh.ord_num = h.ord_num " + ;
- " And ordh.division = h.division "
- .cSB_WhereString = " NOT EXISTS(SELECT 1 FROM zzocrdcr " + ;
- " WHERE " + ;
- " fkey = ordh.pkey) " + ;
- " AND h.cardno > '' "
- .SB_SetLiteralFieldValue("last_mod",SQLFormatTS(DATETIME()))
- .SB_SetLiteralFieldValue("user_id",SQLFormatChar(goEnv.envLogin.cUserName))
- .SB_SetLiteralFieldValue("notes",SQLFormatChar(""))
- .SB_KeySetAddKeySpec("pkey","Int","h.pkey")
- .SB_SetLiteralFieldValue("fkey", "ordh.pkey")
- IF This.oHostProcess.lAuthorizeNetMode
- .SB_SetLiteralFieldValue("use_chrg_amt", "'N'")
- .SB_SetLiteralFieldValue("cc_number", "h.cardno")
- .SB_SetLiteralFieldValue("cardno", "h.cardno")
- .SB_SetLiteralFieldValue("expirationdate", "h.expirationdate")
- .SB_SetLiteralFieldValue("cc_expirationdate", "''")
- ELSE
- .SB_SetLiteralFieldValue("use_chrg_amt", "'Y'")
- lccc_number= " dbo.BCFN_XP_encrypt( h.cardno,'" + ;
- lcEncAlogorithm + "','" + lcCrypt_key + "','" + lcCrypt_password + "')"
- .SB_SetLiteralFieldValue("cc_number", lccc_number)
- .SB_SetLiteralFieldValue("cardno", "''")
- lccc_expdate= " dbo.BCFN_XP_encrypt( h.expirationdate,'" + ;
- lcEncAlogorithm + "','" + lcCrypt_key + "','" + lcCrypt_password + "')"
- .SB_SetLiteralFieldValue("cc_expirationdate", lccc_expdate)
- .SB_SetLiteralFieldValue("expirationdate", "''")
- ENDIF
- * .SB_SetLiteralFieldValue("cc_cvv", "h.cc_cvv")
- llRetVal = llRetVal AND .SB_GenerateSQLInsertString()
- tcInsertCreditCardSQL = .cSQLString
- ENDWITH
- ENDIF
- ENDIF
- ENDWITH
- SELECT (lnSelect)
- RETURN llRetVal
- ENDFUNC
- *=== TR 1075041 9-12-2013 VKK
- *--------------------------------------------------------------------------
- PROCEDURE LogAfterUpdateBeforeCommitError
- LPARAMETERS pcAfterCommitErrorCursor
- LOCAL llRetVal
- llRetVal = .t.
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetOrderInsertSQL
- LPARAMETERS pcInsertSQL_zzoordrh, pcInsertSQL_zzoordrd, pcInsertSQL_zzoordSP, pcInsertSQL_zzoordad ;
- , pcInsertSQL_zzootadr, pcInsertSQL_zzoordcd, pcInsertSQL_zzoordrh_nt, pcInsertSQL_zzoordrd_nt, ;
- pcInsertSQL_zzedatawhse
- &&--- TechRec 1054619 09-Jun-2011 MANI. pcInsertSQL_zzedatawhse ===
- Local llRetVal, lnOldSelect
- llRetVal = .t.
- lnOldSelect = Select()
- llRetVal = .T.
- LOCAL lcInsertSQL_zzoordrh, lcInsertSQL_zzoordrd, lcInsertSQL_zzoordSP
- LOCAL lcInsertSQL_zzoordad, lcInsertSQL_zzootadr, lcInsertSQL_zzoordcd, lcInsertSQL_zzedatawhse &&--- TechRec 1054619 09-Jun-2011 MANI. lcInsertSQL_zzedatawhse ===
- LOCAL lcInsertSQL_zzoordrh_nt, lcInsertSQL_zzoordrd_nt
- STORE " " TO lcInsertSQL_zzoordrh, lcInsertSQL_zzoordrd, lcInsertSQL_zzoordSP
- STORE " " TO lcInsertSQL_zzoordad, lcInsertSQL_zzootadr, lcInsertSQL_zzoordcd, lcInsertSQL_zzedatawhse &&--- TechRec 1054619 09-Jun-2011 MANI. lcInsertSQL_zzedatawhse ===
- STORE " " TO pcInsertSQL_zzoordrh_nt, lcInsertSQL_zzoordrd_nt
- LOCAL lcZzoordrh, lcZzoordrd, lcZzoordsp,lcZzoordad, lcZzootadr, lcZzoordcd, lcZzoordrh_nt, lcZzoordrd_nt, lczzedatawhse &&--- TechRec 1054619 09-Jun-2011 MANI. Added lczzedatawhse ===
- lcZzoordrh = this.cZzoordrh
- lcZzoordrd = this.cZzoordrd
- lcZzoordsp = this.cZzoordsp
- lcZzoordad = this.cZzoordad
- lcZzootadr = this.cZzootadr
- lcZzoordcd = this.cZzoordcd
- lcZzoordrh_nt = this.cZzoordrh_nt
- lcZzoordrd_nt = this.cZzoordrd_nt
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- lczzedatawhse = This.cZzedatawhse
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- Local lcValues, lcExcludeFlds, lcCalFlds, lcCalFldsValues
- lnOldSelect = Select()
- llRetVal = .T.
- lcFlds = ""
- lcValues = ""
- lcExcludeFlds = ""
- lcCalFlds = ""
- lcCalFldsValues = ""
- *--- Order Header insert
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzoordrh", lcZzoordrh, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"h.")
- lcInsertSQL_zzoordrh = " INSERT INTO zzoordrh (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordrh + " h "
- *--- Order Detail insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzoordrd", lcZzoordrd, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"d.")
- lcInsertSQL_zzoordrd = " INSERT INTO zzoordrd (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordrd + " d "
- *--- Order sp insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzoordsp", lcZzoordsp, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"sp.")
- lcInsertSQL_zzoordsp = " INSERT INTO zzoordsp (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordsp + " sp "
- *--- Order address insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzoordad", lcZzoordad, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"a")
- lcInsertSQL_zzoordad = " INSERT INTO zzoordad (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordad + " a "
- *--- one time address insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzootadr", lcZzootadr, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"a")
- lcInsertSQL_zzootadr = " INSERT INTO zzootadr (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzootadr + " a "
- *--- Order comment insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzoordcd", lcZzoordcd, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"c")
- lcInsertSQL_zzoordcd = " INSERT INTO zzoordcd (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordcd + " c "
- *--- Order Header Notes insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "sysnotes", lcZzoordrh_nt, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"h.")
- lcInsertSQL_zzoordrh_nt = " INSERT INTO sysnotes (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordrh_nt + " h "
- *--- Order Detail Notes Insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "sysnotes", lcZzoordrd_nt, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"d.")
- lcInsertSQL_zzoordrd_nt = " INSERT INTO sysnotes (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lcZzoordrd_nt + " d "
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- *--- Data warehouse insert
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And This.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzedatawhse", lcZzedatawhse, ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,"wh")
- lcInsertSQL_zzedatawhse = " INSERT INTO zzedatawhse (" + lcFlds + " ) SELECT " + lcValues + " FROM " + lczzedatawhse+ " wh "
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- pcInsertSQL_zzoordrh = lcInsertSQL_zzoordrh
- pcInsertSQL_zzoordrd = lcInsertSQL_zzoordrd
- pcInsertSQL_zzoordSP = lcInsertSQL_zzoordSP
- pcInsertSQL_zzoordad = lcInsertSQL_zzoordad
- pcInsertSQL_zzootadr = lcInsertSQL_zzootadr
- pcInsertSQL_zzoordcd = lcInsertSQL_zzoordcd
- pcInsertSQL_zzoordrh_nt = lcInsertSQL_zzoordrh_nt
- pcInsertSQL_zzoordrd_nt = lcInsertSQL_zzoordrd_nt
- *--- TechRec 1054619 09-Jun-2011 MANI. ---
- pcInsertSQL_zzedatawhse = lcInsertSQL_zzedatawhse
- *=== TechRec 1054619 09-Jun-2011 MANI. ===
- Select(lnOldSelect)
- Return llRetVal
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetTransHistoryInsertSQL
- LPARAMETERS pcInsertSQL_Zzeipohh, pcInsertSQL_Zzeipohd, pcInsertSQL_Zzeipoha, pcInsertSQL_Zzeipohc,;
- pcInsertSQL_Zzeipohh_nt, pcInsertSQL_Zzeipohd_nt,pcInsertSQL_Zzeipohs
- LOCAL llRetVal
- LOCAL lcInsertSQL_Zzeipohh, lcInsertSQL_Zzeipohd, lcInsertSQL_Zzeipoha, lcInsertSQL_Zzeipohc
- LOCAL lcInsertSQL_Zzeipohh_nt, lcInsertSQL_Zzeipohd_nt,pcInsert_Zzeipohs,lcZZeipohs
- LOCAL lcZzeipohh, lcZzeipohd, lcZzeipoha, lcZzeipohc, lcZzeipohh_nt, lcZzeipohd_nt
- STORE " " TO lcInsertSQL_Zzeipohh, lcInsertSQL_Zzeipohd, lcInsertSQL_Zzeipoha, lcInsertSQL_Zzeipohc
- STORE " " TO lcInsertSQL_Zzeipohh_nt, lcInsertSQL_Zzeipohd_nt,lcInsert_Zzeipohs
- llRetVal = .T.
- lcZzeipohh = this.cZzeipohh
- lcZzeipohd = this.cZzeipohd
- lcZzeipoha = this.cZzeipoha
- lcZzeipohc = this.cZzeipohc
- lcZzeipohh_nt = this.cZzeipohh_nt
- lcZzeipohd_nt = this.cZzeipohd_nt
- lcZZeipohs = this.cZzeipohs
- LOCAL lcFlds, lcValues,lcExcludeFlds,lcCalFlds,lcCalFldsValues
- lcFlds = ""
- lcValues = ""
- lcExcludeFlds = ""
- lcCalFlds = ""
- lcCalFldsValues = ""
- *--- insert new trans header in history
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzeipohh", lcZzeipohh , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'h')
- lcInsertSQL_Zzeipohh = " INSERT INTO zzeipohh ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohh + " h "
- *--- insert new trans detail in history
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzeipohd", lcZzeipohd , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'d')
- lcInsertSQL_Zzeipohd = " INSERT INTO zzeipohd ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohd + " d "
- *--- insert new trans detail in history
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzeipohs", lcZzeipohs , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'d')
- lcInsertSQL_Zzeipohs = " INSERT INTO zzeipohs ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohs + " d "
- *--- insert new trans address in history
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzeipoha", lcZzeipoha , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'a')
- lcInsertSQL_Zzeipoha = " INSERT INTO zzeipoha ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipoha + " a "
- *--- insert new trans comment in history
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "zzeipohc", lcZzeipohc , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'c')
- lcInsertSQL_Zzeipohc = " INSERT INTO zzeipohc ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohc + " c "
- *--- insert new trans header notes in history
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "sysnotes", lcZzeipohh_nt , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'h')
- lcInsertSQL_Zzeipohh_nt = " INSERT INTO sysnotes ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohh_nt + " h "
- lcFlds = ""
- lcValues = ""
- llRetVal = llRetVal And this.oCopyUtil.GetFldsValues(@lcFlds, @lcValues, "sysnotes", lcZzeipohd_nt , ;
- lcExcludeFlds,lcCalFlds,lcCalFldsValues,.f.,'h')
- lcInsertSQL_Zzeipohd_nt = " INSERT INTO sysnotes ( " + lcFlds + " ) " + ;
- " SELECT " + lcValues + " FROM " + lcZzeipohd_nt + " h "
- pcInsertSQL_Zzeipohh = lcInsertSQL_Zzeipohh
- pcInsertSQL_Zzeipohd = lcInsertSQL_Zzeipohd
- pcInsertSQL_Zzeipoha = lcInsertSQL_Zzeipoha
- pcInsertSQL_Zzeipohc = lcInsertSQL_Zzeipohc
- pcInsertSQL_Zzeipohh_nt = lcInsertSQL_Zzeipohh_nt
- pcInsertSQL_Zzeipohd_nt = lcInsertSQL_Zzeipohd_nt
- pcInsertSQL_Zzeipohs = lcInsertSQL_Zzeipohs
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetDeleteSQL
- LPARAMETERS pcDeleteSQL, pcSrc, pcDes, plNotExists
- LOCAL llRetVal
- llRetVal = .T.
- lcFilter = IIF(EMPTY(this.cFilterCriteria)," Where ", this.cFilterCriteria + " and ")
- lcExistsOrNot = IIF(plNotExists, " not ", "") + " exists "
- pcDeleteSQL = "DELETE h from " + pcDes + " h " + lcFilter + lcExistsOrNot + " (select h.pkey from " + pcSrc + ;
- " th where th.pkey = h.pkey ) "
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SqlExecInTran
- LPARAMETERS pcSql, plRetVal, pnTranErrCount, pcTranFailedMsg, pcErrMsg
- *--- TR 1060326 25-Feb-13 SK Proceeding only when plRetVal is true (To avoid updating wrong error messages)
- IF plRetVal
- *!* plRetVal = plRetVal And v_SQLExec(pcSql)
- plRetVal = v_SQLExec(pcSql)
- If pnTranErrCount = 0 And Not plRetVal
- pcTranFailedMsg = pcErrMsg
- lnTranErrCount = 1
- Endif
- ENDIF
- *=== TR 1060326 25-Feb-13 SK
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetPkey
- LPARAMETERS pcTbl, pcPkeySourceTbl
- Local llRetVal, lnOldSelect,lcUnique, lcSQL, lnMaxPkey, lcPkeyIdentity
- llRetVal = .T.
- lnOldSelect = Select()
- lnMaxPkey = 0
- lcSQL = "SELECT count(*) newCount from " + pcTbl
- llRetVal = llRetVal AND v_SqlExec(lcSQL,"TblRecord")
- IF llRetVal AND TblRecord.newCount > 0
- lcPkeyIdentity = "pkey_I" + SYS(2015)
- lnMaxPkey = v_NextPKey(pcPkeySourceTbl,TblRecord.newCount)
- llRetVal = llRetVal and this.oCopyUtil.KeyFldUpdate(pcTbl, "pkey", lnMaxPkey, TblRecord.newCount, ;
- lcPkeyIdentity, "")
- ENDIF
- IF USED("TblRecord")
- USE IN select("TblRecord")
- ENDIF
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE UpdateProcessStatus
- LOCAL llRetVal, lnOldSelect, lcSql, lcZzoordrh, lcZzoordrd
- llRetVal = .t.
- lnOldSelect = SELECT()
- *--- number of order header created
- lcZzoordrh = "tcZzoordrh" + SYS(2015)
- lcSql = "select COUNT(*) as RecordCount from " + this.cZzoordrh
- llRetVal = llRetVal and v_sqlexec(lcSql,lcZzoordrh)
- IF llRetVal AND USED(lcZzoordrh)
- this.oHostProcess.nOrderHeader = EVALUATE(lcZzoordrh + ".RecordCount")
- USE IN SELECT(lcZzoordrh)
- ENDIF
- *--- number of order detail created
- lcZzoordrd = "tcZzoordrd" + SYS(2015)
- lcSql = "select COUNT(*) as RecordCount from " + this.cZzoordrd
- llRetVal = llRetVal and v_sqlexec(lcSql,lcZzoordrd)
- IF llRetVal AND USED(lcZzoordrd)
- this.oHostProcess.nOrderDetail = EVALUATE(lcZzoordrd + ".RecordCount")
- USE IN SELECT(lcZzoordrd)
- ENDIF
- Select(lnOldSelect)
- Return llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *!* PROCEDURE GetInstance_AfterUpdateBeforeCommit
- *!* LPARAMETERS poAfterUpdateBeforeCommit
- *!*
- *!* LOCAL llRetVal
- *!* llRetVal = .t.
- *!* poAfterUpdateBeforeCommit = NEWOBJECT("clsIpoPr_AfterUpdateBeforeCommit","clsIpoPr_AfterUpdateBeforeCommit.fxp",null,this.oHostPROCESS,this)
- *!* llRetVal = (VARTYPE(poAfterUpdateBeforeCommit) == "O")
- *!* RETURN llRetVal
- *!* ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetLineSeqInTransComment
- LOCAL llRetVal, lcZzeipotc
- llRetVal = .t.
- lcZzeipotc = "#zzeipotc" + SYS(2015)
- *--- move data with line_seq = 0 to temp table
- lcSql = "select pkey, fkey, line_num into " + lcZzeipotc + " from " + this.cZzeipotc + " where line_num = 0 "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- THIS.RegisterTable(lcZzeipotc)
- *--- set line seq in temp table
- llRetVal = llRetVal and this.oCopyUtil.SetLineSeq(lcZzeipotc, "line_num", "fkey", "fkey,pkey", "d")
- *--- update line seq in work table
- lcSql = "Update c Set line_num = d.line_num from " + this.cZzeipotc + " c inner join " + lcZzeipotc + ;
- " d on d.pkey = c.pkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE CheckFldAndAssign
- LPARAMETERS pcFlds, pcFld, pcValue, pcPrefixComma
- LOCAL lcAssign, lcFlds, lcFld, lcDeli
- lcAssign = ""
- lcDeli = ","
- lcFlds = lcDeli + pcFlds + lcDeli
- lcFld = lcDeli + UPPER(ALLTRIM(pcFld)) + lcDeli
- IF at(lcFld,lcFlds) > 0
- lcAssign = pcFld + " = " + pcValue
- ENDIF
- IF !EMPTY(pcPrefixComma) AND !EMPTY(lcAssign)
- lcAssign = pcPrefixComma + lcAssign
- ENDIF
- RETURN lcAssign
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE ClearShippingFields
- LPARAMETERS pcOrderTbl
- LOCAL llRetVal, lcSql,lcAssign, lnOldSelect
- LOCAL lcDefaultDate, lcCurDate, lcOrderCur, lcDeli
- llRetVal = .t.
- lnOldSelect = SELECT()
- lcDefaultDate = SQLFormatTS({//})
- lcCurDate = SQLFormatTS(TTOD(ServerDatetime()))
- lcOrderCur = "tcOrderCur" + SYS(2015)
- lcSql = " select * from " + pcOrderTbl + " where 1=2"
- llRetVal = llRetVal and v_sqlexec(lcSql, lcOrderCur)
- DIMENSION laFlds[1]
- AFIELDS(laFlds,lcOrderCur)
- lcDeli = ","
- lcFlds = this.GetFldList(@laFlds,lcDeli)
- lcAssign = ""
- lcAssign = lcAssign + ", frgt_amt = case when Over_Frgt <> 'P' then 0 else h.frgt_amt end "
- lcAssign = lcAssign + ", misc_amt = case when Over_Frgt <> 'P' then 0 else h.misc_amt end "
- lcAssign = lcAssign + ", tax_amt = case when Tax_Empt <> 'P' then 0 else h.tax_amt end "
- *--- TechRec 1066657 28-Jan-2013 jjanand --- Removed , disc_amt = 0
- lcAssign = lcAssign + ", insu_amt = 0 "
- *=== TechRec 1066657 28-Jan-2013 jjanand ===
- lcAssign = lcAssign + ", mani_num = 0, bill_num = '', pro_num = '', consol_num = 0, ship_date = " + lcDefaultDate
- lcAssign = lcAssign + ", RRC = '', Load_Id = '', stop_seq = 0, Sent_753 = '',Rcvd_754 = ''"
- lcAssign = lcAssign + ", first_pack_user = ''"
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "proc_940","''",",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "proc_810","''",",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "proc_810f","''",",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "proc_870","''",",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "opks_proc","''",",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "pub_ship_date",lcDefaultDate,",")
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "act_ship_date",lcDefaultDate,",")
- *--- TR 1043347
- * Do not clear these fields.
- *lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "ok_to_ship",lcDefaultDate,",")
- *IF !vl_parmr("SOPRTNSHPR")
- * lcAssign = lcAssign + ",shipper = ''"
- *ENDIF
- *=== TR 1043347
- lcAssign = lcAssign + ",AR_PERIOD = '', PRD_YEAR = 0, PRD_MONTH = 0"
- lcAssign = lcAssign + ",wave_num = 0, swc_num = 0"
- lcAssign = lcAssign + ",Proc_856 = 'N'"
- *IF This.oHostProcess.lCCVerisignApproval ??????????
- lcAssign = lcAssign + this.CheckFldAndAssign(lcFlds, "appv_num","''",",")
- *ENDIF
- lcSql = "Update h Set carton = 0, weight = 0, ord_volume = 0 " + lcAssign + ;
- " from " + pcOrderTbl + " h "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- SELECT(lnOldSelect)
- RETURN llRetVal
- ENDPROC
- *-----------------------------------------------------------------------------
- *!* PROCEDURE GetInstance_BulkNibbler
- *!* LPARAMETERS poBulkNibbler
- *!* LOCAL llRetVal
- *!* llRetVal = .t.
- *!* poBulkNibbler = NEWOBJECT("clsIpoPr_BulkNibbler","clsIpopr_BulkNibbler.fxp",null,this.oHostProcess,this)
- *!* llRetVal = VARTYPE(poBulkNibbler) == "O"
- *!* RETURN llRetVal
- *!* ENDPROC
- *-----------------------------------------------------------------------------
- PROCEDURE GetFldList
- LPARAMETERS paFlds, pcDeli
- LOCAL lcFlds, lnFld, lnMaxFld, lcDeli
- lcFlds = ""
- lcDeli = IIF(EMPTY(pcDeli),",",pcDeli)
- lnMaxFld = ALEN(paFlds,1)
- FOR lnFld = 1 TO lnMaxFld
- lcFlds = lcFlds + UPPER(ALLTRIM(paFlds[lnFld,1])) + lcDeli
- ENDFOR
- IF !EMPTY(lcFlds)
- lcFlds = LEFT(lcFlds,LEN(lcFlds) - LEN(lcDeli))
- ENDIF
- RETURN lcFlds
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetDefaultDate_OrderDetail
- LOCAL llRetVal, lcSql, lcDefaultDate, lcCurDate
- llRetVal = .t.
- lcDefaultDate = SQLFormatTS({//})
- lcCurDate = SQLFormatTS(TTOD(ServerDatetime()))
- *--- TR 1071867 06/24/13 ATHIRUNAVU Set default date for isr_Start_date
- *--- TR 1077221 03/18/14 ATHIRUNAVU Removed pri_Date update.
- *lcSql = "Update d Set CNCL_DATE = " + lcDefaultDate + ;
- ", FEXPN_DATE = " + lcDefaultDate + ;
- ", PRI_DATE = " + lcCurDate + ;
- ", ISR_START_DATE = " + lcDefaultDate + ;
- " FROM " + this.cZzoordrd + " d "
- lcSql = "Update d Set CNCL_DATE = " + lcDefaultDate + ;
- ", FEXPN_DATE = " + lcDefaultDate + ;
- ", ISR_START_DATE = " + lcDefaultDate + ;
- " FROM " + this.cZzoordrd + " d "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareOrderExtender
- LOCAL llRetVal,lcSql
- llRetVal = .t.
- *--- Update three fields - hdrfkey, dtlfkey, GrpFKey in zzzudfdt table.
- *--- Now, cZzeipotd has final order pkey in zzoordrd_pkey field
- lcSql = "Update dex Set hdrfkey = d.fkey, DtlFkey = d.pkey, GrpFKey = dex.Grp_O_Key " + ;
- " from " + this.cZzoordrdExt + " dex inner join " + this.cZzoordrd + " d on d.zzeipotd_pkey = dex.oldDtlfkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("Prepare Order extender " + IIF(llRetVal,"completed.","failed."))
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareOrderDiscount
- LOCAL llRetVal, lcSql, lcDefaultdt
- *,CUSTOMER,ORD_NUM,PICK_NUM,INV_NUM,ORD_DATE,PO_NUM,PO_DATE,
- llRetVal = .t.
- *, po_date = h.po_date - h.po_Date not exists
- lcDefaultdt = sqlformatTS({})
- lcSql = " Update ds Set customer = h.customer, pick_num = 0, inv_num = 0, ord_date = h.ord_date, po_num = h.po_num" + ;
- ", po_date = " + lcDefaultdt + ;
- " from " + this.cZzoordsac + " ds inner join " + this.cZzoordrh + " h on h.ord_num = ds.ord_num "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = " Update ds Set LINE_SEQ = D.line_seq from " + this.cZzoordsac + " ds inner join " + this.cZzoordrd + " d on d.ord_num = ds.ord_num " + ;
- " and d.pkey = ds.dfkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- this.LogEntry("Prepare Order Discount " + IIF(llRetVal,"completed.","failed."))
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE PrepareOrderDiscount
- LOCAL llRetVal, lcSql, lcDefaultdt
- *,CUSTOMER,ORD_NUM,PICK_NUM,INV_NUM,ORD_DATE,PO_NUM,PO_DATE,
- llRetVal = .t.
- *, po_date = h.po_date - h.po_Date not exists
- lcDefaultdt = sqlformatTS({})
- lcSql = " Update ds Set customer = h.customer, pick_num = 0, inv_num = 0, ord_date = h.ord_date, po_num = h.po_num" + ;
- ", po_date = " + lcDefaultdt + ;
- " from " + this.cZzoordsac + " ds inner join " + this.cZzoordrh + " h on h.ord_num = ds.ord_num "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = " Update ds Set LINE_SEQ = D.line_seq from " + this.cZzoordsac + " ds inner join " + this.cZzoordrd + " d on d.ord_num = ds.ord_num " + ;
- " and d.pkey = ds.dfkey "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetUniqueSet_id(pcZzeipoTD, pcOrigSet_id)
- LOCAL llRetVal, lcSql, lcOrigSet_id, lcUnique, lcPrefix
- llRetVal = .t.
- lcUnique = SYS(2015)
- lcOrigSet_id = "#Uk_set_id" + lcUnique
- lcPrefix = RIGHT(lcUnique,5) + "@"
- * ", case when d.set_id > '' then d.set_id else '" + lcPrefix + " + left(ltrim(str(d.line_seq)),3) +' end set_id_new " + ;
- *--- create unique set_id for blank set_id
- lcSql = "select d.pkey, d.set_id" + ;
- ",'" + lcPrefix + "' + left(ltrim(str(d.line_seq)),4) set_id_new " + ;
- " into " + lcOrigSet_id + " from " + pcZzeipoTD + " d " + ;
- " where d.set_id = '' and exists (select ex.pkey from " + this.cZzeipoTDExt + " ex where ex.oldDtlFkey = d.pkey and ex.oldHdrFkey = d.fkey)"
- llRetval = llRetval and v_sqlexec(lcSql)
- .RegisterTable(lcOrigSet_id)
- lcSql = "Update d Set set_id = u.set_id_new from " + pcZzeipoTD + " d inner join " + lcOrigSet_id + " u on u.pkey = d.pkey "
- llRetval = llRetval and v_sqlexec(lcSql)
- pcOrigSet_id = lcOrigSet_id
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE ResetOriginalSet_id(pcZzeipotd_OrigSet_id,pcZzeipoTD)
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- lcSql = "update d Set set_id = u.set_id from " + pcZzeipoTD + " d inner join " + pcZzeipotd_OrigSet_id + ;
- " u on u.pkey = d.pkey "
- llRetval = llRetval and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE GetUpdateSQL_OrderExtender(pcUpdateSql_zzzudfdt)
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- llRetVal = llRetVal and this.oCopyUtil.GetUpdateSql(@pcUpdateSql_zzzudfdt,this.cZzoordrdExt,"zzzudfdt")
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *!* PROCEDURE GetInstance_EDIBulkMatching(poEdiBulkMatch)
- *!*
- *!* LOCAL llRetVal, lcSql
- *!* llRetVal = .t.
- *!* IF VARTYPE(this.oHostProcess.oPostValidation) == "O" AND VARTYPE(this.oHostProcess.oPostValidation.oEdiBulkMatching) == "O"
- *!* poEdiBulkMatch = this.oHostProcess.oPostValidation.oEdiBulkMatching
- *!* ELSE
- *!* poEdiBulkMatch = NEWOBJECT("clsipopr_EdiBulkMatching","clsipopr_EdiBulkMatching.fxp","",null,this.oHostProcess)
- *!* ENDIF
- *!* llRetval = llRetVal and (VARTYPE(poEdiBulkMatch) == "O")
- *!* RETURN llRetVal
- *!* ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE SetSac_IDandRate
- LPARAMETERS pcZzeipoTD, pcZzeiPOtsac
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- lcSql = "alter table " + pcZzeipoTD + " add sac_id varchar(250) not null default('')"
- llRetval = llRetVal and v_sqlexec(lcSql)
- lcSql = "alter table " + pcZzeipoTD + " add sac_rate numeric(7,3) not null default(0)"
- llRetval = llRetVal and v_sqlexec(lcSql)
- TEXT TO lcSql NOSHOW
- declare curSac CURSOR FORWARD_ONLY FOR
- select c.hfkey, c.dfkey
- FROM zzeipotsac c inner join #zzeipotd d on c.hfkey = d.fkey and c.dfkey = d.pkey order by hfkey, dfkey
- OPEN curSac
- declare @sac_id as varchar(250);
- set @sac_id = ''
- declare @sac_rate as numeric(7,3);
- set @sac_rate = 0.0
- declare @hfkey as int
- declare @dfkey as int
- FETCH NEXT FROM curSac INTO @hfkey,@dfkey
- while @@fetch_status = 0
- begin
- set @sac_id = ''
- set @sac_rate = 0.0
- select @sac_id = @sac_id + sac_code, @sac_rate = @sac_rate + sac_rate from zzeipotsac a
- where hfkey = @hfkey and dfkey = @dfkey order by a.hfkey, a.dfkey, a.sac_code, a.sac_rate
- update d set sac_id = @sac_id, sac_rate = @sac_rate from #zzeipotd d where d.pkey = @dfkey and d.fkey = @hfkey
- FETCH NEXT FROM curSac INTO @hfkey,@dfkey
- end
- close curSac;
- DEALLOCATE curSac;
- create index sac_id on #zzeipotd (sac_id,sac_rate)
- ENDTEXT
- lcSql = STRTRAN(lcSql,"#zzeipotd", pcZzeipoTD)
- lcSql = STRTRAN(lcSql,"#zzeipotsac", pcZzeiPOtsac)
- llRetval = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- PROCEDURE AdvanceThermoPlus(l_nThermoCnt, pcCaption)
- If This.lUserInterface
- dodefault(@l_nThermoCnt)
- IF !EMPTY(pcCaption) AND VARTYPE(pcCaption) = "C"
- this.UpdateThermoCaption(pcCaption)
- ENDIF
- ENDIF
- ENDPROC
- *--------------------------------------------------------------------------
- *--- TechRec 1048804 23-Aug-2010 TShenbagavalli ---
- PROCEDURE SetSpsBillOptn
- LOCAL llRetVal, lcSql
- llRetVal = .t.
- *--- TR 1060588 01-29-2013 RKI ---*
- *Bill_optn from Shipper Reference
- lcSQL = "Update h set bill_optn = r.bill_optn " + ;
- " from " + this.cZzoordrh + " h " + ;
- " inner join zzxshipr r (nolock) " + ;
- " on h.shipper = r.shipper where h.bill_optn = '' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TR 1060588 01-29-2013 RKI ===*
- *--- TR 1062786 5-8-2012 VKK
- lcSql = "Update h Set bill_optn = r.bill_optn " + ;
- "from " + this.cZzoordrh + " h " + ;
- " inner join zzxcslsr r (nolock) " + ;
- " on r.pkey = dbo.bcfn_customer_sales_res(h.customer, h.division, h.store, h.department,h.ord_type) " + ;
- " where h.bill_optn = '' " && TR 1060588 02-12-2013 RKI
- llRetVal = llRetVal and v_sqlexec(lcSql)
- *=== TR 1062786 5-8-2012 VKK
- lcSql = "Update h Set bill_optn = r.bill_optn from " + this.cZzoordrh + " h inner join zzxstorr r (nolock) " + ;
- " on h.customer = r.customer and h.store = r.store where r.active_ok = 'Y'" + ;
- " and h.bill_optn = '' " && *--- TR 1062786 5-8-2012 VKK
- llRetVal = llRetVal and v_sqlexec(lcSql)
- lcSql = "Update h Set bill_optn = r.bill_optn from " + this.cZzoordrh + " h inner join zzxcustr r (nolock) " + ;
- " on h.customer = r.customer where h.bill_optn = '' "
- llRetVal = llRetVal and v_sqlexec(lcSql)
- RETURN llRetVal
- ENDPROC
- *--------------------------------------------------------------------------
- *=== TechRec 1048804 23-Aug-2010 TShenbagavalli ===
- PROCEDURE RegisterTable
- LPARAMETERS tcTable
- IF USED("curTabDrop") AND NOT EMPTY(tcTable)
- INSERT INTO curTabDrop VALUES (tcTable)
- ENDIF
- ENDPROC
- *--- TechRec 1054619 13-Jun-2011 MANI. ---
- *==============================================================
- *-- Function : PrepareDataForWhse
- *-- Syopsis : Update field values to ware house table
- *-- (zzedatawhse) from oder detail.
- *==============================================================
- FUNCTION PrepareDataForWhse
- LOCAL llRetVal, lcSQL
- llRetVal = true
- lcSQL = ""
- WITH This
- *--- TechRec 1056973 15-Nov-2011 jisingh ---
- *!* lcSQL = "UPDATE wh SET Table_name = (CASE WHEN wh.hfkey = h.pkey and Wh.dfkey = 0 THEN 'ZZOORDRH' ELSE " + ;
- *!* " (CASE WHEN wh.Dfkey = COALESCE(D.pkey, 0) THEN 'ZZOORDRD' END) END), " + ;
- *!* " line_seq = CASE WHEN wh.Dfkey = COALESCE(D.pkey,0) THEN COALESCE(D.Line_seq,0) ELSE wh.line_seq END, " + ;
- *!* " sizebucket = CASE WHEN wh.Dfkey = COALESCE(D.pkey,0) THEN COALESCE(D.sizebucket,0) ELSE Wh.sizebucket END, " + ;
- *!* " user_id = " + SQLFormatchar(EDI_USER) + ;
- *!* "FROM " + .cZzeiPOtWHSE + " Wh JOIN " + .cZzeipoth + " h ON h.pkey = wh.Hfkey " + ;
- *!* "LEFT OUTER JOIN " + .cZzeipotd + " D ON D.Pkey = wh.dfkey "
- *!* llRetVal = v_SQLExec(lcSQL)
- lcSQL = "UPDATE wh1 SET sfkey = s.pkey " + ;
- "FROM " + .cZzedataWHSE + " wh1 " + ;
- "JOIN " + .czzeipotwhse + " wh " + ;
- " ON wh.sfkey = wh1.sfkey " + ;
- " AND wh.dfkey = wh1.dfkey " + ;
- "JOIN " + .cZzeipots + " s " + ;
- " ON s.doc_num = wh.doc_num " + ;
- " AND s.sln_line = wh.edi_line " + ;
- " AND s.sln01 = wh.sln_line "
- llRetVal = llRetVal AND v_SQLExec(lcSQL)
- *--- TechRec 1059747 27-Apr-2012 jisingh ---
- * EDIS
- lcSQL = "UPDATE wh1 SET wh1.dfkey = d.pkey " + ;
- " ,wh1.sizebucket = d.sizebucket " + ;
- "FROM " + .cZzedataWHSE + " wh1 " + ;
- "JOIN " + .czzeipotwhse + " wh " + ;
- " ON wh.sfkey = wh1.sfkey " + ;
- " AND wh.dfkey = wh1.dfkey " + ;
- "JOIN " + .cZzeipotd + " d " + ;
- " ON d.doc_num = wh.doc_num " + ;
- " AND d.po1_line = wh.edi_line " + ;
- " AND d.sln01 = wh.sln_line " + ;
- " AND d.store = wh.store " + ;
- "WHERE wh.sfkey > 0 "
- llRetVal = llRetVal AND v_SQLExec(lcSQL)
- * EDID
- lcSQL = "UPDATE wh1 SET wh1.dfkey = d.pkey " + ;
- " ,wh1.sizebucket = d.sizebucket " + ;
- "FROM " + .cZzedataWHSE + " wh1 " + ;
- "JOIN " + .czzeipotwhse + " wh " + ;
- " ON wh.sfkey = wh1.sfkey " + ;
- " AND wh.dfkey = wh1.dfkey " + ;
- "JOIN " + .cZzeipotd + " d " + ;
- " ON d.doc_num = wh.doc_num " + ;
- " AND d.po1_line = wh.edi_line " + ;
- " AND d.store = wh.store " + ;
- "WHERE wh.sfkey = 0 "
- llRetVal = llRetVal AND v_SQLExec(lcSQL)
- *=== TechRec 1059747 27-Apr-2012 jisingh ===
- *!* *- TR 1059065 FH - why do we need to update dfkey again?
- *!* *- - this update doesn't work on SDQ orders where 2 lines have the same doc_num, po1_line, sln01 but belongs to different
- *!* *- - header so it has different hfkey and dfkey.
- *!* lcSQL = "UPDATE wh1 SET dfkey = d.pkey " + ;
- *!* "FROM " + .cZzedataWHSE + " wh1 " + ;
- *!* "JOIN " + .czzeipotwhse + " wh " + ;
- *!* " ON wh.sfkey = wh1.sfkey " + ;
- *!* " AND wh.dfkey = wh1.dfkey " + ;
- *!* "JOIN " + .cZzeipotd + " d " + ;
- *!* " ON d.doc_num = wh.doc_num " + ;
- *!* " AND d.po1_line = wh.edi_line " + ;
- *!* " AND d.sln01 = wh.sln_line "
- *!* llRetVal = llRetVal AND v_SQLExec(lcSQL)
- *--- TechRec 1058326 13-Dec-2011 jisingh ---
- *lcSQL = "UPDATE wh SET table_name = (CASE WHEN wh.sfkey = s.pkey THEN 'ZZEIPOHS' ELSE " + ;
- " (CASE WHEN wh.hfkey > 0 AND wh.dfkey = 0 THEN 'ZZOORDRH' ELSE " + ;
- " (CASE WHEN wh.dfkey = COALESCE(d.pkey, 0) THEN 'ZZOORDRD' ELSE wh.table_name END) END) END), " + ;
- " line_seq = CASE WHEN wh.dfkey = COALESCE(d.pkey,0) THEN COALESCE(d.line_seq,0) ELSE wh.line_seq END, " + ;
- " sizebucket = CASE WHEN wh.sfkey = COALESCE(s.pkey,0) THEN COALESCE(s.sizebucket,0) ELSE d.sizebucket END, " + ;
- " user_id = " + SQLFormatchar(EDI_USER) + ;
- "FROM " + .cZzedataWHSE + " wh " + ;
- "LEFT OUTER JOIN " + .cZzeipotd + " d ON d.pkey = wh.dfkey " + ;
- "LEFT OUTER JOIN " + .cZzeipots + " s ON s.pkey = wh.sfkey "
- *!* lcSQL = "UPDATE wh SET table_name = (CASE WHEN wh.sfkey > 0 THEN 'ZZEIPOHS' ELSE " + ;
- *!* " (CASE WHEN wh.hfkey > 0 AND wh.dfkey = 0 THEN 'ZZOORDRH' ELSE " + ;
- *!* " (CASE WHEN wh.dfkey = COALESCE(d.pkey, 0) THEN 'ZZOORDRD' ELSE wh.table_name END) END) END), " + ;
- *!* " line_seq = (CASE WHEN COALESCE(d.slntodtl,'') IN ('Y','I') THEN COALESCE(d1.line_seq,0) ELSE " + ;
- *!* " (CASE WHEN wh.dfkey = COALESCE(d.pkey,0) THEN COALESCE(d.line_seq,0) ELSE wh.line_seq END) END), " + ;
- *!* " sizebucket = (CASE WHEN wh.sfkey = COALESCE(s.pkey,0) THEN COALESCE(s.sizebucket,0) ELSE " + ;
- *!* " (CASE WHEN d.sizebucket IS NOT NULL THEN d.sizebucket ELSE wh.sizebucket END) END), " + ;
- *!* " user_id = " + SQLFormatchar(EDI_USER) + ;
- *!* "FROM " + .cZzedataWHSE + " wh " + ;
- *!* "LEFT OUTER JOIN " + .cZzeipotd + " d ON d.pkey = wh.dfkey " + ;
- *!* "LEFT OUTER JOIN " + .cZzeipots + " s ON s.pkey = wh.sfkey " + ;
- *!* "LEFT OUTER JOIN (SELECT ord_num, assortment , po1_line, MIN(line_seq) AS line_seq " + ;
- *!* " FROM " + .cZzeipotd + " GROUP BY ord_num, assortment, po1_line) d1 " + ;
- *!* " ON d.ord_num = d1.ord_num AND d.assortment = d1.assortment AND d.po1_line = d1.po1_line "
- *!*
- *=== TechRec 1058326 13-Dec-2011 jisingh ===
- *- FH 1074465 - Added zzoordrd_pkey to group by. zzoordrh.line_seq MUST MATCH zzedatawhse.line_seq
- *-TR 1059065 FH - took out sizebucket, we updated sizebucket from before
- lcSQL = "UPDATE wh SET table_name = (CASE WHEN wh.sfkey > 0 THEN 'ZZEIPOHS' ELSE " + ;
- " (CASE WHEN wh.hfkey > 0 AND wh.dfkey = 0 THEN 'ZZOORDRH' ELSE " + ;
- " (CASE WHEN wh.dfkey = COALESCE(d.pkey, 0) THEN 'ZZOORDRD' ELSE wh.table_name END) END) END), " + ;
- " line_seq = (CASE WHEN COALESCE(d.slntodtl,'') IN ('Y','I') THEN COALESCE(d1.line_seq,0) ELSE " + ;
- " (CASE WHEN wh.dfkey = COALESCE(d.pkey,0) THEN COALESCE(d.line_seq,0) ELSE wh.line_seq END) END), " + ;
- " user_id = " + SQLFormatchar(EDI_USER) + ;
- "FROM " + .cZzedataWHSE + " wh " + ;
- "LEFT OUTER JOIN " + .cZzeipotd + " d ON d.pkey = wh.dfkey " + ;
- "LEFT OUTER JOIN " + .cZzeipots + " s ON s.pkey = wh.sfkey " + ;
- "LEFT OUTER JOIN (SELECT ord_num, assortment , po1_line, MIN(line_seq) AS line_seq , zzoordrd_pkey " + ; && FH 1074465 zzoordrd_pkey
- " FROM " + .cZzeipotd + " GROUP BY ord_num, assortment, po1_line, zzoordrd_pkey ) d1 " + ; && FH 1074465 zzoordrd_pkey
- " ON d.ord_num = d1.ord_num AND d.assortment = d1.assortment AND d.po1_line = d1.po1_line " +;
- " AND d.zzoordrd_pkey = d1.zzoordrd_pkey "
- llRetVal = llRetVal AND v_SQLExec(lcSQL)
- *=== TechRec 1056973 15-Nov-2011 jisingh ===
- *-FH 1074465 - If SLNTODTL, we need to set min(sizebucket) for assortment, otherwise set sizebucket to what was set above
- *- Moved this below to try and get the min(line_seq) for EDID lines.
- *- If this was above then line_seq on EDID won't necessary be the min(line_seq) per assortment (set by query above). (outbound won't pick it up)
- lcSQL = " Update wh set " + ;
- " sizebucket = (case " + ;
- " when COALESCE(d.slntodtl, '') in ('Y', 'I') then COALESCE(d1.sizebucket, 0) " + ;
- " else COALESCE(wh.sizebucket , 0) end) " + ;
- " , line_seq = (CASE WHEN COALESCE(d.slntodtl,'') IN ('Y','I') THEN COALESCE(d1.line_seq,0) ELSE " +;
- " (CASE WHEN wh.dfkey = COALESCE(d.pkey,0) THEN COALESCE(d.line_seq,0) ELSE wh.line_seq END) END) " +;
- " FROM " + .cZzedataWHSE + " wh " + ;
- " left outer join " + .cZzeipotd + " d " + ;
- " on d.pkey = wh.dfkey " + ;
- " left outer join ( " + ;
- " select ord_num " + ;
- " , assortment " + ;
- " , po1_line " + ;
- " , min(sizebucket) as sizebucket " + ;
- " , MIN(line_seq) as line_seq " +;
- " from " + .cZzeipotd + ;
- " group by ord_num, assortment, po1_line) d1 " + ;
- " on d.ord_num = d1.ord_num " + ;
- " and d.assortment = d1.assortment " + ;
- " and d.po1_line = d1.po1_line " + ;
- " where wh.sfkey = 0 "
- llRetVal = llRetVal AND v_SQLExec(lcSQL)
- ENDWITH
- RETURN llRetVal
- ENDFUNC && PrepareDataForWhse
- *=== TechRec 1054619 13-Jun-2011 MANI. ===
- *-TR 1059065 FH
- PROCEDURE UpdateWarehouseSizebucket
- LPARAMETERS pcDataWhse, pcSrcDtl
- LOCAL llRetval, lcSql
- llRetval = .t.
- lcSql = " update wh set wh.sizebucket = d.sizebucket " + ;
- " from " + pcDataWhse + " wh " + ;
- " join " + pcSrcDtl + " d " + ;
- " on wh.dfkey = d.pkey " +;
- " where wh.sfkey = 0"
- llRetval = llRetVal and v_sqlexec(lcSql)
- RETURN llRetval
- ENDPROC
- PROCEDURE UpdateWarehouseSLNSizebucket
- LPARAMETERS pcDataWhse, pcSrcDtl
- LOCAL llRetval, lcSql
- llRetval = .t.
- lcSql = " update wh set wh.sizebucket = s.sizebucket " + ;
- " from " + pcDataWhse + " wh " + ;
- " join " + pcSrcDtl + " s " + ;
- " on wh.sfkey = s.pkey " +;
- " where wh.sfkey > 0"
- llRetval = llRetVal and v_sqlexec(lcSql)
- RETURN llRetval
- ENDPROC
- *-TR 1059065 FH
- ENDDEFINE
- *==========================================================
- DEFINE CLASS IPO_CopyUtil AS CopyUtil
- *--------------------------------------------------
- PROCEDURE SendCursorToSqlTbl
- Lparam pcSrcDbf, pcDesTable, plDesTableExists
- LOCAL llRetVal
- llRetVal = .T.
- llRetVal = DODEFAULT(pcSrcDbf, pcDesTable, plDesTableExists)
- IF llRetVal AND USED("curTabDrop") AND NOT EMPTY(pcDesTable)
- INSERT INTO curTabDrop VALUES (pcDesTable)
- ENDIF
- ENDPROC
- ENDDEFINE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement