# CO_LOG_MDR_PLANT_PURCH_ORG

**SOAP v1.0.0 — ACTIVE**

## Title / 标题
**Assignments of Plant to Purchasing Organization – Replicate / 工厂到采购组织的分配 – 复制**

## Operation / 操作
`PlantPurchOrgBulkReplicateRequest`

---

## Description / 描述
Transfers assignments of plants to purchasing organizations from SAP S/4HANA Cloud to an external system using this asynchronous outbound service.

使用此异步出站服务，将工厂到采购组织的分配从 SAP S/4HANA Cloud 传输到外部系统。

---

## Endpoint / 端点
| Environment | URL |
|-------------|-----|
| Production | `https://sap.example.com/sap/bc/srt/rfc/sap/CO_LOG_MDR_PLANT_PURCH_ORG` |
| Test | `https://sap-test.example.com/sap/bc/srt/rfc/sap/CO_LOG_MDR_PLANT_PURCH_ORG` |

## Message Structure / 消息结构

### Request / 请求
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `PlantPurchOrgAssignment` | Table | Plant to purchasing org assignments | 工厂到采购组织的分配列表 |
| `?Plant` | `CHAR(4)` | Plant code | 工厂代码 |
| `?PurchasingOrganization` | `CHAR(4)` | Purchasing organization code | 采购组织代码 |
| `?Default` | `BOOLEAN` | Default purchasing org indicator | 默认采购组织标识 |
| `?ValidFrom` | `DATE` | Validity start date | 有效期开始日期 |
| `?ValidTo` | `DATE` | Validity end date | 有效期结束日期 |

### Response / 响应
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `Return` | `BAPIRETURN` | Replication result status | 复制结果状态 |
| `?Type` | `CHAR(1)` | Message type (S/E/W/I) | 消息类型（成功/错误/警告/信息） |
| `?Message` | `CHAR(220)` | Status message text | 状态消息文本 |
| `?LogMsgNo` | `NUMC(6)` | Message sequence number | 消息序号 |

---

## Example Payload / 示例负载

### Request
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <PlantPurchOrgBulkReplicateRequest>
      <PlantPurchOrgAssignment>
        <item>
          <Plant>PL01</Plant>
          <PurchasingOrganization>PURC_ORG1</PurchasingOrganization>
          <Default>true</Default>
          <ValidFrom>2026-01-01</ValidFrom>
          <ValidTo>9999-12-31</ValidTo>
        </item>
        <item>
          <Plant>PL02</Plant>
          <PurchasingOrganization>PURC_ORG1</PurchasingOrganization>
          <Default>false</Default>
          <ValidFrom>2026-01-01</ValidFrom>
          <ValidTo>9999-12-31</ValidTo>
        </item>
      </PlantPurchOrgAssignment>
    </PlantPurchOrgBulkReplicateRequest>
  </soap:Body>
</soap:Envelope>
```

### Response
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <PlantPurchOrgBulkReplicateResponse>
      <Return>
        <Type>S</Type>
        <Message>Assignments replicated successfully / 分配复制成功</Message>
        <LogMsgNo>000001</LogMsgNo>
      </Return>
    </PlantPurchOrgBulkReplicateResponse>
  </soap:Body>
</soap:Envelope>
```

---

## Error Codes / 错误代码
| Code | Description (EN) | Description (CN) |
|------|------------------|------------------|
| `PPO_001` | Plant not found in system | 系统中未找到工厂 |
| `PPO_002` | Purchasing organization not found | 未找到采购组织 |
| `PPO_003` | Assignment already exists | 分配关系已存在 |
| `PPO_004` | Validity period is invalid | 有效期无效 |

---

## Notes / 备注
- This is an asynchronous outbound service / 这是一个异步出站服务
- Only active assignments are replicated / 仅复制有效的分配关系
- A plant can have multiple purchasing organizations, but only one default / 一个工厂可以有多个采购组织，但只有一个默认组织
- Max 5000 assignments per request / 每次请求最多 5000 条分配记录