From eaf885429fa6a58d2fa3fd65ce028437ec14d969 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 23:42:18 +0000 Subject: [PATCH 1/5] Honor UPSTREAM_HEAD in mirror-core + draft retention for z2ui5_t_01 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mirror-core.js now fetches the sha announced in UPSTREAM_HEAD and mirrors it when it is newer than the cloned default-branch HEAD (the fast-double- push race that let announced and built commit diverge). A stale slot — trigger_cap upstream is manual, so the slot lags — no longer pins the nightly to an old core: the newer commit wins, unfetchable shas fall back to HEAD with a warning. Also refreshes run/input/core to upstream 70d176d. The CDS draft store was append-only with no cleanup, so z2ui5_t_01 grew without bound in production. z2ui5_t_01 rows now carry a managed createdAt; srv/draft-retention.js deletes rows older than Z2UI5_DRAFT_TTL_HOURS (default 24h, 0 disables) once at startup and hourly (unref'd timer). Covered by two new jest tests (13 total, all green). Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RXSCVM7CSVZ3Yo9eM4cG6d --- run/input/UPSTREAM_COMMIT | 2 +- .../srv/app/samples/z2ui5_cl_demo_app_028.js | 2 +- .../srv/app/samples/z2ui5_cl_demo_app_078.js | 2 +- .../srv/app/samples/z2ui5_cl_demo_app_160.js | 2 +- .../srv/app/samples/z2ui5_cl_demo_app_294.js | 8 +- .../srv/app/samples/z2ui5_cl_demo_app_306.js | 4 +- .../app/samples/z2ui5_cl_sample_app_001.js | 2 +- .../app/samples/z2ui5_cl_sample_context.js | 8 +- .../srv/z2ui5/00/03/z2ui5_cl_a2ui5_context.js | 4 +- .../core/srv/z2ui5/99/01/z2ui5_cl_util_db.js | 81 - .../core/srv/z2ui5/99/01/z2ui5_cl_util_ext.js | 3328 ----------------- .../srv/z2ui5/99/01/z2ui5_cl_util_http.js | 229 -- .../core/srv/z2ui5/99/01/z2ui5_cl_util_log.js | 105 - .../core/srv/z2ui5/99/01/z2ui5_cl_util_msg.js | 534 --- .../srv/z2ui5/99/01/z2ui5_cl_util_range.js | 157 - .../core/srv/z2ui5/99/01/z2ui5_cl_util_xml.js | 175 - .../srv/z2ui5/99/01/z2ui5_cx_util_error.js | 39 - .../core/srv/z2ui5/99/z2ui5_cl_xml_view_cc.js | 215 -- scripts/mirror-core.js | 32 + src/db/schema.cds | 7 +- src/srv/draft-retention.js | 41 + src/srv/server.js | 7 +- src/test/draft-retention.test.js | 43 + 23 files changed, 143 insertions(+), 4884 deletions(-) delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_db.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_ext.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_http.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_log.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_msg.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_range.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_xml.js delete mode 100644 run/input/core/srv/z2ui5/99/01/z2ui5_cx_util_error.js delete mode 100644 run/input/core/srv/z2ui5/99/z2ui5_cl_xml_view_cc.js create mode 100644 src/srv/draft-retention.js create mode 100644 src/test/draft-retention.test.js diff --git a/run/input/UPSTREAM_COMMIT b/run/input/UPSTREAM_COMMIT index 20383ba..6dbb3d6 100644 --- a/run/input/UPSTREAM_COMMIT +++ b/run/input/UPSTREAM_COMMIT @@ -1 +1 @@ -05e318be47a390220eda080a38bc48b5f7fc2e46 +70d176d1e9030ac11f982815cc5f1d6d38088850 diff --git a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_028.js b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_028.js index b163214..aee9600 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_028.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_028.js @@ -26,7 +26,7 @@ class z2ui5_cl_demo_app_028 extends z2ui5_if_app { on_event() { this.counter = this.counter + 1; - this.t_tab.push({ title: `entry${this.counter}`, info: `completed`, descr: `this is a description`, icon: `sap-icon://account` }); + this.t_tab.push({ title: `entry${this.counter}`, info: `completed`, descr: `this is a description`, icon: `sap-icon://account`, value: ``, checkbox: false }); if (this.counter < 3) { this.start_timer(); } else { diff --git a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_078.js b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_078.js index 0aebf8e..3ebd1a3 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_078.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_078.js @@ -39,7 +39,7 @@ class z2ui5_cl_demo_app_078 extends z2ui5_if_app { sy_tabix = 0; for (const ls_token of this.mt_tokens_added) { sy_tabix++; - this.mt_token.push({ key: ls_token.key, text: ls_token.text, visible: true, editable: true }); + this.mt_token.push({ key: ls_token.key, text: ls_token.text, visible: true, editable: true, selkz: false }); } this.mt_tokens_removed = {}; this.mt_tokens_added = {}; diff --git a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_160.js b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_160.js index a82426e..5c9a619 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_160.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_160.js @@ -20,7 +20,7 @@ class z2ui5_cl_demo_app_160 extends z2ui5_if_app { model_init() { this.mt_output = {}; for (let sy_index = 1; sy_index <= 10; sy_index++) { - this.mt_output.push({ index: sy_index, set_sk: `Test`, matnr: `1234567`, description: `Test`, pl_01: 0, pl_02: 0 }); + this.mt_output.push({ index: sy_index, set_sk: `Test`, matnr: `1234567`, description: `Test`, pl_01: 0, pl_02: 0, is_total: 0, pl_total: 0, per_cent_total: 0, is_01_prev: 0, per_cent_01: 0, is_02_prev: 0, per_cent_02: 0, is_03_prev: 0, pl_03: 0, per_cent_03: 0, is_q01_prev: 0, pl_q01: 0, per_cent_q01: 0, is_q02_prev: 0, pl_q02: 0, per_cent_q02: 0, is_q03_prev: 0, pl_q03: 0, per_cent_q03: 0, is_q04_prev: 0, pl_q04: 0, per_cent_q04: 0 }); } } diff --git a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_294.js b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_294.js index 2a758ea..37bb7d2 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_294.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_294.js @@ -50,11 +50,11 @@ class z2ui5_cl_demo_app_294 extends z2ui5_if_app { this.s_text = {}; this.lt_a_data = {}; this.s_text = `DatePicker with valueState `; - this.lt_a_data.push({ label: this.s_text + `None`, value_state: `None` }); - this.lt_a_data.push({ label: this.s_text + `Information`, value_state: `Information` }); - this.lt_a_data.push({ label: this.s_text + `Success`, value_state: `Success` }); + this.lt_a_data.push({ label: this.s_text + `None`, value_state: `None`, value_state_text: `` }); + this.lt_a_data.push({ label: this.s_text + `Information`, value_state: `Information`, value_state_text: `` }); + this.lt_a_data.push({ label: this.s_text + `Success`, value_state: `Success`, value_state_text: `` }); this.lt_a_data.push({ label: this.s_text + `Warning and long valueStateText`, value_state: `Warning`, value_state_text: `Warning message. This is an extra long text used as a warning message. ` + `It illustrates how the text wraps into two or more lines without truncation to show the full length of the message.` }); - this.lt_a_data.push({ label: this.s_text + `Error`, value_state: `Error` }); + this.lt_a_data.push({ label: this.s_text + `Error`, value_state: `Error`, value_state_text: `` }); } } diff --git a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_306.js b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_306.js index e2f9f45..c39fdf4 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_demo_app_306.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_demo_app_306.js @@ -59,7 +59,7 @@ class z2ui5_cl_demo_app_306 extends z2ui5_if_app { } switch (client.get().EVENT) { case `CAPTURE`: - this.mt_picture.push({ data: this.mv_picture_base, thumbnail: this.mv_picture_thumb, time: sy_uzeit }); + this.mt_picture.push({ data: this.mv_picture_base, thumbnail: this.mv_picture_thumb, time: sy_uzeit, id: ``, name: ``, selected: false }); this.mv_picture_base = {}; this.mv_picture_thumb = {}; client.view_model_update(); @@ -88,7 +88,7 @@ class z2ui5_cl_demo_app_306 extends z2ui5_if_app { sy_tabix = 0; for (const ls_pic of this.mt_picture) { sy_tabix++; - this.mt_picture_out.push({ name: `picture ${sy_tabix}`, id: sy_tabix, thumbnail: ls_pic.thumbnail, selected: (sy_tabix === this.selected_picture.id ? true : null) }); + this.mt_picture_out.push({ name: `picture ${sy_tabix}`, id: sy_tabix, thumbnail: ls_pic.thumbnail, selected: (sy_tabix === this.selected_picture.id ? true : null), time: ``, data: `` }); } } diff --git a/run/input/core/srv/app/samples/z2ui5_cl_sample_app_001.js b/run/input/core/srv/app/samples/z2ui5_cl_sample_app_001.js index d0ddf3d..9905e70 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_sample_app_001.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_sample_app_001.js @@ -129,7 +129,7 @@ class z2ui5_cl_sample_app_001 extends z2ui5_if_app { _fs$fs_block = sy_subrc === 0 ? { o: _t, k: _i } : null; } if (sy_subrc !== 0) { - fs_block = { group: tile.group, base: base }; + fs_block = { group: tile.group, base: base, width: 0 }; result.push(fs_block); } width = this.header_width({ header: tile.header }); diff --git a/run/input/core/srv/app/samples/z2ui5_cl_sample_context.js b/run/input/core/srv/app/samples/z2ui5_cl_sample_context.js index a09676a..72ee789 100644 --- a/run/input/core/srv/app/samples/z2ui5_cl_sample_context.js +++ b/run/input/core/srv/app/samples/z2ui5_cl_sample_context.js @@ -158,7 +158,7 @@ class z2ui5_cl_sample_context { sy_tabix = 0; for (const lr_comp of z2ui5_cl_sample_context.rtti_get_t_attri_by_any({ val: val })) { sy_tabix++; - result.push({ name: lr_comp.name }); + result.push({ name: lr_comp.name, t_range: [], t_token: [], t_token_added: [], t_token_removed: [] }); } return result; } @@ -239,7 +239,7 @@ class z2ui5_cl_sample_context { lv_value = lt_mapping.find((row) => row.n === lr_row.option).v; // TODO(abap2js): REPLACE `{LOW}` IN lv_value WITH lr_row->low. // TODO(abap2js): REPLACE `{HIGH}` IN lv_value WITH lr_row->high. - result.push({ key: lv_value, text: lv_value, visible: true, editable: true }); + result.push({ key: lv_value, text: lv_value, visible: true, editable: true, selkz: false }); } return result; } @@ -900,7 +900,7 @@ class z2ui5_cl_sample_context { if (names.some((row) => row.table_line === lr_comp.name)) { lv_check_key = true; } - result.push({ fieldname: lr_comp.name, rollname: lr_comp.name, keyflag: lv_check_key, scrtext_s: lr_comp.name, scrtext_m: lr_comp.name, scrtext_l: lr_comp.name }); + result.push({ fieldname: lr_comp.name, rollname: lr_comp.name, keyflag: lv_check_key, scrtext_s: lr_comp.name, scrtext_m: lr_comp.name, scrtext_l: lr_comp.name, tabname: ``, langu: ``, position: ``, offset: ``, domname: ``, checktable: ``, leng: ``, intlen: ``, outputlen: ``, decimals: ``, datatype: ``, inttype: ``, reftable: ``, reffield: ``, precfield: ``, authorid: ``, memoryid: ``, logflag: ``, mask: ``, masklen: ``, convexit: ``, headlen: ``, scrlen1: ``, scrlen2: ``, scrlen3: ``, fieldtext: ``, reptext: ``, lowercase: ``, mac: ``, genkey: ``, noforkey: ``, valexi: ``, noauthch: ``, sign: ``, dynpfld: ``, f4availabl: ``, comptype: ``, lfieldname: ``, ltrflddis: ``, bidictrlc: ``, outputstyle: ``, nohistory: ``, ampmformat: `` }); } return result; } @@ -1022,7 +1022,7 @@ class z2ui5_cl_sample_context { break; default: if (z2ui5_cl_sample_context.rtti_check_clike({ val: val })) { - result.push({ text: val }); + result.push({ text: val, id: ``, no: ``, type: ``, v1: ``, v2: ``, v3: ``, v4: ``, timestampl: null, t_meta: [] }); } break; } diff --git a/run/input/core/srv/z2ui5/00/03/z2ui5_cl_a2ui5_context.js b/run/input/core/srv/z2ui5/00/03/z2ui5_cl_a2ui5_context.js index 1735e1f..75aeed7 100644 --- a/run/input/core/srv/z2ui5/00/03/z2ui5_cl_a2ui5_context.js +++ b/run/input/core/srv/z2ui5/00/03/z2ui5_cl_a2ui5_context.js @@ -213,7 +213,7 @@ class z2ui5_cl_a2ui5_context { lv_value = lt_mapping.find((row) => row.n === lr_row.option).v; // TODO(abap2js): REPLACE `{LOW}` IN lv_value WITH lr_row->low. // TODO(abap2js): REPLACE `{HIGH}` IN lv_value WITH lr_row->high. - result.push({ key: lv_value, text: lv_value, visible: true, editable: true }); + result.push({ key: lv_value, text: lv_value, visible: true, editable: true, selkz: false }); } return result; } @@ -1115,7 +1115,7 @@ class z2ui5_cl_a2ui5_context { break; default: if (z2ui5_cl_a2ui5_context.rtti_check_clike({ val: val })) { - result.push({ text: val }); + result.push({ text: val, id: ``, no: ``, type: ``, v1: ``, v2: ``, v3: ``, v4: ``, timestampl: null, t_meta: [] }); } break; } diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_db.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_db.js deleted file mode 100644 index e7cdcb3..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_db.js +++ /dev/null @@ -1,81 +0,0 @@ -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); -const z2ui5_cx_util_error = require("abap2UI5/z2ui5_cx_util_error"); -const z2ui5_port = require("abap2UI5/z2ui5_port"); - -class z2ui5_cl_util_db { - static delete_by_handle({ uname, handle, handle2, handle3, check_commit = true } = {}) { - z2ui5_port.db({ op: `delete`, table: `z2ui5_t_91`, where: [{ field: `uname`, op: `eq`, value: uname }, { field: `handle`, op: `eq`, value: handle }, { field: `handle2`, op: `eq`, value: handle2 }, { field: `handle3`, op: `eq`, value: handle3 }] }); - sy_subrc = z2ui5_port.sy_subrc; - if ((check_commit === true || check_commit === `X`)) { - z2ui5_port.db({ op: `commit` }); - } - } - - static load_by_handle({ uname, handle, handle2, handle3 } = {}) { - let sy_subrc = 0; - let lv_data = z2ui5_port.db({ op: `select_single`, table: `z2ui5_t_91`, fields: [`data`], where: [{ field: `uname`, op: `eq`, value: uname }, { field: `handle`, op: `eq`, value: handle }, { field: `handle2`, op: `eq`, value: handle2 }, { field: `handle3`, op: `eq`, value: handle3 }], single_field: true }); - sy_subrc = z2ui5_port.sy_subrc; - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `NO_ENTRY_FOR_HANDLE_EXISTS` }); - } - // TODO(abap2js): z2ui5_cl_util=>xml_parse( EXPORTING xml = lv_data IMPORTING any = result ). - } - - static load_multi_by_handle({ uname, handle, handle2, handle3 } = {}) { - let result = []; - let lr_uname = []; - let lr_handle = []; - let lr_handle2 = []; - let lr_handle3 = []; - if (uname !== undefined) { - lr_uname = [{ sign: `I`, option: `EQ`, low: uname }]; - } - if (handle !== undefined) { - lr_handle = [{ sign: `I`, option: `EQ`, low: handle }]; - } - if (handle2 !== undefined) { - lr_handle2 = [{ sign: `I`, option: `EQ`, low: handle2 }]; - } - if (handle3 !== undefined) { - lr_handle3 = [{ sign: `I`, option: `EQ`, low: handle3 }]; - } - result = z2ui5_port.db({ op: `select_table`, table: `z2ui5_t_91`, fields: [], where: [{ field: `uname`, op: `in`, value: lr_uname }, { field: `handle`, op: `in`, value: lr_handle }, { field: `handle2`, op: `in`, value: lr_handle2 }, { field: `handle3`, op: `in`, value: lr_handle3 }] }); - sy_subrc = z2ui5_port.sy_subrc; - return result; - } - - static load_by_id({ id } = {}) { - let sy_subrc = 0; - let lv_data = z2ui5_port.db({ op: `select_single`, table: `z2ui5_t_91`, fields: [`data`], where: [{ field: `id`, op: `eq`, value: id }], single_field: true }); - sy_subrc = z2ui5_port.sy_subrc; - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `NO_ENTRY_FOR_ID_EXISTS: ${id}` }); - } - // TODO(abap2js): z2ui5_cl_util=>xml_parse( EXPORTING xml = lv_data IMPORTING any = result ). - } - - static save({ uname, handle, handle2, handle3, data, check_commit = true } = {}) { - let result = ``; - let sy_subrc = 0; - let lv_id = z2ui5_port.db({ op: `select_single`, table: `z2ui5_t_91`, fields: [`id`], where: [{ field: `uname`, op: `eq`, value: uname }, { field: `handle`, op: `eq`, value: handle }, { field: `handle2`, op: `eq`, value: handle2 }, { field: `handle3`, op: `eq`, value: handle3 }], single_field: true }); - sy_subrc = z2ui5_port.sy_subrc; - const ls_db = { uname: uname, handle: handle, handle2: handle2, handle3: handle3, data: z2ui5_cl_util.xml_stringify(data) }; - if (lv_id) { - ls_db.id = z2ui5_cl_util.abap_copy(lv_id); - } else { - ls_db.id = z2ui5_cl_util.uuid_get_c32(); - } - z2ui5_port.db({ op: `modify`, table: `z2ui5_t_91`, row: ls_db }); - sy_subrc = z2ui5_port.sy_subrc; - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `DB_SAVE_FAILED` }); - } - if ((check_commit === true || check_commit === `X`)) { - z2ui5_port.db({ op: `commit` }); - } - result = z2ui5_cl_util.abap_copy(ls_db.id); - return result; - } -} - -module.exports = z2ui5_cl_util_db; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_ext.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_ext.js deleted file mode 100644 index dcf8cdf..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_ext.js +++ /dev/null @@ -1,3328 +0,0 @@ -const cl_abap_datadescr = require("abap2UI5/cl_abap_datadescr"); -const cl_abap_structdescr = require("abap2UI5/cl_abap_structdescr"); -const cl_abap_tabledescr = require("abap2UI5/cl_abap_tabledescr"); -const cl_abap_typedescr = require("abap2UI5/cl_abap_typedescr"); -const cx_sy_dyn_call_illegal_class = require("abap2UI5/cx_sy_dyn_call_illegal_class"); -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); -const z2ui5_cx_util_error = require("abap2UI5/z2ui5_cx_util_error"); -const z2ui5_port = require("abap2UI5/z2ui5_port"); - -class z2ui5_cl_util_ext { - static rtti_get_class_descr_on_cloud({ i_classname } = {}) { - let result = ``; - let obj = null; - let content = null; - let lv_classname = ``; - let xco_cp_abap = ``; - lv_classname = z2ui5_cl_util.abap_copy(i_classname); - xco_cp_abap = `XCO_CP_ABAP`; - // TODO(abap2js): CALL METHOD (xco_cp_abap)=>(`CLASS`) EXPORTING iv_name = lv_classname RECEIVING ro_class = obj. - // TODO(abap2js): CALL METHOD obj->(`IF_XCO_AO_CLASS~CONTENT`) RECEIVING ro_content = content. - // TODO(abap2js): CALL METHOD content->(`IF_XCO_CLAS_CONTENT~GET_SHORT_DESCRIPTION`) RECEIVING rv_short_description = result. - return result; - } - - static rtti_get_t_attri_on_prem({ tabname } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_dfies = null; - let _fs$fs_dfies = null; - let fs_value = null; - let _fs$fs_value = null; - let fs_value_dest = null; - let _fs$fs_value_dest = null; - let structdescr = null; - let dfies = null; - let s_dfies = {}; - let temp9 = []; - let comps = null; - let temp10 = null; - let lo_struct = null; - let new_struct_desc = null; - let new_table_desc = null; - let comp = null; - comps = z2ui5_cl_util.abap_copy(temp9); - temp10 = cl_abap_structdescr.describe_by_name(`DFIES`); - lo_struct = z2ui5_cl_util.abap_copy(temp10); - comps = lo_struct.get_components(); - try { - new_struct_desc = cl_abap_structdescr.create(comps); - new_table_desc = cl_abap_tabledescr.create({ p_line_type: new_struct_desc, p_table_kind: cl_abap_tabledescr.tablekind_std }); - // TODO(abap2js): CREATE DATA dfies TYPE HANDLE new_table_desc. - // TODO(abap2js): ASSIGN dfies->* TO . - if (!(fs_dfies != null)) { - return result; - } - if (!tabname) { - throw new z2ui5_cx_util_error({ val: `RTTI_BY_NAME_TAB_INITIAL` }); - } - structdescr = cl_abap_structdescr.describe_by_name(tabname); - fs_dfies = structdescr.get_ddic_field_list(); - if (_fs$fs_dfies) _fs$fs_dfies.o[_fs$fs_dfies.k] = fs_dfies; - sy_tabix = 0; - for (const fs_line of fs_dfies) { - sy_tabix++; - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const comp of comps) { - sy_tabix++; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, comp.name); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } - _fs$fs_value_dest = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(s_dfies, comp.name); - fs_value_dest = _fs$fs_value_dest ? _fs$fs_value_dest.o[_fs$fs_value_dest.k] : null; - sy_subrc = _fs$fs_value_dest ? 0 : 4; - if (!(fs_value_dest != null)) { - continue; - } - fs_value_dest = z2ui5_cl_util.abap_copy(fs_value); - if (_fs$fs_value_dest) _fs$fs_value_dest.o[_fs$fs_value_dest.k] = fs_value_dest; - fs_value = null; - _fs$fs_value = null; - fs_value_dest = null; - _fs$fs_value_dest = null; - } - sy_tabix = _sy_tabix_1; - result.push(s_dfies); - s_dfies = null; - } - } catch (error) { - } - return result; - } - - static rtti_get_t_attri_on_cloud({ tabname } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let fs_ddfields = null; - let _fs$fs_ddfields = null; - let fs_field = null; - let _fs$fs_field = null; - let lv_method2; - let workaround; - let lv_check_key; - let obj = null; - let lv_tabname = ``; - let lr_ddfields = null; - let names = []; - lv_tabname = z2ui5_cl_util.abap_copy(tabname); - try { - try { - lv_method2 = `XCO_CP_ABAP_DICTIONARY`; - // TODO(abap2js): CALL METHOD (lv_method2)=>(`DATABASE_TABLE`) EXPORTING iv_name = lv_tabname RECEIVING ro_database_table = obj. - // TODO(abap2js): ASSIGN obj->(`IF_XCO_DATABASE_TABLE~FIELDS->IF_XCO_DBT_FIELDS_FACTORY~KEY`) TO . - if (sy_subrc !== 0) { - throw new cx_sy_dyn_call_illegal_class(); - } - obj = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD obj->(`IF_XCO_DBT_FIELDS~GET_NAMES`) RECEIVING rt_names = names. - } catch (error) { - workaround = `DDFIELDS`; - // TODO(abap2js): CREATE DATA lr_ddfields TYPE (workaround). - // TODO(abap2js): ASSIGN lr_ddfields->* TO . - if (!(sy_subrc === 0)) throw new Error(`ASSERT failed`); - fs_ddfields = (cl_abap_typedescr.describe_by_name(lv_tabname)).get_ddic_field_list(); - if (_fs$fs_ddfields) _fs$fs_ddfields.o[_fs$fs_ddfields.k] = fs_ddfields; - sy_tabix = 0; - for (const fs_any of fs_ddfields) { - sy_tabix++; - _fs$fs_field = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_any, `KEYFLAG`); - fs_field = _fs$fs_field ? _fs$fs_field.o[_fs$fs_field.k] : null; - sy_subrc = _fs$fs_field ? 0 : 4; - if (sy_subrc !== 0 || !(fs_field === true || fs_field === `X`)) { - continue; - } - _fs$fs_field = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_any, `FIELDNAME`); - fs_field = _fs$fs_field ? _fs$fs_field.o[_fs$fs_field.k] : null; - sy_subrc = _fs$fs_field ? 0 : 4; - if (!(sy_subrc === 0)) throw new Error(`ASSERT failed`); - names.push(fs_field); - } - } - } catch (error) { - } - const lt_comp = z2ui5_cl_util.rtti_get_t_attri_by_any(tabname); - sy_tabix = 0; - for (const lr_comp of lt_comp) { - sy_tabix++; - lv_check_key = false; - if (names.some((row) => row.table_line === lr_comp.name)) { - lv_check_key = true; - } - result.push({ fieldname: lr_comp.name, rollname: lr_comp.name, keyflag: lv_check_key, scrtext_s: lr_comp.name, scrtext_m: lr_comp.name, scrtext_l: lr_comp.name }); - } - return result; - } - - static rtti_get_t_dfies_by_table_name({ table_name } = {}) { - let result = []; - if (z2ui5_cl_util.context_check_abap_cloud()) { - result = z2ui5_cl_util_ext.rtti_get_t_attri_on_cloud({ tabname: table_name }); - } else { - result = z2ui5_cl_util_ext.rtti_get_t_attri_on_prem({ tabname: table_name }); - } - return result; - } - - static rtti_get_table_desrc({ tabname, langu } = {}) { - let result = ``; - let sy_langu = "E"; - let lan; - let lv_tabname; - let ddtext = ``; - if (!(langu !== undefined)) { - lan = z2ui5_cl_util.abap_copy(sy_langu); - } else { - lan = z2ui5_cl_util.abap_copy(langu); - } - if (z2ui5_cl_util.context_check_abap_cloud()) { - ddtext = z2ui5_cl_util.abap_copy(tabname); - } else { - try { - lv_tabname = `dd02t`; - // TODO(abap2js): SELECT SINGLE ddtext FROM (lv_tabname) WHERE tabname = @tabname AND ddlanguage = @lan INTO @ddtext. - } catch (error) { - } - } - if (ddtext) { - result = z2ui5_cl_util.abap_copy(ddtext); - } else { - result = z2ui5_cl_util.abap_copy(tabname); - } - return result; - } - - static bus_search_help_read({ ms_shlp, mv_fname, mv_table, mr_data, mt_result_desc, mv_shlpfield, mt_data, ms_data_row } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let fs_shlp = null; - let _fs$fs_shlp = null; - let fs_shlp2 = null; - let _fs$fs_shlp2 = null; - let fs_row2 = null; - let _fs$fs_row2 = null; - let fs_any = null; - let _fs$fs_any = null; - let fs_value = null; - let _fs$fs_value = null; - let fs_fs_target_tab = null; - let _fs$fs_fs_target_tab = null; - let fs_fs_line = null; - let _fs$fs_fs_line = null; - let fs_line_content = null; - let _fs$fs_line_content = null; - let fs_tab = null; - let _fs$fs_tab = null; - let fs_row = null; - let _fs$fs_row = null; - let lv_fm; - let lv_type2; - let valule; - let descption; - let lt_result_tab = []; - let ls_comp = null; - let lt_comps = []; - let lo_datadescr = null; - let lr_line = null; - let lr_shlp = null; - const lv_type = `SHLP_DESCR`; - // TODO(abap2js): CREATE DATA lr_shlp TYPE (lv_type). - // TODO(abap2js): ASSIGN lr_shlp->* TO . - let lv_tabname = ``; - let lv_fieldname = ``; - lv_tabname = z2ui5_cl_util.abap_copy(mv_table); - lv_fieldname = z2ui5_cl_util.abap_copy(mv_fname); - if (!ms_shlp) { - lv_fm = `F4IF_DETERMINE_SEARCHHELP`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING tabname = lv_tabname fieldname = lv_fieldname IMPORTING shlp = EXCEPTIONS field_not_found = 1 no_help_for_field = 2 inconsistent_help = 3 OTHERS = 4. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `F4IF_DETERMINE_SEARCHHELP failed for ${lv_tabname}-${lv_fieldname}` }); - } - ms_shlp = ({ ...fs_shlp }); - if (!(ms_shlp.intdescr.issimple === true || ms_shlp.intdescr.issimple === `X`)) { - let lr_t_shlp = null; - lv_type2 = `SHLP_DESCT`; - // TODO(abap2js): CREATE DATA lr_t_shlp TYPE (lv_type2). - // TODO(abap2js): ASSIGN lr_t_shlp->* TO . - lv_fm = `F4IF_EXPAND_SEARCHHELP`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING shlp_top = ms_shlp IMPORTING shlp_tab = . - fs_row2 = fs_shlp2[(1) - 1]; - _fs$fs_row2 = null; - sy_subrc = 0; - ms_shlp = ({ ...fs_row2 }); - } - } - if (mr_data != null) { - sy_tabix = 0; - for (const r_interface of ms_shlp.interface) { - sy_tabix++; - if (!(!r_interface.value)) continue; - // TODO(abap2js): ASSIGN mr_data->* TO . - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_any, r_interface.shlpfield); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (sy_subrc !== 0) { - continue; - } - r_interface.value = z2ui5_cl_util.abap_copy(fs_value); - } - } - sy_tabix = 0; - for (const interface_ of ms_shlp.interface) { - sy_tabix++; - if (interface_.valfield === mv_fname) { - mv_shlpfield = z2ui5_cl_util.abap_copy(interface_.shlpfield); - } - if (interface_.value) { - ms_shlp.selopt = [...(ms_shlp.selopt ?? []),{ shlpfield: interface_.shlpfield, shlpname: interface_.valtabname, option: ([...String(interface_.value)].some(($c) => String(`*`).includes($c)) ? `CP` : `EQ`), sign: `I`, low: interface_.value }]; - } - } - sy_tabix = 0; - for (const fieldrop of ms_shlp.fieldprop) { - sy_tabix++; - if (!fieldrop.defaultval) { - continue; - } - valule = z2ui5_cl_util.abap_copy(fieldrop.defaultval); - // TODO(abap2js): REPLACE ALL OCCURRENCES OF `'` IN valule WITH ``. - ms_shlp.selopt = [...(ms_shlp.selopt ?? []),{ shlpfield: fieldrop.fieldname, option: ([...String(fieldrop.defaultval)].some(($c) => String(`*`).includes($c)) ? `CP` : `EQ`), sign: `I`, low: valule }]; - } - // TODO(abap2js): CREATE DATA lr_shlp TYPE (lv_type). - // TODO(abap2js): ASSIGN lr_shlp->* TO . - fs_shlp = null; - if (_fs$fs_shlp) _fs$fs_shlp.o[_fs$fs_shlp.k] = fs_shlp; - // TODO(abap2js): MOVE-CORRESPONDING ms_shlp TO . - lv_fm = `F4IF_SELECT_VALUES`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING shlp = sort = space call_shlp_exit = abap_true TABLES record_tab = lt_result_tab recdescr_tab = mt_result_desc. - ms_shlp.fieldprop.sort((a, b) => ((a.shlplispos > b.shlplispos ? 1 : a.shlplispos < b.shlplispos ? -1 : 0))); - sy_tabix = 0; - for (const field_props of ms_shlp.fieldprop) { - sy_tabix++; - if (!(field_props.shlplispos)) continue; - descption = (() => { try { return mt_result_desc.find((row) => row.fieldname === field_props.fieldname) ?? null; } catch { return null; } })(); - ls_comp.name = z2ui5_cl_util.abap_copy(descption.fieldname); - ls_comp.type = cl_abap_datadescr.describe_by_name(descption.rollname); - lt_comps.push(ls_comp); - } - if (!lt_comps.some((row) => row.name === `ROW_ID`)) { - lo_datadescr = cl_abap_datadescr.describe_by_name(`INT4`); - ls_comp.name = `ROW_ID`; - ls_comp.type = z2ui5_cl_util.abap_copy(lo_datadescr); - lt_comps.push(ls_comp); - } - const strucdescr = cl_abap_structdescr.create({ p_components: lt_comps }); - const tabdescr = cl_abap_tabledescr.create({ p_line_type: strucdescr }); - if (mt_data != null) { - // TODO(abap2js): CREATE DATA mt_data TYPE HANDLE tabdescr. - } - // TODO(abap2js): ASSIGN mt_data->* TO . - fs_fs_target_tab = null; - if (_fs$fs_fs_target_tab) _fs$fs_fs_target_tab.o[_fs$fs_fs_target_tab.k] = fs_fs_target_tab; - if (ms_data_row != null) { - // TODO(abap2js): CREATE DATA ms_data_row TYPE HANDLE strucdescr. - } - sy_tabix = 0; - for (const result_line of lt_result_tab) { - sy_tabix++; - // TODO(abap2js): CREATE DATA lr_line TYPE HANDLE strucdescr. - // TODO(abap2js): ASSIGN lr_line->* TO FIELD-SYMBOL(). - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const result_desc of mt_result_desc) { - sy_tabix++; - _fs$fs_line_content = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_fs_line, result_desc.fieldname); - fs_line_content = _fs$fs_line_content ? _fs$fs_line_content.o[_fs$fs_line_content.k] : null; - sy_subrc = _fs$fs_line_content ? 0 : 4; - if (sy_subrc !== 0) { - continue; - } - if (result_desc.leng < result_desc.intlen) { - result_desc.offset = z2ui5_cl_util.abap_div(result_desc.offset, 2); - } - try { - fs_line_content = result_line + result_desc.offset (result_desc.outputlen); - if (_fs$fs_line_content) _fs$fs_line_content.o[_fs$fs_line_content.k] = fs_line_content; - } catch (error) { - try { - fs_line_content = result_line + result_desc.offset; - if (_fs$fs_line_content) _fs$fs_line_content.o[_fs$fs_line_content.k] = fs_line_content; - } catch (error) { - } - } - } - sy_tabix = _sy_tabix_1; - fs_fs_target_tab.push(fs_fs_line); - } - sy_tabix = 0; - for (const interface_ of ms_shlp.interface) { - sy_tabix++; - if (interface_.value) { - fs_any = null; - _fs$fs_any = null; - // TODO(abap2js): ASSIGN ms_data_row->* TO . - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_any, interface_.shlpfield); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (sy_subrc !== 0) { - continue; - } - fs_value = z2ui5_cl_util.abap_copy(interface_.value); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - } - // TODO(abap2js): ASSIGN mt_data->* TO . - sy_tabix = 0; - for (const fs_line of fs_tab) { - sy_tabix++; - _fs$fs_row = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `ROW_ID`); - fs_row = _fs$fs_row ? _fs$fs_row.o[_fs$fs_row.k] : null; - sy_subrc = _fs$fs_row ? 0 : 4; - if (fs_row != null) { - fs_row = z2ui5_cl_util.abap_copy(sy_tabix); - if (_fs$fs_row) _fs$fs_row.o[_fs$fs_row.k] = fs_row; - } - } - } - - static tab_get_where_by_dfies({ mv_check_tab_field, ms_data_row, it_dfies } = {}) { - let result = ``; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_row = null; - let _fs$fs_row = null; - let fs_value = null; - let _fs$fs_value = null; - let and; - let escape; - let val = ``; - sy_tabix = 0; - for (const dfies of it_dfies) { - sy_tabix++; - if (!(((dfies.keyflag === true || dfies.keyflag === `X`) || dfies.fieldname === mv_check_tab_field))) { - continue; - } - // TODO(abap2js): ASSIGN ms_data_row->* TO FIELD-SYMBOL(). - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_row, dfies.fieldname); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } - if (!fs_value) { - continue; - } - if (result) { - and = ` AND `; - } - if ([...String(fs_value)].some(($c) => String(`_`).includes($c))) { - escape = `ESCAPE '#'`; - } else { - escape = null; - } - val = z2ui5_cl_util.abap_copy(fs_value); - if ([...String(val)].some(($c) => String(`_`).includes($c))) { - // TODO(abap2js): REPLACE ALL OCCURRENCES OF `_` IN val WITH `#_`. - } - result = `${result}${and} ( ${dfies.fieldname} LIKE '%${val}%' ${escape} )`; - } - return result; - } - - static _get_e071k_tabkey({ dfies } = {}) { - let rv_tabkey = null; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_value = null; - let _fs$fs_value = null; - let lv_type = ``; - let lv_tabkey = ``; - let lv_tabkey_len = 0; - let lv_field_len = 0; - let lv_offset = 0; - sy_tabix = 0; - for (const s_dfies of dfies) { - sy_tabix++; - if (!((s_dfies.keyflag === true || s_dfies.keyflag === `X`))) continue; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(line, s_dfies.fieldname); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } - lv_type = cl_abap_typedescr.describe_by_data(fs_value).type_kind; - if (![...String(lv_type)].some(($c) => String(`CDNT`).includes($c))) { - // TODO(abap2js): lv_tabkey+lv_tabkey_len = '*'. - rv_tabkey = z2ui5_cl_util.abap_copy(lv_tabkey); - return rv_tabkey; - } else { - lv_field_len = z2ui5_cl_util.abap_div((cl_abap_typedescr.describe_by_data(fs_value).length), z2ui5_cl_util.cv_char_util_charsize); - } - lv_field_len = z2ui5_cl_util.abap_div((cl_abap_typedescr.describe_by_data(fs_value).length), z2ui5_cl_util.cv_char_util_charsize); - // TODO(abap2js): lv_tabkey+lv_tabkey_len(lv_field_len) = . - lv_tabkey_len = lv_tabkey_len + lv_field_len; - } - if (lv_tabkey_len > 119) { - if (String(lv_tabkey).toLowerCase().includes(String(`_`).toLowerCase())) { - lv_offset = z2ui5_cl_util.abap_copy(sy_fdpos); - // TODO(abap2js): lv_tabkey+lv_offset = '*'. - } else { - // TODO(abap2js): lv_tabkey+119 = '*'. - } - } - rv_tabkey = z2ui5_cl_util.abap_copy(lv_tabkey); - return rv_tabkey; - } - - static bus_tr_add({ ir_data, iv_tabname, is_transport } = {}) { - let sy_subrc = 0; - let fs_e071 = null; - let _fs$fs_e071 = null; - let fs_t_e071k = null; - let _fs$fs_t_e071k = null; - let fs_t_e071 = null; - let _fs$fs_t_e071 = null; - let r_e071k; - let r_e071; - let fb1; - let fb2; - if (z2ui5_cl_util.context_check_abap_cloud()) { - } else { - z2ui5_cl_util_ext.set_mandt({ ir_data: ir_data }); - r_e071k = z2ui5_cl_util_ext._set_e071k({ ir_data, iv_tabname, is_transport }); - // TODO(abap2js): ASSIGN r_e071k->* TO . - if (!fs_e071) { - return; - } - r_e071 = z2ui5_cl_util_ext._set_e071({ iv_tabname, is_transport }); - // TODO(abap2js): ASSIGN r_e071k->* TO . - // TODO(abap2js): ASSIGN r_e071->* TO . - fb1 = `TR_APPEND_TO_COMM_OBJS_KEYS`; - // TODO(abap2js): CALL FUNCTION fb1 EXPORTING wi_trkorr = is_transport-transport iv_dialog = abap_false TABLES wt_e071 = wt_e071k = EXCEPTIONS error_message = 1 OTHERS = 2. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error(); - } - fb2 = `TR_SORT_AND_COMPRESS_COMM`; - // TODO(abap2js): CALL FUNCTION fb2 EXPORTING iv_trkorr = is_transport-task EXCEPTIONS error_message = 1 OTHERS = 2. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error(); - } else { - z2ui5_port.db({ op: `commit` }); - } - } - } - - static _set_e071k({ ir_data, iv_tabname, is_transport } = {}) { - let result = null; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_t_e071k = null; - let _fs$fs_t_e071k = null; - let fs_s_e071k = null; - let _fs$fs_s_e071k = null; - let fs_value = null; - let _fs$fs_value = null; - let fs_tab = null; - let _fs$fs_tab = null; - let struct_desc; - let table_desc; - let t_e071k = null; - let s_e071k = null; - const t_comp = z2ui5_cl_util.rtti_get_t_attri_by_table_name(`E071K`); - try { - struct_desc = cl_abap_structdescr.create(t_comp); - table_desc = cl_abap_tabledescr.create({ p_line_type: struct_desc, p_table_kind: cl_abap_tabledescr.tablekind_std }); - // TODO(abap2js): CREATE DATA t_e071k TYPE HANDLE table_desc. - // TODO(abap2js): CREATE DATA s_e071k TYPE HANDLE struct_desc. - // TODO(abap2js): ASSIGN t_e071k->* TO . - // TODO(abap2js): ASSIGN s_e071k->* TO . - } catch (error) { - } - const dfies = z2ui5_cl_util_ext.rtti_get_t_dfies_by_table_name({ table_name: iv_tabname }); - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `TRKORR`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util.abap_copy(is_transport.task); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `PGMID`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `R3TR`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `MASTERTYPE`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `TABU`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `OBJECT`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `TABU`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `MASTERNAME`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util.abap_copy(iv_tabname); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `OBJNAME`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util.abap_copy(iv_tabname); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - // TODO(abap2js): ASSIGN ir_data->* TO . - sy_tabix = 0; - for (const fs_line of fs_tab) { - sy_tabix++; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071k, `TABKEY`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util_ext._get_e071k_tabkey({ dfies, line: fs_line }); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_t_e071k.push(fs_s_e071k); - } - result = z2ui5_cl_util.abap_copy(t_e071k); - return result; - } - - static _set_e071({ iv_tabname, is_transport } = {}) { - let result = null; - let sy_subrc = 0; - let fs_t_e071 = null; - let _fs$fs_t_e071 = null; - let fs_s_e071 = null; - let _fs$fs_s_e071 = null; - let fs_value = null; - let _fs$fs_value = null; - let struct_desc_new; - let table_desc_new; - let t_e071 = null; - let s_e071 = null; - const t_comp = z2ui5_cl_util.rtti_get_t_attri_by_table_name(`E071`); - try { - struct_desc_new = cl_abap_structdescr.create(t_comp); - table_desc_new = cl_abap_tabledescr.create({ p_line_type: struct_desc_new, p_table_kind: cl_abap_tabledescr.tablekind_std }); - // TODO(abap2js): CREATE DATA t_e071 TYPE HANDLE table_desc_new. - // TODO(abap2js): CREATE DATA s_e071 TYPE HANDLE struct_desc_new. - // TODO(abap2js): ASSIGN t_e071->* TO . - // TODO(abap2js): ASSIGN s_e071->* TO . - } catch (error) { - } - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071, `TRKORR`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util.abap_copy(is_transport.task); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071, `PGMID`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `R3TR`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071, `OBJECT`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `TABU`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071, `OBJ_NAME`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = z2ui5_cl_util.abap_copy(iv_tabname); - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_s_e071, `OBJFUNC`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - return result; - } else { - fs_value = `K`; - if (_fs$fs_value) _fs$fs_value.o[_fs$fs_value.k] = fs_value; - } - fs_value = null; - _fs$fs_value = null; - fs_t_e071.push(fs_s_e071); - result = z2ui5_cl_util.abap_copy(t_e071); - return result; - } - - static _read_e070({ mt_data } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let sy_uname = ""; - let fs_table = null; - let _fs$fs_table = null; - let fs_line = null; - let _fs$fs_line = null; - let fs_value = null; - let _fs$fs_value = null; - let t_comp; - let new_struct_desc; - let new_table_desc; - let where; - let lo_tab = null; - let lo_line = null; - let ls_data = {}; - const table_name = `E070`; - try { - t_comp = z2ui5_cl_util.rtti_get_t_attri_by_table_name(table_name); - new_struct_desc = cl_abap_structdescr.create(t_comp); - new_table_desc = cl_abap_tabledescr.create({ p_line_type: new_struct_desc, p_table_kind: cl_abap_tabledescr.tablekind_std }); - // TODO(abap2js): CREATE DATA lo_tab TYPE HANDLE new_table_desc. - // TODO(abap2js): CREATE DATA lo_line TYPE HANDLE new_struct_desc. - // TODO(abap2js): ASSIGN lo_tab->* TO . - // TODO(abap2js): ASSIGN lo_line->* TO . - where = `( TRFUNCTION EQ 'Q' ) AND ( TRSTATUS EQ 'D' ) AND ( KORRDEV EQ 'CUST' ) AND ( AS4USER EQ '${sy_uname}' )`; - // TODO(abap2js): SELECT trkorr, trfunction, trstatus, tarsystem, korrdev, as4user, as4date, as4time, strkorr FROM (table_name) WHERE (where) INTO TABLE @
. - if (sy_subrc !== 0) { - return; - } - } catch (error) { - } - sy_tabix = 0; - for (const fs_line of fs_table) { - sy_tabix++; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `TRKORR`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } else { - ls_data.transport = z2ui5_cl_util.abap_copy(fs_value); - } - fs_value = null; - _fs$fs_value = null; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `STRKORR`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } else { - ls_data.task = z2ui5_cl_util.abap_copy(fs_value); - } - fs_value = null; - _fs$fs_value = null; - mt_data.push(ls_data); - } - } - - static bus_tr_read() { - let mt_data = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_table = null; - let _fs$fs_table = null; - let fs_line = null; - let _fs$fs_line = null; - let fs_value = null; - let _fs$fs_value = null; - let table_name; - let t_comp; - let new_struct_desc; - let new_table_desc; - let index; - let where; - let data; - if (z2ui5_cl_util.context_check_abap_cloud()) { - } else { - let lo_tab = null; - let lo_line = null; - z2ui5_cl_util_ext._read_e070({ mt_data }); - table_name = `E07T`; - try { - t_comp = z2ui5_cl_util.rtti_get_t_attri_by_table_name(table_name); - new_struct_desc = cl_abap_structdescr.create(t_comp); - new_table_desc = cl_abap_tabledescr.create({ p_line_type: new_struct_desc, p_table_kind: cl_abap_tabledescr.tablekind_std }); - // TODO(abap2js): CREATE DATA lo_tab TYPE HANDLE new_table_desc. - // TODO(abap2js): CREATE DATA lo_line TYPE HANDLE new_struct_desc. - // TODO(abap2js): ASSIGN lo_tab->* TO
. - // TODO(abap2js): ASSIGN lo_line->* TO . - index = 0; - sy_tabix = 0; - for (const line of mt_data) { - sy_tabix++; - index = index + 1; - if (index === 1) { - where = `TRKORR EQ '${line.task}'`; - } else { - where = `${where} OR TRKORR EQ '${line.task}'`; - } - where = `( ${where} )`; - } - // TODO(abap2js): SELECT trkorr, langu, as4text FROM (table_name) WHERE (where) INTO TABLE @
. - if (sy_subrc !== 0) { - return mt_data; - } - } catch (error) { - } - sy_tabix = 0; - for (const fs_line of fs_table) { - sy_tabix++; - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `TRKORR`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } else { - data = {}; - { - const _t = mt_data; - const _i = _t.findIndex((_r) => _r.task === fs_value); - sy_subrc = _i >= 0 && _i < _t.length ? 0 : 4; - if (sy_subrc === 0) data = _t[_i]; - } - if (sy_subrc === 0) { - _fs$fs_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `AS4TEXT`); - fs_value = _fs$fs_value ? _fs$fs_value.o[_fs$fs_value.k] : null; - sy_subrc = _fs$fs_value ? 0 : 4; - if (!(fs_value != null)) { - continue; - } else { - data.short_description = z2ui5_cl_util.abap_copy(fs_value); - } - } - } - } - } - return mt_data; - } - - static set_mandt({ ir_data } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let sy_mandt = "000"; - let fs_tab = null; - let _fs$fs_tab = null; - let fs_row = null; - let _fs$fs_row = null; - // TODO(abap2js): ASSIGN ir_data->* TO . - sy_tabix = 0; - for (const fs_line of fs_tab) { - sy_tabix++; - _fs$fs_row = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `MANDT`); - fs_row = _fs$fs_row ? _fs$fs_row.o[_fs$fs_row.k] : null; - sy_subrc = _fs$fs_row ? 0 : 4; - if (fs_row != null) { - try { - fs_row = z2ui5_cl_util.abap_copy(sy_mandt); - if (_fs$fs_row) _fs$fs_row.o[_fs$fs_row.k] = fs_row; - } catch (error) { - } - } - } - } - - static conv_exit({ name, val, result } = {}) { - let sy_subrc = 0; - let conv; - let lv_tab; - if (z2ui5_cl_util.context_check_abap_cloud()) { - } else { - conv = `CONVERSION_EXIT_${name.convexit}_INPUT`; - let conex = ``; - lv_tab = `TFDIR`; - // TODO(abap2js): SELECT SINGLE funcname FROM (lv_tab) WHERE funcname = @conv INTO @conex. - if (sy_subrc === 0) { - // TODO(abap2js): CALL FUNCTION conex EXPORTING input = val IMPORTING output = result EXCEPTIONS error_message = 1 OTHERS = 2. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error(); - } - } - } - } - - static bal_search({ object, subobject, id, date_from, date_to, user } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let sy_datum = ""; - let fs_filter = null; - let _fs$fs_filter = null; - let fs_range = null; - let _fs$fs_range = null; - let fs_rline = null; - let _fs$fs_rline = null; - let fs_comp = null; - let _fs$fs_comp = null; - let fs_headers = null; - let _fs$fs_headers = null; - let lv_obj_f; - let lv_sub_f; - let lv_id_f; - let lv_from; - let lv_to; - let ls_hdr_c; - let ls_hdr; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_filter = null; - let lo_db = null; - let lt_logs = null; - let lv_class = ``; - try { - lv_class = `CL_BALI_LOG_FILTER`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) RECEIVING filter = lo_filter. - lv_obj_f = (object ? object : ``); - lv_sub_f = (subobject ? subobject : ``); - lv_id_f = (id ? id : ``); - // TODO(abap2js): CALL METHOD lo_filter->(`SET_DESCRIPTOR`) EXPORTING object = lv_obj_f subobject = lv_sub_f external_id = lv_id_f. - if (date_from || date_to) { - lv_from = (date_from ? date_from : `19000101`); - lv_to = (date_to ? date_to : sy_datum); - // TODO(abap2js): CALL METHOD lo_filter->(`SET_CREATE_DATE`) EXPORTING from_date = lv_from to_date = lv_to. - } - lv_class = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db. - // TODO(abap2js): CALL METHOD lo_db->(`LOAD_LOGS_VIA_FILTER`) EXPORTING filter = lo_filter read_only_header = abap_true RECEIVING log_table = lt_logs. - sy_tabix = 0; - for (const lo_log of lt_logs) { - sy_tabix++; - ls_hdr_c = {}; - try { - let lo_header = null; - // TODO(abap2js): CALL METHOD lo_log->(`GET_HEADER`) RECEIVING header = lo_header. - // TODO(abap2js): CALL METHOD lo_header->(`GET_OBJECT`) RECEIVING object = ls_hdr_c-object. - // TODO(abap2js): CALL METHOD lo_header->(`GET_SUBOBJECT`) RECEIVING subobject = ls_hdr_c-subobject. - // TODO(abap2js): CALL METHOD lo_header->(`GET_EXTERNAL_ID`) RECEIVING external_id = ls_hdr_c-external_id. - } catch (error) { - } - result.push(ls_hdr_c); - } - } catch (error) { - } - return result; - } - let lv_fm = ``; - let lr_filter = null; - let lr_headers = null; - let lr_rline = null; - try { - // TODO(abap2js): CREATE DATA lr_filter TYPE ('BAL_S_LFIL'). - // TODO(abap2js): ASSIGN lr_filter->* TO . - if (object) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `OBJECT`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(object); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - if (subobject) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `SUBOBJECT`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(subobject); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - if (id) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `EXTNUMBER`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(id); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - if (date_from || date_to) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `ALDATE`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `BT`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = (date_from ? date_from : `19000101`); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `HIGH`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = (date_to ? date_to : sy_datum); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - if (user) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `ALUSER`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(user); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - // TODO(abap2js): CREATE DATA lr_headers TYPE ('BALHDR_T'). - // TODO(abap2js): ASSIGN lr_headers->* TO . - lv_fm = `BAL_DB_SEARCH`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_log_filter = IMPORTING e_t_log_header = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - return result; - } - sy_tabix = 0; - for (const fs_header of fs_headers) { - sy_tabix++; - ls_hdr = {}; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `LOG_HANDLE`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.log_handle = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `OBJECT`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.object = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `SUBOBJECT`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.subobject = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `EXTNUMBER`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.external_id = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `ALDATE`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.log_date = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `ALTIME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.log_time = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `ALUSER`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_hdr.user = z2ui5_cl_util.abap_copy(fs_comp); - } - result.push(ls_hdr); - } - } catch (error) { - } - return result; - } - - static bal_read_latest({ object, subobject, id } = {}) { - let result = null; - const lt_msgs = z2ui5_cl_util_ext.bal_read({ object, subobject, id }); - if (lt_msgs) { - result = z2ui5_cl_util.abap_copy(lt_msgs[(lt_msgs.length) - 1]); - } - return result; - } - - static bal_delete_before({ object, subobject, days = 30 } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let sy_datum = ""; - let fs_filter = null; - let _fs$fs_filter = null; - let fs_range = null; - let _fs$fs_range = null; - let fs_rline = null; - let _fs$fs_rline = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_sub_c; - const lv_cutoff = (sy_datum - days); - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_filter_c = null; - let lo_db_c = null; - let lt_logs_c = null; - let lv_cls = ``; - try { - lv_cls = `CL_BALI_LOG_FILTER`; - // TODO(abap2js): CALL METHOD (lv_cls)=>(`CREATE`) RECEIVING filter = lo_filter_c. - lv_sub_c = (subobject ? subobject : ``); - // TODO(abap2js): CALL METHOD lo_filter_c->(`SET_DESCRIPTOR`) EXPORTING object = object subobject = lv_sub_c external_id = ``. - // TODO(abap2js): CALL METHOD lo_filter_c->(`SET_CREATE_DATE`) EXPORTING from_date = CONV d( '19000101' ) to_date = lv_cutoff. - lv_cls = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_cls)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db_c. - // TODO(abap2js): CALL METHOD lo_db_c->(`LOAD_LOGS_VIA_FILTER`) EXPORTING filter = lo_filter_c RECEIVING log_table = lt_logs_c. - sy_tabix = 0; - for (const lo_log_c of lt_logs_c) { - sy_tabix++; - // TODO(abap2js): CALL METHOD lo_db_c->(`DELETE_LOG`) EXPORTING log = lo_log_c. - } - z2ui5_port.db({ op: `commit` }); - } catch (error) { - } - return; - } - let lv_fm = ``; - let lr_filter = null; - let lr_rline = null; - try { - // TODO(abap2js): CREATE DATA lr_filter TYPE ('BAL_S_LFIL'). - // TODO(abap2js): ASSIGN lr_filter->* TO . - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `OBJECT`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(object); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - if (subobject) { - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `SUBOBJECT`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(subobject); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - } - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_filter, `ALDATE`); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_rline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_rline->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `BT`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `19000101`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_rline, `HIGH`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(lv_cutoff); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_rline); - lv_fm = `BAL_DB_DELETE`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_log_filter = EXCEPTIONS OTHERS = 1. - if (sy_subrc === 0) { - z2ui5_port.db({ op: `commit` }); - } - } catch (error) { - } - } - - static bal_read_by_type({ object, subobject, id, msg_type = `E` } = {}) { - let result = []; - let sy_tabix = 0; - const lt_all = z2ui5_cl_util_ext.bal_read({ object, subobject, id }); - sy_tabix = 0; - for (const ls_msg of lt_all) { - sy_tabix++; - if (!(ls_msg.type === msg_type)) continue; - result.push(ls_msg); - } - return result; - } - - static bal_count({ object, subobject, id } = {}) { - let result = 0; - const lt_msgs = z2ui5_cl_util_ext.bal_read({ object, subobject, id }); - result = z2ui5_cl_util.abap_copy(lt_msgs.length); - return result; - } - - static bal_read({ object, subobject, id } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_handles = null; - let _fs$fs_handles = null; - let fs_single = null; - let _fs$fs_single = null; - let fs_msgh = null; - let _fs$fs_msgh = null; - let fs_msg = null; - let _fs$fs_msg = null; - let ls_msg; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lt_items = []; - let lo_filter = null; - let lo_db = null; - let lt_logs = null; - let lv_text = ``; - let lv_class = ``; - let lv_severity = ``; - let lv_msgid = ``; - let lv_msgno = ``; - let lv_msgv1 = ``; - let lv_msgv2 = ``; - let lv_msgv3 = ``; - let lv_msgv4 = ``; - try { - lo_filter = z2ui5_cl_util_ext.bal_cloud_build_filter({ object, subobject, id }); - lv_class = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db. - // TODO(abap2js): CALL METHOD lo_db->(`LOAD_LOGS_VIA_FILTER`) EXPORTING filter = lo_filter RECEIVING log_table = lt_logs. - sy_tabix = 0; - for (const lo_log of lt_logs) { - sy_tabix++; - lt_items = {}; - // TODO(abap2js): CALL METHOD lo_log->(`GET_ALL_ITEMS`) RECEIVING item_table = lt_items. - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const ls_item of lt_items) { - sy_tabix++; - if (ls_item.item != null) { - continue; - } - ls_msg = {}; - lv_text = ``; - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_TEXT`) RECEIVING message_text = lv_text. - ls_msg.text = z2ui5_cl_util.abap_copy(lv_text); - try { - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_SEVERITY`) RECEIVING severity = lv_severity. - ls_msg.type = z2ui5_cl_util.abap_copy(lv_severity); - } catch (error) { - } - try { - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_ID`) RECEIVING id = lv_msgid. - ls_msg.id = z2ui5_cl_util.abap_copy(lv_msgid); - } catch (error) { - } - try { - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_NUMBER`) RECEIVING number = lv_msgno. - ls_msg.no = z2ui5_cl_util.abap_copy(lv_msgno); - } catch (error) { - } - try { - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_VARIABLE_1`) RECEIVING variable_1 = lv_msgv1. - ls_msg.v1 = z2ui5_cl_util.abap_copy(lv_msgv1); - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_VARIABLE_2`) RECEIVING variable_2 = lv_msgv2. - ls_msg.v2 = z2ui5_cl_util.abap_copy(lv_msgv2); - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_VARIABLE_3`) RECEIVING variable_3 = lv_msgv3. - ls_msg.v3 = z2ui5_cl_util.abap_copy(lv_msgv3); - // TODO(abap2js): CALL METHOD ls_item-item->(`GET_MESSAGE_VARIABLE_4`) RECEIVING variable_4 = lv_msgv4. - ls_msg.v4 = z2ui5_cl_util.abap_copy(lv_msgv4); - } catch (error) { - } - result.push(ls_msg); - } - sy_tabix = _sy_tabix_1; - } - } catch (error) { - return result; - } - } else { - let lv_fm = ``; - let lr_handles = null; - let lr_single = null; - let lr_msgh = null; - let lr_msg = null; - try { - lr_handles = z2ui5_cl_util_ext.bal_std_load_handles({ object, subobject, id }); - if (lr_handles != null) { - return result; - } - // TODO(abap2js): ASSIGN lr_handles->* TO . - // TODO(abap2js): CREATE DATA lr_single TYPE ('BAL_T_LOGH'). - // TODO(abap2js): ASSIGN lr_single->* TO . - // TODO(abap2js): CREATE DATA lr_msgh TYPE ('BAL_T_MSGH'). - // TODO(abap2js): ASSIGN lr_msgh->* TO . - // TODO(abap2js): CREATE DATA lr_msg TYPE ('BAL_S_MSG'). - // TODO(abap2js): ASSIGN lr_msg->* TO . - sy_tabix = 0; - for (const fs_handle of fs_handles) { - sy_tabix++; - fs_single = null; - if (_fs$fs_single) _fs$fs_single.o[_fs$fs_single.k] = fs_single; - fs_single.push(fs_handle); - fs_msgh = null; - if (_fs$fs_msgh) _fs$fs_msgh.o[_fs$fs_msgh.k] = fs_msgh; - lv_fm = `BAL_GLB_SEARCH_MSG`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_t_log_handle = IMPORTING e_t_msg_handle = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - continue; - } - const _sy_tabix_2 = sy_tabix; - sy_tabix = 0; - for (const fs_mh of fs_msgh) { - sy_tabix++; - fs_msg = null; - if (_fs$fs_msg) _fs$fs_msg.o[_fs$fs_msg.k] = fs_msg; - lv_fm = `BAL_LOG_MSG_READ`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_msg_handle = IMPORTING e_s_msg = EXCEPTIONS OTHERS = 1. - if (sy_subrc === 0) { - result.push(z2ui5_cl_util_ext.bal_std_map_msg({ msg: fs_msg })); - } - } - sy_tabix = _sy_tabix_2; - } - } catch (lx_read) { - throw new z2ui5_cx_util_error({ val: lx_read }); - } - } - return result; - } - - static bal_create({ object, subobject, id, t_log } = {}) { - let sy_subrc = 0; - let fs_log = null; - let _fs$fs_log = null; - let fs_comp = null; - let _fs$fs_comp = null; - let fs_handle = null; - let _fs$fs_handle = null; - let fs_handles = null; - let _fs$fs_handles = null; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_header = null; - let lo_log = null; - let lo_db = null; - let lv_class = ``; - try { - lv_class = `CL_BALI_HEADER_SETTER`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) EXPORTING object = object subobject = subobject external_id = id RECEIVING header = lo_header. - lv_class = `CL_BALI_LOG`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) RECEIVING log = lo_log. - // TODO(abap2js): CALL METHOD lo_log->(`SET_HEADER`) EXPORTING header = lo_header. - z2ui5_cl_util_ext.bal_cloud_add_items({ log: lo_log, t_log }); - lv_class = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db. - // TODO(abap2js): CALL METHOD lo_db->(`SAVE_LOG`) EXPORTING log = lo_log. - z2ui5_port.db({ op: `commit` }); - } catch (error) { - return; - } - } else { - let lv_fm = ``; - let lr_log = null; - let lr_handle = null; - let lr_handles = null; - try { - // TODO(abap2js): CREATE DATA lr_log TYPE ('BAL_S_LOG'). - // TODO(abap2js): ASSIGN lr_log->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_log, `OBJECT`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(object); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_log, `SUBOBJECT`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(subobject); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_log, `EXTNUMBER`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(id); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - // TODO(abap2js): CREATE DATA lr_handle TYPE ('BALLOGHNDL'). - // TODO(abap2js): ASSIGN lr_handle->* TO . - lv_fm = `BAL_LOG_CREATE`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_log = IMPORTING e_log_handle = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - return; - } - z2ui5_cl_util_ext.bal_std_msg_add({ handle: fs_handle, t_log }); - // TODO(abap2js): CREATE DATA lr_handles TYPE ('BAL_T_LOGH'). - // TODO(abap2js): ASSIGN lr_handles->* TO . - fs_handles.push(fs_handle); - lv_fm = `BAL_DB_SAVE`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_t_log_handle = EXCEPTIONS OTHERS = 1. - if (sy_subrc === 0) { - z2ui5_port.db({ op: `commit` }); - } - } catch (lx_create) { - throw new z2ui5_cx_util_error({ val: lx_create }); - } - } - } - - static bal_update({ object, subobject, id, t_log } = {}) { - let sy_subrc = 0; - let fs_handles = null; - let _fs$fs_handles = null; - let fs_handle = null; - let _fs$fs_handle = null; - let lo_log; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_filter = null; - let lo_db = null; - let lt_logs = null; - let lv_class = ``; - try { - lo_filter = z2ui5_cl_util_ext.bal_cloud_build_filter({ object, subobject, id }); - lv_class = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db. - // TODO(abap2js): CALL METHOD lo_db->(`LOAD_LOGS_VIA_FILTER`) EXPORTING filter = lo_filter RECEIVING log_table = lt_logs. - if (!lt_logs) { - z2ui5_cl_util_ext.bal_create({ object, subobject, id, t_log }); - return; - } - lo_log = z2ui5_cl_util.abap_copy(lt_logs[(1) - 1]); - z2ui5_cl_util_ext.bal_cloud_add_items({ log: lo_log, t_log }); - // TODO(abap2js): CALL METHOD lo_db->(`SAVE_LOG`) EXPORTING log = lo_log. - z2ui5_port.db({ op: `commit` }); - } catch (error) { - z2ui5_cl_util_ext.bal_create({ object, subobject, id, t_log }); - } - } else { - let lv_fm = ``; - let lr_handles = null; - try { - lr_handles = z2ui5_cl_util_ext.bal_std_load_handles({ object, subobject, id }); - if (lr_handles != null) { - z2ui5_cl_util_ext.bal_create({ object, subobject, id, t_log }); - return; - } - // TODO(abap2js): ASSIGN lr_handles->* TO . - if (!fs_handles) { - z2ui5_cl_util_ext.bal_create({ object, subobject, id, t_log }); - return; - } - fs_handle = fs_handles[(1) - 1]; - _fs$fs_handle = null; - sy_subrc = 0; - z2ui5_cl_util_ext.bal_std_msg_add({ handle: fs_handle, t_log }); - lv_fm = `BAL_DB_SAVE`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_t_log_handle = EXCEPTIONS OTHERS = 1. - if (sy_subrc === 0) { - z2ui5_port.db({ op: `commit` }); - } - } catch (lx_update) { - throw new z2ui5_cx_util_error({ val: lx_update }); - } - } - } - - static bal_delete({ object, subobject, id } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let fs_filter = null; - let _fs$fs_filter = null; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_filter = null; - let lo_db = null; - let lt_logs = null; - let lv_class = ``; - try { - lo_filter = z2ui5_cl_util_ext.bal_cloud_build_filter({ object, subobject, id }); - lv_class = `CL_BALI_LOG_DB`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_INSTANCE`) RECEIVING db_handler = lo_db. - // TODO(abap2js): CALL METHOD lo_db->(`LOAD_LOGS_VIA_FILTER`) EXPORTING filter = lo_filter RECEIVING log_table = lt_logs. - sy_tabix = 0; - for (const lo_log of lt_logs) { - sy_tabix++; - // TODO(abap2js): CALL METHOD lo_db->(`DELETE_LOG`) EXPORTING log = lo_log. - } - z2ui5_port.db({ op: `commit` }); - } catch (error) { - return; - } - } else { - let lv_fm = ``; - let lr_filter = null; - try { - lr_filter = z2ui5_cl_util_ext.bal_std_build_filter({ object, subobject, id }); - // TODO(abap2js): ASSIGN lr_filter->* TO . - lv_fm = `BAL_DB_DELETE`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_log_filter = EXCEPTIONS OTHERS = 1. - if (sy_subrc === 0) { - z2ui5_port.db({ op: `commit` }); - } - } catch (lx_delete) { - throw new z2ui5_cx_util_error({ val: lx_delete }); - } - } - } - - static tr_get_objects({ trkorr } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_objects = null; - let _fs$fs_objects = null; - let fs_header = null; - let _fs$fs_header = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_xco; - let lv_trkorr_c; - let ls_obj; - if (z2ui5_cl_util.context_check_abap_cloud()) { - try { - let lo_transport = null; - let lt_objects_c = null; - lv_xco = `XCO_CP_CTS`; - lv_trkorr_c = (trkorr); - // TODO(abap2js): CALL METHOD (lv_xco)=>(`TRANSPORT`) EXPORTING iv_transport = lv_trkorr_c RECEIVING ro_transport = lo_transport. - let lo_objects_api = null; - // TODO(abap2js): CALL METHOD lo_transport->(`OBJECTS`) RECEIVING ro_objects = lo_objects_api. - let lo_all = null; - // TODO(abap2js): CALL METHOD lo_objects_api->(`ALL`) RECEIVING ro_all = lo_all. - // TODO(abap2js): CALL METHOD lo_all->(`GET`) RECEIVING rt_objects = lt_objects_c. - sy_tabix = 0; - for (const lo_obj of lt_objects_c) { - sy_tabix++; - let ls_obj_c = {}; - ls_obj_c = null; - try { - // TODO(abap2js): CALL METHOD lo_obj->(`GET_PGMID`) RECEIVING rv_pgmid = ls_obj_c-pgmid. - // TODO(abap2js): CALL METHOD lo_obj->(`GET_TYPE`) RECEIVING rv_type = ls_obj_c-object. - // TODO(abap2js): CALL METHOD lo_obj->(`GET_NAME`) RECEIVING rv_name = ls_obj_c-obj_name. - } catch (error) { - } - result.push(ls_obj_c); - } - } catch (error) { - } - return result; - } - let lr_objects = null; - let lr_header = null; - let lv_fm = ``; - try { - // TODO(abap2js): CREATE DATA lr_objects TYPE STANDARD TABLE OF (`E071`). - // TODO(abap2js): ASSIGN lr_objects->* TO . - // TODO(abap2js): CREATE DATA lr_header TYPE (`TRWBO_REQUEST_HEADER`). - // TODO(abap2js): ASSIGN lr_header->* TO
. - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `TRKORR`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(trkorr); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - lv_fm = `TR_GET_OBJECTS_OF_REQ_AN_TASKS`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING is_request_header =
IMPORTING et_objects = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - return result; - } - sy_tabix = 0; - for (const fs_object of fs_objects) { - sy_tabix++; - ls_obj = {}; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_object, `PGMID`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_obj.pgmid = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_object, `OBJECT`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_obj.object = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_object, `OBJ_NAME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_obj.obj_name = z2ui5_cl_util.abap_copy(fs_comp); - } - result.push(ls_obj); - } - } catch (error) { - } - return result; - } - - static tr_get_user_requests({ user = sy_uname, request_type } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let sy_uname = ""; - let fs_prop = null; - let _fs$fs_prop = null; - let fs_pcomp = null; - let _fs$fs_pcomp = null; - let fs_tab = null; - let _fs$fs_tab = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_xco; - let lv_user_c; - let lv_tab1; - let lv_tab2; - let lv_where; - let lt_comp; - let lo_struct; - let lo_table; - let ls_req; - if (z2ui5_cl_util.context_check_abap_cloud()) { - try { - lv_xco = `XCO_CP_CTS`; - let lo_filter_tr = null; - let lo_status_f = null; - let lo_owner_f = null; - let lt_transports = null; - lv_user_c = ((user ? user : sy_uname)); - // TODO(abap2js): CALL METHOD (lv_xco)=>(`TRANSPORTS`) RECEIVING ro_transports = lo_filter_tr. - let lo_where = null; - // TODO(abap2js): CALL METHOD lo_filter_tr->(`ALL`) RECEIVING ro_all = lo_where. - // TODO(abap2js): CALL METHOD lo_where->(`GET`) RECEIVING rt_transports = lt_transports. - sy_tabix = 0; - for (const lo_tr of lt_transports) { - sy_tabix++; - let ls_req_c = {}; - ls_req_c = null; - try { - let lo_props = null; - // TODO(abap2js): CALL METHOD lo_tr->(`PROPERTIES`) RECEIVING ro_properties = lo_props. - let ls_prop = null; - // TODO(abap2js): CALL METHOD lo_props->(`GET`) RECEIVING rs_properties = ls_prop. - // TODO(abap2js): ASSIGN ls_prop->* TO . - _fs$fs_pcomp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_prop, `OWNER`); - fs_pcomp = _fs$fs_pcomp ? _fs$fs_pcomp.o[_fs$fs_pcomp.k] : null; - sy_subrc = _fs$fs_pcomp ? 0 : 4; - if (sy_subrc === 0) { - ls_req_c.owner = z2ui5_cl_util.abap_copy(fs_pcomp); - } - if (ls_req_c.owner !== lv_user_c) { - continue; - } - _fs$fs_pcomp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_prop, `SHORT_DESCRIPTION`); - fs_pcomp = _fs$fs_pcomp ? _fs$fs_pcomp.o[_fs$fs_pcomp.k] : null; - sy_subrc = _fs$fs_pcomp ? 0 : 4; - if (sy_subrc === 0) { - ls_req_c.description = z2ui5_cl_util.abap_copy(fs_pcomp); - } - _fs$fs_pcomp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_prop, `STATUS`); - fs_pcomp = _fs$fs_pcomp ? _fs$fs_pcomp.o[_fs$fs_pcomp.k] : null; - sy_subrc = _fs$fs_pcomp ? 0 : 4; - if (sy_subrc === 0) { - ls_req_c.status = z2ui5_cl_util.abap_copy(fs_pcomp); - } - _fs$fs_pcomp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_prop, `TYPE`); - fs_pcomp = _fs$fs_pcomp ? _fs$fs_pcomp.o[_fs$fs_pcomp.k] : null; - sy_subrc = _fs$fs_pcomp ? 0 : 4; - if (sy_subrc === 0) { - ls_req_c.type = z2ui5_cl_util.abap_copy(fs_pcomp); - } - let lv_tr_value = ``; - // TODO(abap2js): CALL METHOD lo_tr->(`GET_VALUE`) RECEIVING rv_value = lv_tr_value. - ls_req_c.trkorr = z2ui5_cl_util.abap_copy(lv_tr_value); - } catch (error) { - } - if (ls_req_c.trkorr) { - result.push(ls_req_c); - } - } - } catch (error) { - } - return result; - } - let lv_user = ``; - let lv_type = ``; - let lr_data = null; - try { - lv_user = z2ui5_cl_util.abap_copy(user); - lv_type = z2ui5_cl_util.abap_copy(request_type); - lv_tab1 = `E070`; - lv_tab2 = `E07T`; - lv_where = `AS4USER = '${lv_user}' AND TRSTATUS IN ('D','L')`; - lt_comp = z2ui5_cl_util.rtti_get_t_attri_by_table_name(lv_tab1); - lo_struct = cl_abap_structdescr.create(lt_comp); - lo_table = cl_abap_tabledescr.create(lo_struct); - // TODO(abap2js): CREATE DATA lr_data TYPE HANDLE lo_table. - // TODO(abap2js): ASSIGN lr_data->* TO . - // TODO(abap2js): SELECT trkorr, as4user, trstatus, trfunction FROM (lv_tab1) WHERE (lv_where) INTO CORRESPONDING FIELDS OF TABLE @. - sy_tabix = 0; - for (const fs_row of fs_tab) { - sy_tabix++; - ls_req = {}; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_row, `TRKORR`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_req.trkorr = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_row, `AS4USER`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_req.owner = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_row, `TRSTATUS`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_req.status = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_row, `TRFUNCTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_req.type = z2ui5_cl_util.abap_copy(fs_comp); - } - if (lv_type && ls_req.type !== lv_type) { - continue; - } - ls_req.description = z2ui5_cl_util_ext.tr_get_description({ trkorr: ls_req.trkorr }); - result.push(ls_req); - } - } catch (error) { - } - return result; - } - - static tr_get_description({ trkorr } = {}) { - let result = ``; - let sy_langu = "E"; - let lv_xco_d; - let lv_tab; - let lv_where; - if (z2ui5_cl_util.context_check_abap_cloud()) { - try { - let lo_tr_d = null; - lv_xco_d = `XCO_CP_CTS`; - // TODO(abap2js): CALL METHOD (lv_xco_d)=>(`TRANSPORT`) EXPORTING iv_transport = CONV string( trkorr ) RECEIVING ro_transport = lo_tr_d. - let lo_props_d = null; - // TODO(abap2js): CALL METHOD lo_tr_d->(`PROPERTIES`) RECEIVING ro_properties = lo_props_d. - // TODO(abap2js): CALL METHOD lo_props_d->(`GET_SHORT_DESCRIPTION`) RECEIVING rv_short_description = result. - } catch (error) { - } - return result; - } - let lv_trkorr = ``; - lv_trkorr = z2ui5_cl_util.abap_copy(trkorr); - try { - lv_tab = `E07T`; - lv_where = `TRKORR = '${lv_trkorr}' AND LANGU = '${sy_langu}'`; - // TODO(abap2js): SELECT SINGLE as4text FROM (lv_tab) WHERE (lv_where) INTO @result. - } catch (error) { - } - return result; - } - - static tr_is_released({ trkorr } = {}) { - let result = false; - let lv_xco_r; - let lv_tab; - let lv_where; - if (z2ui5_cl_util.context_check_abap_cloud()) { - try { - let lo_tr_r = null; - lv_xco_r = `XCO_CP_CTS`; - // TODO(abap2js): CALL METHOD (lv_xco_r)=>(`TRANSPORT`) EXPORTING iv_transport = CONV string( trkorr ) RECEIVING ro_transport = lo_tr_r. - let lo_props_r = null; - // TODO(abap2js): CALL METHOD lo_tr_r->(`PROPERTIES`) RECEIVING ro_properties = lo_props_r. - let lv_status_c = ``; - // TODO(abap2js): CALL METHOD lo_props_r->(`GET_STATUS`) RECEIVING rv_status = lv_status_c. - result = (lv_status_c === `RELEASED` || lv_status_c === `R`); - } catch (error) { - result = false; - } - return result; - } - let lv_trkorr = ``; - let lv_status = ``; - lv_trkorr = z2ui5_cl_util.abap_copy(trkorr); - try { - lv_tab = `E070`; - lv_where = `TRKORR = '${lv_trkorr}'`; - // TODO(abap2js): SELECT SINGLE trstatus FROM (lv_tab) WHERE (lv_where) INTO @lv_status. - result = (lv_status === `R`); - } catch (error) { - result = false; - } - return result; - } - - static tr_add_object({ trkorr, pgmid = `R3TR`, object, obj_name } = {}) { - let sy_subrc = 0; - let lv_fm = ``; - let lv_trkorr = ``; - let lv_pgmid = ``; - let lv_object = ``; - let lv_obj_name = ``; - lv_trkorr = z2ui5_cl_util.abap_copy(trkorr); - lv_pgmid = z2ui5_cl_util.abap_copy(pgmid); - lv_object = z2ui5_cl_util.abap_copy(object); - lv_obj_name = z2ui5_cl_util.abap_copy(obj_name); - try { - lv_fm = `TR_ORDER_CHOICE_CORRECTION`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING iv_category = lv_pgmid iv_object = lv_object iv_obj_name = lv_obj_name iv_order = lv_trkorr EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `TR_ADD_OBJECT failed` }); - } - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx = _caught1; - throw lx; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ val: x }); - } else { - throw _caught1; - } - } - } - - static tr_create({ text, target, clike = `T` } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_header = null; - let _fs$fs_header = null; - let fs_trkorr = null; - let _fs$fs_trkorr = null; - try { - let lr_header = null; - let lv_class = ``; - // TODO(abap2js): CREATE DATA lr_header TYPE (`TRWBO_REQUEST_HEADER`). - // TODO(abap2js): ASSIGN lr_header->* TO
. - lv_class = `CL_ADT_CTS_MANAGEMENT`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE_EMPTY_REQUEST`) EXPORTING iv_type = type iv_text = text iv_target = target IMPORTING es_request_header =
. - _fs$fs_trkorr = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `TRKORR`); - fs_trkorr = _fs$fs_trkorr ? _fs$fs_trkorr.o[_fs$fs_trkorr.k] : null; - sy_subrc = _fs$fs_trkorr ? 0 : 4; - result = z2ui5_cl_util.abap_copy(fs_trkorr); - } catch (x) { - throw new z2ui5_cx_util_error({ previous: x }); - } - return result; - } - - static tr_release({ trkorr, ignore_locks = true } = {}) { - try { - let lo_api = null; - let lv_class = ``; - lv_class = `CL_CTS_REST_API_FACTORY`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE_INSTANCE`) RECEIVING result = lo_api. - // TODO(abap2js): CALL METHOD lo_api->(`RELEASE`) EXPORTING iv_trkorr = trkorr iv_ignore_locks = ignore_locks. - } catch (x) { - throw new z2ui5_cx_util_error({ previous: x }); - } - } - - static tr_copy_objects({ source, destination } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let fs_headers = null; - let _fs$fs_headers = null; - let fs_trkorr = null; - let _fs$fs_trkorr = null; - let fs_strkorr = null; - let _fs$fs_strkorr = null; - if (z2ui5_cl_util.context_check_abap_cloud()) { - throw new z2ui5_cx_util_error({ val: `tr_copy_objects is not supported on ABAP Cloud` }); - } - try { - let lr_headers = null; - let lv_fm = ``; - // TODO(abap2js): CREATE DATA lr_headers TYPE (`TRWBO_REQUEST_HEADERS`). - // TODO(abap2js): ASSIGN lr_headers->* TO . - lv_fm = `TR_READ_REQUEST_WITH_TASKS`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING iv_trkorr = source IMPORTING et_request_headers = EXCEPTIONS invalid_input = 1 OTHERS = 2. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `TR_READ_REQUEST_WITH_TASKS failed` }); - } - sy_tabix = 0; - for (const fs_header of fs_headers) { - sy_tabix++; - _fs$fs_trkorr = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `TRKORR`); - fs_trkorr = _fs$fs_trkorr ? _fs$fs_trkorr.o[_fs$fs_trkorr.k] : null; - sy_subrc = _fs$fs_trkorr ? 0 : 4; - _fs$fs_strkorr = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_header, `STRKORR`); - fs_strkorr = _fs$fs_strkorr ? _fs$fs_strkorr.o[_fs$fs_strkorr.k] : null; - sy_subrc = _fs$fs_strkorr ? 0 : 4; - if (fs_trkorr !== source && fs_strkorr !== source) { - continue; - } - lv_fm = `TR_COPY_COMM`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING wi_dialog = abap_false wi_trkorr_from = wi_trkorr_to = destination wi_without_documentation = abap_false EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `TR_COPY_COMM failed` }); - } - } - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx_known = _caught1; - throw lx_known; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ previous: x }); - } else { - throw _caught1; - } - } - } - - static tr_import({ trkorr, target_system, client, ignore_version = true } = {}) { - let result = 0; - let sy_subrc = 0; - let sy_mandt = "000"; - let fs_exc = null; - let _fs$fs_exc = null; - if (z2ui5_cl_util.context_check_abap_cloud()) { - throw new z2ui5_cx_util_error({ val: `tr_import is not supported on ABAP Cloud` }); - } - try { - let lv_system = ``; - let lv_client = ``; - let lv_retcode = ``; - let lr_exc = null; - let lv_fm = ``; - [lv_system, lv_client] = target_system.split(`.`); - if (!lv_client) { - if (client) { - lv_client = z2ui5_cl_util.abap_copy(client); - } else { - lv_client = z2ui5_cl_util.abap_copy(sy_mandt); - } - } - // TODO(abap2js): CREATE DATA lr_exc TYPE (`STMSCALERT`). - // TODO(abap2js): ASSIGN lr_exc->* TO . - lv_fm = `TMS_MGR_REFRESH_IMPORT_QUEUES`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING iv_system = lv_system iv_monitor = abap_true iv_verbose = abap_true IMPORTING es_exception = EXCEPTIONS OTHERS = 99. - if (sy_subrc === 99) { - throw new z2ui5_cx_util_error({ val: `TMS_MGR_REFRESH_IMPORT_QUEUES failed` }); - } - lv_fm = `TMS_MGR_IMPORT_TR_REQUEST`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING iv_system = lv_system iv_request = trkorr iv_client = lv_client iv_ignore_cvers = ignore_version IMPORTING ev_tp_ret_code = lv_retcode EXCEPTIONS read_config_failed = 1 table_of_requests_is_empty = 2 OTHERS = 3. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `TMS_MGR_IMPORT_TR_REQUEST failed` }); - } - result = z2ui5_cl_util.abap_copy(lv_retcode); - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx_known = _caught1; - throw lx_known; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ previous: x }); - } else { - throw _caught1; - } - } - return result; - } - - static tr_check_status({ trkorr, system, imported, rc } = {}) { - let sy_subrc = 0; - let fs_settings = null; - let _fs$fs_settings = null; - let fs_systems = null; - let _fs$fs_systems = null; - let fs_sysline = null; - let _fs$fs_sysline = null; - let fs_cofile = null; - let _fs$fs_cofile = null; - let fs_comp = null; - let _fs$fs_comp = null; - if (z2ui5_cl_util.context_check_abap_cloud()) { - throw new z2ui5_cx_util_error({ val: `tr_check_status is not supported on ABAP Cloud` }); - } - try { - let lr_settings = null; - let lr_cofile = null; - let lr_sysline = null; - let lv_fm = ``; - // TODO(abap2js): CREATE DATA lr_settings TYPE (`CTSLG_SETTINGS`). - // TODO(abap2js): ASSIGN lr_settings->* TO . - _fs$fs_systems = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_settings, `SYSTEMS`); - fs_systems = _fs$fs_systems ? _fs$fs_systems.o[_fs$fs_systems.k] : null; - sy_subrc = _fs$fs_systems ? 0 : 4; - // TODO(abap2js): CREATE DATA lr_sysline LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_sysline->* TO . - fs_sysline = z2ui5_cl_util.abap_copy(system); - if (_fs$fs_sysline) _fs$fs_sysline.o[_fs$fs_sysline.k] = fs_sysline; - fs_systems.push(fs_sysline); - // TODO(abap2js): CREATE DATA lr_cofile TYPE (`CTSLG_COFILE`). - // TODO(abap2js): ASSIGN lr_cofile->* TO . - lv_fm = `TR_READ_GLOBAL_INFO_OF_REQUEST`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING iv_trkorr = trkorr is_settings = IMPORTING es_cofile = . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cofile, `EXISTS`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (!(fs_comp === true || fs_comp === `X`)) { - throw new z2ui5_cx_util_error({ val: `request does not exist in target system` }); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cofile, `IMPORTED`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - imported = z2ui5_cl_util.abap_copy(fs_comp); - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cofile, `RC`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - rc = z2ui5_cl_util.abap_copy(fs_comp); - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx_known = _caught1; - throw lx_known; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ previous: x }); - } else { - throw _caught1; - } - } - } - - static bal_cloud_add_items({ log, t_log } = {}) { - let sy_tabix = 0; - let lo_item = null; - let lv_msgty = ``; - let lv_class = ``; - sy_tabix = 0; - for (const ls_log of t_log) { - sy_tabix++; - lv_msgty = z2ui5_cl_util.abap_copy(ls_log.type); - if (ls_log.id && ls_log.no) { - lv_class = `CL_BALI_MESSAGE_SETTER`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) EXPORTING severity = lv_msgty id = ls_log-id number = ls_log-no variable_1 = ls_log-v1 variable_2 = ls_log-v2 variable_3 = ls_log-v3 variable_4 = ls_log-v4 RECEIVING message = lo_item. - } else { - lv_class = `CL_BALI_FREE_TEXT_SETTER`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) EXPORTING severity = lv_msgty text = ls_log-text RECEIVING free_text = lo_item. - } - // TODO(abap2js): CALL METHOD log->(`ADD_ITEM`) EXPORTING item = lo_item. - } - } - - static bal_cloud_build_filter({ object, subobject, id } = {}) { - let result = null; - let lo_filter = null; - let lv_class = ``; - lv_class = `CL_BALI_LOG_FILTER`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) RECEIVING filter = lo_filter. - // TODO(abap2js): CALL METHOD lo_filter->(`SET_DESCRIPTOR`) EXPORTING object = object subobject = subobject external_id = id. - result = z2ui5_cl_util.abap_copy(lo_filter); - return result; - } - - static bal_std_msg_add({ handle, t_log } = {}) { - let sy_tabix = 0; - let sy_subrc = 0; - let fs_msg = null; - let _fs$fs_msg = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_fm = ``; - let lr_msg = null; - let lv_msgty = ``; - let lv_text = ``; - sy_tabix = 0; - for (const ls_log of t_log) { - sy_tabix++; - if (ls_log.id && ls_log.no) { - // TODO(abap2js): CREATE DATA lr_msg TYPE ('BAL_S_MSG'). - // TODO(abap2js): ASSIGN lr_msg->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGTY`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.type); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGID`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.id); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGNO`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.no); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGV1`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.v1); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGV2`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.v2); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGV3`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.v3); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_msg, `MSGV4`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(ls_log.v4); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - lv_fm = `BAL_LOG_MSG_ADD`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_log_handle = handle i_s_msg = EXCEPTIONS OTHERS = 1. - } else { - lv_msgty = z2ui5_cl_util.abap_copy(ls_log.type); - lv_text = z2ui5_cl_util.abap_copy(ls_log.text); - lv_fm = `BAL_LOG_MSG_ADD_FREE_TEXT`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_log_handle = handle i_msgty = lv_msgty i_text = lv_text EXCEPTIONS OTHERS = 1. - } - } - } - - static bal_std_load_handles({ object, subobject, id } = {}) { - let result = null; - let sy_subrc = 0; - let fs_filter = null; - let _fs$fs_filter = null; - let fs_headers = null; - let _fs$fs_headers = null; - let fs_handles = null; - let _fs$fs_handles = null; - let lv_fm = ``; - let lr_filter = null; - let lr_headers = null; - lr_filter = z2ui5_cl_util_ext.bal_std_build_filter({ object, subobject, id }); - // TODO(abap2js): ASSIGN lr_filter->* TO . - // TODO(abap2js): CREATE DATA lr_headers TYPE ('BALHDR_T'). - // TODO(abap2js): ASSIGN lr_headers->* TO . - lv_fm = `BAL_DB_SEARCH`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_s_log_filter = IMPORTING e_t_log_header = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0 || !fs_headers) { - return result; - } - // TODO(abap2js): CREATE DATA result TYPE ('BAL_T_LOGH'). - // TODO(abap2js): ASSIGN result->* TO . - lv_fm = `BAL_DB_LOAD`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING i_t_log_header = IMPORTING e_t_log_handle = EXCEPTIONS OTHERS = 1. - return result; - } - - static bal_std_build_filter({ object, subobject, id } = {}) { - let result = null; - let sy_subrc = 0; - let fs_filter = null; - let _fs$fs_filter = null; - // TODO(abap2js): CREATE DATA result TYPE ('BAL_S_LFIL'). - // TODO(abap2js): ASSIGN result->* TO . - z2ui5_cl_util_ext.bal_std_filter_add({ comp: `OBJECT`, value: object, filter: fs_filter }); - z2ui5_cl_util_ext.bal_std_filter_add({ comp: `SUBOBJECT`, value: subobject, filter: fs_filter }); - z2ui5_cl_util_ext.bal_std_filter_add({ comp: `EXTNUMBER`, value: id, filter: fs_filter }); - return result; - } - - static bal_std_filter_add({ comp, value, filter } = {}) { - let sy_subrc = 0; - let fs_range = null; - let _fs$fs_range = null; - let fs_line = null; - let _fs$fs_line = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lr_line = null; - if (!value) { - return; - } - _fs$fs_range = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(filter, comp); - fs_range = _fs$fs_range ? _fs$fs_range.o[_fs$fs_range.k] : null; - sy_subrc = _fs$fs_range ? 0 : 4; - if (sy_subrc !== 0) { - return; - } - // TODO(abap2js): CREATE DATA lr_line LIKE LINE OF . - // TODO(abap2js): ASSIGN lr_line->* TO . - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `SIGN`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `I`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `OPTION`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = `EQ`; - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `LOW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - fs_comp = z2ui5_cl_util.abap_copy(value); - if (_fs$fs_comp) _fs$fs_comp.o[_fs$fs_comp.k] = fs_comp; - fs_range.push(fs_line); - } - - static bal_std_map_msg({ msg } = {}) { - let result = null; - let sy_subrc = 0; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_fm = ``; - let lv_text = ``; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGTY`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.type = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGID`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.id = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGNO`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.no = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGV1`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.v1 = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGV2`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.v2 = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGV3`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.v3 = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `MSGV4`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.v4 = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(msg, `TIME_STMP`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - result.timestampl = z2ui5_cl_util.abap_copy(fs_comp); - } - try { - lv_fm = `MESSAGE_TEXT_BUILD`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING msgid = result-id msgnr = result-no msgv1 = result-v1 msgv2 = result-v2 msgv3 = result-v3 msgv4 = result-v4 IMPORTING message_text_output = lv_text. - result.text = z2ui5_cl_util.abap_copy(lv_text); - } catch (error) { - result.text = z2ui5_cl_util.abap_copy(result.v1); - } - return result; - } - - static lock_set({ val, t_param } = {}) { - let result = false; - result = z2ui5_cl_util_ext.lock_call_function({ val, t_param }); - return result; - } - - static lock_set_wait({ val, t_param, retries = 5, delay_ms = 500 } = {}) { - let result = false; - let lv_remaining = z2ui5_cl_util.abap_copy(retries); - while (lv_remaining > 0) { - result = z2ui5_cl_util_ext.lock_set({ val, t_param }); - if ((result === true || result === `X`)) { - return result; - } - lv_remaining = lv_remaining - 1; - if (lv_remaining > 0) { - // TODO(abap2js): WAIT UP TO delay_ms / 1000 SECONDS. - } - } - return result; - } - - static lock_is_locked({ val, t_param } = {}) { - let result = false; - const lv_locked = z2ui5_cl_util_ext.lock_set({ val, t_param }); - if ((lv_locked === true || lv_locked === `X`)) { - z2ui5_cl_util_ext.lock_delete({ val, t_param }); - result = false; - } else { - result = true; - } - return result; - } - - static lock_get_owner({ val, t_param } = {}) { - let result = ``; - let sy_tabix = 0; - let lt_locks; - let lv_arg; - let lv_name; - try { - lt_locks = z2ui5_cl_util_ext.lock_read(); - lv_arg = ``; - sy_tabix = 0; - for (const ls_param of t_param) { - sy_tabix++; - lv_arg = lv_arg + ls_param.value; - } - lv_name = z2ui5_cl_util.c_trim_upper(val); - // TODO(abap2js): REPLACE `ENQUEUE_` IN lv_name WITH ``. - sy_tabix = 0; - for (const ls_lock of lt_locks) { - sy_tabix++; - if (!(String(ls_lock.lock_object).toLowerCase().includes(String(lv_name).toLowerCase()))) continue; - if (!lv_arg || String(ls_lock.argument).toLowerCase().includes(String(lv_arg).toLowerCase())) { - result = z2ui5_cl_util.abap_copy(ls_lock.user); - return result; - } - } - } catch (error) { - } - return result; - } - - static lock_get_dequeue_by_enqueue({ val } = {}) { - let result = ``; - result = z2ui5_cl_util.c_trim_upper(val).replace(`ENQUEUE_`, `DEQUEUE_`); - return result; - } - - static lock_read({ lock_object, user, client } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_lt_enq = null; - let _fs$fs_lt_enq = null; - let fs_lv_value = null; - let _fs$fs_lv_value = null; - let lr_enq = null; - let lv_client = ``; - let lv_name = ``; - let lv_uname = ``; - let lt_param = []; - let ls_param = null; - let lt_exception = []; - let ls_exception = null; - let lv_function = ``; - let ls_lock = {}; - try { - // TODO(abap2js): CREATE DATA lr_enq TYPE STANDARD TABLE OF (`SEQG3`). - // TODO(abap2js): ASSIGN lr_enq->* TO . - if (!client) { - lv_client = z2ui5_cl_util.context_get_sy().mandt; - } else { - lv_client = z2ui5_cl_util.abap_copy(client); - } - lv_name = z2ui5_cl_util.abap_copy(lock_object); - lv_uname = z2ui5_cl_util.abap_copy(user); - ls_param.name = `GCLIENT`; - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_exporting); - // TODO(abap2js): GET REFERENCE OF lv_client INTO ls_param-value. - lt_param.push(ls_param); - ls_param.name = `GNAME`; - // TODO(abap2js): GET REFERENCE OF lv_name INTO ls_param-value. - lt_param.push(ls_param); - ls_param.name = `GUNAME`; - // TODO(abap2js): GET REFERENCE OF lv_uname INTO ls_param-value. - lt_param.push(ls_param); - ls_param.name = `ENQ`; - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_tables); - // TODO(abap2js): GET REFERENCE OF INTO ls_param-value. - lt_param.push(ls_param); - ls_exception.name = `OTHERS`; - ls_exception.value = 4; - lt_exception.push(ls_exception); - lv_function = `ENQUEUE_READ`; - // TODO(abap2js): CALL FUNCTION lv_function PARAMETER-TABLE lt_param EXCEPTION-TABLE lt_exception. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `LOCK_READ_FAILED` }); - } - sy_tabix = 0; - for (const fs_ls_enq of fs_lt_enq) { - sy_tabix++; - ls_lock = null; - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GNAME`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.lock_object = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GARG`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.argument = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUNAME`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.user = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GMODE`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.mode = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GCLIENT`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.client = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GTDATE`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.date = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GTTIME`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.time = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUSR`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.owner = z2ui5_cl_util.abap_copy(fs_lv_value); - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUSRVB`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - ls_lock.owner_vb = z2ui5_cl_util.abap_copy(fs_lv_value); - } - result.push(ls_lock); - } - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx_error = _caught1; - throw lx_error; - } else if (true) { - const lx_root = _caught1; - throw new z2ui5_cx_util_error({ val: lx_root }); - } else { - throw _caught1; - } - } - return result; - } - - static lock_delete({ val, t_param } = {}) { - let result = false; - result = z2ui5_cl_util_ext.lock_call_function({ val: z2ui5_cl_util_ext.lock_get_dequeue_by_enqueue({ val: val }), t_param }); - return result; - } - - static lock_delete_entries({ t_lock } = {}) { - let result = false; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_lt_enq = null; - let _fs$fs_lt_enq = null; - let fs_ls_enq = null; - let _fs$fs_ls_enq = null; - let fs_lv_value = null; - let _fs$fs_lv_value = null; - let lr_enq = null; - let lr_row = null; - let ls_lock = {}; - let lv_check_upd = 0; - let lv_subrc = null; - let lt_param = []; - let ls_param = null; - let lt_exception = []; - let ls_exception = null; - let lv_function = ``; - try { - // TODO(abap2js): CREATE DATA lr_enq TYPE STANDARD TABLE OF (`SEQG3`). - // TODO(abap2js): ASSIGN lr_enq->* TO . - // TODO(abap2js): CREATE DATA lr_row TYPE (`SEQG3`). - // TODO(abap2js): ASSIGN lr_row->* TO . - sy_tabix = 0; - for (const ls_lock of t_lock) { - sy_tabix++; - fs_ls_enq = null; - if (_fs$fs_ls_enq) _fs$fs_ls_enq.o[_fs$fs_ls_enq.k] = fs_ls_enq; - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GNAME`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.lock_object); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GARG`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.argument); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUNAME`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.user); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GMODE`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.mode); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GCLIENT`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.client); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUSR`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.owner); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - _fs$fs_lv_value = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_enq, `GUSRVB`); - fs_lv_value = _fs$fs_lv_value ? _fs$fs_lv_value.o[_fs$fs_lv_value.k] : null; - sy_subrc = _fs$fs_lv_value ? 0 : 4; - if (sy_subrc === 0) { - fs_lv_value = z2ui5_cl_util.abap_copy(ls_lock.owner_vb); - if (_fs$fs_lv_value) _fs$fs_lv_value.o[_fs$fs_lv_value.k] = fs_lv_value; - } - fs_lt_enq.push(fs_ls_enq); - } - if (!fs_lt_enq) { - result = true; - return result; - } - ls_param.name = `CHECK_UPD_REQUESTS`; - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_exporting); - // TODO(abap2js): GET REFERENCE OF lv_check_upd INTO ls_param-value. - lt_param.push(ls_param); - ls_param.name = `SUBRC`; - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_importing); - // TODO(abap2js): GET REFERENCE OF lv_subrc INTO ls_param-value. - lt_param.push(ls_param); - ls_param.name = `ENQ`; - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_tables); - // TODO(abap2js): GET REFERENCE OF INTO ls_param-value. - lt_param.push(ls_param); - ls_exception.name = `OTHERS`; - ls_exception.value = 4; - lt_exception.push(ls_exception); - lv_function = `ENQUE_DELETE`; - // TODO(abap2js): CALL FUNCTION lv_function PARAMETER-TABLE lt_param EXCEPTION-TABLE lt_exception. - result = (sy_subrc === 0 && lv_subrc === 0); - } catch (error) { - result = false; - } - return result; - } - - static auth_check({ object, field, value, activity = `03` } = {}) { - let result = false; - let sy_subrc = 0; - let lv_object = ``; - let lv_field = ``; - let lv_value = ``; - let lv_activity = ``; - lv_object = z2ui5_cl_util.abap_copy(object); - lv_field = z2ui5_cl_util.abap_copy(field); - lv_value = z2ui5_cl_util.abap_copy(value); - lv_activity = z2ui5_cl_util.abap_copy(activity); - // TODO(abap2js): AUTHORITY-CHECK OBJECT lv_object ID lv_field FIELD lv_value ID 'ACTVT' FIELD lv_activity. - result = (sy_subrc === 0); - return result; - } - - static text_get({ msgid, msgno, v1, v2, v3, v4, langu = sy_langu } = {}) { - let result = ``; - let lv_fm; - let lv_msgid = ``; - let lv_msgno = ``; - let lv_msgv1 = ``; - let lv_msgv2 = ``; - let lv_msgv3 = ``; - let lv_msgv4 = ``; - let lv_text = ``; - lv_msgid = z2ui5_cl_util.abap_copy(msgid); - lv_msgno = z2ui5_cl_util.abap_copy(msgno); - lv_msgv1 = z2ui5_cl_util.abap_copy(v1); - lv_msgv2 = z2ui5_cl_util.abap_copy(v2); - lv_msgv3 = z2ui5_cl_util.abap_copy(v3); - lv_msgv4 = z2ui5_cl_util.abap_copy(v4); - try { - lv_fm = `MESSAGE_TEXT_BUILD`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING msgid = lv_msgid msgnr = lv_msgno msgv1 = lv_msgv1 msgv2 = lv_msgv2 msgv3 = lv_msgv3 msgv4 = lv_msgv4 IMPORTING message_text_output = lv_text. - result = z2ui5_cl_util.abap_copy(lv_text); - } catch (error) { - result = `${lv_msgid} ${lv_msgno}: ${lv_msgv1} ${lv_msgv2} ${lv_msgv3} ${lv_msgv4}`; - } - return result; - } - - static mail_send({ subject, body, html = false } = {}) { - let result = false; - let sy_tabix = 0; - let sy_subrc = 0; - let sy_uname = ""; - let fs_body = null; - let _fs$fs_body = null; - let fs_line = null; - let _fs$fs_line = null; - let fs_field = null; - let _fs$fs_field = null; - let lt_lines; - if (z2ui5_cl_util.context_check_abap_cloud()) { - let lo_mail_c = null; - let lv_cls_c = ``; - try { - lv_cls_c = `CL_BCS_MAIL_MESSAGE`; - // TODO(abap2js): CALL METHOD (lv_cls_c)=>(`CREATE_INSTANCE`) RECEIVING result = lo_mail_c. - // TODO(abap2js): CALL METHOD lo_mail_c->(`SET_SENDER`) EXPORTING iv_address = z2ui5_cl_util=>context_get_user_tech( ) && `@placeholder.local`. - // TODO(abap2js): CALL METHOD lo_mail_c->(`ADD_RECIPIENT`) EXPORTING iv_address = to. - // TODO(abap2js): CALL METHOD lo_mail_c->(`SET_SUBJECT`) EXPORTING iv_subject = subject. - if ((html === true || html === `X`)) { - // TODO(abap2js): CALL METHOD lo_mail_c->(`SET_MAIN`) EXPORTING iv_content_type = `text/html` iv_content_text = body. - } else { - // TODO(abap2js): CALL METHOD lo_mail_c->(`SET_MAIN`) EXPORTING iv_content_type = `text/plain` iv_content_text = body. - } - // TODO(abap2js): CALL METHOD lo_mail_c->(`SEND`) RECEIVING result = result. - } catch (error) { - result = false; - } - return result; - } - let lo_mail = null; - let lo_sender = null; - let lo_recipient = null; - let lo_doc = null; - let lr_body = null; - let lr_line = null; - let lv_class = ``; - let lv_subject = ``; - let lv_type = ``; - let lv_address = ``; - lv_subject = z2ui5_cl_util.abap_copy(subject); - lv_address = z2ui5_cl_util.abap_copy(to); - lv_type = ((html === true || html === `X`) ? `HTM` : `RAW`); - try { - lv_class = `CL_BCS`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE_PERSISTENT`) RECEIVING result = lo_mail. - lv_class = `CL_SAPUSER_BCS`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE`) EXPORTING i_user = sy-uname RECEIVING result = lo_sender. - // TODO(abap2js): CALL METHOD lo_mail->(`SET_SENDER`) EXPORTING i_sender = lo_sender. - lv_class = `CL_CAM_ADDRESS_BCS`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE_INTERNET_ADDRESS`) EXPORTING i_address_string = lv_address RECEIVING result = lo_recipient. - // TODO(abap2js): CALL METHOD lo_mail->(`ADD_RECIPIENT`) EXPORTING i_recipient = lo_recipient. - // TODO(abap2js): CREATE DATA lr_body TYPE (`BCSY_TEXT`). - // TODO(abap2js): ASSIGN lr_body->* TO . - // TODO(abap2js): CREATE DATA lr_line TYPE (`SOLI`). - // TODO(abap2js): ASSIGN lr_line->* TO . - lt_lines = z2ui5_cl_util.c_split({ val: body, sep: z2ui5_cl_util.cv_char_util_newline }); - sy_tabix = 0; - for (const lv_body_line of lt_lines) { - sy_tabix++; - _fs$fs_field = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_line, `LINE`); - fs_field = _fs$fs_field ? _fs$fs_field.o[_fs$fs_field.k] : null; - sy_subrc = _fs$fs_field ? 0 : 4; - fs_field = z2ui5_cl_util.abap_copy(lv_body_line); - if (_fs$fs_field) _fs$fs_field.o[_fs$fs_field.k] = fs_field; - fs_body.push(fs_line); - } - lv_class = `CL_DOCUMENT_BCS`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`CREATE_DOCUMENT`) EXPORTING i_type = lv_type i_text = i_subject = lv_subject RECEIVING result = lo_doc. - // TODO(abap2js): CALL METHOD lo_mail->(`SET_DOCUMENT`) EXPORTING i_document = lo_doc. - // TODO(abap2js): CALL METHOD lo_mail->(`SET_SEND_IMMEDIATELY`) EXPORTING i_send_immediately = abap_true. - // TODO(abap2js): CALL METHOD lo_mail->(`SEND`) RECEIVING result = result. - z2ui5_port.db({ op: `commit` }); - } catch (error) { - result = false; - } - return result; - } - - static job_submit_report({ report, variant, start_immediate = true, job_name } = {}) { - let result = ``; - let sy_subrc = 0; - let sy_uname = ""; - let sy_datum = ""; - let sy_uzeit = ""; - if (z2ui5_cl_util.context_check_abap_cloud()) { - throw new z2ui5_cx_util_error({ val: `job_submit_report: On ABAP Cloud use CL_APJ_RT_API with a registered job catalog entry instead` }); - } - let lv_fm = ``; - let lv_jobname = ``; - let lv_jobcount = ``; - let lv_report = ``; - let lv_variant = ``; - lv_report = z2ui5_cl_util.abap_copy(report); - lv_variant = z2ui5_cl_util.abap_copy(variant); - lv_jobname = (job_name ? job_name : `Z2UI5_${sy_datum}${sy_uzeit}`); - try { - lv_fm = `JOB_OPEN`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING jobname = lv_jobname IMPORTING jobcount = lv_jobcount EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `JOB_OPEN failed` }); - } - lv_fm = `JOB_SUBMIT`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING authcknam = sy-uname jobcount = lv_jobcount jobname = lv_jobname report = lv_report variant = lv_variant EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `JOB_SUBMIT failed` }); - } - lv_fm = `JOB_CLOSE`; - if ((start_immediate === true || start_immediate === `X`)) { - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING jobcount = lv_jobcount jobname = lv_jobname strtimmed = abap_true EXCEPTIONS OTHERS = 1. - } else { - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING jobcount = lv_jobcount jobname = lv_jobname EXCEPTIONS OTHERS = 1. - } - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `JOB_CLOSE failed` }); - } - result = z2ui5_cl_util.abap_copy(lv_jobname); - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx = _caught1; - throw lx; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ val: x }); - } else { - throw _caught1; - } - } - return result; - } - - static numrange_get_next({ object, subobject = `01` } = {}) { - let result = ``; - let sy_subrc = 0; - let lv_cls; - let lv_fm; - let lv_object = ``; - let lv_nr_sub = ``; - let lv_number = ``; - lv_object = z2ui5_cl_util.abap_copy(object); - lv_nr_sub = z2ui5_cl_util.abap_copy(subobject); - try { - if (z2ui5_cl_util.context_check_abap_cloud()) { - lv_cls = `CL_NUMBERRANGE_RUNTIME`; - // TODO(abap2js): CALL METHOD (lv_cls)=>(`NUMBER_GET`) EXPORTING nr_range_nr = lv_nr_sub object = lv_object IMPORTING number = lv_number. - } else { - lv_fm = `NUMBER_GET_NEXT`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING nr_range_nr = lv_nr_sub object = lv_object IMPORTING number = lv_number EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - throw new z2ui5_cx_util_error({ val: `NUMBER_GET_NEXT failed for ${lv_object}/${lv_nr_sub}` }); - } - } - result = z2ui5_cl_util.abap_copy(lv_number); - } catch (_caught1) { - if (_caught1 instanceof z2ui5_cx_util_error) { - const lx = _caught1; - throw lx; - } else if (true) { - const x = _caught1; - throw new z2ui5_cx_util_error({ val: x }); - } else { - throw _caught1; - } - } - return result; - } - - static changdoc_read({ objectclass, objectid, date_from = `19000101`, date_to = `99991231` } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_cds_tab = null; - let _fs$fs_cds_tab = null; - let fs_cds_fld = null; - let _fs$fs_cds_fld = null; - let fs_headers = null; - let _fs$fs_headers = null; - let fs_positions = null; - let _fs$fs_positions = null; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_cds; - let lv_where_c; - let lt_comp_c; - let lo_struct_c; - let lo_table_c; - let ls_doc_c; - let ls_doc; - let ls_pos; - if (z2ui5_cl_util.context_check_abap_cloud()) { - try { - lv_cds = `I_CHANGEDOCUMENTITEM`; - lv_where_c = `OBJECTCLASS = '${objectclass}' AND OBJECTID = '${objectid}'`; - if (date_from) { - lv_where_c = `${lv_where_c} AND CREATIONDATE >= '${date_from}'`; - } - if (date_to && date_to !== `99991231`) { - lv_where_c = `${lv_where_c} AND CREATIONDATE <= '${date_to}'`; - } - let lr_cds_tab = null; - lt_comp_c = z2ui5_cl_util.rtti_get_t_attri_by_table_name(lv_cds); - lo_struct_c = cl_abap_structdescr.create(lt_comp_c); - lo_table_c = cl_abap_tabledescr.create(lo_struct_c); - // TODO(abap2js): CREATE DATA lr_cds_tab TYPE HANDLE lo_table_c. - // TODO(abap2js): ASSIGN lr_cds_tab->* TO . - // TODO(abap2js): SELECT * FROM (lv_cds) WHERE (lv_where_c) INTO CORRESPONDING FIELDS OF TABLE @. - sy_tabix = 0; - for (const fs_cds_row of fs_cds_tab) { - sy_tabix++; - ls_doc_c = {}; - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHANGEDOCOBJECTCLASS`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc !== 0) { - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `OBJECTCLASS`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHANGEDOCUMENT`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.changenr = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CREATEDBYUSER`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.username = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CREATIONDATE`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.udate = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CREATIONTIME`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.utime = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `TRANSACTIONCODE`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.tcode = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHNGEDOCITEMFIELDNAME`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.fieldname = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHNGEDOCITEMNEWVALUE`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.new_value = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHNGEDOCITEMOLDVALUE`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.old_value = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHANGEDOCITEMTABLENAME`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.tabname = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - _fs$fs_cds_fld = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_cds_row, `CHNGEDOCITEMCHNGIND`); - fs_cds_fld = _fs$fs_cds_fld ? _fs$fs_cds_fld.o[_fs$fs_cds_fld.k] : null; - sy_subrc = _fs$fs_cds_fld ? 0 : 4; - if (sy_subrc === 0) { - ls_doc_c.chngind = z2ui5_cl_util.abap_copy(fs_cds_fld); - } - result.push(ls_doc_c); - } - } catch (error) { - } - return result; - } - let lv_fm = ``; - let lv_objectclas = ``; - let lv_objectid = ``; - let lr_headers = null; - let lr_positions = null; - lv_objectclas = z2ui5_cl_util.abap_copy(objectclass); - lv_objectid = z2ui5_cl_util.abap_copy(objectid); - try { - // TODO(abap2js): CREATE DATA lr_headers TYPE STANDARD TABLE OF (`CDHDR`). - // TODO(abap2js): CREATE DATA lr_positions TYPE STANDARD TABLE OF (`CDPOS`). - // TODO(abap2js): ASSIGN lr_headers->* TO . - // TODO(abap2js): ASSIGN lr_positions->* TO . - lv_fm = `CHANGEDOCUMENT_READ_HEADERS`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING objectclass = lv_objectclas objectid = lv_objectid date_of_change = date_from TABLES i_cdhdr = EXCEPTIONS OTHERS = 1. - if (sy_subrc !== 0) { - return result; - } - sy_tabix = 0; - for (const fs_hdr of fs_headers) { - sy_tabix++; - ls_doc = {}; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_hdr, `CHANGENR`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_doc.changenr = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_hdr, `USERNAME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_doc.username = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_hdr, `UDATE`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_doc.udate = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_hdr, `UTIME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_doc.utime = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_hdr, `TCODE`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_doc.tcode = z2ui5_cl_util.abap_copy(fs_comp); - } - fs_positions = null; - if (_fs$fs_positions) _fs$fs_positions.o[_fs$fs_positions.k] = fs_positions; - lv_fm = `CHANGEDOCUMENT_READ_POSITIONS`; - // TODO(abap2js): CALL FUNCTION lv_fm EXPORTING changenumber = ls_doc-changenr TABLES editpos = EXCEPTIONS OTHERS = 1. - if (!fs_positions) { - result.push(ls_doc); - } else { - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const fs_pos of fs_positions) { - sy_tabix++; - ls_pos = z2ui5_cl_util.abap_copy(ls_doc); - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_pos, `FNAME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_pos.fieldname = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_pos, `VALUE_OLD`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_pos.old_value = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_pos, `VALUE_NEW`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_pos.new_value = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_pos, `TABNAME`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_pos.tabname = z2ui5_cl_util.abap_copy(fs_comp); - } - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_pos, `CHNGIND`); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (sy_subrc === 0) { - ls_pos.chngind = z2ui5_cl_util.abap_copy(fs_comp); - } - result.push(ls_pos); - } - sy_tabix = _sy_tabix_1; - } - } - } catch (error) { - } - return result; - } - - static source_get_method({ iv_classname, iv_methodname } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - let lt_source = []; - let lt_string = []; - let lv_class = ``; - let lv_method = ``; - let xco_cp_abap = ``; - let lv_name = ``; - let lv_check_method = null; - let lv_source = null; - let lv_source_upper = ``; - try { - lv_class = iv_classname.toUpperCase(); - lv_method = iv_methodname.toUpperCase(); - xco_cp_abap = `XCO_CP_ABAP`; - // TODO(abap2js): CALL METHOD (xco_cp_abap)=>(`CLASS`) EXPORTING iv_name = lv_class RECEIVING ro_class = object. - // TODO(abap2js): ASSIGN object->(`IF_XCO_AO_CLASS~IMPLEMENTATION`) TO . - if (!(sy_subrc === 0)) throw new Error(`ASSERT failed`); - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`IF_XCO_CLAS_IMPLEMENTATION~METHOD`) EXPORTING iv_name = lv_method RECEIVING ro_method = object. - // TODO(abap2js): CALL METHOD object->(`IF_XCO_CLAS_I_METHOD~CONTENT`) RECEIVING ro_content = object. - // TODO(abap2js): CALL METHOD object->(`IF_XCO_CLAS_I_METHOD_CONTENT~GET_SOURCE`) RECEIVING rt_source = result. - } catch (error) { - lv_name = `CL_OO_FACTORY`; - // TODO(abap2js): CALL METHOD (lv_name)=>(`CREATE_INSTANCE`) RECEIVING result = object. - // TODO(abap2js): CALL METHOD object->(`IF_OO_CLIF_SOURCE_FACTORY~CREATE_CLIF_SOURCE`) EXPORTING clif_name = lv_class RECEIVING result = object. - // TODO(abap2js): CALL METHOD object->(`IF_OO_CLIF_SOURCE~GET_SOURCE`) IMPORTING source = lt_source. - lv_check_method = false; - sy_tabix = 0; - for (const lv_source of lt_source) { - sy_tabix++; - lv_source_upper = lv_source.toUpperCase(); - if (String(lv_source_upper).toLowerCase().includes(String(`ENDMETHOD`).toLowerCase())) { - lv_check_method = false; - } - if (String(lv_source_upper).toLowerCase().includes(String(`METHOD ${lv_method}`).toLowerCase())) { - lv_check_method = true; - continue; - } - if ((lv_check_method === true || lv_check_method === `X`)) { - lt_string.push(lv_source); - } - } - result = z2ui5_cl_util.abap_copy(lt_string); - } - return result; - } - - static source_get_method2({ iv_classname, iv_methodname } = {}) { - let result = ``; - const lt_source = z2ui5_cl_util_ext.source_get_method({ iv_classname, iv_methodname }); - result = z2ui5_cl_util_ext.source_method_to_file({ it_source: lt_source }); - return result; - } - - static source_get_file_types() { - let result = []; - const lv_types = `abap, abc, actionscript, ada, apache_conf, applescript, asciidoc, assembly_x86, autohotkey, batchfile, bro, c9search, c_cpp, cirru, clojure, cobol, coffee, coldfusion, csharp, css, curly, d, dart, diff, django, dockerfile, ` + `dot, drools, eiffel, yaml, ejs, elixir, elm, erlang, forth, fortran, ftl, gcode, gherkin, gitignore, glsl, gobstones, golang, groovy, haml, handlebars, haskell, haskell_cabal, haxe, hjson, html, html_elixir, html_ruby, ini, io, jack, jade, java, ja` + `vascri` + `pt, json, jsoniq, jsp, jsx, julia, kotlin, latex, lean, less, liquid, lisp, live_script, livescript, logiql, lsl, lua, luapage, lucene, makefile, markdown, mask, matlab, mavens_mate_log, maze, mel, mips_assembler, mipsassembler, mushcode, mysql, ni` + `x, nsis, objectivec, ocaml, pascal, perl, pgsql, php, plain_text, powershell, praat, prolog, properties, protobuf, python, r, razor, rdoc, rhtml, rst, ruby, rust, sass, scad, scala, scheme, scss, sh, sjs, smarty, snippets, soy_template, space, sql,` + ` sqlserver, stylus, svg, swift, swig, tcl, tex, text, textile, toml, tsx, twig, typescript, vala, vbscript, velocity, verilog, vhdl, wollok, xml, xquery, terraform, slim, redshift, red, puppet, php_laravel_blade, mixal, jssm, fsharp, edifact,` + ` csp, cssound_score, cssound_orchestra, cssound_document`; - result = lv_types.split(`,`); - return result; - } - - static source_method_to_file({ it_source } = {}) { - let result = ``; - let sy_tabix = 0; - sy_tabix = 0; - for (const lv_source of it_source) { - sy_tabix++; - if (lv_source.length > 1) { - result = result + lv_source + 1 + z2ui5_cl_util.cv_char_util_newline; - } else { - result = result + z2ui5_cl_util.cv_char_util_newline; - } - } - return result; - } - - static lock_call_function({ val, t_param } = {}) { - let result = false; - let sy_tabix = 0; - let sy_subrc = 0; - let lt_param = []; - let ls_param = null; - let ls_lock_param = {}; - let lr_value = null; - let lt_exception = []; - let ls_exception = null; - let lv_function = ``; - try { - sy_tabix = 0; - for (const ls_lock_param of t_param) { - sy_tabix++; - ls_param.name = z2ui5_cl_util.abap_copy(ls_lock_param.name); - ls_param.kind = z2ui5_cl_util.abap_copy(abap_func_exporting); - // TODO(abap2js): CREATE DATA lr_value. - lr_value = z2ui5_cl_util.abap_copy(ls_lock_param.value); - ls_param.value = z2ui5_cl_util.abap_copy(lr_value); - lt_param.push(ls_param); - } - ls_exception.name = `OTHERS`; - ls_exception.value = 4; - lt_exception.push(ls_exception); - lv_function = z2ui5_cl_util.c_trim_upper(val); - // TODO(abap2js): CALL FUNCTION lv_function PARAMETER-TABLE lt_param EXCEPTION-TABLE lt_exception. - result = (sy_subrc === 0); - } catch (error) { - result = false; - } - return result; - } - - static cal_get_weekday({ date } = {}) { - let result = 0; - const lv_days = date - (`19000101`); - result = lv_days % 7 + 1; - return result; - } - - static cal_is_weekend({ date } = {}) { - let result = false; - result = (z2ui5_cl_util_ext.cal_get_weekday({ date: date }) >= 6); - return result; - } - - static cal_is_workday({ date, calendar_id } = {}) { - let result = false; - if (calendar_id) { - z2ui5_cl_util.x_raise(`cal_is_workday: factory calendar support is not yet implemented`); - } - result = (!(z2ui5_cl_util_ext.cal_is_weekend({ date: date }) === true || z2ui5_cl_util_ext.cal_is_weekend({ date: date }) === `X`)); - return result; - } - - static cal_add_workdays({ date, days, calendar_id } = {}) { - let result = null; - let lv_remaining = this.abs(days); - const lv_step = (days < 0 ? - 1 : 1); - result = z2ui5_cl_util.abap_copy(date); - while (lv_remaining > 0) { - result = result + lv_step; - if ((z2ui5_cl_util_ext.cal_is_workday({ date: result, calendar_id }) === true || z2ui5_cl_util_ext.cal_is_workday({ date: result, calendar_id }) === `X`)) { - lv_remaining = lv_remaining - 1; - } - } - return result; - } - - static cal_count_workdays({ date_from, date_to, calendar_id } = {}) { - let result = 0; - let lv_date = z2ui5_cl_util.abap_copy(date_from); - const lv_step = (date_to < date_from ? - 1 : 1); - while (lv_date !== date_to) { - lv_date = lv_date + lv_step; - if ((z2ui5_cl_util_ext.cal_is_workday({ date: lv_date, calendar_id }) === true || z2ui5_cl_util_ext.cal_is_workday({ date: lv_date, calendar_id }) === `X`)) { - result = result + 1; - } - } - return result; - } - - static conv_get_xlsx_by_itab({ val } = {}) { - let result = null; - return result; - } - - static conv_get_itab_by_xlsx({ val, result } = {}) { - } - - static zip_pack({ files } = {}) { - let result = null; - let sy_tabix = 0; - let lo_zip = null; - try { - lo_zip = (() => { const _n = String(`CL_ABAP_ZIP`); const _c = z2ui5_cl_util.rtti_get_class(_n.toLowerCase()); if (!_c) throw new Error(`CREATE OBJECT: class ${_n} not found`); return new _c(); })(); - sy_tabix = 0; - for (const ls_file of files) { - sy_tabix++; - // TODO(abap2js): CALL METHOD lo_zip->('ADD') EXPORTING name = ls_file-name content = ls_file-content. - } - // TODO(abap2js): CALL METHOD lo_zip->('SAVE') RECEIVING zip = result. - } catch (x) { - throw new z2ui5_cx_util_error({ val: x }); - } - return result; - } - - static zip_unpack({ val } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_files = null; - let _fs$fs_files = null; - let fs_name = null; - let _fs$fs_name = null; - let lo_zip = null; - let lv_name = ``; - let ls_result = null; - try { - lo_zip = (() => { const _n = String(`CL_ABAP_ZIP`); const _c = z2ui5_cl_util.rtti_get_class(_n.toLowerCase()); if (!_c) throw new Error(`CREATE OBJECT: class ${_n} not found`); return new _c(); })(); - // TODO(abap2js): CALL METHOD lo_zip->('LOAD') EXPORTING zip = val. - // TODO(abap2js): ASSIGN lo_zip->('FILES') TO . - sy_tabix = 0; - for (const fs_file of fs_files) { - sy_tabix++; - _fs$fs_name = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_file, `NAME`); - fs_name = _fs$fs_name ? _fs$fs_name.o[_fs$fs_name.k] : null; - sy_subrc = _fs$fs_name ? 0 : 4; - lv_name = z2ui5_cl_util.abap_copy(fs_name); - ls_result = { name: lv_name }; - // TODO(abap2js): CALL METHOD lo_zip->('GET') EXPORTING name = lv_name IMPORTING content = ls_result-content. - result.push(ls_result); - } - } catch (x) { - throw new z2ui5_cx_util_error({ val: x }); - } - return result; - } -} - -module.exports = z2ui5_cl_util_ext; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_http.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_http.js deleted file mode 100644 index 51ae70b..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_http.js +++ /dev/null @@ -1,229 +0,0 @@ -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); -const z2ui5_cx_util_error = require("abap2UI5/z2ui5_cx_util_error"); - -class z2ui5_cl_util_http { - mo_server_onprem = null; - mo_request_cloud = null; - mo_response_cloud = null; - - static client_create({ destination, url } = {}) { - let result = null; - let sy_subrc = 0; - let lv_classname = ``; - lv_classname = `CL_HTTP_CLIENT`; - let lv_destination = ``; - lv_destination = z2ui5_cl_util.abap_copy(destination); - const lv_url = (url); - try { - if (lv_destination && lv_destination !== `NONE`) { - // TODO(abap2js): CALL METHOD (lv_classname)=>create_by_destination EXPORTING destination = lv_destination IMPORTING client = result EXCEPTIONS argument_not_found = 1 destination_not_found = 2 destination_no_authority = 3 plugin_not_active = 4 internal_error = 5 OTHERS = 6. - } else { - // TODO(abap2js): CALL METHOD (lv_classname)=>create_by_url EXPORTING url = lv_url IMPORTING client = result EXCEPTIONS argument_not_found = 1 plugin_not_active = 2 internal_error = 3 OTHERS = 4. - } - if (sy_subrc !== 0) { - result = null; - } - } catch (x) { - throw new z2ui5_cx_util_error({ val: x }); - } - if (result != null) { - throw new z2ui5_cx_util_error({ val: `HTTP_CLIENT_CREATE_ERROR - check the destination/url configuration` }); - } - return result; - } - - static client_call({ method, body, destination, url } = {}) { - let result = {}; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let lv_method; - let lv_body; - let lo_request = null; - let lo_response = null; - let lv_message = ``; - const lo_client = z2ui5_cl_util_http.client_create({ destination, url }); - try { - // TODO(abap2js): ASSIGN lo_client->(`REQUEST`) TO . - lo_request = z2ui5_cl_util.abap_copy(fs_any); - lv_method = (method); - // TODO(abap2js): CALL METHOD lo_request->(`SET_METHOD`) EXPORTING method = lv_method. - lv_body = (body); - // TODO(abap2js): CALL METHOD lo_request->(`SET_CDATA`) EXPORTING data = lv_body. - // TODO(abap2js): CALL METHOD lo_client->(`SEND`) EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 http_invalid_timeout = 4 OTHERS = 5. - if (sy_subrc === 0) { - // TODO(abap2js): CALL METHOD lo_client->(`RECEIVE`) EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 OTHERS = 4. - } - if (sy_subrc !== 0) { - // TODO(abap2js): CALL METHOD lo_client->(`GET_LAST_ERROR`) IMPORTING message = lv_message. - // TODO(abap2js): CALL METHOD lo_client->(`CLOSE`) EXCEPTIONS OTHERS = 1. - throw new z2ui5_cx_util_error({ val: `HTTP_COMMUNICATION_ERROR - ${lv_message}` }); - } - // TODO(abap2js): ASSIGN lo_client->(`RESPONSE`) TO . - lo_response = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD lo_response->(`GET_CDATA`) RECEIVING data = result-body. - // TODO(abap2js): CALL METHOD lo_response->(`GET_STATUS`) IMPORTING code = result-status_code reason = result-status_reason. - // TODO(abap2js): CALL METHOD lo_client->(`CLOSE`) EXCEPTIONS OTHERS = 1. - } catch (x) { - throw new z2ui5_cx_util_error({ val: x }); - } - return result; - } - - delete_response_cookie({ val } = {}) { - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - const lv_val = (val); - if (this.mo_server_onprem != null) { - let object = null; - // TODO(abap2js): ASSIGN mo_server_onprem->(`RESPONSE`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`DELETE_COOKIE`) EXPORTING name = lv_val. - } else { - } - } - - get_response_cookie({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - const lv_val = (val); - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`RESPONSE`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`GET_COOKIE`) EXPORTING name = lv_val IMPORTING value = result. - } else { - } - return result; - } - - get_header_field({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - const lv_val = (val); - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`REQUEST`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`GET_HEADER_FIELD`) EXPORTING name = lv_val RECEIVING value = result. - } else { - // TODO(abap2js): CALL METHOD mo_request_cloud->(`IF_WEB_HTTP_REQUEST~GET_HEADER_FIELD`) EXPORTING i_name = lv_val RECEIVING r_value = result. - } - return result; - } - - set_header_field({ n, v } = {}) { - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - const lv_n = (n); - const lv_v = (v); - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`RESPONSE`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`SET_HEADER_FIELD`) EXPORTING name = lv_n value = lv_v. - } else { - // TODO(abap2js): CALL METHOD mo_response_cloud->(`IF_WEB_HTTP_RESPONSE~SET_HEADER_FIELD`) EXPORTING i_name = lv_n i_value = lv_v. - } - } - - static factory({ server } = {}) { - let result = null; - result = new z2ui5_cl_util_http(); - result.mo_server_onprem = z2ui5_cl_util.abap_copy(server); - return result; - } - - static factory_cloud({ req, res } = {}) { - let result = null; - result = new z2ui5_cl_util_http(); - result.mo_request_cloud = z2ui5_cl_util.abap_copy(req); - result.mo_response_cloud = z2ui5_cl_util.abap_copy(res); - return result; - } - - get_cdata() { - let result = ``; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`REQUEST`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`GET_CDATA`) RECEIVING data = result. - } else { - // TODO(abap2js): CALL METHOD mo_request_cloud->(`IF_WEB_HTTP_REQUEST~GET_TEXT`) RECEIVING r_value = result. - } - return result; - } - - get_method() { - let result = ``; - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`REQUEST`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`IF_HTTP_REQUEST~GET_METHOD`) RECEIVING method = result. - } else { - // TODO(abap2js): CALL METHOD mo_request_cloud->(`IF_WEB_HTTP_REQUEST~GET_METHOD`) RECEIVING r_value = result. - } - return result; - } - - set_cdata({ val } = {}) { - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`RESPONSE`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`SET_CDATA`) EXPORTING data = val. - } else { - // TODO(abap2js): CALL METHOD mo_response_cloud->(`IF_WEB_HTTP_RESPONSE~SET_TEXT`) EXPORTING i_text = val. - } - } - - set_status({ code, reason } = {}) { - let sy_subrc = 0; - let fs_any = null; - let _fs$fs_any = null; - let object = null; - const lv_reason = (reason); - if (this.mo_server_onprem != null) { - // TODO(abap2js): ASSIGN mo_server_onprem->(`RESPONSE`) TO . - object = z2ui5_cl_util.abap_copy(fs_any); - // TODO(abap2js): CALL METHOD object->(`IF_HTTP_RESPONSE~SET_STATUS`) EXPORTING code = code reason = lv_reason. - } else { - // TODO(abap2js): CALL METHOD mo_response_cloud->(`IF_WEB_HTTP_RESPONSE~SET_STATUS`) EXPORTING i_code = code i_reason = lv_reason. - } - } - - set_session_stateful({ val } = {}) { - if (this.mo_server_onprem != null) { - // TODO(abap2js): CALL METHOD mo_server_onprem->(`SET_SESSION_STATEFUL`) EXPORTING stateful = val. - } else { - } - } - - get_req_info() { - let result = {}; - result.body = this.get_cdata(); - result.method = this.get_method(); - result.path = this.get_header_field({ val: `~path` }); - result.t_params = z2ui5_cl_util.url_param_get_tab(this.get_header_field({ val: `~request_uri` })); - return result; - } -} - -module.exports = z2ui5_cl_util_http; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_log.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_log.js deleted file mode 100644 index a6318e2..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_log.js +++ /dev/null @@ -1,105 +0,0 @@ -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); -const z2ui5_cl_util_ext = require("abap2UI5/z2ui5_cl_util_ext"); - -class z2ui5_cl_util_log { - mt_log = []; - - add({ val } = {}) { - let result = null; - const lt_msg = z2ui5_cl_util.msg_get_t(val); - this.mt_log.push(...lt_msg); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - info({ val } = {}) { - let result = null; - this.mt_log.push({ type: `I`, text: val }); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - error({ val } = {}) { - let result = null; - this.mt_log.push({ type: `E`, text: val }); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - warning({ val } = {}) { - let result = null; - this.mt_log.push({ type: `W`, text: val }); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - success({ val } = {}) { - let result = null; - this.mt_log.push({ type: `S`, text: val }); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - clear() { - let result = null; - this.mt_log = []; - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - has_error() { - let result = false; - result = (this.mt_log.some((row) => row.type === `E`)); - return result; - } - - count() { - let result = 0; - result = z2ui5_cl_util.abap_copy(this.mt_log.length); - return result; - } - - bal_read({ object, subobject, id } = {}) { - const lt_msg = z2ui5_cl_util_ext.bal_read({ object, subobject, id }); - this.mt_log.push(...lt_msg); - } - - bal_save({ object, subobject, id } = {}) { - z2ui5_cl_util_ext.bal_create({ object, subobject, id, t_log: this.mt_log }); - } - - to_csv() { - let result = ``; - result = z2ui5_cl_util.itab_get_csv_by_itab(this.mt_log); - return result; - } - - to_xlsx() { - let result = ``; - result = z2ui5_cl_util_ext.conv_get_xlsx_by_itab(this.mt_log); - return result; - } - - to_msg() { - let result = []; - result = z2ui5_cl_util.abap_copy(this.mt_log); - return result; - } - - to_string() { - let result = ``; - let sy_tabix = 0; - sy_tabix = 0; - for (const ls_msg of this.mt_log) { - sy_tabix++; - if (result) { - result = `${result} -`; - } - result = `${result}[${ls_msg.type}] ${ls_msg.text}`; - } - return result; - } -} - -module.exports = z2ui5_cl_util_log; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_msg.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_msg.js deleted file mode 100644 index 67082e9..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_msg.js +++ /dev/null @@ -1,534 +0,0 @@ -const cl_abap_datadescr = require("abap2UI5/cl_abap_datadescr"); -const cl_abap_typedescr = require("abap2UI5/cl_abap_typedescr"); -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); - -class z2ui5_cl_util_msg { - static msg_get_text({ val, val2 } = {}) { - let result = ``; - const lt_msg = z2ui5_cl_util_msg.msg_get({ val, val2 }); - if (lt_msg) { - result = z2ui5_cl_util.abap_copy(lt_msg[(1) - 1].text); - } - return result; - } - - static msg_get({ val, val2 } = {}) { - let result = []; - result = z2ui5_cl_util_msg.msg_get_internal({ val: val }); - if (!result && val2) { - result = z2ui5_cl_util_msg.msg_get_internal({ val: val2 }); - } - return result; - } - - static msg_get_internal({ val } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_tab = null; - let _fs$fs_tab = null; - let fs_comp = null; - let _fs$fs_comp = null; - let fs_tab2 = null; - let _fs$fs_tab2 = null; - let lt_tab; - let lt_attri; - let ls_result; - let lx; - let lt_attri_o; - let lv_name; - let lt_tab2; - const lv_kind = z2ui5_cl_util.rtti_get_type_kind(val); - switch (lv_kind) { - case cl_abap_datadescr.typekind_table: - fs_tab = val; - _fs$fs_tab = null; - sy_subrc = 0; - sy_tabix = 0; - for (const symbol of fs_tab) { - sy_tabix++; - lt_tab = z2ui5_cl_util_msg.msg_get_internal({ val: fs_row }); - result.push(...lt_tab); - } - break; - case cl_abap_datadescr.typekind_struct1: - case cl_abap_datadescr.typekind_struct2: - if (!val) { - return result; - } - if ((z2ui5_cl_util_msg.check_is_rap_struct({ val: val }) === true || z2ui5_cl_util_msg.check_is_rap_struct({ val: val }) === `X`)) { - result = z2ui5_cl_util_msg.msg_get_rap({ val: val }); - return result; - } - lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - ls_result = {}; - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (ls_attri.name === `ITEM`) { - lt_tab = z2ui5_cl_util_msg.msg_get_internal({ val: fs_comp }); - result.push(...lt_tab); - return result; - } else { - ls_result = z2ui5_cl_util_msg.msg_map({ name: ls_attri.name, val: fs_comp, is_msg: ls_result }); - } - } - if (!ls_result.text && ls_result.id) { - ls_result.id = ls_result.id.toUpperCase(); - // TODO(abap2js): MESSAGE ID ls_result-id TYPE `I` NUMBER ls_result-no WITH ls_result-v1 ls_result-v2 ls_result-v3 ls_result-v4 INTO ls_result-text. - } - result.push(ls_result); - break; - case cl_abap_datadescr.typekind_oref: - try { - lx = (val); - ls_result = { type: `E`, text: lx.get_text() }; - lt_attri_o = z2ui5_cl_util.rtti_get_t_attri_by_oref(val); - sy_tabix = 0; - for (const ls_attri_o of lt_attri_o) { - sy_tabix++; - if (!(ls_attri_o.visibility === `U`)) continue; - lv_name = z2ui5_cl_util.abap_copy(ls_attri_o.name); - // TODO(abap2js): ASSIGN lx->(lv_name) TO . - ls_result = z2ui5_cl_util_msg.msg_map({ name: ls_attri_o.name, val: fs_comp, is_msg: ls_result }); - } - result.push(ls_result); - } catch (error) { - let obj = null; - obj = z2ui5_cl_util.abap_copy(val); - try { - let lr_tab = null; - // TODO(abap2js): CREATE DATA lr_tab TYPE (`if_bali_log=>ty_item_table`). - // TODO(abap2js): ASSIGN lr_tab->* TO FIELD-SYMBOL(). - // TODO(abap2js): CALL METHOD obj->(`IF_BALI_LOG~GET_ALL_ITEMS`) RECEIVING item_table = . - lt_tab2 = z2ui5_cl_util_msg.msg_get_internal({ val: fs_tab2 }); - result.push(...lt_tab2); - } catch (error) { - try { - // TODO(abap2js): CREATE DATA lr_tab TYPE (`BAPIRETTAB`). - // TODO(abap2js): ASSIGN lr_tab->* TO . - // TODO(abap2js): CALL METHOD obj->(`ZIF_LOGGER~EXPORT_TO_TABLE`) RECEIVING rt_bapiret = . - lt_tab2 = z2ui5_cl_util_msg.msg_get_internal({ val: fs_tab2 }); - result.push(...lt_tab2); - } catch (lx2) { - lt_attri_o = z2ui5_cl_util.rtti_get_t_attri_by_oref(val); - sy_tabix = 0; - for (const ls_attri_o of lt_attri_o) { - sy_tabix++; - if (!(ls_attri_o.visibility === `U`)) continue; - lv_name = z2ui5_cl_util.abap_copy(ls_attri_o.name); - // TODO(abap2js): ASSIGN obj->(lv_name) TO . - ls_result = z2ui5_cl_util_msg.msg_map({ name: ls_attri_o.name, val: fs_comp, is_msg: ls_result }); - } - result.push(ls_result); - } - } - } - break; - default: - if (z2ui5_cl_util.rtti_check_clike(val)) { - result.push({ text: val }); - } - break; - } - return result; - } - - static msg_map({ name, val, is_msg } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(is_msg); - switch (name) { - case `ID`: - case `MSGID`: - result.id = z2ui5_cl_util.abap_copy(val); - break; - case `NO`: - case `NUMBER`: - case `MSGNO`: - result.no = z2ui5_cl_util.abap_copy(val); - break; - case `MESSAGE`: - case `TEXT`: - result.text = z2ui5_cl_util.abap_copy(val); - break; - case `TYPE`: - case `MSGTY`: - case `M_SEVERITY`: - result.type = z2ui5_cl_util.abap_copy(val); - break; - case `MESSAGE_V1`: - case `MSGV1`: - case `V1`: - result.v1 = z2ui5_cl_util.abap_copy(val); - break; - case `MESSAGE_V2`: - case `MSGV2`: - case `V2`: - result.v2 = z2ui5_cl_util.abap_copy(val); - break; - case `MESSAGE_V3`: - case `MSGV3`: - case `V3`: - result.v3 = z2ui5_cl_util.abap_copy(val); - break; - case `MESSAGE_V4`: - case `MSGV4`: - case `V4`: - result.v4 = z2ui5_cl_util.abap_copy(val); - break; - case `TIME_STMP`: - result.timestampl = z2ui5_cl_util.abap_copy(val); - break; - } - return result; - } - - static msg_get_by_sy() { - let result = []; - result = z2ui5_cl_util_msg.msg_get({ val: z2ui5_cl_util.context_get_sy() }); - return result; - } - - static msg_get_collect({ val, val2 } = {}) { - let result = ``; - result = /* TODO(abap2js): VALUE FOR/BASE */ [].join(z2ui5_cl_util.cv_char_util_newline); - return result; - } - - static check_is_rap_struct({ val } = {}) { - let result = false; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_tab = null; - let _fs$fs_tab = null; - let lo_tab; - let lo_line; - let lt_comps; - const lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - switch (ls_attri.name) { - case `%MSG`: - case `%FAIL`: - case `%OTHER`: - result = true; - return result; - break; - } - } - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - _fs$fs_tab = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_tab = _fs$fs_tab ? _fs$fs_tab.o[_fs$fs_tab.k] : null; - sy_subrc = _fs$fs_tab ? 0 : 4; - if (!(sy_subrc === 0)) continue; - if (!(z2ui5_cl_util.rtti_get_type_kind(fs_tab) === cl_abap_datadescr.typekind_table)) continue; - try { - lo_tab = (cl_abap_typedescr.describe_by_data(fs_tab)); - lo_line = lo_tab.get_table_line_type(); - if (!(lo_line.kind === cl_abap_typedescr.kind_struct)) continue; - lt_comps = (lo_line).get_components(); - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const ls_comp of lt_comps) { - sy_tabix++; - if (ls_comp.name === `%MSG` || ls_comp.name === `%FAIL`) { - result = true; - return result; - } - } - sy_tabix = _sy_tabix_1; - } catch (error) { - } - } - return result; - } - - static msg_get_rap({ val, entity_name } = {}) { - let result = []; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_msg = null; - let _fs$fs_msg = null; - let fs_fail = null; - let _fs$fs_fail = null; - let fs_cause = null; - let _fs$fs_cause = null; - let fs_tab = null; - let _fs$fs_tab = null; - let fs_ftab = null; - let _fs$fs_ftab = null; - let lt_one; - let lv_text; - const lv_kind = z2ui5_cl_util.rtti_get_type_kind(val); - if (lv_kind !== cl_abap_datadescr.typekind_struct1 && lv_kind !== cl_abap_datadescr.typekind_struct2) { - return result; - } - let lv_is_row = false; - const lt_meta = z2ui5_cl_util_msg.msg_get_rap_meta({ val: val }); - _fs$fs_msg = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%MSG`); - fs_msg = _fs$fs_msg ? _fs$fs_msg.o[_fs$fs_msg.k] : null; - sy_subrc = _fs$fs_msg ? 0 : 4; - if (sy_subrc === 0) { - lv_is_row = true; - if (fs_msg) { - try { - lt_one = z2ui5_cl_util_msg.msg_get({ val: fs_msg }); - sy_tabix = 0; - for (const symbol of lt_one) { - sy_tabix++; - fs_m.t_meta = z2ui5_cl_util.abap_copy(lt_meta); - } - result.push(...lt_one); - } catch (error) { - } - } - } - _fs$fs_fail = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%FAIL`); - fs_fail = _fs$fs_fail ? _fs$fs_fail.o[_fs$fs_fail.k] : null; - sy_subrc = _fs$fs_fail ? 0 : 4; - if (sy_subrc === 0) { - lv_is_row = true; - _fs$fs_cause = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_fail, `CAUSE`); - fs_cause = _fs$fs_cause ? _fs$fs_cause.o[_fs$fs_cause.k] : null; - sy_subrc = _fs$fs_cause ? 0 : 4; - if (sy_subrc === 0) { - let lv_cause = 0; - lv_cause = z2ui5_cl_util.abap_copy(fs_cause); - lv_text = z2ui5_cl_util_msg.msg_get_rap_fail_text({ cause: lv_cause }); - if (entity_name) { - lv_text = `${entity_name}: ${lv_text}`; - } - result.push({ type: `E`, text: lv_text, t_meta: lt_meta }); - } - } - if ((lv_is_row === true || lv_is_row === `X`)) { - return result; - } - const lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - _fs$fs_tab = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_tab = _fs$fs_tab ? _fs$fs_tab.o[_fs$fs_tab.k] : null; - sy_subrc = _fs$fs_tab ? 0 : 4; - if (!(sy_subrc === 0)) continue; - if (!(z2ui5_cl_util.rtti_get_type_kind(fs_tab) === cl_abap_datadescr.typekind_table)) continue; - fs_ftab = fs_tab; - _fs$fs_ftab = null; - sy_subrc = 0; - const _sy_tabix_1 = sy_tabix; - sy_tabix = 0; - for (const symbol of fs_ftab) { - sy_tabix++; - if (z2ui5_cl_util.rtti_get_type_kind(fs_row) === cl_abap_datadescr.typekind_oref) { - if (fs_row) { - try { - result.push(...z2ui5_cl_util_msg.msg_get({ val: fs_row })); - } catch (error) { - } - } - } else { - result.push(...z2ui5_cl_util_msg.msg_get_rap({ val: fs_row, entity_name: ls_attri.name })); - } - } - sy_tabix = _sy_tabix_1; - } - return result; - } - - static msg_get_rap_element({ val } = {}) { - let result = ``; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_flag = null; - let _fs$fs_flag = null; - const lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - if (!(ls_attri.name.length > 9)) continue; - if (!(ls_attri.name(9) === `%ELEMENT-`)) continue; - _fs$fs_flag = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_flag = _fs$fs_flag ? _fs$fs_flag.o[_fs$fs_flag.k] : null; - sy_subrc = _fs$fs_flag ? 0 : 4; - if (!(sy_subrc === 0)) continue; - if (!(fs_flag)) continue; - if (!result) { - result = ls_attri.name + 9; - } else { - result = `${result}, ${ls_attri.name + 9}`; - } - } - return result; - } - - static msg_get_rap_state_area({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_sa = null; - let _fs$fs_sa = null; - _fs$fs_sa = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%STATE_AREA`); - fs_sa = _fs$fs_sa ? _fs$fs_sa.o[_fs$fs_sa.k] : null; - sy_subrc = _fs$fs_sa ? 0 : 4; - if (sy_subrc === 0) { - result = z2ui5_cl_util.abap_copy(fs_sa); - } - return result; - } - - static msg_get_rap_action({ val } = {}) { - let result = ``; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_flag = null; - let _fs$fs_flag = null; - const lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - if (!(ls_attri.name.length > 12)) continue; - if (!(ls_attri.name(12) === `%OP-%ACTION-`)) continue; - _fs$fs_flag = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_flag = _fs$fs_flag ? _fs$fs_flag.o[_fs$fs_flag.k] : null; - sy_subrc = _fs$fs_flag ? 0 : 4; - if (!(sy_subrc === 0)) continue; - if (!(fs_flag)) continue; - result = ls_attri.name + 12; - return result; - } - return result; - } - - static msg_get_rap_pid({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_pid = null; - let _fs$fs_pid = null; - _fs$fs_pid = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%PID`); - fs_pid = _fs$fs_pid ? _fs$fs_pid.o[_fs$fs_pid.k] : null; - sy_subrc = _fs$fs_pid ? 0 : 4; - if (sy_subrc === 0) { - result = z2ui5_cl_util.abap_copy(fs_pid); - } - return result; - } - - static msg_get_rap_cid({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_cid = null; - let _fs$fs_cid = null; - _fs$fs_cid = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%CID`); - fs_cid = _fs$fs_cid ? _fs$fs_cid.o[_fs$fs_cid.k] : null; - sy_subrc = _fs$fs_cid ? 0 : 4; - if (sy_subrc === 0) { - result = z2ui5_cl_util.abap_copy(fs_cid); - } - return result; - } - - static msg_get_rap_tky({ val } = {}) { - let result = ``; - let sy_subrc = 0; - let fs_tky = null; - let _fs$fs_tky = null; - _fs$fs_tky = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, `%TKY`); - fs_tky = _fs$fs_tky ? _fs$fs_tky.o[_fs$fs_tky.k] : null; - sy_subrc = _fs$fs_tky ? 0 : 4; - if (sy_subrc !== 0 || !fs_tky) { - return result; - } - result = z2ui5_cl_util_msg.msg_get_rap_flatten({ val: fs_tky }); - return result; - } - - static msg_get_rap_flatten({ val } = {}) { - let result = ``; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_comp = null; - let _fs$fs_comp = null; - let lv_sub_kind; - let lv_sub; - const lv_kind = z2ui5_cl_util.rtti_get_type_kind(val); - if (lv_kind !== cl_abap_datadescr.typekind_struct1 && lv_kind !== cl_abap_datadescr.typekind_struct2) { - return result; - } - const lt_attri = z2ui5_cl_util.rtti_get_t_attri_by_any(val); - sy_tabix = 0; - for (const ls_attri of lt_attri) { - sy_tabix++; - _fs$fs_comp = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(val, ls_attri.name); - fs_comp = _fs$fs_comp ? _fs$fs_comp.o[_fs$fs_comp.k] : null; - sy_subrc = _fs$fs_comp ? 0 : 4; - if (!(sy_subrc === 0)) continue; - lv_sub_kind = z2ui5_cl_util.rtti_get_type_kind(fs_comp); - if (lv_sub_kind === cl_abap_datadescr.typekind_struct1 || lv_sub_kind === cl_abap_datadescr.typekind_struct2) { - lv_sub = z2ui5_cl_util_msg.msg_get_rap_flatten({ val: fs_comp }); - if (lv_sub) { - if (result) { - result = `${result}, `; - } - result = `${result}${lv_sub}`; - } - } else { - if (fs_comp) { - try { - let lv_str = ``; - lv_str = z2ui5_cl_util.abap_copy(fs_comp); - if (result) { - result = `${result}, `; - } - result = `${result}${ls_attri.name}=${lv_str}`; - } catch (error) { - } - } - } - } - return result; - } - - static msg_get_rap_meta({ val } = {}) { - let result = []; - let lv = ``; - lv = z2ui5_cl_util_msg.msg_get_rap_element({ val: val }); - if (lv) { - result.push({ n: `element`, v: lv }); - } - lv = z2ui5_cl_util_msg.msg_get_rap_state_area({ val: val }); - if (lv) { - result.push({ n: `state_area`, v: lv }); - } - lv = z2ui5_cl_util_msg.msg_get_rap_action({ val: val }); - if (lv) { - result.push({ n: `action`, v: lv }); - } - lv = z2ui5_cl_util_msg.msg_get_rap_pid({ val: val }); - if (lv) { - result.push({ n: `pid`, v: lv }); - } - lv = z2ui5_cl_util_msg.msg_get_rap_cid({ val: val }); - if (lv) { - result.push({ n: `cid`, v: lv }); - } - lv = z2ui5_cl_util_msg.msg_get_rap_tky({ val: val }); - if (lv) { - result.push({ n: `tky`, v: lv }); - } - return result; - } - - static msg_get_rap_fail_text({ cause } = {}) { - let result = ``; - result = (cause === 0 ? `Operation failed` : cause === 1 ? `Entity not found` : cause === 2 ? `Entity is locked` : cause === 3 ? `Authorization failure` : cause === 4 ? `Concurrent modification` : cause === 5 ? `Concurrent modification` : cause === 6 ? `Operation disabled` : cause === 7 ? `Operation forbidden` : cause === 8 ? `Semantic error` : cause === 9 ? `Determination failed` : cause === 10 ? `Permission denied` : cause === 11 ? `Validation failed` : `Operation failed (cause code ${cause})`); - return result; - } -} - -module.exports = z2ui5_cl_util_msg; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_range.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_range.js deleted file mode 100644 index 580a4c8..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_range.js +++ /dev/null @@ -1,157 +0,0 @@ -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); - -class z2ui5_cl_util_range { - static signs = { including: `I`, excluding: `E` }; - static options = { equal: `EQ`, not_equal: `NE`, between: `BT`, not_between: `NB`, contains_pattern: `CP`, not_contains_pattern: `NP`, greater_than: `GT`, greater_equal: `GE`, less_equal: `LE`, less_than: `LT` }; - - mv_fieldname = ``; - mr_range = null; - - static eq({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `EQ`, low: val }; - return result; - } - - static ne({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `NE`, low: val }; - return result; - } - - static bt({ low, high, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `BT`, low: low, high: high }; - return result; - } - - static cp({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `CP`, low: val }; - return result; - } - - static gt({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `GT`, low: val }; - return result; - } - - static ge({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `GE`, low: val }; - return result; - } - - static lt({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `LT`, low: val }; - return result; - } - - static le({ val, sign = `I` } = {}) { - let result = null; - result = { sign: sign, option: `LE`, low: val }; - return result; - } - - static get_sql_multi({ t_sql } = {}) { - let result = ``; - let sy_tabix = 0; - sy_tabix = 0; - for (const lv_sql of t_sql) { - sy_tabix++; - if (!lv_sql) { - continue; - } - if (result) { - result = `${result} AND `; - } - result = `${result}${lv_sql}`; - } - return result; - } - - constructor({ iv_fieldname, ir_range } = {}) { - this.mr_range = z2ui5_cl_util.abap_copy(ir_range); - this.mv_fieldname = `${iv_fieldname.toUpperCase()}`; - } - - get_sql() { - let result = ``; - let sy_tabix = 0; - let sy_subrc = 0; - let fs_lt_range = null; - let _fs$fs_lt_range = null; - let fs_lv_sign = null; - let _fs$fs_lv_sign = null; - let fs_lv_option = null; - let _fs$fs_lv_option = null; - let fs_lv_low = null; - let _fs$fs_lv_low = null; - let fs_lv_high = null; - let _fs$fs_lv_high = null; - // TODO(abap2js): ASSIGN me->mr_range->* TO . - if ((((!fs_lt_range)) === true || ((!fs_lt_range)) === `X`)) { - return result; - } - result = `(`; - sy_tabix = 0; - for (const symbol of fs_lt_range) { - sy_tabix++; - _fs$fs_lv_sign = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_range_item, `SIGN`); - fs_lv_sign = _fs$fs_lv_sign ? _fs$fs_lv_sign.o[_fs$fs_lv_sign.k] : null; - sy_subrc = _fs$fs_lv_sign ? 0 : 4; - _fs$fs_lv_option = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_range_item, `OPTION`); - fs_lv_option = _fs$fs_lv_option ? _fs$fs_lv_option.o[_fs$fs_lv_option.k] : null; - sy_subrc = _fs$fs_lv_option ? 0 : 4; - _fs$fs_lv_low = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_range_item, `LOW`); - fs_lv_low = _fs$fs_lv_low ? _fs$fs_lv_low.o[_fs$fs_lv_low.k] : null; - sy_subrc = _fs$fs_lv_low ? 0 : 4; - _fs$fs_lv_high = ((_o, _c) => { if (_o == null) return null; const _k = typeof _c === "number" ? Object.keys(_o)[_c - 1] : String(_c).toLowerCase(); return _k != null && _k in _o ? { o: _o, k: _k } : null; })(fs_ls_range_item, `HIGH`); - fs_lv_high = _fs$fs_lv_high ? _fs$fs_lv_high.o[_fs$fs_lv_high.k] : null; - sy_subrc = _fs$fs_lv_high ? 0 : 4; - if (sy_tabix !== 1) { - result = `${result} OR`; - } - if (fs_lv_sign === z2ui5_cl_util_range.signs.excluding) { - result = `${result} NOT`; - } - result = `${result} ${this.mv_fieldname}`; - switch (fs_lv_option) { - case z2ui5_cl_util_range.options.equal: - case z2ui5_cl_util_range.options.not_equal: - case z2ui5_cl_util_range.options.greater_than: - case z2ui5_cl_util_range.options.greater_equal: - case z2ui5_cl_util_range.options.less_equal: - case z2ui5_cl_util_range.options.less_than: - result = `${result} ${fs_lv_option} ${z2ui5_cl_util_range.quote({ val: fs_lv_low })}`; - break; - case z2ui5_cl_util_range.options.between: - result = `${result} BETWEEN ${z2ui5_cl_util_range.quote({ val: fs_lv_low })} AND ${z2ui5_cl_util_range.quote({ val: fs_lv_high })}`; - break; - case z2ui5_cl_util_range.options.not_between: - result = `${result} NOT BETWEEN ${z2ui5_cl_util_range.quote({ val: fs_lv_low })} AND ${z2ui5_cl_util_range.quote({ val: fs_lv_high })}`; - break; - case z2ui5_cl_util_range.options.contains_pattern: - // TODO(abap2js): TRANSLATE USING `*%`. - result = `${result} LIKE ${z2ui5_cl_util_range.quote({ val: fs_lv_low })}`; - break; - case z2ui5_cl_util_range.options.not_contains_pattern: - // TODO(abap2js): TRANSLATE USING `*%`. - result = `${result} NOT LIKE ${z2ui5_cl_util_range.quote({ val: fs_lv_low })}`; - break; - } - } - result = `${result} )`; - return result; - } - - static quote({ val } = {}) { - let out = ``; - out = `'${val.replaceAll(`'`, `''`)}'`; - return out; - } -} - -module.exports = z2ui5_cl_util_range; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_xml.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_xml.js deleted file mode 100644 index 79a4813..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cl_util_xml.js +++ /dev/null @@ -1,175 +0,0 @@ -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); - -class z2ui5_cl_util_xml { - mv_name = ``; - mv_ns = ``; - mt_prop = []; - mo_root = null; - mo_previous = null; - mo_parent = null; - mt_child = null; - - constructor() { - } - - static factory() { - let result = null; - result = new z2ui5_cl_util_xml(); - result.mo_root = z2ui5_cl_util.abap_copy(result); - result.mo_parent = z2ui5_cl_util.abap_copy(result); - return result; - } - - __({ n, ns, a, v, p } = {}) { - let result = null; - const lo_child = new z2ui5_cl_util_xml(); - lo_child.mv_name = z2ui5_cl_util.abap_copy(n); - lo_child.mv_ns = z2ui5_cl_util.abap_copy(ns); - lo_child.mt_prop = z2ui5_cl_util.abap_copy(p); - if (a) { - lo_child.mt_prop.push({ n: a, v: v }); - } - lo_child.mo_parent = z2ui5_cl_util.abap_copy(this); - lo_child.mo_root = z2ui5_cl_util.abap_copy(this.mo_root); - this.mt_child.push(lo_child); - this.mo_root.mo_previous = z2ui5_cl_util.abap_copy(lo_child); - result = z2ui5_cl_util.abap_copy(lo_child); - return result; - } - - _({ n, ns, a, v, p } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this); - this.__({ n, ns, a, v, p }); - return result; - } - - _if({ when, n, ns, a, v, p } = {}) { - let result = null; - if ((when === true || when === `X`)) { - this.__({ n, ns, a, v, p }); - } - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - __if({ when, n, ns, a, v, p } = {}) { - let result = null; - if ((when === true || when === `X`)) { - result = this.__({ n, ns, a, v, p }); - } else { - result = z2ui5_cl_util.abap_copy(this); - } - return result; - } - - p({ n, v } = {}) { - let result = null; - this.mt_prop.push({ n: n, v: v }); - result = z2ui5_cl_util.abap_copy(this); - return result; - } - - n({ name } = {}) { - let result = null; - if (!name) { - result = z2ui5_cl_util.abap_copy(this.mo_parent); - return result; - } - if (this.mo_parent.mv_name === name) { - result = z2ui5_cl_util.abap_copy(this.mo_parent); - } else if (this === this.mo_root) { - result = z2ui5_cl_util.abap_copy(this); - } else { - result = this.mo_parent.n(name); - } - return result; - } - - n_prev() { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_root.mo_previous); - return result; - } - - n_root() { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_root); - return result; - } - - stringify({ from_root = true, indent = false } = {}) { - let result = ``; - let lt_parts = []; - if ((indent === true || indent === `X`)) { - if ((from_root === true || from_root === `X`)) { - this.mo_root.xml_get_parts_indent({ ct_parts: lt_parts }); - } else { - this.xml_get_parts_indent({ ct_parts: lt_parts }); - } - result = lt_parts.join(` -`); - } else { - if ((from_root === true || from_root === `X`)) { - this.mo_root.xml_get_parts({ ct_parts: lt_parts }); - } else { - this.xml_get_parts({ ct_parts: lt_parts }); - } - result = /* TODO(abap2js) */ concat_lines_of(lt_parts); - } - return result; - } - - xml_get_parts({ ct_parts } = {}) { - let sy_tabix = 0; - if (!this.mv_name) { - sy_tabix = 0; - for (const lr_root of this.mt_child) { - sy_tabix++; - (lr_root).xml_get_parts({ ct_parts }); - } - return; - } - const lv_tmp2 = (this.mv_ns !== `` ? `${this.mv_ns}:` : null); - const lv_tmp3 = /* TODO(abap2js): REDUCE */ null; - if (!this.mt_child) { - ct_parts.push(` <${lv_tmp2}${this.mv_name}${lv_tmp3}/>`); - return; - } - ct_parts.push(` <${lv_tmp2}${this.mv_name}${lv_tmp3}>`); - sy_tabix = 0; - for (const lr_child of this.mt_child) { - sy_tabix++; - (lr_child).xml_get_parts({ ct_parts }); - } - ct_parts.push(``); - } - - xml_get_parts_indent({ iv_depth = 0, ct_parts } = {}) { - let sy_tabix = 0; - if (!this.mv_name) { - sy_tabix = 0; - for (const lr_root of this.mt_child) { - sy_tabix++; - (lr_root).xml_get_parts_indent({ iv_depth, ct_parts }); - } - return; - } - const lv_pad = ` `.repeat(iv_depth * 2); - const lv_ns = (this.mv_ns !== `` ? `${this.mv_ns}:` : null); - const lv_attr = /* TODO(abap2js): REDUCE */ null; - if (!this.mt_child) { - ct_parts.push(`${lv_pad}<${lv_ns}${this.mv_name}${lv_attr}/>`); - return; - } - ct_parts.push(`${lv_pad}<${lv_ns}${this.mv_name}${lv_attr}>`); - sy_tabix = 0; - for (const lr_child of this.mt_child) { - sy_tabix++; - (lr_child).xml_get_parts_indent({ iv_depth: iv_depth + 1, ct_parts }); - } - ct_parts.push(`${lv_pad}`); - } -} - -module.exports = z2ui5_cl_util_xml; diff --git a/run/input/core/srv/z2ui5/99/01/z2ui5_cx_util_error.js b/run/input/core/srv/z2ui5/99/01/z2ui5_cx_util_error.js deleted file mode 100644 index 115a0e3..0000000 --- a/run/input/core/srv/z2ui5/99/01/z2ui5_cx_util_error.js +++ /dev/null @@ -1,39 +0,0 @@ -const cx_no_check = class {}; // TODO(abap2js): unresolved superclass — replace stub manually -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); - -class z2ui5_cx_util_error extends cx_no_check { - ms_error = { x_root: null, uuid: ``, text: `` }; - - constructor({ val, previous } = {}) { - super.constructor({ previous }); - textid = null; - try { - this.ms_error.x_root = z2ui5_cl_util.abap_copy(val); - } catch (error) { - this.ms_error.text = z2ui5_cl_util.abap_copy(val); - } - this.ms_error.uuid = z2ui5_cl_util.uuid_get_c32(); - } - - get_text() { - let error; - let lo_x; - if (this.ms_error.x_root) { - result = this.ms_error.x_root.get_text(); - error = true; - } else if (this.ms_error.text) { - result = z2ui5_cl_util.abap_copy(this.ms_error.text); - error = true; - } - if (previous != null) { - lo_x = z2ui5_cl_util.abap_copy(previous); - while (lo_x != null) { - result = result + z2ui5_cl_util.cv_char_util_newline + lo_x.get_text(); - lo_x = z2ui5_cl_util.abap_copy(lo_x.previous); - } - } - result = ((error === true || error === `X`) && !result ? `UNKNOWN_ERROR` : result); - } -} - -module.exports = z2ui5_cx_util_error; diff --git a/run/input/core/srv/z2ui5/99/z2ui5_cl_xml_view_cc.js b/run/input/core/srv/z2ui5/99/z2ui5_cl_xml_view_cc.js deleted file mode 100644 index eb188f5..0000000 --- a/run/input/core/srv/z2ui5/99/z2ui5_cl_xml_view_cc.js +++ /dev/null @@ -1,215 +0,0 @@ -const z2ui5_cl_a2ui5_context = require("abap2UI5/z2ui5_cl_a2ui5_context"); -const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); - -class z2ui5_cl_xml_view_cc { - mo_view = null; - - approve_popover({ placement, class: class_, text, btn_txt, btn_type, btn_icon, btn_event } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view.popover({ showheader: false, placement, class: class_ }) - .hbox({ justifycontent: `Center` }) - .vbox({ justifycontent: `Center`, alignitems: `Center` }) - .text(text) - .button({ type: btn_type, text: btn_txt, icon: btn_icon, press: btn_event }); - return result; - } - - bwip_js({ bcid, text, scale, height } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `bwipjs`, ns: `z2ui5`, t_prop: [{ n: `bcid`, v: bcid }, { n: `text`, v: text }, { n: `scale`, v: scale }, { n: `height`, v: height }] }); - return result; - } - - camera_picture({ id, value, thumbnail, height, width, press, autoplay, onphoto, facingmode, deviceid } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `CameraPicture`, ns: `z2ui5`, t_prop: [{ n: `id`, v: id }, { n: `value`, v: value }, { n: `thumbnail`, v: thumbnail }, { n: `press`, v: press }, { n: `height`, v: height }, { n: `width`, v: width }, { n: `OnPhoto`, v: onphoto }, { n: `autoplay`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(autoplay) }, { n: `facingMode`, v: facingmode }, { n: `deviceId`, v: deviceid }] }); - return result; - } - - camera_selector({ selectedkey, showclearicon, selectionchange, selecteditem, items, change, width, showsecondaryvalues, placeholder, selecteditemid, name, value, valuestate, valuestatetext, textalign, visible, showvaluestatemessage, showbutton, required, editable, enabled, filtersecondaryvalues, id, class: class_ } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `CameraSelector`, ns: `z2ui5`, t_prop: [{ n: `showClearIcon`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(showclearicon) }, { n: `selectedKey`, v: selectedkey }, { n: `items`, v: items }, { n: `id`, v: id }, { n: `class`, v: class_ }, { n: `selectionChange`, v: selectionchange }, { n: `selectedItem`, v: selecteditem }, { n: `selectedItemId`, v: selecteditemid }, { n: `name`, v: name }, { n: `value`, v: value }, { n: `valueState`, v: valuestate }, { n: `valueStateText`, v: valuestatetext }, { n: `textAlign`, v: textalign }, { n: `showSecondaryValues`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(showsecondaryvalues) }, { n: `visible`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(visible) }, { n: `showValueStateMessage`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(showvaluestatemessage) }, { n: `showButton`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(showbutton) }, { n: `required`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(required) }, { n: `editable`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(editable) }, { n: `enabled`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(enabled) }, { n: `filterSecondaryValues`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(filtersecondaryvalues) }, { n: `width`, v: width }, { n: `placeholder`, v: placeholder }, { n: `change`, v: change }] }); - return result; - } - - chartjs({ canvas_id, view, config, height, width, style } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `chartjs`, ns: `z2ui5`, t_prop: [{ n: `canvas_id`, v: canvas_id }, { n: `view`, v: view }, { n: `config`, v: config }, { n: `height`, v: height }, { n: `width`, v: width }, { n: `style`, v: style }] }); - return result; - } - - constructor({ view } = {}) { - this.mo_view = z2ui5_cl_util.abap_copy(view); - } - - demo_output({ val } = {}) { - let result = null; - let lv_style = ``; - this.mo_view._generic({ ns: `html`, name: `style` }); - const lv_class = `Z2UI5_CL_CC_DEMO_OUT`; - // TODO(abap2js): CALL METHOD (lv_class)=>(`GET_STYLE`) RECEIVING result = lv_style. - result = this.mo_view._cc_plain_xml(lv_style).html(val); - return result; - } - - favicon({ favicon } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Favicon`, ns: `z2ui5`, t_prop: [{ n: `favicon`, v: favicon }] }); - return result; - } - - file_uploader({ value, path, placeholder, upload, icononly, buttononly, buttontext, uploadbuttontext, checkdirectupload, filetype, icon, enabled } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `FileUploader`, ns: `z2ui5`, t_prop: [{ n: `placeholder`, v: placeholder }, { n: `upload`, v: upload }, { n: `path`, v: path }, { n: `value`, v: value }, { n: `iconOnly`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(icononly) }, { n: `buttonOnly`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(buttononly) }, { n: `buttonText`, v: buttontext }, { n: `uploadButtonText`, v: uploadbuttontext }, { n: `fileType`, v: filetype }, { n: `checkDirectUpload`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(checkdirectupload) }, { n: `icon`, v: icon }, { n: `enabled`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(enabled) }] }); - return result; - } - - focus({ focusid, selectionstart, selectionend, setupdate } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Focus`, ns: `z2ui5`, t_prop: [{ n: `setUpdate`, v: setupdate }, { n: `selectionStart`, v: selectionstart }, { n: `selectionEnd`, v: selectionend }, { n: `focusId`, v: focusid }] }); - return result; - } - - geolocation({ finished, error, longitude, latitude, altitude, accuracy, altitudeaccuracy, speed, heading, enablehighaccuracy, timeout } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Geolocation`, ns: `z2ui5`, t_prop: [{ n: `finished`, v: finished }, { n: `error`, v: error }, { n: `longitude`, v: longitude }, { n: `latitude`, v: latitude }, { n: `altitude`, v: altitude }, { n: `accuracy`, v: accuracy }, { n: `altitudeAccuracy`, v: altitudeaccuracy }, { n: `speed`, v: speed }, { n: `heading`, v: heading }, { n: `enableHighAccuracy`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(enablehighaccuracy) }, { n: `timeout`, v: timeout }] }); - return result; - } - - storage({ finished, prefix, value } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Storage`, ns: `z2ui5`, t_prop: [{ n: `finished`, v: finished }, { n: `type`, v: type }, { n: `prefix`, v: prefix }, { n: `key`, v: key }, { n: `value`, v: value }] }); - return result; - } - - history({ search } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `History`, ns: `z2ui5`, t_prop: [{ n: `search`, v: search }] }); - return result; - } - - info_frontend({ finished, ui5_version, device_height, device_width, device_phone, device_desktop, device_tablet, device_combi, ui5_gav, ui5_theme, device_os, device_systemtype, device_browser } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Info`, ns: `z2ui5`, t_prop: [{ n: `ui5_version`, v: ui5_version }, { n: `ui5_gav`, v: ui5_gav }, { n: `finished`, v: finished }, { n: `ui5_theme`, v: ui5_theme }, { n: `device_os`, v: device_os }, { n: `device_systemtype`, v: device_systemtype }, { n: `device_browser`, v: device_browser }, { n: `device_phone`, v: device_phone }, { n: `device_desktop`, v: device_desktop }, { n: `device_tablet`, v: device_tablet }, { n: `device_combi`, v: device_combi }, { n: `device_height`, v: device_height }, { n: `device_width`, v: device_width }] }); - return result; - } - - message_manager({ items } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `MessageManager`, ns: `z2ui5`, t_prop: [{ n: `items`, v: items }] }); - return result; - } - - messaging({ items } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Messaging`, ns: `z2ui5`, t_prop: [{ n: `items`, v: items }] }); - return result; - } - - multiinput_ext({ multiinputid, multiinputname, change, addedtokens, removedtokens } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `MultiInputExt`, ns: `z2ui5`, t_prop: [{ n: `MultiInputId`, v: multiinputid }, { n: `MultiInputName`, v: multiinputname }, { n: `change`, v: change }, { n: `addedTokens`, v: addedtokens }, { n: `removedTokens`, v: removedtokens }] }); - return result; - } - - uploadset_ext({ uploadsetid, filedata, filename, mediatype, filesize, removedfilename, change, remove } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `UploadSetExt`, ns: `z2ui5`, t_prop: [{ n: `uploadSetId`, v: uploadsetid }, { n: `fileData`, v: filedata }, { n: `fileName`, v: filename }, { n: `mediaType`, v: mediatype }, { n: `fileSize`, v: filesize }, { n: `removedFileName`, v: removedfilename }, { n: `change`, v: change }, { n: `remove`, v: remove }] }); - return result; - } - - tree({ tree_id } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Tree`, ns: `z2ui5`, t_prop: [{ n: `tree_id`, v: tree_id }] }); - return result; - } - - scrolling({ setupdate, items } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Scrolling`, ns: `z2ui5`, t_prop: [{ n: `setUpdate`, v: setupdate }, { n: `items`, v: items }] }); - return result; - } - - spreadsheet_export({ tableid, clike, text, icon, tooltip, columnconfig } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `ExportSpreadsheet`, ns: `z2ui5`, t_prop: [{ n: `tableId`, v: tableid }, { n: `text`, v: text }, { n: `icon`, v: icon }, { n: `type`, v: type }, { n: `tooltip`, v: tooltip }, { n: `columnconfig`, v: columnconfig }] }); - return result; - } - - timer({ finished, delayms, checkrepeat, checkactive } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Timer`, ns: `z2ui5`, t_prop: [{ n: `delayMS`, v: delayms }, { n: `finished`, v: finished }, { n: `checkActive`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(checkactive) }, { n: `checkRepeat`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(checkrepeat) }] }); - return result; - } - - binding_update({ changed, path } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `BindingUpdate`, ns: `z2ui5`, t_prop: [{ n: `path`, v: path }, { n: `changed`, v: changed }] }); - return result; - } - - websocket({ value, received, path, checkrepeat, checkactive } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Websocket`, ns: `z2ui5`, t_prop: [{ n: `value`, v: value }, { n: `path`, v: path }, { n: `received`, v: received }, { n: `checkActive`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(checkactive) }, { n: `checkRepeat`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(checkrepeat) }] }); - return result; - } - - lp_title({ title, applicationfullwidth } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `LPTitle`, ns: `z2ui5`, t_prop: [{ n: `title`, v: title }, { n: `ApplicationFullWidth`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(applicationfullwidth) }] }); - return result; - } - - title({ title } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Title`, ns: `z2ui5`, t_prop: [{ n: `title`, v: title }] }); - return result; - } - - dirty({ isdirty } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `Dirty`, ns: `z2ui5`, t_prop: [{ n: `isDirty`, v: z2ui5_cl_a2ui5_context.boolean_abap_2_json(isdirty) }] }); - return result; - } - - uitableext({ tableid } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `UITableExt`, ns: `z2ui5`, t_prop: [{ n: `tableId`, v: tableid }] }); - return result; - } - - smartmultiinput_ext({ multiinputid, change, rangedata, addedtokens, removedtokens } = {}) { - let result = null; - result = z2ui5_cl_util.abap_copy(this.mo_view); - this.mo_view._generic({ name: `SmartMultiInputExt`, ns: `z2ui5`, t_prop: [{ n: `multiInputId`, v: multiinputid }, { n: `rangeData`, v: rangedata }, { n: `change`, v: change }, { n: `addedTokens`, v: addedtokens }, { n: `removedTokens`, v: removedtokens }] }); - return result; - } -} - -module.exports = z2ui5_cl_xml_view_cc; diff --git a/scripts/mirror-core.js b/scripts/mirror-core.js index 71b5749..6a872bb 100644 --- a/scripts/mirror-core.js +++ b/scripts/mirror-core.js @@ -12,6 +12,14 @@ * (same convention as the run/input snapshots in builder-abap2UI5-js). * run/input/core/ is wiped and rewritten on every run, so upstream * deletions propagate. + * + * The sha in UPSTREAM_HEAD (the trigger slot written by builder-abap2UI5-js) + * is honored when it is NEWER than the cloned default-branch HEAD (the + * fast-double-push race: the announced commit is not yet what a fresh clone + * sees). A stale slot — trigger_cap upstream is manual, so the slot lags — + * must not pin the nightly to an old core, so the newer of the two commits + * wins (committer date; equal-or-older slot ⇒ HEAD). If the slot sha cannot + * be fetched at all, the mirror falls back to HEAD with a warning. */ "use strict"; @@ -42,6 +50,13 @@ function copyCore(fromRepo, commit) { console.log(`mirror: builder-abap2UI5-js@${commit.slice(0, 12)} core/ → run/input/core/`); } +function pinnedSha() { + const slot = path.join(root, "UPSTREAM_HEAD"); + if (!fs.existsSync(slot)) return null; + const sha = fs.readFileSync(slot, "utf8").trim(); + return /^[0-9a-f]{40}$/.test(sha) ? sha : null; +} + const local = process.env.MIRROR_SOURCE; if (local) { const commit = execFileSync("git", ["-C", local, "rev-parse", "HEAD"]).toString().trim(); @@ -50,6 +65,23 @@ if (local) { fs.rmSync(tmp, { recursive: true, force: true }); try { execFileSync("git", ["clone", "--depth", "1", UPSTREAM, tmp], { stdio: "inherit" }); + const head = execFileSync("git", ["-C", tmp, "rev-parse", "HEAD"]).toString().trim(); + const pin = pinnedSha(); + if (pin && pin !== head) { + try { + execFileSync("git", ["-C", tmp, "fetch", "--depth", "1", "origin", pin], { stdio: "inherit" }); + const date = (sha) => + Number(execFileSync("git", ["-C", tmp, "show", "-s", "--format=%ct", sha]).toString().trim()); + if (date(pin) > date(head)) { + execFileSync("git", ["-C", tmp, "checkout", "--force", pin], { stdio: "inherit" }); + console.log(`mirror: honoring UPSTREAM_HEAD ${pin.slice(0, 12)} (newer than cloned HEAD ${head.slice(0, 12)})`); + } else { + console.log(`mirror: UPSTREAM_HEAD ${pin.slice(0, 12)} is stale — mirroring HEAD ${head.slice(0, 12)}`); + } + } catch (e) { + console.warn(`mirror: UPSTREAM_HEAD ${pin.slice(0, 12)} not fetchable — falling back to upstream HEAD`); + } + } const commit = execFileSync("git", ["-C", tmp, "rev-parse", "HEAD"]).toString().trim(); copyCore(tmp, commit); } finally { diff --git a/src/db/schema.cds b/src/db/schema.cds index 89f6334..e07e1fc 100644 --- a/src/db/schema.cds +++ b/src/db/schema.cds @@ -6,7 +6,8 @@ namespace cap2ui5; * abap2UI5 table Z2UI5_T_01). */ entity z2ui5_t_01 { - key id : UUID; - id_prev : UUID; - data : LargeString; + key id : UUID; + id_prev : UUID; + data : LargeString; + createdAt : Timestamp @cds.on.insert: $now; } diff --git a/src/srv/draft-retention.js b/src/srv/draft-retention.js new file mode 100644 index 0000000..b930d15 --- /dev/null +++ b/src/srv/draft-retention.js @@ -0,0 +1,41 @@ +const cds = require("@sap/cds"); + +/** + * Draft retention for cap2ui5.z2ui5_t_01. + * + * The store is append-only (one row per roundtrip, chained via id_prev for + * back-navigation), so without cleanup the table grows without bound in + * production. Rows older than the TTL are dead weight: their draft ids are + * long gone from any live browser session. + * + * Z2UI5_DRAFT_TTL_HOURS TTL in hours (default 24; 0 disables cleanup) + * + * deleteExpiredDrafts() is exported for tests; start() runs it once at + * startup and then hourly (unref'd, so it never keeps the process alive). + */ + +const ttlHours = () => { + const raw = process.env.Z2UI5_DRAFT_TTL_HOURS; + if (raw === undefined || raw === "") return 24; + const n = Number(raw); + return Number.isFinite(n) && n >= 0 ? n : 24; +}; + +async function deleteExpiredDrafts(now = Date.now()) { + const ttl = ttlHours(); + if (ttl === 0) return 0; + const { z2ui5_t_01 } = cds.entities("cap2ui5"); + const cutoff = new Date(now - ttl * 3600 * 1000).toISOString(); + const deleted = await DELETE.from(z2ui5_t_01).where({ createdAt: { "<": cutoff } }); + if (deleted) console.log(`[z2ui5] draft retention: deleted ${deleted} row(s) older than ${ttl}h`); + return deleted; +} + +function start() { + if (ttlHours() === 0) return; + const run = () => deleteExpiredDrafts().catch((e) => console.error("[z2ui5] draft retention failed:", e.message)); + run(); + setInterval(run, 3600 * 1000).unref(); +} + +module.exports = { deleteExpiredDrafts, start }; diff --git a/src/srv/server.js b/src/srv/server.js index 31b8d4f..07cbca2 100644 --- a/src/srv/server.js +++ b/src/srv/server.js @@ -16,7 +16,8 @@ const z2ui5_cl_util_http = require("abap2UI5/z2ui5_cl_util_http"); * /resources → the local UI5 runtime * * plus the two platform ports of this app: - * draft store → the CDS entity cap2ui5.z2ui5_t_01 (db/schema.cds) + * draft store → the CDS entity cap2ui5.z2ui5_t_01 (db/schema.cds), + * expired rows cleaned hourly (srv/draft-retention.js) * app discovery → this project's srv/app/ (custom apps) */ @@ -38,6 +39,10 @@ engine.set_store({ // package are found without registration). engine.register_app_dir(require("path").join(__dirname, "app")); +// Retention: the store above is append-only, so expired draft chains are +// pruned on a timer once the database is connected. +cds.on("served", () => require("./draft-retention").start()); + cds.on("bootstrap", (app) => { // Serve the local UI5 runtime at /resources (must be registered before the // CDS services so it is not shadowed by the OData/REST routing) — the app diff --git a/src/test/draft-retention.test.js b/src/test/draft-retention.test.js new file mode 100644 index 0000000..16a8c4c --- /dev/null +++ b/src/test/draft-retention.test.js @@ -0,0 +1,43 @@ +/** + * Draft retention — expired rows in cap2ui5.z2ui5_t_01 are deleted, fresh + * ones survive (see srv/draft-retention.js; the store itself is append-only). + */ +const path = require("path"); +const cds = require("@sap/cds"); + +cds.test(path.join(__dirname, "..")); + +const { deleteExpiredDrafts } = require("../srv/draft-retention"); + +describe("draft retention", () => { + test("deletes rows older than the TTL, keeps fresh ones", async () => { + const { z2ui5_t_01 } = cds.entities("cap2ui5"); + const now = Date.now(); + const old = { id: cds.utils.uuid(), data: "{}" }; + const fresh = { id: cds.utils.uuid(), data: "{}" }; + await INSERT.into(z2ui5_t_01).entries([old, fresh]); + // @cds.on.insert stamps $now on insert — backdate via UPDATE instead + await UPDATE(z2ui5_t_01, old.id).with({ createdAt: new Date(now - 25 * 3600 * 1000).toISOString() }); + await UPDATE(z2ui5_t_01, fresh.id).with({ createdAt: new Date(now - 1 * 3600 * 1000).toISOString() }); + + await deleteExpiredDrafts(now); // default TTL: 24h + + expect(await SELECT.one.from(z2ui5_t_01).where({ id: old.id })).toBeUndefined(); + expect(await SELECT.one.from(z2ui5_t_01).where({ id: fresh.id })).toBeDefined(); + }); + + test("Z2UI5_DRAFT_TTL_HOURS=0 disables cleanup", async () => { + const { z2ui5_t_01 } = cds.entities("cap2ui5"); + const stale = { id: cds.utils.uuid(), data: "{}" }; + await INSERT.into(z2ui5_t_01).entries([stale]); + await UPDATE(z2ui5_t_01, stale.id).with({ createdAt: new Date(Date.now() - 100 * 3600 * 1000).toISOString() }); + + process.env.Z2UI5_DRAFT_TTL_HOURS = "0"; + try { + expect(await deleteExpiredDrafts()).toBe(0); + } finally { + delete process.env.Z2UI5_DRAFT_TTL_HOURS; + } + expect(await SELECT.one.from(z2ui5_t_01).where({ id: stale.id })).toBeDefined(); + }); +}); From 9a1606eb5969bea247638e6b229dab85cd3a7859 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 01:55:22 +0000 Subject: [PATCH 2/5] assemble: validate rewrite+lock output, preserve core/node_modules across builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The blind string rewrite and the lock merge had no guardrails — a broken result only surfaced in the downstream npm ci. assemble now fails itself when the rewritten package.json is invalid or still references run/input/core, when the lock's abap2UI5 entry does not link ./core, or when the core-lock merge comes up empty. The top-level wipe also deleted core/node_modules (the app lock installs the core deps inside the vendored core/), so every re-assemble silently broke the preserved install until the next full npm ci. The install is now stashed across the wipe like the top-level node_modules — assemble; npm test works repeatedly without reinstalling. Verified: 13/13 jest green after two consecutive assembles on one install. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RXSCVM7CSVZ3Yo9eM4cG6d --- scripts/assemble-cap.js | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/scripts/assemble-cap.js b/scripts/assemble-cap.js index 6acd4a0..fd10ad5 100644 --- a/scripts/assemble-cap.js +++ b/scripts/assemble-cap.js @@ -46,7 +46,9 @@ const COPY_IGNORE = new Set(["node_modules", "gen", "resources", "mta_archives", // Local, non-published entries kept across the wipe of run/output/cap2UI5 // (all gitignored) — avoids a full reinstall after each build. -const PRESERVE = new Set(["node_modules"]); +// (.core_node_modules.keep is the stash for core/node_modules, which the +// app lock places INSIDE the vendored core/ — see below.) +const PRESERVE = new Set(["node_modules", ".core_node_modules.keep"]); function copyDir(from, to, topLevel) { fs.mkdirSync(to, { recursive: true }); @@ -82,6 +84,13 @@ if (!fs.existsSync(path.join(coreSrc, "package.json"))) { } fs.mkdirSync(dest, { recursive: true }); +// core/node_modules lives inside the wiped core/ — stash it before the wipe +// (restored after the core vendor step), same preservation as the top-level +// node_modules. +const coreNm = path.join(dest, "core", "node_modules"); +const coreNmKeep = path.join(dest, ".core_node_modules.keep"); +fs.rmSync(coreNmKeep, { recursive: true, force: true }); +if (fs.existsSync(coreNm)) fs.renameSync(coreNm, coreNmKeep); for (const entry of fs.readdirSync(dest)) { if (PRESERVE.has(entry)) continue; fs.rmSync(path.join(dest, entry), { recursive: true, force: true }); @@ -90,10 +99,12 @@ copyDir(base, dest, true); console.log(`src → run/output/cap2UI5 (source skeleton copied, core dep path rewritten)`); // vendor the mirrored core package into the app (mirror-core already -// strips node_modules from the snapshot) +// strips node_modules from the snapshot), then restore the stashed +// core/node_modules install const coreDest = path.join(dest, "core"); fs.rmSync(coreDest, { recursive: true, force: true }); copyDir(coreSrc, coreDest, false); +if (fs.existsSync(coreNmKeep)) fs.renameSync(coreNmKeep, coreNm); console.log(` vendor core (from run/input/core) → core: ${countFiles(coreDest)} files`); const webappSrc = path.join(coreSrc, "app", "z2ui5", "webapp"); @@ -123,4 +134,35 @@ for (const [key, entry] of Object.entries(coreLock.packages || {})) { fs.writeFileSync(appLockPath, JSON.stringify(appLock, null, 2) + "\n"); console.log(` merge core lock → package-lock.json: ${merged} entries under core/node_modules/`); +// Guardrails over the blind string rewrite + lock merge — fail the build +// here instead of in the downstream `npm ci`: +{ + const problems = []; + let pkg; + try { + pkg = JSON.parse(fs.readFileSync(path.join(dest, "package.json"), "utf8")); + } catch (e) { + problems.push(`package.json is not valid JSON after rewrite: ${e.message}`); + } + if (pkg && pkg.dependencies?.abap2UI5 !== "file:./core") { + problems.push(`package.json dependency abap2UI5 is "${pkg?.dependencies?.abap2UI5}", expected "file:./core"`); + } + for (const f of ["package.json", "package-lock.json"]) { + if (fs.readFileSync(path.join(dest, f), "utf8").includes("run/input/core")) { + problems.push(`${f} still references run/input/core after rewrite`); + } + } + const linkEntry = appLock.packages?.["node_modules/abap2UI5"]; + if (!linkEntry || linkEntry.resolved !== "core") { + problems.push(`lock entry node_modules/abap2UI5 does not link "core" (got ${JSON.stringify(linkEntry?.resolved)})`); + } + if (!appLock.packages?.["core"]) problems.push(`lock has no "core" package entry`); + if (merged === 0) problems.push("core lock merge produced 0 entries — empty/renamed core lock?"); + if (problems.length) { + console.error(`assemble: output validation FAILED —\n - ${problems.join("\n - ")}`); + process.exit(1); + } + console.log(` validate: dep rewrite + lock merge OK`); +} + console.log(`\nassembled → run/output/cap2UI5`); From e333168a05c0963c891a1f8ae5c5c49ec7c1498f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 01:56:35 +0000 Subject: [PATCH 3/5] Test the NorthwindCustomers remote proxy (offline, mocked northwind) The READ handler in z2ui5-service.js was the only untested code path in src/. The new test mocks cds.connect.to('northwind') and asserts the query is forwarded exactly once and the remote rows come back through the AdminService projection. 14/14 jest green. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RXSCVM7CSVZ3Yo9eM4cG6d --- src/test/northwind.test.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/northwind.test.js diff --git a/src/test/northwind.test.js b/src/test/northwind.test.js new file mode 100644 index 0000000..783e64a --- /dev/null +++ b/src/test/northwind.test.js @@ -0,0 +1,34 @@ +/** + * NorthwindCustomers READ handler (srv/z2ui5-service.js) — the request must + * be forwarded to the remote 'northwind' OData service and its rows + * returned through the AdminService projection. The remote is mocked at + * cds.connect.to, so the test runs offline and only exercises our wiring. + */ +const path = require("path"); +const cds = require("@sap/cds"); + +const { GET } = cds.test(path.join(__dirname, "..")); + +describe("NorthwindCustomers remote proxy", () => { + test("READ forwards the query to the northwind service", async () => { + const rows = [ + { CustomerID: "ALFKI", CompanyName: "Alfreds Futterkiste" }, + { CustomerID: "ANATR", CompanyName: "Ana Trujillo Emparedados" }, + ]; + const seen = []; + const orig = cds.connect.to; + cds.connect.to = async function (name, ...rest) { + if (name === "northwind") return { run: async (query) => (seen.push(query), rows) }; + return orig.call(this, name, ...rest); + }; + try { + const res = await GET("/odata/v4/admin/NorthwindCustomers"); + expect(res.status).toBe(200); + expect(res.data.value.map((r) => r.CustomerID)).toEqual(["ALFKI", "ANATR"]); + expect(res.data.value[0].CompanyName).toBe("Alfreds Futterkiste"); + expect(seen).toHaveLength(1); // exactly one forwarded query + } finally { + cds.connect.to = orig; + } + }); +}); From 91dc12e75a2f83037cf8895b39d41876f6687b50 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 01:57:00 +0000 Subject: [PATCH 4/5] update_cap: retry the mirror-commit push on a lost rebase race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rebase+push in the commit step had no retry — a concurrent push to main between the two commands failed the whole nightly. Up to three rebase+push attempts with backoff now. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RXSCVM7CSVZ3Yo9eM4cG6d --- .github/workflows/update_cap.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_cap.yml b/.github/workflows/update_cap.yml index d21ab8f..7c829a3 100644 --- a/.github/workflows/update_cap.yml +++ b/.github/workflows/update_cap.yml @@ -51,8 +51,18 @@ jobs: echo "mirror unchanged" else git commit -m "mirror: update run/input/core ($(cut -c1-12 run/input/UPSTREAM_COMMIT))" - git pull --rebase origin main - git push origin HEAD:main + # a concurrent push to main between rebase and push loses the + # race — retry the rebase+push a few times before giving up + for i in 1 2 3; do + git pull --rebase origin main + if git push origin HEAD:main; then + break + elif [ "$i" = 3 ]; then + echo "push failed after 3 attempts" >&2 + exit 1 + fi + sleep $((i * 2)) + done fi - run: npm run assemble # one install covers the app AND the vendored core (its deps are part From 789a92fd2c074d35a772c4a558252a9816a1d09b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 08:35:27 +0000 Subject: [PATCH 5/5] Pin the abap2UI5 port contract with a jest suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors the new "Downstream JS Port Contract" section in upstream abap2UI5's AGENTS.md: asserts the engine seam surface (roundtrip, bootstrap_html, set_store, register_app_dir, ui5_resources_dir, WEBAPP_DIR), the draft-store injection point and app-class registry, and a real handler roundtrip answering the {S_FRONT.APP, 36-char draft id} wire shape — so a core update that moves a seam fails this suite instead of breaking the CAP app or the web build silently. 17/17 green. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RXSCVM7CSVZ3Yo9eM4cG6d --- src/test/port-contract.test.js | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/test/port-contract.test.js diff --git a/src/test/port-contract.test.js b/src/test/port-contract.test.js new file mode 100644 index 0000000..4b1d942 --- /dev/null +++ b/src/test/port-contract.test.js @@ -0,0 +1,45 @@ +/** + * Port-contract pin — the seam surface both this CAP app and the browser + * build (builder-cap2UI5-web) wire against, documented upstream in + * abap2UI5's AGENTS.md ("Downstream JS Port Contract"). If one of these + * assertions fails after a core update, a load-bearing seam changed and the + * consumers (srv/server.js, the web build's entry.mjs/gen-registry.mjs) + * must be adjusted in the same change set. + */ +const engine = require("abap2UI5/engine"); +const z2ui5_cl_util = require("abap2UI5/z2ui5_cl_util"); +const z2ui5_cl_core_srv_draft = require("abap2UI5/z2ui5_cl_core_srv_draft"); +const z2ui5_cl_http_handler = require("abap2UI5/z2ui5_cl_http_handler"); + +describe("abap2UI5 port contract", () => { + test("engine exposes the platform seam", () => { + expect(typeof engine.roundtrip).toBe("function"); + expect(typeof engine.bootstrap_html).toBe("function"); + expect(typeof engine.set_store).toBe("function"); + expect(typeof engine.register_app_dir).toBe("function"); + expect(typeof engine.ui5_resources_dir).toBe("function"); + expect(typeof engine.WEBAPP_DIR).toBe("string"); + }); + + test("draft store injection point and app-class registry exist", () => { + expect(typeof z2ui5_cl_core_srv_draft.set_store).toBe("function"); + expect(typeof z2ui5_cl_util.register_app_class).toBe("function"); + }); + + test("http handler answers the wire format { body, status_code }", async () => { + // minimal roundtrip through the real handler — no CDS involved, the + // draft store is swapped for an in-memory map for this test + const mem = new Map(); + z2ui5_cl_core_srv_draft.set_store({ + load: async (id) => mem.get(id), + save: async (e) => void mem.set(e.id, e), + }); + const res = await z2ui5_cl_http_handler({ + data: { + value: { S_FRONT: { ORIGIN: "http://localhost", PATHNAME: "/", SEARCH: "", HASH: "" } }, + }, + }); + expect(res).toHaveProperty("S_FRONT.APP"); + expect(res.S_FRONT.ID).toMatch(/^[0-9a-f-]{36}$/); + }); +});