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(); } }
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); }
public GENERALDATAXStructure() { RFCTableColumnCollection collection = new RFCTableColumnCollection(); collection.FixedLength = 22; collection.ABAPStructureName = "BAPI1022_FEGLG001X"; RFCTableColumn c = null; c = new RFCTableColumn("ASSETCLASS", 2, 0, RFCTYPE.CHAR); c.Offset = 0; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("DESCRIPT", 2, 0, RFCTYPE.CHAR); c.Offset = 2; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("DESCRIPT2", 2, 0, RFCTYPE.CHAR); c.Offset = 4; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("ACCT_DETRM", 2, 0, RFCTYPE.CHAR); c.Offset = 6; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("SERIAL_NO", 2, 0, RFCTYPE.CHAR); c.Offset = 8; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("INVENT_NO", 2, 0, RFCTYPE.CHAR); c.Offset = 10; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("QUANTITY", 2, 0, RFCTYPE.CHAR); c.Offset = 12; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("BASE_UOM", 2, 0, RFCTYPE.CHAR); c.Offset = 14; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("BASE_UOM_ISO", 2, 0, RFCTYPE.CHAR); c.Offset = 16; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("HISTORY", 2, 0, RFCTYPE.CHAR); c.Offset = 18; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("MAIN_DESCRIPT", 2, 0, RFCTYPE.CHAR); c.Offset = 20; c.IsNonStructureLineType = false; collection.Add(c); _structure = new RFCStructure(collection); }
public GENERALDATAStructure() { RFCTableColumnCollection collection = new RFCTableColumnCollection(); collection.FixedLength = 440; collection.ABAPStructureName = "BAPI1022_FEGLG001"; RFCTableColumn c = null; c = new RFCTableColumn("ASSETCLASS", 16, 0, RFCTYPE.CHAR); c.Offset = 0; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("DESCRIPT", 100, 0, RFCTYPE.CHAR); c.Offset = 16; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("DESCRIPT2", 100, 0, RFCTYPE.CHAR); c.Offset = 116; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("ACCT_DETRM", 16, 0, RFCTYPE.CHAR); c.Offset = 216; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("SERIAL_NO", 36, 0, RFCTYPE.CHAR); c.Offset = 232; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("INVENT_NO", 50, 0, RFCTYPE.CHAR); c.Offset = 268; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("QUANTITY", 7, 3, RFCTYPE.BCD); c.Offset = 318; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("BASE_UOM", 6, 0, RFCTYPE.CHAR); c.Offset = 326; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("BASE_UOM_ISO", 6, 0, RFCTYPE.CHAR); c.Offset = 332; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("HISTORY", 2, 0, RFCTYPE.CHAR); c.Offset = 338; c.IsNonStructureLineType = false; collection.Add(c); c = new RFCTableColumn("MAIN_DESCRIPT", 100, 0, RFCTYPE.CHAR); c.Offset = 340; c.IsNonStructureLineType = false; collection.Add(c); _structure = new RFCStructure(collection); }
/// <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); }
public GENERALDATAXStructure(RFCStructure structure) { _structure = structure; }