Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The dec API converts a value to a packed decimal number.

Parameters
  1. Value / field
  2. Total length (optional)
  3. Decimal places - does not add to the total length (optional)
  4. Half-adjust - if true, the number will be half-adjusted (optional)
Example
Example 1: char -> packed decimal
Code Block
languagejavascript
pjs.define("p1", { type: 'packed decimal', length: 5, decimals: 2 });

p1 = pjs.dec('123.45', 5, 2);
 
return p1;
//123.45
Example 2: date -> packed decimal
Code Block
languagejavascript
pjs.define("d1", { type: 'date', dateFormat: '*eur', initValue: pjs.date('2016-06-15') });
pjs.define("p1", { type: 'packed decimal', length: 10, decimals: 0 });

p1 = pjs.dec(d1);
 
return p1;
//15062016