@@ -10,24 +10,42 @@ This repository implements the [PHP/SAP][phpsap] interface for [Piers Hardings `
1010## Usage
1111
1212``` sh
13- composer require php-sap/saprfc-harding:^2.0
13+ composer require php-sap/saprfc-harding
1414```
1515
1616``` php
1717<?php
18- use phpsap\saprfc\SapRfcConfigA;
19- use phpsap\saprfc\SapRfcConnection;
20-
21- $result = (new SapRfcConnection(new SapRfcConfigA([
22- 'ashost' => 'sap.example.com',
23- 'sysnr' => '001',
24- 'client' => '002',
25- 'user' => 'username',
26- 'passwd' => 'password'
27- ])))
28- ->prepareFunction('MY_COOL_SAP_REMOTE_FUNCTION')
29- ->setParam('INPUT_PARAM', 'some input value')
30- ->invoke();
18+ //Include the composer autoloader ...
19+ require_once 'vendor/autoload.php';
20+ //... and add the namespaces of the classes used.
21+ use phpsap\classes\Config\ConfigTypeA;
22+ use phpsap\DateTime\SapDateTime;
23+ use phpsap\saprfc\SapRfc;
24+ /**
25+ * Create an instance of the SAP remote function using its
26+ * name, input parameters, and connection configuration.
27+ *
28+ * The imaginary SAP remote function requires a
29+ * date as input and will return a date as output.
30+ *
31+ * In this case the configuration array is defined manually.
32+ */
33+ $result = (new SapRfc(
34+ 'MY_COOL_SAP_REMOTE_FUNCTION',
35+ [
36+ 'IV_DATE' => (new DateTime('2019-12-31'))
37+ ->format(SapDateTime::SAP_DATE)
38+ ],
39+ new ConfigTypeA([
40+ ConfigTypeA::JSON_ASHOST => 'sap.example.com',
41+ ConfigTypeA::JSON_SYSNR => '999',
42+ ConfigTypeA::JSON_CLIENT => '001',
43+ ConfigTypeA::JSON_USER => 'username',
44+ ConfigTypeA::JSON_PASSWD => 'password'
45+ ])
46+ ))->invoke();
47+ //The output array contains a DateTime object.
48+ echo $result['OV_DATE']->format('Y-m-d') . PHP_EOL;
3149```
3250
3351For further documentation, please read the documentation on [ PHP/SAP] [ phpsap ] !
0 commit comments