by Lorenz Alder, Senior Consultant / Software Architect

Ever wanted to build a menu processor and tried to figure out how to call functions by the function names stored in the database? Here’s what you need to know:

  1. Create a prototype function defining input and output parameters for callees
    Untitled
  2. Let all functions you want to dynamically call to inherit from the prototype function
    Untitled1
  3. Create a caller function and define fields for Source Code parameters
    Untitled2
  4. Caller sets function name from values (simulating DB access). Implementation name of the function and the full function name including the package structure are needed. (“Function1”, “App.UI.Function1” in the example) We also add a dummy call to the prototype function and map input/output parameter to local variable LocalParmsL.
    Untitled3
  5. Subroutine “Dynamic Call” sets necessary paramters for the source code
    Untitled4
  6. Formatting parameters for Source Code with Messages
    Untitled5
  7. Source Code: DynamicCall
    Untitled6
  8. Parameters for Source Code
    Untitled7
  9. Parameter mapping for Source Code: DynamicCall
    Untitled8

If there are any questions regarding this post please feel free to contact me at lorenz.alder@cmfirstgroup.com.