I'm big fan of CMD_EI_API and VMD_EI_API classes. I use them to create, update and delete customer and vendor master data, including contact persons, partners and all data you have in XD02/XK02 transaction. Also to update Z fields from all customer and vendor related tables. But lately after upgrade from 7.40 SP5 to 7.40 SP16 the method maintain_bapi was not saving the changes to the customers.
After a while I've found out that I have to call additionally the method update_modules and now the customer was saved.
But now all contact persons for customer where deleted, even when I was not passing any contact related values to the main structure. This was really strange behaviour for me. So as always in such kind of situations I've started to search for solution in SCN, then in OSS notes, but I failed. So I did some debugging and found a place where after extraction of data from DB, the contact persons where deleted from internal tables.
So I went deeper and saw that there is a table CVIC_MAP_CONTACT which is responsible to give an info to the class if contact persons should be deleted or not.