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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 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 21x 21x 1x 1x 13x 13x 1x 1x 1x 1x 3x 3x 1x 1x 44x 44x 1x 1x 25x 25x 1x 1x 1x 1x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 8x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 8x 21x 21x 21x 21x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 21x 21x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 21x 21x 1x 1x | import {xmlToArray} from "../../xml_utils";
export enum FunctionModuleParameterDirection {
importing = "importing",
exporting = "exporting",
changing = "changing",
tables = "tables",
}
export interface IFunctionModuleParameter {
name: string;
direction: FunctionModuleParameterDirection;
type: string | undefined;
optional: boolean;
defaultValue: string | undefined;
passByValue: boolean;
}
export enum FunctionModuleType {
regular = "regular",
remote = "remoteEnabled",
update = "update",
}
export class FunctionModuleDefinition {
private name: string;
private description: string | undefined;
private parameters: IFunctionModuleParameter[];
private globalParameters: boolean;
private moduleType: FunctionModuleType | undefined;
public constructor(data: any) {
this.parse(data);
}
public getParameters(): readonly IFunctionModuleParameter[] {
return this.parameters;
}
public getModuleType(): FunctionModuleType | undefined {
return this.moduleType;
}
public getDescription(): string | undefined {
return this.description;
}
public getName(): string {
return this.name;
}
public isGlobalParameters(): boolean {
return this.globalParameters;
}
///////////////
private parse(data: any) {
if (data.FUNCNAME === undefined) {
throw new Error("Function module name undefined");
}
this.name = data.FUNCNAME;
this.description = data.SHORT_TEXT;
this.parameters = [];
this.globalParameters = data.GLOBAL_FLAG === "X";
this.moduleType = FunctionModuleType.regular;
if (data.REMOTE_CALL === "R") {
this.moduleType = FunctionModuleType.remote;
} else if (data.UPDATE_TASK !== undefined) {
this.moduleType = FunctionModuleType.update;
}
if (data.IMPORT) {
for (const param of xmlToArray(data.IMPORT.RSIMP)) {
if (param.PARAMETER === undefined) {
throw new Error("Function module name parameter undefined, importing");
}
this.parameters.push({
name: param.PARAMETER,
direction: FunctionModuleParameterDirection.importing,
type: param.TYP || param.DBFIELD,
optional: param.OPTIONAL === "X",
defaultValue: param.DEFAULT,
passByValue: param.REFERENCE !== "X",
});
}
}
if (data.CHANGING) {
for (const param of xmlToArray(data.CHANGING.RSCHA)) {
if (param.PARAMETER === undefined) {
throw new Error("Function module name parameter undefined, changing");
}
this.parameters.push({
name: param.PARAMETER,
direction: FunctionModuleParameterDirection.changing,
type: param.TYP || param.DBFIELD,
optional: param.OPTIONAL === "X",
defaultValue: param.DEFAULT,
passByValue: param.REFERENCE !== "X",
});
}
}
if (data.EXPORT) {
for (const param of xmlToArray(data.EXPORT.RSEXP)) {
if (param.PARAMETER === undefined) {
throw new Error("Function module name parameter undefined, exporting");
}
this.parameters.push({
name: param.PARAMETER,
direction: FunctionModuleParameterDirection.exporting,
type: param.TYP || param.DBFIELD,
optional: true,
defaultValue: undefined,
passByValue: param.REFERENCE !== "X",
});
}
}
if (data.TABLES) {
for (const param of xmlToArray(data.TABLES.RSTBL)) {
if (param.PARAMETER === undefined) {
throw new Error("Function module name parameter undefined, tables");
}
this.parameters.push({
name: param.PARAMETER,
direction: FunctionModuleParameterDirection.tables,
// table types are stored in TYP
type: param.DBSTRUCT || param.TYP,
optional: param.OPTIONAL === "X",
defaultValue: undefined,
passByValue: false,
});
}
}
}
}
|