Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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)
        {
            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);
        }