@abaplint/runtime 1.7.14 → 1.7.18

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.
@@ -12,6 +12,7 @@ export declare class ABAP {
12
12
  FunctionModules: {};
13
13
  Classes: {};
14
14
  Interfaces: {};
15
+ DDIC: {};
15
16
  statements: Statements;
16
17
  types: typeof types;
17
18
  builtin: typeof builtin;
@@ -18,6 +18,7 @@ class ABAP {
18
18
  this.FunctionModules = {};
19
19
  this.Classes = {};
20
20
  this.Interfaces = {};
21
+ this.DDIC = {};
21
22
  this.types = types;
22
23
  this.builtin = builtin;
23
24
  this.operators = operators;
@@ -1,2 +1,6 @@
1
1
  import { DataReference } from "../types";
2
- export declare function createData(target: DataReference): void;
2
+ export interface ICreateDataOptions {
3
+ table?: boolean;
4
+ name?: string;
5
+ }
6
+ export declare function createData(target: DataReference, options?: ICreateDataOptions): void;
@@ -2,8 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createData = void 0;
4
4
  const clone_1 = require("../clone");
5
- function createData(target) {
6
- target.assign((0, clone_1.clone)(target.getType()));
5
+ function createData(target, options) {
6
+ if ((options === null || options === void 0 ? void 0 : options.name) && (options === null || options === void 0 ? void 0 : options.table)) {
7
+ // @ts-ignore
8
+ if (abap.DDIC[options.name] === undefined) {
9
+ // todo, throw exception
10
+ return;
11
+ }
12
+ // @ts-ignore
13
+ target.assign(new abap.types.Table(abap.DDIC[options.name].type));
14
+ }
15
+ else if (options === null || options === void 0 ? void 0 : options.name) {
16
+ // @ts-ignore
17
+ if (abap.DDIC[options.name] === undefined) {
18
+ // todo, throw exception
19
+ return;
20
+ }
21
+ // @ts-ignore
22
+ target.assign((0, clone_1.clone)(abap.DDIC[options.name].type));
23
+ }
24
+ else {
25
+ target.assign((0, clone_1.clone)(target.getType()));
26
+ }
7
27
  }
8
28
  exports.createData = createData;
9
29
  //# sourceMappingURL=create_data.js.map
@@ -41,6 +41,9 @@ function describe(input) {
41
41
  else if (input.field instanceof types_1.XString) {
42
42
  input.type.set("y");
43
43
  }
44
+ else if (input.field instanceof types_1.DecFloat34) {
45
+ input.type.set("e");
46
+ }
44
47
  else if (input.field instanceof types_1.Structure) {
45
48
  input.type.set("u");
46
49
  }
@@ -1,2 +1,2 @@
1
- import { Structure, Table } from "../types";
2
- export declare function select(target: Structure | Table, select: string): void;
1
+ import { FieldSymbol, Structure, Table } from "../types";
2
+ export declare function select(target: Structure | Table | FieldSymbol, select: string): void;
@@ -4,23 +4,63 @@ exports.select = void 0;
4
4
  const clone_1 = require("../clone");
5
5
  const types_1 = require("../types");
6
6
  function select(target, select) {
7
- var _a;
8
- const res = this.db.exec(select);
9
- target.clear();
10
- if (target instanceof types_1.Structure && ((_a = res[0]) === null || _a === void 0 ? void 0 : _a.values[0])) {
11
- const columns = res[0].columns;
12
- const values = res[0].values[0];
13
- const result = {};
14
- for (const c of columns) {
15
- result[c] = (0, clone_1.clone)(target.get()[c]).set(values.shift());
16
- }
17
- target.set(new types_1.Structure(result));
7
+ var _a, _b, _c;
8
+ if (this.db === undefined) {
9
+ throw new Error("Runtime, database not initialized");
10
+ }
11
+ let res = undefined;
12
+ try {
13
+ res = this.db.exec(select);
14
+ }
15
+ catch (error) {
18
16
  // @ts-ignore
19
- abap.builtin.sy.get().subrc.set(0);
17
+ if (abap.Classes["CX_SY_DYNAMIC_OSQL_SEMANTICS"] !== undefined) {
18
+ // @ts-ignore
19
+ throw new abap.Classes["CX_SY_DYNAMIC_OSQL_SEMANTICS"]();
20
+ }
21
+ throw error;
20
22
  }
21
- else if (target instanceof types_1.Structure) {
23
+ if (target instanceof types_1.FieldSymbol) {
22
24
  // @ts-ignore
23
- abap.builtin.sy.get().subrc.set(4);
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) {
30
+ // @ts-ignore
31
+ abap.builtin.sy.get().subrc.set(4);
32
+ }
33
+ else {
34
+ const columns = res[0].columns;
35
+ const values = res[0].values[0];
36
+ const result = {};
37
+ for (const c of columns) {
38
+ result[c] = (0, clone_1.clone)(target.get()[c]).set(values.shift());
39
+ }
40
+ 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
+ }
50
+ else {
51
+ for (const selectRow of res[0].values) {
52
+ const targetRow = (0, clone_1.clone)(target.getRowType());
53
+ const values = selectRow;
54
+ for (const c of res[0].columns) {
55
+ // @ts-ignore
56
+ (_c = targetRow.get()[c]) === null || _c === void 0 ? void 0 : _c.set(values.shift());
57
+ }
58
+ // @ts-ignore
59
+ abap.statements.insertInternal({ table: target, data: targetRow });
60
+ }
61
+ // @ts-ignore
62
+ abap.builtin.sy.get().subrc.set(0);
63
+ }
24
64
  }
25
65
  else {
26
66
  throw new Error("Runtime, SELECT todo");
@@ -0,0 +1,11 @@
1
+ import { Hex } from "./hex";
2
+ import { ICharacter } from "./_character";
3
+ import { INumeric } from "./_numeric";
4
+ export declare class DecFloat34 {
5
+ private value;
6
+ constructor();
7
+ set(value: INumeric | ICharacter | Hex | string | number): this;
8
+ clear(): void;
9
+ getRaw(): number;
10
+ get(): string;
11
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecFloat34 = void 0;
4
+ const _1 = require(".");
5
+ const hex_1 = require("./hex");
6
+ const xstring_1 = require("./xstring");
7
+ class DecFloat34 {
8
+ constructor() {
9
+ this.value = 0;
10
+ }
11
+ set(value) {
12
+ if (typeof value === "number") {
13
+ this.value = value;
14
+ }
15
+ else if (typeof value === "string" && value.trim().length === 0) {
16
+ this.value = 0;
17
+ }
18
+ else if (typeof value === "string") {
19
+ this.value = parseFloat(value);
20
+ }
21
+ else if (value instanceof _1.Float) {
22
+ this.value = value.getRaw();
23
+ }
24
+ else if (value instanceof hex_1.Hex || value instanceof xstring_1.XString) {
25
+ // todo, how/if should this work?
26
+ this.set(parseInt(value.get(), 16));
27
+ }
28
+ else {
29
+ this.set(value.get());
30
+ }
31
+ return this;
32
+ }
33
+ clear() {
34
+ this.value = 0;
35
+ }
36
+ getRaw() {
37
+ return this.value;
38
+ }
39
+ get() {
40
+ let text = new Number(this.value).toString();
41
+ text = text.replace(".", ",");
42
+ return text;
43
+ }
44
+ }
45
+ exports.DecFloat34 = DecFloat34;
46
+ //# sourceMappingURL=decfloat34.js.map
@@ -2,11 +2,12 @@ export * from "./abap_object";
2
2
  export * from "./character";
3
3
  export * from "./data_reference";
4
4
  export * from "./date";
5
+ export * from "./decfloat34";
5
6
  export * from "./field_symbol";
7
+ export * from "./float";
6
8
  export * from "./hex";
7
9
  export * from "./integer";
8
10
  export * from "./numc";
9
- export * from "./float";
10
11
  export * from "./packed";
11
12
  export * from "./string";
12
13
  export * from "./structure";
@@ -14,11 +14,12 @@ __exportStar(require("./abap_object"), exports);
14
14
  __exportStar(require("./character"), exports);
15
15
  __exportStar(require("./data_reference"), exports);
16
16
  __exportStar(require("./date"), exports);
17
+ __exportStar(require("./decfloat34"), exports);
17
18
  __exportStar(require("./field_symbol"), exports);
19
+ __exportStar(require("./float"), exports);
18
20
  __exportStar(require("./hex"), exports);
19
21
  __exportStar(require("./integer"), exports);
20
22
  __exportStar(require("./numc"), exports);
21
- __exportStar(require("./float"), exports);
22
23
  __exportStar(require("./packed"), exports);
23
24
  __exportStar(require("./string"), exports);
24
25
  __exportStar(require("./structure"), exports);
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@abaplint/runtime",
3
- "version": "1.7.14",
4
- "description": "Transpiler - Runtime",
5
- "main": "build/src/index.js",
6
- "typings": "build/src/index.d.ts",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/abaplint/transpiler.git"
10
- },
11
- "scripts": {
12
- "compile": "tsc",
13
- "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
- "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
- "test": "npm run compile && mocha"
16
- },
17
- "mocha": {
18
- "recursive": true,
19
- "reporter": "progress",
20
- "spec": "build/test/**/*.js",
21
- "require": "source-map-support/register"
22
- },
23
- "keywords": [
24
- "ABAP",
25
- "abaplint"
26
- ],
27
- "author": "abaplint",
28
- "license": "MIT",
29
- "dependencies": {
30
- "hdb": "^0.19.1",
31
- "sql.js": "^1.6.2"
32
- },
33
- "devDependencies": {
34
- "@types/chai": "^4.3.0",
35
- "@types/mocha": "^9.0.0",
36
- "@types/sql.js": "^1.4.3",
37
- "chai": "^4.3.4",
38
- "mocha": "^9.1.3",
39
- "source-map-support": "^0.5.21",
40
- "typescript": "^4.5.4"
41
- }
42
- }
1
+ {
2
+ "name": "@abaplint/runtime",
3
+ "version": "1.7.18",
4
+ "description": "Transpiler - Runtime",
5
+ "main": "build/src/index.js",
6
+ "typings": "build/src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/abaplint/transpiler.git"
10
+ },
11
+ "scripts": {
12
+ "compile": "tsc",
13
+ "publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
14
+ "publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
15
+ "test": "npm run compile && mocha"
16
+ },
17
+ "mocha": {
18
+ "recursive": true,
19
+ "reporter": "progress",
20
+ "spec": "build/test/**/*.js",
21
+ "require": "source-map-support/register"
22
+ },
23
+ "keywords": [
24
+ "ABAP",
25
+ "abaplint"
26
+ ],
27
+ "author": "abaplint",
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "hdb": "^0.19.1",
31
+ "sql.js": "^1.6.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/chai": "^4.3.0",
35
+ "@types/mocha": "^9.0.0",
36
+ "@types/sql.js": "^1.4.3",
37
+ "chai": "^4.3.4",
38
+ "mocha": "^9.1.4",
39
+ "source-map-support": "^0.5.21",
40
+ "typescript": "^4.5.4"
41
+ }
42
+ }