IOBJ/ODSO: Fix errors if objects exist already (#5551)

Implementation worked only for new objects (argh)

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2022-05-11 12:38:20 +02:00 committed by GitHub
parent b0a31b0e3b
commit ff0fc72891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 38 deletions

View File

@ -58,11 +58,17 @@ CLASS zcl_abapgit_object_iobj IMPLEMENTATION.
i_iobjnm = lv_objna i_iobjnm = lv_objna
i_objvers = 'A' i_objvers = 'A'
IMPORTING IMPORTING
e_s_viobj = <lg_viobj>. e_s_viobj = <lg_viobj>
EXCEPTIONS
iobj_not_found = 1
illegal_input = 2
bct_comp_invalid = 3
not_authorized = 4
OTHERS = 5.
IF sy-subrc = 0.
ASSIGN COMPONENT 'TSTPNM' OF STRUCTURE <lg_viobj> TO <lg_tstpnm>. ASSIGN COMPONENT 'TSTPNM' OF STRUCTURE <lg_viobj> TO <lg_tstpnm>.
rv_user = <lg_tstpnm>. rv_user = <lg_tstpnm>.
ENDIF.
ENDMETHOD. ENDMETHOD.
@ -208,6 +214,13 @@ CLASS zcl_abapgit_object_iobj IMPLEMENTATION.
TRY. TRY.
ASSIGN
COMPONENT 'INFOOBJECT'
OF STRUCTURE <lg_details>
TO <lg_infoobject>.
ASSERT sy-subrc = 0.
IF zif_abapgit_object~exists( ) = abap_false.
CALL FUNCTION 'BAPI_IOBJ_CREATE' CALL FUNCTION 'BAPI_IOBJ_CREATE'
EXPORTING EXPORTING
details = <lg_details> details = <lg_details>
@ -222,17 +235,28 @@ CLASS zcl_abapgit_object_iobj IMPLEMENTATION.
elimination = <lt_elimination> elimination = <lt_elimination>
hanafieldsmapping = <lt_hanafieldsmapping> hanafieldsmapping = <lt_hanafieldsmapping>
xxlattributes = <lt_xxlattributes>. xxlattributes = <lt_xxlattributes>.
ELSE.
CALL FUNCTION 'BAPI_IOBJ_CHANGE'
EXPORTING
infoobject = <lg_infoobject>
details = <lg_details>
IMPORTING
return = ls_return
TABLES
compounds = <lt_compounds>
attributes = <lt_attributes>
navigationattributes = <lt_navigationattributes>
atrnavinfoprovider = <lt_atrnavinfoprovider>
hierarchycharacteristics = <lt_hierarchycharacteristics>
elimination = <lt_elimination>
hanafieldsmapping = <lt_hanafieldsmapping>
xxlattributes = <lt_xxlattributes>.
ENDIF.
IF ls_return-type = 'E'. IF ls_return-type = 'E'.
zcx_abapgit_exception=>raise( |Error when creating iobj: { ls_return-message }| ). zcx_abapgit_exception=>raise( |Error when creating iobj: { ls_return-message }| ).
ENDIF. ENDIF.
ASSIGN
COMPONENT 'INFOOBJECT'
OF STRUCTURE <lg_details>
TO <lg_infoobject>.
ASSERT sy-subrc = 0.
APPEND <lg_infoobject> TO <lt_infoobjects>. APPEND <lg_infoobject> TO <lt_infoobjects>.
CALL FUNCTION 'BAPI_IOBJ_ACTIVATE_MULTIPLE' CALL FUNCTION 'BAPI_IOBJ_ACTIVATE_MULTIPLE'

View File

@ -133,6 +133,7 @@ CLASS zcl_abapgit_object_odso IMPLEMENTATION.
FIELD-SYMBOLS: FIELD-SYMBOLS:
<lg_details> TYPE any, <lg_details> TYPE any,
<lg_odsobject> TYPE any,
<lt_infoobjects> TYPE STANDARD TABLE, <lt_infoobjects> TYPE STANDARD TABLE,
<lt_navigation> TYPE STANDARD TABLE, <lt_navigation> TYPE STANDARD TABLE,
<lt_indexes> TYPE STANDARD TABLE, <lt_indexes> TYPE STANDARD TABLE,
@ -169,6 +170,11 @@ CLASS zcl_abapgit_object_odso IMPLEMENTATION.
io_xml->read( EXPORTING iv_name = 'INDEX_IOBJ' io_xml->read( EXPORTING iv_name = 'INDEX_IOBJ'
CHANGING cg_data = <lt_index_iobj> ). CHANGING cg_data = <lt_index_iobj> ).
TRY. TRY.
ASSIGN COMPONENT 'ODSOBJECT' OF STRUCTURE <lg_details> TO <lg_odsobject>.
ASSERT sy-subrc = 0.
IF zif_abapgit_object~exists( ) = abap_false.
CALL FUNCTION 'BAPI_ODSO_CREATE' CALL FUNCTION 'BAPI_ODSO_CREATE'
EXPORTING EXPORTING
details = <lg_details> details = <lg_details>
@ -180,6 +186,18 @@ CLASS zcl_abapgit_object_odso IMPLEMENTATION.
indexes = <lt_indexes> indexes = <lt_indexes>
indexesinfoobjects = <lt_index_iobj> indexesinfoobjects = <lt_index_iobj>
return = lt_return. return = lt_return.
ELSE.
CALL FUNCTION 'BAPI_ODSO_CHANGE'
EXPORTING
odsobject = <lg_odsobject>
details = <lg_details>
TABLES
infoobjects = <lt_infoobjects>
navigationattributes = <lt_navigation>
indexes = <lt_indexes>
indexesinfoobjects = <lt_index_iobj>
return = lt_return.
ENDIF.
CATCH cx_sy_dyn_call_illegal_func. CATCH cx_sy_dyn_call_illegal_func.
zcx_abapgit_exception=>raise( |Necessary BW function modules not found or object not supported| ). zcx_abapgit_exception=>raise( |Necessary BW function modules not found or object not supported| ).
@ -192,7 +210,7 @@ CLASS zcl_abapgit_object_odso IMPLEMENTATION.
CALL FUNCTION 'BAPI_ODSO_ACTIVATE' CALL FUNCTION 'BAPI_ODSO_ACTIVATE'
EXPORTING EXPORTING
odsobject = lv_dsonam odsobject = <lg_odsobject>
TABLES TABLES
return = lt_return. return = lt_return.