cancel
Showing results for 
Search instead for 
Did you mean: 

B1WS businessPartnersService.Add - Error

Former Member
0 Kudos
138

So I'm trying to insert a BP into Sap B1 through B1WS

The error message is 'This entry already exists in the following tables (ODBC -2035)'

Any help apreciated I'm sure I'm missing something obvious.

Edited by: DaveBur on Jan 27, 2011 5:51 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Code ;-

// Login
            string sessionID = LoginManager.LoginB1SW();
            
            // Create service webreference
            BusinessPartnersService.BusinessPartnersService businessPartnersService = new BusinessPartnersService.BusinessPartnersService();
            businessPartnersService.Url = URL;

            BusinessPartnerParams businessPartnersParams = new BusinessPartnersService.BusinessPartnerParams();

            // MsgHeader class
            BusinessPartnersService.MsgHeader msgHeader = new BusinessPartnersService.MsgHeader();
            msgHeader.SessionID = sessionID;
            msgHeader.ServiceName = MsgHeaderServiceName.BusinessPartnersService;
            msgHeader.ServiceNameSpecified = true;
            businessPartnersService.MsgHeaderValue = msgHeader;

            // fill business partner class
            BusinessPartner businessPartner = new BusinessPartner();

            // so I need to get a new bp cardcode?
            string newCardCode = CompanyServiceManager.GetNextCardCode(regionId);

            businessPartner.CardCode = newCardCode;
           
            // probably if customer.Company is blank use First/Lastname
            if (company != "" && company != null)
            {
                businessPartner.CardName = company;
            }
            else
            {
                businessPartner.CardName = lastName + " " + firstName;
            }
            
            // temp here
            businessPartner.GroupCode = 101;

           

            return businessPartnersParams;

Edited by: DaveBur on Jan 27, 2011 5:52 PM

Former Member
0 Kudos

            /////////////////////////////////
            // Lets see if these work temp various User fields that are not null in DB
            /////////////////////////////////
            businessPartner.U_BPDivision = "60-CAM";
            businessPartner.U_rbOkSoBo = 8;
            businessPartner.U_rbOkSoBoSpecified = true;
            businessPartner.U_rbOkPoBo = 8;
            businessPartner.U_rbOkPoBoSpecified = true;
            businessPartner.U_A1WMS_AllowPO = 1;
            businessPartner.U_A1WMS_AllowPOSpecified = true;
            businessPartner.U_A1WMS_AllowSO = 1;
            businessPartner.U_A1WMS_AllowSOSpecified = true;

            /////////////////////////////////
            

            // Contact Details
            BusinessPartnerContactEmployee businessPartnerContactEmployee = new BusinessPartnerContactEmployee();
            
            
            // businessPartnerContactEmployee.Title = customer.Title 
            businessPartnerContactEmployee.Name = firstName + " " + lastName;
            businessPartnerContactEmployee.E_Mail = email;
            businessPartnerContactEmployee.Phone1 = phoneNumber;
            
            
            BusinessPartnerContactEmployee[] contactEmployees = new BusinessPartnerContactEmployee[1];
            contactEmployees[0] = businessPartnerContactEmployee;

            businessPartner.ContactEmployees = contactEmployees;
           
            // Invoice address Details
            BusinessPartnerBPAddress businessPartnerBPAddressInvoice = new BusinessPartnerBPAddress();
            businessPartnerBPAddressInvoice.TypeOfAddress = BusinessPartnerBPAddressAddressType.bo_BillTo.ToString();
            //businessPartnerBPAddressInvoice.Country = customer.BillingAddress.Country.TwoLetterIsoCode;
            businessPartnerBPAddressInvoice.Country = billingTwoLetterIsoCode;
            
           // non compulsory?
            businessPartnerBPAddressInvoice.AddressName = billingAddress1;
            businessPartnerBPAddressInvoice.AddressName2 = billingAddress2;
            businessPartnerBPAddressInvoice.City = billingCity;
            businessPartnerBPAddressInvoice.County = billingStateName;
            businessPartnerBPAddressInvoice.ZipCode = billingPostalCode;

            BusinessPartnersService.BusinessPartnerBPAddress[] bPAddresses = new BusinessPartnersService.BusinessPartnerBPAddress[2];
            bPAddresses[0] = businessPartnerBPAddressInvoice;

            //businessPartner.BPAddresses = bPAddresses;

            //Ship to address
            BusinessPartnersService.BusinessPartnerBPAddress businessPartnerBPAddressShipto = new BusinessPartnersService.BusinessPartnerBPAddress();
            businessPartnerBPAddressShipto.TypeOfAddress = BusinessPartnersService.BusinessPartnerBPAddressAddressType.bo_ShipTo.ToString();
            businessPartnerBPAddressShipto.Country = shippingTwoLetterIsoCode;
            // non compulsory
            businessPartnerBPAddressShipto.AddressName = shippingAddress1;
            businessPartnerBPAddressShipto.AddressName2 = shippingAddress2;
            businessPartnerBPAddressShipto.City = shippingCity;
            businessPartnerBPAddressShipto.County = shippingStateName;
            businessPartnerBPAddressShipto.ZipCode = shippingPostalCode;

            bPAddresses[1] = businessPartnerBPAddressShipto;

            businessPartner.BPAddresses = bPAddresses;

            // save (errors here)
            businessPartnersParams = businessPartnersService.Add(businessPartner);
            
            LoginManager.LogoutB1SW(sessionID);

            return businessPartnersParams;

last line of code in the post before this was mistake but I can't edit 😕

Former Member
0 Kudos

So I have finally sorted this one out

The error message was caused by a corrupt SQL install - seems that the system db had become fubar.

Additional problems existed within my code in that rather than setting TypeOfAddress, I needed to be setting AddressType - Outstanding way to name things guys. Additionally I understand the AddressName field needs to be populated with a unique name.

Former Member
0 Kudos

So back at this again.

I have finally tracked down the issue that was preventing the updates of the Business Partner and thought I'd leave a note for anyone in the future.

Even when we just sent an unmodified BP back to B1WS we still got an error.

It seams that the this install of sap has duplicate LineNum (RowNum in B1WS) entries for addresses within a BP. This is not a problem when the addresses are of differing types ie a ShipTo and BillTo address on the same BP can have identical LineNums however they cannot have duplicates within an addresss type.

Renumbering on our side of B1WS does not work - turning off RowNumSpecified does not work.

Correcting the duplicates in SAP B1 does work.

HTH

Dave