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?
Just tried with ABAP 7.58, no way.
Even by looking at all XCO code, no query on TDEVC-PARENTCL to get the sub-packages.
The only possibility is to read the definition of ALL packages, collect the names of their parent packages, and only then you can determine the sub-packages of one package.
Good luck! 😄
PS: of course, I'm talking about using XCO only (mandatory with ABAP Cloud/public cloud). For on-premises and private cloud, you may still access directly the table TDEVC to easily find the sub-packages.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 |
---|---|
83 | |
9 | |
9 | |
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.