All files / src/bdef/expressions bdef_define_behavior.ts

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

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 611x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {
  BDEFAction, BDEFAlias, BDEFAssociation, BDEFDetermination, BDEFDetermineAction, BDEFEvent, BDEFField, BDEFHierarchy,
  BDEFImplementationIn, BDEFKey, BDEFMapping, BDEFName, BDEFOperation, BDEFOptions, BDEFSideEffects, BDEFString, BDEFUse,
} from ".";
import {altPrio, Expression, optPrio, seq, starPrio} from "../../abap/2_statements/combi";
import {IStatementRunnable} from "../../abap/2_statements/statement_runnable";
 
/** behavior of one entity, "define behavior for ZI_Travel alias Travel ... { ... }" */
export class BDEFDefineBehavior extends Expression {
  public getRunnable(): IStatementRunnable {
    const fieldMapping = seq(BDEFName, "=", BDEFName);
    const lockMapping = seq("(", fieldMapping, starPrio(seq(",", fieldMapping)), ")");
 
    const dependentBy = seq("DEPENDENT", optPrio(seq("BY", BDEFName)));
    const save = seq(altPrio("WITH ADDITIONAL SAVE", "WITH UNMANAGED SAVE"), optPrio("AND CLEANUP"), optPrio("WITH FULL DATA"));
 
    const option = altPrio(
      BDEFAlias,
      BDEFImplementationIn,
      seq("EXTERNAL", BDEFString),
      seq("PERSISTENT TABLE", BDEFName),
      seq("DRAFT TABLE", BDEFName),
      seq("QUERY", BDEFName),
      seq("LOCK", altPrio(seq("MASTER", optPrio("UNMANAGED")), seq(dependentBy, optPrio(lockMapping)))),
      seq("AUTHORIZATION", altPrio(seq("MASTER", BDEFOptions), dependentBy)),
      seq(optPrio("TOTAL"), "ETAG", altPrio(seq("MASTER", BDEFName), dependentBy, BDEFName)),
      // eg. "( lock, authorization, etag ) dependent by _Travel"
      seq(BDEFOptions, dependentBy),
      seq(altPrio("LATE", "EARLY"), "NUMBERING", optPrio("IN PLACE")),
      save,
      "WITH CONTROL",
      "USE ETAG",
      seq("USING", BDEFName),
      seq("CHANGEDOCUMENTS", altPrio(seq("MASTER", optPrio("UTC"), optPrio(BDEFOptions)), dependentBy)),
      "EXTENSIBLE");
 
    const item = altPrio(
      BDEFUse,
      BDEFDetermineAction,
      BDEFOperation,
      BDEFAction,
      BDEFDetermination,
      BDEFField,
      BDEFAssociation,
      BDEFMapping,
      BDEFSideEffects,
      BDEFEvent,
      BDEFHierarchy,
      BDEFKey,
      seq("CHANGEDOCUMENTS", BDEFOptions, ";"),
      ";");
 
    return seq(
      altPrio(seq("DEFINE", optPrio("ROOT"), "BEHAVIOR FOR"), "EXTEND BEHAVIOR FOR"),
      BDEFName,
      starPrio(option),
      "{", starPrio(item), "}",
      optPrio(";"));
  }
}