*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | DEBUG | Identifier | Output file | Debug | | | | | | info | | *---------*---------------*-----------------*----------------*---------------*
The DEBUG operation helps the programmer debug a program that is not working properly. One or more records containing information helpful for finding programming errors are written as a result of this operation. You can use the DEBUG operation independently of or in combination with the OS/400 testing and debugging functions.
You can specify the operation at any point or at several points in the calculation specifications. Whenever the program encounters the DEBUG operation, one or more records are written. The first record contains the source-statement sequence number of the DEBUG operation in the program, factor 1 if any, and a list of all indicators that were on at the time the DEBUG operation was encountered. It can contain the contents of a field, an array element, a table element, or a literal that identifies the written information that describes the DEBUG operation. The contents of factor 1 identify the written information that describes the DEBUG operation. It can contain a field name, an array element, a table name, a named constant, or a literal. The length of the specified field can be from 1 to 8 characters. Factor 1 cannot contain a figurative constant. If factor 1 contains an entry, the sequence number and the contents of the entry are written to the first record. If factor 1 is not used, the source statement sequence number of the DEBUG operation is written to the first record.
Factor 2 can contain the name of the output file to which the DEBUG output is written. This file must have a record length of at least 80 positions. Only program-defined output files are allowed with the DEBUG operation; externally described files are not permitted. If factor 2 is blank, the output goes to the display work station that requested the program (the requester). The same entry must appear in factor 2 of all DEBUG operations in a program.
The contents of the result field are written to a separate record. The result field can contain a field name, an array name, a table name, or a KLIST (Define a Composite Key) name.
If factor 1 and the result field are not specified, only the indicators and the source statement sequence number of the DEBUG operation are written.
The DEBUG operation is performed only if a 1 is specified in position 15 of the control specification. Otherwise, the DEBUG statement is checked for errors at compile time, but the DEBUG operation is not processed at run time.
For a DEBUG operation, one record is always written in the following format:
If an indicator contains a character that is not valid (not '0' or '1'), the indicator is listed followed by the hexadecimal representation of the value in the indicator. For example, if indicators 01 and 88 are on, and indicator 33 contains the character A, the indicator line appears as: ON = 01 33 (C1) 88.
When the result field contains an entry, a separate record is written in the following format:
Numeric fields are written out in unpacked format and are zero-suppressed. The sign is always written to the right of the field; a minus (-) sign is written to the right of negative fields, and a blank is written to the right of positive fields. Zero fields are written with the last zero and the sign. No other editing is done. If the result field is an array name, the elements are written in order, one record for each element. When a multiple occurrence data structure is specified, only the current occurrence is written.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.