
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A simple and easy to use library for SAP Business One Service Layer API.
npm install node-sapb1
Create an object to store your SAP Business One Service Layer configuration details. If you are using an https connection, you can attach the certificate by specifying the ca property of the configuration object as shown below.
var config = {
host : 'http(s): ip or hostname',
port : 50000,
version : 2,
username : 'SAP usernmae',
password : 'SAP password',
company : 'Company name',
ca : fs.readFileSync('/path/to/certificate.crt')
}
Login to the Service Layer to obtain a session as shown below.
const SAPb1 = require('node-sapb1');
SAPb1.createSession(config, sap => {
// Success
}, (error, type) => {
// Error
// type = 1, Connection errors
// type = 2, SAP response errors.
});
If the connection is successful, the success callback function is called and passed a new instance of SAPb1 as the callback argument. The SAPb1 object provides a resource(name) method which returns a new instance of Resource with the specified name. Using this Resource object you can perform CRUD actions.
The following code sample demonstrates how to query a Sales Order service and return a JSON object with multiple entries using the queryBuilder() method. The queryBuilder() method returns a new instance of Query.
SAPb1.createSession(config , sap => {
sap.resource('Orders')
.queryBuilder()
.select('DocNum, DocEntry, CardCode, DocumentLines')
.orderBy('DocNum', 'asc')
.findAll(data => {
console.log(data);
}, (error, type) => {
console.log(error, type);
});
}, (error, type) =>{
console.log(error, type);
});
To return a single entry, use the find(id, success, error) method as shown below.
SAPb1.createSession(config , sap => {
sap.resource('Orders')
.queryBuilder()
.select('DocNum, DocEntry, CardCode, DocumentLines')
.orderBy('DocNum', 'asc')
.find(1474, data => {
console.log(data);
}, (error, type) => {
console.log(error, type);
});
}, (error, type) =>{
console.log(error, type);
});
Depending on the service, id may be a numeric value or a string.
The following code sample shows how to create a new Sales Order using the create() method of the Resource object.
SAPb1.createSession(config , sap => {
sap.resource('Orders').create({
CardCode: "BP Card Code",
DocDueDate: "Doc due date",
DocumentLines: [
{
ItemCode: "Item Code",
Quantity: "200",
}
]
}, (data) => {
console.log(data);
}, (error, type) => {
console.log(error, type);
});
}, (error, type) =>{
console.log(error, type);
});
You must provide any User Defined Fields that are required in the create object. If successful, the newly created Sales Order will be returned as a JSON object.
The following code sample demonstrates how to update a service using the update() method of the Resource object.
SAPb1.createSession(config , sap => {
sap.resource('Orders').update(19165, {
Comments: "This is a comment",
}, (data) => {
console.log(data);
}, (error, type) => {
console.log(error, type);
});
}, (error, type) =>{
console.log(error, type);
});
Note that the first argument to the update() method is the id of the entity to update. In the case of a Sales Order the id is the DocEntry field. If the update is successful and empty JSON object is returned.
You can find more examples and the full documentation at https://syedhussim.com/sap-b1/node-sapb1-library-documentation-v1.html
Please report any issues on the github repository https://github.com/syedhussim/node-sapb1/issues
FAQs
A simple and easy to use library for SAP Business One Service Layer API.
We found that node-sapb1 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.