Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Zhehui_Xia
Product and Topic Expert
Product and Topic Expert

目录


背景介绍...

前提条件...

测试场景...

测试响应...

 

背景介绍


API “日记账分录 – 过账(同步)”, 技术名称:JournalEntryCreateRequestConfirmation_In

使用此内向服务将日记账分录从外部系统同步过账到您的 SAP S/4HANA Cloud 系统。可根据业务需求扩展此服务。

本篇及系列博客介绍基于API “日记账分录 – 过账(同步)可以实现的场景,本篇介绍客户预付款申请。

前提条件


根据链接,通过 APP – 通信安排来创建场景标识是 SAP_COM_0002 的通信安排。在创建通信安排前,需要先创建通信系统,可以参考如下链接。在创建通信安排时,需要为通信安排绑定创建好的通信系统。通信系统中维护的通信用户,用于在 API 测试时的认证授权。

可以通过链接访问 Business Acceleration Hub ,查看该 API 相关信息。通过链接访问该 API 的业务文档,来查看本 API 支持的字段等详细的细节信息。

测试场景


关于本案例更详细的业务部分分析,请参见Blog-浅析API日记账分录-过账可以实现的场景-业务篇:应收账款(二) 客户预付款申请

在使用测试工具进行测试前,需要进行一些配置上的维护。这里拿 Postman 作为测试工具举例。由于我们测试对象是 SOAP 类型的 API ,所以我们需要在 Headers 里添加字段 SOAPAction ,值为 “#POST” 。同时,因为我们的 Request Body 使用的是 xml 类型,因此我们也需要添加字段 Content-Type ,值为 test/xml 


在 Headers 中进行配置


在填写好发送请求的 url 以及通信用户的 Username 和 Password 后,我们就可以填入 Payload 发送 API 请求。以下是用于本场景的 Example Payload: Down Payment Request ,经过 Postman 的测试生成客户预付款申请。

在该 Payload 里,部分字段需要根据实际业务需求和系统实际情况自行调整,可参考下表:



























































字段名 示例值
AccountingDocumentType DZ
DocumentReferenceID 123
DocumentHeaderText Test Posting
CreatedByUser CB9980069191
CompanyCode 1310
DocumentDate 2023-07-31
PostingDate 2023-07-31
TaxDeterminationDate 2023-07-31
DueCalculationBaseDate 2023-07-31
ReferenceDocumentItem 1
Debtor 13100002
AmountInTransactionCurrency 100
AmountInTransactionCurrency currencyCode CNY

 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sfin="http://sap.com/xi/SAPSCORE/SFIN">
<soapenv:Header/>
<soapenv:Body>
<sfin:JournalEntryBulkCreateRequest>
<MessageHeader>
<ID>MSG_2023-07-31</ID>
<!--<ReferenceID></ReferenceID>-->
<CreationDateTime>2023-07-31T12:00:00.1234567Z</CreationDateTime>
</MessageHeader>
<!--1 or more repetitions:-->
<JournalEntryCreateRequest>
<MessageHeader>
<ID>SUB_MSG_2023-07-31</ID>
<!--<ReferenceID></ReferenceID>-->
<CreationDateTime>2023-07-31T12:00:00.1234567Z</CreationDateTime>
</MessageHeader>
<JournalEntry>
<OriginalReferenceDocumentType>BKPFF</OriginalReferenceDocumentType>
<OriginalReferenceDocument/>
<OriginalReferenceDocumentLogicalSystem/>
<BusinessTransactionType>RFST</BusinessTransactionType>
<AccountingDocumentType>DZ</AccountingDocumentType>
<DocumentReferenceID>123</DocumentReferenceID>
<DocumentHeaderText>Test Posting</DocumentHeaderText>
<CreatedByUser>CB9980069191</CreatedByUser>
<CompanyCode>1310</CompanyCode>
<DocumentDate>2023-07-31</DocumentDate>
<PostingDate>2023-07-31</PostingDate>
<TaxDeterminationDate>2023-07-31</TaxDeterminationDate>
<!--<Reference1InDocumentHeader>12345678901234567890</Reference1InDocumentHeader>-->
<!--<Reference2InDocumentHeader>1234567890</Reference2InDocumentHeader>-->
<!--Zero or more repetitions:-->
<DebtorItem>
<ReferenceDocumentItem>1</ReferenceDocumentItem>
<Debtor>131000 02</Debtor>
<AmountInTransactionCurrency currencyCode="CNY">100</AmountInTransactionCurrency>
<!--<CashDiscountTerms>-->
<!--<DueCalculationBaseDate>2023-07-31</DueCalculationBaseDate>-->
<!--<CashDiscount1Days>0</CashDiscount1Days>-->
<!--<CashDiscount1Percent>0</CashDiscount1Percent>-->
<!--<CashDiscount2Days>0</CashDiscount2Days>-->
<!--<CashDiscount2Percent>0</CashDiscount2Percent>-->
<!--<NetPaymentDays>0</NetPaymentDays>-->
<!--</CashDiscountTerms>-->
<TaxCountry>CN</TaxCountry>
<DownPaymentTerms>
<SpecialGLCode>F</SpecialGLCode>
<!--<SalesOrder>27352</SalesOrder>-->
<!--<SalesOrderItem>10</SalesOrderItem>-->
<TaxCode>X0</TaxCode>
</DownPaymentTerms>
</DebtorItem>
<ProductTaxItem>
<TaxCode>X0</TaxCode>
<AmountInTransactionCurrency currencyCode="CNY">0</AmountInTransactionCurrency>
<DebitCreditCode>H</DebitCreditCode>
<TaxCountry>CN</TaxCountry>
<TaxBaseAmountInTransCrcy currencyCode="CNY">0</TaxBaseAmountInTransCrcy>
</ProductTaxItem>
</JournalEntry>
</JournalEntryCreateRequest>
</sfin:JournalEntryBulkCreateRequest>
</soapenv:Body>
</soapenv:Envelope>

<ProductTaxItem>这部分 TaxCode 不能为空,且需与上面<DownPaymentTerms>里的 TaxCode 保持一致。这部分里的两个金额不需要修改,因为并不会生效。

本 API 支持创建多个日记账。参考下图,如果添加多段 11 ~ 61 行的 <JournalEntryCreateRequest> 部分的内容,则可以同时创建多个日记账。


批量创建日记账



测试响应


测试 SOAP 类型的 API 与 ODATA 类型的 API 有一点不同的是,无法通过返回的状态码来判断我们是否成功运行,因为运行成功后状态码都是 200 (除了 Username 和 Password 不正确的情况返回状态码 401 )。因此我们需要检查运行 API 后的 Response Body 进行判断。如果 <JournalEntryCreateConfirmation> 中的 AccountingDocument 值为 0000000000 ,则说明创建不成功。我们可以根据 Response Body 后面的提示内容对我们的 Payload 进行修正。

如下是成功创建日记账时返回的 Response ,会返回创建成功的会计凭证号。
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<n0:JournalEntryBulkCreateConfirmation xmlns:n0="http://sap.com/xi/SAPSCORE/SFIN" xmlns:prx="urn:sap.com:proxy:CC3:/1SAI/TAS3D871C7855B59197A671:795">
<MessageHeader>
<UUID>a3188079-a55c-1ede-94bb-cc8fba1be42b</UUID>
<ReferenceID>MSG_2023-07-31</ReferenceID>
<CreationDateTime>2023-09-13T02:36:50.665434Z</CreationDateTime>
<SenderBusinessSystemID>CC3</SenderBusinessSystemID>
</MessageHeader>
<ConfirmationInterfaceOrignName/>
<JournalEntryCreateConfirmation>
<MessageHeader>
<UUID>a3188079-a55c-1ede-94bb-cc8fba1c042b</UUID>
<ReferenceID>SUB_MSG_2023-07-31</ReferenceID>
<CreationDateTime>2023-09-13T02:36:50.665502Z</CreationDateTime>
</MessageHeader>
<JournalEntryCreateConfirmation>
<AccountingDocument>1400000020</AccountingDocument>
<CompanyCode>1310</CompanyCode>
<FiscalYear>2023</FiscalYear>
</JournalEntryCreateConfirmation>
<Log>
<MaximumLogItemSeverityCode>1</MaximumLogItemSeverityCode>
<Item>
<TypeID>605(RW)</TypeID>
<SeverityCode>1</SeverityCode>
<Note>Document posted successfully: BKPFF 140000002013102023 0LEU6F6</Note>
<WebURI>http://ldai1cc3.wdf.sap.corp:50000/sap/xi/docu_apperror?ID=NA&amp;OBJECT=RW605&amp;LANGUAGE=E&amp;MSGV1=BKPFF&amp;MSGV2=140000002013102023&amp;MSGV3=0LEU6F6</WebURI>
</Item>
</Log>
</JournalEntryCreateConfirmation>
<Log/>
</n0:JournalEntryBulkCreateConfirmation>
</soap-env:Body>
</soap-env:Envelope>