Previous Topic: SyntaxNext Topic: NEWFILE


Parameters

MOVE supports the following parameters:

to-field-name

Use to-field-name when referencing a data field that is defined in the record's layout. The layout must be available to the job step. For more information on how to make the record's layout available, see the keyword LAYOUTFILE.

Note: When this parameter is supplied, the keyword's position is retrieved from the to-field-name definition, and is used to validate the to-data format.

to‑position

Specifies the position to store data. Valid choices are as follows:

1 - 32760

The actual position number

+nnn or –nnn

The relative position to the record's current location

to-data

Specify one of the following:

C'c…'

Character—matches specified case

N'n…'

Numeric—processes the literal as defined by the field-name parameter. The field-name parameter must be defined as a numeric field, and it is only valid when a field-name parameter is supplied.

P'n…'

Packed

T'c…'

Text—upper case letters are substituted for their lower case counterparts. Alphanumeric data is permitted.

X'hh…'

Hexadecimal

length

Specifies the amount of data to move. A value of 0 indicates that the data to move begins at the from-position and goes to the length of the input record. Valid values are 0 - 32760.

from-field-name

Use from-field-name when referencing a data field that is defined in the record's layout. The record's layout must be available to the job step. For more information on how to make the record's layout available, see the keyword LAYOUTFILE.

Note: When this parameter is supplied, the keyword's from-position and length are both retrieved from the from-field-name definition.

from‑position

Starting position in the record. This value cannot reference data that is greater than the record's length. Valid choices are as follows:

1 - 32760

The actual position number

+nnn or –nnn

The relative position to the record's current location

CLEAR

This parameter value initializes the move buffer to the current PADCHAR value and resets the move buffer length for variable output records to 0.

0

Repeat the to data literal, starting at the to-position, for the length of the output record. For variable record output files, this length is the input record's length.

Example 1

This example syntax moves the character string 'CT' to position 5 of the output buffer, and writes the output buffer.

READ,
  MOVE(CLEAR),
  MOVE(5,C'CT'),
  WRITE(CTFILE)

You can obtain the same results using the to-field-name parameter along with the LAYOUTFILE keyword, which would reference the layout member that maps the input file's data.

READ,
  LAYOUTFILE(LAYOUT),
  MOVE(CLEAR),
  MOVE(STATE-CODE,C'CT'),
  WRITE(CTFILE)

Example 2

Input record positions 1-10 are moved to output record positions 1-10. Input record positions 21 – 30 are moved to output record positions 11-20, and input record positions 11-20 are moved to output record position 21-30. The WRITE command resets the relational position back to 1.

READ,
  MOVE(CLEAR),
  MOVE(+0,10,1),
  MOVE(+0,10,21),
  MOVE(+0,10,11),
  WRITE(OUTPUT)

Example 3

This next example moves the entire record to the move buffer. It examines the STATE-CODE field. If it is equal to KS, it appends 6.0 to the end of the record, whatever that position is. If it finds MO, it appends 6.5 to the end of the record. Once the characters are appended, the records are written to the appropriate file and processing continues with the next record.

READ,
  LAYOUTFILE(LAYOUT),
  MOVE(CLEAR),
  MOVE(1,0,1),  
  IF(STATE-CODE,EQ,C'KS'),
	MOVE(+0,C'6.0'),
	WRITE(KSFILE),
	NEXTREC,
  IF(STATE-CODE,EQ,C'MO'),
	MOVE(+0,C'6.5'),
	WRITE(MOFILE)

Example 4

The following example shows how you can easily move one field to another field's location in the output file NEWFILE. The length of the MOVE is decided on by the physical length of the from-field-name's defined physical length, in this case the CC-ADDRESS and CC-NAME fields. Both fields must be defined in the same layout file.

READ,
  LAYOUTFILE(LAYOUT),
  MOVE(CLEAR),
  MOVE(SHIPPING-ADDRESS,CC-ADDRESS),
  MOVE(SHIPPING-NAME,CC-NAME),
  WRITE(NEWFILE)