|
楼主 |
发表于 2010-3-10 08:52:30
|
显示全部楼层
晕,还有10000个字符限制,英文文档要分两次发。
4GL script types
There are four types of 4GL program scripts:
•Type 1 single-occurrence (details) session, operating on a main table.
•Type 2 multi-occurrence (overview) session with group fields, and operating on a main table.
•Type 3 multi-occurrence (overview) session, without group fields, operating on a main table.
•Type 4 print/processing sessions, without main table.
4GL scripts are event oriented. They consist of one or more event sections in which you program actions to be performed at particular states of execution of the standard program - for example, when a session is started, before a form is activated, before input to a field, after input to a field, and so on. It is not necessary to program all sections, only those for which the standard program does not provide the required functionality. The statements programmed in a section can be a combination of 3GL/4GL functions and 3GL statements.
Example
field.pctst099.item:check.input:SELECT pctst001.* FROM pctst001WHERE pctst001.item = :pctst099.itemAS SET WITH 1 ROWSSELECTDO....SELECTEMPTYpctst001.dsca = "*****"set.input.error(".....")ENDSELECTbefore.input:if ..... thenattr.input = falseendifafter.display:SELECT pctst001.* FROM pctst001WHERE pctst001.item = :pctst099.itemAS SET WITH 1 ROWSSELECTEMPTYpctst001.dsca = "*****"ENDSELECTfield.pctst099.date:before.input:attr.oformat$ = "%D002,2"
Report scripts
BaanERP reports are used to output data from the database to a variety of devices (for example, printers, displays, and files). The contents and layouts of reports are defined in the data dictionary. In addition, you can link a report script to a report. In a report script, you can program actions that you want to be performed at particular stages of the report execution. For example, you can create a script to perform calculations on the report data or to read records from related tables that are not automatically available to the report. You program report scripts in the same way as you program 4GL program scripts, except that report scripts use different event sections and some special functions.
A report script consists of one or more event sections in which you program actions to be performed at particular states of execution of the report to which the report script is linked. The statements programmed in a report script section consist of a combination of 3GL language statements and report script functions. Report scripts support the following event sections: program sections, report sections, and text field sections.
Data Access Layer (DAL) Functions
Overview
In BAAN applications, the standard program provides much of the default functionality for a session. In previous versions of the software, changes or additions to the default functionality for a session were programmed in a single script that was associated with the session. Both user interface actions and database actions were programmed in this script. In BaanERP, user interface actions and database actions have been separated. The Data Access Layer (DAL) now handles database interaction. Programmers create a user interface (UI) script to change the default behavior of a session. They create a DAL script to program all the logical integrity rules for a particular table. So the DAL ensures the logical integrity of the database. As in previous versions of the software, the database server ensures the referential integrity of the database.
The DAL script for a particular table has the same name as that table. It is implemented as a DLL that can be accessed by user interface scripts (via the standard program), by other DALs, and by external programs (via the Common Data Access Server (CDAS). The following diagram illustrates the overall relationship of these components.
Database integrity checks
The following are examples of some logical integrity rules that could be programmed in a DAL script:
•When customers have reached their credit limit, they cannot order further items.
•
•If the invoice for an order has been printed, the order cannot be changed.
•If the current PVRC of a user is not equal to the PVRC of the program script, the script cannot be compiled.
Programming database integrity checks in a separate DAL script has two main advantages:
•Code reuse: The integrity rules do not have to be replicated in each session that uses a particular table.
•External access: External applications can access the database via the CDAS and the DAL.
For an overview of the interaction between the user interface, the standard program, and the DAL, see DAL, UI, and standard program interaction.
Business methods
In addition to performing data integrity checks, the DAL provides business methods for handling non-interactive database modifications such as printing sales orders or posting all orders to history. A business method is a function that performs a task that involves manipulating and/or checking one or more tables in the database. The function is programmed in a DAL script and can be called directly from a UI script. It must be programmed in the DAL script of the most relevant table.
Users can activate a business method with a single command. There is then no further user interaction. The UI script calls the relevant function in the DAL script. The function performs all operations to complete the required task. The user must wait until the business method finishes before continuing with other tasks. However, if a progress window is provided, the user can cancel the business method by clicking on the Cancel button. The UI script starts a business method by calling the dal.start.business.method() function.
Interaction between UI, DAL, and standard program
A DAL script contains all the logic integrity rules for a particular object set. These rules are referred to as hooks and they can be programmed for every possible manipulation of an object in the object set. For each session with a main table, the standard program ensures that the integrity rules for the table are checked each time an update, delete, insert, or read operation is performed on an object of the table. If there is no DAL script for the particular object set being accessed, no logic integrity checks are performed (unless they are programmed in the UI script itself).
A DAL script can contain hooks that prevent access to the database and hooks that prevent data being passed back to the user interface. The former are executed before the database action. The latter are performed after the database action.
If a user changes the address of a customer on a form, the standard program changes the address for that customer in the database via the DAL. If you want certain restrictions to apply to the update action, you can program a property hook in the DAL of the sessions main table to impose these restrictions.
UI function calls
The UI script can use either the database write functions or the DAL Data Access Methods (DAM) to manipulate the database. The database write functions are direct database calls. They do not use the DAL. In this case, any logic integrity checks required must be programmed in the UI script itself. This means that they cannot be reused by other sessions. In preference, use the DAL Data Access Methods. These access the database via the DAL, so all necessary checks are automatically performed.
When the DAL is used to manipulate the database, the main steps involved are as follows:
1.The user issues a command through the user interface to access a record in the database.
2.The standard program loads the appropriate DAL and calls the hooks in the DAL to check the integrity rules for the object.
3.If the particular database action is permitted, the standard program issues the appropriate database call.
4.After the database has been updated, the DAL can perform further checks to determine whether or not data is passed back to the user interface.
5.The standard program passes data back to the user interface (provided that the integrity rules permit this).
DAL hooks
A hook is a function, with a predefined name, that the DAL programmer programs in a DAL script. The function is used to program logic integrity rules for database access. The DAL script is compiled into a DLL.
When a user issues a command to access the database, the standard program loads the DAL DLL for the object being accessed and calls the hooks to perform the integrity checks. Provided that a DAL script exists for an object set being accessed, the standard program always ensures that the hooks in the DAL are called at the appropriate times. A DAL script can contain two types of hooks: property hooks and object hooks. |
|