@abaplint/runtime 2.3.12 → 2.3.14
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.
|
@@ -2,7 +2,7 @@ import { DataReference, FieldSymbol, Table, TableRowType } from "../types";
|
|
|
2
2
|
import { ICharacter } from "../types/_character";
|
|
3
3
|
import { INumeric } from "../types/_numeric";
|
|
4
4
|
export interface IAppendOptions {
|
|
5
|
-
source: TableRowType | FieldSymbol;
|
|
5
|
+
source: TableRowType | FieldSymbol | Table;
|
|
6
6
|
target: Table | FieldSymbol | undefined;
|
|
7
7
|
lines?: boolean;
|
|
8
8
|
assigning?: FieldSymbol;
|
|
@@ -5,14 +5,24 @@ const types_1 = require("../types");
|
|
|
5
5
|
function append(input) {
|
|
6
6
|
if (input.target instanceof types_1.FieldSymbol) {
|
|
7
7
|
input.target = input.target.getPointer();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (input.target === undefined) {
|
|
9
|
+
throw "Field symbol not assigned";
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
if (input.source instanceof types_1.FieldSymbol) {
|
|
13
13
|
input.source = input.source.getPointer();
|
|
14
14
|
}
|
|
15
|
-
if (input.
|
|
15
|
+
if (input.target === undefined) {
|
|
16
|
+
// short APPEND, use header field
|
|
17
|
+
if (!(input.source instanceof types_1.Table)) {
|
|
18
|
+
throw "APPEND, header, table";
|
|
19
|
+
}
|
|
20
|
+
input.source.append(input.source.getHeader());
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
abap.builtin.sy.get().tabix.set(input.source.array().length);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
else if (input.lines === true && input.source instanceof types_1.Table) {
|
|
16
26
|
let from = 1;
|
|
17
27
|
if (input.from) {
|
|
18
28
|
from = parseInt(input.from.get() + "", 10);
|
|
@@ -24,6 +24,7 @@ export declare type ITableOptions = {
|
|
|
24
24
|
export declare type TableRowType = INumeric | Structure | ICharacter | Table | ABAPObject;
|
|
25
25
|
export declare class Table {
|
|
26
26
|
private value;
|
|
27
|
+
private readonly header;
|
|
27
28
|
private readonly rowType;
|
|
28
29
|
private readonly loops;
|
|
29
30
|
private readonly options;
|
|
@@ -36,7 +37,8 @@ export declare class Table {
|
|
|
36
37
|
getRowType(): TableRowType;
|
|
37
38
|
array(): readonly any[];
|
|
38
39
|
clear(): void;
|
|
39
|
-
set(tab: Table): void;
|
|
40
|
+
set(tab: Table | TableRowType): void;
|
|
41
|
+
getHeader(): TableRowType;
|
|
40
42
|
insertIndex(item: TableRowType, index: number): TableRowType;
|
|
41
43
|
deleteIndex(index: number): void;
|
|
42
44
|
append(item: TableRowType, cloneRow?: boolean): FieldSymbol | DataReference | TableRowType;
|
package/build/src/types/table.js
CHANGED
|
@@ -27,6 +27,9 @@ class Table {
|
|
|
27
27
|
this.loops = new Set();
|
|
28
28
|
this.rowType = rowType;
|
|
29
29
|
this.options = options;
|
|
30
|
+
if ((options === null || options === void 0 ? void 0 : options.withHeader) === true) {
|
|
31
|
+
this.header = (0, clone_1.clone)(this.rowType);
|
|
32
|
+
}
|
|
30
33
|
if (this.options === undefined) {
|
|
31
34
|
this.options = {
|
|
32
35
|
type: TableAccessType.standard,
|
|
@@ -62,11 +65,26 @@ class Table {
|
|
|
62
65
|
this.value = [];
|
|
63
66
|
}
|
|
64
67
|
set(tab) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.withHeader) === true) {
|
|
70
|
+
(_b = this.header) === null || _b === void 0 ? void 0 : _b.set(tab);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (!(tab instanceof Table) && !(tab instanceof field_symbol_1.FieldSymbol)) {
|
|
74
|
+
throw "Table, set error";
|
|
75
|
+
}
|
|
76
|
+
this.clear();
|
|
77
|
+
for (const a of tab.array()) {
|
|
78
|
+
// this clones the values, and add sorting if required
|
|
79
|
+
(0, insert_internal_1.insertInternal)({ table: this, data: a });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
getHeader() {
|
|
84
|
+
if (this.header === undefined) {
|
|
85
|
+
throw "table, getHeader";
|
|
69
86
|
}
|
|
87
|
+
return this.header;
|
|
70
88
|
}
|
|
71
89
|
insertIndex(item, index) {
|
|
72
90
|
const val = this.getValue(item);
|