@abaplint/core 2.91.24 → 2.91.27

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.
@@ -1866,7 +1866,10 @@ declare namespace Expressions {
1866
1866
  Language,
1867
1867
  Length,
1868
1868
  Let,
1869
+ LoopGroupByComponent,
1870
+ LoopGroupByTarget,
1869
1871
  LoopGroupBy,
1872
+ LoopTarget,
1870
1873
  MacroName,
1871
1874
  MessageClass_2 as MessageClass,
1872
1875
  MessageNumber,
@@ -1933,10 +1936,10 @@ declare namespace Expressions {
1933
1936
  SQLCompareOperator,
1934
1937
  SQLCompare,
1935
1938
  SQLCond,
1936
- SQLField,
1937
1939
  SQLFieldListLoop,
1938
1940
  SQLFieldList,
1939
1941
  SQLFieldName,
1942
+ SQLField,
1940
1943
  SQLForAllEntries,
1941
1944
  SQLFromSource,
1942
1945
  SQLFrom,
@@ -3549,6 +3552,18 @@ declare class LoopGroupBy extends Expression {
3549
3552
  getRunnable(): IStatementRunnable;
3550
3553
  }
3551
3554
 
3555
+ declare class LoopGroupByComponent extends Expression {
3556
+ getRunnable(): IStatementRunnable;
3557
+ }
3558
+
3559
+ declare class LoopGroupByTarget extends Expression {
3560
+ getRunnable(): IStatementRunnable;
3561
+ }
3562
+
3563
+ declare class LoopTarget extends Expression {
3564
+ getRunnable(): IStatementRunnable;
3565
+ }
3566
+
3552
3567
  declare class MacroName extends Expression {
3553
3568
  getRunnable(): IStatementRunnable;
3554
3569
  }
@@ -96,7 +96,10 @@ __exportStar(require("./interface_name"), exports);
96
96
  __exportStar(require("./language"), exports);
97
97
  __exportStar(require("./length"), exports);
98
98
  __exportStar(require("./let"), exports);
99
+ __exportStar(require("./loop_group_by_component"), exports);
100
+ __exportStar(require("./loop_group_by_target"), exports);
99
101
  __exportStar(require("./loop_group_by"), exports);
102
+ __exportStar(require("./loop_target"), exports);
100
103
  __exportStar(require("./macro_name"), exports);
101
104
  __exportStar(require("./message_class"), exports);
102
105
  __exportStar(require("./message_number"), exports);
@@ -163,10 +166,10 @@ __exportStar(require("./sql_client"), exports);
163
166
  __exportStar(require("./sql_compare_operator"), exports);
164
167
  __exportStar(require("./sql_compare"), exports);
165
168
  __exportStar(require("./sql_cond"), exports);
166
- __exportStar(require("./sql_field"), exports);
167
169
  __exportStar(require("./sql_field_list_loop"), exports);
168
170
  __exportStar(require("./sql_field_list"), exports);
169
171
  __exportStar(require("./sql_field_name"), exports);
172
+ __exportStar(require("./sql_field"), exports);
170
173
  __exportStar(require("./sql_for_all_entries"), exports);
171
174
  __exportStar(require("./sql_from_source"), exports);
172
175
  __exportStar(require("./sql_from"), exports);
@@ -3,18 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoopGroupBy = void 0;
4
4
  const combi_1 = require("../combi");
5
5
  const tokens_1 = require("../../1_lexer/tokens");
6
- const component_name_1 = require("./component_name");
7
- const component_compare_1 = require("./component_compare");
8
- const target_1 = require("./target");
9
- const fstarget_1 = require("./fstarget");
10
6
  const source_1 = require("./source");
7
+ const loop_group_by_target_1 = require("./loop_group_by_target");
8
+ const loop_group_by_component_1 = require("./loop_group_by_component");
11
9
  class LoopGroupBy extends combi_1.Expression {
12
10
  getRunnable() {
13
- const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", target_1.Target);
14
- const assigning = (0, combi_1.seq)("ASSIGNING", fstarget_1.FSTarget);
15
- const groupSize = (0, combi_1.seq)(component_name_1.ComponentName, "=", "GROUP SIZE");
16
- const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)((0, combi_1.alt)(component_compare_1.ComponentCompare, groupSize)), (0, combi_1.tok)(tokens_1.WParenRightW));
17
- const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), (0, combi_1.optPrio)((0, combi_1.alt)(into, assigning)));
11
+ const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(loop_group_by_component_1.LoopGroupByComponent), (0, combi_1.tok)(tokens_1.WParenRightW));
12
+ const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
18
13
  return ret;
19
14
  }
20
15
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoopGroupByComponent = void 0;
4
+ const combi_1 = require("../combi");
5
+ const component_name_1 = require("./component_name");
6
+ const component_compare_simple_1 = require("./component_compare_simple");
7
+ class LoopGroupByComponent extends combi_1.Expression {
8
+ getRunnable() {
9
+ const groupSize = (0, combi_1.seq)(component_name_1.ComponentName, "=", "GROUP SIZE");
10
+ const components = (0, combi_1.alt)(component_compare_simple_1.ComponentCompareSimple, groupSize);
11
+ return components;
12
+ }
13
+ }
14
+ exports.LoopGroupByComponent = LoopGroupByComponent;
15
+ //# sourceMappingURL=loop_group_by_component.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoopGroupByTarget = void 0;
4
+ const combi_1 = require("../combi");
5
+ const target_1 = require("./target");
6
+ const fstarget_1 = require("./fstarget");
7
+ class LoopGroupByTarget extends combi_1.Expression {
8
+ getRunnable() {
9
+ const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", target_1.Target);
10
+ const assigning = (0, combi_1.seq)("ASSIGNING", fstarget_1.FSTarget);
11
+ return (0, combi_1.optPrio)((0, combi_1.alt)(into, assigning));
12
+ }
13
+ }
14
+ exports.LoopGroupByTarget = LoopGroupByTarget;
15
+ //# sourceMappingURL=loop_group_by_target.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoopTarget = void 0;
4
+ const combi_1 = require("../combi");
5
+ const _1 = require(".");
6
+ class LoopTarget extends combi_1.Expression {
7
+ getRunnable() {
8
+ const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", _1.Target);
9
+ const assigning = (0, combi_1.seq)("ASSIGNING", _1.FSTarget);
10
+ const target = (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.alt)(into, assigning), (0, combi_1.optPrio)("CASTING")), "TRANSPORTING NO FIELDS");
11
+ return target;
12
+ }
13
+ }
14
+ exports.LoopTarget = LoopTarget;
15
+ //# sourceMappingURL=loop_target.js.map
@@ -9,14 +9,11 @@ const loop_group_by_1 = require("../expressions/loop_group_by");
9
9
  class Loop {
10
10
  getMatcher() {
11
11
  const where = (0, combi_1.seq)("WHERE", (0, combi_1.alt)(expressions_1.ComponentCond, expressions_1.Dynamic));
12
- const into = (0, combi_1.seq)((0, combi_1.opt)("REFERENCE"), "INTO", expressions_1.Target);
13
- const assigning = (0, combi_1.seq)("ASSIGNING", expressions_1.FSTarget);
14
12
  const group = (0, combi_1.ver)(version_1.Version.v740sp08, (0, combi_1.seq)("GROUP BY", loop_group_by_1.LoopGroupBy));
15
- const target = (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.alt)(into, assigning), (0, combi_1.optPrio)("CASTING")), "TRANSPORTING NO FIELDS");
16
13
  const from = (0, combi_1.seq)("FROM", expressions_1.Source);
17
14
  const to = (0, combi_1.seq)("TO", expressions_1.Source);
18
15
  const usingKey = (0, combi_1.seq)("USING KEY", (0, combi_1.altPrio)(expressions_1.SimpleName, expressions_1.Dynamic));
19
- const options = (0, combi_1.per)(target, from, to, where, usingKey, group);
16
+ const options = (0, combi_1.per)(expressions_1.LoopTarget, from, to, where, usingKey, group);
20
17
  const at = (0, combi_1.seq)("AT", (0, combi_1.opt)((0, combi_1.seq)("SCREEN", (0, combi_1.fail)())), (0, combi_1.opt)((0, combi_1.ver)(version_1.Version.v740sp08, "GROUP")), (0, combi_1.alt)(simple_source2_1.SimpleSource2, (0, combi_1.ver)(version_1.Version.v740sp02, expressions_1.Source)), (0, combi_1.opt)(options));
21
18
  return (0, combi_1.seq)("LOOP", (0, combi_1.opt)(at));
22
19
  }
@@ -24,6 +24,7 @@ class BasicTypes {
24
24
  }
25
25
  lookupQualifiedName(name) {
26
26
  var _a;
27
+ // argh, todo, rewrite this entire method
27
28
  if (name === undefined) {
28
29
  return undefined;
29
30
  }
@@ -43,6 +44,21 @@ class BasicTypes {
43
44
  }
44
45
  }
45
46
  }
47
+ else if (name.includes("-")) {
48
+ const split = name.split("-");
49
+ const typeName = split[0];
50
+ const fieldName = split[1];
51
+ const type = this.scope.findType(typeName);
52
+ if (type) {
53
+ const stru = type.getType();
54
+ if (stru instanceof basic_1.StructureType) {
55
+ const f = stru.getComponentByName(fieldName);
56
+ if (f) {
57
+ return new _typed_identifier_1.TypedIdentifier(type.getToken(), type.getFilename(), f);
58
+ }
59
+ }
60
+ }
61
+ }
46
62
  const lookup = this.scope.getDDIC().lookupNoVoid(name);
47
63
  const id = (_a = lookup === null || lookup === void 0 ? void 0 : lookup.object) === null || _a === void 0 ? void 0 : _a.getIdentifier();
48
64
  if (id && (lookup === null || lookup === void 0 ? void 0 : lookup.type)) {
@@ -193,7 +209,7 @@ class BasicTypes {
193
209
  }
194
210
  return undefined;
195
211
  }
196
- simpleType(node, noQualifiedName) {
212
+ simpleType(node, qualifiedNamePrefix) {
197
213
  let nameExpr = node.findFirstExpression(Expressions.NamespaceSimpleName);
198
214
  if (nameExpr === undefined) {
199
215
  nameExpr = node.findFirstExpression(Expressions.DefinitionName);
@@ -211,15 +227,15 @@ class BasicTypes {
211
227
  qualifiedName = name.getStr();
212
228
  }
213
229
  else {
214
- qualifiedName = name.getStr();
230
+ qualifiedName = (qualifiedNamePrefix || "") + name.getStr();
215
231
  if (this.scope.getType() === _scope_type_1.ScopeType.ClassDefinition
216
232
  || this.scope.getType() === _scope_type_1.ScopeType.Interface) {
217
233
  qualifiedName = this.scope.getName() + "=>" + qualifiedName;
218
234
  }
219
235
  }
220
236
  }
221
- if (noQualifiedName === true) {
222
- qualifiedName = undefined;
237
+ else if (qualifiedNamePrefix) {
238
+ qualifiedName = qualifiedNamePrefix + qualifiedName;
223
239
  }
224
240
  const found = this.parseType(node, qualifiedName);
225
241
  if (found) {
@@ -10,10 +10,8 @@ const target_1 = require("./target");
10
10
  class LoopGroupBy {
11
11
  runSyntax(node, scope, filename) {
12
12
  const components = [];
13
- for (const c of node.findDirectExpressions(Expressions.ComponentCompare)) {
14
- for (const f of c.findDirectExpressions(Expressions.ComponentChainSimple)) {
15
- components.push({ name: f.getFirstToken().getStr(), type: new basic_1.VoidType("todoGroupBy") });
16
- }
13
+ for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
14
+ components.push({ name: c.getFirstToken().getStr(), type: new basic_1.VoidType("todoGroupBy") });
17
15
  }
18
16
  if (components.length === 0) {
19
17
  return;
@@ -32,8 +30,10 @@ class LoopGroupBy {
32
30
  if (inlinefs) {
33
31
  new inline_fs_1.InlineFS().runSyntax(inlinefs, scope, filename, sourceType);
34
32
  }
35
- for (const t of node.findDirectExpressions(Expressions.ComponentCompare)) {
36
- new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
33
+ for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
34
+ for (const t of c.findDirectExpressions(Expressions.ComponentCompareSimple)) {
35
+ new component_compare_1.ComponentCompare().runSyntax(t, scope, filename);
36
+ }
37
37
  }
38
38
  }
39
39
  }
@@ -7,7 +7,7 @@ const Expressions = require("../../2_statements/expressions");
7
7
  const basic_1 = require("../../types/basic");
8
8
  const _scope_type_1 = require("../_scope_type");
9
9
  class TypeTable {
10
- runSyntax(node, scope, filename) {
10
+ runSyntax(node, scope, filename, qualifiedNamePrefix) {
11
11
  // todo, input is currently the statement, but should be the expression?
12
12
  let nameExpr = node.findFirstExpression(Expressions.DefinitionName);
13
13
  if (nameExpr === undefined) {
@@ -17,9 +17,9 @@ class TypeTable {
17
17
  return undefined;
18
18
  }
19
19
  const name = nameExpr.getFirstToken();
20
- let qualifiedName = "";
20
+ let qualifiedName = qualifiedNamePrefix || "";
21
21
  if (node.getFirstToken().getStr().toUpperCase() === "TYPES") {
22
- qualifiedName = name.getStr();
22
+ qualifiedName = qualifiedName + name.getStr();
23
23
  if (scope.getType() === _scope_type_1.ScopeType.ClassDefinition
24
24
  || scope.getType() === _scope_type_1.ScopeType.Interface) {
25
25
  qualifiedName = scope.getName() + "=>" + qualifiedName;
@@ -6,6 +6,7 @@ const source_1 = require("../expressions/source");
6
6
  const target_1 = require("../expressions/target");
7
7
  const basic_1 = require("../../types/basic");
8
8
  const fstarget_1 = require("../expressions/fstarget");
9
+ const inline_data_1 = require("../expressions/inline_data");
9
10
  class Append {
10
11
  runSyntax(node, scope, filename) {
11
12
  let targetType = undefined;
@@ -21,6 +22,14 @@ class Append {
21
22
  const rowType = targetType instanceof basic_1.TableType ? targetType.getRowType() : targetType;
22
23
  new fstarget_1.FSTarget().runSyntax(fsTarget, scope, filename, rowType);
23
24
  }
25
+ const dataTarget = node.findExpressionAfterToken("INTO");
26
+ if (dataTarget && node.concatTokens().toUpperCase().includes(" REFERENCE INTO DATA(")) {
27
+ if (!(targetType instanceof basic_1.TableType) && !(targetType instanceof basic_1.VoidType)) {
28
+ throw new Error("APPEND to non table type");
29
+ }
30
+ const rowType = targetType instanceof basic_1.TableType ? targetType.getRowType() : targetType;
31
+ new inline_data_1.InlineData().runSyntax(dataTarget, scope, filename, new basic_1.DataReference(rowType));
32
+ }
24
33
  let source = node.findDirectExpression(Expressions.Source);
25
34
  if (source === undefined) {
26
35
  source = node.findDirectExpression(Expressions.SimpleSource4);
@@ -14,7 +14,8 @@ const dynamic_1 = require("../expressions/dynamic");
14
14
  const loop_group_by_1 = require("../expressions/loop_group_by");
15
15
  class Loop {
16
16
  runSyntax(node, scope, filename) {
17
- let target = node.findDirectExpression(Expressions.Target);
17
+ const loopTarget = node.findDirectExpression(Expressions.LoopTarget);
18
+ let target = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.Target);
18
19
  const targetType = target ? new target_1.Target().runSyntax(target, scope, filename) : undefined;
19
20
  if (target === undefined) {
20
21
  target = node.findDirectExpression(Expressions.FSTarget);
@@ -58,7 +59,7 @@ class Loop {
58
59
  new inline_fs_1.InlineFS().runSyntax(inlinefs, scope, filename, sourceType);
59
60
  }
60
61
  else {
61
- const fstarget = node.findDirectExpression(Expressions.FSTarget);
62
+ const fstarget = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.FSTarget);
62
63
  if (fstarget) {
63
64
  new fstarget_1.FSTarget().runSyntax(fstarget, scope, filename, sourceType);
64
65
  }
@@ -7,12 +7,12 @@ const basic_1 = require("../../types/basic");
7
7
  const Expressions = require("../../2_statements/expressions");
8
8
  const type_table_1 = require("../expressions/type_table");
9
9
  class Type {
10
- runSyntax(node, scope, filename, noQualifiedName) {
10
+ runSyntax(node, scope, filename, qualifiedNamePrefix) {
11
11
  const tt = node.findFirstExpression(Expressions.TypeTable);
12
12
  if (tt) {
13
- return new type_table_1.TypeTable().runSyntax(node, scope, filename);
13
+ return new type_table_1.TypeTable().runSyntax(node, scope, filename, qualifiedNamePrefix);
14
14
  }
15
- const found = new basic_types_1.BasicTypes(filename, scope).simpleType(node, noQualifiedName);
15
+ const found = new basic_types_1.BasicTypes(filename, scope).simpleType(node, qualifiedNamePrefix);
16
16
  if (found) {
17
17
  return found;
18
18
  }
@@ -20,7 +20,7 @@ class Types {
20
20
  const ctyp = c.get();
21
21
  if (c instanceof nodes_1.StatementNode) {
22
22
  if (ctyp instanceof Statements.Type) {
23
- const found = new type_1.Type().runSyntax(c, scope, filename, true);
23
+ const found = new type_1.Type().runSyntax(c, scope, filename, name.getStr() + "-");
24
24
  if (found) {
25
25
  components.push({ name: found.getName(), type: found.getType() });
26
26
  }
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.91.24";
71
+ return "2.91.27";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Downport = exports.DownportConf = void 0;
4
+ /* eslint-disable max-len */
4
5
  const Statements = require("../abap/2_statements/statements");
5
6
  const Expressions = require("../abap/2_statements/expressions");
6
7
  const Structures = require("../abap/3_structures/structures");
@@ -208,6 +209,10 @@ Only one transformation is applied to a statement at a time, so multiple steps m
208
209
  if (found) {
209
210
  return found;
210
211
  }
212
+ found = this.downportLoopGroup(high, lowFile, highSyntax, highFile);
213
+ if (found) {
214
+ return found;
215
+ }
211
216
  found = this.callFunctionParameterSimple(high, lowFile, highSyntax);
212
217
  if (found) {
213
218
  return found;
@@ -860,6 +865,86 @@ ${indentation}RAISE EXCEPTION ${uniqueName2}.`;
860
865
  const fix = edit_helper_1.EditHelper.replaceRange(lowFile, start, end, code);
861
866
  return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, simple REF move", this.getMetadata().key, this.conf.severity, fix);
862
867
  }
868
+ downportLoopGroup(high, lowFile, highSyntax, highFile) {
869
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
870
+ if (!(high.get() instanceof Statements.Loop)) {
871
+ return undefined;
872
+ }
873
+ const group = high.findDirectExpression(Expressions.LoopGroupBy);
874
+ if (group === undefined) {
875
+ return undefined;
876
+ }
877
+ const groupTargetName = ((_a = group.findFirstExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.concatTokens()) || "nameNotFound";
878
+ const loopSourceName = ((_b = high.findFirstExpression(Expressions.SimpleSource2)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "nameNotFound";
879
+ const loopTargetName = ((_c = high.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "nameNotFound";
880
+ const groupTarget = ((_d = group.findDirectExpression(Expressions.LoopGroupByTarget)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "";
881
+ let loopSourceRowType = "typeNotFound";
882
+ const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
883
+ if (spag !== undefined) {
884
+ const found = spag.findVariable(loopSourceName);
885
+ const tt = found === null || found === void 0 ? void 0 : found.getType();
886
+ if (tt instanceof basic_1.TableType) {
887
+ loopSourceRowType = tt.getRowType().getQualifiedName() || "typeNotFound";
888
+ }
889
+ }
890
+ let code = `TYPES: BEGIN OF ${groupTargetName}type,\n`;
891
+ let condition = "";
892
+ let groupCountName = undefined;
893
+ for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
894
+ const name = c.findFirstExpression(Expressions.ComponentName);
895
+ let type = ((_e = c.findFirstExpression(Expressions.Source)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "todo";
896
+ if ((_f = c.concatTokens()) === null || _f === void 0 ? void 0 : _f.toUpperCase().endsWith(" = GROUP SIZE")) {
897
+ type = "i";
898
+ groupCountName = name === null || name === void 0 ? void 0 : name.concatTokens();
899
+ }
900
+ else {
901
+ condition += c.concatTokens();
902
+ type = type.replace(loopTargetName, loopSourceRowType);
903
+ type = type.replace("->", "-");
904
+ }
905
+ code += ` ${name === null || name === void 0 ? void 0 : name.concatTokens()} TYPE ${type},\n`;
906
+ }
907
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
908
+ const uniqueFS = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
909
+ code += ` items LIKE ${loopSourceName},
910
+ END OF ${groupTargetName}type.
911
+ DATA ${groupTargetName}tab TYPE STANDARD TABLE OF ${groupTargetName}type WITH DEFAULT KEY.
912
+ DATA ${uniqueName} LIKE LINE OF ${groupTargetName}tab.
913
+ LOOP AT ${loopSourceName} ${(_g = high.findFirstExpression(Expressions.LoopTarget)) === null || _g === void 0 ? void 0 : _g.concatTokens()}.
914
+ READ TABLE ${groupTargetName}tab ASSIGNING FIELD-SYMBOL(<${uniqueFS}>) WITH KEY ${condition}.
915
+ IF sy-subrc = 0.
916
+ <${uniqueFS}>-${groupCountName} = <${uniqueFS}>-${groupCountName} + 1.
917
+ INSERT ${loopTargetName}->* INTO TABLE <${uniqueFS}>-items.
918
+ ELSE.\n`;
919
+ for (const c of group.findAllExpressions(Expressions.LoopGroupByComponent)) {
920
+ code += ` ${uniqueName}-${c.concatTokens().replace("GROUP SIZE", "1")}.\n`;
921
+ }
922
+ code += ` INSERT ${loopTargetName}->* INTO TABLE ${uniqueName}-items.\n`;
923
+ code += ` INSERT ${uniqueName} INTO TABLE ${groupTargetName}tab.\n`;
924
+ code += `ENDIF.
925
+ ENDLOOP.
926
+ LOOP AT ${groupTargetName}tab ${groupTarget}.`;
927
+ let fix = edit_helper_1.EditHelper.replaceRange(lowFile, high.getFirstToken().getStart(), high.getLastToken().getEnd(), code);
928
+ for (const l of ((_h = highFile.getStructure()) === null || _h === void 0 ? void 0 : _h.findAllStructures(Structures.Loop)) || []) {
929
+ // make sure to find the correct/current loop statement
930
+ if (l.findDirectStatement(Statements.Loop) !== high) {
931
+ continue;
932
+ }
933
+ for (const loop of l.findAllStatements(Statements.Loop)) {
934
+ if ((_j = loop.concatTokens()) === null || _j === void 0 ? void 0 : _j.toUpperCase().startsWith("LOOP AT GROUP ")) {
935
+ const subLoopSource = loop.findFirstExpression(Expressions.SimpleSource2);
936
+ if (subLoopSource === undefined) {
937
+ continue;
938
+ }
939
+ const subLoopSourceName = (subLoopSource === null || subLoopSource === void 0 ? void 0 : subLoopSource.concatTokens()) || "nameNotFound";
940
+ const subCode = `LOOP AT ${subLoopSourceName}->items`;
941
+ const subFix = edit_helper_1.EditHelper.replaceRange(lowFile, loop.getFirstToken().getStart(), subLoopSource.getLastToken().getEnd(), subCode);
942
+ fix = edit_helper_1.EditHelper.merge(subFix, fix);
943
+ }
944
+ }
945
+ }
946
+ return issue_1.Issue.atToken(lowFile, high.getFirstToken(), "Downport, LOOP GROUP", this.getMetadata().key, this.conf.severity, fix);
947
+ }
863
948
  downportRef(high, lowFile, highSyntax) {
864
949
  let found = undefined;
865
950
  for (const s of high.findAllExpressionsRecursive(Expressions.Source)) {
@@ -1111,7 +1196,7 @@ ${indentation} output = ${topTarget}.`;
1111
1196
  return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline LOOP input", this.getMetadata().key, this.conf.severity, fix);
1112
1197
  }
1113
1198
  outlineLoopTarget(node, lowFile, _highSyntax) {
1114
- var _a, _b, _c, _d, _e;
1199
+ var _a, _b, _c, _d, _e, _f, _g;
1115
1200
  // also allows outlining of voided types
1116
1201
  if (!(node.get() instanceof Statements.Loop)) {
1117
1202
  return undefined;
@@ -1125,18 +1210,18 @@ ${indentation} output = ${topTarget}.`;
1125
1210
  return undefined;
1126
1211
  }
1127
1212
  const indentation = " ".repeat(node.getFirstToken().getStart().getCol() - 1);
1128
- const dataTarget = (_b = node.findDirectExpression(Expressions.Target)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.InlineData);
1213
+ const dataTarget = (_c = (_b = node.findDirectExpression(Expressions.LoopTarget)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.Target)) === null || _c === void 0 ? void 0 : _c.findDirectExpression(Expressions.InlineData);
1129
1214
  if (dataTarget) {
1130
- const targetName = ((_c = dataTarget.findDirectExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "DOWNPORT_ERROR";
1215
+ const targetName = ((_d = dataTarget.findDirectExpression(Expressions.TargetField)) === null || _d === void 0 ? void 0 : _d.concatTokens()) || "DOWNPORT_ERROR";
1131
1216
  const code = `DATA ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
1132
1217
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1133
1218
  const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, dataTarget.getFirstToken().getStart(), dataTarget.getLastToken().getEnd(), targetName);
1134
1219
  const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1135
1220
  return issue_1.Issue.atToken(lowFile, node.getFirstToken(), "Outline LOOP data target", this.getMetadata().key, this.conf.severity, fix);
1136
1221
  }
1137
- const fsTarget = (_d = node.findDirectExpression(Expressions.FSTarget)) === null || _d === void 0 ? void 0 : _d.findDirectExpression(Expressions.InlineFS);
1222
+ const fsTarget = (_f = (_e = node.findDirectExpression(Expressions.LoopTarget)) === null || _e === void 0 ? void 0 : _e.findDirectExpression(Expressions.FSTarget)) === null || _f === void 0 ? void 0 : _f.findDirectExpression(Expressions.InlineFS);
1138
1223
  if (fsTarget) {
1139
- const targetName = ((_e = fsTarget.findDirectExpression(Expressions.TargetFieldSymbol)) === null || _e === void 0 ? void 0 : _e.concatTokens()) || "DOWNPORT_ERROR";
1224
+ const targetName = ((_g = fsTarget.findDirectExpression(Expressions.TargetFieldSymbol)) === null || _g === void 0 ? void 0 : _g.concatTokens()) || "DOWNPORT_ERROR";
1140
1225
  const code = `FIELD-SYMBOLS ${targetName} LIKE LINE OF ${sourceName}.\n${indentation}`;
1141
1226
  const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, node.getFirstToken().getStart(), code);
1142
1227
  const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, fsTarget.getFirstToken().getStart(), fsTarget.getLastToken().getEnd(), targetName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.91.24",
3
+ "version": "2.91.27",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",