|
|
The commands are listed below in alphabetical order. Click on any command name for more information. The examples included in the detailed section are only intended to illustrate usage. They do not necessarily represent the most efficient way of achieving particular objectives.
ACCEPTS | Defines arguments passed to (received by) a procedure. |
ARRAY |
Declares array variable within WORKAREA ... END WORKAREA. |
ATTRIBUTES | Specifies attributes for a print line. |
BEGIN...END_FIELD | Specifies a block of MDL that is used to derive print field rather than a single expression, within an MDL window. |
BLOCK_MOVE | Copies contents of one storage area to another without conversion. |
CACHE | Defines a cache based on a workarea record. |
CACHE_CLEAR | Clears the contents of a cache. |
CACHE_GET | Retrieves an existing cache entry. |
CACHE_PUT | Adds a new cache entry or updates an existing one. |
CALL | Invokes external subroutine from MDL program. |
CHANGE_CMPY | Changes the effective current company to the specified company. |
CHOOSE | Specifies selection qualification. |
CLOSE_DEVICE | Closes an instance of a selected device. |
CLOSE_REPORT | Closes an instance of a selected report or all user defined reports. |
COMMAREA | Generates a workarea based on a communication area (COMMAREA) definition in the repository. |
CONTINUE | Used when syntax demands a statement, but no action is required. |
CREATE_TABLE | This command creates the referenced Work/Master/Interface table for the given jobtag value. |
DEFAULT IS | Specifies default values for parameters not specified at request time. |
DELETE_DEVICE | Deletes the file associated with a specified device. |
DELETE_TABLE | This command deletes the referenced Work/Master/Interface table at the Mappings successful termination. |
DELETE_TABLE_NOW | This command deletes the referenced Work/Master/Interface table immediately. |
DISPLAY | Writes output to one of four destinations: a selected report; QED Quick Query report, RQZZ01; QED run-time Error report, RQZZ02; or System Log. |
DISPLAY_MESSAGE | Will produce a correctly formatted run-time message for the given message code(s) and substitution text. |
DO ... END_DO | Groups statements and executes them repetitively. |
DYNAMIC | Makes a function allocate / de-allocate its memory dynamically (i.e. when called) |
EFFECTS | Reference Report, Page, Line or Field level printing effects (i.e. BOLD, BOX, etc.). Only appears with appropriate distribution. |
EXECUTE | Execute a Method attached to an entity definition. |
FIELD |
Declares a variable within WORKAREA ... END WORKAREA. |
FORCE_STATUS | Used to force or override an error status, this maintains the status of a selected field. |
HEADING_REFRESH | Used to refresh default report page headings for all or a selected report. |
IF ... THEN ... ELSE ... END_IF | Allows conditional execution of MDL statements. |
INITIALISE | Sets initial values for variables. |
INSERT ... END_INSERT | Inserts a row on to a table or a Data Block to the output XML Device. |
ITERATE | Alters the flow within a repetitive DO loop; returns control to the beginning of the loop. |
LEAVE | Causes immediate exit from a repetitive DO loop, and passes control to the statement following the END_DO. |
LET | Assigns the result of an expression to a variable. |
LIST | Produces a simple report, RQZZ01, where the attributes specified in the LIST statement appear as column headings. |
NOTE_DIARY_LINE | Adds a new line to an existing Diary Entry. |
NOTE_EVENT | Notifies an Event to the Business Event Manager. |
OPEN_DEVICE | Opens a selected device (file). |
OPEN_REPORT | Opens selected report(s) to a required destination. |
PERFORM | Invokes another level defined on the same mapping. |
POPULATE | Loads data into matrix cells. |
Prints a line defined on a report. | |
PROCESS_LIMIT | Used to limit unproductive processing. |
QUIT | Stops execution of a mapping, with a normal exit. |
REPRINT | Used after a page overflow, this causes the last printed version of a line to be reprinted exactly as the previous version. |
RETURN | Used within a function declaration, this specifies a value to be returned to the invoking program once the function has completed its processing. |
SELECT ... END_SELECT | Allows the program to select one of several alternative statements for execution. |
SET | Used within an INSERT block, this assigns a value to a table column. |
SQL_COMMIT | Used within a mapping to do an SQL COMMIT. |
STATIC | Makes a function allocate / de-allocate its memory statically (i.e. when mapping starts / terminates) |
TERMINATE | Forces an abnormal end to execution of a mapping. |
UNIQUE | Used in the Order By field of the Level Component screen MQM0, this determines the order in which instances of an entity are processed. |
VALUE IS | Assigns a value to a print field, within BEGIN ... END_FIELD. |
WAIT | Puts the mapping to sleep for a given number of seconds. |
WHENEVER PAGE_OVERFLOW ... END_WHENEVER | Allows control to be transferred to a statement or group of statements whenever a page end is reached. |
WORKAREA ... END_WORKAREA | Delimits the declaration of a group of variables and assigns them contiguous storage locations in memory. |
XML_EXECUTE | For output allows for a Data Group XML Schema and/or Style Sheet to be generated. For input allows for a file to be Syntax Checked. |
XML_FETCH | Allows for the retrieval of a Data Block into the Mapping from the input XML Device. |
XML_INSERT | Allows individual XML words to be written to the output XML Device. |
XML_READ | Allows individual XML words to be read from the input XML Device. |
ZEROISE | Allows you to reset all accumulators on a specified report line back to zero. |
The ACCEPTS statement is used to define the arguments that will be passed to a procedure when it is invoked. The arguments from the invoking statement are matched positionally with the formal parameters defined by the ACCEPTS statement. The valid procedures are Functions, Entity Attributes and print lines.
ACCEPTS ( <id> ( <class> ) [ , <id> ( <class> ) ]* )
<id> | A valid MDL identifier for the argument. |
<class> | A valid MDL class for the argument. |
The ACCEPTS statement is best demonstrated in an example showing an entire function declaration. The following is the declaration for the function named Red_Bal_Dep. This function would already have been named on Function - Insert MQFB.
ACCEPTS (Residual_Value (DECIMAL(15,2)) ,
Valuation_Amount (DECIMAL(15,2)) ,
Life_in_Periods (INTEGER)
)
LET Rate = 100*(1-(Residual_Value/Valuation_Amount)**
(1 / Life_in_Periods)
)
RETURN(Rate)
In the example the function accepts three values when it is invoked: Residual_Value, Valuation_Amount and Life_in_periods. If the function is called using the statement:
LET depreciation_rate = Red_Bal_Dep(10,2000,5)
then
This statement is used to declare an array variable. It can only be used within a WORKAREA ... END_WORKAREA construct.
(See also FIELD)
ARRAY <array_name> ( <class> ) BOUNDS <bound> [ , <bound> ]*
<array_name> | A valid MDL identifier that will be the symbolic name for the array. |
<class> | A valid MDL class. |
<bound> | An integer literal that defines the number of repeats in that dimension (an array can have up to 6 dimensions). |
WORKAREA my_variables
FIELD my_field1 (DECIMAL(7,2))
FIELD my_field2 (DATE)
ARRAY My_Array1 (DECIMAL(5,2)) BOUNDS 10,20
END_WORKAREA
The workarea My_Variables contains two fields and a two dimensional array of DECIMAL(5,2) elements. The array has 10 columns and 20 rows.
The array would be accessed using the following syntax:
<array_name> ( <expr> [,<expr>]* )
<expr> Must be an arithmetic expression that defines the subscript for the dimension.
The ATTRIBUTES keyword is used to specify attributes for a print line. It is specified in an MDL window on Report - Amend MQMD. The window is opened by placing the cursor on the command line and using the Expand action.
ATTRIBUTES <attribute_name> [ , <attribute_name> ]*
Attribute name | Description |
NEWPAGE | causes the system to print the associated line on a new page |
SPACING ( n ) [n is a numeric literal] |
will cause n line feeds before printing i.e. a spacing of two would print one blank line before the print line. |
CTLASA 'X' | the character X will be used as the carriage control character when printing. X must be a valid ASA control character. |
ATTRIBUTES NEWPAGE
This will cause the print line to be printed on a new page.
ATTRIBUTES SPACING(2)
This will cause the print line to be preceded by a blank line.
The BEGIN ... END_FIELD statement is used on Report - Amend MQMD. It is used within a report field definition in an MDL window. Use of the BEGIN ... END_FIELD statement specifies that what is delimited by the construct is a block of MDL that is used to derive the print field, rather than a single expression. The VALUE IS statement is used to assign a value to the print field and terminate the execution of the block.
BEGIN
<statement>
[ <statement> ]*
END_FIELD
A field can be created on a report to show credit values. An attribute 'BALANCE' is evaluated to check whether it is positive or negative, since only negative values should be placed in the 'CREDIT' field.
The following MDL code will assign the value of BALANCE to the report field only if the value held in Balance is negative. Otherwise the value 'SPACES' will be assigned to the report field (that is, the field will be blanked):
BEGIN
IF BALANCE GT ZERO THEN
VALUE IS SPACES
ELSE
VALUE IS BALANCE
END_IF
END_FIELD
The BEGIN ... END_FIELD statements are compulsory here to tell the compiler that the MDL code 'IF BALANCE GT ZERO THEN' is not an expression but a general MDL statement.
The Block_Move statement is used to copy the contents of one area of storage to another area of storage without any conversion.
BLOCK_MOVE <from_id> TO <to_id>
<from_id> |
The name of a Workarea, Commarea or Field. |
<to_id> |
Must be the name of a Workarea, Commarea or Field. |
BLOCK_MOVE Balance TO Calc_vat_commarea
In this example the value held in the FIELD Balance is copied to the COMMAREA Calc_vat_commarea and would be used as the argument for the corresponding subroutine, Calc_vat.
BLOCK_MOVE my_rtn_workarea TO external_rtn_commarea
In this example the values of fields used as arguments for a user-defined subroutine which gets its arguments from my_rtn_workarea will be copied to the commarea called external_rtn_commarea.
The BLOCK_MOVE statement can be used for moving a string into an area where separate elements are defined. This then enables you to access parts of the string as separate elements.
For example the field CUSTOMER_DETAILS may be defined as a string of CHAR(100) and may hold the following value:
'Smith John 15 Grosvenor Park Gosforth 01912345678'
A corresponding Workarea may be defined in the following way:
WORKAREA cust_dets
Surname (char(10))
Firstname (char(10))
Streetno (char(4))
Streetname (char(20))
Town (char(15))
Telno (char(11))
END_WORKAREA
The statement
BLOCK_MOVE CUSTOMER_DETAILS to cust_dets
would move the string into the WORKAREA so that individual parts of the string may now be accessed. For example the customer's telephone number could now be accessed by referencing the appropriate field within the WORKAREA:
cust_dets.Telno
This statement is used to declare a cache. It can be used anywhere a WORKAREA can be declared, and is usually a precursor to other cache manipulation commands.
CACHE <cache_name> ( <size> , <Workarea_name> , <No of Key Fields> )
<cache_name> | A valid MDL identifier that will be the symbolic name of the cache. |
<size> | Must be an integer between 1 and 999,999 to specifiy the maximum number of entries in the cache. |
<Workarea_name> | The name of the workarea which is both the cache record definition and the interface area used by CACHE_GET and CACHE_PUT. |
<No of Key Fields> | The number of fields which will form the key for each cache entry, starting from the beginning of the workarea, up to a maximum of 12. |
Each Key value will be unique. Note that fields included in the Key definition may not be of class CURRVAL or VARCHAR.
Workarea REC1
Field Msg_code(CHAR(5))
Field Msg_Text(CHAR(66))
End_workarea
Cache STORED_MSGS (100,REC1,1)
This example defines a cache for up to 100 messages.
This statement is used to empty a cache, usually prior to it being re-used (on change of company, for example).
CACHE_CLEAR(<cache_name>)
<cache_name> | A valid cache name which exists within the mapping. |
Workarea Last_area Persistent
Field Last_lang(CHAR(2))
End_workarea
Workarea REC1
Field Msg_code(CHAR(5))
Field Msg_Text(CHAR(66))
End_workarea
Cache STORED_MSGS (100,REC1,1)
IF CURR_LANG NE Last_lang Then
CACHE_CLEAR(STORED_MSGS)
Let Last_lang = CURR_LANG
End_if
Let Msg_Code = NOT_FND_MSG
CACHE_GET(STORED_MSGS)
If Return_code NE Zero Then
Let Msg_text = LOOKUP('TABMSG.DESCR','** Not Found **')
USING ('LANG',Last_lang),
('PRG',SUBSTR(NOT_FND_MSG(1,3))),
('PRG',SUBSTR(NOT_FND_MSG(4,2))),
CACHE_PUT(STORED_MSGS)
End_if
Return(Msg_text)
This example shows how a cache for 100 messages would be used.
This statement is used to retrieve an existing entry from a named cache.
Appropriate key values for the data required are first assigned to the cache workarea key fields, then CACHE_GET is invoked. If the operation is successful (the data requested is in the cache) then the RETURN_CODE is zero and the data associated with the key is placed in the cache workarea. If the operation fails (the requested data is not in the cache) then the RETURN_CODE is set to +8.
CACHE_GET ( <cache_name> [ , <arg2> ] )
<cache_name> | A valid cache name which exists within the mapping. |
<arg2> | An optional integer representing the cache entry number of the data item to be retrieved. If this is specified then any supplied key values are ignored. |
Workarea REC1
Field Msg_code(CHAR(5))
Field Msg_Text(CHAR(66))
End_workarea
Cache STORED_MSGS (100,REC1,1)
Let Msg_Code = NOT_FND_MSG
CACHE_GET(STORED_MSGS)
If Return_code NE Zero Then
Let Msg_text = LOOKUP('TABMSG.DESCR','** Not Found **')
USING ('LANG','00'),
('PRG',SUBSTR(NOT_FND_MSG(1,3))),
('PRG',SUBSTR(NOT_FND_MSG(4,2))),
CACHE_PUT(STORED_MSGS)
End_if
Return(Msg_text)
This shows the use of a cache for 100 messages.
Let Ws_count = Zero
Do CACHE_ENTRIES(C1) Times
Let Ws_count = Ws_count + 1
CACHE_GET(C1,Ws_count)
Display_List Ws_count, ' Key:', W1.key, ' Data:', W1.data
End_do
In this example the cache C1 is based on workarea W1, which has KEY and DATA defined as fields within it.
This statement is used to add an entry to an existing cache or to update an existing entry.
Appropriate key and data values are first assigned to the cache workarea, then CACHE_PUT is invoked. If the operation is successful (that is, the entry requested is added to the cache) then the RETURN_CODE is zero. If an update to an existing entry with the same key value(s) occurred then the RETURN_CODE is +4. If the cache was already full, then the new entry overwrites an existing entry and the RETURN_CODE is set to +8.
CACHE_PUT ( <cache_name> )
<cache_name> | A valid cache name which exists within the mapping |
Workarea REC1
Field Msg_code(CHAR(5))
Field Msg_Text(CHAR(66))
End_workarea
Cache STORED_MSGS (100,REC1,1)
Let Msg_Code = NOT_FND_MSG
CACHE_GET(STORED_MSGS)
If Return_code NE Zero Then
Let Msg_text = LOOKUP('TABMSG.DESCR','** Not Found **')
USING ('LANG','00'),
('PRG',SUBSTR(NOT_FND_MSG(1,3))),
('PRG',SUBSTR(NOT_FND_MSG(4,2))),
CACHE_PUT(STORED_MSGS)
End_if
Return(msg_text)
This illustrates the use of a cache for 100 messages.
The CALL statement is used to invoke a external subroutine from an MDL program.
After invocation of the subroutine control returns to the statement immediately following the CALL statement with RETURN_CODE set from the called routine.
CALL <subroutine_name> ( <arg> [ , <arg> ]* )
<subroutine_name> | Must exist as a symbolic name for a program / routine that is defined within the repository. |
CALL USR_EXIT_1(EXIT_1_WORKAREA)
This makes a call to the user exit subroutine USR_EXIT_1 passing the workarea named EXIT_1_WORKAREA.
This command makes the specified company the effective 'current' company, for security and other purposes (for example, reports generated after a successful CHANGE_CMPY will be stored on the spool under the new company and any currency related fuctions where a currency code is not specified will use the companies default currency code).
The CHANGE_CMPY command is normally used in the process method of an entity which can operate across multiple companies. It should be followed by a test of the Return_Code to see whether the change succeeded.
If CHANGE_CMPY succeeds, then the Return_Code is zero; failures are indicated by non-zero codes.
CHANGE_CMPY(<company.identifier>)
<company.identifier> | The two-character key for a company defined on the system. |
CHANGE_CMPY('03')
The CHOOSE statement is used to specify selection qualification. It allows the user to specify, at a mapping level, selection that QED can use to restrict the amount of data accessed.
CHOOSE <Id> <Relational operator>
<Id> | This must be a fully qualified entity attribute reference. In addition the attribute must be derived from a single base table column. |
<Relational operator> | Must be a valid MDL relational operator |
Assume it is required to restrict data base access to a particular company code that is to be supplied at request time as a runtime parameter and, that the data is accessed via an entity called COMPANY. If the following statement is added to the formula box for the parameter, then QED will generate code to select only instances of that entity where the company code is equal to the supplied parameter.
CHOOSE company.company_code EQ
This command may be used to close a device. The command is used in conjunction with the OPEN_DEVICE command.
The OPEN_DEVICE command will open a device, which may be used with the INSERT command or as a levels base table. When work is completed the device should be closed with the CLOSE_DEVICE command.
CLOSE_DEVICE ( <Device> )
<Device> | The name of a device within current mapping that has its use indicator set to user controlled. |
Open a device for output, write data to the device, close it then reopen it for input in a level later.
Open_Device (Dev1,Output)
Insert TabDev1
.....
End_Insert
Close_Device (Dev1)
Open_Device (Dev1,Input)
This command may be used to close an instance of a selected report or all user defined reports. The command is used in conjunction with the OPEN_REPORT command.
Using the OPEN_REPORT command will open an instance of a report. Lines may be printed to the report. Those lines being printed to the current instance of the report. When the CLOSE_REPORT command is used, the current instance of the report is closed.
Repeating the OPEN_REPORT command will open a second instance of the report. Thus, a number of versions of a report may be generated from the same mapping.
Additionally, a report may be opened for a selected Distribution Profile. These are defined on Distribution Profile - Edit MAOJ. This will result in the report being sent to the selected destination.
CLOSE_REPORT ( ALL )
CLOSE_REPORT ( <report name> )
<report name> | The name of a report component on the current mapping. |
Consider a mapping which is processing data for a number of companies. So, level MAIN has an attached companies entity. Within the PROCESS block of MAIN are the following commands:
Open_Report (QED132)
Print hdg_line
Perform second_level
Close_Report (QED132)
The above code is executed for each instance of a company. The first command opens report QED132. All print commands following the OPEN_REPORT are made to the current instance of the report, for the first company. Once all processing for the first company is completed, the CLOSE_REPORT command is executed.
The next company is processed, and a second instance of report is opened. If three instances of company were to be executed, then three reports would be generated, one for each company.
This command generates a workarea based on a communication area (COMMAREA) definition in the repository.
COMMAREAs can be declared in the following procedures: functions, entity attributes and levels.
The scope of the commarea, and the variables within it, is the same as the procedure in which it is declared.
COMMAREA <commarea_name>
<commarea_name> | The name of a commarea that is defined in the repository. |
This example shows the use of COMMAREA to declare an interface area for an external subroutine.
The COMMAREA to be used by a given subroutine must always be specified prior to the subroutine call. The COMMAREA fields to be used as input to the subroutine must then be assigned their values. Finally, the subroutine can be invoked. The COMMAREA name is specified in the subroutine call.
Suppose, for example, the following COMMAREA named CQLA exists on the database. (The format shown is the approximate format in which a COMMAREA definition would be held on the database).
FIELD | CLASS | TYPE | REPEATS |
FUNC | CHAR(1) | I | - |
DATE_IN | DATE | I | - |
DUR | DECIMAL(8) | I | - |
YRS | INTEGER | I | - |
MTHS | INTEGER | I | - |
DYS | INTEGER | I | - |
WKS | INTEGER | I | - |
DATE_OUT | DATE | O | - |
RESPONSE | CHAR(3) | O | - |
MSG | CHAR(72) | O | - |
A COMMAREA statement can be used to specify that the above COMMAREA is to be used by an external subroutine; the MDL code to invoke the subroutine would look something like this:
COMMAREA CQLA
--
-- The input fields of the COMMAREA could then be assigned
-- their values:
--
LET cqla.func = '1'
LET cqla.date_in = USER_DATE_IN
LET cqla.dur = USER_DURATION
LET cqla.yrs = 0
LET cqla.mths = 0
LET cqla.dys = 0
LET cqla.wks = 0
--
-- Once the input fields of the COMMAREA have been assigned
-- their values the subroutine call can be made:
--
CALL INCREMENT_DATE(cqla)
--
-- The COMMAREA name 'cqla' is specified in the call to the
-- subroutine. Each field of the COMMAREA cqla will now hold
-- the value assigned to it within the external subroutine.
-- For example:
-- 'cqla.date_out' will contain the incremented date.
The CONTINUE statement is used when the syntax demands a statement, but no action is required.
CONTINUE
SELECT (TRUE)
WHEN var2 EQ var3
CONTINUE
WHEN var2 EQ var4
CONTINUE
OTHERWISE
LET var1 = var2
END_SELECT
This command creates the referenced Work/Master/Interface table for the given jobtag value.
All Master and Interface tables are pre-created on any e5 system so for these this command does not physically do anything.
CREATE_TABLE ("<Table>", <jobtag>)
<Table> | The name of the Work/Master/Interface table to be created. |
<jobtag> | The jobtag value for the table creation. Usually SUBMIT_JOBTAG for the current process jobtag Work table, The Mappings commarea jobtag for a passed in value from another process or SPACES for a Master or Interface table. |
Before doing an INSERT to a Work table which does not already exist you need to create it first.
CREATE_TABLE("TBX6EXT",SUBMIT_JOBTAG)
The DEFAULT IS statement specifies default values for parameters if these are not specified at request time. Default parameters are defined on Parameters - Amend MQME.
DEFAULT IS <LITERAL>
To define a Parameter default value, open an MDL window by using the Expand action on the parameter name within Parameter Names - Amend MQME. Enter the DEFAULT IS statement in this window:
PARAM_FROM_CMPY CHARACTER (2) default is 'AA' |
In this example, the user will be prompted at run time for a value for PARAM_FROM_CMPY. If a value is not supplied then QED will assign the default value 'AA' to PARAM_FROM_CMPY.
This command deletes the file that the device defines.
DELETE_DEVICE ( <Device> )
<Device> | The name of a device within current mapping that has its use indicator set to user controlled. |
After a file is read into a mapping via a user controlled device there is a requirement to delete the file. Give the following command:
Delete_Device(Dev1)
This command deletes the referenced Work/Master/Interface table at the Mappings successful termination.
Therefore is the QED Mapping Abends the DELETE_TABLE will NOT be actioned allowing the Mapping to be re-run.
DELETE_TABLE ("<Table>", <jobtag>)
<Table> | The name of the Work/Master/Interface table to be deleted at the end of the Mappings execution. |
<jobtag> | The jobtag value for the table deletion. Usually SUBMIT_JOBTAG for the current process jobtag Work table, The Mappings commarea jobtag for a passed in value from another process or SPACES for a Master or Interface table. |
After a Work, Master or Interface table has been read and processed there is a requirement to delete the table. Give the following command;
DELETE_TABLE("TBX6EXT",SUBMIT_JOBTAG)
This command deletes the referenced Work/Master/Interface table immediately.
DELETE_TABLE_NOW ("<Table>", <jobtag>)
<Table> | The name of the Work/Master/Interface table to be deleted immediately. |
<jobtag> | The jobtag value for the table deletion. Usually SUBMIT_JOBTAG for the current process jobtag Work table, The Mappings commarea jobtag for a passed in value from another process or SPACES for a Master or Interface table. |
Before doing a CREATE_TABLE (which does not physically do anything) on an interface table you may need to clear its contents before adding in more rows.
DELETE_TABLE_NOW("TEDHIFF",SPACES)
CREATE_TABLE("TEDHIFF",SPACES)
The Display command can be used to write output to one of four destinations:
DISPLAY (<report_id>) <expression> [, <expression>]*
DISPLAY_LIST <expression> [, <expression>]*
DISPLAY_ERROR <expression> [, <expression>]*
DISPLAY_SYSLOG <expression> [, <expression>]*
DISPLAY TO RQZZ01
Display_List 'Company Id',' ',Company_Code
In this example, the text between the quotes will be output as entered.
Company_Code in this case is a variable. The value of the variable which is current when the DISPLAY_LIST statement is invoked will be printed with the rest of the text.
For example, the output might look like this:
Company Id E1
Where 'E1' is the value of the Company_Code variable.
DISPLAY TO RQZZ02
The report RQZZ02 is the QED run-time error report. It is generated for mapping submissions.
DISPLAY_ERROR '*Record for Company ',Company_code,'does not exist*'
In this example, an error message is printed to the runtime error report.
DISPLAY TO THE SYSTEM LOG
This version of the Display command writes the output specified to the Syslog destination, that is, the user-specified output device. The Syslog destination is specified by the user within e5 Controls - Amend MAAB.
There are four options:
DISPLAY_SYSLOG '*Record for Company ',Company_code,'does not exist*'
DISPLAY TO A REPORT
This command may be used to output a line to a specified report. The report must be defined in the current mapping.
Display (QED132) '***** End of Report *****'
This command will display the string of text to the report QED132.
The Display_Message command is used to write out a run-time (RQZZ02) message for the given message code(s) and substitution text. Its main use is to pass on messages returned from called OLAS routines.
DISPLAY_MESSAGE (<msg Code/Type>, <msg Subtext>)
To display a 'QZZ03' Error Message with 'CMS61' as substitution text:
Display_MESSAGE('QZZ03E','CMS61')
This will display the message to the run-time report and increment the USER_ERRORS system variable.
Up to four message codes can be appended together to produce a long message:
DISPLAY_MESSAGE('QQQ01WQQQ02QQQ03QQQ04',SPACES)
This will display the concatenation of the 4 message codes text to the run-time report and increment the USER_WARNINGS system variable.
An example for a called routine:
...
CALL INCREMENT_DATE(CQLA)
IF CQLA.MSG NE SPACES THEN
DISPLAY_MESSAGE(CQLA.MSG | CQLA.MSG_TYPE, CQLA.MSG_TEXT)
END_IF
...
The DO ... END_DO construct is used to group statements together and execute them repetitively
DO FOREVER
<statement> [ <statement> ]*
END_DO
This format will cause the statements within the DO ... END_DO block to be repeated unconditionally. Therefore the statements within the DO group must terminate the loop. See the LEAVE statement.
DO WHILE ( <expression> )
<statement> [ <statement> ]*
END_DO
<expression> Must evaluate to a boolean (TRUE or FALSE) result.
This format will cause the statements within the DO ... END_DO block to be repeated while the expression evaluates to TRUE. The expression is evaluated and tested on each iteration of the loop before the statements within the DO group are executed. If the expression evaluates to false, then control is passed to the first statement following the END_DO. The LEAVE statement will cause control to pass directly to the statement following the END_DO.
DO <expression> TIMES
<statement> [ <statement> ]*
END_DO
<expression> Must evaluate to an integer result.
This format will cause the statements within the DO ... END_DO block to be repeated a number of times equal to the result of the expression. Control will then pass to the statement following the END_DO.
DO
<statement> [ <statement> ]*
END_DO
This format will cause the statements within the DO ... END_DO block to be executed ONCE only. Control will then pass to the statement following the END_DO.
The following four code fragments all display the string 'Hello world' five times
LET LoopCounter = ZERO
DO FOREVER
LET LoopCounter = LooprCounter + 1
IF loopCounter GT +5 THEN
LEAVE
END_IF
DISPLAY_LIST "Hello world"
END_DO
LET LoopCounter = ZERO
DO WHILE (loopCounter LT +5)
LET LoopCounter = LooprCounter + 1
DISPLAY_LIST "Hello world"
END_DO
DO +5 TIMES
DISPLAY_LIST "Hello world"
END_DO
DO
IF Parm_flag NE 'Y' THEN
LEAVE
END_IF
DISPLAY_LIST "Hello world"
DISPLAY_LIST "Hello world"
DISPLAY_LIST "Hello world"
DISPLAY_LIST "Hello world"
DISPLAY_LIST "Hello world"
END_DO
In this example, the message is only printed if Parm_flag contains 'Y'.
This statement is used after the accepts statement in a function definition. Functions marked as dynamic will allocate memory for workarea variables when the function is called and release that memory when the function completes. This means that the function can be used recursively, but gives a considerable performance overhead over STATIC (default) functions.
DYNAMIC
ACCEPTS ( VAR1 (CHAR(10)) )
DYNAMIC
. . . . . .
Body of function
. . . . . .
RETURN(xxx)
The above MDL is within a function definition i.e. MQFB
With a QED Report Components Print Effects may be referenced at Report, Page, Line and Field levels. The referenced effects will only appear if the final distribution supports them.
EFFECTS <effect> [ (&&<parameter>=<alpha expression> [,<parameter name>=<parameter value>] *) ] [,<effect> [ (&&<parameter>=<alpha expression> [,<parameter name>=<parameter value>] *) ] ]*
<effect > | existing Print Effect, which may have many parameters. |
<parameter name> | a parameter for the referenced Effect. If you reference the wrong value NO error messages will be given. |
<parameter value> | a parameter value for the referenced Effect. May be any alpha expression up to a maximum size of 128 characters after which it will be truncated. |
At the Report/Page Level
EFFECTS NOHEADER_REPORT
At the Line Level
ACCEPTS(FONT_SIZE(CHAR(2)))
EFFECTS PARAGRAPH_START(&&PAGE_FONTSZ=FONT_SIZE)
At the Field Level
"Totals:" EFFECTS TABLE_CEL_SPAN(&&SPAN="2",&&CELL_BGCOLOR='AQUA')
The EXECUTE statement is used to invoke a method which is attached to an entity definition. (A method changes the environment of a running mapping, but does not return a value.)
After execution of the method, control returns to the statement immediately following the EXECUTE statement.
EXECUTE <method_name>[ ( <arg> [ , <arg> ]* )]
<method_name> | The name of a method which must exist on the definition of the current entity. |
<arg> | Optional arguments which may be required by the method being called. |
One use of methods is to simplify the generation of reports across multiple companies, ensuring that each has the correct company-dependent information. (An additional example is given in QED System Administration Entities.)
First, a method must exist on the entity being used. (Methods appear as if they were attributes on Entity - Amend MQEB.) The example method below is taken from an entity which has several methods, which are used in the generation of different kinds of reports; this example sets up the environment for Fixed Assets reports. This is the complete method definition, shown in an MDL window on MQEB; the method name is emphasized.
Entity . . . . COMPANY Company
Base Table . . TAACMPY Company
FA_REPORT_HEADINGS
Let Reports_Cmpy_Dpdnt = 'Y'
Let Reports_Cmpy = Taacmpy.Cmpy
Let Reports_Calendar = Lookup ('Tfacntrl.fscl_clndr',' ')
Using ('CMPY',Taacmpy.Cmpy)
Let Reports_Period = Lookup ('Tfacntrl.curnt_per',0)
Using ('CMPY',Taacmpy.Cmpy)
Let Reports_Fiscal_Lvl = zero
Let Reports_Fiscal_Yr = Lookup ('Tfacntrl.curnt_yy',0)
Using ('CMPY',Taacmpy.Cmpy) Heading_Refresh(All)
(The contents of the method should be self-explanatory.)
A mapping which makes use of this method contains the following in level Main:
Mapping . . . . FA_HIST_DEPN Historic Depreciation Report
Level . . . . . MAIN Company Processing
ENTITY IS COMPANY Company
...
Execute Fa_Report_Headings
Perform Grp_Categ
Print Blank_Line
Print Cmpy_Total
(The illustration shows part of the screen Level Break - Amend (MQM0); note the entity and method names; the Execute command is emphasized.)
This statement is used to declare a variable. It can only be used within a WORKAREA ... END_WORKAREA construct.
(See also ARRAY)
FIELD <field_name> ( <class> )
<field_name> | A valid MDL identifier that will be the symbolic name for the field. |
<class> | A valid MDL class. |
WORKAREA my_variables
FIELD my_field1 ( DECIMAL(7,2) )
FIELD my_field2 ( DATE)
END_WORKAREA
This function may be used to maintain the status of a selected field. Each field has an associated status field. The status of a field is maintained by the system, and can be displayed using the STATUS command.
FORCE_STATUS may be used to change the status of a field. This can be used to force a field to an error status or to override an error status.
FORCE_STATUS (<field id>, <expression>
<field id> | A working storage Field name. |
<expression> | Must evaluate to an integer between 0 and 20. |
Force_Status (cntr,8)
The status of the field CNTR, is given the value of 8.
This command is used to refresh the default report page headings. This may be done for all reports, or for a selected report.
The command is typically used in conjunction with these variables:
The above are system supplied variables which may be used to print either a selected company description, or a selected period name and end date as part of the default report page headings.
The HEADING_REFRESH action will result in the report(s) default headings being refreshed to the values assigned to the system supplied variables.
If the default headings have been disabled using the <report>.HEADING variable, then the HEADING_REFRESH action will enable the default headings.
The HEADING_REFRESH action is performed either for all reports, or for a selected report.
A mapping may have a number of report components, for example, QED132, and QED132A. By refreshing all reports, then the amended default headings will be displayed for reports generated by both report components on mappings.
Alternatively, the Heading_Refresh command may be performed for a selected report, for example, QED132. So, any amended default report headings will only appear for mappings which use the report QED132.
Heading_Refresh (<All>/<Report name>)
Let Reports_Cmpy = Cmpy
Heading_Refresh (All)
This command can be used to refresh the company descriptions for all reports to the value assigned to the REPORTS_CMPY variable.
Let Reports_Cmpy = Cmpy
Heading_Refresh (QED132)
This command will only affect reports generated for QED132. So, for example, the default headings for reports generated for QED132A will not be affected.
The IF ... THEN ... ELSE ... END_IF construct allows the conditional execution of MDL statements. It evaluates a condition and, depending upon the result of the evaluation, execute the appropriate statements.
IF <expression_1> THEN
<statements>
END_IF
IF <expression_1> THEN
<statements>
ELSE
<statements>
END_IF
<expression_1> | A Boolean expression. |
<statements> | Any valid MDL statements. |
IF a EQ b THEN
LET x = y
END_IF
If the values of a and b are equal then the statements following the THEN will be executed, if they are not then control will pass to the statement following the END_IF.
IF a EQ b THEN
LET x = y
ELSE
LET x = z
END_IF
If the values of a and b are equal then the statements following the THEN will be executed, if they are not then control will pass to the statement following the ELSE.
Both spellings (INITIALISE and INITIALIZE) are legal in MDL, and may be used interchangeably.
The INITIALISE command is used to ensure that declared variables have known initial values before they are used in processing; the assigned values are zero-equivalents, depending on the class of the variable.
Zero is assigned to numeric variables, empty strings are assigned to alphanumeric variables, and the figurative constants MIN_DATE and MIN_TIME are assigned to date and time variables.
If non-zero starting values need to be assigned to variables before processing starts, then this should be done after the INITIALISE command; for example, you would intialise an array then assign non-zero values to a few specific cells within that array.
INITIALISE <identifier>
<identifier> | The name of a workarea, workfield, or array which is defined within the mapping. |
The INSERT block is used to insert a row on to a table. If the table has been redirected to a device (and not a translate program) then any failure of the INSERT will usually result in a file-related ABEND. However, if the table has been redirected to or from a program or has not been redirected at all (that is, an SQL INSERT is occuring), then the RETURN_CODE system variable can be checked as to the success or failure of the INSERT command.
INSERT <table name/data block> <insert XML type> <insert set flag opt>
<proc_statements>
END_INSERT
<table name/data block> | Table or Data Block already defined in the Tables Component. |
<insert XML type> | If a Data Block is being inserted to the XML Output Device then this gives the option of the Data Block end Tag (if it has a tag defined) being written WITH_END_TAG or not WITHOUT_END_TAG. The default is WITH_END_TAG if not specified.<proc_statements> Can be any of these MDL commands: LET DISPLAY CALL BLOCK_MOVE CONTINUE DO IF SELECT SET BLOCK_SET RETURN. |
<insert set flag opt> | Controls set flag processing. Within e5 many output files use "set flags" to indicate if a field has been populated. This option controls how QED deals with these flags. To definine a "_S" flag in the repository for a file a "_S" flag entry is placed before the normal entry for a data item with the same name as the data entry with a "_S" postfix. SET_FLAGS_AUTO (default), This option will cause code to be generated when the END_INSERT is encountered to set any "_S" entries in the "table name" to be "Y" or spaces. If the data value for the "_S" is not min value for its class (spaces, 0, min date or min time) the "_S" flag is set to "Y" otherwise it is set to " ". If the "_S" entry is already set to "Y" it will be left alone - this allows values to be overiden when the "_S" value should be set to "Y" but the data value is min value for its class. SET_FLAGS_MANUAL, QED will make no attempt to place values in any "_S" entries in a table. All "_S" values must be set up by user created MDL code. |
The ITERATE instruction alters the flow within a repetitive DO loop. It returns control back up to the beginning of the loop. The program then moves back up to re-enter the beginning of the DO loop. Any condition specified in the DO statement will be re-tested at this point. The statement, or group of statements within the DO loop will as usual be executed, or not depending on the outcome of the evaluation.
ITERATE
DO WHILE (Acc_no NE '9999')
<statement>
<statement>
IF ACC_NO EQ SPACES THEN
ITERATE
END_IF
<statement>
<statement>
END_DO
In the above example the program will execute the first group of statements (1) and then evaluate the field ACC_NO. If ACC_NO is equal to SPACES (that is, no data has been input for this account number) then the second group of statements will be ignored and the program will re-enter the loop at the beginning of the DO statement. In this case the program will exit the loop when an account number of '9999' is encountered.
The LEAVE statement causes immediate exit from a repetitive DO loop. Once the program has exited the DO loop, control is passed to the statement following the END_DO.
LEAVE
LET FINISH = 'N'
DO FOREVER
CALL USR_EXIT_1(VAR1,FINISH)
IF FINISH EQ 'Y' THEN
LEAVE
END_IF
END_DO
In the above example the subroutine USR_EXIT_1 will be called repeatedly until the value of the field FINISH becomes equal to 'Y'. At this point the program will exit the loop, and control will be passed to the instruction immediately following the END_DO statement.
The LET command is used to assign the result of an expression to a variable.
LET <variable> = <expression>
The expression to the right of the assignment operator is evaluated and the result of this evaluation becomes the current value of the variable to the left of the assignment operator. The new value will replace any previous value held by this variable. Any type conversion necessary will be performed. If conversion is not possible the a type check error will occur at compile time.
LET a = b
a receives the value of b.
LET Tax = (Earnings / 100) * 25
In this example the variable TAX will take on the value of the result of the calculation to the right of the equals sign.
The LIST statement produces a simple report where the attributes specified in the LIST statement appear as column headings. The information is output to a special report : RQZZ01. This name is automatically assigned to the report when the LIST statement is used. This command is intended for use within the PROCESS block of a LEVEL that has an entity specified.
LIST <expression> [ , <expression>] *
Suppose, for example, it were necessary to produce a report listing a number of companies showing their NAME, COUNTRY, BASE_CURRENCY and BALANCE. If an Entity 'COMPANY' were defined with 'COMPANY_NAME', COUNTRY, BASE_CURRENCY and BALANCE as its attributes, then the above report could be produced with the following statement:
LIST COMPANY_NAME,COUNTRY,BASE_CURRENCY,BALANCE
This statement would have to be issued within an MDL window from a level where COMPANY was defined as the Entity.
The Note_Diary_Line command adds a new line of text to an existing Diary Entry.
NOTE_DIARY_LINE (<DiaryNum>,<Expr>)
A Note_Diary_Line would always be preceeded by a Note_Diary function in order to obtain a New Diary entry number, for example:
Let DIARY1 = NOTE_DIARY ('SYSTEM', SPACE, SPACE, 'Urgent Reminder')
NOTE_DIARY_LINE (DIARY1, 'Board Meeting Tomorrow')
This creates a non-event Diary entry and adds a single text line to it.
The Note_Event command notes the given Event and Object Key to the OLAS Business Event Manager.
NOTE_EVENT (<expr1>,<expr2>)
NOTE_EVENT ('DATE_EXCEEDED', TAFUSR_USR)
This notes the DATE_EXCEEDED event passing the User Code for which the event applies.
This command may be used to open a device (file) that has been defined as user controlled. The command is used in conjunction with the CLOSE_DEVICE and DELETE_DEVICE commands.
Before data is read or written to a device the device should be opened for the appropriate access type. A user controlled device may be opened and closed a number of times within one mapping. To write to the device the INSERT command is used. To read data from the device the TABLE linked to the device needs to be used as the base table of a levels entity or as a levels table and the level performed.
Open_DEVICE (<Device name>,<access type>)
<Device name> | The name of a device within current mapping that has its use indicator set to user controlled. |
<Access type> |
Controls how the device is to be used: INPUT - Allows data to be read from the device. OUTPUT - Clears any existing data in the device and allows new data to be inserted. APPEND - Leaves any existing data in the device, and allows more data to be added. |
Open a device for output, write data to the device, close it then reopen it for input in a level later.
Open_Device (Dev1,Output)
Insert TabDev1
...
End_Insert
Close_Device (Dev1)
Open_Device (Dev1,Input)
This command may be used to open an instance of a selected report(s), to a required destination. The command is used in conjunction with the CLOSE_REPORT command.
Using the OPEN_REPORT command will open an instance of a report. Lines may be printed to the report. Those lines being printed to the current instance of the report. When the CLOSE_REPORT command is used, the current instance of the report is closed.
Repeating the OPEN_REPORT command will open a second instance of the report. Thus, a number of versions of a report may be generated from the same mapping.
Additionally, a report may be opened for a selected Distribution Profile. These are defined on the map MAOJ, Distribution Profile - Edit. This will result in the report being sent to the selected destination.
Open_Report (<report name>,<alpha expr>)
Open_Report (ALL ,<alpha expr>)
<report name> | The name of a report component on the current mapping. |
ALL | Open all user defined reports in the mapping. |
<alpha expression> | An alphanumeric expression which nominates the identifier of a currently defined distribution profile. |
Consider a mapping which is processing data for a number of companies. A companies entity is attached to level MAIN. Within the PROCESS block of Main are the following commands:
Open_Report (QED132)
Print hdg_line
Perform second_level
Close_Report (QED132)
This code is executed for each instance of a company. The first command opens report QED132. All print commands following the OPEN_REPORT are made to the current instance of the report, for the first company. Once all processing for the first company is completed, the CLOSE_REPORT command is executed.
The next company is processed, and a second instance of report is opened. If three instances of company were to be executed, then three reports would be generated, one for each company.
It may be a requirement to attach separate distribution details to each instance of report. This may be performed by attaching a distribution profile to a report when it is opened.
Open_Report (QED132,'STD')
This command will open a report for distribution profile STD. The profile identifier may be a parameter name, or workfield:
Open_Report (QED132,param_profile)
A mapping can be defined with a number of levels. The PERFORM instruction can be used to invoke another level defined on a mapping. Both levels must be defined on the same mapping.
When the invoked level has completed, control returns to the calling level, at the instruction following the PERFORM instruction.
There is an implied qualification on entity between levels when a PERFORM instruction is executed. That is, the instances of the entity extracted by the subordinate level are qualified by the current instance of the calling level's entity. This qualification is based on the defined relationships between the base tables of the entities concerned. Relationships are defined in the repository.
PERFORM <id> [ RELATIONSHIP (<alpha_literal>)]
<id> | Must specify a level name that exists within the mapping. |
<alpha_literal> | Must specify a valid relationship. The RELATIONSHIP statement is used within the PERFORM statement to specify explicitly which relationship between tables is to be used to extract the data. The relationship must previously have been defined on MAIG. If it is not specified, QED will establish valid relationships between the base tables from the repository. If multiple relationships exist they will be ORed together. If no relationship exists a QED compile time error will result. |
-- Execution of this statement invokes the level "next_level".
PERFORM next_level
-- When next_level has completed execution, control returns
-- to the calling level, at the instruction following the
-- PERFORM, in this case the PRINT instruction.
PRINT report_line
The POPULATE command is used to load a matrix with data. Data is extracted from the database via the entity associated with the matrix in its definition.
Earlier versions of QED used to populate all defined matrices automatically as soon as a mapping was run; each matrix in a mapping must now be populated explicitly. (The MDL compiler issues a warning message if a matrix is defined but a relevant POPULATE command is not found in a mapping.)
It allows for multiple instances of a matrix depending on the level at which the command is issued.
There is an implied qualification on entity between levels when a POPULATE instruction is executed. That is, the instances of the entity extracted by the subordinate level are qualified by the current instance of the calling level's entity. This qualification is based on the defined relationships between the base tables of the entities concerned. Relationships are defined in the repository.
POPULATE <matrix_name>
<matrix_name> | The name of the matrix to be populated. This must be a valid name which exists within the mapping. |
This keyword can be used to print a line defined on a report. The report and the level on which the report line is defined must be defined within the same mapping. When PRINT is specified the entity on the report line should be the same as that defined on the level.
PRINT <line_name> [ (<expression> [ , <expression>]* ) ]
<line_name> | Must be a valid line name that exists within the mapping. |
<expression> | Expressions matching the class of the lines defined Accepts variables. |
PRINT hdg_line_1
This command prints the report line line hdg_line_1.
PRINT hdg_line_1 (PAram_period, Param_year)
This command prints the report line line hdg_line_1.
The parameters Param_period and param_year are passed to the report line.
The PROCESS_LIMIT command is used to set a ceiling to the amount of processing performed; it is a 'logical unit of work' limit.
Certain limits are defined at various levels on a system, to prevent 'runaway' programs from uselessly tying up system resources; for example, there is a specific upper limit to the number of report lines a single mapping can generate. These limits mean that even infinite loops are eventually terminated.
You can use this command to effectively set your own limits in case of excessive unproductive processing.
PROCESS_LIMIT (<arg_1>,<arg_2>)
<arg_1> | is the increment amount; this should be an integer of value 1 or greater. Values less than 1 are treated as 1. |
<arg_2> | is the message to be inserted in the run time error report, normally an alphanumeric literal. |
PROCESS_LIMIT (5,"Level 2: limit exceeded")
In this example, it is known that the level should never be executed more than 10000 times; the system defined limit is 50000. Setting the increment to 5 means that the system limit will be reached when the process has been executed 10000 times, and the 'runaway' is stopped; the message in the error report indicates which Process_Limit command was being executed when the limit was reached.
The QUIT command is used to immediately exit from a mapping. It has the same effect as a jump to the end of the post-process block in the level Main, and all normal closedown 'housekeeping' is performed.
It is normally used when no further processing is required; for example, there is no more data to process, or some other anticipated condition has arisen which renders further processing pointless.
(See also TERMINATE)
QUIT
The REPRINT statement is generally used after a page overflow. It causes the last printed version of a line to be reprinted exactly as the previous version. Unlike the PRINT statement the REPRINT statement does not affect the TOTAL accumulators for numeric FIELDS.
REPRINT <line_name>
<line_name> | Must be a valid line name that exists within the mapping. |
REPRINT ACCT_HDR
This line would cause the page headers defined in the print line ACCT_HDR to be printed.
The REPRINT command would typically be used when beginning a new page:
WHENEVER PAGE_OVERFLOW
REPRINT ACCT_HDR
<statement>
<statement>
END_WHENEVER
This MDL code would cause the print line ACCT_HDR to be reprinted at the top of every new page.
The RETURN statement is used within a function or entity attribute declaration to specify a value to be returned to the invoking program once the function or entity attribute has completed its processing. It can also be used in methods and levels where no value is to be returned.
It returns control to the statement immediately following the one which invoked the function, method or level containing the RETURN.
RETURN(<expression>)
RETURN
<expression> | Expressions matching the returns class of the function or entity attribute. |
The first format of RETURN statement is best illustrated from within the context of a full function declaration. Here is the declaration for a function named 'CALC_TAX' which has been defined using MQFB, Function - Insert:
ACCEPTS (Earnings (DECIMAL(15,2)
,Tax_rate (DECIMAL(4,2)
)
LET Tax = Earnings / 100 * Tax_rate
RETURN(Tax)
The value returned at the end of the function is be the current value of the variable Tax. Suppose, for example, the above function CALC_TAX were invoked with the following statement:
LET Tax_value = CALC_TAX(Salary,Rate)
The variable Tax_value would be assigned the value held in the variable Tax at the end of the function's processing.
The second format of the command does not return a value.
Whilst the IF ... THEN ... END_IF statement allows a selection of two alternatives, the SELECT ... WHEN ... END_SELECT statement allows the program to select one of several alternative statements for execution depending on the value of the workfield selected.
To allow for an unforseen value being selected by the SELECT statement the OTHERWISE statement may be included. The statement to be executed in the event of an unforeseen value being selected follows the OTHERWISE section of the SELECT statement.
SELECT <expression>
WHEN <expression>
<statement
WHEN <expression>
<statement>
...
OTHERWISE
<statement>
END_SELECT
SELECT Balance_type_ind
WHEN 'A'
return('Base')
WHEN 'B'
return('Base Equivalent Frgn')
WHEN 'C'
return('Foreign')
OTHERWISE
return('???????')
END_SELECT
In this example the workfield Balance_type_ind will be evaluated. If the value of Balance_type_ind is equal to 'A' then the statement return(Base) will be executed. If the value of Balance_type_ind is equal to 'B' then the statement return (Base Equivalent Frgn) will be executed and so on. If Balance_type_ind does not have any of the anticipated values (that is, not 'A', 'B' or 'C') then the statement following OTHER, return(???????), will be executed.
The SET command is used within an INSERT block to assign a value to a table column.
SET <column> TO <expression>
<column> | A table column/Data Block field from the INSERTed Table/Data Block. |
<expression> | Expressions matching the class of the Table column/Data Block field. |
INSERT my_table
SET my_column1 TO CURRENT_DATE
SET my_column2 TO 'Y'
END_INSERT
The SQL_COMMIT command is used within a mapping to do an SQL COMMIT. The result is dependent upon the database's COMMIT functionality. Under some database releases doing an SQL_COMMIT can close all open cursors. This will probably lead to an ABEND for the mapping, so this should be placed carefully to avoid problems.
SQL_COMMIT
This statement is used after the accepts statement in a function definition. Functions marked as static will allocate memory for workarea variables when the mapping starts and release that memory when the mapping completes. This means that the function can not be used recursively, but gives a considerable performance advantage over DYNAMIC functions.
If neither STATIC nor DYNAMIC are specified in a function definition then the function will default to STATIC unless it calls itself directly in which case it will default (and override any STATIC keyword) to DYNAMIC. It should be noted however that this will not protect against functions that call other functions that call the first function.
STATIC
ACCEPTS ( VAR1 (CHAR(10)) )
STATIC
. . . . . .
Body of function
. . . . . .
RETURN(xxx)
The above MDL is within a function definition i.e. MQFB
The TERMINATE command is used to immediately stop processing of a mapping with an ABEND (abnormal end), with the specified message.
It is normally used when a problem is anticipated but a solution is not (yet) available, and processing can not or should not continue.
Because TERMINATE forces an ABEND, all the normal diagnostic reports are available to provide additional information about why the mapping stopped; this makes it useful for deugging complex mappings.
(See also QUIT)
TERMINATE WITH MESSAGE <expression>
<expression> | can be any expression which returns an alphanumeric string; in practice, this is normally an alphanumeric literal. Strings longer than 66 characters are truncated (this is the e5 message length limit). |
IF a GT b THEN
TERMINATE WITH MESSAGE "Level 3: limit b exceeded"
ELSE
CONTINUE
END_IF
In this example, a test has been set to check the value of one variable against another; if a becomes greater than b, this is regarded as an error which should halt processing. The message indicates at what point the processing was halted, and why.
This command can be used in the Order By field of Level Component MQML. The Order By clause is used to determine the order in which instances from an entity are processed. Typically, instances are ordered by attributes on an entity.
The UNIQUE command can be used to ignore duplicate instances of attributes. The command will result in only one instance for a given sort key being processed.
UNIQUE
Order By UNIQUE CMPY,ACCOUNT
In this example, instances from an entity are ordered by the attributes CMPY and ACCOUNT. There may be a number of instances extracted from the entity for the same company/account combination.
Using the UNIQUE keyword will result in instances being sorted by company/account, but only one of each company/account combination is processed.
The VALUE IS statement is used to assign a value to a print field. It can only be used within the BEGIN .... END_FIELD construct.
VALUE IS <expression>
VALUE IS <expression> MASK IS <edit_mask> [<presentation_option>
[ ,<presentation_option> ]*]
VALUE IS <expression> PRESENTATION IS <presentation_name>
[<presentation_option>[ ,
<presentation_option> ]*]
<expression> | Can be any numeric or alphanumeric expression. The expression is evaluated and the result is assigned to the print field. If the print field is named and typed then the result of the expression must be compatible with the declared field class. |
<edit_mask> | The edit mask must be a alphanumeric literal that contains a valid edit mask for the result of the expression. Edit masks are detailed under Field Presentation. |
<presentation option> | Presentation options are operators that modify the edited character string prior to printing on the report. Each operator modifies the current string that is the result of previous operations in a left to right order. The valid presentation options are detailed in Field Presentation. |
<presentation_name> | Presentation_name is an externally defined set of field presentation instructions that are maintained by Field Presentation list and edit (MQPA and MQPB). |
For example, a field may be created on a report called CREDIT. This field might correspond to a given nominal and be used to indicate any credits against that particular nominal. An attribute BALANCE is evaluated to check whether it is positive or negative, since only negative values should be placed in the CREDIT field.
The following MDL code will assign the value of BALANCE to the to the report field CREDIT only if the value held in Balance is negative. Otherwise the value 'SPACES' will be assigned to the report field CREDIT, that is, the field will be blanked :
BEGIN
IF BALANCE GT ZERO THEN
VALUE IS SPACES
ELSE
VALUE IS BALANCE
END_IF
END_FIELD
The BEGIN...END_FIELD statements are compulsory here to tell the compiler that the MDL code 'IF BALANCE GT ZERO THEN' is not an expression but a general MDL statement.
This command will put the mapping to sleep for the given number of seconds, continuing execution of the mapping on the statement after the WAIT command.
WAIT (<expression>)
<expression> | must be a valid numeric expresssion where the final value does not exceed 32768 (equivalent to 9.1 hours). |
To wait for one minute use;
WAIT(60)
The main use of this command would be with the DEVICE_EXISTS function to repeatedly check for the existance of a file possibly before timing out.
The WHENEVER PAGE_OVERFLOW ... END_WHENEVER construct allows control to be transferred to a statement or group of statements whenever a page end is reached. This construct is restricted to level blocks and the effect of the WHENEVER code is limited to page overflows that occur during the processing of the level in which it was defined.
WHENEVER PAGE_OVERFLOW(<report_id>)
<statement>
<statement>
...
END_WHENEVER
<report_id> | Any Report component already defined in the Mapping. |
WHENEVER PAGE_OVERFLOW(QED132)
REPRINT HEADER_LINE_1
REPRINT HEADER_LINE_2
END_WHENEVER
In this example whenever a page end is reached on the report QED132 the print lines HEADER_LINE_1 and HEADER_LINE_2 will be reprinted at the top of the new page.
This construct is used to delimit the declaration of a group of variables (see FIELD and ARRAY). The variables declared will be assigned contiguous storage locations in memory.
WORKAREAs can be declared in these procedures: Functions, Entity attributes and Levels.
The scope of the workarea, and the variables within it, is the same as the procedure in which it is declared.
WORKAREA <Workarea_name> [PERSISTENT]
<declaration>
[<declaration>]*
END_WORKAREA
PERSISTENT If this optional keyword is not code then the life of the storage allocation is the same as the procedure in which the WORKAREA is declared. If it is coded then the storage persists for the life of the mapping; that is, the contents of the variables is preserved between invocations of the procedure.
<declaration> | A valid declaration for a FIELD or ARRAY. |
WORKAREA my_variables
FIELD my_field1 (DECIMAL(7,2))
FIELD my_field2 (DATE)
ARRAY My_Array1 (DECIMAL(5,2)) BOUNDS 10,20
END_WORKAREA
The workarea My_Variables contains two fields and a two dimensional array of DECIMAL(5,2) elements. The array has 10 columns and 20 rows.
Allows the automatic generation of an XML Schema or Style Sheet for a given Data Group. May also be used to do a Syntax Check on the Mapping input XML Device reporting all errors found.
XML_EXECUTE(<Execute Type>[,<Device Expression>, <Data Group Expression>])
<Execute Type> |
Controls what XML Execute function is to be done: GENERATE_SCHEMA - Will generate an XML Schema into the given Device for the specified Data Group. GENERATE_STYLESHEET - Will generate an XML Style Sheet into the given Device for the specified Data Group. SYNTAX_CHECK - Will perform a XML Syntax check on the Mappings input XML Device reporting any errors found. FULL_CHECK - Validates that the XML file against the data group definition. All tags in the XML file must be defined in the data group (in the correct structural order). The RETURN_CODE is set to 0 if check success , or 8 if check fails. MANDATORY_CHECK - Validates XML file against the data group, checks that all fields / blocks in the group that are marked as mandatory exist in the correct place. The XML file may contain tags that do not exist in the data group. The RETURN_CODE is set to 0 if the check succeeds , or 8 if the check fails. |
<Device Expression> | An expression containing the name of a device to be used for the output of the generated Schema or Style Sheet. |
<Data Group Expression> | An expression containing the name of a Data Group for which a Schema or Style Sheet is to be generated. |
To generate the XML Schema for the SI_DOC_XML Data Group and send the result to the KQXMLSCH device the following command should be used.
XML_EXECUTE(GENERATE_SCHEMA,'KQXMLSCH','SI_DOC_XML')
Retrieves the next instance of the referenced Data Block into the Mapping from the XML input Device.
XML_FETCH(<Data Block>,<Fetch Type>)
<Data Block> | The name of the Data Block to be fetched. |
<Fetch Type> |
Controls what XML Fetch does to locate the referenced Data Block:
WITHOUT_FIND - Will start loading the referenced Data Group Fields from the current position until the end of the current Tag. WITH_FIND - Will search globally for the referenced Data Blocks start Tag from the current position before starting to load its field values. |
To generate the XML Schema for the SI_DOC_XML Data Group and send the result to the KQXMLSCH device the following command should be used.
XML_FETCH(TQFFUNC_BLK,WITHOUT_FIND)
A successful XML_FETCH will leave the XML input Device positioned at the end tag of the current XML Tag Block.
An unsuccessful XML_FETCH will leave the XML input Device position unknown.
Allows individual XML "words" to be written to the output XML Device.
XML_INSERT(<Insert Type>[, <Tag Expression>][, <Data Expression>])
<Insert Type> |
Controls what type of XML Insert occurs:
START_TAG - Will just insert the Given start Tag (e.g. <TAG>) the maximum tag size is 64 characters mixed case. END_TAG - Will insert the currently started tags end tag (e.g. </TAG>). START_END_TAG - Will insert a blank start and end tag (e.g. <EMPTY_TAG />). COMMENT_TAG - Will insert the given comment tag (e.g. <?--This is a Comment -->) the maximum comment tag size is 3999 characters. TAGGED_DATA - Will insert the given tags start and end around the given data (e.g. <TAG> Data </TAG>) the maximum tag size is 64 characters and the maximum data size is 3999 characters. DATA_ONLY - Will insert the given data value only maximum size 3999 characters. TAG_ATTRIBUTES - If the previous tag insertion had the XML output Device.XML_ATTR_OVFL flag set to 'Y' this will allow for up to 16 more Device.XML_ATTR_NAME(xx) and matching Device.XML_ATTR_VALUE(xx) to be inserted. Attribute names are up to 32 characters and attribute values are up to 128 characters with their being no limit to the total number of attributes which may be inserted for any tag. |
<Tag Expression> | The expression containing the tag value. This is required for the START_TAG, START_END_TAG and TAGGED_DATA insert types. The maximum size of any tag is 64 characters however a comment tag may be up to 3999 characters. |
<Data Expression> | The expression containing the data value. This is required for the TAGGED_DATA and DATA_ONLY insert types. This may be up to 3999 characters but trailing spaces are not considered significant. Multiple DATA_ONLY XML_INSERTs may be executed to allow for more than 3999 characters. |
Here a start Tag of 'BIG_DATA' is inserted followed by three lines of data and finally the end tag is inserted.
XML_INSERT(START_TAG,'BIG_DATA')
XML_INSERT(DATA_ONLY,WS_DATA_LINE1)
XML_INSERT(DATA_ONLY,WS_DATA_LINE2)
XML_INSERT(DATA_ONLY,WS_DATA_LINE3)
XML_INSERT(END_TAG)
Allows individual XML "words" to be read from the input XML Device.
XML_READ(<Read Type>)
<Read Type> |
Controls what type of XML Read occurs:
NEXT_XML_ITEM - This will just read in the next XML "word" whatever it happens to be. TAG_ATTRIBUTES - This will just read in the next set of the current tags attributes into the XML input Device.XML_ATTR_NAME(xx) and Device.XML_ATTR_VALUE(xx) where xx is up to 16. If there are more than 16 attributes for a tag then more TAG_ATTRIBUTES type read calls should be made until the Device.XML_ATTR_OVFL flag is not set to 'Y'. TAGGED_DATA - this should only be issued when it is known that a <TAG> data </TAG> is expected next. |
Both spellings (ZEROISE and ZEROIZE) are legal in MDL and may be used interchangeably.
In QED each field of numeric class on a user defined report line has associated with it an accumulator which keeps a total of all values to be printed out in the report. This is a built-in feature of QED.
Each time an MDL call is made to print a line the numeric FIELD totals are adjusted to take account of the additional values.
The ZEROISE statement allows you to reset all accumulators on a specified line back to zero.
ZEROISE <line_name>
<line_name> | Must be a valid line name that exists with in the mapping. All the accumulators associated with fields on that line will be set to zero. |
Suppose that the print line CATEG_DETAIL prints out three fields, FIELD_1, FIELD_2 and FIELD_3 all of which are numeric. If FIELD_1 has a value of '50' at the first print call, '25' at the second print call and '100' at the third print call then the TOTAL of the field after the third print call will be '175'.
In order to reset this total to zero it is necessary to ZEROISE the entire print line. In the above example this could be done by the following statement:
ZEROISE CATEG_DETAIL
See also
QED Mapping Development Language Home Page