huysentruitw / SapNwRfc

SAP NetWeaver RFC library for .NET 5, .NET Core and .NET Framework
MIT License
149 stars 43 forks source link

Receiving "No transaction handler is installed. Unable to process tRFC/qRFC requests." Error on Generic RFC Communication #75

Open arunksinfo opened 2 years ago

arunksinfo commented 2 years ago

Hello,

We've used the GenericServerHandler to receive messages via RFC. Server Launch is able to establish the connection between service and SAP. When we try to send any data to service, it shows "No transaction handler is instanlled. Unable to process tRFC/qRFC request"

Can you please provide details on how to register generic handler listener.

Here's the code


SapConnectionParameters sapConnectionParameters = new SapConnectionParameters();
                sapConnectionParameters.SncMyName = "XXXX";
                sapConnectionParameters.GatewayHost = "XX.XX.X.XXX";
                sapConnectionParameters.GatewayService = "MyGatewayServicename";
                sapConnectionParameters.ProgramId = "MyPgmID";
                sapConnectionParameters.RegistrationCount = "1";
                sapConnectionParameters.AppServerHost = "XX.XX.X.XXX";
                sapConnectionParameters.SystemNumber = "02";
                sapConnectionParameters.User = "Username";
                sapConnectionParameters.Password = "Password";
                sapConnectionParameters.Client = "900";
                sapConnectionParameters.Language = "EN";

SapServer.InstallGenericServerFunctionHandler(sapConnectionParameters, (connection, function) =>
                {
                    Console.WriteLine("Calling First");
                    var attributes = connection.GetAttributes();

                    switch (function.GetName())
                    {
                        case "IDOC_INBOUND_ASYNCHRONOUS":
                            Console.WriteLine("Received Metadata");
                            break;
                    }
                });

var server = SapServer.Create(sapConnectionParameters);
                server.Error += (object sender, SapServerErrorEventArgs args) => Console.WriteLine(args.Error.Message);
                server.StateChange += (object sender, SapServerStateChangeEventArgs args) => Console.WriteLine(args.OldState + " -> " + args.NewState);

server.Launch();

image

tom-j-irvine commented 2 years ago

Hi - I've used the GenericServerHandler quite a bit, but all calls have been synchronous. Looking at the RFC SDK doc, implementing a tRFC server is quite a bit more involved as you need to maintain state for executing transactions, etc... Are you able to change how you call the function in the SAP system and make the call synchronous?

arunksinfo commented 2 years ago

Hello @tom-j-irvine,

Now, we are trying to InstallGenericServerHandler, but the calls are not receiving at the Action delegates. Can you please provide some sample to use GenericServerHandler ?

tom-j-irvine commented 2 years ago

Sorry, it is really clear what you need help with. Your originally handler code looks okay, though you need to provide two different sets of connection information. When calling InstallGenericServerFunctionHandler, you are provide client connection information (App host, user, etc..) - this is to fetch function metadata, etc. Then, when creating the server, you are providing information for the gateway host, etc. It might work with all of that together in one set of connection info, but if you look at the readme, it is using two different sets of info.

Then, it would be assumed you have an RFC destination setup with the same Program ID. Then, when calling a function from SAP, you would do something like this:

CALL FUNCTION 'YOUR_FUNCTION_NAME'
  DESTINATION 'YOUR_RFC_DEST'
  ...parameters, etc...

This function needs to be defined in the SAP system (this is where your server will get the metadata about the function).

Finally, you may need to look at the RFC Gateway security in your system (in SMGW) to make sure it allows outbound RFC calls to your program id/host, etc...

ssamsundar commented 1 year ago

@tom-j-irvine ,

Whether is it possible to enhance the SapNwRfc library to work for Asynchronous RFC (tRFC) ?

tom-j-irvine commented 1 year ago

@ssamsundar - First, I am not one of the developers. To date, I have used the RFC server functionality of the library and helped a little bit with testing, etc. So, to the possibility of adding the functionality, I'll have to defer to the developers for their input. The only thing I can add is that the implementation of a tRFC server would be quite a bit more complex as it needs to maintain state of transactions (likely in some sort of database).