Previous Topic: ParametersNext Topic: NEWFILE


Examples

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

This example syntax moves the entire record to the output buffer and overwrites the two bytes of data starting at position 5 of the OUTFILE with the INFILE's positions 7 and 8. It writes this new record to the file referenced by ddname NEWMSTR.

COPY,
  MOVE(CLEAR),
  MOVE(1,0,1)
  MOVE(5,2,7),
  WRITE(NEWMSTR)

Example 3

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 4

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 5

For a 125-byte output record length, this example repeats the to-data literal, a space, 50 times starting at position 75 of the output record, after initializing the output record with the first 74 bytes of the input record. It writes that new record to the ddname LONGREC.

READ,
  MOVE(CLEAR),
  MOVE(1,74,1),
  MOVE(75,0,X'40'),
  WRITE(LONGREC)

Example 6

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)