Making your own Google Docs is stupid unless your company's core business is document management.
OTOH Replacing SAP with a bespoke system will make a lot of sense for many companies.
SAP is already the worst of both worlds. It'll have been highly customized for your flow so you've got all of the headaches of bespoke software and all of the headaches of SaaS. And unlike Google Docs, it'll be highly integral to your core business.
I would absolutely NEVER steal or rewrite that. So much finanical stuff is baked into the business logic that impacts finance, regulations, hr, etc.
No do not roll your own ERP core.
Roll everything else