#=============================================================================================
# @TITLE			Configuration - Load System tables
#
# @NUMBER			WDBM_FKT_02055
#
# @DESCRIPTION		The 'System Tables' will be loaded again.
#
# @EXP_RESULT		.
#
# @REQUIREMENTS		Test: WDBM_FKT_01000; WDBM_FKT_00100; WDBM_FKT_01010;
#=============================================================================================
public function trim (in str) {
	if (substr(str, 1, 1) == " ") {

		str = trim(substr(str, 2));
	}
	if (substr(str, length(str)) == " ") {
		str = trim(substr(str, 1, length(str)-1));
	}
	return (str);
} 
#=============================================================================================
# @STEP 1			Clicking the link for Configuration - Upgrade System Tables.
#=============================================================================================
set_window(menu_window, 1);
web_link_click("Upgrade System Tables");
wait(5);
set_window (work_window, 1);
if (new_interface == "1") {
	web_obj_get_text("Information - CACHES - DB73","#1","#1",cell_value,"","",1);
} else {
	tbl_get_cell_data("Database/Servername", "#1", "#1", cell_value);
}

if ((cell_value == "Upgrade System Tables" && version == "7.3.00") ||
	(cell_value == "Configuration - Upgrade System Tables" && (version == "7.4.03" || version == "7.5.00" || version == "7.5.01" || version == "7.6.00"))) {
	
	tl_step("Title of window - '" & cell_value & "'","0","is correct");
} else {
	tl_step("Title of window - '" & cell_value & "'","1","is incorrect");
}
#=============================================================================================
# @STEP 2			Checking window content.
#=============================================================================================
set_window (work_window, 1);

if (obj_exists("DBAName",0) == 0 &&
	obj_exists("DBAPwd",0) == 0 && 
	obj_exists("DOMPwd",0) == 0 &&
	obj_exists("Start",0) == 0) {
	tl_step("Work window content","0","all displayed correctly");
} else {
	tl_step("Work window content","1","not all displayed correctly");
}
#=============================================================================================
# @STEP 3			Enter password/user combination for dba-User and start of upgrade.
#=============================================================================================
set_window (work_window, 1);
edit_set("DBAName","dba");
password_edit_set("DBAPwd","4979b8c216ae5ed5");
web_link_click("Start");

wait(30);

for (i=0;i<100;i++) {
	
	set_window (work_window, 1);
	if (new_interface == "1") {
		web_obj_get_text ("Information - CACHES - DB73", "#1", "#1", cell_value_1, "", "", 1);
	} else {
		tbl_get_cell_data ("Database/Servername", "#1", "#1", cell_value_1);
	}
	
	if (match (trim(cell_value_1), "Error") != 0) {
		
		tl_step ("Configuration - Upgrade System Tables","1","Error occurred while loading system tables.");
		break;
	} 
	
	if(obj_exists("Back",0) == 0) {
		break;
	}
	wait(1);
}
set_window (work_window, 1);
tbl_get_cell_data("1x1","#1","#2",cell_value);

if (cell_value == "OK, system tables loaded.") {
	tl_step("Upgrade of system tables","0","all worked fine");
} else {
	tl_step("Upgrade of system tables","0","error occured");
}
