menu items. It is also easy to execute the methods directly from X++. To
manually control the input with code, instead of using the dialog interface,
supplement the class with methods to initialize the variables without user
interaction.
If the previous example is changed to initialize, specify input for, and execute the
data manipulation without a dialog, it will require extra methods to set the type
specific variables.
The following parm method can get or set the custAccount variable:
1 2 3 4 5 6 | public CustAccount parmCustAccount(CustAccount _custAccount = custAccount) { custAccount = _custAccount; return custAccount; } |
Parm methods would also be required for the toDate and fromDate variables.
The following illustrates how you can execute the class directly from X++,
instead of from a menu item.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | static void DemoRunBaseJob(Args _args) { CustAccount custAccount; FromDate fromDate; ToDate toDate; DemoRunBase demoRunBase; custAccount = "4001"; fromDate = mkdate(1,1,2006); toDate = mkdate(31,12,2006); demoRunBase = new DemoRunBase(); demoRunBase.parmCustAccount(custAccount); demoRunBase.parmFromDate(fromDate); demoRunBase.parmToDate(toDate); demoRunBase.run(); } |
This approach can also be used to transfer information from the main() method
to the object. If you combine a dialog with the above approach, call the methodgetLast() on the RunBase object before activating the parm*() methods.
Otherwise, the prompt() method restores the choices from the last execution and
overwrites the initialization.
Best Regards,
Hossein Karimi
No comments:
Post a Comment