cancel
Showing results for 
Search instead for 
Did you mean: 

Issues With Batch/Serial Numbers when creating Item Invoices with Service Layer

0 Kudos

Hi,

I'm trying to create an invoice using the service layer, but I get the response:

{
"error": {
"code": -4014,
"message": {
"lang": "en-us",
"value": "Cannot add row without complete selection of batch/serial numbers"
}
}
}

I am posting this body to the Invoices endpoint.

{
	"CardCode": "100003",
	"DocumentLines": [
		{
			"ItemCode": "0021050008",
			"Quantity": "100",
			"TaxCode": "T1",
			"UnitPrice": "30",
			"WareHouseCode": "01",
			"BatchNumbers": 220110
		}
	]
}

I've tried all the following formats for BatchNumbers / SerialNumbers

"BatchNumbers": 220110,
"SerialNumbers": 220110,
"BatchNumbers": "220110",
"SerialNumbers": "220110",
"BatchNumbers": [220110],
"SerialNumbers": [220110],
"BatchNumbers": ["220110"],
"SerialNumbers": ["220110"],

When I try to see how an invoice that has already been posted in SAP looks like from the API, both SerialNumbers and Batchnumbers are just Emtpy Arrays.

"SerialNumbers": [],
"BatchNumbers": [],

I know that this specific batch exists on this specific WhsCode, as seen in the picture.

Theres a button in our system that can automatically pick the batches for a line, and if such a function exists using the service layer, that would be extremely apprecieated, if not, I'd just like to know how to create an invoice and pick a batch I know exists.

If any further elaboration is needed, please let me now. Thank you in advance.

0 Kudos

Tryign to implement the answer presented here:https://answers.sap.com/questions/12675439/how-to-batch-number-details-in-service-layer.html

I'm using SAP B1 10.0 Service Layer API

My body now looks like this:

{
	"CardCode": "219909",
	"DocDate": "2023-12-01",
	"DocDueDate":"2023-12-01",
	"DocumentLines": [
		{
			"ItemCode": "0021050008",
			"Quantity": 5,
			"Price": 5,
			"WareHouseCode": "01",
			"BatchNumbers": [
				 {
					 "BatchNumber": "DM20231201",
                                         "Quantity": 5
				 }
			]
		}
	]
}

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi jedikrigeren,

You can do a quick test.

Try to create an Invoice manually via SAP Business One client using the same input values which you are having in your simplified JSON.

After the Invoice is created, GET the Invoice details and match the values from JSON.

In few cases, it can be related to UoM or Batch/Serial Number quantity.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

0 Kudos

Hi Ankit,

Thank you very much for your response.

The problem was that I did not specficy the UoMEntry for the ItemCode I was sending.

The below code worked for me:

{
	"CardCode": "219909",
	"DocDate": "2023-12-01",
	"DocDueDate":"2023-12-01",
	"DocumentLines": [
		{
			"ItemCode": "0021050008",
			"Quantity": 5,
			"Price": 5,
			"UoMEntry": 1,
			"WareHouseCode": "01",
			"BatchNumbers": [
				 {
					 "BatchNumber": "DM20231201",
           "Quantity": 5
				 }
			]
		}
	]
}
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi jedikrigeren,

Glad to know that the issue has been resolved.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Answers (0)