MOVTODEC MOVE TO DECIMAL TAACLPQ |
The 'Move to Decimal' and 'Move to Character' commands perform an RPG
type of MOVE operation where no decimal alignment is performed. The
normal CHGVAR command always performs decimal alignment.
MOVTODEC is intended for those situations where a variable or literal
contains an implied decimal point and needs to be placed into a
decimal field which is defined with decimal positions. CHGVAR cannot
be used because it will place all of the digits to the left of the
decimal position.
An example of the use of MOVTODEC is where a literal needs to be
defined with digits to the right of the decimal point and the program
is intended to operate in different countries. If a decimal point is
used, the character is misinterpreted in countries which use a comma
as the decimal point notation.
For example, assume you wanted to multiply by 10%. You would
normally specify:
CHGVAR &RESULT (&AMOUNT * .10)
To avoid specifying the decimal point, you define a variable and then
use MOVTODEC to initialize the value:
DCL &PERCENT *DEC LEN(15 5)
.
.
MOVTODEC TODEC(&PERCENT) FROMCHAR(10000)
CHGVAR &RESULT (&AMOUNT * &PERCENT)
The TODEC variable must be defined as *DEC LEN(15 5). The character
value you define is moved from the right so that you must provide for
the 5 decimal positions. Any blanks are bypassed.
If you wanted the value 1234.567 you would specify:
DCL &XX *DEC LEN(15 5)
.
.
MOVTODEC TODEC(&XX) FROMCHAR(123456700)
MOVTOCHR
--------
The Move to Character command is intended for those situations where
you have a decimal field with some number of decimal positions and
want it to be moved to a character field without the decimal point.
For example, assume you have a decimal field declared with LEN(5 2)
and it has a value of 123.45. You want to move it to a character
field so that the value will be 12345 without a decimal point. The
CHGVAR command cannot be used because a decimal point will appear in
the result.
Any decimal field passed to a command decimal parameter will be
decimal aligned. Therefore, the MOVTOCHR command provides 6
different input fields (FROMDEC1 .... FROMDEC6). You must use the
proper command parameter and declare which of the 6 you are using.
The character field you move to must be declared as LEN(15). The
value will be right adjusted. You may need to substring into the
result field to work with it.
To move a LEN(5 2) field to a character field you would specify:
DCL &CHARX *CHAR LEN(15)
DCL &DEC *DEC LEN(5 2)
.
.
MOVTOCHR TOCHAR(&CHARX) DECPOS(2) FROMDEC2(&DEC)
If &DEC has a value of 123.45, the &CHARX field will contain
000000000012345. You may have to substring the value out to work
with it.
MOVTODEC Command parameters *CMD
---------------------------
TODEC The decimal variable to be moved to. It must be
declared as *DEC LEN(15 5).
FROMCHAR The character field which contains the value to
move. The variable must be declared as *CHAR and
can be any length up to 15. The value is always
moved from the right. Blanks are bypassed. You
must provide for the 5 digits to the right of the
decimal point.
MOVTOCHR Command parameters *CMD
---------------------------
TOCHAR The character variable to be moved to. It must be
declared as *CHAR LEN(15). The value will be right
adjusted. If the value is negative, the low order
position will have a D zone. You may have to
substring the result to work with the value.
DECPOS The number of decimal positions in the FROM field.
An entry of *1, *2 ... *6 must be specified. The
appropriate FROMDECn field must be used.
FROMDEC1 A from decimal field that has 1 decimal position.
The number of digits in the total length may be any
number from 1 to 15.
FROMDEC2 A from decimal field that has 2 decimal positions.
The number of digits in the total length may be any
number from 2 to 15.
FROMDEC3 A from decimal field that has 3 decimal positions.
The number of digits in the total length may be any
number from 3 to 15.
FROMDEC4 A from decimal field that has 4 decimal positions.
The number of digits in the total length may be any
number from 4 to 15.
FROMDEC5 A from decimal field that has 5 decimal positions.
The number of digits in the total length may be any
number from 5 to 15.
FROMDEC6 A from decimal field that has 6 decimal positions.
The number of digits in the total length may be any
number from 6 to 15.
Restrictions
------------
None.
Prerequisites
-------------
None.
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
MOVTODEC *CMD TAACLPQ QATTCMD
MOVTOCHR *CMD TAACLPQ2 QATTCMD
TAACLPQR *PGM RPG TAACLPQR QATTRPG
TAACLPQR2 *PGM RPG TAACLPQR2 QATTRPG
Note that the RPG programs are the command processing programs.
There are no CL programs.
Structure
---------
MOVTODEC Cmd
TAACLPQR RPG
MOVTOCHR Cmd
TAACLPQR2 RPG
|
Added to TAA Productivity tools April 1, 1995