---
# API: Pricing Configuration Migration
# File: PricingConfigurationMigrationService.md
# Version: 1.0
# Status: ACTIVE
# Protocol: OData V2
# Source URL: https://api.sap.com/api/PricingConfigurationMigrationService/overview
# Generated: 2026-07-24
---

# Pricing Configuration Migration / 定价配置迁移 API

> **API 版本:** 1.0 | **状态:** ACTIVE | **协议:** OData V2  
> **技术名称:** `PricingConfigurationMigrationService`  
> **服务根路径:** `/sap/opu/odata/sap/PricingConfigurationMigrationService`

## 概述 / Overview

该服务支持导出和导入定价方案（定价配置），用于在系统之间迁移定价数据。

This service enables the export and import of pricing schemes (pricing configurations) for migrating pricing data between systems.

---

## 实体列表 / Entity List

| # | 实体名称 | 描述 (EN) | 描述 (CN) | 主键 |
|---|----------|-----------|-----------|------|
| 1 | `PricingScheme` | Pricing Scheme Header | 定价方案抬头 | `PricingSchemeId` |
| 2 | `PricingConditionRecord` | Pricing Condition Records | 定价条件记录 | `PricingSchemeId`, `ConditionRecordId` |
| 3 | `PricingProcedure` | Pricing Procedure Assignment | 定价过程分配 | `PricingSchemeId`, `ProcedureId` |
| 4 | `PricingScale` | Pricing Scale Values | 定价阶梯 | `PricingSchemeId`, `ScaleId` |

---

## 1. PricingScheme — 定价方案抬头

**实体集合路径:** `PricingScheme`  
**主键 (Key):** `PricingSchemeId` (String)

### 字段列表 / Field List

| 字段名 | 类型 | 长度 | 描述 (EN) | 描述 (CN) |
|--------|------|------|-----------|-----------|
| `PricingSchemeId` | String | 20 | Pricing Scheme ID | 定价方案ID |
| `Description` | String | 100 | Description of Pricing Scheme | 定价方案描述 |
| `ValidFrom` | DateTimeOffset | - | Validity Start Date | 有效起始日期 |
| `ValidTo` | DateTimeOffset | - | Validity End Date | 有效截止日期 |
| `Status` | String | 1 | Status (A=Active, I=Inactive) | 状态（A=活跃，I=非活跃） |
| `CreatedBy` | String | 12 | Created By User | 创建人 |
| `CreatedAt` | DateTimeOffset | - | Created At | 创建时间 |
| `LastChangedBy` | String | 12 | Last Changed By User | 最后更改人 |
| `LastChangedAt` | DateTimeOffset | - | Last Changed At | 最后更改时间 |

---

## 2. PricingConditionRecord — 定价条件记录

**实体集合路径:** `PricingConditionRecord`  
**主键 (Key):** `PricingSchemeId` (String), `ConditionRecordId` (String)

### 字段列表 / Field List

| 字段名 | 类型 | 长度 | 描述 (EN) | 描述 (CN) |
|--------|------|------|-----------|-----------|
| `PricingSchemeId` | String | 20 | Pricing Scheme ID | 定价方案ID |
| `ConditionRecordId` | String | 10 | Condition Record ID | 条件记录ID |
| `ConditionType` | String | 4 | Condition Type | 条件类型 |
| `ConditionTable` | String | 3 | Condition Table | 条件表 |
| `ConditionKey` | String | 50 | Condition Key Fields | 条件关键字段 |
| `ConditionRateValue` | Decimal | - | Condition Rate / Amount | 条件费率/金额 |
| `ConditionUnit` | String | 3 | Condition Unit | 条件单位 |
| `ConditionScaleBasis` | String | 1 | Scale Basis (A=Amount, Q=Quantity) | 阶梯基准 |
| `NumberOfConditionScales` | Decimal | - | Number of Scales | 阶梯数量 |
| `ValidFrom` | DateTimeOffset | - | Validity Start | 有效起始日期 |
| `ValidTo` | DateTimeOffset | - | Validity End | 有效截止日期 |

---

## 3. PricingProcedure — 定价过程分配

**实体集合路径:** `PricingProcedure`  
**主键 (Key):** `PricingSchemeId` (String), `ProcedureId` (String)

### 字段列表 / Field List

| 字段名 | 类型 | 长度 | 描述 (EN) | 描述 (CN) |
|--------|------|------|-----------|-----------|
| `PricingSchemeId` | String | 20 | Pricing Scheme ID | 定价方案ID |
| `ProcedureId` | String | 6 | Pricing Procedure ID | 定价过程ID |
| `Description` | String | 100 | Description | 描述 |
| `ConditionTypeSequence` | String | 100 | Condition Type Sequence | 条件类型序列 |
| `ValidFrom` | DateTimeOffset | - | Validity Start | 有效起始日期 |
| `ValidTo` | DateTimeOffset | - | Validity End | 有效截止日期 |

---

## 4. PricingScale — 定价阶梯

**实体集合路径:** `PricingScale`  
**主键 (Key):** `PricingSchemeId` (String), `ScaleId` (String)

### 字段列表 / Field List

| 字段名 | 类型 | 长度 | 描述 (EN) | 描述 (CN) |
|--------|------|------|-----------|-----------|
| `PricingSchemeId` | String | 20 | Pricing Scheme ID | 定价方案ID |
| `ScaleId` | String | 10 | Scale ID | 阶梯ID |
| `ScaleLevel` | String | 3 | Scale Level | 阶梯级别 |
| `ScaleAmount` | Decimal | - | Scale Amount From | 阶梯金额从 |
| `ScaleQuantity` | Decimal | - | Scale Quantity From | 阶梯数量从 |
| `ConditionRateValue` | Decimal | - | Condition Rate at This Level | 本级别条件费率 |
| `ScaleUnit` | String | 3 | Scale Unit of Measure | 阶梯计量单位 |

---

## CRUD 端点 / CRUD Endpoints

### 创建 (Create) — POST

```
POST /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme
Content-Type: application/json
```

### 读取 (Read) — GET

```
GET /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme(PricingSchemeId='SCHEME001')
GET /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme?$filter=...
```

### 更新 (Update) — PATCH

```
PATCH /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme(PricingSchemeId='SCHEME001')
Content-Type: application/json
```

### 替换 (Replace) — PUT

```
PUT /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme(PricingSchemeId='SCHEME001')
Content-Type: application/json
```

### 删除 (Delete) — DELETE

```
DELETE /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme(PricingSchemeId='SCHEME001')
```

### 各实体端点路径速查表

| 实体 | 端点路径 |
|------|---------|
| PricingScheme | `PricingScheme` |
| PricingConditionRecord | `PricingConditionRecord` |
| PricingProcedure | `PricingProcedure` |
| PricingScale | `PricingScale` |

---

## 导出操作 / Export Operation

该API支持的典型用法是导出完整定价方案用于迁移。以下示例导出方案内的所有数据。

### 导出请求

```
GET /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme('SCHEME001')?$expand=PricingConditionRecord,PricingProcedure,PricingScale
```

### 响应示例

```json
{
  "PricingSchemeId": "SCHEME001",
  "Description": "Standard China Pricing Scheme",
  "Status": "A",
  "ValidFrom": "2026-01-01T00:00:00Z",
  "ValidTo": "2026-12-31T00:00:00Z",
  "PricingConditionRecord": [
    {
      "ConditionRecordId": "CR0001",
      "ConditionType": "PR00",
      "ConditionTable": "001",
      "ConditionRateValue": 100.00
    }
  ],
  "PricingProcedure": [
    {
      "ProcedureId": "PROC01",
      "Description": "Standard Procedure"
    }
  ],
  "PricingScale": [
    {
      "ScaleId": "SCL001",
      "ScaleLevel": "1",
      "ScaleAmount": 1000.00,
      "ConditionRateValue": 5.00
    }
  ]
}
```

---

## 导入操作 / Import Operation

创建或更新定价方案以完成导入。

### 导入请求示例

```json
POST /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme
Content-Type: application/json

{
  "PricingSchemeId": "SCHEME002",
  "Description": "Imported Pricing Scheme",
  "Status": "A",
  "ValidFrom": "2026-01-01T00:00:00Z",
  "ValidTo": "2026-12-31T00:00:00Z",
  "PricingConditionRecord": [
    {
      "ConditionRecordId": "CR1001",
      "ConditionType": "PR00",
      "ConditionTable": "001",
      "ConditionRateValue": 150.00
    }
  ]
}
```

---

## 导航属性关系总表 / Navigation Property Matrix

| 源实体 | 导航属性 | 目标实体 | 基数 |
|--------|----------|----------|------|
| PricingScheme | `to_PricingConditionRecord` | PricingConditionRecord | 0..* |
| PricingScheme | `to_PricingProcedure` | PricingProcedure | 0..* |
| PricingScheme | `to_PricingScale` | PricingScale | 0..* |

---

## OData 查询选项 / Query Options

| 参数 | 示例 | 说明 |
|------|------|------|
| `$filter` | `$filter=Status eq 'A'` | 过滤 |
| `$select` | `$select=PricingSchemeId,Description` | 选择字段 |
| `$expand` | `$expand=to_PricingConditionRecord` | 展开导航属性 |
| `$top` | `$top=100` | 返回前 N 条 |
| `$skip` | `$skip=50` | 跳过前 N 条 |
| `$orderby` | `$orderby=PricingSchemeId desc` | 排序 |
| `$count` | `$count=true` | 返回计数 |

---

## 错误码 / Error Codes

| HTTP 状态码 | 描述 (EN) | 描述 (CN) |
|-------------|-----------|-----------|
| 200 | OK | 请求成功 |
| 201 | Created | 创建成功 |
| 204 | No Content | 无返回内容 |
| 400 | Bad Request | 请求参数错误 |
| 401 | Unauthorized | 未授权 |
| 403 | Forbidden | 禁止访问 |
| 404 | Not Found | 资源不存在 |
| 409 | Conflict | 数据冲突（如重复ID） |
| 500 | Internal Server Error | 服务器内部错误 |

---

## 认证 / Authentication

### OAuth 2.0 (推荐)

```
Authorization: Bearer <access_token>
Content-Type: application/json
```

### CSRF Token 处理

写操作必须携带有效的 CSRF Token：

```http
# 步骤 1: 获取 CSRF Token
GET /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme
X-CSRF-Token: Fetch

# 响应: X-CSRF-Token: <token_value>

# 步骤 2: 使用 Token 执行写操作
POST /sap/opu/odata/sap/PricingConfigurationMigrationService/PricingScheme
X-CSRF-Token: <token_value>
Content-Type: application/json
```

---

## 备注 / Notes

- 定价方案是定价配置的容器，包含条件记录、定价过程和阶梯数据 / A pricing scheme is a container for pricing configurations including condition records, procedures, and scales
- 导出操作建议使用 `$expand` 一次性获取完整方案数据 / Export operation should use `$expand` to retrieve complete scheme data in one call
- 导入时需确保条件类型在目标系统中存在 / Ensure condition types exist in the target system during import
- 使用批量处理（`$batch`）可以提高大量数据传输效率 / Use batch processing (`$batch`) for efficient bulk data transfer

---