Tuesday, October 04, 2011

Using ZAKE to export objects to the filesystem

A script to use ZAKE to export a package to the filesystem. I'm starting to use ZAKE and SAPLink to synchronize the ABAP repository with the mercurial version control system, so the default SVN object was not good for my goal.



*&---------------------------------------------------------------------*
*& Report z_zake_fs_from_package
*&---------------------------------------------------------------------*
* Uses ZAKE to export to the filesystem the contents of a package as
* slinkees and to upload from the filesystem the objects into SAP.
*----------------------------------------------------------------------*
report z_zake_fs_from_package.
* zake subclass just for using the download/upload to filesystem
class lcl_zake_fs definition inheriting from zake.
public section.
methods update redefinition.
methods checkout redefinition.
methods checkin redefinition.
endclass. "lcl_zake_fs DEFINITION
class lcl_zake_fs implementation.
method update.
endmethod. "UPDATE
method checkout.
endmethod. "CHECKOUT
method checkin.
endmethod. "CHECKIN
endclass. "lcl_zake_fs IMPLEMENTATION
data: zake type ref to lcl_zake_fs,
ex type ref to zcx_saplink,
message type string,
loclpath_str type string.
selection-screen begin of block a with frame title a.
parameters:
package type devclass.
selection-screen end of block a.
selection-screen begin of block b with frame title b.
parameters:
download type flag radiobutton group act default 'X',
upload type flag radiobutton group act.
selection-screen end of block b.
selection-screen begin of block c with frame title c.
parameters:
loclpath type char512 default '' lower case obligatory,
testrun type flag default 'X'.
selection-screen end of block c.
initialization.
a = 'Package'.
b = 'Action'.
c = 'Parameters'.
start-of-selection.
loclpath_str = loclpath.
try.
create object zake
exporting
i_svnpath = loclpath_str
i_localpath = loclpath_str.
zake->set_testrun( testrun ).
if download = abap_true.
zake->download_slinkees_to_lm = abap_true.
zake->download_nugget_to_lm = abap_false.
zake->download_zip_to_lm_flag = abap_false.
zake->set_package_objects( package ).
zake->create_slinkees( ).
elseif upload = abap_true.
zake->install_slinkees_from_lm( testrun ).
endif.
catch zcx_saplink into ex.
message = ex->get_text( ).
write: / 'An Error occured: ', message.
endtry.

Labels: ,