https://hcpms-XXXXXXtrial.hanatrial.ondemand.com/SampleServices/ESPM.svc/$metadata
mkdir ~/Documents/iOSSDKProjects/GettingStarted/GettingStarted/ProxyClasses/
sapcpsdk-proxygenerator -m ~/Documents/iOSSDKProjects/GettingStarted/metadata.xml -d ~/Documents/iOSSDKProjects/GettingStarted/GettingStarted/ProxyClasses
import SAPOData
// MARK: - OData queries
private func getProducts(_ serviceRoot: URL, _ urlSession: SAPURLSession) {
let oDataProvider = OnlineODataProvider(serviceName: "ESPMContainer", serviceRoot: serviceRoot, sapURLSession: urlSession)
let espmContainer = ESPMContainer(provider: oDataProvider)
espmContainer.fetchProducts() { products, error in
guard let products = products else {
print("Error fetching products: \(error!.localizedDescription)")
return
}
print("Got \(products.count) products and the first product name is \(products[0].name!)")
}
}
getProducts(serviceURL, myContext.sapURLSession)
private func getProductNamesOnly(_ serviceRoot: URL, _ urlSession: SAPURLSession) {
let oDataProvider = OnlineODataProvider(serviceName: "ESPMContainer", serviceRoot: serviceRoot, sapURLSession: urlSession)
Logger.shared(named: "SAP.OData").logLevel = LogLevel.debug
oDataProvider.traceRequests = true
oDataProvider.traceWithData = true
oDataProvider.prettyTracing = true
let espmContainer = ESPMContainer(provider: oDataProvider)
let query = DataQuery()
.select(Product.name)
.where(Product.category.equal("Notebooks"))
.orderBy(Product.name)
espmContainer.fetchProducts(matching: query) { products, error in
guard let products = products else {
self.logger.error("Error fetching products: \(error!.localizedDescription)")
return
}
print("Got \(products.count) products names only and the first product name is \(products[0].name!)")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
38 | |
19 | |
13 | |
13 | |
11 | |
10 | |
10 | |
10 | |
8 | |
8 |