Hi,
I had a requirement of moving a value from the input file to a amount field. Pleas help me out on this.
ex., Input value:
112345678911 - input value
I want to move this i/p value to a amount field of 9(9)v99, since the value from input file is a amount value. When i try to move this value to a variable of 9(9)v99, Last two digit is truncated and getting as 234567891100 as the output. Please help me out on this.
Thanks,
bala.M

COMPUTE 9(09)V99 = 9(11) / 100 takes an 11-byte field and divides it by 100 giving 9 digits before the decimal point and 2 digits after the decimal point. The REDEFINES allows you to exactly the same thing in a different way. Your original problem statement is to take an 11-byte number and change it to 9(9)V99 without losing the decimal digits.

Perhaps before you criticize a solution you haven't tested yet, you should either try it or figure out what it does first.

Because COBOL aligns to the decimal point. PIC 9(11) is implied PIC 9(11)V so the decimal points are aligned and digits before the decimal are moved, truncating the first two digits. The digits after the decimal point are filled with zero since they don't exist on the sending field.

In addition to the Robert post, numeric variable has Right to left movement.
Therefore, PIC 9(11) will try to move 11 bytes in 9 bytes of output field.
First 2 bytes of input field will truncate.
'V' in PIC clause implies the inclusive of decimal point.
To see the decimal point in output you need to use Editing picture clause.

In case you are not aware of it, the generated MVC instruction is not a right-to-left instruction. It is a left-to-right instruction. The variables are aligned on the decimal place for the MOVE and COBOL only moves as much data as will fit in the receiving variable. There is no right-to-left movement of data.

Sorry, all you've shown is lack of understanding of how COBOL works. If you use the LIST compile option and review the generated code for each of your MOVE statements you will find that Assembler MVC instructions are used. MVC is a left to right instruction. You will see that the generated MVC instructions use different starting position because COBOL aligns to the decimal and generates the MVC based on how many bytes to move; it does not start at the decimal point and move bytes right to left.

Definitely I am unaware of the assembler instructions that how exactly it works.
My post was on the output basis.

Request you to share some more points on this MVC instructions i.e.
1) On what basis cobol decides that from where it needs to truncate the data i.e. either from Right or Left?
2) As we can see in output if the input is more than the output in numeric field then data gets truncated from left. Similarly in case of decimal part data gets truncated from Right.

1) COBOL aligns to the decimal -- wherever the V (or .) is (and there is always a V since it is implied after the rightmost digit if not otherwise specified). Once that is done, COBOL will truncate or pad with zeros left or right depending on the picture clauses of the sending and receiving fields. Truncation or padding will not occur if the field components are the same size (number of digits).
2) There are four possibilities:
- If the sending field integer part (before the V) is larger than the receiving field integer part, the extra digits are truncated off the left.
- If the sending field integer part is smaller than the receiving field integer part, there are zeroes padded on the front of the receiving field
- If the sending field decimal part (after the V) is larger than the receiving field decimal part, the extra digits are truncated off the right
- If the sending field decimal part is smaller than the receiving field decimal part, there are zeros padded on the end of the receiving field.

Be aware the rules are slightly different for numeric edited fields (which has PIC clauses including -, +, Z, etc).

In addition to the Robert post, numeric variable has Right to left movement.
Therefore, PIC 9(11) will try to move 11 bytes in 9 bytes of output field.
First 2 bytes of input field will truncate.
'V' in PIC clause implies the inclusive of decimal point.
To see the decimal point in output you need to use Editing picture clause.

Numeric field has Right to left movement whereas decimal part of numeric field has Left to Right movement.

Where did you learn this? If it came from some book or some teacher, suggest you no longer use them as a technical reference. . .