on 2009 Jan 22 10:57 PM
Hello all -
I am looking for help with testing and improving a new PHP RFC extension, sapnwrfc.
This is designed to take advantage of the NetWeaver RFC SDK, and hopefully will help deal with unicode issues.
The code is available at http://www.piersharding.com/download/php/sapnwrfc/
And the primary problems are with:
determining the build process for win32
robustly testing the parameter calling interface.
In the source archive available above, there are sketchy build instructions in INSTAL, and in the unit_tests directory, are examples.
A starting point would be to get the build going and just run those tests.
Cheers,
Piers Harding.
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Hi,
As usual I did a lot of misstakes and errors but finally I had sapnwrfc for PHP working on Mandriva 2007, just to realise that if you read and follow the install instruction, it takes about 10 minutes the first time (I used about six hours). BUT how do I use sapnwrfc?
Is there some documentation somewhere? I read the connect example and the unittests but it does not tell me very much. E.G. how do I get the export meta data?
I run BAPI_CURRENCY_GETLIST and I get a nice array of associative arrays as a result. In the result there is a field 'VALID_TO' that shows up as string(8), but it is a SAP DATE field. I can not for my life figure out how to find out the original SAP data type for the result of a function call.
Any help is highly appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lars -
The unit tests are quite a good start, but unfortunately, it does expect you to know a lot about RFC, ABAP, and SE37 in general. It would be great if people who were working and using all of the sapnwrfc connectors (PHP, Perl, Python, and Ruby), blogged about their path to enlightenment, frustrations, ideas, and triumphs.
If you want meta data for the function calls, then there are specific functions for finding this:
RFC_GET_FUNCTION_INTERFACE_P and RFC_GET_UNICODE_STRUCTURE, RFC_GET_STRUCTURE_DEFINITION_P.
You should find what you need in here.
Cheers.
Thank you very much for your answer.
The reason I need the meta data is I have an interface to the 'old' SAPRFC which can 'autoload' the result into Mysql and I need the meta-information for the SQL 'create table' statements.
I will study your reply and go through the unit tests again and read more carefully this time.
I start build my interface to sapnwrfc today and I will come back with more questions. I hope you do not mind to much.
Example how I use SAPRFC today. I have a job scheduler that controls execution of jobs like:
<job name='curRte' type='script' pgm='sap2.php' comment='Run BAPI for each row in array driver0'>
<!-- sap2.php is my interface to SAPRFC -->
<mydriver>
<name>@J_generate_driver/driver0</name>
<select>('@RATE_TYPE'=='EURO')</select>
</mydriver>
<sap>
<rfc>
<name>BAPI_EXCHRATE_GETCURRENTRATES</name>
<import>
('DATE',@TODAY)
,('DATE_TYPE','V')
,('RATE_TYPE','@RATE_TYPE')
</import>
</rfc>
</sap>
<sql>
<autoload>replace</autoload><database>@C_DB</database><truncate>yes</truncate>
<table>EXCH_RATE_LIST</table> <!-- Only load table EXCH_RATE_LIST -->
</sql>
</job>
Something different. I have recently taken a lot of interest in perl6, will you port sapnwrfc to perl6?
Hi Piers,
The new sapnwrfc is simple to work with. As usual I messed up things, but I do a rewrite now that I understand sapnwrfc better. I still have some problems with chinese letters/signs, not all of them look the same when I look at them in Mysql and SAP, but most of then do so I'm on the right track
I compiled sapnwrfc into PHP 5.3 RC2. I had to comment out a 'static' declaration in sapnwrfc.c for the compile to work. Will you come out with a PHP 5.3 version when 5.3 is released?
Thanks again. SAPNWRFC is really really cool.
Hi -
$fds should be the RFC call container - and instance of an RFC call that you have populated the parameterrs (in this case none), invoke(), and then inspect the return parameters (export/changing parameters, and tables) afterwards.
So - you should only need to do $fds->invoke() - invoke() has no arguments.
The documentation for sapnwrfc for Perl, has had a lot of work on it recently - have a look here http://search.cpan.org/dist/sapnwrfc/sapnwrfc-cookbook.pod , as it should help you understand how it is supposed to work.
Cheers,
Piers Harding.
Actually, I have tried invoke() without arguments before and I get following error:
object(Exception)#3 (7) { ["message:protected"]=> string(64) "sapnwrfc_function::invoke() expects exactly 1 parameter, 0 given" ["string:private"]=> string(0) "" ["code:protected"]=> int(0) ["file:protected"]=> string(34) "C:\xampp\htdocs\sap\sm04\zsm04.php" ["line:protected"]=> int(91) ["trace:private"]=> array(1) { [0]=> array(6) { ["file"]=> string(34) "C:\xampp\htdocs\sap\sm04\zsm04.php" ["line"]=> int(91) ["function"]=> string(6) "invoke" ["class"]=> string(17) "sapnwrfc_function" ["type"]=> string(2) "->" ["args"]=> array(0) { } } } ["severity"]=> int(2) } Exception message: sapnwrfc_function::invoke() expects exactly 1 parameter, 0 given
Fatal error: Uncaught exception 'Exception' with message 'Assertion failed.' in C:\xampp\htdocs\sap\sm04\zsm04.php:130 Stack trace: #0 thrown in C:\xampp\htdocs\sap\sm04\zsm04.php on line 130
Hi Mr. Harding
Just out of curiosity...
Are you still working on this project?
Next year we'll do an upgrade of our SAP system.
Afer then I would like to test the NW RFC SDK with PHP to the fully.
We've already have a lot of experience with the old saprfc SDK and the SAPRFC module for PHP. It works superb! We just can't live and work without it anymore.
Many thanks in advance.
Hi Piers, hello again,
how can we send a table parameter?
I have a rfc function which expects a table besides import parameters. Import parameters are no problem, but when I try to send the table as an array in $parms, I get:
Fatal error: RFC FUNCTION CALL ERROR: set_table_line invalid Input value type in C:\xampp\htdocs\myscript.php on line 100
>
> Hi -
> $fds should be the RFC call container - and instance of an RFC call that you have populated the parameterrs (in this case none), invoke(), and then inspect the return parameters (export/changing parameters, and tables) afterwards.
> So - you should only need to do $fds->invoke() - invoke() has no arguments.
>
> The documentation for sapnwrfc for Perl, has had a lot of work on it recently - have a look here http://search.cpan.org/dist/sapnwrfc/sapnwrfc-cookbook.pod , as it should help you understand how it is supposed to work.
>
> Cheers,
> Piers Harding.
Taking a peek at problem, I solved it by using:
$results = $fds->invoke(array());
invoke() has no arguments, but expects an array, so passing an empty array is mandatory.
> Hi -
>
> passing tables is no problem at all - have a look at the unit_tests directory that comes with the module - in there there are a number of examples - especially FuncDataTest.php.
>
> Cheers,
> Piers Harding.
Hi Piers,
I looked at the examples in the units_tests directory. I could not see an example in which you pass a TABLE as parameter, but IMPORT parameters instad. For example, in FuncTest.php, you passed IMPORT_TABLE, ROWCOUNT and OPTIONS parms, which are IMPORT parms. However, RFC_READ_TABLE accepts also a table named FIELDS and I need an example about the usage of this.
EDIT: I was mistaken, OPTIONS IS a table parameter.
And you wrap such in an additional array, like:
$parms = array( 'QUERY_TABLE' => $TABLENAME,
'FIELDS' => array(array('FIELDNAME' =>"TCODE"))
);
Thanks,
Guvenc
Edited by: Guvenc Kaplan on Dec 9, 2009 10:57 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.