The big issue is that you can’t update fields in query/400. Normally, you cannot do any updates in query applications.
Here’s the only way I can think of doing this in query/400
It requires two or three queries
1. Writes to an Outfile for ‘M’ records Setting the WrkFld = TMRFRQ
2. Adds to the Outfile for ‘D’ records Setting the WrkFld = TMRFRQ/30
Then if you need a report
3. Uses the Outfile to write your report.