OUTREC Data Conversion


The OUTREC statement can be used to convert data from one format to another, such as from Zoned Decimal (ZD) to Packed Decimal (PD), Binary (BI), or character formats. Data conversion is useful when reformatting records for different applications that require specific formats.

Syntax -

//SYSIN DD *
  OUTREC FIELDS=(starting_pos_of_field1,
	    field1_length,
		field1_data_type,
		TO=field1_target_format,
		LENGTH=n,…)
/*
starting_pos_of_field1Specifies the starting byte of the numeric field in the record.
field1_lengthSpecifies the length of the numeric field.
field1_data_typeSpecifies the data type of the field before or after conversion (e.g., FS, ZD, PD, BI).
TO=field1_target_formatSpecifies the field1 target format
LENGTH=nSpecifies the length field1

Examples -


Scenario1 - Convert Zoned Decimal (ZD) to Packed Decimal (PD).

//SYSIN   DD  *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,10,11,5,ZD,TO=PD)
/*

Converts the 5-byte zoned decimal field starting at position 11 to a packed decimal format in the output record.

Scenario2 - Convert Packed Decimal (PD) to Zoned Decimal (ZD).

//SYSIN   DD  *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,10,15,6,PD,TO=ZD)
/*

Converts the 6-byte packed decimal field starting at position 15 to zoned decimal format.

Scenario3 - Convert Binary (BI) to Zoned Decimal (ZD).

//SYSIN   DD  *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,10,20,4,BI,TO=ZD,LENGTH=7)
/*

Converts the 4-byte binary field starting at position 20 to a 7-digit zoned decimal field.