2015-01-05 110 views
0

我是新的php saprfc。我使用我們的集成函數,但現在我需要讀取表格中的行。但是我怎麼做只讀幾行,按照一個標準過濾結果,因爲這個表有幾百萬行。Saprfc table with filter

可能嗎?

+0

你對自己在做什麼並不十分清楚。您是否使用非標準的RFC功能(在這種情況下,您的團隊可以控制此功能並可以對其進行調整),還是需要執行其他任務並希望使用標準功能? –

回答

1

這是最近使用的代碼部分,在很大的表格上也可以很好地工作。我希望它也能幫助別人。

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

請在你的回答中加上解釋 – Alex

+0

明天下午我會詳細說明。 – Woodyka