Hi Tarun -
I don't have much experience specifically with DB2, but in general, when we face requirements like this, in the past, the method has been to create console applications using Visual Studio or whatever platform you use that supports both systems. I mention Visual Studio because there is a lot of support for Microsoft Dynamics 365 using that tool, and there is also support to write to DB2, as evidenced by this article. The console application is then scheduled to run at intervals using Windows task scheduler, usually on a server.
The application would periodically query Microsoft Dynamics 365 for changes, and when it found them, it would capture those changes and update the tables in DB2.
I have been on projects where this method was used to create two-way integrations between Microsoft Dynamics and on-premise applications.
Hope this helps.
Best,
Owen