@abaplint/runtime 2.3.22 → 2.3.24

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.
@@ -1,5 +1,8 @@
1
1
  import { ICharacter } from "../types/_character";
2
- export declare function shift_left(input: {
2
+ import { INumeric } from "../types/_numeric";
3
+ export interface IShiftLeftInput {
3
4
  val: ICharacter | string;
4
- sub: ICharacter | string;
5
- }): ICharacter;
5
+ sub?: ICharacter | string;
6
+ places?: ICharacter | INumeric | string;
7
+ }
8
+ export declare function shift_left(input: IShiftLeftInput): ICharacter;
@@ -2,11 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shift_left = void 0;
4
4
  const string_1 = require("../types/string");
5
+ const throw_error_1 = require("../throw_error");
5
6
  function shift_left(input) {
6
7
  let val = typeof input.val === "string" ? input.val : input.val.get();
7
- const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
8
- while (val.startsWith(sub)) {
9
- val = val.substr(sub.length);
8
+ if (input.sub) {
9
+ const sub = typeof input.sub === "string" ? input.sub : input.sub.get();
10
+ while (val.startsWith(sub)) {
11
+ val = val.substr(sub.length);
12
+ }
13
+ }
14
+ else if (input.places) {
15
+ let places = typeof input.places === "string" ? input.places : input.places.get();
16
+ if (typeof places === "string") {
17
+ places = parseInt(places, 10);
18
+ }
19
+ if (places > val.length) {
20
+ (0, throw_error_1.throwError)("CX_SY_RANGE_OUT_OF_BOUNDS");
21
+ }
22
+ val = val.substring(places);
10
23
  }
11
24
  return new string_1.String().set(val);
12
25
  }
@@ -1,8 +1,8 @@
1
- import { DataReference, FieldSymbol, Structure } from "../types";
1
+ import { DataReference, FieldSymbol, Structure, Table } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
4
  export interface IAssignInput {
5
- source?: INumeric | ICharacter | Structure | DataReference;
5
+ source?: INumeric | ICharacter | Table | Structure | DataReference;
6
6
  target: FieldSymbol;
7
7
  dynamicName?: string;
8
8
  dynamicSource?: ICharacter;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assign = void 0;
4
4
  const types_1 = require("../types");
5
5
  function assign(input) {
6
- // console.dir(input);
6
+ var _a;
7
7
  if (input.dynamicName) {
8
8
  if (input.dynamicSource instanceof types_1.FieldSymbol) {
9
9
  input.dynamicSource = input.dynamicSource.getPointer();
@@ -58,7 +58,8 @@ function assign(input) {
58
58
  assign(input);
59
59
  return;
60
60
  }
61
- else if (!(input.source instanceof types_1.Structure)) {
61
+ else if (!(input.source instanceof types_1.Structure)
62
+ && !(input.source instanceof types_1.Table)) {
62
63
  // @ts-ignore
63
64
  abap.builtin.sy.get().subrc.set(4);
64
65
  return;
@@ -67,14 +68,27 @@ function assign(input) {
67
68
  if (typeof component !== "string") {
68
69
  component = component.get();
69
70
  }
71
+ if (input.source instanceof types_1.Table) {
72
+ if (((_a = input.source.getOptions()) === null || _a === void 0 ? void 0 : _a.withHeader) === true) {
73
+ input.source = input.source.getHeader();
74
+ }
75
+ else {
76
+ // result is the table itself, no change of input.source
77
+ }
78
+ }
70
79
  let result = undefined;
71
80
  if (typeof component === "number") {
72
- const structure_as_object = input.source.get();
73
- const keys = Object.keys(structure_as_object);
74
- const component_name = keys[(component - 1)];
75
- result = structure_as_object[component_name];
81
+ if (component === 0) {
82
+ result = input.source;
83
+ }
84
+ else if (input.source instanceof types_1.Structure) {
85
+ const structure_as_object = input.source.get();
86
+ const keys = Object.keys(structure_as_object);
87
+ const component_name = keys[component - 1];
88
+ result = structure_as_object[component_name];
89
+ }
76
90
  }
77
- else {
91
+ else if (!(input.source instanceof types_1.Table)) {
78
92
  result = input.source.get()[component.toLowerCase()];
79
93
  }
80
94
  if (result === undefined) {
@@ -16,11 +16,26 @@ function createData(target, options) {
16
16
  }
17
17
  else if (options === null || options === void 0 ? void 0 : options.name) {
18
18
  // @ts-ignore
19
- if (abap.DDIC[options.name] === undefined) {
19
+ if (abap.DDIC[options.name]) {
20
+ // @ts-ignore
21
+ target.assign((0, clone_1.clone)(abap.DDIC[options.name].type));
22
+ }
23
+ else if (options.name.includes("=>")) {
24
+ const [className, typeName] = options.name.toUpperCase().split("=>");
25
+ // @ts-ignore
26
+ if (abap.Classes[className] === undefined) {
27
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
28
+ }
29
+ // @ts-ignore
30
+ if (abap.Classes[className][typeName.toLowerCase()] === undefined) {
31
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
32
+ }
33
+ // @ts-ignore
34
+ target.assign((0, clone_1.clone)(abap.Classes[className][typeName.toLowerCase()]));
35
+ }
36
+ else {
20
37
  (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
21
38
  }
22
- // @ts-ignore
23
- target.assign((0, clone_1.clone)(abap.DDIC[options.name].type));
24
39
  }
25
40
  else if (options === null || options === void 0 ? void 0 : options.typeName) {
26
41
  switch (options.typeName) {
@@ -70,7 +85,22 @@ function createData(target, options) {
70
85
  target.assign(new types_1.XString());
71
86
  break;
72
87
  default:
73
- throw "CREATE DATA, unknown type " + options.typeName;
88
+ if (options.typeName.includes("=>")) {
89
+ const [className, typeName] = options.typeName.toUpperCase().split("=>");
90
+ // @ts-ignore
91
+ if (abap.Classes[className] === undefined) {
92
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
93
+ }
94
+ // @ts-ignore
95
+ if (abap.Classes[className][typeName.toLowerCase()] === undefined) {
96
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
97
+ }
98
+ // @ts-ignore
99
+ target.assign((0, clone_1.clone)(abap.Classes[className][typeName.toLowerCase()]));
100
+ }
101
+ else {
102
+ throw "CREATE DATA, unknown type " + options.typeName;
103
+ }
74
104
  }
75
105
  }
76
106
  else if (options === null || options === void 0 ? void 0 : options.type) {
@@ -8,7 +8,7 @@ function throwError(name) {
8
8
  throw new abap.Classes[name]();
9
9
  }
10
10
  else {
11
- throw "Global class name not found";
11
+ throw `Global class ${name} not found`;
12
12
  }
13
13
  }
14
14
  exports.throwError = throwError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",