Hello, everybody,
I do need help very urgent. My customer goes live with Business One HANA in two days and I got severe problems in importing master data by DI-API.
I managed to import all Business Partners. Now I would like to import the addresses by using the object oBusinessPartners and object Addresses.
When I test my code (vba) with SQL-Server everything is fine. All data are imported, no error-message. So the code has to be correct (it is not the first time, that I do such thing).
Using the code for HANA everything is fine only in the first step. That is to say, the objects got their correct values and I can update the Businesspartner without any error-message. The new address is created in the bp-masterdata.
The only thing is, that despite of the address-name all other data are not saved. The fields are simply empty.
Is there any difference between SQL-Server and HANA when using the di-api-objects?
I really do hope for fast and helpful answers.
Thank you very much in advance!!!
with kind regards,
Toby
my code is:
| Set GP = sapComp.GetBusinessObject(oBusinessPartners) |
| blnupdate = GP.GetByKey(MyWsh.Cells(zeile, FieldColumn(HdrRange, "CardCode"))) |
| |
| If blnupdate Then |
| |
| Set GPAdr = GP.Addresses |
| |
| Dim AdrCount As Long |
| Dim AdrCurrLine As Long |
| AdrCount = 0 |
| AdrCurrLine = -1 |
| |
| For AdrCount = 0 To GP.Addresses.Count - 1 |
| GPAdr.SetCurrentLine (AdrCount) |
| If GPAdr.AddressName = MyWsh.Cells(zeile, FieldColumn(HdrRange, "AddressName")) Then |
| AdrCurrLine = AdrCount |
| End If |
| Next AdrCount |
| |
| If Not AdrCurrLine = -1 Then |
| GPAdr.SetCurrentLine (AdrCurrLine) |
| End If |
| |
| With GPAdr |
| If Not AdrCurrLine = -1 Then .Add |
| .AddressName = ADR_AddressName(MyWsh.Cells(zeile, FieldColumn(HdrRange, "AddressName"))) |
| .Street = ADR_Street(MyWsh.Cells(zeile, FieldColumn(HdrRange, "Street"))) |
| .Block = ADR_Block(MyWsh.Cells(zeile, FieldColumn(HdrRange, "Block"))) |
| .ZipCode = ADR_ZipCode(MyWsh.Cells(zeile, FieldColumn(HdrRange, "ZipCode"))) |
| .City = ADR_City(MyWsh.Cells(zeile, FieldColumn(HdrRange, "City"))) |
| .County = ADR_County(MyWsh.Cells(zeile, FieldColumn(HdrRange, "County"))) |
| .Country = ADR_Country(MyWsh.Cells(zeile, FieldColumn(HdrRange, "Country"))) |
| .State = ADR_State(MyWsh.Cells(zeile, FieldColumn(HdrRange, "State"))) |
| .FederalTaxID = ADR_FederalTaxID(MyWsh.Cells(zeile, FieldColumn(HdrRange, "FederalTaxID"))) |
| .TaxCode = ADR_TaxCode(MyWsh.Cells(zeile, FieldColumn(HdrRange, "TaxCode"))) |
| .BuildingFloorRoom = ADR_BuildingFloorRoom(MyWsh.Cells(zeile, FieldColumn(HdrRange, "BuildingFloorRoom"))) |
| .AddressType = ADR_AddressType(MyWsh.Cells(zeile, FieldColumn(HdrRange, "AddressType"))) |
| .AddressName2 = ADR_AddressName2(MyWsh.Cells(zeile, FieldColumn(HdrRange, "AddressName2"))) |
| .AddressName3 = ADR_AddressName3(MyWsh.Cells(zeile, FieldColumn(HdrRange, "AddressName3"))) |
| .TypeOfAddress = ADR_TypeOfAddress(MyWsh.Cells(zeile, FieldColumn(HdrRange, "TypeOfAddress"))) |
| .StreetNo = ADR_StreetNo(MyWsh.Cells(zeile, FieldColumn(HdrRange, "StreetNo"))) |
| End With |
| |
| UDF: |
| If GPAdr.UserFields.Fields.Count > 0 Then |
| For uf = 0 To GPAdr.UserFields.Fields.Count - 1 |
| GPAdr.UserFields.Fields(uf).Value = UDF(GPAdr.UserFields.Fields(uf), MyWsh.Cells(zeile, FieldColumn(HdrRange, GPAdr.UserFields.Fields(uf).Name))) |
| Next uf |
| End If |
| If MyWsh.Cells(zeile, FieldColumn(HdrRange, "Standard")) = "Y" Then |
| With GP |
| If GPAdr.AddressType = bo_BillTo Then |
| GP.BilltoDefault = GPAdr.AddressName |
| Else |
| GP.ShipToDefault = GPAdr.AddressName |
| End If |
| End With |
| End If |
| |
| lngRst = GP.Update |
| |
| If Not lngRst = 0 Then |
| MyWsh.Cells(zeile, FieldColumn(HdrRange, "")) = SAPErrorHdl(False) |
| ErrCount = ErrCount + 1 |
| End If |
| |
| End If |