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

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

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 57 58 59 60 61 62 631x 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 3x 3x 3x 3x 3x 3x 1x 1x  
import {IStatement} from "./_statement";
import {alt, altPrio, opt, optPrio, per, plus, plusPrio, seq, ver, AlsoIn} from "../combi";
import {EMLEntityPath, EntityAssociation, NamespaceSimpleName, SimpleName, Source, Target} from "../expressions";
import {IStatementRunnable} from "../statement_runnable";
import {Release} from "../../../version";
 
export class ModifyEntities implements IStatement {
 
  public getMatcher(): IStatementRunnable {
    const withh = seq("WITH", Source);
    const fieldsWith = seq("FIELDS (", plus(SimpleName), ")", withh);
    const by = seq("BY", EMLEntityPath);
    const relating = seq("RELATING TO", NamespaceSimpleName, "BY", NamespaceSimpleName);
 
    const execute = seq("EXECUTE", NamespaceSimpleName, "FROM", Source);
    const create = seq("CREATE", opt(by), "FROM", Source, opt(relating));
    const updateFrom = seq("UPDATE FROM", Source, opt(relating));
    const deleteFrom = seq("DELETE FROM", Source);
    const updateFields = seq("UPDATE", fieldsWith);
    const updateSetFields = seq("UPDATE SET FIELDS WITH", Source);
 
    const operation = alt(
      updateSetFields,
      seq("CREATE SET FIELDS WITH", Source),
      updateFields,
      deleteFrom,
      updateFrom,
      create,
      execute,
      seq("CREATE", opt(by), optPrio("AUTO FILL CID"), altPrio(withh, fieldsWith)));
 
    const failed = seq("FAILED", Target);
    const result = seq("RESULT", Target);
    const mapped = seq("MAPPED", Target);
    const reported = seq("REPORTED", Target);
 
    const end = optPrio(per(failed,
                            result,
                            mapped,
                            reported));
 
    const entities = seq(optPrio("AUGMENTING"), "ENTITIES OF", NamespaceSimpleName,
                         opt("IN LOCAL MODE"),
                         plusPrio(seq("ENTITY", NamespaceSimpleName, plus(operation))));
 
    const dynamic = seq("ENTITIES",
                        optPrio(altPrio("IN LOCAL MODE", seq(opt("FORWARDING"), "PRIVILEGED"))),
                        "OPERATIONS", Source);
 
    const create2 = seq("CREATE", fieldsWith, opt(seq("CREATE BY", EMLEntityPath, fieldsWith)));
    const create3 = seq("CREATE BY", EMLEntityPath, fieldsWith);
    const create4 = seq("CREATE FROM", Source, plus(seq("CREATE BY", EMLEntityPath, "FROM", Source)));
 
    const entity = seq("ENTITY",
                       opt("IN LOCAL MODE"),
                       alt(NamespaceSimpleName, EntityAssociation),
                       alt(execute, create, updateFields, deleteFrom, updateSetFields, updateFrom, create2, create3, create4));
 
    return ver(Release.v754, seq("MODIFY", alt(entities, dynamic, entity), end), {also: AlsoIn.OpenABAP});
  }
 
}