@abaplint/runtime 1.8.39 → 2.0.1
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.
- package/build/src/builtin/sy.js +2 -0
- package/build/src/compare/cs.js +2 -0
- package/build/src/context.d.ts +13 -0
- package/build/src/context.js +18 -0
- package/build/src/db/db.d.ts +49 -0
- package/build/src/db/db.js +3 -0
- package/build/src/index.d.ts +11 -13
- package/build/src/index.js +17 -21
- package/build/src/offset_length.js +1 -1
- package/build/src/statements/call_function.d.ts +6 -1
- package/build/src/statements/call_function.js +19 -15
- package/build/src/statements/delete_database.d.ts +7 -2
- package/build/src/statements/delete_database.js +34 -33
- package/build/src/statements/get_time.d.ts +2 -0
- package/build/src/statements/get_time.js +11 -8
- package/build/src/statements/index.d.ts +21 -21
- package/build/src/statements/index.js +26 -13
- package/build/src/statements/insert_database.d.ts +6 -1
- package/build/src/statements/insert_database.js +23 -28
- package/build/src/statements/message.d.ts +6 -1
- package/build/src/statements/message.js +34 -33
- package/build/src/statements/modify_database.d.ts +7 -2
- package/build/src/statements/modify_database.js +27 -23
- package/build/src/statements/select.d.ts +6 -1
- package/build/src/statements/select.js +29 -46
- package/build/src/statements/update_database.d.ts +7 -2
- package/build/src/statements/update_database.js +39 -42
- package/build/src/statements/write.d.ts +7 -3
- package/build/src/statements/write.js +29 -24
- package/build/src/template_formatting.d.ts +1 -0
- package/build/src/template_formatting.js +6 -1
- package/package.json +2 -4
package/build/src/builtin/sy.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.sy = new types_1.Structure({
|
|
|
6
6
|
abcde: new types_1.Character({ length: 26 }).set("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
|
7
7
|
datlo: new types_1.Date(),
|
|
8
8
|
datum: new types_1.Date(),
|
|
9
|
+
dbcnt: new types_1.Integer(),
|
|
9
10
|
fdpos: new types_1.Integer(),
|
|
10
11
|
index: new types_1.Integer(),
|
|
11
12
|
langu: new types_1.Character({ length: 1 }).set("E"),
|
|
@@ -19,6 +20,7 @@ exports.sy = new types_1.Structure({
|
|
|
19
20
|
subrc: new types_1.Integer(),
|
|
20
21
|
sysid: new types_1.Character({ length: 3 }).set("ABC"),
|
|
21
22
|
tabix: new types_1.Integer(),
|
|
23
|
+
tzone: new types_1.Integer(),
|
|
22
24
|
timlo: new types_1.Time(),
|
|
23
25
|
uname: new types_1.Character({ length: 12 }).set("USERNAME"),
|
|
24
26
|
uzeit: new types_1.Time(),
|
package/build/src/compare/cs.js
CHANGED
|
@@ -9,6 +9,7 @@ function cs(left, right) {
|
|
|
9
9
|
else {
|
|
10
10
|
l = left.get().toString();
|
|
11
11
|
}
|
|
12
|
+
l = l.toUpperCase();
|
|
12
13
|
let r = "";
|
|
13
14
|
if (typeof right === "string") {
|
|
14
15
|
r = right.toString();
|
|
@@ -16,6 +17,7 @@ function cs(left, right) {
|
|
|
16
17
|
else {
|
|
17
18
|
r = right.get().toString();
|
|
18
19
|
}
|
|
20
|
+
r = r.toUpperCase();
|
|
19
21
|
const index = l.indexOf(r);
|
|
20
22
|
if (index < 0) {
|
|
21
23
|
// @ts-ignore
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Console } from "./console";
|
|
2
|
+
import { DatabaseClient } from "./db/db";
|
|
3
|
+
import * as RFC from "./rfc";
|
|
4
|
+
export declare class Context {
|
|
5
|
+
console: Console;
|
|
6
|
+
databaseConnections: {
|
|
7
|
+
[name: string]: DatabaseClient;
|
|
8
|
+
};
|
|
9
|
+
RFCDestinations: {
|
|
10
|
+
[name: string]: RFC.RFCClient;
|
|
11
|
+
};
|
|
12
|
+
defaultDB(): DatabaseClient;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Context = void 0;
|
|
4
|
+
class Context {
|
|
5
|
+
constructor() {
|
|
6
|
+
// DEFAULT and secondary database connections
|
|
7
|
+
this.databaseConnections = {};
|
|
8
|
+
this.RFCDestinations = {};
|
|
9
|
+
}
|
|
10
|
+
defaultDB() {
|
|
11
|
+
if (this.databaseConnections["DEFAULT"] === undefined) {
|
|
12
|
+
throw new Error("Runtime, database not initialized");
|
|
13
|
+
}
|
|
14
|
+
return this.databaseConnections["DEFAULT"];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Context = Context;
|
|
18
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface DeleteDatabaseOptions {
|
|
2
|
+
table: string;
|
|
3
|
+
where: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UpdateDatabaseOptions {
|
|
6
|
+
table: string;
|
|
7
|
+
where: string;
|
|
8
|
+
set: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface InsertDatabaseOptions {
|
|
11
|
+
table: string;
|
|
12
|
+
columns: string[];
|
|
13
|
+
values: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface SelectDatabaseOptions {
|
|
16
|
+
select: string;
|
|
17
|
+
}
|
|
18
|
+
export declare type DatabaseValue = number | string | Uint8Array | null;
|
|
19
|
+
export declare type DatabaseRow = {
|
|
20
|
+
[name: string]: DatabaseValue;
|
|
21
|
+
};
|
|
22
|
+
export declare type DatabaseRows = DatabaseRow[];
|
|
23
|
+
export interface SelectDatabaseResult {
|
|
24
|
+
rows: DatabaseRows;
|
|
25
|
+
}
|
|
26
|
+
export interface DatabaseClient {
|
|
27
|
+
/*** the type/name/identifier of the database */
|
|
28
|
+
name: string;
|
|
29
|
+
connect(): Promise<void>;
|
|
30
|
+
disconnect(): Promise<void>;
|
|
31
|
+
/*** execute any native SQL command */
|
|
32
|
+
execute(sql: string): Promise<void>;
|
|
33
|
+
beginTransaction(): Promise<void>;
|
|
34
|
+
commit(): Promise<void>;
|
|
35
|
+
rollback(): Promise<void>;
|
|
36
|
+
delete(options: DeleteDatabaseOptions): Promise<{
|
|
37
|
+
subrc: number;
|
|
38
|
+
dbcnt: number;
|
|
39
|
+
}>;
|
|
40
|
+
update(options: UpdateDatabaseOptions): Promise<{
|
|
41
|
+
subrc: number;
|
|
42
|
+
dbcnt: number;
|
|
43
|
+
}>;
|
|
44
|
+
insert(options: InsertDatabaseOptions): Promise<{
|
|
45
|
+
subrc: number;
|
|
46
|
+
dbcnt: number;
|
|
47
|
+
}>;
|
|
48
|
+
select(options: SelectDatabaseOptions): Promise<SelectDatabaseResult>;
|
|
49
|
+
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Console } from "./console";
|
|
2
|
+
import { Context } from "./context";
|
|
3
|
+
import { OffsetLength } from "./offset_length";
|
|
4
|
+
import { Statements } from "./statements";
|
|
5
|
+
import { templateFormatting } from "./template_formatting";
|
|
6
|
+
import { UnitTestResult } from "./unit_test";
|
|
2
7
|
import * as builtin from "./builtin";
|
|
3
8
|
import * as compare from "./compare";
|
|
9
|
+
import * as DB from "./db/db";
|
|
4
10
|
import * as operators from "./operators";
|
|
5
|
-
import { Statements } from "./statements";
|
|
6
11
|
import * as RFC from "./rfc";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import { OffsetLength } from "./offset_length";
|
|
10
|
-
import { templateFormatting } from "./template_formatting";
|
|
11
|
-
export { UnitTestResult, RFC, types };
|
|
12
|
+
import * as types from "./types";
|
|
13
|
+
export { UnitTestResult, RFC, types, DB };
|
|
12
14
|
export declare class ABAP {
|
|
13
15
|
FunctionModules: {
|
|
14
16
|
[name: string]: any;
|
|
@@ -22,18 +24,14 @@ export declare class ABAP {
|
|
|
22
24
|
DDIC: {
|
|
23
25
|
[name: string]: any;
|
|
24
26
|
};
|
|
25
|
-
RFCDestinations: {
|
|
26
|
-
[name: string]: RFC.RFCClient;
|
|
27
|
-
};
|
|
28
27
|
statements: Statements;
|
|
29
28
|
types: typeof types;
|
|
30
29
|
builtin: typeof builtin;
|
|
31
30
|
operators: typeof operators;
|
|
32
31
|
compare: typeof compare;
|
|
33
|
-
console: Console;
|
|
34
|
-
db: undefined | any;
|
|
32
|
+
readonly console: Console;
|
|
35
33
|
OffsetLength: typeof OffsetLength;
|
|
36
34
|
templateFormatting: typeof templateFormatting;
|
|
35
|
+
readonly context: Context;
|
|
37
36
|
constructor();
|
|
38
|
-
initDB(sql?: string): Promise<void>;
|
|
39
37
|
}
|
package/build/src/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ABAP = exports.types = exports.RFC = exports.UnitTestResult = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
exports.ABAP = exports.DB = exports.types = exports.RFC = exports.UnitTestResult = void 0;
|
|
4
|
+
const console_1 = require("./console");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
const offset_length_1 = require("./offset_length");
|
|
7
|
+
const statements_1 = require("./statements");
|
|
8
|
+
const template_formatting_1 = require("./template_formatting");
|
|
9
|
+
const unit_test_1 = require("./unit_test");
|
|
10
|
+
Object.defineProperty(exports, "UnitTestResult", { enumerable: true, get: function () { return unit_test_1.UnitTestResult; } });
|
|
6
11
|
const builtin = require("./builtin");
|
|
7
12
|
const compare = require("./compare");
|
|
13
|
+
const DB = require("./db/db");
|
|
14
|
+
exports.DB = DB;
|
|
8
15
|
const operators = require("./operators");
|
|
9
|
-
const statements_1 = require("./statements");
|
|
10
16
|
const RFC = require("./rfc");
|
|
11
17
|
exports.RFC = RFC;
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const unit_test_1 = require("./unit_test");
|
|
15
|
-
Object.defineProperty(exports, "UnitTestResult", { enumerable: true, get: function () { return unit_test_1.UnitTestResult; } });
|
|
16
|
-
const offset_length_1 = require("./offset_length");
|
|
17
|
-
const template_formatting_1 = require("./template_formatting");
|
|
18
|
+
const types = require("./types");
|
|
19
|
+
exports.types = types;
|
|
18
20
|
class ABAP {
|
|
19
21
|
constructor() {
|
|
20
22
|
// global objects
|
|
@@ -22,28 +24,22 @@ class ABAP {
|
|
|
22
24
|
this.Classes = {};
|
|
23
25
|
this.Interfaces = {};
|
|
24
26
|
this.DDIC = {};
|
|
25
|
-
// RFC Destinations
|
|
26
|
-
this.RFCDestinations = {};
|
|
27
27
|
this.types = types;
|
|
28
28
|
this.builtin = builtin;
|
|
29
29
|
this.operators = operators;
|
|
30
30
|
this.compare = compare;
|
|
31
31
|
this.OffsetLength = offset_length_1.OffsetLength;
|
|
32
32
|
this.templateFormatting = template_formatting_1.templateFormatting;
|
|
33
|
+
this.context = new context_1.Context();
|
|
33
34
|
this.console = new console_1.Console();
|
|
34
|
-
this.
|
|
35
|
+
this.context.console = this.console;
|
|
36
|
+
this.statements = new statements_1.Statements(this.context);
|
|
35
37
|
// todo, this should not be a singleton, it should be part of this instance
|
|
38
|
+
// todo, move to context
|
|
36
39
|
builtin.sy.get().subrc.set(0);
|
|
37
40
|
builtin.sy.get().tabix.set(0);
|
|
38
41
|
builtin.sy.get().index.set(0);
|
|
39
|
-
|
|
40
|
-
async initDB(sql) {
|
|
41
|
-
const SQL = await (0, sql_js_1.default)();
|
|
42
|
-
this.db = new SQL.Database();
|
|
43
|
-
if (sql && sql !== "") {
|
|
44
|
-
this.db.run(sql);
|
|
45
|
-
}
|
|
46
|
-
this.statements.setDb(this.db);
|
|
42
|
+
this.statements.getTime({ sy: builtin.sy });
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
exports.ABAP = ABAP;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
export interface ICallFunctionOptions {
|
|
2
3
|
name: string;
|
|
3
4
|
destination: string;
|
|
@@ -7,4 +8,8 @@ export interface ICallFunctionOptions {
|
|
|
7
8
|
changing?: any;
|
|
8
9
|
exceptions?: any;
|
|
9
10
|
}
|
|
10
|
-
export declare
|
|
11
|
+
export declare class CallFunction {
|
|
12
|
+
private readonly context;
|
|
13
|
+
constructor(context: Context);
|
|
14
|
+
callFunction(options: ICallFunctionOptions): Promise<void>;
|
|
15
|
+
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if
|
|
9
|
-
|
|
3
|
+
exports.CallFunction = void 0;
|
|
4
|
+
class CallFunction {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
this.context = context;
|
|
7
|
+
}
|
|
8
|
+
// note: this is only called if DESTINIATION is supplied
|
|
9
|
+
async callFunction(options) {
|
|
10
|
+
const dest = this.context.RFCDestinations[options.destination];
|
|
11
|
+
if (dest === undefined) {
|
|
12
|
+
throw new Error(`RFC destination ${options.destination} does not exist`);
|
|
13
|
+
}
|
|
14
|
+
await dest.call(options.name, {
|
|
15
|
+
exporting: options.exporting,
|
|
16
|
+
importing: options.importing,
|
|
17
|
+
tables: options.tables,
|
|
18
|
+
changing: options.changing,
|
|
19
|
+
exceptions: options.exceptions,
|
|
20
|
+
});
|
|
10
21
|
}
|
|
11
|
-
await dest.call(options.name, {
|
|
12
|
-
exporting: options.exporting,
|
|
13
|
-
importing: options.importing,
|
|
14
|
-
tables: options.tables,
|
|
15
|
-
changing: options.changing,
|
|
16
|
-
exceptions: options.exceptions,
|
|
17
|
-
});
|
|
18
22
|
}
|
|
19
|
-
exports.
|
|
23
|
+
exports.CallFunction = CallFunction;
|
|
20
24
|
//# sourceMappingURL=call_function.js.map
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { FieldSymbol, Structure, Table } from "../types";
|
|
2
3
|
import { ICharacter } from "../types/_character";
|
|
3
|
-
export interface
|
|
4
|
+
export interface IDeleteDatabaseOptions {
|
|
4
5
|
from?: Structure | FieldSymbol;
|
|
5
6
|
table?: Table | FieldSymbol;
|
|
6
7
|
}
|
|
7
|
-
export declare
|
|
8
|
+
export declare class DeleteDatabase {
|
|
9
|
+
private readonly context;
|
|
10
|
+
constructor(context: Context);
|
|
11
|
+
deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
|
|
12
|
+
}
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DeleteDatabase = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
class DeleteDatabase {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
this.context = context;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
options.table
|
|
11
|
-
|
|
12
|
-
if (options.from instanceof types_1.FieldSymbol) {
|
|
13
|
-
options.from = options.from.getPointer();
|
|
14
|
-
}
|
|
15
|
-
if (options.table) {
|
|
16
|
-
for (const row of options.table.array()) {
|
|
17
|
-
deleteDatabase.bind(this)(table, { from: row });
|
|
9
|
+
async deleteDatabase(table, options) {
|
|
10
|
+
if (options.table instanceof types_1.FieldSymbol) {
|
|
11
|
+
options.table = options.table.getPointer();
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const where = [];
|
|
22
|
-
const structure = options.from.get();
|
|
23
|
-
for (const k of Object.keys(structure)) {
|
|
24
|
-
// todo, integers should not be surrounded by '"'?
|
|
25
|
-
const str = k + ' = "' + structure[k].get() + '"';
|
|
26
|
-
where.push(str);
|
|
13
|
+
if (options.from instanceof types_1.FieldSymbol) {
|
|
14
|
+
options.from = options.from.getPointer();
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
this.db.exec(sql);
|
|
16
|
+
if (typeof table !== "string") {
|
|
17
|
+
table = table.get();
|
|
32
18
|
}
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
if (options.table) {
|
|
20
|
+
for (const row of options.table.array()) {
|
|
21
|
+
this.deleteDatabase(table, { from: row });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (options.from) {
|
|
25
|
+
let where = [];
|
|
26
|
+
const structure = options.from.get();
|
|
27
|
+
for (const k of Object.keys(structure)) {
|
|
28
|
+
// todo, integers should not be surrounded by '"'?
|
|
29
|
+
const str = k + ' = "' + structure[k].get() + '"';
|
|
30
|
+
where.push(str);
|
|
31
|
+
}
|
|
32
|
+
where = where.join(" AND ");
|
|
33
|
+
const { subrc, dbcnt } = await this.context.defaultDB().delete({ table, where });
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
abap.builtin.sy.get().dbcnt.set(dbcnt);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw "deleteDatabase todo";
|
|
35
41
|
}
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
abap.builtin.sy.get().subrc.set(subrc);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw "deleteDatabase todo";
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
exports.
|
|
44
|
+
exports.DeleteDatabase = DeleteDatabase;
|
|
44
45
|
//# sourceMappingURL=delete_database.js.map
|
|
@@ -9,14 +9,17 @@ function getTime(options) {
|
|
|
9
9
|
const time = (d.getUTCHours() + "").padStart(2, "0") +
|
|
10
10
|
(d.getUTCMinutes() + "").padStart(2, "0") +
|
|
11
11
|
(d.getUTCSeconds() + "").padStart(2, "0");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
if (options === undefined) {
|
|
13
|
+
options = {};
|
|
14
|
+
}
|
|
15
|
+
if ((options === null || options === void 0 ? void 0 : options.sy) === undefined) {
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
options.sy = abap.builtin.sy;
|
|
18
|
+
}
|
|
19
|
+
options.sy.get().datlo.set(date);
|
|
20
|
+
options.sy.get().datum.set(date);
|
|
21
|
+
options.sy.get().timlo.set(time);
|
|
22
|
+
options.sy.get().uzeit.set(time);
|
|
20
23
|
if (options === null || options === void 0 ? void 0 : options.field) {
|
|
21
24
|
options.field.set(time);
|
|
22
25
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { append } from "./append";
|
|
2
2
|
import { assert } from "./assert";
|
|
3
3
|
import { assign } from "./assign";
|
|
4
|
-
import { callFunction } from "./call_function";
|
|
5
4
|
import { clear } from "./clear";
|
|
6
5
|
import { commit } from "./commit";
|
|
7
6
|
import { concatenate } from "./concatenate";
|
|
8
7
|
import { condense } from "./condense";
|
|
9
|
-
import { Console } from "../console";
|
|
10
8
|
import { convert } from "./convert";
|
|
11
9
|
import { createData } from "./create_data";
|
|
12
10
|
import { deleteInternal } from "./delete_internal";
|
|
@@ -15,25 +13,29 @@ import { find } from "./find";
|
|
|
15
13
|
import { getBit } from "./get_bit";
|
|
16
14
|
import { getRunTime } from "./get_run_time";
|
|
17
15
|
import { getTime } from "./get_time";
|
|
18
|
-
import {
|
|
16
|
+
import { IInsertDatabaseOptions } from "./insert_database";
|
|
19
17
|
import { insertInternal } from "./insert_internal";
|
|
20
|
-
import {
|
|
18
|
+
import { IDeleteDatabaseOptions } from "./delete_database";
|
|
21
19
|
import { loop } from "./loop";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
20
|
+
import { IMessageOptions } from "./message";
|
|
21
|
+
import { IModifyDatabaseOptions } from "./modify_database";
|
|
24
22
|
import { modifyInternal } from "./modify_internal";
|
|
25
23
|
import { moveCorresponding } from "./move_corresponding";
|
|
26
24
|
import { readTable } from "./read_table";
|
|
27
25
|
import { replace } from "./replace";
|
|
28
26
|
import { rollback } from "./rollback";
|
|
29
|
-
import { select } from "./select";
|
|
30
27
|
import { setBit } from "./set_bit";
|
|
31
28
|
import { shift } from "./shift";
|
|
32
29
|
import { sort } from "./sort";
|
|
33
30
|
import { split } from "./split";
|
|
34
31
|
import { translate } from "./translate";
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
32
|
+
import { IUpdateDatabaseOptions } from "./update_database";
|
|
33
|
+
import { IWriteOptions } from "./write";
|
|
34
|
+
import { Context } from "../context";
|
|
35
|
+
import { ICharacter } from "../types/_character";
|
|
36
|
+
import { FieldSymbol, Structure, Table } from "../types";
|
|
37
|
+
import { INumeric } from "../types/_numeric";
|
|
38
|
+
import { ICallFunctionOptions } from "./call_function";
|
|
37
39
|
export declare class Statements {
|
|
38
40
|
append: typeof append;
|
|
39
41
|
assert: typeof assert;
|
|
@@ -48,30 +50,28 @@ export declare class Statements {
|
|
|
48
50
|
describe: typeof describe;
|
|
49
51
|
find: typeof find;
|
|
50
52
|
getBit: typeof getBit;
|
|
51
|
-
callFunction: typeof callFunction;
|
|
52
53
|
getRunTime: typeof getRunTime;
|
|
53
|
-
deleteDatabase: typeof deleteDatabase;
|
|
54
54
|
getTime: typeof getTime;
|
|
55
|
-
insertDatabase: typeof insertDatabase;
|
|
56
55
|
insertInternal: typeof insertInternal;
|
|
57
56
|
loop: typeof loop;
|
|
58
|
-
message: typeof message;
|
|
59
57
|
modifyInternal: typeof modifyInternal;
|
|
60
58
|
moveCorresponding: typeof moveCorresponding;
|
|
61
59
|
readTable: typeof readTable;
|
|
62
|
-
updateDatabase: typeof updateDatabase;
|
|
63
|
-
modifyDatabase: typeof modifyDatabase;
|
|
64
60
|
replace: typeof replace;
|
|
65
61
|
rollback: typeof rollback;
|
|
66
|
-
select: typeof select;
|
|
67
62
|
setBit: typeof setBit;
|
|
68
63
|
shift: typeof shift;
|
|
69
64
|
sort: typeof sort;
|
|
70
65
|
split: typeof split;
|
|
71
66
|
translate: typeof translate;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
private readonly context;
|
|
68
|
+
constructor(context: Context);
|
|
69
|
+
deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
|
|
70
|
+
insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number>;
|
|
71
|
+
message(options: IMessageOptions): Promise<void>;
|
|
72
|
+
modifyDatabase(table: string | ICharacter, options: IModifyDatabaseOptions): Promise<void>;
|
|
73
|
+
select(target: Structure | Table | FieldSymbol, select: string): Promise<void>;
|
|
74
|
+
updateDatabase(table: string | ICharacter, options: IUpdateDatabaseOptions): Promise<number>;
|
|
75
|
+
callFunction(options: ICallFunctionOptions): Promise<void>;
|
|
76
|
+
write(source: INumeric | ICharacter | FieldSymbol | string | number, options?: IWriteOptions): void;
|
|
77
77
|
}
|
|
@@ -4,7 +4,6 @@ exports.Statements = void 0;
|
|
|
4
4
|
const append_1 = require("./append");
|
|
5
5
|
const assert_1 = require("./assert");
|
|
6
6
|
const assign_1 = require("./assign");
|
|
7
|
-
const call_function_1 = require("./call_function");
|
|
8
7
|
const clear_1 = require("./clear");
|
|
9
8
|
const commit_1 = require("./commit");
|
|
10
9
|
const concatenate_1 = require("./concatenate");
|
|
@@ -36,10 +35,11 @@ const split_1 = require("./split");
|
|
|
36
35
|
const translate_1 = require("./translate");
|
|
37
36
|
const update_database_1 = require("./update_database");
|
|
38
37
|
const write_1 = require("./write");
|
|
38
|
+
const call_function_1 = require("./call_function");
|
|
39
39
|
// this is a class, as statements like SELECT needs access to the database object instance
|
|
40
40
|
// and WRITE will access the Console
|
|
41
41
|
class Statements {
|
|
42
|
-
constructor(
|
|
42
|
+
constructor(context) {
|
|
43
43
|
this.append = append_1.append;
|
|
44
44
|
this.assert = assert_1.assert;
|
|
45
45
|
this.assign = assign_1.assign;
|
|
@@ -53,32 +53,45 @@ class Statements {
|
|
|
53
53
|
this.describe = describe_1.describe;
|
|
54
54
|
this.find = find_1.find;
|
|
55
55
|
this.getBit = get_bit_1.getBit;
|
|
56
|
-
this.callFunction = call_function_1.callFunction;
|
|
57
56
|
this.getRunTime = get_run_time_1.getRunTime;
|
|
58
|
-
this.deleteDatabase = delete_database_1.deleteDatabase;
|
|
59
57
|
this.getTime = get_time_1.getTime;
|
|
60
|
-
this.insertDatabase = insert_database_1.insertDatabase;
|
|
61
58
|
this.insertInternal = insert_internal_1.insertInternal;
|
|
62
59
|
this.loop = loop_1.loop;
|
|
63
|
-
this.message = message_1.message;
|
|
64
60
|
this.modifyInternal = modify_internal_1.modifyInternal;
|
|
65
61
|
this.moveCorresponding = move_corresponding_1.moveCorresponding;
|
|
66
62
|
this.readTable = read_table_1.readTable;
|
|
67
|
-
this.updateDatabase = update_database_1.updateDatabase;
|
|
68
|
-
this.modifyDatabase = modify_database_1.modifyDatabase;
|
|
69
63
|
this.replace = replace_1.replace;
|
|
70
64
|
this.rollback = rollback_1.rollback;
|
|
71
|
-
this.select = select_1.select;
|
|
72
65
|
this.setBit = set_bit_1.setBit;
|
|
73
66
|
this.shift = shift_1.shift;
|
|
74
67
|
this.sort = sort_1.sort;
|
|
75
68
|
this.split = split_1.split;
|
|
76
69
|
this.translate = translate_1.translate;
|
|
77
|
-
this.
|
|
78
|
-
|
|
70
|
+
this.context = context;
|
|
71
|
+
}
|
|
72
|
+
async deleteDatabase(table, options) {
|
|
73
|
+
return new delete_database_1.DeleteDatabase(this.context).deleteDatabase(table, options);
|
|
74
|
+
}
|
|
75
|
+
async insertDatabase(table, options) {
|
|
76
|
+
return new insert_database_1.InsertDatabase(this.context).insertDatabase(table, options);
|
|
77
|
+
}
|
|
78
|
+
async message(options) {
|
|
79
|
+
return new message_1.MessageStatement(this.context).message(options);
|
|
80
|
+
}
|
|
81
|
+
async modifyDatabase(table, options) {
|
|
82
|
+
return new modify_database_1.ModifyDatabase(this.context).modifyDatabase(table, options);
|
|
83
|
+
}
|
|
84
|
+
async select(target, select) {
|
|
85
|
+
return new select_1.SelectDatabase(this.context).select(target, select);
|
|
86
|
+
}
|
|
87
|
+
async updateDatabase(table, options) {
|
|
88
|
+
return new update_database_1.UpdateDatabase(this.context).updateDatabase(table, options);
|
|
89
|
+
}
|
|
90
|
+
async callFunction(options) {
|
|
91
|
+
return new call_function_1.CallFunction(this.context).callFunction(options);
|
|
79
92
|
}
|
|
80
|
-
|
|
81
|
-
this.
|
|
93
|
+
write(source, options) {
|
|
94
|
+
return new write_1.WriteStatement(this.context).write(source, options);
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
exports.Statements = Statements;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { Structure } from "../types";
|
|
2
3
|
import { ICharacter } from "../types/_character";
|
|
3
4
|
export interface IInsertDatabaseOptions {
|
|
4
5
|
values: Structure;
|
|
5
6
|
}
|
|
6
|
-
export declare
|
|
7
|
+
export declare class InsertDatabase {
|
|
8
|
+
private readonly context;
|
|
9
|
+
constructor(context: Context);
|
|
10
|
+
insertDatabase(table: string | ICharacter, options: IInsertDatabaseOptions): Promise<number>;
|
|
11
|
+
}
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.InsertDatabase = void 0;
|
|
4
|
+
class InsertDatabase {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
this.context = context;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
async insertDatabase(table, options) {
|
|
9
|
+
const columns = [];
|
|
10
|
+
const values = [];
|
|
11
|
+
const structure = options.values.get();
|
|
12
|
+
for (const k of Object.keys(structure)) {
|
|
13
|
+
columns.push(k);
|
|
14
|
+
// todo, integers should not be surrounded by '"'?
|
|
15
|
+
values.push('"' + structure[k].get() + '"');
|
|
16
|
+
}
|
|
17
|
+
if (typeof table !== "string") {
|
|
18
|
+
table = table.get();
|
|
19
|
+
}
|
|
20
|
+
const { subrc, dbcnt } = await this.context.defaultDB().insert({ table, columns, values });
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
abap.builtin.sy.get().dbcnt.set(dbcnt);
|
|
25
|
+
return subrc;
|
|
15
26
|
}
|
|
16
|
-
if (typeof table !== "string") {
|
|
17
|
-
table = table.get();
|
|
18
|
-
}
|
|
19
|
-
const sql = `INSERT INTO ${table} (${columns.join(",")}) VALUES (${values.join(",")})`;
|
|
20
|
-
// console.dir(sql);
|
|
21
|
-
let subrc = 0;
|
|
22
|
-
try {
|
|
23
|
-
this.db.exec(sql);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
// eg "UNIQUE constraint failed" errors
|
|
27
|
-
subrc = 4;
|
|
28
|
-
}
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
abap.builtin.sy.get().subrc.set(subrc);
|
|
31
|
-
return subrc;
|
|
32
27
|
}
|
|
33
|
-
exports.
|
|
28
|
+
exports.InsertDatabase = InsertDatabase;
|
|
34
29
|
//# sourceMappingURL=insert_database.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { ICharacter } from "../types/_character";
|
|
2
3
|
export interface IMessageOptions {
|
|
3
4
|
id?: ICharacter | string;
|
|
@@ -6,4 +7,8 @@ export interface IMessageOptions {
|
|
|
6
7
|
with?: (ICharacter | string)[];
|
|
7
8
|
into?: ICharacter;
|
|
8
9
|
}
|
|
9
|
-
export declare
|
|
10
|
+
export declare class MessageStatement {
|
|
11
|
+
private readonly context;
|
|
12
|
+
constructor(context: Context);
|
|
13
|
+
message(options: IMessageOptions): Promise<void>;
|
|
14
|
+
}
|
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function message(options) {
|
|
5
|
-
let arbgb = options.id;
|
|
6
|
-
if (arbgb !== undefined && typeof arbgb !== "string") {
|
|
7
|
-
arbgb = arbgb.get();
|
|
8
|
-
}
|
|
9
|
-
arbgb = arbgb === null || arbgb === void 0 ? void 0 : arbgb.toUpperCase();
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
abap.builtin.sy.get().msgid.set(arbgb);
|
|
12
|
-
let msgnr = options.number;
|
|
13
|
-
if (msgnr !== undefined && typeof msgnr !== "string") {
|
|
14
|
-
msgnr = msgnr.get();
|
|
15
|
-
}
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
abap.builtin.sy.get().msgno.set(msgnr);
|
|
18
|
-
const text = findText.bind(this)(arbgb, msgnr);
|
|
19
|
-
const replaced = replace(text, options.with);
|
|
20
|
-
if (options.into) {
|
|
21
|
-
options.into.set(replaced);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.message = message;
|
|
3
|
+
exports.MessageStatement = void 0;
|
|
25
4
|
function replace(text, w) {
|
|
26
5
|
for (let i = 0; i < 6; i++) {
|
|
27
6
|
const search = "&" + (i + 1);
|
|
@@ -44,19 +23,15 @@ function replace(text, w) {
|
|
|
44
23
|
}
|
|
45
24
|
return text.trim();
|
|
46
25
|
}
|
|
47
|
-
function findText(arbgb, msgnr) {
|
|
26
|
+
async function findText(context, arbgb, msgnr) {
|
|
48
27
|
let text = undefined;
|
|
49
|
-
|
|
50
|
-
if (db && arbgb && msgnr) {
|
|
28
|
+
if (arbgb && msgnr) {
|
|
51
29
|
try {
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
});
|
|
58
|
-
if (result.text) {
|
|
59
|
-
text = result.text;
|
|
30
|
+
// todo, sql injection?
|
|
31
|
+
const select = `SELECT * FROM t100 WHERE sprsl='E' AND arbgb='${arbgb}' AND msgnr='${msgnr}' LIMIT 1`;
|
|
32
|
+
const { rows: result } = await context.defaultDB().select({ select });
|
|
33
|
+
if (result[0]) {
|
|
34
|
+
text = result[0]["text"];
|
|
60
35
|
}
|
|
61
36
|
}
|
|
62
37
|
catch (_a) {
|
|
@@ -69,4 +44,30 @@ function findText(arbgb, msgnr) {
|
|
|
69
44
|
}
|
|
70
45
|
return text;
|
|
71
46
|
}
|
|
47
|
+
class MessageStatement {
|
|
48
|
+
constructor(context) {
|
|
49
|
+
this.context = context;
|
|
50
|
+
}
|
|
51
|
+
async message(options) {
|
|
52
|
+
let arbgb = options.id;
|
|
53
|
+
if (arbgb !== undefined && typeof arbgb !== "string") {
|
|
54
|
+
arbgb = arbgb.get();
|
|
55
|
+
}
|
|
56
|
+
arbgb = arbgb === null || arbgb === void 0 ? void 0 : arbgb.toUpperCase();
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
abap.builtin.sy.get().msgid.set(arbgb);
|
|
59
|
+
let msgnr = options.number;
|
|
60
|
+
if (msgnr !== undefined && typeof msgnr !== "string") {
|
|
61
|
+
msgnr = msgnr.get();
|
|
62
|
+
}
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
abap.builtin.sy.get().msgno.set(msgnr);
|
|
65
|
+
const text = await findText(this.context, arbgb, msgnr);
|
|
66
|
+
const replaced = replace(text, options.with);
|
|
67
|
+
if (options.into) {
|
|
68
|
+
options.into.set(replaced);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MessageStatement = MessageStatement;
|
|
72
73
|
//# sourceMappingURL=message.js.map
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { FieldSymbol, Structure, Table } from "../types";
|
|
2
3
|
import { ICharacter } from "../types/_character";
|
|
3
|
-
export interface
|
|
4
|
+
export interface IModifyDatabaseOptions {
|
|
4
5
|
from?: Structure | FieldSymbol;
|
|
5
6
|
table?: Table | FieldSymbol;
|
|
6
7
|
}
|
|
7
|
-
export declare
|
|
8
|
+
export declare class ModifyDatabase {
|
|
9
|
+
private readonly context;
|
|
10
|
+
constructor(context: Context);
|
|
11
|
+
modifyDatabase(table: string | ICharacter, options: IModifyDatabaseOptions): Promise<void>;
|
|
12
|
+
}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ModifyDatabase = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const insert_database_1 = require("./insert_database");
|
|
6
6
|
const update_database_1 = require("./update_database");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
class ModifyDatabase {
|
|
8
|
+
constructor(context) {
|
|
9
|
+
this.context = context;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
options.table
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
options.from
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
async modifyDatabase(table, options) {
|
|
12
|
+
if (options.table instanceof types_1.FieldSymbol) {
|
|
13
|
+
options.table = options.table.getPointer();
|
|
14
|
+
}
|
|
15
|
+
if (options.from instanceof types_1.FieldSymbol) {
|
|
16
|
+
options.from = options.from.getPointer();
|
|
17
|
+
}
|
|
18
|
+
const insert = new insert_database_1.InsertDatabase(this.context);
|
|
19
|
+
const update = new update_database_1.UpdateDatabase(this.context);
|
|
20
|
+
if (options.table) {
|
|
21
|
+
for (const row of options.table.array()) {
|
|
22
|
+
const subrc = await insert.insertDatabase(table, { values: row });
|
|
23
|
+
if (subrc !== 0) {
|
|
24
|
+
await update.updateDatabase(table, { from: row });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (options.from) {
|
|
29
|
+
const subrc = await insert.insertDatabase(table, { values: options.from });
|
|
20
30
|
if (subrc !== 0) {
|
|
21
|
-
|
|
31
|
+
await update.updateDatabase(table, { from: options.from });
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const subrc = insert_database_1.insertDatabase.bind(this)(table, { values: options.from });
|
|
27
|
-
if (subrc !== 0) {
|
|
28
|
-
update_database_1.updateDatabase.bind(this)(table, { from: options.from });
|
|
34
|
+
else {
|
|
35
|
+
throw "modifyDatabase todo";
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
|
-
else {
|
|
32
|
-
throw "modifyDatabase todo";
|
|
33
|
-
}
|
|
34
38
|
}
|
|
35
|
-
exports.
|
|
39
|
+
exports.ModifyDatabase = ModifyDatabase;
|
|
36
40
|
//# sourceMappingURL=modify_database.js.map
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { FieldSymbol, Structure, Table } from "../types";
|
|
2
|
-
export declare
|
|
3
|
+
export declare class SelectDatabase {
|
|
4
|
+
private readonly context;
|
|
5
|
+
constructor(context: Context);
|
|
6
|
+
select(target: Structure | Table | FieldSymbol, select: string): Promise<void>;
|
|
7
|
+
}
|
|
@@ -1,70 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SelectDatabase = void 0;
|
|
4
4
|
const clone_1 = require("../clone");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new Error("Runtime, database not initialized");
|
|
6
|
+
class SelectDatabase {
|
|
7
|
+
constructor(context) {
|
|
8
|
+
this.context = context;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
async select(target, select) {
|
|
11
|
+
var _a;
|
|
12
|
+
const { rows: rows } = await this.context.defaultDB().select({ select });
|
|
13
|
+
if (target instanceof types_1.FieldSymbol) {
|
|
14
|
+
if (target.isAssigned() === false) {
|
|
15
|
+
throw "select, fs not assigned";
|
|
16
|
+
}
|
|
18
17
|
// @ts-ignore
|
|
19
|
-
|
|
18
|
+
target = target.getPointer();
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (target instanceof types_1.FieldSymbol) {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
target = target.getPointer();
|
|
26
|
-
}
|
|
27
|
-
target.clear();
|
|
28
|
-
if (target instanceof types_1.Structure) {
|
|
29
|
-
if (((_a = res[0]) === null || _a === void 0 ? void 0 : _a.values[0]) === undefined) {
|
|
20
|
+
target.clear();
|
|
21
|
+
if (rows.length === 0) {
|
|
30
22
|
// @ts-ignore
|
|
31
23
|
abap.builtin.sy.get().subrc.set(4);
|
|
24
|
+
return;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
const columns = res[0].columns;
|
|
35
|
-
const values = res[0].values[0];
|
|
26
|
+
if (target instanceof types_1.Structure) {
|
|
36
27
|
const result = {};
|
|
37
|
-
for (const
|
|
38
|
-
result[
|
|
28
|
+
for (const column in rows[0]) {
|
|
29
|
+
result[column] = (0, clone_1.clone)(target.get()[column]).set(rows[0][column]);
|
|
39
30
|
}
|
|
40
31
|
target.set(new types_1.Structure(result));
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
abap.builtin.sy.get().subrc.set(0);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else if (target instanceof types_1.Table) {
|
|
46
|
-
if (((_b = res[0]) === null || _b === void 0 ? void 0 : _b.values[0]) === undefined) {
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
abap.builtin.sy.get().subrc.set(4);
|
|
49
32
|
}
|
|
50
|
-
else {
|
|
51
|
-
for (const
|
|
33
|
+
else if (target instanceof types_1.Table) {
|
|
34
|
+
for (const row of rows) {
|
|
52
35
|
const targetRow = (0, clone_1.clone)(target.getRowType());
|
|
53
|
-
const
|
|
54
|
-
|
|
36
|
+
for (const columnName in row) {
|
|
37
|
+
// todo, non structured table = table with simple rows
|
|
55
38
|
// @ts-ignore
|
|
56
|
-
(
|
|
39
|
+
(_a = targetRow.get()[columnName]) === null || _a === void 0 ? void 0 : _a.set(row[columnName]);
|
|
57
40
|
}
|
|
58
41
|
// @ts-ignore
|
|
59
42
|
abap.statements.insertInternal({ table: target, data: targetRow });
|
|
60
43
|
}
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
abap.builtin.sy.get().subrc.set(0);
|
|
63
44
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
else {
|
|
46
|
+
throw new Error("Runtime, SELECT todo");
|
|
47
|
+
}
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
abap.builtin.sy.get().subrc.set(0);
|
|
67
50
|
}
|
|
68
51
|
}
|
|
69
|
-
exports.
|
|
52
|
+
exports.SelectDatabase = SelectDatabase;
|
|
70
53
|
//# sourceMappingURL=select.js.map
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { FieldSymbol, Structure, Table } from "../types";
|
|
2
3
|
import { ICharacter } from "../types/_character";
|
|
3
|
-
export interface
|
|
4
|
+
export interface IUpdateDatabaseOptions {
|
|
4
5
|
from?: Structure | FieldSymbol;
|
|
5
6
|
table?: Table | FieldSymbol;
|
|
6
7
|
}
|
|
7
|
-
export declare
|
|
8
|
+
export declare class UpdateDatabase {
|
|
9
|
+
private readonly context;
|
|
10
|
+
constructor(context: Context);
|
|
11
|
+
updateDatabase(table: string | ICharacter, options: IUpdateDatabaseOptions): Promise<number>;
|
|
12
|
+
}
|
|
@@ -1,51 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UpdateDatabase = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
class UpdateDatabase {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
this.context = context;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
options.table
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
options.from
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
table
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
async updateDatabase(table, options) {
|
|
10
|
+
if (options.table instanceof types_1.FieldSymbol) {
|
|
11
|
+
options.table = options.table.getPointer();
|
|
12
|
+
}
|
|
13
|
+
if (options.from instanceof types_1.FieldSymbol) {
|
|
14
|
+
options.from = options.from.getPointer();
|
|
15
|
+
}
|
|
16
|
+
if (typeof table !== "string") {
|
|
17
|
+
table = table.get();
|
|
18
|
+
}
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const keys = abap.DDIC[table.toUpperCase()].keyFields;
|
|
21
|
+
const where = [];
|
|
22
|
+
const set = [];
|
|
23
|
+
if (options.from) {
|
|
24
|
+
const structure = options.from.get();
|
|
25
|
+
for (const k of Object.keys(structure)) {
|
|
26
|
+
// todo, integers should not be surrounded by '"'?
|
|
27
|
+
const str = k + ' = "' + structure[k].get() + '"';
|
|
28
|
+
if (keys.includes(k.toUpperCase())) {
|
|
29
|
+
where.push(str);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
set.push(str);
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
}
|
|
36
|
+
else {
|
|
37
|
+
throw "updateDatabase, todo";
|
|
38
|
+
}
|
|
39
|
+
const { subrc, dbcnt } = await this.context.defaultDB().update({ table, where: where.join(" AND "), set });
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
abap.builtin.sy.get().subrc.set(subrc);
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
abap.builtin.sy.get().dbcnt.set(dbcnt);
|
|
44
|
+
return subrc;
|
|
34
45
|
}
|
|
35
|
-
else {
|
|
36
|
-
throw "updateDatabase, todo";
|
|
37
|
-
}
|
|
38
|
-
const sql = `UPDATE ${table} SET ${set.join(", ")} WHERE ${where.join(" AND ")}`;
|
|
39
|
-
let subrc = 0;
|
|
40
|
-
try {
|
|
41
|
-
this.db.exec(sql);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
subrc = 4;
|
|
45
|
-
}
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
abap.builtin.sy.get().subrc.set(subrc);
|
|
48
|
-
return subrc;
|
|
49
46
|
}
|
|
50
|
-
exports.
|
|
47
|
+
exports.UpdateDatabase = UpdateDatabase;
|
|
51
48
|
//# sourceMappingURL=update_database.js.map
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { Context } from "../context";
|
|
1
2
|
import { FieldSymbol } from "../types/field_symbol";
|
|
2
3
|
import { ICharacter } from "../types/_character";
|
|
3
4
|
import { INumeric } from "../types/_numeric";
|
|
4
|
-
interface IWriteOptions {
|
|
5
|
+
export interface IWriteOptions {
|
|
5
6
|
newLine?: boolean;
|
|
6
7
|
skipLine?: boolean;
|
|
7
8
|
target?: ICharacter;
|
|
8
9
|
}
|
|
9
|
-
export declare
|
|
10
|
-
|
|
10
|
+
export declare class WriteStatement {
|
|
11
|
+
private readonly context;
|
|
12
|
+
constructor(context: Context);
|
|
13
|
+
write(source: INumeric | ICharacter | FieldSymbol | string | number, options?: IWriteOptions): void;
|
|
14
|
+
}
|
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WriteStatement = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
5
|
+
class WriteStatement {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
this.context = context;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
if ((options === null || options === void 0 ? void 0 : options.
|
|
11
|
-
this.console.add("\n");
|
|
12
|
-
}
|
|
13
|
-
if (typeof source === "string" || typeof source === "number") {
|
|
14
|
-
if (options === null || options === void 0 ? void 0 : options.target) {
|
|
15
|
-
options.target.set(source.toString());
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.console.add(source.toString());
|
|
19
|
-
}
|
|
9
|
+
write(source, options) {
|
|
10
|
+
if ((options === null || options === void 0 ? void 0 : options.skipLine) === true) {
|
|
11
|
+
this.context.console.add("\n");
|
|
20
12
|
}
|
|
21
13
|
else {
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.newLine) === true && this.context.console.get().length > 0) {
|
|
15
|
+
this.context.console.add("\n");
|
|
16
|
+
}
|
|
17
|
+
if (typeof source === "string" || typeof source === "number") {
|
|
18
|
+
if (options === null || options === void 0 ? void 0 : options.target) {
|
|
19
|
+
options.target.set(source.toString());
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.context.console.add(source.toString());
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
else {
|
|
30
|
-
if (
|
|
31
|
-
|
|
26
|
+
if (source instanceof types_1.Structure) {
|
|
27
|
+
const obj = source.get();
|
|
28
|
+
for (const f in obj) {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
abap.statements.write(obj[f]);
|
|
31
|
+
}
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
|
|
34
|
+
if (options === null || options === void 0 ? void 0 : options.target) {
|
|
35
|
+
options.target.set(source.get().toString());
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.context.console.add(source.get().toString());
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
|
-
exports.
|
|
45
|
+
exports.WriteStatement = WriteStatement;
|
|
41
46
|
//# sourceMappingURL=write.js.map
|
|
@@ -14,7 +14,12 @@ function templateFormatting(source, options) {
|
|
|
14
14
|
text = text.substr(0, 2) + ":" + text.substr(2, 2) + ":" + text.substr(4, 2);
|
|
15
15
|
}
|
|
16
16
|
if (options.width && options.pad) {
|
|
17
|
-
|
|
17
|
+
if (options.align === "right") {
|
|
18
|
+
text = text.trimEnd().padStart(options.width, options.pad);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
text = text.trimEnd().padEnd(options.width, options.pad);
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
else if (options.width) {
|
|
20
25
|
text = text.trimEnd().padEnd(options.width, " ");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Transpiler - Runtime",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"compile": "tsc",
|
|
13
|
+
"publish:major": "npm --no-git-tag-version version major && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
13
14
|
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
15
|
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
16
|
"test": "npm run compile && mocha"
|
|
@@ -26,9 +27,6 @@
|
|
|
26
27
|
],
|
|
27
28
|
"author": "abaplint",
|
|
28
29
|
"license": "MIT",
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"sql.js": "^1.6.2"
|
|
31
|
-
},
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"@types/chai": "^4.3.0",
|
|
34
32
|
"@types/mocha": "^9.1.0",
|