The $expand query option allows to connect to other entities.
OData $expand command. join objects
Item("A001")?$select=ItemCode,ItemWareHouse&$expand=ItemWareHouse
{"ItemCode":"A001",ItemWareHouse:[
{"WhsCode":"01","OnHand":10.5}
{"WhsCode":"02","OnHand":5.3}
]
}
If you do not define the $expand function, the Beas Service Layer returns this as a single line. This is not an ODATA standard, but a function available in Beas Service Layer.
Item("A001")?$select=ItemCode,ItemWareouse
{"ItemCode":"A001","WhsCode":"01","OnHand":10.5},
{"ItemCode":"A001","WhsCode":"02","OnHand":5.3}
Attention
If you work with KeyPredicate in combination with a join without the $expand function, the result is not fully defined.
Example:
BatchNumber("A0001",1003):
{"value":
{"ItemCode":"A001"...}
}
BatchNumber("A001",1003)?$select=Batch,BatchNumberStock/WhsCode
If you have more than one result:
{"value":{"Batch":"5000","Quantity":3} ]
}
If you have more results, an array is created:
{"value":[
{"Batch":"5000","Quantity":3},{"Batch":"5000","Quantity":2}
]
}
It is preferred to work with the $expand function so that the structure of the result is always defined:
BatchNumber("A001",1003)?$select=Batch,BatchNumberStock/WhsCode&$expand=BatchNumberStock
Limitations with multiple levels:
More than one level is not allowed.
Example: BatchNumber -> BatchNumberStock -> WareHouseName
Result of this example is as follows:
BatchNumber("A11896",1)?$select=Batch,BatchNumberStock,BatchNumberStock/WareHouse/WhsName&$expand=BatchNumberStock
{"value": {
"Batch": "BRM0011",
"BatchNumberStock": [
{
"ItemCode": "A11896",
"SystemNumber": 1,
"Quantity": 0,
"WhsCode": "01",
"WhsName": "General Warehouse1"
},
{
"ItemCode": "A11896",
"SystemNumber": 1,
"Quantity": 0,
"WhsCode": "QC",
"WhsName": "QC-Warehouse"
}
]
}
}
All sub-sub objects are on the same level as the sub-object, in this case "BatchNumberStock".
The $expand option works with nested information. The nested information is surrounded by brackets as follows:
$expand=EntityObject(UrlString),EntityOPbject(UrlString) ...
For example:
Workorder?$select=Workorder.DocEntry,WorkorderPos
$expand=WorkorderPos($select=ItemCode,UoM&$expand=UoM)
This creates the following structure:
Workorder (Docentry)
WorkorderPos (ItemCode)
UoM (all fields)
All parameter types are allowed in nested commands. Nested commands are also allowed inside nested commands.
$expand=EntityObject($select=..$expand=x($select=..$expand=y(...)))
The format types can also be mixed.
Attention:
JSON + XML substrucutre is not a JSON compatible string, but it is possible to combine JSON and with JSON array.