public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { Decimal AllowableToError = 0.5M; MoConfirmationMaterialVo inVo = (MoConfirmationMaterialVo)vo; MoConfirmationHeaderVo header = (MoConfirmationHeaderVo)inVo.MoConfirmationHeaderVo; //MoConfirmationMaterialVo materialsVo = (MoConfirmationMaterialVo)inVo.MoConfirmationMaterialListVo.FirstOrDefault(); List <MoConfirmationMaterialVo> materials = inVo.MoConfirmationMaterialListVo; if (header.CancellationFlag != "CAL") { MoConfirmationResultVo FrontResultVo = new MoConfirmationResultVo(); List <SapMessageVo> FrontMessageList = new List <SapMessageVo>(); bool DataIsOk = true; MoConfirmationMaterialVo materialProduct = materials.Find(s => s.MovementType == Properties.Resources.MOVEMENT_TYPE); if (materialProduct == null) { DataIsOk = false; SapMessageVo NullMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00036, LogMessageNumber = "000", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(NullMessage); } else { if (materialProduct.SapBatchNumber != header.LotNoOfUsers) { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00037, LogMessageNumber = "001", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } if (materialProduct.Quantity != header.ProductionOfUsers) { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00038, LogMessageNumber = "002", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } } Decimal MaterQtyAll = materials.Where(r => r.MovementType != Properties.Resources.MOVEMENT_TYPE).Sum(t => t.Quantity); if (header.TotalOfUsers >= MaterQtyAll - AllowableToError && header.TotalOfUsers <= MaterQtyAll + AllowableToError) { } else { DataIsOk = false; SapMessageVo BatchDifferentMessage = new SapMessageVo { OrderNumber = header.OrderNumber, MessageType = Properties.Resources.ErrorMessageCategory, MessageClassId = "000", MessageNumber = "000", LogNumber = Properties.Resources.scce00039, LogMessageNumber = "003", MessageVariable1 = "", MessageVariable2 = "", MessageVariable3 = "", MessageVariable4 = "" }; FrontResultVo.MessageList.Add(BatchDifferentMessage); } if (!DataIsOk) { FrontResultVo.OutSapFlag = Properties.Resources.ErrorMessageCategory; return(FrontResultVo); } } SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MANUFACTURING_ORDER_CONFIRMATION.GetValue()); //get the sapuser from cache memory SapUserVo sapUserVo = sapCommandAdapter.GetSapUser(trxContext); DateTime dbTime = trxContext.ProcessingDBDateTime; SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // ); sapParameter.AddParameter("ORDER_NUMBER", header.OrderNumber); sapParameter.AddParameter("IMUSER", sapUserVo.SapUser); //set sapuser using using sessionid sapParameter.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); //submitting datetime "yyyyMMdd" sapParameter.AddParameter("IMTIME", dbTime.ToString("HHmmss")); //submitting datetime "HHmmss" if (string.IsNullOrEmpty(header.Supervisor)) { sapParameter.AddParameter("SUPERVISOR", trxContext.UserData.UserCode); //nidecmes login user } else { sapParameter.AddParameter("SUPERVISOR", header.Supervisor); // trxContext.UserData.UserCode); //nidecmes login user } sapParameter.AddParameter("ACT_STARTDATE", header.StartDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_STARTTIME", header.StartDateTime.ToString("HHmmss")); sapParameter.AddParameter("ACT_ENDDATE", header.EndDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_ENDTIME", header.EndDateTime.ToString("HHmmss")); sapParameter.AddParameter("MAN_HOUR", header.ManHour.ToString("0.000")); sapParameter.AddParameter("MACHINE_HOUR", header.MachineHour.ToString("0.000")); sapParameter.AddParameter("WORKUNIT", header.WorkTimeUnit); sapParameter.AddParameter("POSTDATE", header.PostingDate.ToString("yyyyMMdd")); sapParameter.AddParameter("CAL_FLAG", header.CancellationFlag); sapParameter.AddParameter("END_FLAG", header.EndFlag); sapParameter.AddParameter("CONF_NO", header.ConfirmationNumber.ToString()); sapParameter.AddParameter("CONF_CNT", header.ConfirmationCounter.ToString()); sapParameter.AddParameter("MULTI_FLAG", header.MultiFlag); sapParameter.AddParameter("IM_COUNT", header.MaterialCount); sapParameter.AddParameter("IM_TOTAL", header.MaterialQuantityTotal.ToString("0.000")); SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); foreach (MoConfirmationMaterialVo m in materials) { //rfcTable.Insert(); sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("ORDER_NUMBER", m.OrderNumber); sapParameterTable.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); sapParameterTable.AddParameter("IMTIME", dbTime.ToString("HHmmss")); sapParameterTable.AddParameter("MATERIAL", m.MaterialNumber); sapParameterTable.AddParameter("BATCH", m.SapBatchNumber); sapParameterTable.AddParameter("V_BATCH", m.VendorBatchNumber); sapParameterTable.AddParameter("MOVETYPE", m.MovementType); sapParameterTable.AddParameter("ACT_QUANTITY", m.Quantity.ToString()); sapParameterTable.AddParameter("LGORT", m.StorageLocation); sapParameterTable.AddParameter("UNIT", m.Unit); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_ORDER_MOVEMENT", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); MoConfirmationResultVo resultVo = new MoConfirmationResultVo { OutSapFlag = sapFuntion.GetSAPValue("OUT_SAPFLAG") }; List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapTable.Rows) { SapMessageVo message = new SapMessageVo { OrderNumber = ConvertNull <string>(dr, "AUFNR"), MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; resultVo.MessageList.Add(message); } return(resultVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { ManufacturingOrderVo inVo = (ManufacturingOrderVo)vo; List <MRPControllerRangeVo> mrpControllers = inVo.MRPControllerRangeListVo; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MANUFACTURING_ORDER.GetValue()); //create parameter SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_PLANT", inVo.PlantCode); if (!string.IsNullOrEmpty(inVo.FromDate)) { sapParameter.AddParameter("IM_FROM_DATE", inVo.FromDate); } if (!string.IsNullOrEmpty(inVo.ToDate)) { sapParameter.AddParameter("IM_TO_DATE", inVo.ToDate); //"20160323" } if (!string.IsNullOrEmpty(inVo.OrderType)) { sapParameter.AddParameter("IM_ORDERTYPE", inVo.OrderType);//ZP01 } if (!string.IsNullOrEmpty(inVo.WorkCenter)) { sapParameter.AddParameter("IM_WORKCENTER", inVo.WorkCenter); } if (!string.IsNullOrEmpty(inVo.MoNumberFrom)) { sapParameter.AddParameter("IM_FROM_MONO", inVo.MoNumberFrom); } if (!string.IsNullOrEmpty(inVo.MoNumberTo)) { sapParameter.AddParameter("IM_TO_MONO", inVo.MoNumberTo); } if (!string.IsNullOrEmpty(inVo.Shift)) { sapParameter.AddParameter("IM_SHIFT", inVo.Shift); } sapParameter.AddParameter("IM_SOURCE", inVo.Source); sapParameter.AddParameter("IM_BOM", inVo.IncludeBOM); SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); sapParameterTable = sapCommandAdapter.CreateParameterList(); foreach (MRPControllerRangeVo mrp in mrpControllers) { sapParameterTable.AddParameter("SIGN", mrp.Sign); sapParameterTable.AddParameter("HIGH", mrp.High); sapParameterTable.AddParameter("OPTION", mrp.Option); sapParameterTable.AddParameter("LOW", mrp.Low); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_MRP_CNTRL_RANGE", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); //MO data DataTable sapMOTable = sapFuntion.GetSAPTable("TB_MANUFACTURING_ORDER"); // result BOM data DataTable sapMODetailTable = sapFuntion.GetSAPTable("TB_ORDER_DETAIL"); ManufacturingOrderVo outVo = new ManufacturingOrderVo(); foreach (DataRow dr in sapMOTable.Rows) { ManufacturingOrderVo currOutVo = new ManufacturingOrderVo(); currOutVo.MoNumber = ConvertNull <string>(dr, "ORDER_NUMBER").TrimStart('0'); currOutVo.ItemCd = ConvertNull <string>(dr, "MATERIAL").TrimStart('0'); currOutVo.ItemName = ConvertNull <string>(dr, "MATERIAL_TEXT"); currOutVo.ProductionDate = ConvertNull <string>(dr, "PRODUCTION_START_DATE"); currOutVo.Shift = ConvertNull <string>(dr, "SHIFT"); currOutVo.TargetQty = ConvertNull <string>(dr, "TARGET_QUANTITY"); currOutVo.OrderType = ConvertNull <string>(dr, "ORDER_TYPE"); currOutVo.MrpController = ConvertNull <string>(dr, "MRP_CONTROLLER"); currOutVo.Status = ConvertNull <string>(dr, "SYSTEM_STATUS"); currOutVo.WorkCenter = ConvertNull <string>(dr, "WORK_CENTER"); currOutVo.FinishDate = ConvertNull <string>(dr, "PRODUCTION_FINISH_DATE"); currOutVo.FinishTime = ConvertNull <string>(dr, "FINISH_TIME"); if (sapMODetailTable != null && sapMODetailTable.Rows.Count > 0) { DataRow[] drDetail = sapMODetailTable.Select("ORDER_NUMBER = '" + ConvertNull <string>(dr, "ORDER_NUMBER") + "'"); if (drDetail.Length > 0) { currOutVo.MoConfirmationMaterialListVo = new List <MoConfirmationMaterialVo>(); foreach (DataRow currdrdetail in drDetail) { MoConfirmationMaterialVo detailOutVo = new MoConfirmationMaterialVo(); detailOutVo.OrderNumber = ConvertNull <string>(currdrdetail, "ORDER_NUMBER").TrimStart('0'); detailOutVo.MaterialNumber = ConvertNull <string>(currdrdetail, "MATERIAL").TrimStart('0'); detailOutVo.MaterialOld = ConvertNull <string>(currdrdetail, "MATERIAL_OLD").TrimStart('0'); detailOutVo.AlternateGroup = ConvertNull <string>(currdrdetail, "ALT_GROUP"); detailOutVo.SapBatchNumber = ConvertNull <string>(currdrdetail, "BATCH"); detailOutVo.ProcureType = ConvertNull <string>(currdrdetail, "PROCURE_TYPE"); detailOutVo.VendorBatchNumber = ConvertNull <string>(currdrdetail, "VENDOR_BATCH"); detailOutVo.SapVendor = ConvertNull <string>(currdrdetail, "VENDOR"); detailOutVo.StorageLocation = ConvertNull <string>(currdrdetail, "LGORT"); detailOutVo.Quantity = (int)Convert.ToDecimal(ConvertNull <string>(currdrdetail, "QUANTITY")); detailOutVo.Unit = ConvertNull <string>(currdrdetail, "UNIT"); detailOutVo.MovementType = ConvertNull <string>(currdrdetail, "MOVETYPE"); currOutVo.MoConfirmationMaterialListVo.Add(detailOutVo); } } } outVo.ManufacturingOrderListVo.Add(currOutVo); } //MoConfirmationMaterialVo moConfirmationMaterialOutVo; //foreach (DataRow dr in orderDetailTable.Rows) //{ // moConfirmationMaterialOutVo = new MoConfirmationMaterialVo(); // moConfirmationMaterialOutVo.OrderNumber = ConvertNull<string>(dr, "ORDER_NUMBER").TrimStart('0'); // moConfirmationMaterialOutVo.MaterialNumber = ConvertNull<string>(dr, "MATERIAL").TrimStart('0'); // moConfirmationMaterialOutVo.MaterialOld = ConvertNull<string>(dr, "MATERIAL_OLD").TrimStart('0'); // moConfirmationMaterialOutVo.AlternateGroup = ConvertNull<string>(dr, "ALT_GROUP"); // moConfirmationMaterialOutVo.SapBatchNumber = ConvertNull<string>(dr, "BATCH"); // moConfirmationMaterialOutVo.VendorBatchNumber = ConvertNull<string>(dr, "VENDOR_BATCH"); // moConfirmationMaterialOutVo.SapVendor = ConvertNull<string>(dr, "VENDOR"); // moConfirmationMaterialOutVo.StorageLocation = ConvertNull<string>(dr, "LGORT"); // moConfirmationMaterialOutVo.Quantity = (int) Convert.ToDecimal(ConvertNull<string>(dr, "QUANTITY")); // moConfirmationMaterialOutVo.Unit = ConvertNull<string>(dr, "UNIT"); // moConfirmationMaterialOutVo.MovementType = ConvertNull<string>(dr, "MOVETYPE"); // outVo.MoConfirmationMaterialListVo.Add(moConfirmationMaterialOutVo); //} outVo.SapMessageListVo = new List <SapMessageVo>(); DataTable sapMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapMessageTable.Rows) { SapMessageVo message = new SapMessageVo { MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; outVo.SapMessageListVo.Add(message); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { MoConfirmationMaterialVo inVo = (MoConfirmationMaterialVo)vo; MoConfirmationHeaderVo header = (MoConfirmationHeaderVo)inVo.MoConfirmationHeaderVo; //MoConfirmationMaterialVo materialsVo = (MoConfirmationMaterialVo)inVo.MoConfirmationMaterialListVo.FirstOrDefault(); List <MoConfirmationMaterialVo> materials = inVo.MoConfirmationMaterialListVo; SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MANUFACTURING_ORDER_CONFIRMATION.GetValue()); //get the sapuser from cache memory SapUserVo sapUserVo = sapCommandAdapter.GetSapUser(trxContext); DateTime dbTime = trxContext.ProcessingDBDateTime; SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // ); sapParameter.AddParameter("ORDER_NUMBER", header.OrderNumber); sapParameter.AddParameter("IMUSER", sapUserVo.SapUser); //set sapuser using using sessionid sapParameter.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); //submitting datetime "yyyyMMdd" sapParameter.AddParameter("IMTIME", dbTime.ToString("HHmmss")); //submitting datetime "HHmmss" sapParameter.AddParameter("SUPERVISOR", trxContext.UserData.UserCode); //nidecmes login user sapParameter.AddParameter("ACT_STARTDATE", header.StartDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_STARTTIME", header.StartDateTime.ToString("HHmmss")); sapParameter.AddParameter("ACT_ENDDATE", header.EndDateTime.ToString("yyyyMMdd")); sapParameter.AddParameter("ACT_ENDTIME", header.EndDateTime.ToString("HHmmss")); sapParameter.AddParameter("MAN_HOUR", header.ManHour.ToString("0.000")); sapParameter.AddParameter("MACHINE_HOUR", header.MachineHour.ToString("0.000")); sapParameter.AddParameter("WORKUNIT", header.WorkTimeUnit); sapParameter.AddParameter("POSTDATE", header.PostingDate.ToString("yyyyMMdd")); sapParameter.AddParameter("CAL_FLAG", header.CancellationFlag); sapParameter.AddParameter("END_FLAG", header.EndFlag); sapParameter.AddParameter("CONF_NO", header.ConfirmationNumber.ToString()); sapParameter.AddParameter("CONF_CNT", header.ConfirmationCounter.ToString()); sapParameter.AddParameter("MULTI_FLAG", header.MultiFlag); sapParameter.AddParameter("IM_COUNT", header.MaterialCount); sapParameter.AddParameter("IM_TOTAL", header.MaterialQuantityTotal.ToString("0.000")); SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); foreach (MoConfirmationMaterialVo m in materials) { //rfcTable.Insert(); sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("ORDER_NUMBER", m.OrderNumber); sapParameterTable.AddParameter("IMDATE", dbTime.ToString("yyyyMMdd")); sapParameterTable.AddParameter("IMTIME", dbTime.ToString("HHmmss")); sapParameterTable.AddParameter("MATERIAL", m.MaterialNumber); sapParameterTable.AddParameter("BATCH", m.SapBatchNumber); sapParameterTable.AddParameter("V_BATCH", m.VendorBatchNumber); sapParameterTable.AddParameter("MOVETYPE", m.MovementType); sapParameterTable.AddParameter("ACT_QUANTITY", m.Quantity.ToString()); sapParameterTable.AddParameter("LGORT", m.StorageLocation); sapParameterTable.AddParameter("UNIT", m.Unit); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_ORDER_MOVEMENT", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); MoConfirmationResultVo resultVo = new MoConfirmationResultVo { OutSapFlag = sapFuntion.GetSAPValue("OUT_SAPFLAG") }; List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapTable.Rows) { SapMessageVo message = new SapMessageVo { OrderNumber = ConvertNull <string>(dr, "AUFNR"), MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; resultVo.MessageList.Add(message); } return(resultVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { PurchaseOrderInVo inVo = (PurchaseOrderInVo)vo; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "ZGTMMFG38_MES_SAP_INBOUND"); // SAPRFCNameEnum.RFC_DELIVERY_ORDER.GetValue()); SAPParameterList sapParameterTableInput = sapCommandAdapter.CreateParameterList(); SAPParameterList sapParameter; //create parameter for TABLES TB_LIFNR: STRUCTURE ZGTMMS62, if (inVo.LIFNRValueList != null && inVo.LIFNRValueList.Count > 0) { SAPParameterList sapParameterTableLIFNR = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.LIFNRValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("LIFNR", value); sapParameterTableLIFNR.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_LIFNR", sapParameterTableLIFNR); } //create parameter for TABLES TB_EBELN: STRUCTURE ZGTMMS63, if (inVo.EBELNValueList != null && inVo.EBELNValueList.Count > 0) { SAPParameterList sapParameterTableEBELN = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.EBELNValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("EBELN", value); sapParameterTableEBELN.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_EBELN", sapParameterTableEBELN); } //create parameter for TABLES TB_MATNR: STRUCTURE ZGTMMS64, if (inVo.MATNRValueList != null && inVo.MATNRValueList.Count > 0) { SAPParameterList sapParameterTableMATNR = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.MATNRValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("MATNR", value); sapParameterTableMATNR.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_MATNR", sapParameterTableMATNR); } //create parameter for TABLES TB_BEDAT_RANGE:STRUCTURE ZGTMMS65, if (!string.IsNullOrEmpty(inVo.BEFromDate) && !string.IsNullOrEmpty(inVo.BEToDate)) { SAPParameterList sapParameterTableBEDATRANGE = sapCommandAdapter.CreateParameterList(); sapParameterTableBEDATRANGE.AddParameter("SIGN", "I"); sapParameterTableBEDATRANGE.AddParameter("OPTION", "BT"); sapParameterTableBEDATRANGE.AddParameter("LOW", inVo.BEFromDate); sapParameterTableBEDATRANGE.AddParameter("HIGH", inVo.BEToDate); sapParameterTableInput.AddParameter("TB_BEDAT_RANGE", sapParameterTableBEDATRANGE); } //create parameter for TABLES TB_EINDT_RANGE: STRUCTURE ZGTMMS65, if (!string.IsNullOrEmpty(inVo.EINFromDate) && !string.IsNullOrEmpty(inVo.EINToDate)) { SAPParameterList sapParameterTableEINDTRANGE = sapCommandAdapter.CreateParameterList(); sapParameterTableEINDTRANGE.AddParameter("SIGN", "I"); sapParameterTableEINDTRANGE.AddParameter("OPTION", "BT"); sapParameterTableEINDTRANGE.AddParameter("LOW", inVo.EINFromDate); sapParameterTableEINDTRANGE.AddParameter("HIGH", inVo.EINToDate); sapParameterTableInput.AddParameter("TB_EINDT_RANGE", sapParameterTableEINDTRANGE); } sapParameterTableInput.AddParameter("IM_WERKS", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); sapParameterTableInput.AddParameter("IM_STATUS", inVo.Status); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameterTableInput); //PO Count Value string POCount = sapFuntion.GetSAPValue("EX_COUNT"); //PO INFO table data DataTable headerTable = sapFuntion.GetSAPTable("TB_OUTDATA"); // result message table data DataTable resultMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); PurchaseOrderDataVo outVo = new PurchaseOrderDataVo(); // get the Header data foreach (DataRow dr in headerTable.Rows) { PurchaseOrderDataVo curroutVo = new PurchaseOrderDataVo(); curroutVo.AFNAM = ConvertNull <string>(dr, "AFNAM"); curroutVo.AMTLC = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "AMTLC")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "AMTLC")).ToString().Replace(",", "")); try { curroutVo.BEDAT = DateTime.Parse(ConvertNull <string>(dr, "BEDAT")); } catch { curroutVo.BEDAT = DateTime.MinValue; } curroutVo.BISMT = ConvertNull <string>(dr, "BISMT"); try { curroutVo.BUDAT = DateTime.Parse(ConvertNull <string>(dr, "BUDAT")); } catch { curroutVo.BUDAT = DateTime.MinValue; } curroutVo.EBELN = ConvertNull <string>(dr, "EBELN"); curroutVo.EBELP = ConvertNull <string>(dr, "EBELP"); try { curroutVo.EINDT = DateTime.Parse(ConvertNull <string>(dr, "EINDT")); } catch { curroutVo.EINDT = DateTime.MinValue; } curroutVo.EKNAM = ConvertNull <string>(dr, "EKNAM"); curroutVo.ESTKZ_DESC = ConvertNull <string>(dr, "ESTKZ_DESC"); curroutVo.LGPBE = ConvertNull <string>(dr, "LGPBE"); curroutVo.LIFNR = ConvertNull <string>(dr, "LIFNR"); curroutVo.MAKTX = ConvertNull <string>(dr, "MAKTX"); curroutVo.MATNR = ConvertNull <string>(dr, "MATNR"); curroutVo.MEINS = ConvertNull <string>(dr, "MEINS"); curroutVo.MENGE = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "MENGE")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "MENGE")).ToString().Replace(",", "")); curroutVo.NAME1 = ConvertNull <string>(dr, "NAME1"); curroutVo.NETWR = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "NETWR")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "NETWR")).ToString().Replace(",", "")); curroutVo.OPENQ = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "OPENQ")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "OPENQ")).ToString().Replace(",", "")); curroutVo.OPNAMTLC = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "OPNAMTLC")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "OPNAMTLC")).ToString().Replace(",", "")); curroutVo.PEINH = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "PEINH")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "PEINH")).ToString().Replace(",", "")); curroutVo.STATUS = ConvertNull <string>(dr, "STATUS"); curroutVo.UNITP = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "UNITP")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "UNITP")).ToString().Replace(",", "")); curroutVo.VERSG = ConvertNull <string>(dr, "VERSG"); curroutVo.WAERS = ConvertNull <string>(dr, "WAERS"); curroutVo.WAERS_L = ConvertNull <string>(dr, "WAERS_L"); curroutVo.WEMNG = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "WEMNG")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "WEMNG")).ToString().Replace(",", "")); curroutVo.WRBTR = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "WRBTR")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "WRBTR")).ToString().Replace(",", "")); curroutVo.XBLNR = ConvertNull <string>(dr, "XBLNR"); curroutVo.ZAD_NAME = ConvertNull <string>(dr, "ZAD_NAME"); if (outVo.PurchaseOrderDataList == null) { outVo.PurchaseOrderDataList = new List <PurchaseOrderDataVo>(); } outVo.PurchaseOrderDataList.Add(curroutVo); } //get the Return Message data outVo.PurchaseOrderResultMessageList = new List <SapMessageVo>(); foreach (DataRow dr in resultMessageTable.Rows) { SapMessageVo message = new SapMessageVo(); message.MessageType = ConvertNull <string>(dr, "TYPE"); message.MessageClassId = ConvertNull <string>(dr, "ID"); message.MessageNumber = ConvertNull <string>(dr, "NUMBER"); message.Message = ConvertNull <string>(dr, "MESSAGE"); message.LogNumber = ConvertNull <string>(dr, "LOG_NO"); message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO"); message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"); message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"); message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"); message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4"); message.Parameter = ConvertNull <string>(dr, "PARAMETER"); message.Row = ConvertNull <string>(dr, "ROW"); message.Field = ConvertNull <string>(dr, "FIELD"); message.System = ConvertNull <string>(dr, "SYSTEM"); outVo.PurchaseOrderResultMessageList.Add(message); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { SubmitOutBoundVo inVo = (SubmitOutBoundVo)vo; inVo.SubmitOutBoundVoMessageList = new List <SapMessageVo>(); SubmitOutBoundVo outVo = new SubmitOutBoundVo(); outVo = inVo; outVo.SubmitOutBoundVoMessageList = new List <SapMessageVo>(); List <SubmitOutBoundVo> pos = new List <SubmitOutBoundVo>(); pos = inVo.SubmitOutBoundVoList; SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "Z_GTPPFG2301_GOODSMVT_CREATE"); SAPParameterList sapParameterTableList = sapCommandAdapter.CreateParameterList(); SAPParameterList sapParameterTable; //for (int ii = inVo.SubmitOutBoundVoList.Count - 1; ii >= 0; ii--) //{ foreach (SubmitOutBoundVo curVo in pos) { sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("MATERIAL", curVo.MATERIAL); sapParameterTable.AddParameter("PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); sapParameterTable.AddParameter("STGE_LOC", curVo.STGE_LOC); sapParameterTable.AddParameter("BATCH", curVo.BATCH); sapParameterTable.AddParameter("MOVE_TYPE", curVo.MOVE_TYPE); sapParameterTable.AddParameter("ENTRY_QNT", curVo.ENTRY_QNT); sapParameterTable.AddParameter("ENTRY_UOM", curVo.ENTRY_UOM); sapParameterTable.AddParameter("MOVE_STLOC", curVo.MOVE_STLOC); sapParameterTable.AddParameter("ZROW", curVo.ZROW); sapParameterTableList.AddParameterList(sapParameterTable); } //} SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_GOODSMVT_CODE", inVo.IM_GOODSMVT_CODE); sapParameter.AddParameter("IM_PSTNG_DATE", inVo.IM_PSTNG_DATE); sapParameter.AddParameter("IM_PR_UNAME", trxContext.UserData.UserCode); sapParameter.AddParameter("IM_HEADER_TXT", inVo.IM_HEADER_TXT); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapMessageTable.Rows) { SapMessageVo message = new SapMessageVo { MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4"), Row = ConvertNull <string>(dr, "ROW") }; outVo.SubmitOutBoundVoMessageList.Add(message); } SapMessageVo message1 = new SapMessageVo(); message1.Message = sapCommandAdapter.ToString(); outVo.SubmitOutBoundVoMessageList.Add(message1); return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { StockVo inVo = (StockVo)vo; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_STOCK.GetValue()); //create parameter SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // inVo.PlantCode); sapParameter.AddParameter("IM_LGORT", inVo.StorageLocationCode); //create table parameter and set to parameter SAPParameterList sapParameterTable = sapCommandAdapter.CreateParameterList(); foreach (string material in inVo.MaterialList) { SAPParameterList sapParameterRow = sapCommandAdapter.CreateParameterList(); sapParameterRow.AddParameter("MATERIAL", material); sapParameterTable.AddParameterList(sapParameterRow); } sapParameter.AddParameter("TB_MATERIAL", sapParameterTable); //create function SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); DataTable sapTable = sapFuntion.GetSAPTable("TB_STOCK_DATA"); StockVo outVo = new StockVo(); foreach (DataRow dr in sapTable.Rows) { string stockQty = ConvertNull <string>(dr, "UNRESTRICTED_STCK"); StockVo currOutVo = new StockVo { ItemNumber = ConvertNull <string>(dr, "MATERIAL"), WarehouseCode = ConvertNull <string>(dr, "LGORT"), InternalLot = ConvertNull <string>(dr, "BATCH"), SupplierCode = ConvertNull <string>(dr, "VENDOR"), SupplierName = ConvertNull <string>(dr, "V_DESC"), OrderStr = ConvertNull <string>(dr, "GR_DATE") + ConvertNull <string>(dr, "GR_TIME") + ConvertNull <string>(dr, "BATCH"), SapBatchNumber = ConvertNull <string>(dr, "BATCH"), VendorBatchNumber = ConvertNull <string>(dr, "V_BATCH"), StockQty = (int)Convert.ToDecimal(stockQty), UnrestrictedStock = (int)Convert.ToDecimal(stockQty), PlanToConsume = (int)Convert.ToDecimal(stockQty), StockReserve = (int)Convert.ToDecimal(stockQty), StockReserve2 = (int)Convert.ToDecimal(stockQty) }; outVo.StockListVo.Add(currOutVo); } List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapMessageTable.Rows) { SapMessageVo message = new SapMessageVo { MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; messageList.Add(message); } outVo.SapMessageListVo = messageList; List <string> errorMaterialList = new List <string>(); DataTable errorMaterialTable = sapFuntion.GetSAPTable("TB_ERROR_MATERIAL"); foreach (DataRow dr in errorMaterialTable.Rows) { string errorMaterial = ConvertNull <string>(dr, "MATERIAL"); errorMaterialList.Add(errorMaterial); } outVo.ErrorMaterialList = errorMaterialList; return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { PurchaseOrderInVo inVo = (PurchaseOrderInVo)vo; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "ZGTMMFG38_MES_SAP_INBOUND"); // SAPRFCNameEnum.RFC_DELIVERY_ORDER.GetValue()); SAPParameterList sapParameterTableInput = sapCommandAdapter.CreateParameterList(); SAPParameterList sapParameter; //create parameter for TABLES TB_LIFNR: STRUCTURE ZGTMMS62, if (inVo.LIFNRValueList != null && inVo.LIFNRValueList.Count > 0) { SAPParameterList sapParameterTableLIFNR = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.LIFNRValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("LIFNR", value); sapParameterTableLIFNR.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_LIFNR", sapParameterTableLIFNR); } //create parameter for TABLES TB_EBELN: STRUCTURE ZGTMMS63, if (inVo.EBELNValueList != null && inVo.EBELNValueList.Count > 0) { SAPParameterList sapParameterTableEBELN = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.EBELNValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("EBELN", value); sapParameterTableEBELN.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_EBELN", sapParameterTableEBELN); } //create parameter for TABLES TB_MATNR: STRUCTURE ZGTMMS64, if (inVo.MATNRValueList != null && inVo.MATNRValueList.Count > 0) { SAPParameterList sapParameterTableMATNR = sapCommandAdapter.CreateParameterList(); foreach (String value in inVo.MATNRValueList) { sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("MATNR", value); sapParameterTableMATNR.AddParameterList(sapParameter); } sapParameterTableInput.AddParameter("TB_MATNR", sapParameterTableMATNR); } //create parameter for TABLES TB_BEDAT_RANGE:STRUCTURE ZGTMMS65, if (!string.IsNullOrEmpty(inVo.BEFromDate) && !string.IsNullOrEmpty(inVo.BEToDate)) { SAPParameterList sapParameterTableBEDATRANGE = sapCommandAdapter.CreateParameterList(); sapParameterTableBEDATRANGE.AddParameter("SIGN", "I"); sapParameterTableBEDATRANGE.AddParameter("OPTION", "BT"); sapParameterTableBEDATRANGE.AddParameter("LOW", inVo.BEFromDate); sapParameterTableBEDATRANGE.AddParameter("HIGH", inVo.BEToDate); sapParameterTableInput.AddParameter("TB_BEDAT_RANGE", sapParameterTableBEDATRANGE); } //create parameter for TABLES TB_EINDT_RANGE: STRUCTURE ZGTMMS65, if (!string.IsNullOrEmpty(inVo.EINFromDate) && !string.IsNullOrEmpty(inVo.EINToDate)) { SAPParameterList sapParameterTableEINDTRANGE = sapCommandAdapter.CreateParameterList(); sapParameterTableEINDTRANGE.AddParameter("SIGN", "I"); sapParameterTableEINDTRANGE.AddParameter("OPTION", "BT"); sapParameterTableEINDTRANGE.AddParameter("LOW", inVo.EINFromDate); sapParameterTableEINDTRANGE.AddParameter("HIGH", inVo.EINToDate); sapParameterTableInput.AddParameter("TB_EINDT_RANGE", sapParameterTableEINDTRANGE); } sapParameterTableInput.AddParameter("IM_WERKS", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); sapParameterTableInput.AddParameter("IM_STATUS", inVo.Status); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameterTableInput); //PO Count Value string POCount = sapFuntion.GetSAPValue("EX_COUNT"); //PO INFO table data DataTable headerTable = sapFuntion.GetSAPTable("TB_OUTDATA"); // result message table data DataTable resultMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); PurchaseOrderOutVo outVo = new PurchaseOrderOutVo(); // get the Header data foreach (DataRow dr in headerTable.Rows) { PurchaseOrderOutVo curroutVo = new PurchaseOrderOutVo(); curroutVo.Material = ConvertNull <string>(dr, "MATNR"); curroutVo.MaterialName = ConvertNull <string>(dr, "MAKTX"); curroutVo.Supplier = ConvertNull <string>(dr, "LIFNR"); curroutVo.SupplierName = ConvertNull <string>(dr, "NAME1"); curroutVo.PurchaseOrderNumber = ConvertNull <string>(dr, "EBELN"); curroutVo.POLineNumber = ConvertNull <string>(dr, "EBELP"); curroutVo.OrderQuantity = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "MENGE")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "MENGE")).ToString().Replace(",", "")); curroutVo.OpenQuantity = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "OPENQ")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "OPENQ")).ToString().Replace(",", "")); // decimal.Parse(ConvertNull<string>(dr, "OPENQ")); curroutVo.ReceivedQuantity = decimal.Parse(string.IsNullOrEmpty((ConvertNull <string>(dr, "WEMNG")).ToString().Trim()) ? "0" : (ConvertNull <string>(dr, "WEMNG")).ToString().Replace(",", "")); //decimal.Parse(ConvertNull<string>(dr, "WEMNG")); curroutVo.Unit = ConvertNull <string>(dr, "MEINS"); if (outVo.PurchaseOrderList == null) { outVo.PurchaseOrderList = new List <PurchaseOrderOutVo>(); } if (!string.IsNullOrWhiteSpace(POCount)) { outVo.POCount = Convert.ToInt32(POCount); } outVo.PurchaseOrderList.Add(curroutVo); } //get the Return Message data outVo.PurchaseOrderResultMessageList = new List <SapMessageVo>(); foreach (DataRow dr in resultMessageTable.Rows) { SapMessageVo message = new SapMessageVo(); message.MessageType = ConvertNull <string>(dr, "TYPE"); message.MessageClassId = ConvertNull <string>(dr, "ID"); message.MessageNumber = ConvertNull <string>(dr, "NUMBER"); message.Message = ConvertNull <string>(dr, "MESSAGE"); message.LogNumber = ConvertNull <string>(dr, "LOG_NO"); message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO"); message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"); message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"); message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"); message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4"); message.Parameter = ConvertNull <string>(dr, "PARAMETER"); message.Row = ConvertNull <string>(dr, "ROW"); message.Field = ConvertNull <string>(dr, "FIELD"); message.System = ConvertNull <string>(dr, "SYSTEM"); outVo.PurchaseOrderResultMessageList.Add(message); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { int totalQty = 0; int imCount = 0; ValueObjectList <DispatchReportItemDtlVo> LIST = new ValueObjectList <DispatchReportItemDtlVo>(); //if (vo is ValueObjectList<DispatchReportItemDtlVo>) //{ // LIST = (ValueObjectList<DispatchReportItemDtlVo>)vo; //} //else //{ // LIST.add((DispatchReportItemDtlVo)vo); //} //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "Z_GTSDFG7401_SCAN_DELIVERY"); // SAPRFCNameEnum.RFC_PICKING_LIST.GetValue()); SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); DispatchReportItemDtlVo inVo = (DispatchReportItemDtlVo)vo; //foreach (DispatchReportItemDtlVo inVo in LIST.GetList()) //{ //int pickedQuantity = 0; //foreach (DispatchReportItemDtlVo currVo in inVo.DipatchReportItemDetailsList) //{ // pickedQuantity += currVo.ItemQuantity; //} //create parameter for table IT_LIPS SAPParameterList sapParameterTable = sapCommandAdapter.CreateParameterList(); //sapParameterTable.AddParameter("SIGN", "I"); //value set from invo //sapParameterTable.AddParameter("OPTION", "EQ"); sapParameterTable.AddParameter("VBELN", ("0000000000" + inVo.DeliveryOrderNo.ToString().Trim()).Substring(("0000000000" + inVo.DeliveryOrderNo.ToString().Trim()).Length - 10, 10)); sapParameterTable.AddParameter("POSNR", inVo.DeliveryOrderUnit.ToString()); sapParameterTable.AddParameter("PIKMG", inVo.ItemQuantity.ToString()); // picked quantity sapParameterTable.AddParameter("CHARG", inVo.LotNo); // picked quantity sapParameterTable.AddParameter("WADAT_IST", inVo.ActualDeliveryDate.ToString("yyyyMMdd")); // picked quantity sapParameterTable.AddParameter("LGORT", inVo.StorageLocation); // picked quantity sapParameterTableLists.AddParameterList(sapParameterTable); //totalQty += pickedQuantity; imCount++; //} //create parameter for table Z_GTSDFG7301_DELIVERY_RFC SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); // "1100"); sapParameter.AddParameter("IM_COUNT", 1); sapParameter.AddParameter("IM_TOTAL", inVo.ItemQuantity.ToString()); sapParameter.AddParameter("IT_LIPS", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); DataTable resultMessageTable = sapFuntion.GetSAPTable("ET_RETURN"); DispatchReportItemDtlVo outVo = new DispatchReportItemDtlVo(); // outVo.DeliveryOrderResultMessageList = new List<DeliveryOrderResultMessageVo>(); outVo.DispatchReportResultMessageList = new List <SapMessageVo>(); foreach (DataRow dr in resultMessageTable.Rows) { SapMessageVo message = new SapMessageVo(); message.MessageType = ConvertNull <string>(dr, "TYPE"); message.MessageClassId = ConvertNull <string>(dr, "ID"); message.MessageNumber = ConvertNull <string>(dr, "NUMBER"); message.Message = ConvertNull <string>(dr, "MESSAGE"); message.LogNumber = ConvertNull <string>(dr, "LOG_NO"); message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO"); message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"); message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"); message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"); message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4"); outVo.DispatchReportResultMessageList.Add(message); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { string DEFAULT_DATE_FORMAT = "0000-00-00"; string DEFAULT_TIME_FORMAT = "00:00:00"; ManufacturingOrderVo inVo = (ManufacturingOrderVo)vo; List <MRPControllerRangeVo> mrpControllers = inVo.MRPControllerRangeListVo; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "Z_GTPPFG1201_MO_OUT");// SAPRFCNameEnum.RFC_MANUFACTURING_ORDER.GetValue()); //create parameter SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); if (!string.IsNullOrEmpty(inVo.FromDate)) { sapParameter.AddParameter("IM_FROM_DATE", inVo.FromDate); } if (!string.IsNullOrEmpty(inVo.ToDate)) { sapParameter.AddParameter("IM_TO_DATE", inVo.ToDate); } if (!string.IsNullOrEmpty(inVo.OrderType)) { sapParameter.AddParameter("IM_ORDERTYPE", inVo.OrderType); } if (!string.IsNullOrEmpty(inVo.WorkCenter)) { sapParameter.AddParameter("IM_WORKCENTER", inVo.WorkCenter); } if (!string.IsNullOrEmpty(inVo.MoNumberFrom)) { sapParameter.AddParameter("IM_FROM_MONO", inVo.MoNumberFrom); } if (!string.IsNullOrEmpty(inVo.MoNumberTo)) { sapParameter.AddParameter("IM_TO_MONO", inVo.MoNumberTo); } if (!string.IsNullOrEmpty(inVo.Shift)) { sapParameter.AddParameter("IM_SHIFT", inVo.Shift); } if (inVo.ActQty != null) { sapParameter.AddParameter("IM_ACTQTY", inVo.ActQty); } if (!string.IsNullOrEmpty(inVo.Line)) { sapParameter.AddParameter("IM_LINE", inVo.Line); } sapParameter.AddParameter("IM_SOURCE", inVo.Source); sapParameter.AddParameter("IM_BOM", inVo.IncludeBOM); if (!string.IsNullOrEmpty(inVo.IncludeDBSAVE)) { sapParameter.AddParameter("IM_DBSAVE", inVo.IncludeDBSAVE); } SAPParameterList sapParameterTable; SAPParameterList sapParameterTableLists = sapCommandAdapter.CreateParameterList(); sapParameterTable = sapCommandAdapter.CreateParameterList(); foreach (MRPControllerRangeVo mrp in mrpControllers) { sapParameterTable.AddParameter("SIGN", mrp.Sign); sapParameterTable.AddParameter("HIGH", mrp.High); sapParameterTable.AddParameter("OPTION", mrp.Option); sapParameterTable.AddParameter("LOW", mrp.Low); sapParameterTableLists.AddParameterList(sapParameterTable); } sapParameter.AddParameter("TB_MRP_CNTRL_RANGE", sapParameterTableLists); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); //MO data DataTable sapMOTable = sapFuntion.GetSAPTable("TB_MANUFACTURING_ORDER"); // result BOM data DataTable sapMODetailTable = sapFuntion.GetSAPTable("TB_ORDER_DETAIL"); ManufacturingOrderVo outVo = new ManufacturingOrderVo(); foreach (DataRow dr in sapMOTable.Rows) { ManufacturingOrderVo currOutVo = new ManufacturingOrderVo(); string datetimeval; currOutVo.MoNumber = ConvertNull <string>(dr, "ORDER_NUMBER").TrimStart('0'); currOutVo.ItemCd = ConvertNull <string>(dr, "MATERIAL").TrimStart('0'); currOutVo.ItemName = ConvertNull <string>(dr, "MATERIAL_TEXT"); currOutVo.Shift = ConvertNull <string>(dr, "SHIFT"); currOutVo.TargetQty = ConvertNull <string>(dr, "TARGET_QUANTITY"); currOutVo.OrderType = ConvertNull <string>(dr, "ORDER_TYPE"); currOutVo.MrpController = ConvertNull <string>(dr, "MRP_CONTROLLER"); currOutVo.Status = ConvertNull <string>(dr, "SYSTEM_STATUS"); currOutVo.WorkCenter = ConvertNull <string>(dr, "WORK_CENTER"); currOutVo.ProductionDate = ConvertNull <string>(dr, "START_DATE"); currOutVo.StartTime = ConvertNull <string>(dr, "START_TIME"); currOutVo.FinishDate = ConvertNull <string>(dr, "FINISH_DATE"); currOutVo.FinishTime = ConvertNull <string>(dr, "FINISH_TIME"); currOutVo.GoodsReceipt = ConvertNull <string>(dr, "GOODS_RECIPIENT");//没有数据 currOutVo.PloductionPlant = ConvertNull <string>(dr, "PRODUCTION_PLANT"); datetimeval = ConvertNull <string>(dr, "EXPL_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ExplDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "ROUTING_NO"); if (!string.IsNullOrWhiteSpace(datetimeval)) { currOutVo.RoutingNo = Convert.ToInt32(datetimeval); } datetimeval = ConvertNull <string>(dr, "RESERVATION_NUMBER"); if (!string.IsNullOrWhiteSpace(datetimeval)) { currOutVo.ReservationNumber = Convert.ToInt32(datetimeval); } datetimeval = ConvertNull <string>(dr, "ACTUAL_RELEASE_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ActualReleaseDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "PRODUCTION_FINISH_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ProductionFinishDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "PRODUCTION_START_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ProductionStartDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "ACTUAL_START_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ActualStartDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "ACTUAL_FINISH_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.ActualFinishDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } datetimeval = ConvertNull <string>(dr, "SCRAP"); currOutVo.Scrap = Convert.ToDecimal(datetimeval); currOutVo.Unit = ConvertNull <string>(dr, "UNIT"); currOutVo.EnteredBy = ConvertNull <string>(dr, "ENTERED_BY"); datetimeval = ConvertNull <string>(dr, "ENTER_DATE"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_DATE_FORMAT)) { currOutVo.EnterDate = DateTime.ParseExact(datetimeval, "yyyy-MM-dd", null); } currOutVo.DeletionFlag = ConvertNull <string>(dr, "DELETION_FLAG"); datetimeval = ConvertNull <string>(dr, "CONF_NO"); if (!string.IsNullOrWhiteSpace(datetimeval)) { currOutVo.ConfNo = Convert.ToInt32(datetimeval); } datetimeval = ConvertNull <string>(dr, "CONF_CNT"); if (!string.IsNullOrWhiteSpace(datetimeval)) { currOutVo.ConfCnt = Convert.ToInt32(datetimeval); } datetimeval = ConvertNull <string>(dr, "SCHED_FIN_TIME"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_TIME_FORMAT)) { currOutVo.SchedFinTime = DateTime.ParseExact(ConvertNull <string>(dr, "SCHED_FIN_TIME"), "HH:mm:ss", null); } datetimeval = ConvertNull <string>(dr, "SCHED_START_TIME"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_TIME_FORMAT)) { currOutVo.SchedStartTime = DateTime.ParseExact(ConvertNull <string>(dr, "SCHED_START_TIME"), "HH:mm:ss", null); } datetimeval = ConvertNull <string>(dr, "ACTUAL_START_TIME"); if (!string.IsNullOrWhiteSpace(datetimeval) && !string.Equals(datetimeval, DEFAULT_TIME_FORMAT)) { currOutVo.ActualStartTime = DateTime.ParseExact(ConvertNull <string>(dr, "ACTUAL_START_TIME"), "HH:mm:ss", null); } datetimeval = ConvertNull <string>(dr, "CONFIRMED_QUANTITY"); if (!string.IsNullOrWhiteSpace(datetimeval)) { currOutVo.ConfirmedQuantity = Convert.ToDecimal(datetimeval); } currOutVo.PlanPlant = ConvertNull <string>(dr, "PLAN_PLANT"); currOutVo.Batch = ConvertNull <string>(dr, "BATCH"); currOutVo.PVersion = ConvertNull <string>(dr, "P_VERSION"); currOutVo.WKName = ConvertNull <string>(dr, "WK_NAMAE"); currOutVo.CostName = ConvertNull <string>(dr, "COST_NAME"); currOutVo.CostCenter = ConvertNull <string>(dr, "COST_CENTER"); currOutVo.Wempf = ConvertNull <string>(dr, "GOODS_RECIPIENT");//Not Exist in RFC but Exist in DB currOutVo.rowsall = sapMODetailTable.Rows.Count; if (sapMODetailTable != null && sapMODetailTable.Rows.Count > 0) { DataRow[] drDetail = sapMODetailTable.Select("ORDER_NUMBER = '" + ConvertNull <string>(dr, "ORDER_NUMBER") + "'"); currOutVo.rows = drDetail.Length; if (drDetail.Length > 0) { currOutVo.MoConfirmationMaterialListVo = new List <MoConfirmationMaterialVo>(); foreach (DataRow currdrdetail in drDetail) { MoConfirmationMaterialVo detailOutVo = new MoConfirmationMaterialVo(); detailOutVo.OrderNumber = ConvertNull <string>(currdrdetail, "ORDER_NUMBER").TrimStart('0'); detailOutVo.MaterialNumber = ConvertNull <string>(currdrdetail, "MATERIAL").TrimStart('0'); detailOutVo.MaterialOld = ConvertNull <string>(currdrdetail, "MATERIAL_OLD").TrimStart('0'); detailOutVo.AlternateGroup = ConvertNull <string>(currdrdetail, "ALT_GROUP"); detailOutVo.SapBatchNumber = ConvertNull <string>(currdrdetail, "BATCH"); detailOutVo.ProcureType = ConvertNull <string>(currdrdetail, "PROCURE_TYPE"); detailOutVo.VendorBatchNumber = ConvertNull <string>(currdrdetail, "VENDOR_BATCH"); detailOutVo.SapVendor = ConvertNull <string>(currdrdetail, "VENDOR"); detailOutVo.StorageLocation = ConvertNull <string>(currdrdetail, "LGORT"); detailOutVo.Quantity = (string.IsNullOrEmpty(ConvertNull <string>(currdrdetail, "QUANTITY")) ? 0M : Convert.ToDecimal(ConvertNull <string>(currdrdetail, "QUANTITY"))); detailOutVo.Unit = ConvertNull <string>(currdrdetail, "UNIT"); detailOutVo.MovementType = ConvertNull <string>(currdrdetail, "MOVETYPE"); currOutVo.MoConfirmationMaterialListVo.Add(detailOutVo); } } } outVo.ManufacturingOrderListVo.Add(currOutVo); } foreach (DataRow currdrdetail in sapMODetailTable.Rows) { MoConfirmationMaterialVo detailOutVo = new MoConfirmationMaterialVo(); detailOutVo.OrderNumber = ConvertNull <string>(currdrdetail, "ORDER_NUMBER").TrimStart('0'); detailOutVo.MaterialNumber = ConvertNull <string>(currdrdetail, "MATERIAL").TrimStart('0'); detailOutVo.MaterialOld = ConvertNull <string>(currdrdetail, "MATERIAL_OLD").TrimStart('0'); detailOutVo.AlternateGroup = ConvertNull <string>(currdrdetail, "ALT_GROUP"); detailOutVo.SapBatchNumber = ConvertNull <string>(currdrdetail, "BATCH"); detailOutVo.ProcureType = ConvertNull <string>(currdrdetail, "PROCURE_TYPE"); detailOutVo.VendorBatchNumber = ConvertNull <string>(currdrdetail, "VENDOR_BATCH"); detailOutVo.SapVendor = ConvertNull <string>(currdrdetail, "VENDOR"); detailOutVo.StorageLocation = ConvertNull <string>(currdrdetail, "LGORT"); detailOutVo.Quantity = (string.IsNullOrEmpty(ConvertNull <string>(currdrdetail, "QUANTITY")) ? 0M : Convert.ToDecimal(ConvertNull <string>(currdrdetail, "QUANTITY"))); detailOutVo.Unit = ConvertNull <string>(currdrdetail, "UNIT"); detailOutVo.MovementType = ConvertNull <string>(currdrdetail, "MOVETYPE"); outVo.MoConfirmationMaterialListVo.Add(detailOutVo); } outVo.SapMessageListVo = new List <SapMessageVo>(); DataTable sapMessageTable = sapFuntion.GetSAPTable("TB_RETURN"); foreach (DataRow dr in sapMessageTable.Rows) { SapMessageVo message = new SapMessageVo { MessageType = ConvertNull <string>(dr, "TYPE"), MessageClassId = ConvertNull <string>(dr, "ID"), MessageNumber = ConvertNull <string>(dr, "NUMBER"), LogNumber = ConvertNull <string>(dr, "MESSAGE"), LogMessageNumber = ConvertNull <string>(dr, "LOG_NO"), MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"), MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"), MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"), MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4") }; outVo.SapMessageListVo.Add(message); } return(outVo); }
public override ValueObject Execute(TransactionContext trxContext, ValueObject vo) { PoGoodReceiptVo inVo = (PoGoodReceiptVo)vo; List <PoGoodReceiptVo> pos = inVo.PoGoodReceiptList; //create command SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "ZGTMMFG39_MES_TO_SAP"); // SAPRFCNameEnum.RFC_DELIVERY_ORDER.GetValue()); //create parameter for table IT_WERKS SAPParameterList sapParameterTableList = sapCommandAdapter.CreateParameterList(); SAPParameterList sapParameterTable; ////multiple PO details set //foreach (PoGoodReceiptVo m in pos) //{ // sapParameterTable = sapCommandAdapter.CreateParameterList(); // //DOCU_DATE:DATE, POSTING_DATE:DATE, DELIV_NOTE:CHAR16, BATCH:CHAR10, PO_NUM:CHAR10, ITEM:NUM(5), MATERIAL:CHAR18, QUAN:BCD[7:3], VENDRBATCH:CHAR15 // sapParameterTable.AddParameter("DOCU_DATE", m.DocumentDate); //Document date // sapParameterTable.AddParameter("POSTING_DATE", m.PostingDate); //Posting date // sapParameterTable.AddParameter("DELIV_NOTE", m.DeliveryNote); //Delivery Note // sapParameterTable.AddParameter("BATCH", m.Batch); //Batch // sapParameterTable.AddParameter("PO_NUM", m.PurchaseOrderNumber); //PO Number // sapParameterTable.AddParameter("ITEM", m.POItem); //PO Item // sapParameterTable.AddParameter("MATERIAL", m.Material); //Material // sapParameterTable.AddParameter("QUAN", m.Quantity); //Quantity in Unit of Entry // sapParameterTable.AddParameter("VENDRBATCH", m.SupplierLotNo); //Vendor Batch // sapParameterTableList.AddParameterList(sapParameterTable); //} for (int ii = pos.Count - 1; ii >= 0; ii--) { sapParameterTable = sapCommandAdapter.CreateParameterList(); sapParameterTable.AddParameter("DOCU_DATE", pos[ii].DocumentDate); //Document date sapParameterTable.AddParameter("POSTING_DATE", pos[ii].PostingDate); //Posting date sapParameterTable.AddParameter("DELIV_NOTE", pos[ii].DeliveryNote); //Delivery Note sapParameterTable.AddParameter("BATCH", pos[ii].Batch); //Batch sapParameterTable.AddParameter("PO_NUM", pos[ii].PurchaseOrderNumber); //PO Number sapParameterTable.AddParameter("ITEM", pos[ii].POItem); //PO Item sapParameterTable.AddParameter("MATERIAL", pos[ii].Material); //Material sapParameterTable.AddParameter("QUAN", pos[ii].Quantity); //Quantity in Unit of Entry sapParameterTable.AddParameter("VENDRBATCH", pos[ii].SupplierLotNo); //Vendor Batch sapParameterTableList.AddParameterList(sapParameterTable); } SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList(); sapParameter.AddParameter("IM_PLANT", ServerConfigurationDataTypeEnum.DEFAULT_SAP_PLANT_CODE.GetValue()); sapParameter.AddParameter("TB_INPUT", sapParameterTableList); SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter); List <SapMessageVo> messageList = new List <SapMessageVo>(); DataTable sapTable = sapFuntion.GetSAPTable("TB_RETURN"); PoGoodReceiptVo resultVo = new Vo.PoGoodReceiptVo(); //get the Return Message data resultVo.PoGoodReceiptResultMessageList = new List <SapMessageVo>(); //if (sapTable != null && sapTable.Rows.Count > 0) //{ // DataView dv = sapTable.DefaultView; // dv.Sort = "ROW desc"; // sapTable = dv.ToTable(); //} foreach (DataRow dr in sapTable.Rows) { SapMessageVo message = new SapMessageVo(); message.MessageType = ConvertNull <string>(dr, "TYPE"); message.MessageClassId = ConvertNull <string>(dr, "ID"); message.MessageNumber = ConvertNull <string>(dr, "NUMBER"); message.Message = ConvertNull <string>(dr, "MESSAGE"); message.LogNumber = ConvertNull <string>(dr, "LOG_NO"); message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO"); message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1"); message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2"); message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3"); message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4"); message.Parameter = ConvertNull <string>(dr, "PARAMETER"); message.Row = ConvertNull <string>(dr, "ROW"); message.Field = ConvertNull <string>(dr, "FIELD"); message.System = ConvertNull <string>(dr, "SYSTEM"); resultVo.PoGoodReceiptResultMessageList.Add(message); } return(resultVo); }