Adding and Updating Business Partner Addresses

Following is an example for adding a new Business Partner address. In this example, the new address's information is held in a SQL table named “SBO_Address_Info,” which is in a database named “VersagoData.”

SELECT
Address, CardCode, Street, Block, ZipCode, City, Country, State, AdresType,
CASE
WHEN AdresType = 'B' THEN 1 ELSE 0 END AS [AdresTypeEnum],
Address + AdresType AS [RecordBreak]
FROM crd1
WHERE CardCode = 'C99001'
UNION ALL
SELECT
AddressName, CardCode, Address1, Address2, PostCode, City, Country, State,
CASE
WHEN AdresType = 'B' THEN 1 ELSE 0 END
Address + AdresType
FROM versagoData..sbo_address_info
WHERE CardCode = 'C99001'

The first part of the query returns the existing address rows for Business Partner code C99001. After the UNION ALL statement, the second part of the query returns the row of the address to be added.

This is an example where the rows also use “Change on value …” for the “Create a new record on” option. The value created by “RecordBreak” ensures that records are processed for each combination of address name + address type.

The image below shows the mapping for this process.