I think your main question is how to access a field by having its name in a string variable? If that's the case then please see the following two links:
How to convert field name to its ID
How to access a table field by ID
In short: First of all you have to convert your field name to the corresponding field ID by using fieldName2Id
. After that, you can access this field by using the syntax myTable.(fieldId)
.
To put it all together for your case:
myTable.(fieldName2Id(myTable.TableId, strfmt("%1%2", "Sales", mthofyr(myTable.Date)))) += myTable.SalesQty
If you have any problems or questions don't hesitate to ask via a comment.