In COBOL an alternative solution is available for reference modification. In reference modification, you need to give position and length to get required length. I found one disadvantage with this usage.
The disadvantage is other programmers does not know which field value you are moving. Since from main string you are moving part of its value.
MOVE MY_FIELD(2:1) TO NEW_FIELD.
You are moving part of input string value into output field. So you may not known which value you are moving. Program maintenance point of view this way of coding is not good practice.
Let us assume,
The break-up of MY_FIELD is as follows.
In the above move, you are moving ‘B’ value. With 88 level only you will know the field name, but with reference modification it is hard to know.
Use redefines in your Copy book and 88 Level fields that you want to use in your program. Define these in your COBOL copy book.
05 ORG_FIELD X(20).
05 MY_FIELD REDEFINES ORG_FIELD.
88 A X(01).
88 B X(01).
88 C X(18).
Then, directly you can use those fields in your program. This question was asked in COBOL screening test. So I am sharing with you.
MOVE B TO NEW_FIELD.