//設定連線參數 RfcConfigParameters parms = new RfcConfigParameters(); parms.Add(RfcConfigParameters.AppServerHost, ServerIP); //172.16.0.1 parms.Add(RfcConfigParameters.SystemNumber, SystemNumber); //00 parms.Add(RfcConfigParameters.SystemID, SystemID); //PRD parms.Add(RfcConfigParameters.User, User); //SAPUSER parms.Add(RfcConfigParameters.Password, Password); //SAPPWD parms.Add(RfcConfigParameters.Client, Client); //225 parms.Add(RfcConfigParameters.Language, "EN"); parms.Add(RfcConfigParameters.PoolSize, "5"); parms.Add(RfcConfigParameters.PeakConnectionsLimit, "10"); parms.Add(RfcConfigParameters.ConnectionIdleTimeout, "600"); parms.Add(RfcConfigParameters.Name, "LIPS"); //取得連線 RfcDestination destination = RfcDestinationManager.GetDestination(parms); RfcSessionManager.BeginContext(destination); destination.Ping(); //宣告RfcFunction IRfcFunction rfcFunction = destination.Repository.CreateFunction(RfcFunctionName); //設定RfcFunction Table參數 rfcFunction.SetValue("AUFNR", 傳入參數); //傳入型別: 字串(string), 代表意義 工單 rfcFunction.SetValue("LOC_TYPE", 傳入參數); //傳入型別: 字元(character), 代表意義 R:電阻 C:電容 L:電感 //執行此RfcFunction以產生RfcFunction Table rfcFunction.Invoke(destination); //取回RfcFunction產生的Table IRfcTable table = rfcFunction.GetTable(TableName); //destination = null;//關閉連線 if (destination != null) { RfcSessionManager.EndContext(destination); destination = null; } DataTable dt = new DataTable(); //新建表格 dt.Columns.Add("Part"); //表格添加一列 dt.Columns.Add("Location"); //表格添加一列 for (int i = 0; i < table.RowCount; i++) { table.CurrentIndex = i; //当前内表的索引行 string PartName = string.Empty; string Location = string.Empty; PartName = table.GetString("MATNR"); //获取表格的某行某列的值 Location += table.GetString("LOC1"); Location += table.GetString("LOC2"); Location += table.GetString("LOC3"); //Console.WriteLine(PartName); //Console.WriteLine(Location); //開始Parser資訊... }
文章標籤
全站熱搜
留言列表