(table: string | ICharacter, options: IModifyDatabaseOptions, context: Context)
| 10 | export interface IModifyDatabaseOptions { |
| 11 | values?: Structure | FieldSymbol, |
| 12 | table?: Table | FieldSymbol, |
| 13 | } |
| 14 | |
| 15 | export async function modifyDatabase(table: string | ICharacter, options: IModifyDatabaseOptions, context: Context) { |
| 16 | if (options.table instanceof FieldSymbol) { |
| 17 | options.table = options.table.getPointer() as Table; |
| 18 | } |
| 19 | if (options.values instanceof FieldSymbol) { |
| 20 | options.values = options.values.getPointer() as Structure; |
| 21 | } |
| 22 | |
| 23 | if (options.table) { |
| 24 | let subrc = 0; |
| 25 | let dbcnt = 0; |
| 26 | for (const row of options.table.array()) { |
| 27 | const insertSubrc = await insertDatabase(table, {values: row}, context); |
| 28 | if (insertSubrc !== 0) { |
| 29 | await updateDatabase(table, {from: row}, context); |
| 30 | } |
| 31 | subrc = Math.max(subrc, abap.builtin.sy.get().subrc.get()); |
| 32 | dbcnt += abap.builtin.sy.get().dbcnt.get(); |
| 33 | } |
| 34 | abap.builtin.sy.get().subrc.set(subrc); |
| 35 | abap.builtin.sy.get().dbcnt.set(dbcnt); |
| 36 | } else if (options.values) { |
| 37 | const subrc = await insertDatabase(table, {values: options.values}, context); |
| 38 | if (subrc !== 0) { |
no test coverage detected