All files / output kernel_create_data_handle.clas.mjs

61.92% Statements 148/239
51.28% Branches 20/39
25% Functions 6/24
61.92% Lines 148/239

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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 2391x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x       1x     1x 174x 174x 174x 174x 174x 174x         174x     174x 174x 116x 174x 34x 58x 24x 24x           174x 1x     1x                                                 1x     1x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 117x 117x 117x 117x 117x     117x       117x 34x 34x 1x     1x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 21x 21x   21x 21x 21x 21x 21x 21x 21x 55x 55x 55x 21x 24x 24x 1x     1x 116x 116x 116x 116x 116x 116x 116x 116x     116x 10x 10x 116x     106x 2x 2x 106x     104x     104x     104x     104x 104x 104x 104x 104x                                       116x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// kernel_create_data_handle.clas.abap
class kernel_create_data_handle {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'KERNEL_CREATE_DATA_HANDLE';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"ELEM": {"visibility": "I", "parameters": {"HANDLE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "DREF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "C", "type_name": "DataReference"}}},
  "STRUCT": {"visibility": "I", "parameters": {"HANDLE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "DREF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "C", "type_name": "DataReference"}}},
  "TABLE": {"visibility": "I", "parameters": {"HANDLE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "DREF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "C", "type_name": "DataReference"}}},
  "REF": {"visibility": "I", "parameters": {"HANDLE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "DREF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "C", "type_name": "DataReference"}}},
  "CALL": {"visibility": "U", "parameters": {"HANDLE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});}, "is_optional": " ", "parm_kind": "I", "type_name": "ObjectReferenceType"}, "DREF": {"type": () => {return new abap.types.DataReference(new abap.types.Character(4));}, "is_optional": " ", "parm_kind": "C", "type_name": "DataReference"}}}};
  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 call(INPUT) {
    return kernel_create_data_handle.call(INPUT);
  }
  static async call(INPUT) {
    let handle = INPUT?.handle;
    if (handle?.getQualifiedName === undefined || handle.getQualifiedName() !== "CL_ABAP_DATADESCR") { handle = undefined; }
    if (handle === undefined) { handle = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}).set(INPUT.handle); }
    let dref = new abap.types.DataReference(new abap.types.Character(4));
    if (INPUT && INPUT.dref) {dref = INPUT.dref;}
    if (abap.compare.initial(handle)) {
      const unique1501 = await (new abap.Classes['CX_SY_REF_IS_INITIAL']()).constructor_();
      unique1501.EXTRA_CX = {"INTERNAL_FILENAME": "kernel_create_data_handle.clas.abap","INTERNAL_LINE": 35};
      throw unique1501;
    }
    if (dref.constructor.name === "FieldSymbol") {
        dref = dref.getPointer();
    }
    let unique1502 = handle.get().kind;
    if (abap.compare.eq(unique1502, abap.Classes['CL_ABAP_TYPEDESCR'].kind_elem)) {
      await this.elem({handle: handle, dref: dref});
    } else if (abap.compare.eq(unique1502, abap.Classes['CL_ABAP_TYPEDESCR'].kind_struct)) {
      await this.struct({handle: handle, dref: dref});
    } else if (abap.compare.eq(unique1502, abap.Classes['CL_ABAP_TYPEDESCR'].kind_table)) {
      await this.table({handle: handle, dref: dref});
    } else if (abap.compare.eq(unique1502, abap.Classes['CL_ABAP_TYPEDESCR'].kind_ref)) {
      await this.ref({handle: handle, dref: dref});
    } else {
      console.dir(handle);
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
  }
  async ref(INPUT) {
    return kernel_create_data_handle.ref(INPUT);
  }
  static async ref(INPUT) {
    let handle = INPUT?.handle;
    if (handle?.getQualifiedName === undefined || handle.getQualifiedName() !== "CL_ABAP_DATADESCR") { handle = undefined; }
    if (handle === undefined) { handle = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}).set(INPUT.handle); }
    let dref = new abap.types.DataReference(new abap.types.Character(4));
    if (INPUT && INPUT.dref) {dref = INPUT.dref;}
    let lo_refdescr = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_REFDESCR", RTTIName: "\\CLASS=CL_ABAP_REFDESCR"});
    let lo_datadescr = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"});
    let lo_classdescr = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CLASSDESCR", RTTIName: "\\CLASS=CL_ABAP_CLASSDESCR"});
    let field = new abap.types.DataReference(new abap.types.Character(4));
    let lv_relative_name = new abap.types.String({qualifiedName: "STRING"});
    let lv_absolute_name = new abap.types.String({qualifiedName: "STRING"});
    await abap.statements.cast(lo_refdescr, handle);
    let unique1503 = lo_refdescr.get().type_kind;
    if (abap.compare.eq(unique1503, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_oref)) {
      await abap.statements.cast(lo_classdescr, (await lo_refdescr.get().get_referenced_type()));
      lv_relative_name.set(lo_classdescr.get().relative_name);
      lv_absolute_name.set(lo_classdescr.get().absolute_name);
      dref.assign(new abap.types.ABAPObject({"qualifiedName": lv_relative_name.get(), "RTTIName": lv_absolute_name.get()}));
    } else {
      await abap.statements.cast(lo_datadescr, (await lo_refdescr.get().get_referenced_type()));
      await this.call({handle: lo_datadescr, dref: field});
      dref.assign(new abap.types.DataReference(field.getPointer()));
    }
  }
  async struct(INPUT) {
    return kernel_create_data_handle.struct(INPUT);
  }
  static async struct(INPUT) {
    let handle = INPUT?.handle;
    if (handle?.getQualifiedName === undefined || handle.getQualifiedName() !== "CL_ABAP_DATADESCR") { handle = undefined; }
    if (handle === undefined) { handle = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}).set(INPUT.handle); }
    let dref = new abap.types.DataReference(new abap.types.Character(4));
    if (INPUT && INPUT.dref) {dref = INPUT.dref;}
    let lo_struct = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_STRUCTDESCR", RTTIName: "\\CLASS=CL_ABAP_STRUCTDESCR"});
    let lt_components = abap.types.TableFactory.construct(new abap.types.Structure({
    "name": new abap.types.String({qualifiedName: "NAME"}),
    "type": new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}),
    "as_include": new abap.types.Character(1, {"qualifiedName":"as_include","ddicName":"ABAP_BOOL"}),
    "suffix": new abap.types.String({qualifiedName: "SUFFIX"})}, "abap_componentdescr", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "abap_component_tab");
    let field = new abap.types.DataReference(new abap.types.Character(4));
    let lv_name = new abap.types.String({qualifiedName: "STRING"});
    let lv_suffix = new abap.types.String({qualifiedName: "STRING"});
    let fs_ls_component_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "name": new abap.types.String({qualifiedName: "NAME"}),
    "type": new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}),
    "as_include": new abap.types.Character(1, {"qualifiedName":"as_include","ddicName":"ABAP_BOOL"}),
    "suffix": new abap.types.String({qualifiedName: "SUFFIX"})}, "abap_componentdescr", undefined, {}, {}));
    await abap.statements.cast(lo_struct, handle);
    lt_components.set((await lo_struct.get().get_components()));
    let obj = {};
    let suffix = {};
    let asInclude = {};
    for await (const unique1504 of abap.statements.loop(lt_components)) {
      fs_ls_component_.assign(unique1504);
      await this.call({handle: (await lo_struct.get().get_component_type({p_name: fs_ls_component_.get().name})), dref: field});
      lv_name.set(abap.builtin.to_lower({val: fs_ls_component_.get().name}));
      obj[lv_name.get()] = field.getPointer();
      if (abap.compare.eq(fs_ls_component_.get().as_include, abap.builtin.abap_true)) {
        asInclude[lv_name.get()] = true;
      }
      if (abap.compare.initial(fs_ls_component_.get().suffix) === false) {
        lv_suffix.set(abap.builtin.to_lower({val: fs_ls_component_.get().suffix}));
        suffix[lv_name.get()] = lv_suffix.get();
      }
    }
    dref.assign(new abap.types.Structure(obj, lo_struct.get().internal_qualified_name.get(), lo_struct.get().internal_ddic_name.get(), suffix, asInclude));
  }
  async table(INPUT) {
    return kernel_create_data_handle.table(INPUT);
  }
  static async table(INPUT) {
    let handle = INPUT?.handle;
    if (handle?.getQualifiedName === undefined || handle.getQualifiedName() !== "CL_ABAP_DATADESCR") { handle = undefined; }
    if (handle === undefined) { handle = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}).set(INPUT.handle); }
    let dref = new abap.types.DataReference(new abap.types.Character(4));
    if (INPUT && INPUT.dref) {dref = INPUT.dref;}
    let lo_table = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_TABLEDESCR", RTTIName: "\\CLASS=CL_ABAP_TABLEDESCR"});
    let lt_keys = abap.types.TableFactory.construct(new abap.types.Structure({
    "components": abap.types.TableFactory.construct(new abap.types.Structure({
    "name": new abap.types.String({qualifiedName: "NAME"})}, "abap_table_keycompdescr", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "abap_table_keydescr-components"),
    "name": new abap.types.String({qualifiedName: "NAME"}),
    "is_primary": new abap.types.Character(1, {"qualifiedName":"is_primary","ddicName":"ABAP_BOOL"}),
    "access_kind": new abap.types.String({qualifiedName: "ACCESS_KIND"}),
    "is_unique": new abap.types.Character(1, {"qualifiedName":"is_unique","ddicName":"ABAP_BOOL"}),
    "key_kind": new abap.types.String({qualifiedName: "KEY_KIND"})}, "abap_table_keydescr", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "abap_table_keydescr_tab");
    let lv_component = new abap.types.String({qualifiedName: "STRING"});
    let field = new abap.types.DataReference(new abap.types.Character(4));
    let fs_ls_key_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "components": abap.types.TableFactory.construct(new abap.types.Structure({
    "name": new abap.types.String({qualifiedName: "NAME"})}, "abap_table_keycompdescr", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "abap_table_keydescr-components"),
    "name": new abap.types.String({qualifiedName: "NAME"}),
    "is_primary": new abap.types.Character(1, {"qualifiedName":"is_primary","ddicName":"ABAP_BOOL"}),
    "access_kind": new abap.types.String({qualifiedName: "ACCESS_KIND"}),
    "is_unique": new abap.types.Character(1, {"qualifiedName":"is_unique","ddicName":"ABAP_BOOL"}),
    "key_kind": new abap.types.String({qualifiedName: "KEY_KIND"})}, "abap_table_keydescr", undefined, {}, {}));
    await abap.statements.cast(lo_table, handle);
    await this.call({handle: (await lo_table.get().get_table_line_type()), dref: field});
    let options = {primaryKey: undefined, keyType: "DEFAULT", withHeader: false};
    options.primaryKey = {name: "primary_key", type: "STANDARD", keyFields: [], isUnique: false};
    lt_keys.set((await lo_table.get().get_keys()));
    for await (const unique1505 of abap.statements.loop(lt_keys,{where: async (I) => {return abap.compare.eq(I.is_primary, abap.builtin.abap_true);},topEquals: {"is_primary": abap.builtin.abap_true}})) {
      fs_ls_key_.assign(unique1505);
      if (abap.compare.eq(fs_ls_key_.get().access_kind, abap.Classes['CL_ABAP_TABLEDESCR'].tablekind_sorted)) {
        options.primaryKey.type = "SORTED";
      } else if (abap.compare.eq(fs_ls_key_.get().access_kind, abap.Classes['CL_ABAP_TABLEDESCR'].tablekind_hashed)) {
        options.primaryKey.type = "HASHED";
      }
      if (abap.compare.eq(fs_ls_key_.get().is_unique, abap.builtin.abap_true)) {
        options.primaryKey.isUnique = true;
      }
      for await (const unique1506 of abap.statements.loop(fs_ls_key_.get().components)) {
        lv_component.set(unique1506);
        options.primaryKey.keyFields.push(lv_component.get().toLowerCase());
      }
    }
    dref.assign(abap.types.TableFactory.construct(field.getPointer(), options));
  }
  async elem(INPUT) {
    return kernel_create_data_handle.elem(INPUT);
  }
  static async elem(INPUT) {
    let handle = INPUT?.handle;
    if (handle?.getQualifiedName === undefined || handle.getQualifiedName() !== "CL_ABAP_DATADESCR") { handle = undefined; }
    if (handle === undefined) { handle = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_DATADESCR", RTTIName: "\\CLASS=CL_ABAP_DATADESCR"}).set(INPUT.handle); }
    let dref = new abap.types.DataReference(new abap.types.Character(4));
    if (INPUT && INPUT.dref) {dref = INPUT.dref;}
    let lv_half = new abap.types.Integer({qualifiedName: "I"});
    let unique1507 = handle.get().type_kind;
    if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_float)) {
      abap.statements.createData(dref,{"typeName": "F"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_string)) {
      abap.statements.createData(dref,{"typeName": "STRING"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_xstring)) {
      abap.statements.createData(dref,{"typeName": "XSTRING"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_int)) {
      abap.statements.createData(dref,{"typeName": "I"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_utclong)) {
      abap.statements.createData(dref,{"typeName": "UTCLONG"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_date)) {
      abap.statements.createData(dref,{"typeName": "D"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_hex)) {
      abap.statements.createData(dref,{"typeName": "X","length": handle.get().length});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_packed)) {
      abap.statements.createData(dref,{"typeName": "P","length": handle.get().length,"decimals": handle.get().decimals});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_char)) {
      lv_half.set(abap.operators.divide(handle.get().length,abap.IntegerFactory.get(2)));
      abap.statements.createData(dref,{"typeName": "C","length": lv_half});
      dref.getPointer().extra = {"qualifiedName": handle.get().internal_qualified_name};
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_num)) {
      lv_half.set(abap.operators.divide(handle.get().length,abap.IntegerFactory.get(2)));
      abap.statements.createData(dref,{"typeName": "N","length": lv_half});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_time)) {
      abap.statements.createData(dref,{"typeName": "T"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_int8)) {
      abap.statements.createData(dref,{"typeName": "INT8"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_decfloat16)) {
      abap.statements.createData(dref,{"typeName": "DECFLOAT16"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else if (abap.compare.eq(unique1507, abap.Classes['CL_ABAP_TYPEDESCR'].typekind_decfloat34)) {
      abap.statements.createData(dref,{"typeName": "DECFLOAT34"});
      dref.getPointer().qualifiedName = handle.get().internal_qualified_name;
    } else {
      console.dir(handle);
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(4, 'todo')));
    }
  }
}
abap.Classes['KERNEL_CREATE_DATA_HANDLE'] = kernel_create_data_handle;
export {kernel_create_data_handle};