@abaplint/runtime 1.7.2 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,5 +12,6 @@ export * from "./initial";
12
12
  export * from "./le";
13
13
  export * from "./lt";
14
14
  export * from "./ne";
15
+ export * from "./na";
15
16
  export * from "./ns";
16
17
  export { compareIn as in } from "./in";
@@ -25,6 +25,7 @@ __exportStar(require("./initial"), exports);
25
25
  __exportStar(require("./le"), exports);
26
26
  __exportStar(require("./lt"), exports);
27
27
  __exportStar(require("./ne"), exports);
28
+ __exportStar(require("./na"), exports);
28
29
  __exportStar(require("./ns"), exports);
29
30
  var in_1 = require("./in");
30
31
  Object.defineProperty(exports, "in", { enumerable: true, get: function () { return in_1.compareIn; } });
@@ -0,0 +1,3 @@
1
+ import { ICharacter } from "../types/_character";
2
+ import { INumeric } from "../types/_numeric";
3
+ export declare function na(left: number | string | ICharacter | INumeric, right: string | ICharacter): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.na = void 0;
4
+ const ca_1 = require("./ca");
5
+ function na(left, right) {
6
+ return !(0, ca_1.ca)(left, right);
7
+ }
8
+ exports.na = na;
9
+ //# sourceMappingURL=na.js.map
@@ -1,12 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modifyInternal = void 0;
4
+ const types_1 = require("../types");
5
+ const delete_internal_1 = require("./delete_internal");
6
+ const insert_internal_1 = require("./insert_internal");
7
+ const read_table_1 = require("./read_table");
4
8
  function modifyInternal(table, options) {
5
- const index = options.index.get() - 1;
6
- const found = table.array()[index] !== undefined;
7
- if (found) {
8
- table.deleteIndex(index);
9
- table.insertIndex(options.from, index);
9
+ let found = false;
10
+ if (options.index) {
11
+ const index = options.index.get() - 1;
12
+ found = table.array()[index] !== undefined;
13
+ if (found) {
14
+ table.deleteIndex(index);
15
+ table.insertIndex(options.from, index);
16
+ }
17
+ }
18
+ else if (options.from) {
19
+ const readResult = (0, read_table_1.readTable)(table, { from: options.from });
20
+ if (readResult.subrc === 0) {
21
+ (0, delete_internal_1.deleteInternal)(table, { index: new types_1.Integer().set(readResult.foundIndex) });
22
+ }
23
+ (0, insert_internal_1.insertInternal)({ table, data: options.from });
10
24
  }
11
25
  const subrc = found ? 0 : 4;
12
26
  // @ts-ignore
@@ -5,7 +5,11 @@ export interface IReadTableOptions {
5
5
  index?: INumeric | number;
6
6
  withKey?: (i: any) => boolean;
7
7
  into?: INumeric | ICharacter | Structure | Table | DataReference;
8
+ from?: INumeric | ICharacter | Structure | Table | DataReference;
8
9
  referenceInto?: DataReference;
9
10
  assigning?: FieldSymbol;
10
11
  }
11
- export declare function readTable(table: Table | FieldSymbol, options?: IReadTableOptions): void;
12
+ export declare function readTable(table: Table | FieldSymbol, options?: IReadTableOptions): {
13
+ subrc: number;
14
+ foundIndex: number;
15
+ };
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readTable = void 0;
4
+ const compare_1 = require("../compare");
4
5
  const types_1 = require("../types");
5
6
  function readTable(table, options) {
7
+ var _a;
6
8
  let found = undefined;
7
9
  let foundIndex = 0;
8
10
  const arr = table.array();
@@ -30,10 +32,40 @@ function readTable(table, options) {
30
32
  foundIndex = 0;
31
33
  }
32
34
  }
35
+ else if (options === null || options === void 0 ? void 0 : options.from) {
36
+ if (table instanceof types_1.Table && options.from instanceof types_1.Structure) {
37
+ const keys = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.keyFields;
38
+ const isStructured = arr[0] instanceof types_1.Structure;
39
+ if (keys !== undefined && isStructured === true) {
40
+ // console.dir(keys);
41
+ // console.dir(options.from.get()[keys[0].toLowerCase()]);
42
+ for (const a of arr) {
43
+ foundIndex++;
44
+ let matches = true;
45
+ for (const k of keys) {
46
+ if ((0, compare_1.eq)(a.get()[k.toLowerCase()], options.from.get()[k.toLowerCase()]) === false) {
47
+ matches = false;
48
+ break;
49
+ }
50
+ }
51
+ if (matches === true) {
52
+ found = arr;
53
+ break;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ if (found === undefined) {
59
+ foundIndex = 0;
60
+ }
61
+ }
33
62
  else {
34
63
  throw new Error("runtime, readTable, unexpected input");
35
64
  }
36
- const subrc = found ? 0 : 4;
65
+ let subrc = found ? 0 : 4;
66
+ if ((options === null || options === void 0 ? void 0 : options.from) && subrc === 4) {
67
+ subrc = 8;
68
+ }
37
69
  // @ts-ignore
38
70
  abap.builtin.sy.get().subrc.set(subrc);
39
71
  // @ts-ignore
@@ -55,6 +87,7 @@ function readTable(table, options) {
55
87
  else if (options.assigning && found) {
56
88
  options.assigning.assign(found);
57
89
  }
90
+ return { subrc, foundIndex };
58
91
  }
59
92
  exports.readTable = readTable;
60
93
  //# sourceMappingURL=read_table.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "1.7.2",
3
+ "version": "1.7.6",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",