PHP code example of trim07 / service-layer-sap
1. Go to this page and download the library: Download trim07/service-layer-sap library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
trim07 / service-layer-sap example snippets
$config = [
'https' => true,
'host' => 'IP or Hostname',
'port' => 50000,
'sslOptions' => [
"cafile" => "path/to/certificate.crt",
"verify_peer" => true,
"verify_peer_name" => true,
],
'version' => 2
];
$sap = SAPClient::createSession($config, 'SAP UserName', 'SAP Password', 'Company', 'Language');
use Trim07\ServiceLayerSap\Filters\Equal;
$sap = SAPClient::createSession($config, 'SAP UserName', 'SAP Password', 'Company', 'Language');
$items = $sap->crossJoin(['Items', 'Items/ItemWarehouseInfoCollection', 'Warehouses'])
->expand([
'Items' => ['ItemCode', 'ItemName'],
'Warehouses' => ['WarehouseCode', 'WarehouseName']])
->where(new Equal('Items/ItemCode', 'Items/ItemWarehouseInfoCollection/ItemCode'))
->where(new Equal('Items/ItemWarehouseInfoCollection/WarehouseCode', 'Warehouses/WarehouseCode'))
->findAll()
$sap = SAPClient::createSession($config, 'SAP UserName', 'SAP Password', 'Company', 'Language');
$orders = $sap->getService('Orders');
$result = $orders->queryBuilder()
->select('DocEntry,DocNum')
->orderBy('DocNum', 'asc')
->limit(5)
->findAll();
...
$orders = $sap->getService('Orders');
$result = $orders->queryBuilder()
->select('DocEntry,DocNum')
->find(123456); // DocEntry value
...
$meta = $orders->getMetaData();
...
$orders = $sap->getService('Orders');
$result = $orders->create([
'CardCode' => 'BP Card Code',
'DocDueDate' => 'Doc due date',
'DocumentLines' => [
[
"ItemCode" => "Item Code",
"Quantity" => 100,
]
]
]);
...
$orders = $sap->getService('Orders');
$result = $orders->update(19925, [
'Comments' => 'Comment added here'
]);
...
$orders = $sap->getService('Orders');
$result = $orders->action(19925, 'Cancel');
...
$orders = $sap->getService('Orders');
$result = $orders->action(19925, 'Close');
...
$orders = $sap->getService('Orders');
$orders->headers(['Prefer' => 'odata.maxpagesize=0']);
$result = $orders->queryBuilder()
->select('DocEntry,DocNum')
->find(123456); // DocEntry value