Skip to main content Skip to complementary content

Field moves

 In field moves, the contents of the fields are moved without conversion. 

Take the following example for instance:

In AS/400 IBMi, when you move a PACKED numeric field to an alpha field, there is no conversion into extended numeric field. For this, you must first transfer the PACKED numeric field to an extended numeric field (ZONED) using the Z-ADD instruction.

 

In Oracle, SQL Server and ODBC, when you move a numeric field to an alpha field, there is no conversion into extended numeric. For this, you must use the STR instruction.

 

MOVER – Move bytes from right to left (only AS/400 IBMi)

This copies the contents of a field/constant to another field, from right to left. 

You can use sub-strings for both the source and destination fields. 

No conversion is made while copying.

MOVER bField1/Constant TO b.Field2  

 

It performs a byte-by-byte transfer of the contents of field1 to field2, from right to left, until field2 is full.

If field2 is shorter than field1, the transfer is limited to the length of field2. 

DCL W.field_1 CHAR 9
DCL W.field_2 CHAR 6
 
  W.field_1 =  ’ABCDEFGHI’
  W.field_2  = ’123456’
  MOVER W.field_1 TO W.field_2 
  TRACE W.field_2  

‘DEFGHI’ trace

 

If field2 is longer than field1, the transfer impacts only that part of field2 that is equal in length to field1.

DCL W.field_1 CHAR 6
DCL W.field_2 CHAR 9
 
  W.field_1 = ’ABCDEF’
  W.field_2 = ’123456789’
  MOVER W.field_1 TO W.field_2 
  TRACE W.field_2 

 

‘123ABCDEF’ trace

Using the field extract concept, you can assign only a part of the target field.

DCL W.field_1 CHAR 6
DCL W.field_2 CHAR 9
 
  W.field_1 = ’ABCDEF’
  W.field_2 = ’123456789’
  MOVER W.field_1(3:2) TO W.field_2(5:3) 
  TRACE W.field_2 

‘12345CD89’ trace

 

MOVEA – Move bytes left and complete

 

This copies the contents of a field/constant to another field and completes it by repeating a specified character. You can use sub-strings for both the source and destination fields. No conversion is made while copying.

 

MOVEA b.Field1/Constant TO b.FieldR COMPLETEDBY b.Field2/Constant

 

This instruction is useful only if field2 is longer than field1.

It performs a byte-by-byte transfer of the contents of field1 to field2, from left to right, up to the length of field1, and then completes field2 with the first character in field3.

If field2 is shorter than field1, the transfer is limited to the length of field2. 

 

DCL W.field_1 CHAR 9
DCL W.field_2 CHAR 6
 
  W.field_1 = ’ABCDEFGHI’
  W.field_2 = ’123456’
  MOVEA W.field_1 TO W.field_2 COMPLETEDBY ‘.’
  TRACE W.field_2 

‘ABCDEF’ trace

 

If field2 is longer than field1, the transfer impacts only that part of field2 that is equal in length to field1, then the remaining part of field2 receives the first character in field3 repeated to complete the remaining length.

 

DCL W.field_1 CHAR 6
DCL W.field_2 CHAR 9
 
  W.field_1 = ’ABCDEF’
  W.field_2 = ’123456789’
  MOVEA W.field_1 TO W.field_2 COMPLETEDBY ‘.’
  TRACE W.field_2 

‘ABCDEF...’ trace

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!