LedgerDefaultDimensionValueSet defaultDimension;
MainAccountRecId mainAccountRecId;
LedgerDefaultDimensionValueSet ledgerDimension;
//You can get the value of defaultDimension and mainAccountRecId from the source you require //from business logic e.g. in case of Fixed asset you can get from Asset Book //(AssetBook.DefaultDimension) and the main account is usually parameterized. Eventually there's //only one line of code for getting LedgerDimension
ledgerDimension = LedgerDimensionFacade::serviceCreateLedgerDimension(mainAccountRecId, defaultDimension);