on 03-19-2024 6:01 PM
I am attempting to use XCO classes to get a list of sub packages for a given package. I have working code to retrieve other things from a package (such as Data Definitions), but the comparable coding for packages is not behaving the same way. See the example coding here:
DATA(lo_package) = xco_cp_abap_repository=>package->for( 'ZMD_LOCAL' ).
DATA(lo_entities_name) = xco_cp_abap_sql=>constraint->contains_pattern( 'ZMD_I_%' ).
DATA(lo_entities_filter) = xco_cp_abap_repository=>object_name->get_filter( lo_entities_name ).
DATA(lo_entities) = xco_cp_abap_repository=>objects->ddls->where( it_filters = VALUE #( ( lo_entities_filter ) ) ).
DATA(lt_entities) = lo_entities->in( lo_package )->get( ).
" at this point, lt_entities has the correct content
DATA(lo_packages_name) = xco_cp_abap_sql=>constraint->contains_pattern( 'ZMD%' ).
DATA(lo_packages_filter) = xco_cp_abap_repository=>object_name->get_filter( lo_packages_name ).
DATA(lo_packages) = xco_cp_abap_repository=>objects->devc->where( it_filters = VALUE #( ( lo_packages_filter ) ) ).
DATA(lt_packages) = lo_packages->in( lo_package )->get( ).
" same logic, but lt_packages only contains one entry for the superpackage that was provided above, ZMD_LOCAL instead of an entry for each of its subpackages
Any hints on how to go about getting the sub packages?
If you want a working example based on Sandra's comment, here it is:
DATA(lo_packages_name) = xco_cp_abap_sql=>constraint->contains_pattern( 'ZMD%' ).
DATA(lo_packages_filter) = xco_cp_abap_repository=>object_name->get_filter( lo_packages_name ).
DATA(lo_packages) = xco_cp_abap_repository=>objects->devc->where( it_filters = VALUE #( ( lo_packages_filter ) ) ).
DATA(lt_packages) = lo_packages->in( xco_cp_abap=>repository )->get( ).
LOOP AT lt_packages INTO DATA(lo_package).
IF lo_package->read( )-property-super_package->if_xco_ar_object~name->value <> 'ZMD_LOCAL'.
DELETE lt_packages.
ENDIF.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.