@abaplint/runtime 2.7.42 → 2.7.45

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.
@@ -3,7 +3,10 @@ import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
4
  export type ContainsInput = {
5
5
  val: ICharacter;
6
- regex: ICharacter;
6
+ regex?: ICharacter;
7
+ sub?: ICharacter;
8
+ start?: ICharacter;
9
+ end?: ICharacter;
7
10
  case?: ICharacter;
8
11
  off?: INumeric;
9
12
  len?: INumeric;
@@ -9,7 +9,19 @@ function contains(input) {
9
9
  || input.occ !== undefined) {
10
10
  throw "runtime, contains() todo";
11
11
  }
12
- const ret = input.val.get().match(input.regex.get()) !== null ? "X" : " ";
12
+ let ret = " ";
13
+ if (input.regex) {
14
+ ret = input.val.get().match(input.regex.get()) !== null ? "X" : " ";
15
+ }
16
+ else if (input.sub) {
17
+ ret = input.val.get().includes(input.sub.get()) ? "X" : " ";
18
+ }
19
+ else if (input.start) {
20
+ ret = input.val.get().startsWith(input.start.get()) ? "X" : " ";
21
+ }
22
+ else if (input.end) {
23
+ ret = input.val.get().endsWith(input.end.get()) ? "X" : " ";
24
+ }
13
25
  return new types_1.String().set(ret);
14
26
  }
15
27
  exports.contains = contains;
@@ -32,6 +32,7 @@ function readTable(table, options) {
32
32
  var _a, _b, _c, _d;
33
33
  let found = undefined;
34
34
  let foundIndex = 0;
35
+ let binarySubrc = undefined;
35
36
  if (table instanceof types_1.FieldSymbol) {
36
37
  if (table.getPointer() === undefined) {
37
38
  throw new Error("GETWA_NOT_ASSIGNED");
@@ -42,11 +43,14 @@ function readTable(table, options) {
42
43
  if ((options === null || options === void 0 ? void 0 : options.withTableKey) === undefined
43
44
  && (options === null || options === void 0 ? void 0 : options.withKeySimple)
44
45
  && (((_a = table.getOptions().primaryKey) === null || _a === void 0 ? void 0 : _a.keyFields) || []).length > 0) {
45
- const fields = new Set(table.getOptions().primaryKey.keyFields);
46
+ const firstKeyField = table.getOptions().primaryKey.keyFields[0];
47
+ let useKey = false;
46
48
  for (const name in options.withKeySimple) {
47
- fields.delete(name.toUpperCase());
49
+ if (firstKeyField === name.toUpperCase()) {
50
+ useKey = true;
51
+ }
48
52
  }
49
- if (fields.size === 0) {
53
+ if (useKey === true) {
50
54
  options.withTableKey = true;
51
55
  }
52
56
  }
@@ -97,6 +101,29 @@ function readTable(table, options) {
97
101
  const searchResult = searchWithKey(arr, options.withKey, startIndex, options.usesTableLine);
98
102
  found = searchResult.found;
99
103
  foundIndex = searchResult.foundIndex;
104
+ if (found === undefined) {
105
+ if (arr.length === 0) {
106
+ binarySubrc = 8;
107
+ foundIndex = 1;
108
+ }
109
+ else {
110
+ binarySubrc = 4;
111
+ foundIndex = startIndex + 1;
112
+ // check if going beyond the last row, todo: only checks one field
113
+ const last = arr[arr.length - 1];
114
+ const isStructured = last instanceof types_1.Structure;
115
+ let row = undefined;
116
+ if (options.usesTableLine === false && isStructured === true) {
117
+ row = last.get();
118
+ }
119
+ else {
120
+ row = isStructured ? Object.assign({ table_line: last }, last.get()) : { table_line: last };
121
+ }
122
+ if ((0, compare_1.ge)(first.value, first.key(row))) {
123
+ binarySubrc = 8;
124
+ }
125
+ }
126
+ }
100
127
  }
101
128
  else if (options === null || options === void 0 ? void 0 : options.withKey) {
102
129
  const arr = table.array();
@@ -142,7 +169,10 @@ function readTable(table, options) {
142
169
  throw new Error("runtime, readTable, unexpected input");
143
170
  }
144
171
  let subrc = found ? 0 : 4;
145
- if (((options === null || options === void 0 ? void 0 : options.from) || (options === null || options === void 0 ? void 0 : options.binarySearch) === true || (options === null || options === void 0 ? void 0 : options.keyName) !== undefined)
172
+ if (binarySubrc) {
173
+ subrc = binarySubrc;
174
+ }
175
+ else if (((options === null || options === void 0 ? void 0 : options.from) || (options === null || options === void 0 ? void 0 : options.binarySearch) === true || (options === null || options === void 0 ? void 0 : options.keyName) !== undefined)
146
176
  && subrc === 4) {
147
177
  subrc = 8;
148
178
  }
@@ -4,6 +4,7 @@ import { Structure } from "./structure";
4
4
  import { AbstractTypeData } from "./_abstract_type_data";
5
5
  import { ICharacter } from "./_character";
6
6
  import { INumeric } from "./_numeric";
7
+ import { Integer } from "./integer";
7
8
  export declare class Character implements ICharacter {
8
9
  private value;
9
10
  private constant;
@@ -11,7 +12,7 @@ export declare class Character implements ICharacter {
11
12
  private readonly extra;
12
13
  constructor(length?: number, extra?: AbstractTypeData);
13
14
  setConstant(): this;
14
- set(value: ICharacter | string | Structure | FieldSymbol): this;
15
+ set(value: ICharacter | string | Structure | FieldSymbol | Integer): this;
15
16
  getQualifiedName(): string | undefined;
16
17
  getConversionExit(): string | undefined;
17
18
  getDDICName(): string | undefined;
@@ -5,6 +5,7 @@ const _parse_1 = require("../operators/_parse");
5
5
  const throw_error_1 = require("../throw_error");
6
6
  const field_symbol_1 = require("./field_symbol");
7
7
  const structure_1 = require("./structure");
8
+ const integer_1 = require("./integer");
8
9
  const TRIMREGEX = / *$/;
9
10
  class Character {
10
11
  constructor(length, extra) {
@@ -41,6 +42,10 @@ class Character {
41
42
  this.set(value.getCharacter());
42
43
  return this;
43
44
  }
45
+ else if (value instanceof integer_1.Integer) {
46
+ this.value = Math.abs(value.get()) + (value.get() < 0 ? "-" : " ");
47
+ this.value = this.value.padStart(this.length, " ");
48
+ }
44
49
  else {
45
50
  this.value = value.get() + "";
46
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.42",
3
+ "version": "2.7.45",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",