All files / output cl_message_helper.clas.mjs

45.35% Statements 83/183
95% Branches 19/20
8.33% Functions 3/36
45.35% Lines 83/183

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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 1831x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x           1x 1x 1x 1x 1x 1x               1x       1x     1x               1x     1x           1x     1x             1x     1x             1x     1x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 64x 54x 54x 64x 64x 64x 64x 64x 54x 64x 1x     1x                                         1x     1x 107x 107x 107x 107x 107x 107x 107x 78x 107x 29x 29x 107x 107x 102x 107x 5x 5x 107x 107x 107x 107x     107x 107x 1x     1x                                               1x 1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_message_helper.clas.abap
class cl_message_helper {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_MESSAGE_HELPER';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"GC_FALLBACK": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"SET_MSG_VARS_FOR_IF_MSG": {"visibility": "U", "parameters": {"TEXT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_MESSAGE", RTTIName: "\\INTERFACE=IF_MESSAGE"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "STRING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "E", "type_name": "StringType"}}},
  "SET_MSG_VARS_FOR_CLIKE": {"visibility": "U", "parameters": {"TEXT": {"type": () => {return new abap.types.Character();}, "is_optional": " ", "parm_kind": "I", "type_name": "CLikeType"}}},
  "GET_TEXT_FOR_MESSAGE": {"visibility": "U", "parameters": {"RESULT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "R", "type_name": "StringType"}, "TEXT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_MESSAGE", RTTIName: "\\INTERFACE=IF_MESSAGE"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}}},
  "CHECK_MSG_KIND": {"visibility": "U", "parameters": {"MSG": {"type": () => {return new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});}, "is_optional": " ", "parm_kind": "I", "type_name": "GenericObjectReferenceType"}, "T100KEY": {"type": () => {return new abap.types.Structure({
  "msgid": new abap.types.Character(20, {"qualifiedName":"SYMSGID","ddicName":"SYMSGID","description":"SYMSGID"}),
  "msgno": new abap.types.Numc({length: 3, qualifiedName: "SYMSGNO"}),
  "attr1": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
  "attr2": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
  "attr3": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
  "attr4": new abap.types.String({qualifiedName: "SCX_ATTRNAME"})}, "SCX_T100KEY", "SCX_T100KEY", {}, {});}, "is_optional": " ", "parm_kind": "E", "type_name": "StructureType"}, "TEXTID": {"type": () => {return new abap.types.Character(32, {"qualifiedName":"SOTR_CONC","ddicName":"SOTR_CONC","description":"SOTR_CONC"});}, "is_optional": " ", "parm_kind": "E", "type_name": "CharacterType"}}},
  "GET_OTR_TEXT_RAW": {"visibility": "U", "parameters": {"TEXTID": {"type": () => {return new abap.types.Character(32, {"qualifiedName":"SOTR_CONC","ddicName":"SOTR_CONC","description":"SOTR_CONC"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}, "RESULT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "E", "type_name": "StringType"}}},
  "REPLACE_TEXT_PARAMS": {"visibility": "U", "parameters": {"OBJ": {"type": () => {return new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});}, "is_optional": " ", "parm_kind": "I", "type_name": "GenericObjectReferenceType"}, "RESULT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "C", "type_name": "StringType"}}},
  "GET_TEXT_PARAMS": {"visibility": "U", "parameters": {"OBJ": {"type": () => {return new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined});}, "is_optional": " ", "parm_kind": "I", "type_name": "GenericObjectReferenceType"}, "PARAMS": {"type": () => {return new abap.types.Character(4);}, "is_optional": " ", "parm_kind": "E", "type_name": "AnyType"}}},
  "GET_LATEST_T100_EXCEPTION": {"visibility": "U", "parameters": {"RESULT": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "IF_T100_MESSAGE", RTTIName: "\\INTERFACE=IF_T100_MESSAGE"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}, "EXCEPTION": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CX_ROOT", RTTIName: "\\CLASS=CX_ROOT"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.gc_fallback = cl_message_helper.gc_fallback;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async get_latest_t100_exception(INPUT) {
    return cl_message_helper.get_latest_t100_exception(INPUT);
  }
  static async get_latest_t100_exception(INPUT) {
    let result = new abap.types.ABAPObject({qualifiedName: "IF_T100_MESSAGE", RTTIName: "\\INTERFACE=IF_T100_MESSAGE"});
    let exception = INPUT?.exception;
    if (exception?.getQualifiedName === undefined || exception.getQualifiedName() !== "CX_ROOT") { exception = undefined; }
    if (exception === undefined) { exception = new abap.types.ABAPObject({qualifiedName: "CX_ROOT", RTTIName: "\\CLASS=CX_ROOT"}).set(INPUT.exception); }
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    return result;
  }
  async get_text_params(INPUT) {
    return cl_message_helper.get_text_params(INPUT);
  }
  static async get_text_params(INPUT) {
    let obj = INPUT?.obj;
    if (obj === undefined) { obj = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined}).set(INPUT.obj); }
    let params = INPUT?.params || new abap.types.Character(4);
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
  }
  async get_otr_text_raw(INPUT) {
    return cl_message_helper.get_otr_text_raw(INPUT);
  }
  static async get_otr_text_raw(INPUT) {
    let textid = INPUT?.textid;
    if (textid?.getQualifiedName === undefined || textid.getQualifiedName() !== "SOTR_CONC") { textid = undefined; }
    if (textid === undefined) { textid = new abap.types.Character(32, {"qualifiedName":"SOTR_CONC","ddicName":"SOTR_CONC","description":"SOTR_CONC"}).set(INPUT.textid); }
    let result = INPUT?.result || new abap.types.String({qualifiedName: "STRING"});
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
  }
  async replace_text_params(INPUT) {
    return cl_message_helper.replace_text_params(INPUT);
  }
  static async replace_text_params(INPUT) {
    let obj = INPUT?.obj;
    if (obj === undefined) { obj = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined}).set(INPUT.obj); }
    let result = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.result) {result = INPUT.result;}
    abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
  }
  async get_text_for_message(INPUT) {
    return cl_message_helper.get_text_for_message(INPUT);
  }
  static async get_text_for_message(INPUT) {
    let result = new abap.types.String({qualifiedName: "STRING"});
    let text = INPUT?.text;
    if (text?.getQualifiedName === undefined || text.getQualifiedName() !== "IF_MESSAGE") { text = undefined; }
    if (text === undefined) { text = new abap.types.ABAPObject({qualifiedName: "IF_MESSAGE", RTTIName: "\\INTERFACE=IF_MESSAGE"}).set(INPUT.text); }
    let lv_msgid = new abap.types.Character(20, {"qualifiedName":"sy-msgid"});
    let lv_msgno = new abap.types.Numc({length: 3, qualifiedName: "sy-msgno"});
    let lv_msgv1 = new abap.types.Character(50, {"qualifiedName":"sy-msgv1"});
    let lv_msgv2 = new abap.types.Character(50, {"qualifiedName":"sy-msgv2"});
    let lv_msgv3 = new abap.types.Character(50, {"qualifiedName":"sy-msgv3"});
    let lv_msgv4 = new abap.types.Character(50, {"qualifiedName":"sy-msgv4"});
    if (text.get()?.if_t100_message$t100key === undefined) { result.set(this.gc_fallback); return result; };
    lv_msgid.set(text.get().if_t100_message$t100key.get().msgid);
    lv_msgno.set(text.get().if_t100_message$t100key.get().msgno);
    lv_msgv1.set(text.get()[text.get().if_t100_message$t100key.get().attr1.get().toLowerCase().replace("~", "$").trimEnd()] ? text.get()[text.get().if_t100_message$t100key.get().attr1.get().toLowerCase().replace("~", "$").trimEnd()].get() : "");
    lv_msgv2.set(text.get()[text.get().if_t100_message$t100key.get().attr2.get().toLowerCase().replace("~", "$").trimEnd()] ? text.get()[text.get().if_t100_message$t100key.get().attr2.get().toLowerCase().replace("~", "$").trimEnd()].get() : "");
    lv_msgv3.set(text.get()[text.get().if_t100_message$t100key.get().attr3.get().toLowerCase().replace("~", "$").trimEnd()] ? text.get()[text.get().if_t100_message$t100key.get().attr3.get().toLowerCase().replace("~", "$").trimEnd()].get() : "");
    lv_msgv4.set(text.get()[text.get().if_t100_message$t100key.get().attr4.get().toLowerCase().replace("~", "$").trimEnd()] ? text.get()[text.get().if_t100_message$t100key.get().attr4.get().toLowerCase().replace("~", "$").trimEnd()].get() : "");
    await abap.statements.message({into: result, id: lv_msgid, type: abap.CharacterFactory.get(1, 'I'), number: lv_msgno, with: [lv_msgv1,lv_msgv2,lv_msgv3,lv_msgv4]});
    return result;
  }
  async set_msg_vars_for_if_msg(INPUT) {
    return cl_message_helper.set_msg_vars_for_if_msg(INPUT);
  }
  static async set_msg_vars_for_if_msg(INPUT) {
    let text = INPUT?.text;
    if (text?.getQualifiedName === undefined || text.getQualifiedName() !== "IF_MESSAGE") { text = undefined; }
    if (text === undefined) { text = new abap.types.ABAPObject({qualifiedName: "IF_MESSAGE", RTTIName: "\\INTERFACE=IF_MESSAGE"}).set(INPUT.text); }
    let string = INPUT?.string || new abap.types.String({qualifiedName: "STRING"});
    if (abap.compare.initial(text)) {
      const unique1461 = await (new abap.Classes['CX_SY_MESSAGE_ILLEGAL_TEXT']()).constructor_();
      unique1461.EXTRA_CX = {"INTERNAL_FILENAME": "cl_message_helper.clas.abap","INTERNAL_LINE": 95};
      throw unique1461;
    }
    string.set((await this.get_text_for_message({text: text})));
    if (abap.compare.ne(string, cl_message_helper.gc_fallback)) {
      abap.builtin.sy.get().msgty.clear();
      return;
    }
    string.set((await text.get().if_message$get_text()));
    if (abap.compare.initial(string)) {
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
    await this.set_msg_vars_for_clike({text: string});
  }
  async set_msg_vars_for_clike(INPUT) {
    return cl_message_helper.set_msg_vars_for_clike(INPUT);
  }
  static async set_msg_vars_for_clike(INPUT) {
    let text = INPUT?.text;
    let lv_char200 = new abap.types.Character(200, {});
    lv_char200.set(text);
    abap.builtin.sy.get().msgid.set(abap.CharacterFactory.get(2, '00'));
    abap.builtin.sy.get().msgno.set(abap.CharacterFactory.get(3, '001'));
    abap.builtin.sy.get().msgv1.set(lv_char200);
    if (abap.compare.eq(lv_char200.getOffset({offset: 49, length: 1}), abap.builtin.space)) {
      lv_char200.set(lv_char200.getOffset({offset: 49}));
    } else {
      lv_char200.set(text.getOffset({offset: 50}));
    }
    abap.builtin.sy.get().msgv2.set(lv_char200);
    if (abap.compare.eq(lv_char200.getOffset({offset: 49, length: 1}), abap.builtin.space)) {
      lv_char200.set(lv_char200.getOffset({offset: 49}));
    } else {
      lv_char200.set(lv_char200.getOffset({offset: 50}));
    }
    abap.builtin.sy.get().msgv3.set(lv_char200);
    if (abap.compare.eq(lv_char200.getOffset({offset: 49, length: 1}), abap.builtin.space)) {
      lv_char200.set(lv_char200.getOffset({offset: 49}));
    } else {
      lv_char200.set(lv_char200.getOffset({offset: 50}));
    }
    abap.builtin.sy.get().msgv4.set(lv_char200);
  }
  async check_msg_kind(INPUT) {
    return cl_message_helper.check_msg_kind(INPUT);
  }
  static async check_msg_kind(INPUT) {
    let msg = INPUT?.msg;
    if (msg === undefined) { msg = new abap.types.ABAPObject({qualifiedName: undefined, RTTIName: undefined}).set(INPUT.msg); }
    let t100key = INPUT?.t100key || new abap.types.Structure({
    "msgid": new abap.types.Character(20, {"qualifiedName":"SYMSGID","ddicName":"SYMSGID","description":"SYMSGID"}),
    "msgno": new abap.types.Numc({length: 3, qualifiedName: "SYMSGNO"}),
    "attr1": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
    "attr2": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
    "attr3": new abap.types.String({qualifiedName: "SCX_ATTRNAME"}),
    "attr4": new abap.types.String({qualifiedName: "SCX_ATTRNAME"})}, "SCX_T100KEY", "SCX_T100KEY", {}, {});
    let textid = INPUT?.textid || new abap.types.Character(32, {"qualifiedName":"SOTR_CONC","ddicName":"SOTR_CONC","description":"SOTR_CONC"});
    let li_t100_message = new abap.types.ABAPObject({qualifiedName: "IF_T100_MESSAGE", RTTIName: "\\INTERFACE=IF_T100_MESSAGE"});
    try {
      await abap.statements.cast(li_t100_message, msg);
      t100key.set(li_t100_message.get().if_t100_message$t100key);
    } catch (e) {
      if ((abap.Classes['CX_SY_MOVE_CAST_ERROR'] && e instanceof abap.Classes['CX_SY_MOVE_CAST_ERROR'])) {
        console.dir(msg);
        abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
      } else {
        throw e;
      }
    }
  }
}
abap.Classes['CL_MESSAGE_HELPER'] = cl_message_helper;
cl_message_helper.gc_fallback = new abap.types.String({qualifiedName: "STRING"});
cl_message_helper.gc_fallback.set('An exception was raised.');
export {cl_message_helper};