@abaplint/runtime 2.7.44 → 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.
|
@@ -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
|
|
46
|
+
const firstKeyField = table.getOptions().primaryKey.keyFields[0];
|
|
47
|
+
let useKey = false;
|
|
46
48
|
for (const name in options.withKeySimple) {
|
|
47
|
-
|
|
49
|
+
if (firstKeyField === name.toUpperCase()) {
|
|
50
|
+
useKey = true;
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
|
-
if (
|
|
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 (
|
|
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
|
}
|