コード例 #1
0
 public void FangXing()
 {
     try
     {
         Connection connection = (Connection)this.ReturnLogin().NewConnection();
         if (connection.Logon(0, true))
         {
             SAPFunctionsClass class3 = new SAPFunctionsClass
             {
                 Connection = connection
             };
             IFunction  function  = (IFunction)class3.Add("ZLE_RFC_ZMMWTD");
             IParameter parameter = (IParameter)function.get_Exports("I_VSTEL");
             parameter.Value = "3000";
             IParameter parameter2 = (IParameter)function.get_Exports("I_ZMENID");
             parameter2.Value = "CQ02";
             IParameter parameter3 = (IParameter)function.get_Exports("I_ZCARNO");
             parameter3.Value = this.I_ZCARNO;
             IParameter parameter4 = (IParameter)function.get_Exports("I_EBELN");
             parameter4.Value = this.I_EBELN;
             function.Call();
             Tables    tables   = (Tables)function.Tables;
             Table     table    = (Table)tables.get_Item("Return");
             int       rowCount = table.RowCount;
             DataTable table2   = new DataTable();
             for (int i = 1; i <= rowCount; i++)
             {
                 DataRow row = table2.NewRow();
                 if (i == 1)
                 {
                     table2.Columns.Add("type");
                     table2.Columns.Add("message");
                 }
                 row["type"]    = table.get_Cell(i, "type").ToString();
                 row["message"] = table.get_Cell(i, "message").ToString();
                 table2.Rows.Add(row);
             }
             this.Table2 = table2;
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
コード例 #2
0
 public void SaveData()
 {
     try
     {
         Connection connection = (Connection)this.ReturnLogin().NewConnection();
         if (connection.Logon(0, true))
         {
             SAPFunctionsClass class3 = new SAPFunctionsClass
             {
                 Connection = connection
             };
             IFunction  function  = (IFunction)class3.Add("ZLE_RFC_WTD");
             IParameter parameter = (IParameter)function.get_Exports("I_WTD_ID");
             parameter.Value = this.I_WTD_ID;
             IParameter parameter2 = (IParameter)function.get_Exports("I_DATUM");
             parameter2.Value = CommonalityEntity.GetServersTime().ToString();
             IParameter parameter3 = (IParameter)function.get_Exports("I_CRFLG");
             parameter3.Value = this.I_CRFLG;
             function.Call();
             Tables    tables   = (Tables)function.Tables;
             Table     table    = (Table)tables.get_Item("Return");
             int       rowCount = table.RowCount;
             DataTable table2   = new DataTable();
             for (int i = 1; i <= rowCount; i++)
             {
                 DataRow row = table2.NewRow();
                 if (i == 1)
                 {
                     table2.Columns.Add("type");
                     table2.Columns.Add("message");
                 }
                 row["type"]    = table.get_Cell(i, "type").ToString();
                 row["message"] = table.get_Cell(i, "message").ToString();
                 table2.Rows.Add(row);
             }
             this.Table2 = table2;
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
コード例 #3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SAPLogonControlClass login = new SAPLogonControlClass();

            login.ApplicationServer = sapconfig.ApplicationServer;
            login.Client            = sapconfig.Client;
            login.Language          = sapconfig.Language;
            login.User         = sapconfig.User;
            login.Password     = sapconfig.Password;
            login.SystemNumber = sapconfig.SystemNumber;
            Connection conn = (Connection)login.NewConnection();

            ds    = new DataSet();
            table = new DataTable();
            table.Columns.Add("ID", typeof(string));
            table.Columns.Add("VBELN", typeof(string));
            table.Columns.Add("POSNR", typeof(string));
            table.Columns.Add("KWMENG", typeof(string));
            table.Columns.Add("Sapqty", typeof(string));
            table.Columns.Add("WERKS", typeof(string));
            table.Columns.Add("VRKME", typeof(string));
            table.Columns.Add("LGORT", typeof(string));
            table.Columns.Add("VSTEL", typeof(string));
            table.Columns.Add("AUFNR", typeof(string));
            table.Columns.Add("VGPOS", typeof(string));
            table.Columns.Add("MATNR", typeof(string));
            table.Columns.Add("ARKTX", typeof(string));
            table.Columns.Add("OutBQty", typeof(string));
            table.Columns.Add("CHARG", typeof(string));
            ReqTab = new DataTable();
            ReqTab.Columns.Add("ID", typeof(string));
            ReqTab.Columns.Add("ZRQWK", typeof(string));
            ReqTab.Columns.Add("ZREQNO", typeof(string));
            ReqTab.Columns.Add("ZREQPS", typeof(string));
            ReqTab.Columns.Add("ATINN", typeof(string));
            ReqTab.Columns.Add("ATZHL", typeof(string));
            ReqTab.Columns.Add("ATWRT", typeof(string));
            if (conn.Logon(0, true))
            {
                SAPFunctionsClass func = new SAPFunctionsClass();
                func.Connection = conn;
                IFunction  ifunc   = (IFunction)func.Add("ZAST_GET_SO");
                IParameter gclient = (IParameter)ifunc.get_Exports("WK_VBELN");
                gclient.Value = TBVbeln.Text;
                ifunc.Call();
                Tables tables = (Tables)ifunc.Tables;
                Table  vbap   = (Table)tables.get_Item("RT_VBAP");
                Table  rels   = (Table)tables.get_Item("RT_CUSTOMER_RQ");
                Table  RET    = (Table)tables.get_Item("RETURN");
                for (int i = 1; i <= RET.RowCount; i++)
                {
                    if (((string)RET.get_Cell(i, "TYPE") == "E") || ((string)RET.get_Cell(i, "TYPE") == "A"))
                    {
                        MessageBox.Show((string)RET.get_Cell(i, "MESSAGE"));
                        return;
                    }
                }
                for (int i = 1; i <= vbap.RowCount; i++)
                {
                    DataRow dr = table.NewRow();
                    dr["ID"]      = i.ToString();
                    dr["VBELN"]   = vbap.get_Cell(i, "VBELN");
                    dr["POSNR"]   = vbap.get_Cell(i, "POSNR");
                    dr["KWMENG"]  = vbap.get_Cell(i, "KWMENG");
                    dr["Sapqty"]  = vbap.get_Cell(i, "KWMENG");
                    dr["WERKS"]   = vbap.get_Cell(i, "WERKS");
                    dr["VRKME"]   = vbap.get_Cell(i, "VRKME");
                    dr["LGORT"]   = vbap.get_Cell(i, "LGORT");
                    dr["VSTEL"]   = vbap.get_Cell(i, "VSTEL");
                    dr["AUFNR"]   = vbap.get_Cell(i, "AUFNR");
                    dr["VGPOS"]   = vbap.get_Cell(i, "VGPOS");
                    dr["MATNR"]   = vbap.get_Cell(i, "MATNR");
                    dr["ARKTX"]   = vbap.get_Cell(i, "ARKTX");
                    dr["CHARG"]   = vbap.get_Cell(i, "CHARG");
                    dr["OutBQty"] = vbap.get_Cell(i, "KWMENG");

                    table.Rows.Add(dr);
                }

                for (int i = 1; i <= rels.RowCount; i++)
                {
                    DataRow dr = ReqTab.NewRow();
                    dr["ID"]     = i.ToString();
                    dr["ZRQWK"]  = rels.get_Cell(i, "ZRQWK");
                    dr["ZREQNO"] = rels.get_Cell(i, "ZREQNO");
                    dr["ZREQPS"] = rels.get_Cell(i, "ZREQPS");
                    dr["ATINN"]  = rels.get_Cell(i, "ATINN");
                    dr["ATZHL"]  = rels.get_Cell(i, "ATZHL");
                    dr["ATWRT"]  = rels.get_Cell(i, "ATWRT");

                    ReqTab.Rows.Add(dr);
                }

                ds.Tables.Add(table.Copy());
                ds.Tables.Add(ReqTab.Copy());
                conn.Logoff();
                this.Content.DataSource = ds.Tables[0];
                gridControl1.DataSource = ds.Tables[1].DefaultView;
            }
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: aeolus0829/pMtlList
        private void connSAP()
        {
            Sapcon oLogon = new Sapcon(clientNum);

            SAPLogonCtrl.Connection oSAPConn = CType <SAPLogonCtrl.Connection>(oLogon.NewConnection());


            try
            {
                if (oSAPConn.Logon(0, true))
                {
                    sDate1 = txtDate1.Text.Trim();
                    sDate2 = txtDate2.Text.Trim();
                    sPO    = txtPO.Text.Trim();
                    if (ddlMvt.SelectedIndex > 0)
                    {
                        sMvt = ddlMvt.SelectedValue.ToString();
                    }
                    sMtlDoc     = txtMtlDoc.Text.Trim();
                    sRefDoc     = txtRefDoc.Text.Trim();
                    sVendorName = txtVendorName.Text.Trim();
                    sMaterial   = txtMaterial.Text.Trim();
                    sZflag      = convertFlag(cbZflag.Checked);

                    SAPFunctionsClass func = new SAPFunctionsClass();
                    func.Connection = oSAPConn;

                    if (string.IsNullOrEmpty(sDate1))
                    {
                        sDate1 = DateTime.Today.ToString("yyyyMMdd");
                    }
                    if (string.IsNullOrEmpty(sDate2))
                    {
                        sDate2 = sDate1;
                    }

                    //功能模組名稱
                    IFunction ifunc = (IFunction)func.Add(rfcName);
                    //查詢參數:起始日期
                    IParameter pDate1 = (IParameter)ifunc.get_Exports("DATE1");
                    pDate1.Value = sDate1;
                    //查詢參數:結束日期
                    IParameter pDate2 = (IParameter)ifunc.get_Exports("DATE2");
                    if (txtDate2.Text == "")
                    {
                        pDate2.Value = sDate1;
                    }
                    else
                    {
                        pDate2.Value = sDate2;
                    }
                    //查詢參數:未產生105
                    IParameter pFlag = (IParameter)ifunc.get_Exports("ZFLAG");
                    pFlag.Value = sZflag;
                    //查詢參數:採購單
                    IParameter pPO = (IParameter)ifunc.get_Exports("PO");
                    pPO.Value = sPO;
                    //查詢參數:物料號碼
                    IParameter pMaterial = (IParameter)ifunc.get_Exports("MATERIAL");
                    pMaterial.Value = sMaterial;
                    //查詢參數:廠商名稱
                    IParameter pVendorName = (IParameter)ifunc.get_Exports("VENDORNM");
                    pVendorName.Value = sVendorName;
                    //查詢參數:異動類型
                    IParameter pMvt = (IParameter)ifunc.get_Exports("MVT");
                    pMvt.Value = sMvt;
                    //查詢參數:物料文件
                    IParameter pMtlDoc = (IParameter)ifunc.get_Exports("MTLDOC");
                    pMtlDoc.Value = sMtlDoc;
                    //查詢參數:參考文件
                    IParameter pRefDoc = (IParameter)ifunc.get_Exports("REFDOC");
                    pRefDoc.Value = sRefDoc;

                    ifunc.Call();

                    Tables tables = (Tables)ifunc.Tables;
                    SAPTableFactoryCtrl.Table ITAB = (SAPTableFactoryCtrl.Table)tables.get_Item("ITAB");

                    int itabRowCount = ITAB.RowCount;

                    if (itabRowCount > 0)
                    {
                        for (int i = 1; i <= itabRowCount; i++)
                        {
                            DataRow dr = sapDataDt.NewRow();
                            if (i == 1)
                            {
                                //  dt.Columns.Add("No");
                                sapDataDt.Columns.Add("輸入日期");
                                sapDataDt.Columns.Add("輸入時間");
                                sapDataDt.Columns.Add("採購文件");
                                sapDataDt.Columns.Add("文件項次");
                                sapDataDt.Columns.Add("物料文件");
                                sapDataDt.Columns.Add("異動類型");
                                sapDataDt.Columns.Add("參考文件");
                                sapDataDt.Columns.Add("數量");
                                sapDataDt.Columns.Add("單價");
                                sapDataDt.Columns.Add("幣別");
                                sapDataDt.Columns.Add("料號");
                                sapDataDt.Columns.Add("工單");
                                sapDataDt.Columns.Add("群組說明");
                                sapDataDt.Columns.Add("品名");
                                sapDataDt.Columns.Add("供應商");
                                sapDataDt.Columns.Add("備註");
                            }

                            //dr["No"] = i.ToString();
                            dr["輸入日期"] = Convert.ToDateTime(ITAB.get_Cell(i, "CPUDT")).ToString("yyyy-MM-dd");
                            dr["輸入時間"] = Convert.ToDateTime(ITAB.get_Cell(i, "CPUTM")).ToString("HH:mm:ss");
                            dr["採購文件"] = ITAB.get_Cell(i, "EBELN").ToString();
                            dr["文件項次"] = ITAB.get_Cell(i, "EBELP").ToString().TrimStart('0');
                            dr["物料文件"] = ITAB.get_Cell(i, "BELNR").ToString();
                            dr["異動類型"] = ITAB.get_Cell(i, "BWART").ToString();
                            dr["參考文件"] = ITAB.get_Cell(i, "LFBNR").ToString();
                            dr["數量"]   = ITAB.get_Cell(i, "MENGE").ToString().TrimEnd('0').TrimEnd('.');
                            dr["單價"]   = ITAB.get_Cell(i, "NETPR").ToString();
                            dr["幣別"]   = ITAB.get_Cell(i, "WAERS").ToString();
                            dr["料號"]   = ITAB.get_Cell(i, "MATNR").ToString().TrimStart('0');
                            dr["工單"]   = ITAB.get_Cell(i, "AUFNR").ToString().TrimStart('0');
                            dr["群組說明"] = ITAB.get_Cell(i, "TEXT20").ToString();
                            dr["品名"]   = ITAB.get_Cell(i, "TXZ01").ToString();
                            var vendorName = checkStringLen(ITAB.get_Cell(i, "NAME1").ToString(), 4);

                            dr["供應商"] = vendorName;
                            dr["備註"]  = ITAB.get_Cell(i, "MD_MEMO").ToString().TrimEnd(':');

                            sapDataDt.Rows.Add(dr);
                        }
                        formatedDT = arrangeExcelLayout(sapDataDt);

                        gvData.DataSource = formatedDT.DefaultView;
                        gvData.DataBind();
                        btnConvert.Visible = true;
                    }
                    else
                    {
                        lblMsg.Text    = "無符合條件的資料";
                        gvData.Visible = false;
                    }
                }
                else
                {
                    lblMsg.Text = "無法連接 sap";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
コード例 #5
0
 /// <summary>
 /// 成品SAP
 /// </summary>
 public void ChengPin()
 {
     try
     {
         Connection connection = (Connection)this.ReturnLogin().NewConnection();
         if (connection.Logon(0, true))
         {
             int               num2;
             DataRow           row;
             SAPFunctionsClass class3 = new SAPFunctionsClass
             {
                 Connection = connection
             };
             IFunction  function  = (IFunction)class3.Add("ZLE_RFC_VEHICLE_CHECKIN");
             IParameter parameter = (IParameter)function.get_Exports("LV_VEHICLE_TYPE");
             parameter.Value = "20";
             IParameter parameter2 = (IParameter)function.get_Exports("LV_CARNO");
             parameter2.Value = this.LV_CARNO;
             function.Call();
             Tables    tables   = (Tables)function.Tables;
             Table     table    = (Table)tables.get_Item("OUT_TAB");
             int       rowCount = table.RowCount;
             DataTable table2   = new DataTable();
             for (num2 = 1; num2 <= rowCount; num2++)
             {
                 row = table2.NewRow();
                 if (num2 == 1)
                 {
                     table2.Columns.Add("CARNO");
                     table2.Columns.Add("WTD_ID");
                     table2.Columns.Add("O_FLAG");
                     table2.Columns.Add("TEL_NUMBER");
                     table2.Columns.Add("HG");
                     table2.Columns.Add("XZ");
                     table2.Columns.Add("KDATB");
                     table2.Columns.Add("KDATE");
                     table2.Columns.Add("NAME1_C");
                     table2.Columns.Add("NAME1_P");
                     table2.Columns.Add("Prodh");
                 }
                 row["CARNO"]      = table.get_Cell(num2, "CARNO");
                 row["WTD_ID"]     = table.get_Cell(num2, "WTD_ID");
                 row["O_FLAG"]     = table.get_Cell(num2, "O_FLAG");
                 row["TEL_NUMBER"] = table.get_Cell(num2, "TEL_NUMBER");
                 row["HG"]         = table.get_Cell(num2, "HG");
                 row["XZ"]         = table.get_Cell(num2, "XZ");
                 row["KDATB"]      = table.get_Cell(num2, "KDATB");
                 row["KDATE"]      = table.get_Cell(num2, "KDATE");
                 row["NAME1_C"]    = table.get_Cell(num2, "NAME1_C");
                 row["NAME1_P"]    = table.get_Cell(num2, "NAME1_P");
                 row["Prodh"]      = table.get_Cell(num2, "Prodh");
                 table2.Rows.Add(row);
             }
             Tables    tables2 = (Tables)function.Tables;
             Table     table3  = (Table)tables2.get_Item("Return");
             int       num3    = table3.RowCount;
             DataTable table4  = new DataTable();
             for (num2 = 1; num2 <= num3; num2++)
             {
                 row = table4.NewRow();
                 if (num2 == 1)
                 {
                     table4.Columns.Add("type");
                     table4.Columns.Add("message");
                 }
                 row["type"]    = table3.get_Cell(num2, "type").ToString();
                 row["message"] = table3.get_Cell(num2, "message").ToString();
                 table4.Rows.Add(row);
             }
             this.Table1 = table2;
             this.Table2 = table4;
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
コード例 #6
0
 /// <summary>
 /// 送货SAP
 /// </summary>
 public void SendGoods()
 {
     try
     {
         Connection connection = (Connection)this.ReturnLogin().NewConnection();
         if (connection.Logon(0, true))
         {
             int               num2;
             DataRow           row;
             SAPFunctionsClass class3 = new SAPFunctionsClass
             {
                 Connection = connection
             };
             IFunction  function  = (IFunction)class3.Add("ZLE_RFC_VEHICLE_CHECKIN");
             IParameter parameter = (IParameter)function.get_Exports("LV_VEHICLE_TYPE");
             parameter.Value = "10";
             IParameter parameter2 = (IParameter)function.get_Exports("LV_EBELN");
             parameter2.Value = this.LV_EBELN;
             function.Call();
             Tables    tables   = (Tables)function.Tables;
             Table     table    = (Table)tables.get_Item("OUT_TAB");
             int       rowCount = table.RowCount;
             DataTable table2   = new DataTable();
             for (num2 = 1; num2 <= rowCount; num2++)
             {
                 row = table2.NewRow();
                 if (num2 == 1)
                 {
                     table2.Columns.Add("EBELN");
                     table2.Columns.Add("NAME1_P");
                     table2.Columns.Add("MAKTX");
                     table2.Columns.Add("KDATB");
                     table2.Columns.Add("KDATE");
                 }
                 row["EBELN"]   = table.get_Cell(num2, "EBELN").ToString();
                 row["NAME1_P"] = table.get_Cell(num2, "NAME1_P").ToString();
                 row["MAKTX"]   = table.get_Cell(num2, "MAKTX").ToString();
                 row["KDATB"]   = table.get_Cell(num2, "KDATB").ToString();
                 row["KDATE"]   = table.get_Cell(num2, "KDATE").ToString();
                 table2.Rows.Add(row);
             }
             Tables    tables2 = (Tables)function.Tables;
             Table     table3  = (Table)tables2.get_Item("Return");
             int       num3    = table3.RowCount;
             DataTable table4  = new DataTable();
             for (num2 = 1; num2 <= num3; num2++)
             {
                 row = table4.NewRow();
                 if (num2 == 1)
                 {
                     table4.Columns.Add("type");
                     table4.Columns.Add("message");
                 }
                 row["type"]    = table3.get_Cell(num2, "type").ToString();
                 row["message"] = table3.get_Cell(num2, "message").ToString();
                 table4.Rows.Add(row);
             }
             this.Table1 = table2;
             this.Table2 = table4;
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }