1

Has anyone successfully created a Journal Entry in S/4HANA Cloud system via POSTMAN or Cloud Platform App?

I keep getting 401 unauthorized in POSTMAN. I tried PO GET API URL, and it is working fine.

https://:/sap/bc/srt/scs/sap/journalentrycreaterequestconfi

{
"JournalEntryBulkCreateRequest": {
    "MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
    "JournalEntryCreateRequest": {
        "MessageHeader": { "CreationDateTime": "2018-05-27T12:50:30.45+01:00" },
        "JournalEntry": {
            "OriginalReferenceDocumentLogicalSystem": "",
            "OriginalReferenceDocumentType": "BKPFF",
            "OriginalReferenceDocument": "",
            "BusinessTransactionType": "RFBU",
            "AccountingDocumentType": "",
            "DocumentHeaderText": "Header Value",
            "CompanyCode": "US01",
            "CreatedByUser": "CB9980000010",
            "DocumentDate": "2018-05-27",
            "PostingDate": "2018-05-27",
            "item": [
                {
                    "GLAccount": "0021517000",
                    "AmountInTransactionCurrency": {
                        "Amount": "1200.00",
                        "currencyCode": "USD"
                    },
                    "DocumentItemText": "Text1"
                },
                
                {
                    "GLAccount": "0010010000",
                    "AmountInTransactionCurrency": {
                        "Amount": "-1200.00",
                        "currencyCode": "USD"
                    },
                    "DocumentItemText": "Text2"
                }                   
                
            ]
        }
    }
}
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
William
  • 11
  • 2
  • I addressed the 401 error. For this API, we cannot use JSON because it's a SOAP web service. Now, my next step is how to embed the SOAP call with payload in my Cloud Platform app... – William May 29 '18 at 04:14
  • Can we remove the "s4" tag? It isn't appropriate for this question (it refers to an object oriented system in the R programming language, nothing to do with SAP) – JDL Jun 07 '18 at 07:48

1 Answers1

0

This is a Soap Request so you need to call by sending XML Envelop data.

var request =
            "<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><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
            "<JournalEntryCreateRequest><MessageHeader><CreationDateTime>" + currentDate.toISOString() + "</CreationDateTime></MessageHeader>" +
            "<JournalEntry>" +
            "<OriginalReferenceDocumentType>BKPFF</OriginalReferenceDocumentType>" +
            "<OriginalReferenceDocument>" + Item[1] + "</OriginalReferenceDocument>" + // Report number
            "<OriginalReferenceDocumentLogicalSystem>INBOUND</OriginalReferenceDocumentLogicalSystem>" +
            "<BusinessTransactionType>RFBU</BusinessTransactionType>" +
            "<AccountingDocumentType>SA</AccountingDocumentType>" +
            "<DocumentHeaderText>Certify NonReimbursement</DocumentHeaderText>" +
            "<CreatedByUser>CC0000000001</CreatedByUser>" +
            "<CompanyCode>" + Item[8] + "</CompanyCode>" +
            "<DocumentDate>" + this.parseJsonDate(documentDate) + "</DocumentDate>" +
            "<PostingDate>" + this.parseJsonDate(postingdate) + "</PostingDate>" +
            "<Item>" +
            "<CompanyCode>" + Item[8] + "</CompanyCode>" +
            "<GLAccount>" + this.suffixZeros(nonExpAcc + "") + "</GLAccount>" +
            "<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">-" + Item[4] + "</AmountInTransactionCurrency>" +
            "<DebitCreditCode>S</DebitCreditCode>" +
            "</Item>" +
            "<Item>" +
            "<CompanyCode>" + Item[8] + "</CompanyCode>" +
            "<GLAccount>" + this.suffixZeros(Item[3] + "") + "</GLAccount>" +
            "<AmountInTransactionCurrency currencyCode=\"" + Item[5] + "\">" + Item[4] + "</AmountInTransactionCurrency>" +
            "<DebitCreditCode>H</DebitCreditCode>" +
            "<AccountAssignment>" +
            "<CostCenter>" + this.suffixZeros(Item[7] + "") + "</CostCenter>" +
            "</AccountAssignment>" +
            "</Item>" +
            "</JournalEntry></JournalEntryCreateRequest></sfin:JournalEntryBulkCreateRequest></soapenv:Body></soapenv:Envelope>";