This example of RDML code will display a data entry screen to allow Customer data to be written to a Customer table. It illustrates some of the key 4GL structures in LANSA's RDML and shows how these structures provide productivity and maintenance benefits:
GROUP_BY NAME(#CUSTOMER) FIELDS (#CUSTNO #NAME #ADDR1 #ADDR2 #CITY #STATE #PHONE)
REQUEST FIELDS(#CUSTOMER) DESIGN(*DOWN)
INSERT FIELDS(#CUSTOMER) TO_FILE(CUSTMST)
CHANGE FIELD(#CUSTOMER) TO(*DEFAULT)
A single FUNCTION statement controls the execution of your programs without complex external programs or parameter setting.
The GROUP_BY statement defines an abstract construct, a field list which can be used in other RDML statements. The field #CUSTOMER represents a list of fields #CUSTNO #NAME #ADDR1 #ADDR2 #CITY #STATE #PHONE. Instead of typing each field name in subsequent statements to request, write or change data, the field #CUSTOMER can be used in its place. New fields can be added to the GROUP_BY and will automatically be used wherever the #CUSTOMER field is used.
The REQUEST statement is all that is required for a complete screen to be created with all message and error handling. This single command replaces hundreds of lines of 3GL code. It controls the complete user interface and can build a 5250 screen for an IBM i or GUI screen for a PC running Windows. Screen characteristics are controlled by the Repository and by a set of statement parameters such as DESIGN(*DOWN) for how screen fields are designed.
The INSERT statement is used to write data to the Customer table. You will notice that no validation rules and error handling logic appear in the program. These are all handled by the Repository and the parameters of the INSERT command.
The CHANGE statement combined with the GROUP_BY statement replaces at least 7 lines of 3GL code which would be required to reset the individual fields. The use of *DEFAULT means that the default field values are based on the Repository field default values when fields are reset. The developer does not have to hard code these values or read them from a table. There is less code to maintain. Changes can be made to the Repository without changing this RDML code.
To add a new field such as #POSTCD to a Customer data entry screen, you simply add the field to the GROUP_BY command and recompile. With LANSA's RDML, it is just one change to one line of code. It is that simple to code and maintain functions with RDML.