使用筛选器读取的 SAP RFC 表


SAP RFC table read with filter

我是PHP SAP RFC的新手。我使用我们的集成函数,但现在我需要从表中读取行。但是我怎么能只阅读几行,按条件过滤结果,因为这个表有数百万行。

可能吗?

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

//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);