SObjects have get
and set
methods which you can use to set/get the values of fields. To
If the fields are of the same type and the only difference is that objA has a prefix in the field API names, i.e. SVCM__
then you can just loop over the field names in the objB list (which you say you have) and then add the prefix when getting fields from objA:
for(String field : objBFields)
{
objBRecord.set(field, objARecord.get('SVCM__' + field));
}
If the field names have other variances and you need a full map then you could implement this you could use a string map to work out what goes where:
Map<String, String> AFieldToBField = new Map<String, String>
{
'SVCMP__xyz__c' => 'xyz__ c',
'SVCMP__abc__c' => 'abc__ c'
};
for(String key : AFieldToBField.KeySet())
{
objA.put(key, objB.get(key));
}
Obviously this is only going to work if the fields are of the same types on each object, otherwise you're going to need to deal with conversion as well.