Closed goalmaker closed 5 years ago
Can you provide a (reproducible) example?
example in bapi table col1 | col2 | col3 | col4 1 | 2 | 3 | 4
PHP invoke - results is same ok. col1 | col2 | col3 | col4 1 | 2 | 3 | 4
When table field change like, if i remove col3 in BAPI in SAP In BAPI col1 | col2 | col4 1 | 2 | 4
PHP invoke - results as below: col1 | col2 | col4 1 | 2 3 | 4
after i restart the iis server 2012 the PHP invoke result is ok as below col1 | col2 | col4 1 | 2 | 4
Looks like i have to restart the iis everytime the BAPI table parameter in SAP side changes. sapnwrfc - Version | 1.1.2 SAP NW RFC SDK | 7210.0.45 . Please advise.
Might be an issue with caching. I will have a look at this, but cannot give you an exact timeframe. What I need is a minimal reproducible example (including ABAP code).
Sorry Mr gkralik. puting live data as well as ABAP code in public is not authorized for me. It is a long procedure and takes time. I am a PHP programmer and am more into GUI interface. The organization has assigned me with ABAP developer to create BAPI as required for the report. This BAPI returns Current Finished Goods Stock Description My code checks for columns key and column value dynamically and displays output in Table format.
Wincache info
I do not need any production code, just a minimal example that reproduces the issue (with a step by step explanation). Without that, I won't be able to help you. This also has nothing to do with wincache, but might be related to either a metadata cache in SAP itself or the cache used by the NetWeaver SDK.
I have informed the ABAP developer to check SAP Portal cache. I will get back to you once he replies. Any idea how to refresh metadata from iis server dynamically using PHP.
use SAPNWRFC\Connection as SapConnection;
use SAPNWRFC\Exception as SapException;
$sap = false;
$ReadData2 = "";
$config = [
'ashost' => DEV_ASHOST,
'sysnr' => DEV_SYSNR,
'client' => DEV_CLIENT,
'user' => DEV_USER,
'passwd' => DEV_PASSWD,
'trace' => SapConnection::TRACE_LEVEL_OFF
];
try {
$sap = new SapConnection($config);
$ReadCall2=$sap->getFunction("ZBAPI_FG_STOCK_DETAILS");
$NOW = new DateTime();
$FROM_DATE = $NOW->format('Ymd');
$TO_DATE = $NOW->format('Ymd');
$ReadParams2 = [
// run empty parameter
// "FROM_DATE" => "$FROM_DATE", // "TO_DATE" => "$TO_DATE"
// "I_MATTYPE" => 'FERT',
// "PLANT" => "1000"
];
$ReadDataObject2 = $ReadCall2->invoke($ReadParams2 );
if(isset($ReadDataObject2['RETURN'][0]['TYPE']) && $ReadDataObject2['RETURN'][0]['TYPE'] == 'E'){
echo "Error from SAP: ". $ReadDataObject2['RETURN'][0]['MESSAGE'];
$sap->close();
exit();
} else{
$ReadData2 = ($ReadDataObject2["IT_FGSTOCK"]);
}
$sap->close();
} catch(SapException $ex) {
echo 'Exception: ' . $ex->getMessage() . PHP_EOL;
echo "<br />";echo "<br />";
$errorInfo = $ex->getErrorInfo();
var_dump($errorInfo);echo "<br />";echo "<br />";
var_dump(!empty($errorInfo["code"]));echo "<br />";
var_dump(!empty($errorInfo["key"]));echo "<br />";
var_dump(!empty($errorInfo["message"]));
}
This is my code.
I will have a look at providing a method for clearing the repository cache. Cannot give you a timeframe though.
Thank you Gregor Kralik for your time. I have 20 days before moving to production. At present restarting iis for every change in BAPI table fields.
As I am not regular to forums, Please guide by providing an example link if someone has explained the quoted requirement --> "(just a minimal example that reproduces the issue (with a step by step explanation) )" so that i can improve my explanation to clearly visualize the issue.
Also this is the only successful library that works for me. Error Handling is also easy. Thanks for the detailed documentation.
hello, in the file sapnwrfc.c line 456 function "getFunction" ( PHP_METHOD(Connection, getFunction)) , Add 2 variables:
const SAP_UC sysnr_u; zend_string sysnr;
set value for sysnr: sysnr = zend_string_init("sysnr", strlen("sysnr"), 0);
Remove Cache, Add code between the lines "intern = SAPNWRFC_CONNECTION_OBJ_P(getThis());" and "// get function description":
// Remove Cache Function Module
for (i = 0; i < intern->rfc_login_params_len; i++) {
if (intern->rfc_login_params[i].name == zend_string_to_sapuc(sysnr)){
sysnr_u = intern->rfc_login_params[i].value;
break;
}
}
rc = RfcRemoveFunctionDesc(sysnr_u,(function_name_u = zend_string_to_sapuc(function_name)),&error_info);
if (rc != RFC_OK) {
sapnwrfc_throw_function_exception(error_info, "Problem removing function description from the cache %s", ZSTR_VAL(func_intern->name));
zend_replace_error_handling(EH_NORMAL, NULL, NULL);
RETURN_NULL();
}
save file and make the library.
Yes, this is currently in the works. Although I do not want to clear the function cache unconditionally but make it dependent on a parameter to Connection::getFunction()
. Something like this:
// second parameter $clearFunctionDescCache, defaults to false
$function = $connection->getFunction('STFC_CHANGING', true);
Additionally, I'd like to provide a function \SAPNWRFC\remove_function_desc($name)
to make manually clearing the cache possible.
What do you think?
Or maybe an option at Connection
level, like:
$conn = new Connection([
// ...
'use_function_desc_cache' => false,
])
I am not sure whether i should touch the main files. Suppose if i make change, do i have to rebuild(NO IDEA HOW IT IS DONE) sapnwrfc or can i use it directly after modification ?
option at connection would be great.
Yes, this is currently in the works. Although I do not want to clear the function cache unconditionally but make it dependent on a parameter to
Connection::getFunction()
. Something like this:// second parameter $clearFunctionDescCache, defaults to false $function = $connection->getFunction('STFC_CHANGING', true);
Additionally, I'd like to provide a function
\SAPNWRFC\remove_function_desc($name)
to make manually clearing the cache possible.What do you think?
Hi Gregor Currently i am restarting the web server for any BAPI change. above mentioned functionality would be a great help :)
I did almost forget about this, sorry...
What are your thoughts about the getFunction() parameter vs. a connection level setting?
connection level setting would be great.
Just a quick heads-up, I didn't forget about this. Its currently a work in progress.
See the commit message of b58cbfa for details. Documenation still needs to be updated before I will release a new version.
@goalmaker If you are able to test the changes in master that would be much appreciated.
@goalmaker Did you have a chance to look at the changes?
Hi Gregor, I appreciate your work. But I do not know what is a commit or what changes i will have to do to be effective. Or is it just copy paste of files. However i am trying to learn how to implement fixes. I will get back to you once i implement. thank you brother
You will have to compile the extension yourself. For Windows, follow the instructions here.
Closing this, as version 1.3.0 with support for clearing the function description cache has been released.
When the bapi TABLE column format change the response array doesnt map with respective fields unless WEBSERVER is restarted.
I am using IIS server and php 7.0.21 x64.
When i restart the iis server the data(value) maps with respective fields(Key).
Kindly advise.