The below code would allow you to cycle the source directory .sub files and then create them in the target; it then cycle the elements in the source dim and populate them to the target dim subset.
Note that it will only create them as Static subsets - any MDX will be missed. You could alter the below code with the MDX GET function and then use subsetcreatebymdx etc.
Code: Select all
sFileName = WildCardFileSearch ( cDirectory | '*', '' );
While ( sFileName @<> '' );
sSubsetName = SubSt ( sFileName, 1, Long ( sFileName ) - 4 );
If ( SubsetExists ( cDimSource, sSubsetName ) = 1 );
If ( SubsetExists ( cDimtarget, sSubsetName ) = 1 );
SubsetDeleteAllElements ( cDimTarget, sSubsetName );
Else;
SubsetCreate ( cDimTarget, sSubsetName );
EndIf;
iCount = 1;
iMax = SubsetGetSize ( cDimSource, sSubsetName );
While ( iCount <= iMax );
sElementName = SubsetGetElementName ( cDimSource, sSubsetName, iCount );
If ( Dimix ( cDimTarget, sElementName ) = 0 );
AsciiOutput ( cErrorFile, sElementName | ' not found in dimension ' | cDimtarget );
Else;
SubsetElementInsert ( cDimTarget, sSubsetName, sElementName, SubsetGetSize ( cDimTarget, sSubsetName ) + 1 );
EndIf;
iCount = iCount + 1;
End;
EndIf;
sFileName = WildCardFileSearch ( cDirectory | '*', sFileName );
End;
Caveat - I wrote the code in the forum window; it has not been checked so you must validate it for typos. It is intended to give an idea rather than be a finished solution.
You will need to specify variables/constants for:
cDimTarget and cDimSource (your to and from dimensions)
cErrorFile (a text file name to output issues to )
cDirectory (the }.....Subs folder for the source dim)