All files / output cl_abap_exceptional_values.clas.mjs

19.78% Statements 18/91
100% Branches 2/2
9.09% Functions 1/11
19.78% Lines 18/91

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 911x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x       1x     1x                                                                                     1x     1x                                     1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_abap_exceptional_values.clas.abap
class cl_abap_exceptional_values {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_ABAP_EXCEPTIONAL_VALUES';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"GET_MAX_VALUE": {"visibility": "U", "parameters": {"OUT": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " "}, "IN": {"type": () => {return new abap.types.Character(4);}, "is_optional": " "}}},
  "GET_MIN_VALUE": {"visibility": "U", "parameters": {"OUT": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " "}, "IN": {"type": () => {return new abap.types.Character(4);}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async get_max_value(INPUT) {
    return cl_abap_exceptional_values.get_max_value(INPUT);
  }
  static async get_max_value(INPUT) {
    let out = new abap.types.DataReference(new abap.types.Character(4));
    let $in = INPUT?.in;
    let lv_type = new abap.types.Character(1, {});
    let lv_length = new abap.types.Integer({qualifiedName: "I"});
    let lv_decimals = new abap.types.Integer({qualifiedName: "I"});
    let lv_digits_before_decimal = new abap.types.Integer({qualifiedName: "I"});
    let lv_integer_part = new abap.types.String({qualifiedName: "STRING"});
    let lv_decimal_part = new abap.types.String({qualifiedName: "STRING"});
    let fs_out_ = new abap.types.FieldSymbol(new abap.types.Character(4));
    abap.statements.describe({field: $in, type: lv_type});
    let unique1104 = lv_type;
    if (abap.compare.eq(unique1104, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_int)) {
      out.assign(abap.Classes['CL_ABAP_MATH'].max_int4);
    } else if (abap.compare.eq(unique1104, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_packed)) {
      abap.statements.describe({field: $in, length: lv_length, decimals: lv_decimals, mode: 'BYTE'});
      abap.statements.createData(out,{"typeName": "P","length": lv_length,"decimals": lv_decimals});
      abap.statements.assign({target: fs_out_, source: out.dereference()});
      lv_digits_before_decimal.set(abap.operators.minus(abap.operators.minus(abap.operators.multiply(lv_length,abap.IntegerFactory.get(2)),abap.IntegerFactory.get(1)),lv_decimals));
      const indexBackup1 = abap.builtin.sy.get().index.get();
      const unique1105 = lv_digits_before_decimal.get();
      for (let unique1106 = 0; unique1106 < unique1105; unique1106++) {
        abap.builtin.sy.get().index.set(unique1106 + 1);
        lv_integer_part.set(abap.operators.concat(lv_integer_part,abap.CharacterFactory.get(1, '9')));
      }
      abap.builtin.sy.get().index.set(indexBackup1);
      if (abap.compare.gt(lv_decimals, abap.IntegerFactory.get(0))) {
        lv_decimal_part.set(abap.CharacterFactory.get(1, '.'));
        const indexBackup2 = abap.builtin.sy.get().index.get();
        const unique1107 = lv_decimals.get();
        for (let unique1108 = 0; unique1108 < unique1107; unique1108++) {
          abap.builtin.sy.get().index.set(unique1108 + 1);
          lv_decimal_part.set(abap.operators.concat(lv_decimal_part,abap.CharacterFactory.get(1, '9')));
        }
        abap.builtin.sy.get().index.set(indexBackup2);
      }
      fs_out_.set(abap.operators.concat(lv_integer_part,lv_decimal_part));
    } else {
      console.dir(INPUT);
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
    return out;
  }
  async get_min_value(INPUT) {
    return cl_abap_exceptional_values.get_min_value(INPUT);
  }
  static async get_min_value(INPUT) {
    let out = new abap.types.DataReference(new abap.types.Character(4));
    let $in = INPUT?.in;
    let lv_type = new abap.types.Character(1, {});
    let fs_out_ = new abap.types.FieldSymbol(new abap.types.Character(4));
    abap.statements.describe({field: $in, type: lv_type});
    let unique1109 = lv_type;
    if (abap.compare.eq(unique1109, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_int)) {
      out.assign(abap.Classes['CL_ABAP_MATH'].min_int4);
    } else if (abap.compare.eq(unique1109, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_packed)) {
      out.set((await this.get_max_value({in: $in})));
      abap.statements.assign({target: fs_out_, source: out.dereference()});
      fs_out_.set(abap.operators.multiply(fs_out_,abap.IntegerFactory.get(-1)));
    } else {
      console.dir(INPUT);
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
    return out;
  }
}
abap.Classes['CL_ABAP_EXCEPTIONAL_VALUES'] = cl_abap_exceptional_values;
export {cl_abap_exceptional_values};