Saprfc table 使用过滤器读取

Saprfc table read with filter

我是 php saprfc 的新人。我使用我们的集成函数,但现在我需要从 table 中读取行。但是我该怎么做才能只读取几行,按条件过滤结果,因为这个 table 有几百万行。

可以吗?

这是最近使用的代码部分,在非常大的表上也能很好地快速运行。我希望它对其他人也有帮助。

//Try to connect to SAP using our Login array 
    $rfc = saprfc_open ($saplogin);
    IF (! $rfc ) { ECHO "The RFC connection has failed with the following error:".saprfc_error();EXIT; }
    //We must know if the function really exists
    $fce = saprfc_function_discover($rfc, "RFC_READ_TABLE");
    IF (! $fce ) { ECHO "The function module has failed.";ECHO $rfc;EXIT; }
    //Convert to uppercase the name of the table to show
    $Table = "HERE_THE_TABLE_NAME";
    //Pass import parameters
    saprfc_import ($fce,"QUERY_TABLE",$Table);saprfc_import ($fce,"DELIMITER","/");
    //Pass table parameters
    saprfc_table_init ($fce,"OPTIONS");
    saprfc_table_append ($fce,"OPTIONS", array ("TEXT"=>"TABLE_FIELD_NAME = '{$input}'")); //input field, filter by this variable
    saprfc_table_init ($fce,"FIELDS");
    saprfc_table_append ($fce,"FIELDS", array ("FIELDNAME"=>"INT_UI")); //wanted answer field
    saprfc_table_init ($fce,"DATA");
    //Call and execute the function
    $rc = saprfc_call_and_receive ($fce);
    if ($rc != SAPRFC_OK)
      {
       if ($rfc == SAPRFC_EXCEPTION ) { echo ("Exception raised: ".saprfc_exception($fce)); }
        else { echo ("Call error: ".saprfc_error($fce)); }
       exit; 
      }
    //Fetch the data from the internal tables
    $data_row = saprfc_table_rows ($fce,"DATA");$field_row = saprfc_table_rows ($fce,"FIELDS");
    for($i=1; $i<=$data_row ; $i++)
     { $DATA[$i] = saprfc_table_read ($fce,"DATA",$i);$TEST[] = SPLIT("/",$DATA[$i]['WA']); }  // get the rows to $TEST variable


    //release the function and close the connection
  saprfc_function_free($fce);