It sometimes happens that I need to create a form from which users can choose values intended for a procedure. For example, I developed a program which allows a manager to choose lines from an existing customer order, have those lines inserted into a new order which the program creates, and have the original lines zeroed out.
Why would I need to develop such a form when from the "input parameters" dialog of a procedure, one can press F6 twice and open the base form of the parameter (e.g. the customers form, the parts form)? The reason is that pressing F6 twice can only open what the documentation calls "a root form (having no upper-level form of its own)". In the above example, data is required from the 'orderitems' table, whose form is not a root form (its upper level form is, of course, the 'orders' form).
Normally, the way I have solved this in the past is to define a specific table for this task and then develop a form based on that table. Today I discovered an easier way of solving this problem.
One still has to write a procedure which at the least will consist of two stages, a form and procedural code, but there is no need to define a specific table upon which the form will be based. Let's say that I want to re-implement the example which I gave at the beginning. I can define a form which is based on the 'orderitems' table, showing the fields which I want, along with the parent order number (which will appear on every line). The trick is that the procedure passes to the form a file parameter, into which will be stored the lines that are displayed on the form. This file parameter is then passed to the procedural code which acts on the lines in the file (table) - that are the lines which were displayed on the form!
For my own reference, the original example where I found this technique is a procedure called TEC_CALCINVLEVEL, which unfortunately for my readers is not part of standard Priority, but rather was developed in the early days of my company using Priority - before I arrived on the scene. Whoever it was didn't bother in signing their work, let alone documenting it.
I doubt that I'm going to rewrite the various programs of this type which I've already written, but I'll try and bear this technique in mind in the future.
No comments:
Post a Comment