Skip to content

Commit

Permalink
use introduced Kronos ABAP API from the app
Browse files Browse the repository at this point in the history
  • Loading branch information
iliyan-velichkov committed Jun 21, 2024
1 parent 71376da commit 8669a38
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 88 deletions.
2 changes: 1 addition & 1 deletion abap_transpile.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"input_folder": "src/abap",
"input_folder": "{../../../../root/registry/public/kronos/src/abap,src/abap}",
"input_filter": [],
"output_folder": "dist/abap",
"libs": [
Expand Down
29 changes: 0 additions & 29 deletions abaplint.jsonc

This file was deleted.

15 changes: 12 additions & 3 deletions build-mac.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# fail the whole script if any command bellow fails
set -e

export KRONOS_SRC='/Users/iliyan/work/kronos-work-dir/repo/dirigible/repository/root/registry/public/kronos/src/abap/http'

rm -rf dist
rm -rf node_modules

Expand All @@ -8,13 +13,17 @@ npm install
# check package.json for more details
npm run transpile

npm run lint
# TODO: temp commented
# to be fixed
# npm run lint

# Find all .mjs files in the current directory and its subdirectories,
# and replaces all occurrences of %23 with # in those files.
find . -name '*.mjs' -print0 | xargs -0 sed -i '' 's/%23/#/g'

esbuild src/run.mjs --tsconfig=./tsconfig.json --bundle --outdir=dist --format=esm --target=es2022 \
--external:tls --external:net --external:util --external:crypto --external:zlib \
--external:http --external:https --external:fs --external:path --external:url --external:sdk \
--inject:./src/lib/polyfills/buffer.js --inject:./src/lib/polyfills/process.js --out-extension:.js=.mjs
--external:http --external:https --external:fs --external:path --external:url \
--external:sdk \
--inject:./src/lib/polyfills/buffer.js --inject:./src/lib/polyfills/process.js \
--out-extension:.js=.mjs
26 changes: 13 additions & 13 deletions src/abap/zcl_abap_app.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,55 @@ CLASS zcl_abap_app IMPLEMENTATION.
ENDMETHOD.

METHOD print_hello_world.
zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Hello world!' ).
ENDMETHOD.

METHOD delete_all_employees.
zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Deleting all employees...' ).

zcl_dirigible_employee_dao=>delete_all_employees( ).
zcl_employee_dao=>delete_all_employees( ).

zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'All employees were deleted.' ).
ENDMETHOD.

METHOD insert_employee.
zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Inserting an employee...' ).

zcl_dirigible_employee_dao=>insert_employee( ).
zcl_employee_dao=>insert_employee( ).

zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'An employee was inserted.' ).
ENDMETHOD.

METHOD select_all_employees.
zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Selecting all employees...' ).

zcl_dirigible_employee_dao=>select_all( ).
zcl_employee_dao=>select_all( ).

zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Employees selected.' ).
ENDMETHOD.

METHOD update_employee_last_name.
zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Updating employee last name...' ).

zcl_dirigible_employee_dao=>update_employee_last_name( ).
zcl_employee_dao=>update_employee_last_name( ).

zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = 'Employee last name was updated.' ).
ENDMETHOD.
Expand Down
15 changes: 0 additions & 15 deletions src/abap/zcl_dirigible_response.clas.abap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASS zcl_dirigible_employee_dao DEFINITION PUBLIC.
CLASS zcl_employee_dao DEFINITION PUBLIC.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_employee,
Expand All @@ -17,7 +17,7 @@ CLASS zcl_dirigible_employee_dao DEFINITION PUBLIC.

ENDCLASS.

CLASS zcl_dirigible_employee_dao IMPLEMENTATION.
CLASS zcl_employee_dao IMPLEMENTATION.

METHOD delete_all_employees.
DATA: lv_rc TYPE i.
Expand All @@ -41,7 +41,7 @@ CLASS zcl_dirigible_employee_dao IMPLEMENTATION.
FROM employees
INTO TABLE lt_employees.

zcl_dirigible_response=>println(
zcl_codbex_response=>println(
EXPORTING
message_in = lt_employees ).
ENDMETHOD.
Expand Down
66 changes: 42 additions & 24 deletions src/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,50 @@ import { DatabaseInitializer } from "sdk/abap/database";
import { initializeABAP } from '../dist/abap/init.mjs';

import { zcl_abap_app } from '../dist/abap/zcl_abap_app.clas.mjs';
import { zcl_employee_dao } from '../dist/abap/zcl_employee_dao.clas.mjs';

DatabaseInitializer.initDefaultDataSource();
await initializeABAP();

// a workaround for https://github.com/abaplint/transpiler/issues/1441
// manually register the table
abap.DDIC.EMPLOYEES = {
"objectType": "TABL",
"type": {
"value": {
"offset": {
"value": 0,
"qualifiedName": "I"
async function initialize() {
DatabaseInitializer.initDefaultDataSource();
await initializeABAP();

// a workaround for https://github.com/abaplint/transpiler/issues/1441
// manually register the table
abap.DDIC.EMPLOYEES = {
"objectType": "TABL",
"type": {
"value": {
"offset": {
"value": 0,
"qualifiedName": "I"
},
"length": {
"value": 0,
"qualifiedName": "I"
}
},
"length": {
"value": 0,
"qualifiedName": "I"
}
"qualifiedName": "employees",
"ddicName": "employees",
"suffix": {},
"asInclude": {}
},
"qualifiedName": "employees",
"ddicName": "employees",
"suffix": {},
"asInclude": {}
},
"keyFields": ["id"]
};
"keyFields": ["id"]
};
}

async function runABAPCode() {
await zcl_abap_app.run();
}

await initialize();

await runABAPCode();

async function useDAO() {
console.log("Getting all employees...");
const employees = zcl_employee_dao.select_all();
console.log("All employees: " + JSON.stringify(employees));

await zcl_abap_app.run();
console.log("Done");
}

await useDAO();

0 comments on commit 8669a38

Please sign in to comment.