All files / src/abap/2_statements/expressions for.ts

100% Statements 16/16
100% Branches 0/0
100% Functions 1/1
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251x 1x 1x   1x   1x   1x 1x 1x 1x 1x 1x 1x   1x   1x   1x   1x    
import {seq, opt, alt, ver, plus, Expression, optPrio, altPrio} from "../combi";
import {Let, Source, InlineFieldDefinition, Cond, ComponentCond, InlineLoopDefinition, Target} from ".";
import {Version} from "../../../version";
import {IStatementRunnable} from "../statement_runnable";
import {FieldChain} from "./field_chain";
 
export class For extends Expression {
  public getRunnable(): IStatementRunnable {
    const where = seq("WHERE", ComponentCond);
    const from = seq("FROM", Source);
    const to = seq("TO", Source);
    const inn = seq(InlineLoopDefinition, optPrio(from), optPrio(to), optPrio(where));
    const then = seq("THEN", Source);
    const whil = seq(altPrio("UNTIL", "WHILE"), Cond);
    const itera = seq(InlineFieldDefinition, opt(then), whil);
 
    const groupBy = seq("GROUP BY", FieldChain);
 
    const groups = ver(Version.v740sp08, seq("GROUPS", FieldChain, "OF", Target, "IN", Source, optPrio(groupBy)));
 
    const f = seq("FOR", alt(itera, inn, groups));
 
    return ver(Version.v740sp05, plus(seq(f, optPrio(Let))));
  }
}