onSaveAs(bSaveAsFromRta, bCopyUnsavedChanges, sCurrentLayer, oSelectedAppVariant) {
			let bIsS4HanaCloud;
			let oAppVariantSaveClosure;
			let oManifest = fnGetManifest();
			let bIsRunningApp = true;

			if (
				oSelectedAppVariant
				&& oSelectedAppVariant["sap.app"].id === oManifest["sap.app"].id
			) {
				// When an app variant is created on top of base app/app variant from the app variant overview dialog and root control is from the latter
				bCopyUnsavedChanges = true;
				oManifest = merge({}, oSelectedAppVariant);
				oSelectedAppVariant = null;
			} else if (oSelectedAppVariant) {
				// When an app variant is created on top of app variant from the app variant overview dialog and root control is from base application
				bIsRunningApp = false;
				oManifest = merge({}, oSelectedAppVariant);
				oSelectedAppVariant = null;
			}

			// Determine the selector
			const vSelector = this._determineSelector(bIsRunningApp, oManifest);

			return new Promise(function(resolve) {
				const fnProcessSaveAsDialog = function() {
					return oAppVariantManager.processSaveAsDialog(oManifest, bSaveAsFromRta);
				};

				const fnCreateInlineChanges = function(oAppVariantSpecificData) {
					BusyIndicator.show();
					return oAppVariantManager.createAllInlineChanges(oAppVariantSpecificData, vSelector);
				};

				const fnAddChangesToPersistence = function(aChanges) {
					const aAllInlineChanges = aChanges.slice();
					return AppVariantUtils.addChangesToPersistence(aAllInlineChanges, vSelector);
				};

				const fnCreateAppVariant = function() {
					const sAppVariantId = AppVariantUtils.getNewAppVariantId();

					// Based on the key user provided info, app variant manifest is created
					return oAppVariantManager.createAppVariant(sAppVariantId, vSelector)
					.catch(function(oError) {
						let sMessageKey = oError.messageKey;
						sMessageKey ||= "MSG_SAVE_APP_VARIANT_FAILED";

						return AppVariantUtils.catchErrorDialog(oError, sMessageKey, sAppVariantId);
					});
				};

				const fnClearRTACommandStack = function(oResult) {
					oAppVariantSaveClosure = null;
					oAppVariantSaveClosure = merge({}, oResult.response);

					// If there are any unsaved changes, should be taken away for the new created app variant
					return oAppVariantManager.clearRTACommandStack(bCopyUnsavedChanges);
				};

				const fnResetDirtyFlag = function() {
					const oUshellContainer = FlexUtils.getUshellContainer();
					if (oUshellContainer && bCopyUnsavedChanges) {
						// Tell FLP that no UI change is booked for the currently adapting app
						oUshellContainer.setDirtyFlag(false);
					}
				};

				var fnTriggerSuccessMessage = function() {
					fnResetDirtyFlag();
					bIsS4HanaCloud = FlexRuntimeInfoAPI.isAtoEnabled();
					// Shows the success message and closes the current app (if 'Save As' triggered from UI adaptation toolbar)
					// or opens the app variant overview list (if 'Save As' triggered from App variant overview List)
					const oSuccessInfo = AppVariantUtils.buildSuccessInfo(oAppVariantSaveClosure.id, bSaveAsFromRta, bIsS4HanaCloud);
					return oAppVariantManager.showSuccessMessage(oSuccessInfo);
				};

				const fnShowCatalogAssignmentSuccessMessage = function() {
					const oSuccessInfo = AppVariantUtils.buildFinalSuccessInfoS4HANACloud();
					return oAppVariantManager.showSuccessMessage(oSuccessInfo);
				};

				const fnTriggerPlatformDependentFlow = function() {
					BusyIndicator.show();
					if (bIsS4HanaCloud) {
						let oIAMResponse;
						return fnS4HanaAddBrowserCloseWarning()
						.then(function() {
							return fnTriggerCatalogAssignment(oAppVariantSaveClosure.id, oAppVariantSaveClosure.reference);
						})
						.then(function(oResult) {
							oIAMResponse = { ...oResult };
							BusyIndicator.hide();
							return fnTriggerActionFlow.call(this, bSaveAsFromRta, null, sCurrentLayer);
						}.bind(this))
						.then(function() {
							return fnTriggerPollingTileCreation(oIAMResponse, oAppVariantSaveClosure.id);
						})
						.then(function() {
							fnS4HanaRemoveBrowserCloseWarning();
							return fnShowCatalogAssignmentSuccessMessage();
						})
						.then(function() {
							return bSaveAsFromRta ? resolve() : fnTriggerActionFlow.call(this, bSaveAsFromRta, bIsS4HanaCloud, sCurrentLayer);
						}.bind(this));
					}
					BusyIndicator.hide();
					return fnTriggerActionFlow.call(this, bSaveAsFromRta, bIsS4HanaCloud, sCurrentLayer);
				};

				sap.ui.require(["sap/ui/rta/appVariant/AppVariantManager"], function(AppVariantManager) {
					oAppVariantManager ||= new AppVariantManager({
						commandSerializer: oCommandSerializer,
						layer: sCurrentLayer
					});

					return fnProcessSaveAsDialog()
					.then(fnCreateInlineChanges) // Create the inline changes for application variant
					.then(fnAddChangesToPersistence) // Adds the manifest inline changes to the persistence
					.then(fnCreateAppVariant) // Creates the application variant and saves it to the layered repository
					.then(fnClearRTACommandStack)
					.then(fnTriggerSuccessMessage)
					.then(fnTriggerPlatformDependentFlow.bind(this)).then(resolve)
					.catch(function(oError) {
						if (!oError) {// Cancelling Save As Dialog
							return false;
						}
						if (bIsS4HanaCloud) {
							fnS4HanaRemoveBrowserCloseWarning();
						}
						return fnTriggerActionFlow.call(this, null, bIsS4HanaCloud, sCurrentLayer).then(resolve);
					}.bind(this));
				}.bind(this));
			}.bind(this));
		}
@param {boolean} bSaveAsFromRta - Boolean value which tells if 'Save As' is triggered from the UI adaptation header bar
@param {boolean} bCopyUnsavedChanges - Boolean value which tells if the UI changes needs to be copied
@param {string} sCurrentLayer - Current working layer
@param {Object} oSelectedAppVariant - Contains the selected app variant from app variant overview dialog
@returns {Promise} Resolved promise
@description Creates the app variant when 'Save As' is triggered from the UI adaptation header bar.
When 'Save As' triggered from the UI adaptation header bar, we set both flags <code>bSaveAsFromRta</code> and <code>bCopyUnsavedChanges</code> equal to <code>true</code>.
The flag <code>bCopyUnsavedChanges</code> is <code>true</code> if a key user presses 'Save As' from the running app entry in the app variant overview dialog.