SAP provides a Journal Entry Post / Create API that is very powerful and caters to quite a few scenarios. There are certain limitations to the API though. One amongst them being your ability to control Payment Terms. The Journal Entry Post API provides no option to key in Payment Terms. A workaround is to use the Journal Entry Change API.
Introduction
The Journal Entry Post API provides you with the option to post customer Invoices, Supplier Invoices, Debit Memo and Credit Memo’s into S/4 Hana Cloud amongst multiple things. While this API has the option to provide Discount Terms etc, there is no option to provide Payment Terms externally through this API.
The Journal Entry – Change API provides you with the option to update the payment terms of a Journal Entry.
For one such requirement recently we ended up with a 2 step approach,
- Post the Journal Entry through the normal Journal Entry Post Synchronous API
- If the Journal Entry is posted successfully, immediately update the Payment Terms using the Journal Entry – Change API
Set Up Communication Arrangement for Scenario: SAP_COM_0002
I am not going into the details of set up of a Communication System, Communication Arrangement etc. but just putting in some screenshots for easy reference. You can refer to this blog for these steps : User Guide for Journal Entry Post API on S/4 HANA Cloud
Download the WSDL highlighted in this screenshot and load it in SOAP UI.
Sample Customer Invoice Posting in S/4Hana Cloud using SOAP UI
As an example I have posted a Invoice using the Journal Entry Post Synchronous API
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://sap.com/xi/SAPSCORE/SFIN" xmlns:yy1="http://SAPCustomFields.com/YY1_">
<soapenv:Header/>
<soapenv:Body>
<ns1:JournalEntryBulkCreateRequest>
<MessageHeader>
<ID>MSG_2023-06-13</ID>
<CreationDateTime>2023-07-12T10:42:08.604Z</CreationDateTime>
<TestDataIndicator>false</TestDataIndicator>
</MessageHeader>
<JournalEntryCreateRequest>
<MessageHeader>
<ID>MSG_2023-06-13</ID>
<CreationDateTime>2023-07-12T10:42:08.604Z</CreationDateTime>
</MessageHeader>
<JournalEntry>
<OriginalReferenceDocumentType>BKPFF</OriginalReferenceDocumentType>
<BusinessTransactionType>RFBU</BusinessTransactionType>
<AccountingDocumentType>DR</AccountingDocumentType>
<DocumentReferenceID>111</DocumentReferenceID>
<DocumentHeaderText>PaymentTerms</DocumentHeaderText>
<CreatedByUser>CB9980000114</CreatedByUser>
<CompanyCode>1008</CompanyCode>
<DocumentDate>2023-04-01</DocumentDate>
<PostingDate>2023-04-26</PostingDate>
<TaxReportingDate>2023-04-26</TaxReportingDate>
<TaxDeterminationDate>2023-04-26</TaxDeterminationDate>
<Item>
<ReferenceDocumentItem>2</ReferenceDocumentItem>
<CompanyCode>1008</CompanyCode>
<GLAccount>41910000</GLAccount>
<AmountInTransactionCurrency currencyCode="EUR">-100.00</AmountInTransactionCurrency>
<DebitCreditCode>H</DebitCreditCode>
<DocumentItemText>ItemText2</DocumentItemText>
<AssignmentReference>AssignRef1</AssignmentReference>
<Tax>
<TaxCode>A1</TaxCode>
</Tax>
<AccountAssignment>
<ProfitCenter>PC1</ProfitCenter>
<WBSElement>WBS1</WBSElement>
<FunctionalArea>FA11</FunctionalArea>
</AccountAssignment>
</Item>
<DebtorItem>
<ReferenceDocumentItem>1</ReferenceDocumentItem>
<Debtor>73117</Debtor>
<AmountInTransactionCurrency currencyCode="EUR">105.25</AmountInTransactionCurrency>
<DebitCreditCode>S</DebitCreditCode>
<DocumentItemText>ItemText2</DocumentItemText>
<Reference1IDByBusinessPartner>449739</Reference1IDByBusinessPartner>
</DebtorItem>
<ProductTaxItem>
<TaxCode>A1</TaxCode>
<TaxItemClassification>MWS</TaxItemClassification>
<AmountInTransactionCurrency currencyCode="EUR">-5.25</AmountInTransactionCurrency>
<DebitCreditCode>H</DebitCreditCode>
<TaxBaseAmountInTransCrcy currencyCode="EUR">-100.00</TaxBaseAmountInTransCrcy>
</ProductTaxItem>
</JournalEntry>
</JournalEntryCreateRequest>
</ns1:JournalEntryBulkCreateRequest>
</soapenv:Body>
</soapenv:Envelope>
- Note the following fields form the response
- AccountingDocument – 1800000774 in my case
- CompanyCode – 1008 in my case
- FiscalYear -2023 in my case
Update Payment Terms using Journal Entry Change API
Use the Journal Entry Change API to update the Payment Terms. Note as this is a Asynchronous API and as it uses SAP RM Protocol, you need to ensure the settings highlighted in SOAP UI are selected.
Also, ensure that you provide the correct Document Item Number. That depends on which Item the Debitor posting was on.
Populate the data as per your document number and Payment Terms and post to S/4. You will see that the Payment Terms are updated as you want in SAP.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sfin="http://sap.com/xi/SAPSCORE/SFIN" xmlns:yy1="http://SAPCustomFields.com/YY1_">
<soapenv:Header/>
<soapenv:Body>
<sfin:JournalEntryBulkChangeRequestMessage>
<MessageHeader>
<ID>MSG_2023-06-13</ID>
<CreationDateTime>2023-06-13T12:00:00.1234567Z</CreationDateTime>
</MessageHeader>
<HeaderKey>
<AccountingDocument>1800000714</AccountingDocument>
<CompanyCode>1008</CompanyCode>
<FiscalYear>2023</FiscalYear>
</HeaderKey>
<JournalEntryDebtorCreditorItem>
<MessageHeader>
<ID>MSG_2023-06-13</ID>
<CreationDateTime>2023-06-13T12:00:00.1234567Z</CreationDateTime>
</MessageHeader>
<ItemKey>
<AccountingDocument>1800000774</AccountingDocument>
<CompanyCode>1008</CompanyCode>
<FiscalYear>2023</FiscalYear>
<AccountingDocumentItemID>000001</AccountingDocumentItemID>
</ItemKey>
<PaymentTermsChange>
<PaymentTerms>0020</PaymentTerms>
<FieldValueChangeIsRequested>true</FieldValueChangeIsRequested>
</PaymentTermsChange>
</JournalEntryDebtorCreditorItem>
</sfin:JournalEntryBulkChangeRequestMessage>
</soapenv:Body>
</soapenv:Envelope>
Final Thoughts and Further Reading
The Journal Entry Change API can definitely be used to Update the Payment Terms of a Journal Entry.
- There are multiple other fields and options available in this API, available in the documentation from SAP here : Journal Entry – Change (Asynchronous)
- I would strongly urge you to look at this Blog on how to use the Journal Entry Post API – User Guide for Journal Entry Post API on S/4 HANA Cloud