@abaplint/runtime 2.1.55 → 2.1.58
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/classic_error.d.ts +6 -0
- package/build/src/classic_error.js +11 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +2 -0
- package/build/src/statements/create_data.d.ts +0 -1
- package/build/src/statements/create_data.js +12 -28
- package/build/src/statements/replace.js +16 -22
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassicError = void 0;
|
|
4
|
+
class ClassicError extends Error {
|
|
5
|
+
constructor(input) {
|
|
6
|
+
super();
|
|
7
|
+
this.classic = input.classic;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ClassicError = ClassicError;
|
|
11
|
+
//# sourceMappingURL=classic_error.js.map
|
package/build/src/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import * as operators from "./operators";
|
|
|
11
11
|
import * as RFC from "./rfc";
|
|
12
12
|
import * as types from "./types";
|
|
13
13
|
import { expandIN } from "./expand_in";
|
|
14
|
+
import { ClassicError } from "./classic_error";
|
|
14
15
|
export { UnitTestResult, RFC, types, DB };
|
|
15
16
|
export declare class ABAP {
|
|
16
17
|
FunctionModules: {
|
|
@@ -34,6 +35,7 @@ export declare class ABAP {
|
|
|
34
35
|
OffsetLength: typeof OffsetLength;
|
|
35
36
|
templateFormatting: typeof templateFormatting;
|
|
36
37
|
expandIN: typeof expandIN;
|
|
38
|
+
ClassicError: typeof ClassicError;
|
|
37
39
|
readonly context: Context;
|
|
38
40
|
constructor();
|
|
39
41
|
}
|
package/build/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.RFC = RFC;
|
|
|
18
18
|
const types = require("./types");
|
|
19
19
|
exports.types = types;
|
|
20
20
|
const expand_in_1 = require("./expand_in");
|
|
21
|
+
const classic_error_1 = require("./classic_error");
|
|
21
22
|
class ABAP {
|
|
22
23
|
constructor() {
|
|
23
24
|
// global objects
|
|
@@ -32,6 +33,7 @@ class ABAP {
|
|
|
32
33
|
this.OffsetLength = offset_length_1.OffsetLength;
|
|
33
34
|
this.templateFormatting = template_formatting_1.templateFormatting;
|
|
34
35
|
this.expandIN = expand_in_1.expandIN;
|
|
36
|
+
this.ClassicError = classic_error_1.ClassicError;
|
|
35
37
|
this.context = new context_1.Context();
|
|
36
38
|
this.console = new console_1.Console();
|
|
37
39
|
this.context.console = this.console;
|
|
@@ -3,46 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createData = void 0;
|
|
4
4
|
const clone_1 = require("../clone");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
+
function throwGlobalException(name) {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
if (abap.Classes[name] !== undefined) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
throw new abap.Classes[name]();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
throw `Global class ${name} not found`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
6
16
|
function createData(target, options) {
|
|
7
17
|
// console.dir(options);
|
|
8
18
|
if ((options === null || options === void 0 ? void 0 : options.name) && (options === null || options === void 0 ? void 0 : options.table)) {
|
|
9
19
|
// @ts-ignore
|
|
10
20
|
if (abap.DDIC[options.name] === undefined) {
|
|
11
|
-
|
|
12
|
-
return;
|
|
21
|
+
throwGlobalException("CX_SY_CREATE_DATA_ERROR");
|
|
13
22
|
}
|
|
14
23
|
// @ts-ignore
|
|
15
24
|
target.assign(new abap.types.Table(abap.DDIC[options.name].type));
|
|
16
25
|
}
|
|
17
|
-
else if (options === null || options === void 0 ? void 0 : options.typeHandle) {
|
|
18
|
-
switch (options.typeHandle.get().type_kind.get()) {
|
|
19
|
-
case "F":
|
|
20
|
-
target.assign(new types_1.Float());
|
|
21
|
-
break;
|
|
22
|
-
case "I":
|
|
23
|
-
target.assign(new types_1.Integer());
|
|
24
|
-
break;
|
|
25
|
-
case "D":
|
|
26
|
-
target.assign(new types_1.Date());
|
|
27
|
-
break;
|
|
28
|
-
case "T":
|
|
29
|
-
target.assign(new types_1.Time());
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
throw "CREATE DATA, unknown handle type";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
26
|
else if (options === null || options === void 0 ? void 0 : options.name) {
|
|
36
27
|
// @ts-ignore
|
|
37
28
|
if (abap.DDIC[options.name] === undefined) {
|
|
38
|
-
|
|
39
|
-
if (abap.Classes["CX_SY_CREATE_DATA_ERROR"] !== undefined) {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
throw new abap.Classes["CX_SY_CREATE_DATA_ERROR"]();
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
throw "Global class CX_SY_CREATE_DATA_ERROR not found";
|
|
45
|
-
}
|
|
29
|
+
throwGlobalException("CX_SY_CREATE_DATA_ERROR");
|
|
46
30
|
}
|
|
47
31
|
// @ts-ignore
|
|
48
32
|
target.assign((0, clone_1.clone)(abap.DDIC[options.name].type));
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replace = void 0;
|
|
4
|
+
function escapeRegExp(text) {
|
|
5
|
+
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
6
|
+
}
|
|
4
7
|
function replace(input) {
|
|
5
8
|
let temp = input.target.get();
|
|
6
9
|
const ignoreCase = input.ignoringCase === true ? "i" : "";
|
|
7
|
-
|
|
10
|
+
const allOccurrences = input.all === true ? "g" : "";
|
|
11
|
+
let search = undefined;
|
|
8
12
|
let found = false;
|
|
9
13
|
if (input.of) {
|
|
10
|
-
|
|
11
|
-
if (
|
|
14
|
+
let inp = input.of.get();
|
|
15
|
+
if (inp.length === 0 && input.all === true) {
|
|
12
16
|
throw "REPLACE, zero length input";
|
|
13
17
|
}
|
|
14
|
-
found = temp.indexOf(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
+
found = temp.indexOf(inp) >= 0;
|
|
19
|
+
inp = escapeRegExp(inp);
|
|
20
|
+
search = new RegExp(inp, ignoreCase + allOccurrences);
|
|
18
21
|
}
|
|
19
22
|
else if (input.regex) {
|
|
20
23
|
if (input.regex.get().length === 0 && input.all === true) {
|
|
21
24
|
throw "REPLACE, zero length input";
|
|
22
25
|
}
|
|
23
|
-
found = temp.match(
|
|
24
|
-
search = new RegExp(input.regex.get(), ignoreCase);
|
|
26
|
+
found = temp.match(input.regex.get()) !== null;
|
|
27
|
+
search = new RegExp(input.regex.get(), ignoreCase + allOccurrences);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw "REPLACE, unexpected input";
|
|
25
31
|
}
|
|
26
32
|
let replace = "";
|
|
27
33
|
if (typeof input.with === "string") {
|
|
@@ -33,19 +39,7 @@ function replace(input) {
|
|
|
33
39
|
replace = replace.replace(/\\\{/g, "{");
|
|
34
40
|
replace = replace.replace(/\\\}/g, "}");
|
|
35
41
|
}
|
|
36
|
-
|
|
37
|
-
if (input.regex) {
|
|
38
|
-
temp = temp.replace(new RegExp(input.regex.get(), "g" + ignoreCase), replace);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
while (temp.replace(search, replace) !== temp) {
|
|
42
|
-
temp = temp.replace(search, replace);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
temp = temp.replace(search, replace);
|
|
48
|
-
}
|
|
42
|
+
temp = temp.replace(search, replace);
|
|
49
43
|
const subrc = found ? 0 : 4;
|
|
50
44
|
// @ts-ignore
|
|
51
45
|
abap.builtin.sy.get().subrc.set(subrc);
|