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

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

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 521x 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 1x 1x  
import {IStatement} from "./_statement";
import {seq, opt, alt, regex, per, plus, tok} from "../combi";
import {ParenLeft, ParenRightW} from "../../1_lexer/tokens";
import {Target, Source, Dynamic, ComponentChainSimple, NamespaceSimpleName, FieldSymbol} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
 
export class Import implements IStatement {
 
  public getMatcher(): IStatementRunnable {
    const dto = seq("TO", Target);
    const client = seq("CLIENT", Source);
    const id = seq("ID", Source);
    const using = seq("USING", Source);
 
    const cluster = seq(NamespaceSimpleName,
                        tok(ParenLeft),
                        regex(/^[\w$%\^]{2}$/),
                        tok(ParenRightW));
 
    const buffer = seq("DATA BUFFER", Source);
    const memory = seq("MEMORY", opt(seq("ID", Source)));
    const table = seq("INTERNAL TABLE", Source);
    const shared = seq(alt("SHARED MEMORY", "SHARED BUFFER"), cluster, per(dto, client, id));
    const database = seq("DATABASE", cluster, per(dto, client, id, using));
 
    const source = alt(buffer, memory, database, table, shared);
 
    const to = plus(seq(ComponentChainSimple, alt("TO", "INTO"), Target));
 
    const toeq = plus(seq(alt(ComponentChainSimple, FieldSymbol), "=", Target));
 
    const target = alt(toeq,
                       to,
                       Dynamic,
                       plus(Target));
 
    const options = per("ACCEPTING PADDING",
                        "IGNORING CONVERSION ERRORS",
                        "IN CHAR-TO-HEX MODE",
                        "IGNORING STRUCTURE BOUNDARIES",
                        "ACCEPTING TRUNCATION",
                        seq("REPLACEMENT CHARACTER", Source),
                        seq("CODE PAGE INTO", Source),
                        seq("ENDIAN INTO", Source));
 
    const ret = seq("IMPORT", target, "FROM", source, opt(options));
 
    return ret;
  }
 
}