cancel
Showing results for 
Search instead for 
Did you mean: 

Query a table using RFC_READ_TABLE using .net connector 3.0

Former Member
0 Kudos

Community,

I have been using RFC Dot net connector 3.0  to fetch data from a function for now and there was no need to change the code for a while, but now a new requirement forces us to fetch data from a table.

So i'm trying to use RFC_READ_TABLE to read from VBAK table.

I'm able to connect and able to see the Import/Table parameters for function RFC_READ_TABLE, Though when i try to set the value for Table parameters (adding where clause to filter records), this throws an exception. Here is the code,

               RfcSessionManager.BeginContext(rfcDest);               

               IRfcFunction function = rfcDest.Repository.CreateFunction("RFC_READ_TABLE");

               RfcRepository repo = rfcDest.Repository;

                function.SetValue("QUERY_TABLE", "VBAK" );

                function.SetValue("ROWCOUNT", "2" );

                function.SetValue("NO_DATA", "FALSE" );

                function.Invoke(rfcDest);

                IRfcTable inputTableFields = function.GetTable("FIELDS");

                inputTableFields[0].SetValue("FIELDNAME", "ERDAT");

                inputTableFields[1].SetValue("FIELDNAME", "VBELN");

                 IRfcTable inputTableOptions = function.GetTable("OPTIONS");

                 inputTableOptions[0].SetValue("TEXT", "ERDAT EQ 20130223"); // Exception Message is triggered here saying that the table is null.

Where am i going wrong? Any help on this would be appreciated.

Thanks

Accepted Solutions (0)

Answers (5)

Answers (5)

hynek_petrak
Active Participant
0 Kudos

Hi, I completely agree with Markus. Avoid using RFC_READ_TABLE. Why don't you use BAPISDORDER_GETDETAILEDLIST?

Apparently also your program flow is wrong. You shall call Invoke() once you set all the input parameters. OPTIONS and FIELDS are input parameters.

Former Member
0 Kudos

I have used RFC_READ_TABLE...

Also i invoked after setting all the input parameters, everything is fine now, i have completed my project successfully,

thanks a lot for those supporters... Especially Markus

hynek_petrak
Active Participant
0 Kudos

Apparently you did not listen to him....

Former Member
0 Kudos

yup but he is the one who responds most of my queries, which helped me a lot

Former Member
0 Kudos

In this wer you are getting the value from table?

Former Member
0 Kudos

RfcDestinationManager.RegisterDestinationConfiguration(ECCDestination);

                RfcDestination rfcDest = null;

                rfcDest = RfcDestinationManager.GetDestination(a);

                //SAPReader.TableReader tabReader = new TableReader(dest);

                RfcRepository repo = rfcDest.Repository;

                IRfcFunction customerList = repo.CreateFunction("RFC_READ_TABLE");

                customerList.Invoke(rfcDest);

It says TABLE_NOT AVAILABLE

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Jeswin,

please understand that I cannot provide you help for a solution that is not the one that should be implemented. Please use a different approach and don't keep on trying with the generic RFC_READ_TABLE.

Best regards,

Markus

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

the overall approach should be thought over. Instead of accessing the table via RFC_READ_TABLE and thus bypassing all potential authority checks, you should either use an existing remote enabled function module or if there is none that fits your needs, then implement a specific remote enabled function module that invokes does those authority checks and prevents unauthorized access to the data. Such a function module could also be extended more easily than via RFC_READ_TABLE as there are more possibilities in ABAP directly.

Best regards,

Markus

former_member197445
Contributor
0 Kudos

Two main issues that I can see.

  1. NO_DATA parameters should be set to empty string, not "FALSE."
  2. Your final Options table string should have single quotes around the date:
    "ERDAT EQ '20130223'"