All files / src/abap/2_statements/statements create_data.ts

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

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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  1x 1x   1x   1x       31x   31x                   31x                 31x 31x 31x 31x 31x 31x   31x   31x   31x                 31x      
import {IStatement} from "./_statement";
import {seq, alt, opt, plus, ver} from "../combi";
import {Target, Source, Dynamic, Field, TypeName} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
import {Version} from "../../../version";
 
export class CreateData implements IStatement {
 
  public getMatcher(): IStatementRunnable {
// todo, similar to DATA or TYPES?
    const area = seq("AREA HANDLE", Source);
 
    const type = seq(alt("TYPE",
                         "TYPE REF TO",
                         "TYPE TABLE OF",
                         "TYPE TABLE OF REF TO",
                         "TYPE SORTED TABLE OF",
                         "TYPE HASHED TABLE OF",
                         "TYPE STANDARD TABLE OF",
                         "TYPE LINE OF"),
                     alt(TypeName, Dynamic));
 
    const like = seq(alt("LIKE",
                         "LIKE HASHED TABLE OF",
                         "LIKE LINE OF",
                         "LIKE STANDARD TABLE OF",
                         "LIKE SORTED TABLE OF",
                         "LIKE TABLE OF",
                         "TYPE HANDLE"),
                     alt(Source, Dynamic));
 
    const length = seq("LENGTH", Source);
    const initial = seq("INITIAL SIZE", Source);
    const decimals = seq("DECIMALS", Source);
    const uniq = alt("UNIQUE", "NON-UNIQUE");
    const emptyKey = ver(Version.v740sp02, "EMPTY KEY");
    const def = seq(opt(uniq), alt("DEFAULT KEY", emptyKey));
 
    const kdef = seq(opt(uniq), "KEY", alt(plus(Field), Dynamic));
 
    const key = seq("WITH", alt(def, kdef));
 
    const ret = seq("CREATE DATA",
                    Target,
                    opt(area),
                    opt(alt(type, like)),
                    opt(key),
                    opt(initial),
                    opt(length),
                    opt(decimals));
 
    return ret;
  }
 
}