Showing results for 
Search instead for 
Did you mean: 

How to update serial number from DI API

Former Member
0 Kudos


example I want to update serial number like this

update OSRI set IntrSerial = 'BBB' where IntrSerial = 'AAA'

here sample of my code using DI API

Public oItems As SAPbobsCOM.Items
Set oItems = oCompanyDI.GetBusinessObject(oItems)
oItems.SerialNum = 'BBB'

but how do I know I'm in IntrSerial AAA ?

what code should I put in ???? to know I'm now in IntrSerial AAA ?



Arthur Siwan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Arthur,

I'm coding an addon right now that does a lot of work with items that are managed by serial number. I'm no expert on it whatsoever, but maybe we can help each other out.

I'm surprised to learn that there is a serial number property on the OITM table. Serial numbers allow us to individually track each unit of the specific item, right? So if there are 15 "widgets" in the warehouse, we should have 15 serial numbers for that item in the OSRI table, so what good does having a serial number on the OITM table do?

With that said, there is a serialnumbers object in the DI that gives you some access to table OSRI, but I don't believe that this object was meant to be accessed directly. It does not have a getbykey method, nor does it have an update method. I believe that we are meant to access this object via certain document objects like goods receipts, goods issues and documents. For instances the document_lines object has a serialnumbers object. (It also has a serial number field property, like OITM, but I don't get this, either.). So theoretically, anyway, you should be able to access the rows in OSRI through the document lines. For instance on a delivery note if I have one line item that sells 3 'wdigets', I would think that the lines object would give me a serialnumbers object that would let me get at the three serial numbers that the user assigned to that sale. The problem is, that at least via the goods receipt lines object, that doesn't work (the object seems to be returned, but none of the properties are loaded.

Why do you want to change an existing serial number anyway?

Former Member
0 Kudos

Hi John,

Thanks for the Reply, and Yes OITM and OSRI has a relationship but I don't really understand what is the relationship for.

I want to know how to update serial number using DI API (because I'm new in DI API, I was code the add ons always use UI API), so I make an example only update serial number only with OSRI (From serial number detail in SBO Form), to make my explanation simple.

I want to exchange or update serial number, because this serial number is to maintaince Fish's chip number, and it can be changed.

So you said that that's not possible to do with object oItems, right ?

and can you give me an simple example how to update and what object to do a good receipt and good issue using DI API, because I still don't know how to update a spesific serial number.

I was using getByKey method but it can't, get a specific serial number that I want to update.

Thanks and Regards,

Arthur Siwan

Former Member
0 Kudos

Here's how I believe it should work, in theory (As I mentioned before I had problems with

the serial numbers object). Use SQL to find the goods receipts document number that created the

serial number you want to change. I believe that a serial number can only ever be on one goods

receipt. Do this against the OSRI and SRI1 table (child of OSRI) using your item number and

serial number in OSRI and join osri to sri1 on at least the item number and system serial

number (The system serial number is only unique to the corresponding item number). Select

only records in SRI1 where the basetype field is equal to '59' (goods receipt). Like I said

I think you should only get one record. Use the baseentry field on SRI1 to load the field of

the same name in my code below. You should also retrieve baselinnum from SRI1. This will give

you the goods receipt line number that has your serial number attached to it. But you also need

the line item number (linenum) of the serial number within SRi1. On my system, however, the

linenum field does not appear to always be updated properly. If that is the case for you, then

set up a loop on the ogr_doc.lines.serialnumbers object and compare the internal serial number

on the row to the one you want to change.

In all of this, remember that on one goods receipt line item, you can receive multiple units and

each one of these needs a serial number, and therefore has it's own record in OSRI.

Dim oGR_Doc As Documents 'Goods Receipt

Dim baseentry as long = 'The value retrieved from your sql stmt

Dim baselinnum as long = 'The value retrieved from your sql stmt

Dim linenum as long = 'The value retrieved from your sql stmt

oGR_Doc = B1Comp.GetBusinessObject(BoObjectTypes.oInventoryGenEntry)

if oGR_Doc.GetByKey(baseentry) Then

oGR_Doc.Lines.SetCurrentLine(baselinnum )


ogr_doc.Lines.SerialNumbers.InternalSerialNumber = 'your new number


end if

Notice, the ogr_doc.update. In my earlier post I said that the serialnumbers object didn't have

an update method and that's true, but I believe that is because the update for it will only

happen when you update the parent object, like documents/document_lines objects work. Also,

I'm not an expert, so don't take my word as gold, but hopefully I'm getting you close to what

you need.

Former Member
0 Kudos

Hi John,

I appreciate your help very much, Thanks

and I will reward you some point for your concern


Arthur Siwan

Answers (0)