# CO_PROFIT_CENTRE_GROUP_HIERARC

**SOAP v1.0.0 — ACTIVE**

## Title / 标题
**Profit Centre Group Hierarchy / 利润中心组层次结构**

## Operation / 操作
`ProfitCentreGroupHierarchy`

---

## Description / 描述
This service retrieves and maintains profit centre group hierarchy structures, enabling external systems to read the hierarchical relationships between profit centre groups.

该服务检索和维护利润中心组层次结构，使外部系统能够读取利润中心组之间的层次关系。

---

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

## Message Structure / 消息结构

### Request / 请求
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `HierarchySelect` | `BAPIPCGHR` | Hierarchy selection criteria | 层次结构选择条件 |
| `?ControllingArea` | `CHAR(4)` | Controlling area | 控制范围 |
| `?ProfitCentreGroup` | `CHAR(15)` | Profit centre group | 利润中心组 |
| `?DateFrom` | `DATE` | Valid-from date | 有效期起始日期 |
| `?DateTo` | `DATE` | Valid-to date | 有效期截止日期 |
| `?Language` | `LANG` | Language key | 语言键 |
| `?HierarchyType` | `CHAR(1)` | Hierarchy type (G=group, H=standard) | 层次类型（G=组，H=标准） |
| `IncludeDetails` | `CHAR(1)` | Include profit centre details | 包含利润中心详细信息 |
| `IncludeTexts` | `CHAR(1)` | Include description texts | 包含描述文本 |

### Response / 响应
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `Return` | `BAPIRETURN` | Application log message | 应用程序日志消息 |
| `?Type` | `CHAR(1)` | Message type (S/E/W/I) | 消息类型（成功/错误/警告/信息） |
| `?Code` | `CHAR(20)` | Message code | 消息代码 |
| `?Message` | `CHAR(220)` | Message text | 消息文本 |
| `HierarchyNodes` | Table | Hierarchy node structure | 层次结构节点 |
| `?NodeID` | `CHAR(15)` | Node identifier | 节点标识符 |
| `?ParentNodeID` | `CHAR(15)` | Parent node identifier | 父节点标识符 |
| `?NodeLevel` | `INT` | Node level in hierarchy | 层次结构中的节点级别 |
| `?NodeText` | `CHAR(40)` | Node description | 节点描述 |
| `?ProfitCentre` | `CHAR(10)` | Profit centre assigned to node | 分配给节点的利润中心 |
| `?ProfitCentreName` | `CHAR(40)` | Profit centre name | 利润中心名称 |
| `?ValidFrom` | `DATE` | Validity start date | 有效期起始日期 |
| `?ValidTo` | `DATE` | Validity end date | 有效期截止日期 |

---

## Example Payload / 示例负载

### Request
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ProfitCentreGroupHierarchy>
      <HierarchySelect>
        <ControllingArea>A000</ControllingArea>
        <ProfitCentreGroup>PC_GROUP_01</ProfitCentreGroup>
        <DateFrom>2026-01-01</DateFrom>
        <DateTo>2026-12-31</DateTo>
        <Language>EN</Language>
        <HierarchyType>G</HierarchyType>
        <IncludeDetails>X</IncludeDetails>
        <IncludeTexts>X</IncludeTexts>
      </HierarchySelect>
    </ProfitCentreGroupHierarchy>
  </soap:Body>
</soap:Envelope>
```

### Response
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ProfitCentreGroupHierarchyResponse>
      <Return>
        <Type>S</Type>
        <Code>PCG_001</Code>
        <Message>Hierarchy retrieved successfully / 层次结构已成功检索</Message>
      </Return>
      <HierarchyNodes>
        <item>
          <NodeID>PC_GROUP_01</NodeID>
          <ParentNodeID></ParentNodeID>
          <NodeLevel>0</NodeLevel>
          <NodeText>All Profit Centres / 所有利润中心</NodeText>
        </item>
        <item>
          <NodeID>PC_SUB_A</NodeID>
          <ParentNodeID>PC_GROUP_01</ParentNodeID>
          <NodeLevel>1</NodeLevel>
          <NodeText>Domestic / 国内</NodeText>
          <ProfitCentre>PC-1000</ProfitCentre>
          <ProfitCentreName>China Operations / 中国运营</ProfitCentreName>
        </item>
        <item>
          <NodeID>PC_SUB_B</NodeID>
          <ParentNodeID>PC_GROUP_01</ParentNodeID>
          <NodeLevel>1</NodeLevel>
          <NodeText>International / 国际</NodeText>
          <ProfitCentre>PC-2000</ProfitCentre>
          <ProfitCentreName>Global Operations / 全球运营</ProfitCentreName>
        </item>
      </HierarchyNodes>
    </ProfitCentreGroupHierarchyResponse>
  </soap:Body>
</soap:Envelope>
```

---

## Error Codes / 错误代码
| Code | Description (EN) | Description (CN) |
|------|------------------|------------------|
| `PCG_001` | Controlling area not found | 控制范围未找到 |
| `PCG_002` | Profit centre group not found | 利润中心组未找到 |
| `PCG_003` | No valid hierarchy exists for the period | 该期间无有效层次结构 |
| `PCG_004` | Profit centre group is empty | 利润中心组为空 |

---

## Notes / 备注
- Hierarchy is time-dependent; ensure date range covers the effective period / 层次结构具有时间依赖性，确保日期范围覆盖有效期间
- Node level 0 is the root node of the hierarchy / 节点级别 0 为层次结构的根节点
- A profit centre can appear in multiple groups within the hierarchy / 一个利润中心可以在层次结构中的多个组中出现