cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the Ship To TaxCode of a Business Partner

Former Member
0 Kudos
71

Hi,

As I try to get the bp.Addresses.TaxCode, I get nothing because

in the CRD1 table there are 2 entry for this business partner

one with Null and one with the TaxCode I want.

I dont know how to get the Taxcode that is choosen in the Ship To TaxCode property

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Marc,

The business partner can have multiple addresses. You can loop through the address collection with a for loop and check if it is blank. If it is blank, go to the next address with SetCurrentLine(i). Loop until you get something or when you reach the end of the addresses and exit the for loop.

Hope it helps,

Adele

Former Member
0 Kudos

Hi,

I tought that this could work but it doesn't

for (int iAdress = 0; iAdress < bp.Addresses.Count; iAdress++)

if (bp.Addresses.AddressType == BoAddressType.bo_ShipTo)

bp.Addresses.SetCurrentLine(iAdress);

It never get to the bp.Addresses.SetCurrentLine(iAdress);

as if there isn't any bo_ShipTo which is not right because there is one with a TaxCode of NY

I'm confused...

Former Member
0 Kudos

Hi Marc,

Put the setcurrentline statement before your if statement. Here's a vb example:

            Dim oBP As SAPbobsCOM.BusinessPartners
            Dim i As Integer
            oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
            oBP.GetByKey("C1000")
            For i = 0 To oBP.Addresses.Count - 1
                oBP.Addresses.SetCurrentLine(i)
                If oBP.Addresses.AddressType = SAPbobsCOM.BoAddressType.bo_ShipTo Then
                    sTaxCode = oBP.Addresses.TaxCode
                    Exit For
                End If
            Next

Hopeit helps,

Adele

Former Member
0 Kudos

DOH

Yeah I figured out.

This would have been so much easier if they would have made the Adresses an indexer so we just have to say like

TaxCode = bp.Addresses[BoAddressType.bo_ShipTo].TaxCode

OR even better, a Method in the Adresses

TaxCode = bp.Addresses.GetTaxCode();

Ah well,

Here's my own method for those who want it

public static string SAPGetTaxCode(SAPbobsCOM.BPAddresses Addresses)

{

string TaxCode = "";

for (int iAdress = 0; iAdress < Addresses.Count; iAdress++)

{

Addresses.SetCurrentLine(iAdress);

if (Addresses.AddressType == SAPbobsCOM.BoAddressType.bo_ShipTo)

TaxCode = Addresses.TaxCode;

}

return TaxCode;

}

Thank you for your help.

Answers (1)

Answers (1)

Former Member
0 Kudos

I can almost understand why this is like that.

The Adresses object within the BP object gives me the BillTo

Since the BillTo and ShipTo are in the same table and differenciated by the AdressType which is B for BillTo and S for ShipTo but

From the SDK, I dont know how to get the ShipTo so I can get the TaxCode