From 6c417739cd7f7fa9827a42e5a52664db289859d8 Mon Sep 17 00:00:00 2001 From: larshp Date: Mon, 4 Jul 2016 11:34:46 +0000 Subject: [PATCH] WEBI support, close #90 --- src/zabapgit.prog.abap | 3 +- src/zabapgit_definitions.prog.abap | 2 + src/zabapgit_forms.prog.abap | 2 +- src/zabapgit_object_webi.prog.abap | 404 +++++++++++++++++++++++++++++ src/zabapgit_object_webi.prog.xml | 48 ++++ src/zabapgit_objects.prog.abap | 2 +- 6 files changed, 458 insertions(+), 3 deletions(-) create mode 100644 src/zabapgit_object_webi.prog.abap create mode 100644 src/zabapgit_object_webi.prog.xml diff --git a/src/zabapgit.prog.abap b/src/zabapgit.prog.abap index 95f4b47b7..e049946a2 100644 --- a/src/zabapgit.prog.abap +++ b/src/zabapgit.prog.abap @@ -3,7 +3,7 @@ REPORT zabapgit LINE-SIZE 100. * See http://www.abapgit.org CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT - gc_abap_version TYPE string VALUE 'v1.12.8'. "#EC NOTEXT + gc_abap_version TYPE string VALUE 'v1.12.9'. "#EC NOTEXT ******************************************************************************** * The MIT License (MIT) @@ -62,6 +62,7 @@ INCLUDE zabapgit_objects. INCLUDE zabapgit_tadir. INCLUDE zabapgit_file_status. INCLUDE zabapgit_object. +INCLUDE zabapgit_object_webi. INCLUDE zabapgit_repo_impl. INCLUDE zabapgit_background. INCLUDE zabapgit_zip. diff --git a/src/zabapgit_definitions.prog.abap b/src/zabapgit_definitions.prog.abap index c4e9f00e0..016165fae 100644 --- a/src/zabapgit_definitions.prog.abap +++ b/src/zabapgit_definitions.prog.abap @@ -90,6 +90,8 @@ TYPES: BEGIN OF ty_result, END OF ty_result. TYPES: ty_results_tt TYPE STANDARD TABLE OF ty_result WITH DEFAULT KEY. +TYPES: ty_sval_tt TYPE STANDARD TABLE OF sval WITH DEFAULT KEY. + CONSTANTS: BEGIN OF gc_chmod, file TYPE ty_chmod VALUE '100644', executable TYPE ty_chmod VALUE '100755', diff --git a/src/zabapgit_forms.prog.abap b/src/zabapgit_forms.prog.abap index 1dbf19c91..06523c526 100644 --- a/src/zabapgit_forms.prog.abap +++ b/src/zabapgit_forms.prog.abap @@ -44,7 +44,7 @@ ENDFORM. "run * -->##CALLED text * -->##NEEDED text *----------------------------------------------------------------------* -FORM branch_popup TABLES tt_fields STRUCTURE sval +FORM branch_popup TABLES tt_fields TYPE ty_sval_tt USING pv_code TYPE clike CHANGING cs_error TYPE svale cv_show_popup TYPE c diff --git a/src/zabapgit_object_webi.prog.abap b/src/zabapgit_object_webi.prog.abap new file mode 100644 index 000000000..37dfb3835 --- /dev/null +++ b/src/zabapgit_object_webi.prog.abap @@ -0,0 +1,404 @@ +*&---------------------------------------------------------------------* +*& Include ZABAPGIT_OBJECT_WEBI +*&---------------------------------------------------------------------* + +*----------------------------------------------------------------------* +* CLASS lcl_object_webi DEFINITION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_object_webi DEFINITION INHERITING FROM lcl_objects_super FINAL. + + PUBLIC SECTION. + INTERFACES lif_object. + + PRIVATE SECTION. + TYPES: BEGIN OF ty_webi, + veptext TYPE veptext, + pvepheader TYPE STANDARD TABLE OF vepheader WITH DEFAULT KEY, + pvepfunction TYPE STANDARD TABLE OF vepfunction WITH DEFAULT KEY, + pvepfault TYPE STANDARD TABLE OF vepfault WITH DEFAULT KEY, + pvepparameter TYPE STANDARD TABLE OF vepparameter WITH DEFAULT KEY, + pveptype TYPE STANDARD TABLE OF veptype WITH DEFAULT KEY, + pvepelemtype TYPE STANDARD TABLE OF vepelemtype WITH DEFAULT KEY, + pveptabletype TYPE STANDARD TABLE OF veptabletype WITH DEFAULT KEY, + pvepstrutype TYPE STANDARD TABLE OF vepstrutype WITH DEFAULT KEY, + pveptypesoapext TYPE STANDARD TABLE OF veptypesoapext WITH DEFAULT KEY, + pvepeletypsoap TYPE STANDARD TABLE OF vepeletypsoap WITH DEFAULT KEY, + pveptabtypsoap TYPE STANDARD TABLE OF veptabtypsoap WITH DEFAULT KEY, + pvepfuncsoapext TYPE STANDARD TABLE OF vepfuncsoapext WITH DEFAULT KEY, + pvepfieldref TYPE STANDARD TABLE OF vepfieldref WITH DEFAULT KEY, + pvependpoint TYPE STANDARD TABLE OF vependpoint WITH DEFAULT KEY, + pvepvisoapext TYPE STANDARD TABLE OF vepvisoapext WITH DEFAULT KEY, + pvepparasoapext TYPE STANDARD TABLE OF vepparasoapext WITH DEFAULT KEY, + END OF ty_webi. + + DATA: mi_vi TYPE REF TO if_ws_md_vif. + + METHODS: + handle_endpoint + IMPORTING is_webi TYPE ty_webi + RAISING lcx_exception + cx_ws_md_exception, + handle_types + IMPORTING is_webi TYPE ty_webi + RAISING lcx_exception + cx_ws_md_exception, + handle_soap + IMPORTING is_webi TYPE ty_webi + RAISING lcx_exception + cx_ws_md_exception, + handle_function + IMPORTING is_webi TYPE ty_webi + RAISING lcx_exception + cx_ws_md_exception. + +ENDCLASS. "lcl_object_SFBS DEFINITION + +*----------------------------------------------------------------------* +* CLASS lcl_object_webi IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_object_webi IMPLEMENTATION. + + METHOD lif_object~serialize. + + DATA: ls_webi TYPE ty_webi, + lt_modilog TYPE STANDARD TABLE OF smodilog WITH DEFAULT KEY, + li_vi TYPE REF TO if_ws_md_vif, + lv_name TYPE vepname. + + FIELD-SYMBOLS: LIKE LINE OF ls_webi-pvepheader. + + + CALL FUNCTION 'WEBI_GET_OBJECT' + EXPORTING + webiname = ms_item-obj_name + TABLES + psmodilog = lt_modilog + pvepheader = ls_webi-pvepheader + pvepfunction = ls_webi-pvepfunction + pvepfault = ls_webi-pvepfault + pvepparameter = ls_webi-pvepparameter + pveptype = ls_webi-pveptype + pvepelemtype = ls_webi-pvepelemtype + pveptabletype = ls_webi-pveptabletype + pvepstrutype = ls_webi-pvepstrutype + pveptypesoapext = ls_webi-pveptypesoapext + pvepeletypsoap = ls_webi-pvepeletypsoap + pveptabtypsoap = ls_webi-pveptabtypsoap + pvepfuncsoapext = ls_webi-pvepfuncsoapext + pvepfieldref = ls_webi-pvepfieldref + pvependpoint = ls_webi-pvependpoint + pvepvisoapext = ls_webi-pvepvisoapext + pvepparasoapext = ls_webi-pvepparasoapext + EXCEPTIONS + version_not_found = 1 + webi_not_exist = 2 + OTHERS = 3. + IF sy-subrc <> 0. + _raise 'error from WEBI_GET_OBJECT'. + ENDIF. + + SORT ls_webi-pveptype BY + vepname ASCENDING + version ASCENDING + typename ASCENDING. + + lv_name = ms_item-obj_name. + TRY. + li_vi = cl_ws_md_factory=>get_vif_root( )->get_virtual_interface( lv_name ). + ls_webi-veptext = li_vi->get_short_text( sews_c_vif_version-active ). + CATCH cx_ws_md_exception. + _raise 'error serializing WEBI'. + ENDTRY. + + LOOP AT ls_webi-pvepheader ASSIGNING . + CLEAR -author. + CLEAR -createdon. + CLEAR -changedby. + CLEAR -changedon. + CLEAR -ctime. + CLEAR -text_id. + CLEAR -utime. + CLEAR -wsint_version. + ENDLOOP. + + io_xml->add( iv_name = 'WEBI' + ig_data = ls_webi ). + + ENDMETHOD. + + METHOD handle_endpoint. + + DATA: ls_endpoint LIKE LINE OF is_webi-pvependpoint, + li_endpoint TYPE REF TO if_ws_md_vif_endpoint_ref. + + + READ TABLE is_webi-pvependpoint INDEX 1 INTO ls_endpoint. + ASSERT sy-subrc = 0. + + IF mi_vi->has_endpoint_reference( sews_c_vif_version-all ) = abap_true. + RETURN. + ENDIF. + + li_endpoint = mi_vi->create_endpoint_reference( + endpoint_type = ls_endpoint-endpointtype + service_def_startpoint = ls_endpoint-def_start_pt + auto_generated = ls_endpoint-auto_generated + i_is_srvv = ls_endpoint-is_srvv ). + + IF ls_endpoint-endpointtype = 'BAPI'. +* it looks like some special handling is needed when calling +* set_data, and looking at the cluster data LS_ENDPOINT-CLUSTD + _raise 'todo, WEBI BAPI'. + ENDIF. + + li_endpoint->set_data( + data_version = '1' + data = ls_endpoint-endpointname ). + + ENDMETHOD. + + METHOD handle_function. + + DATA: li_parameter TYPE REF TO if_ws_md_vif_param, + li_soap TYPE REF TO if_ws_md_soap_ext_func, + li_fault TYPE REF TO if_ws_md_vif_fault, + li_function TYPE REF TO if_ws_md_vif_func. + + FIELD-SYMBOLS: LIKE LINE OF is_webi-pvepfunction, + LIKE LINE OF is_webi-pvepfuncsoapext, + LIKE LINE OF is_webi-pvepfault, + LIKE LINE OF is_webi-pvepparameter. + + + LOOP AT is_webi-pvepfunction ASSIGNING . + + li_function = mi_vi->create_function( + funcname = -function + mapped_name = -mappedname ). + + li_function->set_is_exposed( -is_exposed ). + + LOOP AT is_webi-pvepparameter ASSIGNING + WHERE function = -function. + CASE -vepparamtype. + WHEN 'I'. + li_parameter = li_function->create_incoming_parameter( + -vepparam ). + WHEN 'E'. + li_parameter = li_function->create_outgoing_parameter( + -vepparam ). + WHEN OTHERS. + ASSERT 0 = 1. + ENDCASE. + li_parameter->set_name_mapped_to( -mappedname ). + li_parameter->set_is_exposed( -is_exposed ). + li_parameter->set_is_optional( -is_optional ). + li_parameter->set_default_value( -default_value ). + li_parameter->set_initial( -is_initial ). + li_parameter->set_type( -typename ). + ENDLOOP. + + LOOP AT is_webi-pvepfuncsoapext ASSIGNING + WHERE function = -function. + li_soap = li_function->create_soap_extension_function( ). + li_soap->set_soap_request_name( -requestname ). + li_soap->set_soap_response_name( -responsename ). + li_soap->set_namespace( -namespace ). + ENDLOOP. + + LOOP AT is_webi-pvepfault ASSIGNING + WHERE function = -function. + li_fault = li_function->create_fault( -fault ). + li_fault->set_name_mapped_to( -mappedname ). +* li_fault->set_description( -description_id ). + li_fault->set_detail( -detail ). + ENDLOOP. + + ENDLOOP. + + ENDMETHOD. + + METHOD handle_types. + + DATA: lv_index TYPE i, + li_soap TYPE REF TO if_ws_md_soap_extension_type, + li_struc TYPE REF TO if_ws_md_vif_struc_type, + li_field TYPE REF TO if_ws_md_vif_field, + li_table TYPE REF TO if_ws_md_vif_table_type, + li_elem TYPE REF TO if_ws_md_vif_elem_type. + + FIELD-SYMBOLS: LIKE LINE OF is_webi-pvepelemtype, + LIKE LINE OF is_webi-pveptabletype, + LIKE LINE OF is_webi-pveptypesoapext, + LIKE LINE OF is_webi-pvepstrutype. + + + LOOP AT is_webi-pvepelemtype ASSIGNING . + li_elem = mi_vi->create_type_as_elementary( -typename ). + li_elem->set_built_in_type( -build_in_type ). + li_elem->set_decimals( -decimals ). + li_elem->set_kind( -kind ). + li_elem->set_length( -length ). + li_elem->set_signed( -signed ). + li_elem->set_abaptype( -abaptype ). + + READ TABLE is_webi-pveptypesoapext ASSIGNING + WITH KEY typename = -typename. + IF sy-subrc = 0. + li_soap = li_elem->if_ws_md_vif_type~create_soap_extension_type( ). + li_soap->set_namespace( -namespace ). + ENDIF. + ENDLOOP. + + LOOP AT is_webi-pvepstrutype ASSIGNING . + lv_index = sy-tabix. + + li_struc = mi_vi->create_type_as_structure( -typename ). + li_field = li_struc->create_field( + field_name = -fieldname + fieldpos = -fieldpos ). + li_field->set_type( mi_vi->get_type( typename = -typeref + version = sews_c_vif_version-inactive ) ). + + IF lv_index = 1. + READ TABLE is_webi-pveptypesoapext ASSIGNING + WITH KEY typename = -typename. + IF sy-subrc = 0. + li_soap = li_struc->if_ws_md_vif_type~create_soap_extension_type( ). + li_soap->set_namespace( -namespace ). + ENDIF. + ENDIF. + ENDLOOP. + + LOOP AT is_webi-pveptabletype ASSIGNING . + li_table = mi_vi->create_type_as_table( -typename ). + li_table->set_line_type( mi_vi->get_type( typename = -typeref + version = sews_c_vif_version-inactive ) ). + + READ TABLE is_webi-pveptypesoapext ASSIGNING + WITH KEY typename = -typename. + IF sy-subrc = 0. + li_soap = li_table->if_ws_md_vif_type~create_soap_extension_type( ). + li_soap->set_namespace( -namespace ). + ENDIF. + ENDLOOP. + + ENDMETHOD. + + METHOD handle_soap. + + DATA: li_soap TYPE REF TO if_ws_md_soap_ext_virtinfc, + ls_soap LIKE LINE OF is_webi-pvepvisoapext. + + + READ TABLE is_webi-pvepvisoapext INDEX 1 INTO ls_soap. + ASSERT sy-subrc = 0. + + li_soap = mi_vi->create_soap_extension_virtinfc( ls_soap-soap_appl_uri ). + li_soap->set_namespace( ls_soap-namespace ). + + ENDMETHOD. + + METHOD lif_object~deserialize. + + DATA: ls_webi TYPE ty_webi, + lv_name TYPE vepname, + ls_header LIKE LINE OF ls_webi-pvepheader, + lv_text TYPE string, + lx_root TYPE REF TO cx_root, + lv_exists TYPE abap_bool, + li_root TYPE REF TO if_ws_md_vif_root. + + + io_xml->read( EXPORTING iv_name = 'WEBI' + CHANGING cg_data = ls_webi ). + + lv_name = ms_item-obj_name. + + READ TABLE ls_webi-pvepheader INDEX 1 INTO ls_header. + ASSERT sy-subrc = 0. + + lv_exists = cl_ws_md_vif_root=>check_existence_by_vif_name( + name = lv_name + i_version = sews_c_vif_version-all ). + + li_root = cl_ws_md_factory=>get_vif_root( ). + TRY. + IF lv_exists = abap_false. + mi_vi = li_root->create_virtual_interface( + name = lv_name + nameext = ls_header-vepnameext ). + ELSE. + mi_vi = li_root->get_virtual_interface( lv_name ). + mi_vi->if_ws_md_lockable_object~lock( ). + ENDIF. + + mi_vi->set_short_text( ls_webi-veptext ). + + handle_endpoint( ls_webi ). + handle_types( ls_webi ). + handle_function( ls_webi ). + handle_soap( ls_webi ). + + mi_vi->if_ws_md_lockable_object~save( ). + mi_vi->if_ws_md_lockable_object~unlock( ). + CATCH cx_ws_md_exception INTO lx_root. + lv_text = lx_root->if_message~get_text( ). + _raise 'error deserializing WEBI'. + ENDTRY. + + lcl_objects_activation=>add_item( ms_item ). + + ENDMETHOD. + + METHOD lif_object~delete. + + DATA: lv_name TYPE vepname. + + + lv_name = ms_item-obj_name. + + DATA: lo_vif TYPE REF TO cl_ws_md_vif_root. + + CREATE OBJECT lo_vif. + TRY. + lo_vif->if_ws_md_vif_root~delete_virtual_interface( lv_name ). + CATCH cx_ws_md_exception. + _raise 'error deleting WEBI'. + ENDTRY. + + ENDMETHOD. + + METHOD lif_object~exists. + + DATA: lv_name TYPE vepname. + + + lv_name = ms_item-obj_name. + + rv_bool = cl_ws_md_vif_root=>check_existence_by_vif_name( + name = lv_name + i_version = sews_c_vif_version-active ). + + ENDMETHOD. + + METHOD lif_object~jump. + + CALL FUNCTION 'RS_TOOL_ACCESS' + EXPORTING + operation = 'SHOW' + object_name = ms_item-obj_name + object_type = ms_item-obj_type + in_new_window = abap_true. + + ENDMETHOD. + + METHOD lif_object~get_metadata. + rs_metadata = get_metadata( ). + ENDMETHOD. + +ENDCLASS. \ No newline at end of file diff --git a/src/zabapgit_object_webi.prog.xml b/src/zabapgit_object_webi.prog.xml new file mode 100644 index 000000000..db71c561c --- /dev/null +++ b/src/zabapgit_object_webi.prog.xml @@ -0,0 +1,48 @@ + + + + + + ZABAPGIT_OBJECT_WEBI + A + + + X + + + + + + I + + + + 0000-00-00 + + 0000-00-00 + + + + + E + + + 0000-00-00 + + 0000-00-00 + + + X + + + + R + + Include ZABAPGIT_OBJECT_WEBI + 28 + + + + + + diff --git a/src/zabapgit_objects.prog.abap b/src/zabapgit_objects.prog.abap index 5afe296a9..cfae48829 100644 --- a/src/zabapgit_objects.prog.abap +++ b/src/zabapgit_objects.prog.abap @@ -126,7 +126,7 @@ CLASS lcl_objects_activation IMPLEMENTATION. -object = iv_type. -obj_name = lv_obj_name. WHEN 'REPS' OR 'DYNP' OR 'CUAD' OR 'REPT' OR 'INTF' - OR 'FUNC' OR 'ENHO' OR 'TYPE' OR 'XSLT'. + OR 'FUNC' OR 'ENHO' OR 'TYPE' OR 'XSLT' OR 'WEBI'. * these seem to go into the workarea automatically APPEND INITIAL LINE TO gt_programs ASSIGNING . -object = iv_type.