All files / output zcl_abapgit_user_record.clas.mjs

8.14% Statements 18/221
66.66% Branches 2/3
9.09% Functions 1/11
8.14% Lines 18/221

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 2211x 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");
// zcl_abapgit_user_record.clas.abap
class zcl_abapgit_user_record {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_USER_RECORD';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_USER_RECORD"];
  static ATTRIBUTES = {"GT_USER": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"HASHED","isUnique":true,"keyFields":["USER"]},"secondary":[]}, "");}, "visibility": "I", "is_constant": " ", "is_class": "X"}};
  static METHODS = {"CHECK_USER_EXISTS": {"visibility": "I", "parameters": {"IV_USER": {"type": () => {return new abap.types.Character(12, {"qualifiedName":"sy-uname"});}, "is_optional": " "}, "EV_FULLNAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EV_EMAIL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "GET_USER_DTLS_FROM_OTHER_CLNT": {"visibility": "I", "parameters": {"RS_USER": {"type": () => {return new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});}, "is_optional": " "}, "IV_USER": {"type": () => {return new abap.types.Character(12, {"qualifiedName":"sy-uname"});}, "is_optional": " "}}},
  "BUILD_CACHE": {"visibility": "I", "parameters": {"RS_USER": {"type": () => {return new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});}, "is_optional": " "}, "IV_USER": {"type": () => {return new abap.types.Character(12, {"qualifiedName":"sy-uname"});}, "is_optional": " "}}},
  "READ_CACHE": {"visibility": "I", "parameters": {"RS_USER": {"type": () => {return new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});}, "is_optional": " "}, "IV_USER": {"type": () => {return new abap.types.Character(12, {"qualifiedName":"sy-uname"});}, "is_optional": " "}}},
  "RESET": {"visibility": "U", "parameters": {}}};
  #gt_user;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.gt_user = zcl_abapgit_user_record.gt_user;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async build_cache(INPUT) {
    return zcl_abapgit_user_record.build_cache(INPUT);
  }
  static async build_cache(INPUT) {
    let rs_user = new abap.types.Structure({
    "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
    "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
    "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});
    let iv_user = INPUT?.iv_user;
    if (iv_user?.getQualifiedName === undefined || iv_user.getQualifiedName() !== "SY-UNAME") { iv_user = undefined; }
    if (iv_user === undefined) { iv_user = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_user); }
    try {
      await this.check_user_exists({iv_user: iv_user, ev_fullname: rs_user.get().name, ev_email: rs_user.get().email});
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
        rs_user.set((await this.get_user_dtls_from_other_clnt({iv_user: iv_user})));
      } else {
        throw e;
      }
    }
    rs_user.get().user.set(iv_user);
    abap.statements.insertInternal({data: rs_user, table: zcl_abapgit_user_record.gt_user});
    return rs_user;
  }
  async check_user_exists(INPUT) {
    return zcl_abapgit_user_record.check_user_exists(INPUT);
  }
  static async check_user_exists(INPUT) {
    let iv_user = INPUT?.iv_user;
    if (iv_user?.getQualifiedName === undefined || iv_user.getQualifiedName() !== "SY-UNAME") { iv_user = undefined; }
    if (iv_user === undefined) { iv_user = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_user); }
    let ev_fullname = INPUT?.ev_fullname || new abap.types.String({qualifiedName: "STRING"});
    let ev_email = INPUT?.ev_email || new abap.types.String({qualifiedName: "STRING"});
    let lt_return = abap.types.TableFactory.construct(new abap.types.Structure({
    "type": new abap.types.Character(1, {"qualifiedName":"BAPI_MTYPE","ddicName":"BAPI_MTYPE","description":"BAPI_MTYPE"}),
    "id": new abap.types.Character(20, {"qualifiedName":"SYMSGID","ddicName":"SYMSGID","description":"SYMSGID"}),
    "number": new abap.types.Numc({length: 3, qualifiedName: "SYMSGNO"}),
    "message": new abap.types.Character(220, {"qualifiedName":"BAPI_MSG","ddicName":"BAPI_MSG","description":""}),
    "log_no": new abap.types.Character(20, {"qualifiedName":"BALOGNR","ddicName":"BALOGNR","description":"BALOGNR"}),
    "log_msg_no": new abap.types.Numc({length: 6, qualifiedName: "BALMNR"}),
    "message_v1": new abap.types.Character(50, {"qualifiedName":"SYMSGV","ddicName":"SYMSGV","description":"SYMSGV"}),
    "message_v2": new abap.types.Character(50, {"qualifiedName":"SYMSGV","ddicName":"SYMSGV","description":"SYMSGV"}),
    "message_v3": new abap.types.Character(50, {"qualifiedName":"SYMSGV","ddicName":"SYMSGV","description":"SYMSGV"}),
    "message_v4": new abap.types.Character(50, {"qualifiedName":"SYMSGV","ddicName":"SYMSGV","description":"SYMSGV"}),
    "parameter": new abap.types.Character(32, {"qualifiedName":"BAPI_PARAM","ddicName":"BAPI_PARAM","description":"BAPI_PARAM"}),
    "row": new abap.types.Integer({qualifiedName: "BAPI_LINE"}),
    "field": new abap.types.Character(30, {"qualifiedName":"BAPI_FLD","ddicName":"BAPI_FLD","description":"BAPI_FLD"}),
    "system": new abap.types.Character(10, {"qualifiedName":"BAPILOGSYS","ddicName":"BAPILOGSYS","description":"BAPILOGSYS"})}, "BAPIRET2", "BAPIRET2", {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "");
    let ls_address = (() => { throw new Error("Void type: BAPIADDR3") })();
    let lt_smtp = abap.types.TableFactory.construct((() => { throw new Error("Void type: BAPIADSMTP") })(), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "");
    let ls_smtp = (() => { throw new Error("Void type: BAPIADSMTP") })();
    if (abap.FunctionModules['BAPI_USER_GET_DETAIL'] === undefined) { if (abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()] === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; } else { throw new abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()]();} }
    await abap.FunctionModules['BAPI_USER_GET_DETAIL']({exporting: {username: iv_user}, importing: {address: ls_address}, tables: {return: lt_return, addsmtp: lt_smtp}});
    for await (const unique109 of abap.statements.loop(lt_return,{where: async (I) => {return abap.compare.ca(I.type, abap.CharacterFactory.get(2, 'EA'));}})) {
      
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`User: ${abap.templateFormatting(iv_user)} not found`)});
    }
    ev_fullname.set(ls_address.get().fullname);
    abap.statements.sort(lt_smtp,{by: [{component: "consnumber"}]});
    for await (const unique110 of abap.statements.loop(lt_smtp)) {
      ls_smtp.set(unique110);
      ev_email.set(ls_smtp.get().e_mail);
      break;
    }
  }
  async get_user_dtls_from_other_clnt(INPUT) {
    return zcl_abapgit_user_record.get_user_dtls_from_other_clnt(INPUT);
  }
  static async get_user_dtls_from_other_clnt(INPUT) {
    let rs_user = new abap.types.Structure({
    "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
    "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
    "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});
    let iv_user = INPUT?.iv_user;
    if (iv_user?.getQualifiedName === undefined || iv_user.getQualifiedName() !== "SY-UNAME") { iv_user = undefined; }
    if (iv_user === undefined) { iv_user = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_user); }
    let lc_cc_category = new abap.types.String({qualifiedName: "STRING"});
    lc_cc_category.set('C');
    
    let lt_dev_clients = abap.types.TableFactory.construct(new abap.types.Character(3, {"qualifiedName":"sy-mandt"}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"SORTED","isUnique":true,"keyFields":["TABLE_LINE"]},"secondary":[]}, "ty_dev_clients");
    let fs_lv_dev_client_ = new abap.types.FieldSymbol(new abap.types.Character(3, {"qualifiedName":"sy-mandt"}));
    await abap.statements.select(lt_dev_clients, {select: "SELECT mandt FROM " + abap.buildDbTableName("t000") + " WHERE \"cccategory\" = '" + lc_cc_category.get() + "' AND \"mandt\" <> '" + abap.builtin.sy.get().mandt.get() + "' ORDER BY PRIMARY KEY", primaryKey: ["mandt"]});
    for await (const unique111 of abap.statements.loop(lt_dev_clients)) {
      fs_lv_dev_client_.assign(unique111);
      await abap.statements.select([rs_user.get().user,rs_user.get().name,rs_user.get().email], {select: "SELECT \"u\".\"bname\", \"p\".\"name_text\", \"a\".\"smtp_addr\" FROM " + abap.buildDbTableName("usr21") + " AS u INNER JOIN " + abap.buildDbTableName("adrp") + " AS p ON \"p\".\"persnumber\" = u~persnumber AND \"p\".\"client\" = u~mandt INNER JOIN " + abap.buildDbTableName("adr6") + " AS a ON \"a\".\"persnumber\" = u~persnumber AND \"a\".\"addrnumber\" = u~addrnumber AND \"a\".\"client\" = u~mandt WHERE \"u\".\"mandt\" = '" + fs_lv_dev_client_.get() + "' AND \"u\".\"bname\" = '" + iv_user.get() + "' AND \"p\".\"date_from\" <= '" + abap.builtin.sy.get().datum.get() + "' AND \"p\".\"date_to\" >= '" + abap.builtin.sy.get().datum.get() + "' AND \"a\".\"date_from\" <= '" + abap.builtin.sy.get().datum.get() + "' UP TO 1 ROWS"});
      if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
        break;
      }
    }
    return rs_user;
  }
  async read_cache(INPUT) {
    return zcl_abapgit_user_record.read_cache(INPUT);
  }
  static async read_cache(INPUT) {
    let rs_user = new abap.types.Structure({
    "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
    "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
    "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});
    let iv_user = INPUT?.iv_user;
    if (iv_user?.getQualifiedName === undefined || iv_user.getQualifiedName() !== "SY-UNAME") { iv_user = undefined; }
    if (iv_user === undefined) { iv_user = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_user); }
    abap.statements.readTable(zcl_abapgit_user_record.gt_user,{withTableKey: true,
      into: rs_user,
      withKey: (i) => {return abap.compare.eq(i.user, iv_user);},
      withKeyValue: [{key: (i) => {return i.user}, value: iv_user}],
      usesTableLine: false,
      withKeySimple: {"user": iv_user}});
    if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      rs_user.set((await this.build_cache({iv_user: iv_user})));
    }
    return rs_user;
  }
  async reset() {
    return zcl_abapgit_user_record.reset();
  }
  static async reset() {
    zcl_abapgit_user_record.gt_user.clear();
  }
  async zif_abapgit_user_record$get_email(INPUT) {
    let rv_email = new abap.types.String({qualifiedName: "STRING"});
    let iv_username = INPUT?.iv_username;
    if (iv_username?.getQualifiedName === undefined || iv_username.getQualifiedName() !== "SY-UNAME") { iv_username = undefined; }
    if (iv_username === undefined) { iv_username = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_username); }
    rv_email.set(((await this.read_cache({iv_user: iv_username}))).get().email);
    return rv_email;
  }
  async zif_abapgit_user_record$get_name(INPUT) {
    let rv_name = new abap.types.String({qualifiedName: "STRING"});
    let iv_username = INPUT?.iv_username;
    if (iv_username?.getQualifiedName === undefined || iv_username.getQualifiedName() !== "SY-UNAME") { iv_username = undefined; }
    if (iv_username === undefined) { iv_username = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_username); }
    rv_name.set(((await this.read_cache({iv_user: iv_username}))).get().name);
    return rv_name;
  }
  async zif_abapgit_user_record$get_title(INPUT) {
    let rv_title = new abap.types.String({qualifiedName: "STRING"});
    let iv_username = INPUT?.iv_username;
    if (iv_username?.getQualifiedName === undefined || iv_username.getQualifiedName() !== "SY-UNAME") { iv_username = undefined; }
    if (iv_username === undefined) { iv_username = new abap.types.Character(12, {"qualifiedName":"sy-uname"}).set(INPUT.iv_username); }
    let lr_addr3 = new abap.types.DataReference(new abap.types.Character(4));
    let fs_ls_addr3_ = new abap.types.FieldSymbol(new abap.types.Character(4));
    let fs_lv_simple_ = new abap.types.FieldSymbol(new abap.types.Character());
    try {
      abap.statements.createData(lr_addr3,{"name": 'ADDR3_VAL'});
    } catch (e) {
      if ((abap.Classes['CX_SY_CREATE_DATA_ERROR'] && e instanceof abap.Classes['CX_SY_CREATE_DATA_ERROR'])) {
        return rv_title;
      } else {
        throw e;
      }
    }
    abap.statements.assign({target: fs_ls_addr3_, source: lr_addr3.dereference()});
    try {
      if (abap.FunctionModules['SUSR_USER_ADDRESS_READ'] === undefined) { if (abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()] === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_FUNC not found"; } else { throw new abap.Classes['CX_SY_DYN_CALL_ILLEGAL_FUNC'.trimEnd()]();} }
      await abap.FunctionModules['SUSR_USER_ADDRESS_READ']({exporting: {user_name: iv_username}, importing: {user_address: fs_ls_addr3_}});
      abap.builtin.sy.get().subrc.set(0);
    } catch (e) {
      if (e.classic) {
          switch (e.classic.toUpperCase()) {
          case "USER_ADDRESS_NOT_FOUND": abap.builtin.sy.get().subrc.set(1); break;
          default: abap.builtin.sy.get().subrc.set(2); break;
            }
        } else {
            throw e;
        }
      }
      if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
        abap.statements.assign({component: abap.CharacterFactory.get(9, 'NAME_TEXT'), target: fs_lv_simple_, source: fs_ls_addr3_});
        rv_title.set(fs_lv_simple_);
      }
      return rv_title;
    }
  }
  abap.Classes['ZCL_ABAPGIT_USER_RECORD'] = zcl_abapgit_user_record;
  zcl_abapgit_user_record.gt_user = abap.types.TableFactory.construct(new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {}), {"withHeader":false,"keyType":"USER","primaryKey":{"name":"primary_key","type":"HASHED","isUnique":true,"keyFields":["USER"]},"secondary":[]}, "");
  zcl_abapgit_user_record.ty_user = new abap.types.Structure({
  "user": new abap.types.Character(12, {"qualifiedName":"sy-uname"}),
  "name": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-NAME"}),
  "email": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_USER_RECORD=>TY_USER-EMAIL"})}, "zcl_abapgit_user_record=>ty_user", undefined, {}, {});
export {zcl_abapgit_user_record};