there is no need of creating such complex function. You can do such thing in a simple manner :
DECLARE @Prefix varchar(5)
SELECT @Prefix=Prefix
FROM NON_MOL_ChannelIdentification
select CorporateId= CASE WHEN @Perfix<>'' THEN right(CorporateId,len(CorporateId)-3) else CorporateId END
FROM dbo.CORPORATE
WHERE CorporateId = right(CorporateId,len(CorporateId)-3)
OR CorporateId = CorporateId
</pre>