If you are using the batch tools to export a metadata folder and all of it's contents, and you only specify the folder, those contents will be flattened when you come to do the subsequent import - eg as follows:
This happens when your export command looks like this:
data _null_;
infile "cd ""&platform_object_path"" %trim(
) ; ./ExportPackage &connx_string -disableX11 %trim(
)-package ""&build_dir/import.spk"" %trim(
)-objects ""&loc_meta(Folder)"" %trim(
)-log ""&build_dir/spkexport.log"" 2>&1"
pipe lrecl=10000;
input;
list;
run;
If you wish for your package to be imported to a different location in metadata whilst retaining the relative subtree structure, you have to specify every dependent object - eg as follows:
data _null_;
infile "cd ""&platform_object_path"" %trim(
) ; ./ExportPackage &connx_string -disableX11 %trim(
)-package ""&build_dir/import.spk"" %trim(
)-objects ""&loc_meta(Folder)"" %trim(
)-objects ""&loc_meta/Public(Folder)"" %trim(
)-objects ""&loc_meta/Public/getAllGroups(StoredProcess)"" %trim(
)-objects ""&loc_meta/Public/getAllMembers(StoredProcess)"" %trim(
)-objects ""&loc_meta/Public/getAllRoles(StoredProcess)"" %trim(
)-objects ""&loc_meta/Public/getGroupsByMember(StoredProcess)"" %trim(
)-objects ""&loc_meta/Public/getMembersByGroup(StoredProcess)"" %trim(
)-objects ""&loc_meta/Public/getMembersByRole(StoredProcess)"" %trim(
)-log ""&build_dir/spkexport.log"" 2>&1"
pipe lrecl=10000;
input;
list;
run;
This provides the expected result:
This issue was discovered whilst building the User Navigator, and the full source code can be found here. All credit to Yura2301 in this communities thread!