cancel
Showing results for 
Search instead for 
Did you mean: 

SAP .NET Connector RFC server - Passing back table data

Former Member
0 Kudos

Hi,

I have built a RFC server with the SAP .Net Connector, which is listening to one function call.

Because everything should be initiated from the SAP side, I'm using this function for the first

initial call and then determine in the C# code, what kind of call it is. Within this call, I'm calling

the necessary function on the SAP side (from C# now) and in the end, I wanted to pass back

some table data to the RFC server function, which has been called at the beginning from SAP.

But everything, what I'm passing to this table, disappears in ABAP, after the function call has

been done.

My scenario:

ABAP program ---> Call RFC function "Z.....Interface" --> C# receives this call, calls several other RFC functions --> In the end, "Z.....Interface" function should pass back message information in a table.

This information disappears somehow, but in the very end of the C# code, the IRFCTable is still filled.

Can anyone explain me, why this data is not going to be passed back to the caller program, via the called function?

Thank you very much!

Michael

Accepted Solutions (1)

Accepted Solutions (1)

former_member197445
Contributor
0 Kudos

Michael -- your scenario makes sense.  Can we take a look at your code to see if we can spot any problems there, please?

Former Member
0 Kudos

Hey Case,

thanks for the quick answer. I have built my C# application in several classes. One is just for the handling of the server calls:

public class ServerHandler
    {
        [RfcServerFunction(Name = "Z_INTERFACE_HANDLER")]

        public static void IrdpConnection(RfcServerContext context, IRfcFunction function)
        {
            // Create SAPFunctions instance
            SapFunctions sapFunctions = new SapFunctions();

            // Create Structure for control data
            IRfcStructure rfcControlData = function.GetStructure("CONTROL_DATA");

            // Create Table for passing back messages
            IRfcTable messageTable = function.GetTable("MESSAGE_TABLE");

            // Read exchange type
            String exchangeType = rfcControlData.GetString("EXCHNG_TYPE");

            // Write log message for received call
            LogFunctions logFunctions = new LogFunctions();

            // Determine call type
            switch (exchangeType)
            {
                case "01":

                    sapFunctions.extractDataToIrdp(rfcControlData, messageTable);

                    break;
            }
        }
    }

So if I now check the IRfcTable messageTable in the end of the method, it is filled. But I'm not getting anything back to

the caller ABAP program. I hope, this is not a very stupid mistake, which I don't see anymore, cause it's too easy!

Thank You!

Michael

Former Member
0 Kudos

Hey again,

I have found the error by myself and it was something very easy...

I have created the function "Z_INTERFACE_HANDLER" in the SAP system and inside of it, I have added some code, which is creating log information for each call. Inside of this function, the "real" function "Z_INTERFACE_HANDLER", which is registered on the C# side, is going to be called. Within this function frame on the SAP side, I have wrongly passed the MESSAGE_TABLE information from the RFC server call back to the frame function. So the message_table information came always back from C#, but never reached the caller program, which was just calling the frame function.

Thank you for listening anyway!

Michael

Answers (1)

Answers (1)

Former Member
0 Kudos
  1. public class ServerHandler 
  2.     { 
  3.         [RfcServerFunction(Name = "Z_INTERFACE_HANDLER")] 
  4. public static void IrdpConnection(RfcServerContext context, IRfcFunction function) 
  5.         { 
  6. // Create SAPFunctions instance 
  7.             SapFunctions sapFunctions = new SapFunctions(); 
  8. // Create Structure for control data 
  9.             IRfcStructure rfcControlData = function.GetStructure("CONTROL_DATA"); 
  10. // Create Table for passing back messages 
  11.             IRfcTable messageTable = function.GetTable("MESSAGE_TABLE"); 
  12. // Read exchange type 
  13.             String exchangeType = rfcControlData.GetString("EXCHNG_TYPE"); 
  14. // Write log message for received call 
  15.             LogFunctions logFunctions = new LogFunctions(); 
  16. // Determine call type 
  17. switch (exchangeType) 
  18.             { 
  19. case "01"
  20.                     sapFunctions.extractDataToIrdp(rfcControlData, messageTable); 
  21. break; 
  22.             } 
  23.         } 
  24.     } 

When RFC calls from SAP Server controls comes inside ServerHandler  but unable to move inside IrdpConnection.Kindly suggest me what i forgot to declare so all works fine.