@abaplint/runtime
Version:
Transpiler - Runtime
52 lines • 1.95 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.modifyInternal = modifyInternal;
const types_1 = require("../types");
const delete_internal_1 = require("./delete_internal");
const insert_internal_1 = require("./insert_internal");
const read_table_1 = require("./read_table");
function modifyInternal(table, options) {
let found = false;
// console.dir(options);
if (options.index) {
const index = options.index.get() - 1;
const element = table.array()[index];
found = element !== undefined;
if (found) {
element.set(options.from);
/*
table.deleteIndex(index);
table.insertIndex(options.from, index);
*/
}
}
else if (options.where && options.transporting && options.from) {
let index = 1;
const fs = new types_1.FieldSymbol();
while (index <= table.array().length) {
const currentIndex = new types_1.Integer().set(index);
const readResult = (0, read_table_1.readTable)(table, {
withKey: options.where,
assigning: fs,
index: currentIndex
});
if (readResult.subrc === 0) {
found = true;
for (const t of options.transporting) {
fs.get()[t].set(options.from.get()[t]);
}
}
index++;
}
}
else if (options.from) {
const readResult = (0, read_table_1.readTable)(table, { from: options.from });
if (readResult.subrc === 0) {
(0, delete_internal_1.deleteInternal)(table, { index: new types_1.Integer().set(readResult.foundIndex) });
}
(0, insert_internal_1.insertInternal)({ table, data: options.from });
}
const subrc = found ? 0 : 4;
abap.builtin.sy.get().subrc.set(subrc);
}
//# sourceMappingURL=modify_internal.js.map