All files / src/abap/2_statements/expressions string_template_formatting.ts

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

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    
import {seq, per, altPrio, ver, Expression} from "../combi";
import {Source} from ".";
import {IStatementRunnable} from "../statement_runnable";
import {Version} from "../../../version";
import {Dynamic} from "./dynamic";
 
export class StringTemplateFormatting extends Expression {
  public getRunnable(): IStatementRunnable {
 
    // https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapcompute_string_format_options.htm
    const alphaOptions = altPrio("OUT", "RAW", "IN", Source);
 
    const alignOptions = altPrio("LEFT", "RIGHT", "CENTER", Source);
 
    const dateTimeOptions = altPrio("RAW", "ISO", "USER", "ENVIRONMENT", Source, Dynamic);
 
    const timeStampOptions = altPrio("SPACE", "ISO", "USER", "ENVIRONMENT", Source);
 
    const numberOptions = altPrio("RAW", "USER", "ENVIRONMENT", Source);
 
    const signOptions = altPrio("LEFT", "LEFTPLUS", "LEFTSPACE", "RIGHT", "RIGHTPLUS", "RIGHTSPACE", Source);
 
    const caseOptions = altPrio("RAW", "UPPER", "LOWER", Source, Dynamic);
 
    const zeroXSDOptions = altPrio("YES", "NO", Source);
 
    const styleOptions = altPrio("SIMPLE",
                                 "SIGN_AS_POSTFIX",
                                 "SCALE_PRESERVING",
                                 "SCIENTIFIC",
                                 "SCIENTIFIC_WITH_LEADING_ZERO",
                                 "SCALE_PRESERVING_SCIENTIFIC",
                                 "ENGINEERING",
                                 Source);
 
    const width = seq("WIDTH =", Source);
    const align = seq("ALIGN =", alignOptions);
    const timezone = seq("TIMEZONE =", Source);
    const timestamp = seq("TIMESTAMP =", timeStampOptions);
    const pad = seq("PAD =", Source);
    const number = seq("NUMBER =", numberOptions);
    const sign = seq("SIGN =", signOptions);
    const decimals = seq("DECIMALS =", Source);
    const alpha = ver(Version.v740sp02, seq("ALPHA =", alphaOptions));
    const xsd = ver(Version.v740sp02, seq("XSD =", zeroXSDOptions));
 
    const formatting = altPrio(seq("TIME =", dateTimeOptions),
                               seq("DATE =", dateTimeOptions),
                               seq("CASE =", caseOptions),
                               seq("EXPONENT", Source),
                               seq("ZERO =", zeroXSDOptions),
                               xsd,
                               seq("STYLE =", styleOptions),
                               seq("CURRENCY =", Source),
                               seq("COUNTRY =", Source),
                               per(sign, number, decimals, width, pad, alpha, align),
                               per(timezone, timestamp));
 
    return formatting;
  }
}