# CREDITDEBITMEMOREQUEST_IN

**SOAP v1.0.0 — ACTIVE**

## Title / 标题
**Credit/Debit Memo - Create for Self-Billing / 贷项/借项凭证 - 为自开票创建**

## Operation / 操作
`CreditDebitMemoRequestCreate`

---

## Description / 描述
This asynchronous inbound service creates credit memos and debit memos that reference existing invoices, credit memo requests, or debit memo requests, supporting self-billing scenarios in Accounts Receivable.

此异步入站服务创建引用现有发票、贷项凭证请求或借项凭证请求的贷项凭证和借项凭证，支持应收账款中的自开票场景。

---

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

## Message Structure / 消息结构

### Request / 请求
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `CreditDebitMemoRequest` | `SELFBILL_CDMR` | Credit/Debit memo request header | 贷项/借项凭证请求抬头 |
| `?ReferenceDocument` | `CHAR(10)` | Reference invoice or request | 参考发票或请求 |
| `?ReferenceYear` | `CHAR(4)` | Fiscal year of reference | 参考会计年度 |
| `?DocumentType` | `CHAR(2)` | Credit/debit memo type | 贷项/借项凭证类型 |
| `?PostingDate` | `DATE` | Posting date | 过账日期 |
| `?CompanyCode` | `CHAR(4)` | Company code | 公司代码 |
| `Items` | Table | Credit/debit memo items | 贷项/借项凭证项目 |
| `?ItemNumber` | `NUMC(6)` | Item number | 项目编号 |
| `?Material` | `CHAR(40)` | Material number | 物料编号 |
| `?Quantity` | `QUAN` | Quantity | 数量 |
| `?Unit` | `UNIT(3)` | Unit of measure | 计量单位 |
| `?Amount` | `DECIMAL` | Amount in document currency | 凭证货币金额 |
| `?TaxCode` | `CHAR(2)` | Tax code | 税码 |

### Response / 响应
| Element | Type | Description (EN) | Description (CN) |
|---------|------|------------------|------------------|
| `Return` | `BAPIRETURN` | Application log message | 应用程序日志消息 |
| `?Type` | `CHAR(1)` | Message type (S/E/W/I) | 消息类型（成功/错误/警告/信息） |
| `?Message` | `CHAR(220)` | Message text | 消息文本 |
| `DocumentNumber` | `CHAR(10)` | Created document number | 创建的凭证编号 |
| `DocumentYear` | `CHAR(4)` | Fiscal year of document | 凭证会计年度 |

---

## Example Payload / 示例负载

### Request
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CreditDebitMemoRequestCreate>
      <CreditDebitMemoRequest>
        <ReferenceDocument>INV-10000001</ReferenceDocument>
        <ReferenceYear>2026</ReferenceYear>
        <DocumentType>DR</DocumentType>
        <PostingDate>2026-07-23</PostingDate>
        <CompanyCode>1000</CompanyCode>
      </CreditDebitMemoRequest>
      <Items>
        <item>
          <ItemNumber>10</ItemNumber>
          <Material>MAT-001</Material>
          <Quantity>5</Quantity>
          <Unit>PC</Unit>
          <Amount>500.00</Amount>
          <TaxCode>V1</TaxCode>
        </item>
        <item>
          <ItemNumber>20</ItemNumber>
          <Material>MAT-002</Material>
          <Quantity>2</Quantity>
          <Unit>PC</Unit>
          <Amount>200.00</Amount>
          <TaxCode>V1</TaxCode>
        </item>
      </Items>
    </CreditDebitMemoRequestCreate>
  </soap:Body>
</soap:Envelope>
```

### Response
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CreditDebitMemoRequestCreateResponse>
      <Return>
        <Type>S</Type>
        <Message>Credit/Debit memo created / 贷项/借项凭证已创建</Message>
      </Return>
      <DocumentNumber>CD-10000050</DocumentNumber>
      <DocumentYear>2026</DocumentYear>
    </CreditDebitMemoRequestCreateResponse>
  </soap:Body>
</soap:Envelope>
```

---

## Error Codes / 错误代码
| Code | Description (EN) | Description (CN) |
|------|------------------|------------------|
| `CDM_001` | Reference document not found | 未找到参考凭证 |
| `CDM_002` | Invalid document type | 无效的凭证类型 |
| `CDM_003` | Amount exceeds reference document amount | 金额超过参考凭证金额 |
| `CDM_004` | Posting date not in open period | 过账日期不在开放期间 |
| `CDM_005` | Duplicate request reference | 重复的请求参考 |

---

## Notes / 备注
- This service is asynchronous; processing is performed in background / 该服务为异步方式，处理在后台执行
- Reference document must exist and be posted / 参考凭证必须存在且已过账
- The credit/debit memo type must be configured for self-billing / 贷项/借项凭证类型必须为自开票配置