You have a couple of options. You can add a flowfield to the t_39 definition that will represent this value. The calcformula would be of type Sum, operating on the Quantity field, and filtering so that document type and document no. match the current record , and the line no. value is less than the current line. This will basically create a field with a running subtotal of the quantity field.
Another option would be to create a function in the table that basically returns the same value, and add a control to the list form that displays the value of the function return. Using this option, you would not get the use of the drilldown feature that you get with a flowfield, but that’s a moot point if your primary intent is to use this value on a report.
In either case, be careful what you wish for. If you just run a straight sum process without regard to the line types and Nos., you may be adding apples and oranges.
Hope that helps.