Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/01/00/02/z2ui6_cl_abap_api_http.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ CLASS z2ui6_cl_abap_api_http DEFINITION PUBLIC.
v TYPE clike.

DATA mo_server_onprem TYPE REF TO object.

PROTECTED SECTION.

DATA mo_request_cloud TYPE REF TO object.
DATA mo_response_cloud TYPE REF TO object.

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

Expand Down
168 changes: 164 additions & 4 deletions src/01/00/03/z2ui6_cl_util.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ CLASS z2ui6_cl_util DEFINITION
t_filter TYPE ty_t_filter_multi,
END OF ty_s_sql.

TYPES:
BEGIN OF ty_S_msg,
text TYPE string,
id TYPE string,
no TYPE string,
type TYPE string,
v1 TYPE string,
v2 TYPE string,
v3 TYPE string,
v4 TYPE string,
END OF ty_s_msg,
ty_T_msg TYPE STANDARD TABLE OF ty_S_msg WITH EMPTY KEY.

CLASS-METHODS ui5_get_msg_type
IMPORTING
val TYPE clike
RETURNING
VALUE(result) TYPE string.

CLASS-METHODS msg_get
IMPORTING
val TYPE any
RETURNING
VALUE(result) TYPE ty_T_msg.

CLASS-METHODS rtti_get_t_attri_by_include
IMPORTING
type TYPE REF TO cl_abap_datadescr
Expand Down Expand Up @@ -425,6 +450,11 @@ CLASS z2ui6_cl_util DEFINITION
VALUE(result) TYPE string.

CLASS-METHODS check_raise_srtti_installed.
CLASS-METHODS rtti_check_clike
IMPORTING
val TYPE any
RETURNING
VALUE(result) TYPE abap_bool.

PROTECTED SECTION.
PRIVATE SECTION.
Expand Down Expand Up @@ -1294,10 +1324,7 @@ CLASS z2ui6_cl_util IMPLEMENTATION.

IF rtti_check_class_exists( 'ZCL_SRTTI_TYPEDESCR' ) = abap_false.

DATA(lv_link) = `https://github.com/sandraros/S-RTTI`.
DATA(lv_text) = `<p>Please install the open-source project S-RTTI by sandraros and try again: <a href="` &&
lv_link && `" style="color:blue; font-weight:600;" target="_blank">(link)</a></p>`.

DATA(lv_text) = `UNSUPPORTED_FEATURE - Please install the open-source project S-RTTI by sandraros and try again: https://github.com/sandraros/S-RTTI`.
RAISE EXCEPTION TYPE z2ui6_cx_util_error
EXPORTING
val = lv_text.
Expand Down Expand Up @@ -1419,4 +1446,137 @@ CLASS z2ui6_cl_util IMPLEMENTATION.

ENDMETHOD.


METHOD msg_get.

DATA(lv_kind) = z2ui6_cl_util=>rtti_get_type_kind( val ).
CASE lv_kind.

WHEN cl_abap_datadescr=>typekind_table.
FIELD-SYMBOLS <tab> TYPE STANDARD TABLE.
ASSIGN val TO <tab>.
LOOP AT <tab> ASSIGNING FIELD-SYMBOL(<row>).
DATA(lt_tab) = msg_get( <row> ).
INSERT LINES OF lt_tab INTO TABLE result.
ENDLOOP.

WHEN cl_abap_datadescr=>typekind_struct1 OR cl_abap_datadescr=>typekind_struct2.

IF val IS INITIAL.
RETURN.
ENDIF.

DATA(lt_attri) = z2ui6_cl_util=>rtti_get_t_attri_by_any( val ).

DATA(ls_result) = VALUE ty_s_msg( ).
LOOP AT lt_attri REFERENCE INTO DATA(ls_attri).
DATA(lv_name) = 'VAL-' && ls_attri->name.
ASSIGN (lv_name) TO FIELD-SYMBOL(<comp>).
CASE ls_attri->name.
WHEN 'ID' OR 'MSGID'.
ls_result-id = <comp>.
WHEN 'NO' OR 'NUMBER' OR 'MSGNO'.
ls_result-no = <comp>.
WHEN 'MESSAGE' OR 'TEXT'.
ls_result-text = <comp>.
WHEN 'TYPE' OR 'MSGTY'.
ls_result-type = <comp>.
WHEN 'MESSAGE_V1' OR 'MSGV1' OR 'V1'.
ls_result-v1 = <comp>.
WHEN 'MESSAGE_V2' OR 'MSGV2' OR 'V2'.
ls_result-v2 = <comp>.
WHEN 'MESSAGE_V3' OR 'MSGV3' OR 'V3'.
ls_result-v3 = <comp>.
WHEN 'MESSAGE_V4' OR 'MSGV4' OR 'V4'.
ls_result-v4 = <comp>.
ENDCASE.
ENDLOOP.
IF ls_result-text IS INITIAL AND ls_result-id IS NOT INITIAL.
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.
ENDIF.
INSERT ls_result INTO TABLE result.

WHEN cl_abap_datadescr=>typekind_oref.
TRY.
DATA(lx) = CAST cx_root( val ).
ls_result = VALUE #(
type = 'E'
text = lx->get_text( )
).

DATA(lt_attri_o) = z2ui6_cl_util=>rtti_get_t_attri_by_oref( val ).
LOOP AT lt_attri_o REFERENCE INTO DATA(ls_attri_o)
WHERE visibility = 'U'.
CASE ls_attri_o->name.
WHEN 'ID' OR 'MSGID'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-id = <comp>.
WHEN 'NO' OR 'NUMBER' OR 'MSGNO'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-no = <comp>.
WHEN 'MESSAGE'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-text = <comp>.
WHEN 'TYPE' OR 'MSGTY'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-type = <comp>.
WHEN 'MESSAGE_V1' OR 'MSGV1'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-v1 = <comp>.
WHEN 'MESSAGE_V2' OR 'MSGV2'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-v2 = <comp>.
WHEN 'MESSAGE_V3' OR 'MSGV3'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-v3 = <comp>.
WHEN 'MESSAGE_V4' OR 'MSGV4'.
ASSIGN val->(ls_attri_o->name) TO <comp>.
ls_result-v4 = <comp>.
ENDCASE.

ENDLOOP.
* IF ls_result-text IS INITIAL AND ls_result-id IS NOT INITIAL.
* MESSAGE ID ls_result-id TYPE 'I' NUMBER ls_result-no INTO ls_result-text.
* ENDIF.
INSERT ls_result INTO TABLE result.
CATCH cx_root.
ENDTRY.

WHEN OTHERS.

IF rtti_check_clike( val ).
INSERT VALUE #(
text = val
)
INTO TABLE result.
ENDIF.
ENDCASE.

ENDMETHOD.


METHOD rtti_check_clike.

DATA(lv_type) = rtti_get_type_kind( val ).
CASE lv_type.
WHEN cl_abap_datadescr=>typekind_char OR
cl_abap_datadescr=>typekind_clike OR
cl_abap_datadescr=>typekind_csequence OR
cl_abap_datadescr=>typekind_string.
result = abap_true.
ENDCASE.

ENDMETHOD.

METHOD ui5_get_msg_type.

result = SWITCH #( val WHEN 'E' THEN `Error`
WHEN 'S' THEN `Success` WHEN `W` THEN `Warning`
else `Information`
).

ENDMETHOD.

ENDCLASS.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASS z2ui6_cl_core_draft_srv DEFINITION
CLASS z2ui6_cl_core_srv_draft DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
Expand Down Expand Up @@ -42,7 +42,7 @@ ENDCLASS.



CLASS z2ui6_cl_core_draft_srv IMPLEMENTATION.
CLASS z2ui6_cl_core_srv_draft IMPLEMENTATION.


METHOD cleanup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CLASS ltcl_test IMPLEMENTATION.

METHOD test_create.

DATA(lo_draft) = NEW z2ui6_cl_core_draft_srv( ).
DATA(lo_draft) = NEW z2ui6_cl_core_srv_draft( ).

lo_draft->create(
draft = VALUE #( id = `TEST_ID` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI6_CL_CORE_DRAFT_SRV</CLSNAME>
<CLSNAME>Z2UI6_CL_CORE_SRV_DRAFT</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>abap2UI5 - backend drafts</DESCRIPT>
<STATE>1</STATE>
Expand Down
16 changes: 13 additions & 3 deletions src/01/02/z2ui6_cl_core_action.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CLASS z2ui6_cl_core_action DEFINITION

PUBLIC SECTION.

DATA mo_http_post TYPE REF TO z2ui6_cl_core_http_post.
DATA mo_http_post TYPE REF TO z2ui6_cl_core_handler.
DATA mo_app TYPE REF TO z2ui6_cl_core_app.

DATA ms_actual TYPE z2ui6_if_core_types=>ty_s_actual.
Expand Down Expand Up @@ -33,7 +33,7 @@ CLASS z2ui6_cl_core_action DEFINITION

METHODS constructor
IMPORTING
val TYPE REF TO z2ui6_cl_core_http_post.
val TYPE REF TO z2ui6_cl_core_handler.

PROTECTED SECTION.

Expand Down Expand Up @@ -122,7 +122,7 @@ CLASS z2ui6_cl_core_action IMPLEMENTATION.

"check for new app?
TRY.
DATA(lo_draft) = NEW z2ui6_cl_core_draft_srv( ).
DATA(lo_draft) = NEW z2ui6_cl_core_srv_draft( ).
DATA(ls_draft) = lo_draft->read_info( ms_next-o_app_leave->id_draft ).
CATCH cx_root.
result->mo_app->ms_draft-id_prev_app_stack = mo_app->ms_draft-id_prev_app_stack.
Expand Down Expand Up @@ -176,6 +176,16 @@ CLASS z2ui6_cl_core_action IMPLEMENTATION.
result->ms_next-s_set-s_view_nest2-check_update_model = abap_false.
result->ms_next-s_set-s_popup-check_update_model = abap_false.
result->ms_next-s_set-s_popover-check_update_model = abap_false.


IF ms_next-s_set-s_follow_up_action IS NOT INITIAL.
* .eB(['POPUP_CONFIRM'])
SPLIT ms_next-s_set-s_follow_up_action-custom_js AT `.eB(['` INTO DATA(lv_dummy)
result->ms_actual-event.
SPLIT result->ms_actual-event AT `']` INTO result->ms_actual-event lv_dummy.
ENDIF.
result->ms_actual-r_data = ms_next-r_data.

CLEAR result->ms_next-s_set-s_msg_box.
CLEAR result->ms_next-s_set-s_msg_toast.

Expand Down
2 changes: 1 addition & 1 deletion src/01/02/z2ui6_cl_core_action.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CLASS ltcl_test IMPLEMENTATION.

METHOD first_test.

DATA(lo_http) = NEW z2ui6_cl_core_http_post( `` ).
DATA(lo_http) = NEW z2ui6_cl_core_handler( `` ).
DATA(lo_action) = NEW z2ui6_cl_core_action( lo_http ) ##NEEDED.

ENDMETHOD.
Expand Down
21 changes: 11 additions & 10 deletions src/01/02/z2ui6_cl_core_app.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

TRY.

DATA(lo_model) = NEW z2ui6_cl_core_attri_srv(
DATA(lo_model) = NEW z2ui6_cl_core_srv_attri(
attri = mt_attri
app = mo_app ).
lo_model->attri_before_save( ).
Expand All @@ -82,13 +82,13 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

CLEAR mt_attri->*.

DATA(lo_dissolver) = NEW z2ui6_cl_core_diss_srv(
DATA(lo_dissolver) = NEW z2ui6_cl_core_srv_diss(
attri = mt_attri
app = mo_app ).

lo_dissolver->main( ).
lo_dissolver->main( ).
lo_model = NEW z2ui6_cl_core_attri_srv(
lo_model = NEW z2ui6_cl_core_srv_attri(
attri = mt_attri
app = mo_app ).
lo_model->attri_before_save( ).
Expand Down Expand Up @@ -116,11 +116,11 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

METHOD db_load.

DATA(lo_db) = NEW z2ui6_cl_core_draft_srv( ).
DATA(lo_db) = NEW z2ui6_cl_core_srv_draft( ).
DATA(ls_db) = lo_db->read_draft( id ).
result = all_xml_parse( ls_db-data ).

DATA(lo_model) = NEW z2ui6_cl_core_attri_srv(
DATA(lo_model) = NEW z2ui6_cl_core_srv_attri(
attri = result->mt_attri
app = result->mo_app ).

Expand All @@ -131,13 +131,13 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

METHOD db_load_by_app.

DATA(lo_db) = NEW z2ui6_cl_core_draft_srv( ).
DATA(lo_db) = NEW z2ui6_cl_core_srv_draft( ).
DATA(ls_db) = lo_db->read_draft( app->id_draft ).
result = all_xml_parse( ls_db-data ).

result->mo_app = app.

DATA(lo_model) = NEW z2ui6_cl_core_attri_srv(
DATA(lo_model) = NEW z2ui6_cl_core_srv_attri(
attri = result->mt_attri
app = result->mo_app ).

Expand All @@ -150,9 +150,10 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

IF mo_app IS BOUND.
CAST z2ui6_if_app( mo_app )->id_draft = ms_draft-id.
CAST z2ui6_if_app( mo_app )->check_initialized = abap_true.
ENDIF.

DATA(lo_db) = NEW z2ui6_cl_core_draft_srv( ).
DATA(lo_db) = NEW z2ui6_cl_core_srv_draft( ).
lo_db->create(
draft = ms_draft
model_xml = all_xml_stringify( ) ).
Expand All @@ -162,7 +163,7 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

METHOD model_json_parse.

DATA(lo_json_mapper) = NEW z2ui6_cl_core_json_srv( ).
DATA(lo_json_mapper) = NEW z2ui6_cl_core_srv_json( ).
lo_json_mapper->model_front_to_back(
view = iv_view
t_attri = mt_attri
Expand All @@ -173,7 +174,7 @@ CLASS z2ui6_cl_core_app IMPLEMENTATION.

METHOD model_json_stringify.

DATA(lo_json_mapper) = NEW z2ui6_cl_core_json_srv( ).
DATA(lo_json_mapper) = NEW z2ui6_cl_core_srv_json( ).
result = lo_json_mapper->model_back_to_front( mt_attri ).

ENDMETHOD.
Expand Down
Loading