[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

3.6.1 Group Moves

If either the sending or receiving item is a group item, the compiler considers the move to be a group move. It treats both the sending and receiving items as if they were alphanumeric items.

If the sending item is a group item, and the receiving item is an elementary item, the compiler ignores the receiving item description except for the size description, in bytes, and any JUSTIFIED clause. It conducts no conversion or editing on the sending item's data.

3.6.2 Elementary Moves

If both items of a MOVE statement are elementary items, their PICTURE character-strings control their data movement. If the receiving item was described as numeric or numeric edited, the rules for numeric moves control the data movement (see Section 2.6). Nonnumeric receiving items are alphanumeric, alphanumeric edited, or alphabetic.

Table 3-2 shows the valid and invalid nonnumeric elementary moves.

Table 3-2 Nonnumeric Elementary Moves
  Receiving Item Category
Sending Item Category   Alphanumeric
  Alphabetic Alphanumeric Edited
ALPHABETIC Valid Valid
ALPHANUMERIC Valid Valid
ALPHANUMERIC EDITED Valid Valid
NUMERIC INTEGER
(DISPLAY ONLY)
Invalid Valid
NUMERIC EDITED Invalid Valid

In all valid moves, the compiler treats the sending item as though it had been described as PIC X(n). A JUSTIFIED clause in the sending item's description has no effect on the move. If the sending item's PICTURE character-string contains editing characters, the compiler uses them only to determine the item's size.

In valid nonnumeric elementary moves, the receiving item controls the movement of data. All of the following characteristics of the receiving item affect the move:

  • Its size
  • Editing characters in its description
  • The JUSTIFIED RIGHT clause in its description

The JUSTIFIED clause and editing characters are mutually exclusive.

When an item that contains no editing characters or JUSTIFIED clause in its description is used as the receiving item of a nonnumeric elementary MOVE statement, the compiler moves the characters starting at the leftmost position in the item and proceeding, character by character, to the rightmost position. If the sending item is shorter than the receiving item, the compiler fills the remaining character positions with spaces. If the sending item is longer than the receiving item, truncation occurs on the right.

Numeric items used in nonnumeric elementary moves must be integers in DISPLAY format.

If the description of the numeric data item indicates the presence of an operational sign (either as a character or an overpunched character), or if there are P characters in its character-string, the compiler first moves the item to a temporary location. It removes the sign and fills out any P character positions with zero digits. It then uses the temporary value as the sending item as if it had been described as PIC X(n). The temporary value can be shorter than the original value if a separate sign was removed, or longer than the original value if P character positions were filled with zeros.

If the sending item is an unsigned numeric class item with no P characters in its character-string, the MOVE is accomplished directly from the sending item, and a temporary item is not required.

If the numeric sending item is shorter than the receiving item, the compiler fills the receiving item with spaces.

3.6.2.1 Edited Moves

This section explains the following insertion editing characters:

B Blank insertion position
0 Zero insertion position
/ Slash insertion position

When an item with an insertion editing character in its PICTURE character-string is the receiving item of a nonnumeric elementary MOVE statement, each receiving character position corresponding to an editing character receives the insertion byte value. Table 3-3 illustrates the use of such symbols with the following statement, where FIELD1 is described as PIC X(7):


MOVE FIELD1 TO FIELD2

Table 3-3 Data Movement with Editing Symbols
FIELD1 FIELD2
  Character-String Contents After MOVE
070476 XX/99/XX 07/04/76
04JUL76 99BAAAB99 04sJULs76
2351212 XXXBXXXX/XX/ 235s1212/ss/
123456 0XB0XB0XB0X 01s02s03s04

Legend: s = space

Data movement always begins at the left end of the sending item and moves only to the byte positions described as A, 9, or X in the receiving item PICTURE character-string. When the sending item is exhausted, the compiler supplies space characters to fill any remaining character positions (not insertion positions) in the receiving item. If the receiving item is exhausted before the last character is moved from the sending item, the compiler ignores the remaining sending item characters.

Any necessary conversion of data from one form of internal representation to another takes place during valid elementary moves, along with any editing specified for, or de-editing implied by, the receiving data item.

3.6.2.2 Justified Moves

A JUSTIFIED RIGHT clause in the receiving item's data description causes the compiler to reverse its usual data movement conventions. It starts with the rightmost characters of both items and proceeds from right to left. If the sending item is shorter than the receiving item, the compiler fills the remaining leftmost character positions with spaces. If the sending item is longer than the receiving item, truncation occurs on the left. Table 3-4 illustrates various PICTURE character-string situations for the following statement:


MOVE FIELD1 TO FIELD2

Table 3-4 Data Movement with the JUSTIFIED Clause
FIELD1 FIELD2
PICTURE
Character-String
Contents PICTURE
Character-String
(and JUST-Clause)
Contents After
MOVE
    XX AB
    XXXXX ABCss
XXX ABC XX JUST BC
    XXXXX JUST ssABC

Legend: s = space


Previous Next Contents Index