Skip to content

Commit de45e31

Browse files
committed
prepare update to interface v2 and common v3 releases
1 parent c4e10cd commit de45e31

10 files changed

+33
-216
lines changed

Diff for: abstract-rfc.md

-103
This file was deleted.

Diff for: common.md

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ The following common classes are available in namespace `phpsap\common`, and the
1616
### Function
1717

1818
* `AbstractFunction` Manages a PHP/SAP remote function call implementing `\phpsap\interfaces\IFunction`.
19-
* `AbstractRemoteFunctionCall` Proxy class to simplify PHP/SAP remote function calls implementing `\phpsap\interfaces\IFunction`.
2019

2120
### Exceptions
2221

Diff for: index.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Especially short explanation for people in a hurry.
2626
Use `composer require` to add PHP/SAP to your project. Depending on the
2727
[PHP module](php-modules) you need to require a certain PHP/SAP composer
2828
package.
29+
30+
Module Author | Module | supported PHP versions | composer require
31+
------------------------ | ----------- | ---------------------- | -------------------------
32+
[Eduard Koucky][koucky] | `saprfc` | PHP 4.x - 5.5.x | `composer require php-sap/saprfc-koucky`
33+
[Piers Harding][harding] | `sapnwrfc` | PHP 5.x | `composer require php-sap/saprfc-harding`
34+
[Gregor Kralik][kralik] | `sapnwrfc` | PHP 7.x | `composer require php-sap/saprfc-kralik`
2935

3036
```php
3137
<?php
@@ -40,7 +46,8 @@ $result = (new SapRfcConnection(new SapRfcConfigA([
4046
'passwd' => 'password'
4147
])))
4248
->prepareFunction('MY_COOL_SAP_REMOTE_FUNCTION')
43-
->invoke(['INPUT_PARAM' => 'value']);
49+
->setParam('INPUT_PARAM', 'some input value')
50+
->invoke();
4451
```
4552

4653
## Documentation
@@ -49,5 +56,8 @@ $result = (new SapRfcConnection(new SapRfcConfigA([
4956
- [Configure a connection](saprfc-config)
5057
- [Establish a connection](saprfc-connection)
5158
- [Invoke a function call](saprfc-function)
52-
* [Extend `AbstractRemoteFunctionCall`](abstract-rfc)
5359
* [DateTime conversions for SAP](datetime)
60+
61+
[koucky]: http://saprfc.sourceforge.net/ "SAPRFC extension module for PHP"
62+
[harding]: https://github.com/piersharding/php-sapnwrfc "SAP RFC Connector using the SAP NW RFC SDK for PHP"
63+
[kralik]: https://github.com/gkralik/php7-sapnwrfc "SAP NW RFC SDK extension for PHP7"

Diff for: motivation.md

+4-75
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
I inherited a project running on PHP 5.5.x containing undocumented code dealing
44
with SAP remote function calls. As a way to connect, [Eduard Kouckys SAPRFC
55
module][koucky] had been used. In order to switch to a more current PHP
6-
version, I had rewrite the PHP code and replace the PHP module too. The
6+
version, I had to rewrite the PHP code and replace the PHP module too. The
77
question was: How can I be sure, that the code of this project dealing with
88
SAP remote function calls will not be the source of errors?
99

@@ -14,13 +14,10 @@ That lead to the following requirements:
1414
2. The code in my project dealing with SAP remote function calls has to work
1515
for several [PHP modules](php-modules) and it still has to work, in case
1616
of a switch to a different way of communicating with SAP.
17-
3. Any parameters of a SAP remote function call have to be defined as methods
18-
as a way of documenting the API of a SAP remote function call via the
19-
editors autocomplete functionality.
20-
4. The configuration has to be as interchangeable as possible between the PHP
17+
3. The configuration has to be as interchangeable as possible between the PHP
2118
modules.
2219

23-
### Example 1: connect ➔ prepare ➔ invoke
20+
### Example: connect ➔ prepare ➔ invoke
2421

2522
```php
2623
<?php
@@ -41,75 +38,7 @@ $connection = new SapRfcConnection(new SapRfcConfigA($config));
4138
//prepare a function call
4239
$function = $connection->prepareFunction('MY_COOL_SAP_REMOTE_FUNCTION');
4340
//call the remote function
44-
$result = $function->invoke(['paramName' => 'value']);
45-
```
46-
47-
### Example 2: extend remote function call
48-
49-
```php
50-
<?php
51-
52-
use phpsap\saprfc\AbstractRemoteFunctionCall;
53-
54-
class MyCoolSapRemoteFunction extends AbstractRemoteFunctionCall
55-
{
56-
/**
57-
* Define the name of the remote function.
58-
* @return string
59-
*/
60-
public function getName()
61-
{
62-
return 'MY_COOL_SAP_REMOTE_FUNCTION';
63-
}
64-
65-
/**
66-
* Create the SAP remote function call parameters as code.
67-
* @param int $value
68-
* @return $this
69-
*/
70-
public function paramA($value)
71-
{
72-
if (!is_int($value)) {
73-
throw new InvalidArgumentException('Expected value to be int.');
74-
}
75-
return $this->setParam('paramA', $value);
76-
}
77-
78-
/**
79-
* Call SAP remote function to see, if paramA succeeds.
80-
* @param null|array $params Optional parameter array.
81-
* @return bool success?
82-
* @throws \phpsap\interfaces\exceptions\IConnectionFailedException
83-
* @throws \phpsap\interfaces\exceptions\IUnknownFunctionException
84-
* @throws \phpsap\exceptions\FunctionCallException
85-
*/
86-
protected function invoke($params = null)
87-
{
88-
//parent returns array
89-
$result = parent::invoke($params);
90-
return $result['E_OK'] !== 'X';
91-
}
92-
}
93-
```
94-
```php
95-
<?php
96-
97-
use phpsap\saprfc\SapRfcConfigA;
98-
99-
//stored configuration, JSON encoded
100-
$config = '{
101-
"ashost": "sap.example.com",
102-
"sysnr": "001",
103-
"client": "01",
104-
"user": "username",
105-
"passwd": "password"
106-
}';
107-
//create a new SAP remote function instance using the stored configuration
108-
$remoteFunction = new MyCoolSapRemoteFunction(new SapRfcConfigA($config));
109-
//set the parameter for the SAP remote function
110-
$remoteFunction->paramA(123);
111-
//call the SAP remote function
112-
$result = $remoteFunction->invoke();
41+
$result = $function->setParam('paramName', 'value')->invoke();
11342
```
11443

11544
[koucky]: http://saprfc.sourceforge.net/ "SAPRFC extension module for PHP"

Diff for: php-modules.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following PHP modules are currently supported by PHP/SAP.
44

5-
Author | Module | supported PHP versions | PHP/SAP composer package
5+
Module Author | Module | supported PHP versions | PHP/SAP composer package
66
------------------------ | ----------- | ---------------------- | -------------------------
77
[Eduard Koucky][koucky] | `saprfc` | PHP 4.x - 5.5.x | [![Packagist][koucky-version-badge]][koucky-packagist]
88
[Piers Harding][harding] | `sapnwrfc` | PHP 5.x | [![Packagist][harding-version-badge]][harding-packagist]

Diff for: res/php-sap.svg

+11-21
Loading

Diff for: res/php-sap.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ digraph G {
3131
color=red;
3232
node [color=red];
3333
label="your code";
34-
yourcode1 [label="connect ➔ prepare ➔ invoke"];
35-
yourcode2 [label="extending AbstractRemoteFunctionCall"];
34+
yourcode [label="connect ➔ prepare ➔ invoke"];
3635
}
37-
yourcode1 -> "php-sap/saprfc-koucky" [lhead=cluster2 color=red];
38-
yourcode2 -> "php-sap/saprfc-kralik" [lhead=cluster2 color=red];
36+
yourcode -> "php-sap/saprfc-koucky" [lhead=cluster2 color=red];
3937
}
4038
@enduml

Diff for: saprfc-config.md

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ $config = new SapRfcConfigA($configArray);
112112

113113
[Go back to usage overview](usage)
114114
| [Continue with establishing a connection](saprfc-connection)
115-
| [Continue reading about extending `AbstractRemoteFunctionCall`](abstract-rfc)
116115

117116
[jsonserializable]: http://php.net/manual/en/class.jsonserializable.php
118117
[parse_ini_file]: http://php.net/manual/de/function.parse-ini-file.php

Diff for: saprfc-function.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ $remoteFunction->setParam('IV_BLUE', 'blue');
9494

9595
/**
9696
* Invoke a remote function call using the parameters IV_RED='red' and
97-
* IV_BLUE='green' by overwriting IV_BLUE upon invoke.
97+
* IV_BLUE='blue'.
9898
*/
9999
try {
100-
$result1 = $remoteFunction->invoke(['IV_BLUE' => 'green']);
100+
$result1 = $remoteFunction->invoke();
101101
} catch (\phpsap\interfaces\exceptions\IFunctionCallException $exception) {
102102
printf(
103103
'The remote function call failed. Message: %s',
@@ -110,7 +110,7 @@ $remoteFunction->setParam('IV_RED', 'green');
110110

111111
/**
112112
* Invoke a remote function call using the parameters IV_RED='green' and
113-
* IV_BLUE='green'.
113+
* IV_BLUE='blue'.
114114
*/
115115
try {
116116
$result2 = $remoteFunction->invoke();

Diff for: usage.md

-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,4 @@ In order to call a SAP remote function, you need to
1010
[configure](saprfc-config) a [connection](saprfc-connection) and then invoke a
1111
[function](saprfc-function).
1212

13-
In case you want to use the SAP remote function API like any other PHP class,
14-
you can [extend `AbstractRemoteFunctionCall`](abstract-rfc) and you will get
15-
implicit documentation of your SAP remote function call parameters and the
16-
return value(s).
17-
1813
[Continue reading on how to configure a connection](saprfc-config).

0 commit comments

Comments
 (0)