pjs.move()
The pjs.move() API allows you to move values from one field to another, left or right adjusted, without any type checking. By default, the value is right adjusted in the target field.
Parameters
Source - where you are taking data from
Target - where you are moving data into
Source Date/Time/Timestamp format (optional)
Pad (optional) - if passed in as true, the Target field is first cleared.
Adjust left (optional) - pass a value of true to left adjust; otherwise, the value is right adjusted.
Examples
Example 1: char -> char
pjs.define("source", { type: 'char', length: 5, initValue: 'bbbbb' });
pjs.define("unpadded", { type: 'char', length: 10, initValue: 'aaaaaaaaaa' });
pjs.move(source, unpadded);
return unpadded;
// "aaaaabbbbb"
Example 2: char -> char (padding)
pjs.define("source", { type: 'char', length: 5, initValue: 'bbbbb' });
pjs.define("padded", { type: 'char', length: 10, initValue: 'aaaaaaaaaa' });
pjs.move(source, padded, '', true);
return padded;
// " bbbbb"
Example 3: packed(5:2) -> char
pjs.define("char1", { type: 'char', length: 10, initValue: 'abcdefgh' });
pjs.define("pkd1", { type: 'packed decimal', length: 5, decimals: 2, initValue: 123.45 });
pjs.move(pkd1, char1);
return char1;
// "abcde12345"
Example 4: date(*YMD) -> integer (as *USA)
pjs.define("int1", { type: 'integer' });
pjs.define("ResYMD", { type: 'date', dateFormat: '*ymd', initValue: pjs.date('2014-01-28') });
pjs.move(ResYMD, int1, '*usa');
return int1;
// 1282014
Example 5: const -> boolean
pjs.define("ind1", { type: 'boolean', initValue: false });
pjs.move(true, ind1);
return ind1;
// true
Example 6: date -> zoned (*ISO, *USA, *EUR, *JIS)
pjs.define("zoned1", { type: 'decimal', length: 10, decimals: 0 });
pjs.define("zoned2", { type: 'decimal', length: 10, decimals: 0 });
pjs.define("zoned3", { type: 'decimal', length: 8, decimals: 0 });
pjs.define("zoned4", { type: 'decimal', length: 8, decimals: 0 });
pjs.define("Date1", { type: 'date', initValue: pjs.date('2016-01-16') });
pjs.define("Date2", { type: 'date', initValue: pjs.date('2016-01-16') });
pjs.define("Date3", { type: 'date', initValue: pjs.date('2016-01-16') });
pjs.define("Date4", { type: 'date', initValue: pjs.date('2016-01-16') });
pjs.move(Date1, zoned1, '*iso');
pjs.move(Date2, zoned2, '*usa');
pjs.move(Date3, zoned3, '*eur');
pjs.move(Date4, zoned4, '*jis');
// zoned1 = 20160116 (*ISO)
// zoned2 = 1162016 (*USA)
// zoned3 = 16012016 (*EUR)
// zoned4 = 20160116 (*JIS)
RPG Equivalent
MOVE
, multiple selections available, Use left or right arrow keys to navigate selected items