@abaplint/runtime
Version:
Transpiler - Runtime
66 lines • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.append = append;
const types_1 = require("../types");
function append(input) {
if (input.target instanceof types_1.FieldSymbol) {
input.target = input.target.getPointer();
if (input.target === undefined) {
throw "Field symbol not assigned";
}
}
if (input.source instanceof types_1.FieldSymbol) {
input.source = input.source.getPointer();
}
if (input.target === undefined) {
// short APPEND, use header field
if (!(input.source instanceof types_1.Table)) {
throw "APPEND, header, table";
}
input.source.append(input.source.getHeader());
// @ts-ignore
abap.builtin.sy.get().tabix.set(input.source.array().length);
return;
}
else if (input.lines === true && input.source instanceof types_1.Table) {
let from = 1;
if (input.from) {
from = parseInt(input.from.get() + "", 10);
}
let to = input.source.array().length;
if (input.to) {
to = parseInt(input.to.get() + "", 10);
}
let index = 1;
for (const a of input.source.array()) {
if (index < from || index > to) {
index++;
continue;
}
input.target.append(a);
index++;
}
}
else {
const val = input.target.append(input.source);
if (input.assigning) {
if (val instanceof types_1.FieldSymbol) {
input.assigning.assign(val.getPointer());
}
else {
input.assigning.assign(val);
}
}
else if (input.referenceInto) {
if (val instanceof types_1.FieldSymbol) {
input.referenceInto.assign(val.getPointer());
}
else {
input.referenceInto.assign(val);
}
}
}
// @ts-ignore
abap.builtin.sy.get().tabix.set(input.target.array().length);
}
//# sourceMappingURL=append.js.map