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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | 1x 1x 1x 1x 1x 1x 1x 32x 32x 32x 32x 32x 32x 32x 232x 232x 32x 32x 1x 1x 1x 1x 32x 32x 100x 100x 100x 100x 100x 100x 32x 32x 1x 1x 1x 1x 1x 32x 32x 32x 32x 24x 24x 2x 2x 22x 22x 24x 18x 18x 49x 18x 18x 18x 18x 18x 49x 18x 22x 22x 22x 32x 32x 44x 13x 13x 44x 44x 44x 44x 32x 32x 79x 79x 79x 241x 463x 463x 463x 21x 21x 463x 107x 107x 107x 356x 356x 463x 14x 14x 14x 463x 241x 79x 79x 32x 32x 74x 74x 74x 92x 30x 30x 92x 44x 44x 32x 32x 40x 40x 81x 37x 37x 81x 3x 3x 32x 32x 81x 5x 5x 81x 81x 81x 81x 32x 32x 8x 8x 8x 8x 8x 32x 32x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 32x 32x 32x 32x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 39x 39x 18x 18x 18x 18x 18x 17x 17x 18x 32x 32x 2x 2x 2x 4x 2x 2x 4x 32x 32x | import {ABAPObject, ITextElements} from "./_abap_object";
import {FunctionModuleDefinition} from "../abap/types";
import {xmlToArray} from "../xml_utils";
import {XMLParser} from "fast-xml-parser";
import {ABAPFile} from "../abap/abap_file";
import {DynproList, parseDynpros} from "./_dynpros";
export class FunctionGroup extends ABAPObject {
private includes: string[] | undefined = undefined;
private modules: FunctionModuleDefinition[] | undefined = undefined;
private description: string | undefined = undefined;
private dynpros: DynproList | undefined = undefined;
public getType(): string {
return "FUGR";
}
public getDescription(): string | undefined {
if (this.description === undefined) {
this.parseXML();
}
return this.description;
}
public setDirty() {
super.setDirty();
this.includes = undefined;
this.modules = undefined;
this.description = undefined;
this.dynpros = undefined;
}
public getAllowedNaming() {
return {
maxLength: 26,
allowNamespace: true,
};
}
public getDynpros(): DynproList {
if (this.dynpros === undefined) {
this.parseXML();
}
return this.dynpros || [];
}
public getSequencedFiles(): readonly ABAPFile[] {
const main = this.getMainABAPFile();
if (main === undefined) {
return [];
}
const sequence = [main];
for (const m of this.getModules()) {
const search = "." + m.getName().toLocaleLowerCase().replace(/\//g, "#") + ".abap";
for (const f of this.getABAPFiles()) {
if (f.getFilename().toLocaleLowerCase().endsWith(search)) {
if (sequence.indexOf(f) < 0) {
sequence.push(f);
}
break;
}
}
}
return sequence;
}
public getModules(): FunctionModuleDefinition[] {
if (this.modules === undefined) {
this.parseXML();
}
if (this.modules === undefined) {
throw new Error("getIncludes, undefined");
}
return this.modules;
}
public getIncludeFiles(): {file: ABAPFile, name: string}[] {
const ret = [];
const includes = this.getIncludes();
for (const f of this.getABAPFiles()) {
for (const i of includes) {
const namespaced = i.startsWith("/") && i.includes("/L");
let search = i;
if (namespaced) {
search = search.replace(/\//g, "#");
}
if ((i.startsWith("L") || namespaced) && f.getFilename().includes(search.toLowerCase() + ".")) {
ret.push({file: f, name: i});
break;
}
// fix for URL encoded? Uris
if (namespaced) {
search = i.replace(/\//g, "%23");
if (f.getFilename().includes(search.toLowerCase() + ".")) {
ret.push({file: f, name: i});
break;
}
}
}
}
return ret;
}
public getInclude(name: string): ABAPFile | undefined {
const upper = name.toUpperCase();
const includes = this.getIncludeFiles();
for (const i of includes) {
if (i.name.toUpperCase() === upper) {
return i.file;
}
}
return undefined;
}
public getMainABAPFile(): ABAPFile | undefined {
const regex = new RegExp(/\.fugr\.(#\w+#)?sapl/, "i");
for (const f of this.getABAPFiles()) {
if (regex.test(f.getFilename())) {
return f;
}
}
return undefined;
}
public getIncludes(): string[] {
if (this.includes === undefined) {
this.parseXML();
}
if (this.includes === undefined) {
throw new Error("getIncludes, undefined");
}
return this.includes;
}
public getModule(name: string): FunctionModuleDefinition | undefined {
for (const mod of this.getModules()) {
if (mod.getName().toUpperCase() === name.toUpperCase()) {
return mod;
}
}
return undefined;
}
public getTextSymbols(): ITextElements {
if (this.texts === undefined) {
const found = this.findTextFile();
if (found === undefined) {
return {};
}
const parsed = new XMLParser({parseTagValue: false, ignoreAttributes: true, trimValues: false}).parse(found.getRaw());
this.findTexts(parsed);
}
return this.texts!["I"] ?? {};
}
/////////////////////////////////
private parseXML() {
this.includes = [];
this.modules = [];
const parsed = this.parseRaw2();
if (parsed === undefined) {
return;
}
this.description = parsed.abapGit["asx:abap"]["asx:values"]?.AREAT;
this.dynpros = parseDynpros(parsed);
// INCLUDES
const includes = parsed.abapGit["asx:abap"]["asx:values"]?.INCLUDES;
if (includes !== undefined) {
for (const i of xmlToArray(includes.SOBJ_NAME)) {
this.includes.push(i);
}
}
// FUNCTION MODULES
const functions = parsed.abapGit["asx:abap"]["asx:values"]?.FUNCTIONS;
for (const module of xmlToArray(functions?.item)) {
this.modules.push(new FunctionModuleDefinition(module));
}
}
private findTextFile() {
const name = this.getName().replace(/\//g, "#");
const regex = new RegExp(name + "\\.fugr\\.(#\\w+#)?sapl" + name.replace(/^#\w+#/, "") + "\\.xml", "i");
for (const f of this.getFiles()) {
if (regex.test(f.getFilename())) {
return f;
}
}
return undefined;
}
}
|