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

100% Statements 57/57
100% Branches 1/1
100% Functions 1/1
100% Lines 57/57

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 56 571x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x
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";
 
// todo, similar to DATA or TYPES?
export class CreateData implements IStatement {
 
  public getMatcher(): IStatementRunnable {
 
    const areaHandle = seq("AREA HANDLE", Source);
    const typeHandle = seq("TYPE 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"),
                     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 specified = seq(alt(type, like),
                          opt(key),
                          opt(initial),
                          opt(length),
                          opt(decimals));
 
    const ret = seq("CREATE DATA",
                    Target,
                    opt(alt(typeHandle, seq(opt(areaHandle), specified))));
 
    return ret;
  }
 
}