技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
sap-mobile【数据与研究】SAP Mobile development skill. Use when building apps with MDK (Mobile Development Kit), SAP BTP SDK for iOS/Android, configuring offline OData store, push notifications, or mobile security. If the user mentions SAP mobile app, MDK, Mobile Services, offline sync, or BTP SDK iOS/Android, use this skill.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
sap-s4hana-extensibility — Backend OData services consumed by mobile appssap-security-authorization — Mobile app authentication and security policiessap-build-apps — Alternative low-code approach for mobile appsChoose your mobile framework:
| Framework | Language | Offline | Best For |
|---|---|---|---|
| MDK (Mobile Dev Kit) | Metadata/JS | Built-in | Cross-platform business apps |
| BTP SDK for iOS | Swift | Built-in | Native iOS enterprise apps |
| BTP SDK for Android | Kotlin/Java | Built-in | Native Android enterprise apps |
| SAP Build Apps | No-code | Manual | Simple apps, citizen developers |
| SAP Mobile Start | Config only | N/A | Unified mobile launchpad |
MDK Quick Start:
Central management platform for all SAP mobile apps:
Mobile App ──► Local SQLite DB ──► Offline OData Store
│
[Sync Engine]
│
SAP Mobile Services
│
Backend OData Service
Sync modes:
| Mode | Description | Use Case |
|---|---|---|
| Download | Server → device | Initial load, refresh |
| Upload | Device → server | Submit local changes |
| Delta sync | Changed records only | Incremental updates |
| Defining requests | Subset of data per entity | Control offline data scope |
MDKApp/
├── Application.app # App-level config
├── Pages/
│ ├── Main.page # Landing page
│ ├── CustomerList.page # List page
│ └── CustomerDetail.page # Detail page
├── Actions/
│ ├── Service/
│ │ ├── InitializeOffline.action
│ │ ├── SyncStartedMessage.action
│ │ └── UploadOffline.action
│ └── Customers/
│ ├── CreateCustomer.action
│ └── UpdateCustomer.action
├── Rules/
│ ├── OnWillUpdate.js
│ └── FormatAddress.js
├── Services/
│ └── MyODataService.service
├── Styles/
│ └── Styles.less
└── i18n/
└── i18n.properties
// Pages/CustomerList.page
{
"_Type": "Page",
"_Name": "CustomerList",
"Caption": "Customers",
"Controls": [
{
"_Type": "Control.Type.SectionedTable",
"_Name": "CustomerTable",
"Sections": [
{
"_Type": "Section.Type.ObjectTable",
"Target": {
"EntitySet": "Customers",
"Service": "/MDKApp/Services/MyODataService.service",
"QueryOptions": "$orderby=CompanyName&$top=50"
},
"ObjectCell": {
"Title": "{CompanyName}",
"Subhead": "{CustomerID}",
"Description": "{City}, {Country}",
"StatusText": "{ContactName}",
"AccessoryType": "DisclosureIndicator",
"OnPress": "/MDKApp/Actions/Customers/NavToDetail.action"
},
"Search": {
"Enabled": true,
"Placeholder": "Search customers...",
"BarcodeScanner": true
},
"EmptySection": {
"Caption": "No customers found"
}
}
]
}
],
"ToolBar": {
"Items": [
{
"_Type": "Control.Type.ToolbarItem",
"_Name": "AddButton",
"Caption": "Add",
"SystemItem": "Add",
"OnPress": "/MDKApp/Actions/Customers/NavToCreate.action"
}
]
}
}
// Actions/Service/InitializeOffline.action
{
"_Type": "Action.Type.ODataService.Initialize",
"_Name": "InitializeOffline",
"Service": "/MDKApp/Services/MyODataService.service",
"ShowActivityIndicator": true,
"OnSuccess": "/MDKApp/Actions/Service/InitializeOfflineSuccessMessage.action",
"OnFailure": "/MDKApp/Actions/Service/InitializeOfflineFailureMessage.action",
"DefiningRequests": [
{
"Name": "CustomersReq",
"Query": "/Customers",
"AutomaticallyRetrievesStreams": false
},
{
"Name": "OrdersReq",
"Query": "/Orders?$filter=OrderDate gt datetime'2026-01-01T00:00:00'",
"AutomaticallyRetrievesStreams": false
}
]
}
// Rules/ValidateCustomer.js
/**
* @param {IClientAPI} clientAPI
* @returns {string} Empty string if valid, error message if invalid
*/
export default function ValidateCustomer(clientAPI) {
const formProxy = clientAPI.getPageProxy().getControl('FormCellContainer');
const companyName = formProxy.getControl('CompanyName').getValue();
const email = formProxy.getControl('Email').getValue();
const phone = formProxy.getControl('Phone').getValue();
if (!companyName || companyName.trim().length < 2) {
return 'Company name must be at least 2 characters';
}
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (email && !emailRegex.test(email)) {
return 'Invalid email address';
}
if (phone && !/^\+?[\d\s-()]{7,15}$/.test(phone)) {
return 'Invalid phone number';
}
return '';
}
import SAPFoundation
import SAPFiori
import UserNotifications
class PushNotificationManager {
static func registerForPush(application: UIApplication) {
UNUserNotificationCenter.current().requestAuthorization(
options: [.alert, .badge, .sound]
) { granted, error in
guard granted else { return }
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
}
static func sendTokenToMobileServices(deviceToken: Data) {
let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
// Register with SAP Mobile Services
let url = URL(string: "\(mobileServicesURL)/mobileservices/push/v1/register")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: [
"deviceToken": tokenString,
"deviceType": "iOS",
"applicationId": Bundle.main.bundleIdentifier ?? ""
])
URLSession.shared.dataTask(with: request).resume()
}
}
import com.sap.cloud.mobile.odata.offline.*
class OfflineSyncManager(private val offlineStore: OfflineODataProvider) {
fun syncData(callback: SyncCallback) {
// Upload local changes first
offlineStore.upload(
successHandler = {
// Then download server changes
offlineStore.download(
successHandler = {
callback.onSuccess()
},
failureHandler = { error ->
callback.onError("Download failed: ${error.message}")
}
)
},
failureHandler = { error ->
if (error is OfflineODataException &&
error.errorCode == OfflineODataErrorCode.UPLOAD_CONFLICT) {
handleConflict(error, callback)
} else {
callback.onError("Upload failed: ${error.message}")
}
}
)
}
private fun handleConflict(error: OfflineODataException, callback: SyncCallback) {
val errorArchive = offlineStore.getErrorArchive()
for (entry in errorArchive) {
// Strategy: server wins (discard local change)
entry.cancelUpload()
// Alternative: client wins — entry.retryUpload()
}
// Retry sync after conflict resolution
syncData(callback)
}
interface SyncCallback {
fun onSuccess()
fun onError(message: String)
}
}
// Mobile Services — App Security Config
{
"security": {
"passcode": {
"enabled": true,
"minLength": 6,
"hasDigit": true,
"retryLimit": 5,
"lockTimeout": 300,
"biometricEnabled": true
},
"certificatePinning": {
"enabled": true,
"pins": [
{
"host": "*.hana.ondemand.com",
"pins": ["sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="]
}
]
},
"rootDetection": {
"enabled": true,
"action": "WARN"
},
"dataProtection": {
"encryptDatabase": true,
"preventScreenCapture": true,
"clipboardTimeout": 60
}
}
}
| Error | Message | Root Cause | Fix |
|---|---|---|---|
Offline init failed | Cannot create offline store | Defining request error or backend down | Check OData service; validate defining request query |
Upload conflict | Entity modified on server | Concurrent edit during offline period | Implement conflict resolution (server/client wins) |
Push: Token invalid | APNS/FCM token rejected | App reinstalled or token expired | Re-register device token on app launch |
Sync timeout | Download timed out | Large dataset or slow network | Reduce defining request scope; increase timeout |
Certificate error | SSL handshake failed | Certificate pinning mismatch | Update pinned certificates; check cert rotation |
Passcode locked | Too many failed attempts | User exceeded retry limit | Admin reset via Mobile Services console |
MDK deploy error | Metadata upload failed | Invalid page/action JSON | Validate JSON syntax; check MDK version compatibility |
OData 413 | Payload too large | Offline store sync payload exceeds limit | Split defining requests; limit data scope |