SAP API日记帐分录"来自外部系统的日记帐分录" (SAP_COM_0002)

时间:2018-05-27 18:48:25

标签: api sap hana

有没有人通过POSTMAN或云平台应用程序在S / 4HANA云系统中成功创建了日记帐分录? 我一直在POSTMAN中获得401未经授权。我尝试了PO GET API URL,它运行正常。

的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"
                }                   

            ]
        }
    }
}

1 个答案:

答案 0 :(得分:0)

这是一个Soap Request,因此您需要通过发送XML Envelop数据进行调用。

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>";