Offline repo: "Compare via RFC" feature (#4789)

* Offline repo: "Import via RFC" feature

Adds option to **offline** repositories for importing a repo via an RFC connection from another SAP system. It's a shortcut for doing "Export ZIP" in one system, and "Import ZIP" in the other.

Closes #4784

Pre-requisite: abapGit develop version (with this change) is installed on remote SAP system. 

Note: The general recommendation is to use **online** repositories and a git server for comparing and synchronizing systems.

* Lint

* Create guide-import-rfc.md

* Langu

* Langu

* Write-protect only

* Compare

* Compare

* Compare

* Compare

* Git

* Update docs/guide-import-rfc.md

Co-authored-by: Lars Hvam <larshp@hotmail.com>

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2021-06-04 15:09:09 +02:00 committed by GitHub
parent e2a156a326
commit 887e7dd332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 173 additions and 6 deletions

18
docs/guide-import-rfc.md Normal file
View File

@ -0,0 +1,18 @@
---
title: Compare RFC
category: offline projects
order: 25
---
For write-protected offline repositories, you can compare a package with all objects supported by abapGit via an RFC connection to another SAP system.
Pre-requisites:
- abapGit Developer Version is installed on remote SAP system
- Offline repository is write-protected
- Same package names on both systems
- Authorizations to run RFC function Z_ABAPGIT_SERIALIZE_PACKAGE and abapGit serialization process on remote system
Note:
The general recommendation is to use **online** repositories and a Git server for comparing and synchronizing systems. We do not recommend to create RFC destinations between different tier systems or creating RFC users with wide authorizations.

View File

@ -8,6 +8,77 @@
<SOBJ_NAME>SAPLZABAPGIT_PARALLEL</SOBJ_NAME>
</INCLUDES>
<FUNCTIONS>
<item>
<FUNCNAME>Z_ABAPGIT_SERIALIZE_PACKAGE</FUNCNAME>
<REMOTE_CALL>R</REMOTE_CALL>
<SHORT_TEXT>abapGit - Serialize Package to ZIP</SHORT_TEXT>
<IMPORT>
<RSIMP>
<PARAMETER>IV_PACKAGE</PARAMETER>
<TYP>DEVCLASS</TYP>
</RSIMP>
<RSIMP>
<PARAMETER>IV_FOLDER_LOGIC</PARAMETER>
<DEFAULT>&apos;PREFIX&apos;</DEFAULT>
<OPTIONAL>X</OPTIONAL>
<TYP>STRING</TYP>
</RSIMP>
<RSIMP>
<PARAMETER>IV_MAIN_LANG_ONLY</PARAMETER>
<DEFAULT>&apos;&apos;</DEFAULT>
<OPTIONAL>X</OPTIONAL>
<TYP>FLAG</TYP>
</RSIMP>
<RSIMP>
<PARAMETER>IV_SHOW_LOG</PARAMETER>
<DEFAULT>&apos;&apos;</DEFAULT>
<OPTIONAL>X</OPTIONAL>
<TYP>FLAG</TYP>
</RSIMP>
</IMPORT>
<EXPORT>
<RSEXP>
<PARAMETER>EV_XSTRING</PARAMETER>
<TYP>XSTRING</TYP>
</RSEXP>
</EXPORT>
<EXCEPTION>
<RSEXC>
<EXCEPTION>ERROR</EXCEPTION>
</RSEXC>
</EXCEPTION>
<DOCUMENTATION>
<RSFDO>
<PARAMETER>IV_PACKAGE</PARAMETER>
<KIND>P</KIND>
<STEXT>Package</STEXT>
</RSFDO>
<RSFDO>
<PARAMETER>IV_FOLDER_LOGIC</PARAMETER>
<KIND>P</KIND>
<STEXT>Folder logic</STEXT>
</RSFDO>
<RSFDO>
<PARAMETER>IV_MAIN_LANG_ONLY</PARAMETER>
<KIND>P</KIND>
<STEXT>Serialize main language only</STEXT>
</RSFDO>
<RSFDO>
<PARAMETER>IV_SHOW_LOG</PARAMETER>
<KIND>P</KIND>
<STEXT>Display log</STEXT>
</RSFDO>
<RSFDO>
<PARAMETER>EV_XSTRING</PARAMETER>
<KIND>P</KIND>
<STEXT>ZIP data</STEXT>
</RSFDO>
<RSFDO>
<PARAMETER>ERROR</PARAMETER>
<KIND>X</KIND>
</RSFDO>
</DOCUMENTATION>
</item>
<item>
<FUNCNAME>Z_ABAPGIT_SERIALIZE_PARALLEL</FUNCNAME>
<REMOTE_CALL>R</REMOTE_CALL>

View File

@ -0,0 +1,41 @@
FUNCTION z_abapgit_serialize_package.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_PACKAGE) TYPE DEVCLASS
*" VALUE(IV_FOLDER_LOGIC) TYPE STRING DEFAULT 'PREFIX'
*" VALUE(IV_MAIN_LANG_ONLY) TYPE FLAG DEFAULT ''
*" VALUE(IV_SHOW_LOG) TYPE FLAG DEFAULT ''
*" EXPORTING
*" VALUE(EV_XSTRING) TYPE XSTRING
*" EXCEPTIONS
*" ERROR
*"----------------------------------------------------------------------
DATA:
lx_error TYPE REF TO zcx_abapgit_exception,
lv_text TYPE c LENGTH 200,
ls_local_settings TYPE zif_abapgit_persistence=>ty_repo-local_settings,
lo_dot_abapgit TYPE REF TO zcl_abapgit_dot_abapgit.
TRY.
ls_local_settings-main_language_only = iv_main_lang_only.
lo_dot_abapgit = zcl_abapgit_dot_abapgit=>build_default( ).
lo_dot_abapgit->set_folder_logic( iv_folder_logic ).
ev_xstring = zcl_abapgit_zip=>export(
is_local_settings = ls_local_settings
iv_package = iv_package
io_dot_abapgit = lo_dot_abapgit ).
CATCH zcx_abapgit_exception INTO lx_error.
lv_text = lx_error->get_text( ).
MESSAGE s000(oo) RAISING error WITH
lv_text+0(50)
lv_text+50(50)
lv_text+100(50)
lv_text+150(50).
ENDTRY.
ENDFUNCTION.

View File

@ -472,6 +472,11 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ro_toolbar->add( iv_txt = 'Import <sup>zip</sup>'
iv_act = |{ zif_abapgit_definitions=>c_action-zip_import }?key={ mv_key }|
iv_opt = zif_abapgit_html=>c_html_opt-strong ).
IF mo_repo->get_local_settings( )-write_protected = abap_true.
ro_toolbar->add( iv_txt = 'Compare <sup>rfc</sup>'
iv_act = |{ zif_abapgit_definitions=>c_action-rfc_compare }?key={ mv_key }|
iv_opt = zif_abapgit_html=>c_html_opt-strong ).
ENDIF.
ro_toolbar->add( iv_txt = 'Export <sup>zip</sup>'
iv_act = |{ zif_abapgit_definitions=>c_action-zip_export }?key={ mv_key }|
iv_opt = zif_abapgit_html=>c_html_opt-strong ).

View File

@ -698,6 +698,8 @@ CLASS zcl_abapgit_gui_router IMPLEMENTATION.
DATA: lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
lo_repo TYPE REF TO zcl_abapgit_repo,
lv_path TYPE string,
lv_dest TYPE rfcdest,
lv_msg TYPE c LENGTH 200,
lv_xstr TYPE xstring.
CONSTANTS:
@ -709,13 +711,42 @@ CLASS zcl_abapgit_gui_router IMPLEMENTATION.
lv_key = ii_event->query( )->get( 'KEY' ).
CASE ii_event->mv_action.
WHEN zif_abapgit_definitions=>c_action-zip_import. " Import repo from ZIP
WHEN zif_abapgit_definitions=>c_action-zip_import " Import repo from ZIP
OR zif_abapgit_definitions=>c_action-rfc_compare. " Compare repo via RFC
lo_repo = zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).
lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog(
iv_title = 'Import ZIP'
iv_extension = 'zip'
iv_default_filename = '*.zip' ).
lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ).
IF ii_event->mv_action = zif_abapgit_definitions=>c_action-zip_import.
lv_path = zcl_abapgit_ui_factory=>get_frontend_services( )->show_file_open_dialog(
iv_title = 'Import ZIP'
iv_extension = 'zip'
iv_default_filename = '*.zip' ).
lv_xstr = zcl_abapgit_ui_factory=>get_frontend_services( )->file_upload( lv_path ).
ELSE.
lv_dest = zcl_abapgit_ui_factory=>get_popups( )->popup_search_help( 'RFCDES-RFCDEST' ).
IF lv_dest IS INITIAL.
rs_handled-state = zcl_abapgit_gui=>c_event_state-no_more_act.
RETURN.
ENDIF.
CALL FUNCTION 'Z_ABAPGIT_SERIALIZE_PACKAGE'
DESTINATION lv_dest
EXPORTING
iv_package = lo_repo->get_package( )
iv_folder_logic = lo_repo->get_dot_abapgit( )->get_folder_logic( )
iv_main_lang_only = lo_repo->get_local_settings( )-main_language_only
IMPORTING
ev_xstring = lv_xstr
EXCEPTIONS
system_failure = 1 MESSAGE lv_msg
communication_failure = 2 MESSAGE lv_msg
OTHERS = 3.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( |RFC import error: { lv_msg }| ).
ENDIF.
ENDIF.
lo_repo->set_files_remote( zcl_abapgit_zip=>load( lv_xstr ) ).
zcl_abapgit_services_repo=>refresh( lv_key ).

View File

@ -446,6 +446,7 @@ INTERFACE zif_abapgit_definitions
zip_package TYPE string VALUE 'zip_package',
zip_transport TYPE string VALUE 'zip_transport',
zip_object TYPE string VALUE 'zip_object',
rfc_compare TYPE string VALUE 'rfc_compare',
performance_test TYPE string VALUE 'performance_test',
ie_devtools TYPE string VALUE 'ie_devtools',
git_pull TYPE string VALUE 'git_pull',