REFERENCE MODIFICATION:

Using reference modification, the programmer can get a sub string of character data. The parameters given point the starting position of the sub string and the length of the sub string.

The format is:

Dataname/identifier(start position:length)

Assume that there is a field called CITY that contains PROVIDENCE.

MOVE CITY(1:4) would move PROV

MOVE CITY(3:7) would move OVIDENC

You can actually leave out the length - still need the colon. Without the length, COBOL will move from the starting position to the rightmost character.

MOVE CITY(4:) would move VIDENCE

Obviously you are not going to use actual numers in most cases. You will use data names.

START-POS contains the character position of the first character you need to move - lets say it contains a 2

NUM-TO-MOVE contains the number of characters you need to move - lets say it contains a 5

MOVE CITY(START-POS:NUM-TO-MOVE) would ROVID

You can also move something into a field using reference modification.

MOVE "XX" TO CITY(4:2). This will result PROXXDENCE.