cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite a certain existing address of an existing BusinessPartner

Former Member
0 Kudos

Hello SBO programmers

How is to iterate through the address list of the business partner object?

My Use Case is:

I want to overwrite a specific entry of the address list and then update the BP.

Actually I try it with ...

oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)

oBPAdrs = oBP.Addresses

SearchForName = "OldName"

bFound = False

For iSelection = 0 to (m_oBP.Addresses.Count-1)

oBPAdrs.SetCurrentLine (iSelection)

if (SearchForName.Equals(m_oBP.Addresses.AdressName)) then

bFound = True

Exit For

end if

Next

if (bFound) then

oBPAdrs.AdressName = "NewName"

oBPAdrs.Street = "NewStreet"

...

oBP.Update()

end if

... but m_oBP.Addresses.SetCurrentLine() results in the hurtful exception

"This thread has been terminated".

It seems to be completly wrong using this method.

Is it an allowed way? Or do I have to go another way?

Best regards and thanks for help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You need to tell sap the bussines parter you are using to view the address

oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)

<b>'code you need to add

obp.GetByKey("here you put the cardcode")

' end of addition</b>

oBPAdrs = oBP.Addresses

SearchForName = "OldName"

bFound = False

For iSelection = 0 to (m_oBP.Addresses.Count-1)

oBPAdrs.SetCurrentLine (iSelection)

if (SearchForName.Equals(m_oBP.Addresses.AdressName)) then

bFound = True

Exit For

end if

Next

if (bFound) then

oBPAdrs.AdressName = "NewName"

oBPAdrs.Street = "NewStreet"

...

oBP.Update()

end if

and hope it works

regards

Salvador Biot

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Salvador

Thank You for reply.

Of course, it is necessary to get the certain BP before by the method oBP.GetByKey.

I did it too, but I didn't want to write it all, sorry for that.

But anyway, You do not doubt using of the method oBPAdrs.SetCurrentLine(iSelection). That quiets my mind.

Then it must be another run time error in my program.

Thanks again and best regards.