private static void StartRFCServer() { try { RFCServer s = new RFCServer(); s.GatewayHost = "52.200.13.213"; s.GatewayHost = "vhcals4hci.dummy.nodomain"; //s.GatewayHost = "ec5.theobald-software.com"; s.GatewayService = "sapgw00"; s.ProgramID = "ERPTEST"; s.IncomingCall += new ERPConnect.RFCServer.OnIncomingCall(s_IncomingCall); RFCServerFunction f = s.RegisteredFunctions.Add("Z_ADD"); f.Imports.Add("NUMBER1", RFCTYPE.INT); f.Imports.Add("NUMBER2", RFCTYPE.INT); f.Exports.Add("RES", RFCTYPE.INT); s.Start(); Console.WriteLine("Server is running. Press any key to exit."); Console.ReadLine(); s.Stop(); } catch (Exception e1) { Console.WriteLine(e1.Message.ToString()); Console.ReadLine(); } }
private static void StartIDocServer() { try { RFCServer s = new RFCServer(); s.Logging = true; //s.GatewayHost = "52.200.13.213"; s.GatewayHost = "vhcals4hci.dummy.nodomain"; s.GatewayService = "sapgw00"; s.ProgramID = "ERPTEST"; s.CanReceiveIdocs = true; s.IncomingIdoc += new ERPConnect.RFCServer.OnIncomingIdoc(s_IncomingIdoc); //s.IncomingIdoc += S_IncomingIdoc; //s.InternalException += new ERPConnect.RFCServer.OnInternalException(s_InternalException); s.Start(); Console.WriteLine("Server is running. Press any key to exit."); Console.ReadLine(); s.Stop(); } catch (Exception e1) { Console.WriteLine(e1.Message.ToString()); Console.ReadLine(); } }
private static void s_IncomingIdoc(RFCServer sender, Idoc idoc) { Console.WriteLine("Recieved Idoc " + idoc.IDOCTYP); IdocSegment e1maram = idoc.Segments["E2MARAM008", 0]; for (int i = 0; i < e1maram.ChildSegments.Count; i++) { if (e1maram.ChildSegments[i].SegmentName == "E2MAKTM001") { Console.WriteLine("Materialtext found: " + e1maram.ChildSegments[i].ReadDataBuffer(4, 40)); } } }
private static void s_IncomingCall(RFCServer Sender, RFCServerFunction CalledFunction) { if (CalledFunction.FunctionName == "Z_ADD") { Int32 i1 = (Int32)CalledFunction.Imports["NUMBER1"].ParamValue; Int32 i2 = (Int32)CalledFunction.Imports["NUMBER2"].ParamValue; Int32 erg = i1 + i2; CalledFunction.Exports["RES"].ParamValue = erg; Console.WriteLine("Incoming Call"); Console.WriteLine(i1 + " + " + i2 + " = " + erg); } else { throw new ERPConnect.ERPException("Function unknown"); } }