Call a BAM-generated function from an app
From your application, you can call a function generated in a BAM application.
To call a BAM-generated function in your non-BAM app, you must import the BAM module that contains the function, and define variables for the function's parameters prior to calling the function in your app.
This topic uses a demonstration to illustrate the steps you must take. For this demonstration,
you can use the OfficeStore sample project included in the Genero Studio distribution. You will:
- Create a simple app.
- Save it to a module in a new application node.
- Add code to import the module from which you want to call the function, and define variables.
See the code in the example. For example, you will code to:
- Import the module for the Order form file entity, OrderForm_ui.4gl.
- Define variables for the Open Form function.
- Call the function to open the form.
- Run the application to test your app.
Complete code sample
In this example, you have the code you need to open the Order form generated by the BAM. Copy and paste the code to your module.
IMPORT FGL OrderForm_ui -- Import module that has the function
IMPORT FGL libdbappUI -- Import BAM libraries referenced
IMPORT FGL libdbappFormUI
MAIN
DEFINE l_uiSettings UISettings_Type
DEFINE l_whereRelation STRING
DEFINE errNo INTEGER
DEFINE actionNo SMALLINT
CONNECT TO "officestore"
CLOSE WINDOW SCREEN
CALL ui.Interface.loadActionDefaults("dbapp")
CALL ui.Interface.loadStyles("dbapp")
LET l_uiSettings.openMode = C_MODE_UNDEFINED
LET l_uiSettings.defaultMode = C_MODE_UNDEFINED
LET l_uiSettings.disableDisplay = FALSE
LET l_uiSettings.disableAdd = FALSE
LET l_uiSettings.disableModify = FALSE
LET l_uiSettings.disableDelete = FALSE
LET l_uiSettings.disableSearch = FALSE
LET l_uiSettings.disableEmpty = FALSE
CALL l_uiSettings.transitions.clear()
INITIALIZE l_whereRelation TO NULL
CALL OrderForm_ui.OrderForm_ui_uiOpenForm(l_whereRelation, l_uiSettings.*) RETURNING errNo, actionNo
END MAIN