Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacky_Liu
Product and Topic Expert
Product and Topic Expert
Currently I need to block a supplier's invoice if some situatin like GR/IR Deviation Exceeds Threshold happened , I investiage  nodejs soap to realize this .  Let me share the step by step process for this which maybe helpful for you in your project :

Prerequisites:



  • You have installed nodejs. Make sure you run the latest long-term support (LTS) version of Node.js with an even number like 16. Refrain from using odd versions, for which some modules with native parts will have no support and thus might even fail to install.

  • You have installed the latest version of Visual Studio Code.


 

Step 1:  Check the Journal Entry - Change in API hub and download the api specificaiton .




Step 2: Configure communication arrangement in S/4 Hana cloud :




Step 3: create node project to call the soap api in S/4 Hana Cloud to block supplier invoices with following command :


mkdir  sdkforsoap

cd  sdkforsoap

mkdir external

copy the downloaded API specification to folder external

npm  init

code .


 

Step 4: adjust packge.json and index.js


package.json

{
"name": "sdkforsoap",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"soap": "^0.43.0",
"short-uuid": "^4.2.0",
"uuid": "^8.3.2"
}
}


index.js
const soap = require('soap');

const short = require('short-uuid');
const uuid = require('uuid');

var sid =short.generate();
var id = uuid.v1();
{encoding:'utf8',flag:'r'});

var options = {
forceSoap12Headers: true
};
var date1 =new Date().toISOString();

var args = {'MessageHeader':{'ID':sid,'UUID':id,'CreationDateTime':date1},'JournalEntryHeader':{'MessageHeader':{'ID':sid,'CreationDateTime':date1},'HeaderKey':{'AccountingDocument':'5100000050','CompanyCode':'1310','FiscalYear':'2022'},'DocumentHeaderTextChange':{'DocumentHeaderText':'hello1','FieldValueChangeIsRequested':true}},'JournalEntryDebtorCreditorItem':{'MessageHeader':{'ID':sid,'CreationDateTime':date1},'ItemKey':{'AccountingDocument':'5100000050','CompanyCode':'1310','FiscalYear':'2022','AccountingDocumentItemID':'1'},'PaymentBlockingReasonCodeChange':{'PaymentBlockingReasonCode':'A','FieldValueChangeIsRequested':true}}};


soap.createClient('./external/JOURNALENTRYBULKCHANGEREQUEST_.wsdl',options,function(err,client){
client.setEndpoint('https://my300018-api.saps4hanacloud.cn/sap/bc/srt/scs_ext/sap/journalentrybulkchangerequest_');
client.setSecurity(new soap.BasicAuthSecurity('username','password'));
// client.addSoapHeader('MessageID',id,'Action','http://sap.com/xi/SAPSCORE/SFIN/JournalEntryBulkChangeRequest_In/JournalEntryBulkChangeRequest_InRequest')

client.addSoapHeader({MessageID:id},'http://www.w3.org/2005/08/addressing','wsa','http://www.w3.org/2005/08/addressing');

client.addSoapHeader({CreationDateTime:date1});

client.setSOAPAction('JOURNALENTRYBULKCHANGEREQUEST_.binding.JournalEntryBulkChangeRequest_In');
client.JournalEntryBulkChangeRequest_In(args,function(err,result){

if(err){console.log(err);}else{console.log(result);}

});
});

Step 5: run the application .



Step 6, check the result in s/4 hana cloud


 

To be continue , I will adjust code to be deployed on BTP cloud foundry runtime and share  the steps

 

Best regards!

Jacky Liu