Ejemplo n.º 1
0
        private List <HandHeldCounterHold> SAPHandHeldCounterHoldGetLocation(string productCode, string sapProductCode, string warehouseCode, string branchCode)
        {
            List <HandHeldCounterHold> products = new List <HandHeldCounterHold>();

            //Zdd_Get_Material_Master
            using (var sapConnection = new SAPConnection(GlobalContext.SapDestination))
            {
                using (var proxy = new SAPProxy.UWProxy())
                {
                    proxy.Connection = sapConnection;


                    SAPProxy.ZSTRC_MATERIAL_MASTER e_mat_strc = new SAPProxy.ZSTRC_MATERIAL_MASTER();
                    SAPProxy.MEANTable             tb_barcode = new SAPProxy.MEANTable();
                    SAPProxy.ZMM_ASSIGNLOCTable    assign_loc = new SAPProxy.ZMM_ASSIGNLOCTable();
                    SAPProxy.MARDTable             mard       = new SAPProxy.MARDTable();
                    SAPProxy.MARATable             mara       = new SAPProxy.MARATable();
                    SAPProxy.MARMTable             marm       = new SAPProxy.MARMTable();
                    SAPProxy.MLGTTable             mlgt       = new SAPProxy.MLGTTable();

                    proxy.Zdd_Get_Material_Master(sapProductCode
                                                  , out e_mat_strc
                                                  , ref tb_barcode
                                                  , ref assign_loc
                                                  , ref mard
                                                  , ref mara
                                                  , ref marm
                                                  , ref mlgt);

                    assign_loc.SortBy("BIN_CODE", "ASC");
                    //string lastLocation = string.Empty;
                    foreach (SAPProxy.ZMM_ASSIGNLOC item in assign_loc)
                    {
                        if (item.Storage_Loc == warehouseCode) //&& lastLocation != item.Bin_Code)
                        {
                            //item.Unitofmeasure
                            //lastLocation = item.Bin_Code;
                            //var product = ProductLocationGetByProductCode(productCode, warehouseCode, branchCode);
                            var product = ProductInfoGet(branchCode, productCode, item.Unitofmeasure);
                            if (product != null)
                            {
                                products.Add(new HandHeldCounterHold
                                {
                                    Productcode = product.ProductCode,
                                    Productname = product.ProductName,
                                    Location    = item.Bin_Code,
                                    Unitcode    = product.Uom,
                                    Unitname    = product.UomName,
                                    Quantity    = 0
                                });
                            }
                        }
                    }
                }
            }

            return(products);
        }
Ejemplo n.º 2
0
        private string SAPGetLocation(string productCode, string unitCode, string wareHouseCode, string branchCode)
        {
            string location = string.Empty;

            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    productCode = SapProductCodeFormated(productCode);

                    prx.Connection = sapConnection;

                    SAPProxy.ZSTRC_MATERIAL_MASTER strc          = new SAPProxy.ZSTRC_MATERIAL_MASTER();
                    SAPProxy.MEANTable             MeanTB        = new SAPProxy.MEANTable();
                    SAPProxy.MARDTable             MardTB        = new SAPProxy.MARDTable();
                    SAPProxy.MARATable             MaraTB        = new SAPProxy.MARATable();
                    SAPProxy.MARMTable             MarmTB        = new SAPProxy.MARMTable();
                    SAPProxy.ZMM_ASSIGNLOCTable    TB_MMLOCATION = new SAPProxy.ZMM_ASSIGNLOCTable();
                    SAPProxy.MLGTTable             TB_WHLOCATION = new SAPProxy.MLGTTable();

                    var ProductCode            = productCode;
                    var ProductMain            = productCode;
                    SAPProxy.MARATable MaraTB2 = new SAPProxy.MARATable();
                    prx.Zdd_Get_Material_Master(ProductCode, out strc, ref MeanTB, ref TB_MMLOCATION, ref MardTB, ref MaraTB2, ref MarmTB, ref TB_WHLOCATION);

                    foreach (SAPProxy.ZMM_ASSIGNLOC item in TB_MMLOCATION)
                    {
                        string sWH = "11";
                        if (branchCode == "1200")
                        {
                            sWH = "12";
                        }
                        if (item.Unitofmeasure == unitCode && item.Storage_Loc == wareHouseCode)
                        {
                            location = item.Bin_Code;
                            break;
                        }
                        else if (item.Unitofmeasure == unitCode && item.Storage_Loc.Substring(0, 2) == sWH)
                        {
                            location = item.Bin_Code;
                            break;
                        }
                    }

                    foreach (SAPProxy.MLGT item in TB_WHLOCATION)
                    {
                        location = item.Lgpla;
                        break;
                    }
                }
            }

            return(location);
        }
Ejemplo n.º 3
0
        private double SAPGetBalanceQuantity(string productCode, string warehouseCode, string unitCode, string branchCode)
        {
            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    prx.Connection = sapConnection;
                    double dQty = 0.00;
                    SAPProxy.BAPIRETURN     Return       = new SAPProxy.BAPIRETURN();
                    SAPProxy.BAPIMGVMATNR   Material_Evg = new SAPProxy.BAPIMGVMATNR();
                    SAPProxy.BAPIWMDVETable tbWmdVex     = new SAPProxy.BAPIWMDVETable();
                    SAPProxy.BAPIWMDVSTable tbWmdVsx     = new SAPProxy.BAPIWMDVSTable();
                    var     sapProductCode     = SapProductCodeFormated(productCode);
                    string  sPlant             = branchCode;
                    var     sCheck_Rule        = "B";
                    var     sItm_Number        = "000000";
                    var     sBatch             = "";
                    var     sCustomer          = "";
                    var     sDoc_Number        = "";
                    string  sRead_Atp_Lock_X   = "";
                    var     sWbs_Elem          = "";
                    var     sStock_Ind         = "";
                    string  sDialogFlag        = "";
                    var     sEndLeadTme        = "";
                    var     sDec_ForRounding_X = "";
                    var     sRead_Atp_Lock     = "";
                    decimal dlAv_Qty_Plt       = 0;
                    short   shDec_ForRounding  = 0;
                    prx.Bapi_Material_Availability(sBatch, sCheck_Rule, sCustomer, shDec_ForRounding
                                                   , sDec_ForRounding_X, sDoc_Number, sItm_Number
                                                   , sapProductCode, Material_Evg, sPlant, sRead_Atp_Lock
                                                   , sRead_Atp_Lock_X, warehouseCode, sStock_Ind, unitCode
                                                   , sWbs_Elem, out dlAv_Qty_Plt, out sDialogFlag
                                                   , out sEndLeadTme, out Return, ref tbWmdVex, ref tbWmdVsx);

                    foreach (SAPProxy.BAPIWMDVE item in tbWmdVex)
                    {
                        dQty = Convert.ToDouble(item.Com_Qty);
                    }


                    return(dQty);
                }
            }
        }
Ejemplo n.º 4
0
        private double SAPGetBalanceQuantity(string productCode, string warehouseCode, string unitCode, string branchCode)
        {
            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    prx.Connection = sapConnection;
                    double dQty = 0.00;
                    SAPProxy.BAPIRETURN     Return       = new SAPProxy.BAPIRETURN();
                    SAPProxy.BAPIMGVMATNR   Material_Evg = new SAPProxy.BAPIMGVMATNR();
                    SAPProxy.BAPIWMDVETable tbWmdVex     = new SAPProxy.BAPIWMDVETable();
                    SAPProxy.BAPIWMDVSTable tbWmdVsx     = new SAPProxy.BAPIWMDVSTable();
                    productCode = SapProductCodeFormated(productCode);
                    var     checkRule       = "B";
                    var     itemNumber      = "000000";
                    var     batch           = "";
                    var     customer        = "";
                    var     docNumber       = "";
                    string  readAtpLockX    = "";
                    var     wbsElement      = "";
                    var     stockIndex      = "";
                    string  dialogFlag      = "";
                    var     endLeadTime     = "";
                    var     decForRoundingX = "";
                    var     readAtpLock     = "";
                    decimal dlAv_Qty_Plt    = 0;
                    short   decForRounding  = 0;
                    prx.Bapi_Material_Availability(batch, checkRule, customer, decForRounding
                                                   , decForRoundingX, docNumber, itemNumber
                                                   , productCode, Material_Evg, branchCode, readAtpLock
                                                   , readAtpLockX, warehouseCode, stockIndex, unitCode
                                                   , wbsElement, out dlAv_Qty_Plt, out dialogFlag
                                                   , out endLeadTime, out Return, ref tbWmdVex, ref tbWmdVsx);

                    foreach (SAPProxy.BAPIWMDVE item in tbWmdVex)
                    {
                        dQty = Convert.ToDouble(item.Com_Qty);
                    }

                    return(dQty);
                }
            }
        }
Ejemplo n.º 5
0
        private List <Location> SAPGetLocationAllUnit(string productCode, string unitCode, string wareHouseCode)
        {
            List <Location> locations = new List <Location>();

            using (SAP.Connector.SAPConnection sapConnection = new SAP.Connector.SAPConnection(GlobalContext.SapDestination))
            {
                using (SAPProxy.UWProxy prx = new SAPProxy.UWProxy())
                {
                    var sapProductCode = SapProductCodeFormated(productCode);

                    prx.Connection = sapConnection;

                    SAPProxy.ZSTRC_MATERIAL_MASTER strc          = new SAPProxy.ZSTRC_MATERIAL_MASTER();
                    SAPProxy.MEANTable             MeanTB        = new SAPProxy.MEANTable();
                    SAPProxy.MARDTable             MardTB        = new SAPProxy.MARDTable();
                    SAPProxy.MARATable             MaraTB        = new SAPProxy.MARATable();
                    SAPProxy.MARMTable             MarmTB        = new SAPProxy.MARMTable();
                    SAPProxy.ZMM_ASSIGNLOCTable    TB_MMLOCATION = new SAPProxy.ZMM_ASSIGNLOCTable();
                    SAPProxy.MLGTTable             TB_WHLOCATION = new SAPProxy.MLGTTable();

                    var ProductCode            = productCode;
                    var ProductMain            = productCode;
                    SAPProxy.MARATable MaraTB2 = new SAPProxy.MARATable();
                    prx.Zdd_Get_Material_Master(sapProductCode, out strc, ref MeanTB, ref TB_MMLOCATION, ref MardTB, ref MaraTB2, ref MarmTB, ref TB_WHLOCATION);

                    DataTable dt = TB_MMLOCATION.ToADODataTable();
                    //เอาหน่วยออก พี่เอ็มแจ้งให้แสดงทุกหน่วยของสินค้า 2012-11-09
                    //string condition = string.Format("Storage_Loc='{0}' AND Unitofmeasure='{1}'", wareHouseCode, unitCode);
                    string    condition = string.Format("Storage_Loc='{0}'", wareHouseCode);
                    DataRow[] rows      = dt.Select(condition);
                    foreach (DataRow row in rows)
                    {
                        Location location = new Location();
                        location.Code = row["bin_code"] as string;
                        locations.Add(location);
                    }
                }
            }

            return(locations);
        }