Skip to Content
author's profile photo Former Member
Former Member

RFC_READ_TABLE Options causes System Failure

In VBA, I want to use the options parameter like:

Set OPTIONS = MyFunc.Tables("OPTIONS")

OPTIONS.Rows.Add

OPTIONS.Value(1, "TEXT") = "OBJECT = 'S_TCODE'"

however when I then run the module it produces a system failure. If I comment out the two options lines then it runs with no problem with no filter on the data of course.

Any ideas how to correct this?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 01, 2005 at 10:00 PM

    Hi,

    First check if you can call this function using the same parameters from ABAP without errors.

    Some time ago I used this FM but not in VB but in Delphi. I think that code should be similar so i post it below.

    This code reads table KNA1 for specific customer name:

     var Funct, RFC_Read_table: Variant;
         SelectWhere, Fields, TableContent: TStringList;
     
     try
      Funct := CreateOleObject('SAP.Functions');
     except
    (...)
     end;
     try
      RFC_Read_table := Funct.Add('RFC_READ_TABLE');
     except
    (...) 
     end; 
     
     SelectWhere  := TStringList.Create;
     Fields       := TStringList.Create;
     TableContent := TStringList.Create;
    
     SelectWhere.Add('NAME1 = KOWALSKI');
     Fields.Add('KUNNR');
     Fields.Add('ORT01');
     if not ReadDataFromSAPTable('KNA1', SelectWhere, Fields, TableContent) then
      ShowMessage(RFC_Read_table.Exception)
     end;
    
     SelectWhere.Free; Fields.Free; TableContent.Free;
     
    function ReadDataFromSAPTable(TableName: String; SelectWhere, Fields,
                                  TableContent: TStringList): Boolean;
    var Row, iQueryTable, tOptions, tFields, tData: Variant;
        i: Integer;
    begin
     iQueryTable := RFC_Read_table.exports('QUERY_TABLE');
     iQueryTable.Value := TableName;
    
     tOptions := RFC_Read_table.Tables.Item('OPTIONS');
     for i := 0 to SelectWhere.Count - 1 do
      begin
       Row := tOptions.Rows.Add;
       Row.Value('TEXT') := SelectWhere<i>;
      end;
    
     tFields := RFC_Read_table.Tables.Item('FIELDS');
     for i := 0 to Fields.Count - 1 do
      begin
       Row := tFields.Rows.Add;
       Row.Value('FIELDNAME') := Fields<i>;
      end;
    
     tData := RFC_Read_table.Tables.Item('DATA');
    
     Result := RFC_Read_table.Call;
    
     if Result = True then
      for i := 1 to tData.Rowcount do TableContent.Add(tData.Value(i, 1));
    end;

    Krzys

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.