public void ExtractData(int count = 0, int start = 0) { #if DEBUG RFCFunction function = Connection.CreateFunction(FunctionName); //TODO: определиться с входными параметрами //function.Exports.Add function.Execute(); //TODO: определиться с вызодными параметрами // или var data = function.Imports[0].ToTable(); data.ToADOTable(); // // или function.Tables[0].ToADOTable(); // #elif TEST LoadFromLocalQueue(); //загрузка из tp.csv var data = ExtractFromFile(count, start); foreach (var d in data) { Queue.Enqueue(JsonSerializer.Serialize(d)); } SendData(); #endif }
private static void RFCUserCreate(R3Connection con, string username) { using (con) { con.Open(false); RFCFunction func = con.CreateFunction("BAPI_USER_CREATE1"); func.Exports["USERNAME"].ParamValue = username; func.Exports["GENERATE_PWD"].ParamValue = "X"; RFCStructure ADDRESS = func.Exports["ADDRESS"].ToStructure(); ADDRESS["FIRSTNAME"] = "FistName"; ADDRESS["LASTNAME"] = "LastName"; RFCStructure PASSWORD = func.Exports["PASSWORD"].ToStructure(); PASSWORD["BAPIPWD"] = "init01"; func.Execute(); RFCStructure pw = func.Imports["GENERATED_PASSWORD"].ToStructure(); string passw = pw["BAPIPWD"].ToString(); Console.WriteLine("Password:"******"RETURN"][0, "MESSAGE"].ToString(); Console.WriteLine(message); Console.ReadLine(); con.Close(); } }
/// <summary> /// 根据参数查询RFC数据 /// </summary> /// <param name="refStr">查询返回信息</param> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <param name="lnName">料号</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_Param(ref string refStr, R3Connection ConnectionSAP, string interfaceFunName, string lnName) { ReturnResult result = new ReturnResult(); RFCFunction function = null; try { RFCTableColumnCollection ff = new RFCTableColumnCollection(); function = ConnectionSAP.CreateFunction(interfaceFunName); function.Exports["MATNR"].ParamValue = lnName; //查询条件(料号?) function.Execute(); refStr = function.Imports["NORMT"].ParamValue.ToString().Trim(); //返回数据 ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_Param Fail: " + ex.Message); } return(result); }
/// <summary> /// 查询RFC数据(无查询参数) /// </summary> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_NoParam(ref DataTable dataTable_put, R3Connection ConnectionSAP, string interfaceFunName) { RFCTable rfcTable_ERR = new RFCTable(); ReturnResult result = new ReturnResult(); RFCFunction function = null; try { function = ConnectionSAP.CreateFunction(interfaceFunName); function.Execute(); rfcTable_ERR = function.Tables["T_OUTTAB"];//out table dataTable_put = rfcTable_ERR.ToADOTable(); ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_NoParam Fail: " + ex.Message); } return(result); }
static void Main(string[] args) { string mypath = AppDomain.CurrentDomain.BaseDirectory; string myfile = mypath + "DSOInput.csv"; string res; try { ERPConnect.LIC.SetLic("17YZYZ5VVZ"); string[] myLines = System.IO.File.ReadAllLines(myfile); string dsoname = "ZKEDSO01"; // ZBOARD01 R3Connection con = new R3Connection("bw2.theobald-software.com", 0, "Demouser1", "Board2016", "DE", "800"); con.Open(); RFCFunction delfunc = con.CreateFunction("RSDRI_ODSO_DELETE_RFC"); delfunc.Exports["I_DELETE_ALL"].ParamValue = "X"; delfunc.Exports["I_ODSOBJECT"].ParamValue = dsoname; delfunc.Execute(); RFCFunction insfunc = con.CreateFunction("RSDRI_ODSO_INSERT_RFC"); insfunc.Exports["I_ODSOBJECT"].ParamValue = dsoname; foreach (string myline in myLines) { if (!myline.StartsWith("Item")) { string[] vals = myline.Split(",".ToCharArray()); if (vals.Length >= 4) { string st = string.Empty; st += vals[1].PadRight(10); // Customer 10 st += vals[2].PadRight(18); // Material 18 st += vals[3].PadRight(8); // Date 8 RFCStructure neworw = insfunc.Tables["I_T_DATA"].Rows.Add(); neworw["DATA"] = st; } } } insfunc.Execute(); int num = (int)insfunc.Imports["E_NUMROWS"].ParamValue; res = num + " rows inserted into DSO " + dsoname; } catch (Exception e1) { System.IO.File.WriteAllText(mypath + "UploadLog.txt", e1.ToString()); return; } System.IO.File.WriteAllText(mypath + "UploadLog.txt", res); }
/// <summary> /// Ändert eine Anlage /// </summary> public void BAPI_FIXEDASSET_CHANGE(string ASSET, string COMPANYCODE, GENERALDATAStructure GENERALDATA, GENERALDATAXStructure GENERALDATAX, string SUBNUMBER) { if (!Connection.Ping()) { Connection.Open(); } RFCFunction function = Connection.CreateFunction("BAPI_FIXEDASSET_CHANGE"); function.Exports["ASSET"].ParamValue = ASSET; function.Exports["COMPANYCODE"].ParamValue = COMPANYCODE; function.Exports["GENERALDATA"].ParamValue = GENERALDATA.Structure; function.Exports["GENERALDATAX"].ParamValue = GENERALDATAX.Structure; function.Exports["SUBNUMBER"].ParamValue = SUBNUMBER; function.Execute(); }
/// <summary> /// 根据参数查询RFC数据 /// </summary> /// <param name="refStr">查询返回信息</param> /// <param name="ConnectionSAP">链接信息</param> /// <param name="interfaceFunName">接口名称</param> /// <param name="tbParam">料号</param> /// <returns></returns> public ReturnResult Get_RFC_Info_By_Param(ref string rfcRes, R3Connection ConnectionSAP, string interfaceFunName, DataTable tbParam) { RFCTable rfcTable_ERR = new RFCTable(); ReturnResult result = new ReturnResult(); RFCFunction function = null; try { RFCTableColumnCollection ff = new RFCTableColumnCollection(); function = ConnectionSAP.CreateFunction(interfaceFunName); RFCTable info_table_H = function.Tables["IT_ZPPT6017"];//in table foreach (DataRow row in tbParam.Rows) { RFCStructure rfcStruc_H = info_table_H.AddRow(); rfcStruc_H["AUFNR"] = row[0]; //MO 编号 rfcStruc_H["MO_NO"] = row[1]; //MO 排序 } function.Execute(); //rfcTable_ERR = function.Tables["IT_ZPPT6017"];//out table //dataTable_put = rfcTable_ERR.ToADOTable(); rfcRes = function.Imports["E_FLAG"].ParamValue.ToString().Trim(); ConnectionSAP.Close(); result.Status = true; result.Message = "OK"; } catch (Exception ex) { result.Status = false; result.Message = ex.Message; this.logHandler.Error(MethodBase.GetCurrentMethod().Name, "Call Get_RFC_Info_By_Param Fail: " + ex.Message); } return(result); }
/// <summary> /// /// </summary> /// <param name="Orden"></param> public ValidacionOrdenSAPModel ValidacionOrden(string Orden) { ValidacionOrdenSAPModel Modelo = new ValidacionOrdenSAPModel(); try { ConectorSAP.Open(); RFCFunction FuncionSAP = ConectorSAP.CreateFunction("ZFM_OEE_GET_ORDEN"); FuncionSAP.Exports["IM_AUFNR"].ParamValue = "00000" + Orden; FuncionSAP.Execute(); Modelo.Material = FuncionSAP.Imports["EX_MATNR"]?.ParamValue?.ToString().Trim(); Modelo.Descripcion = FuncionSAP.Imports["EX_MAKTX"]?.ParamValue?.ToString().TrimStart().TrimEnd(); Modelo.Lote = FuncionSAP.Imports["EX_CHARG"]?.ParamValue?.ToString().Trim(); Modelo.Orden = FuncionSAP.Imports["EX_AUFNR"]?.ParamValue?.ToString().Trim(); if (Modelo.Orden != string.Empty) { Modelo.EstatusValidacionOrden = 1; } else { Modelo.EstatusValidacionOrden = 2; } } catch (Exception excepcion) { Modelo.EstatusValidacionOrden = -1; Modelo.Mensaje = excepcion.Message; } return(Modelo); }
/// <summary> /// Runs the specified fun. /// </summary> /// <param name="fun">The fun.</param> /// <returns>RFCFunction.</returns> public static RFCFunction Run(this RFCFunction fun) { fun.Execute(); return(fun); }