How to simply create 1 var in a testcase then pass to the next

Maybe you should be making a Test Suite of your Test Cases, that way a Global Variable would work.
However, I have some lengthy tests even for a Test Suite, so you can SAVE your variable(s) to a text or spreadsheet to pass from one test suite to another.
Note that I use a Global Variable because I have a Test Suite of Test Cases that I pass the customer’s name across, but a simple variable would work too if you are only doing one Test Case.

Maybe like

There may be newer ways to save between suites, but since it works, I don’t upgrade the code.

import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.Row
import org.apache.poi.xssf.usermodel.XSSFSheet
import org.apache.poi.xssf.usermodel.XSSFWorkbook

GlobalVariable.gTestIdPathWay = "G:\\Katalon Test Cases\\Data Files\\TestId ST-07-CLM.xlsx";

/* open connection to MS Excel, save surname to sheet 1, cell A2, close connection */
FileInputStream fis = new FileInputStream (GlobalVariable.gTestIdPathWay);
XSSFWorkbook workbook = new XSSFWorkbook (fis);

XSSFSheet sheet = workbook.getSheet("Sheet1");

// cell A2
Row row = sheet.createRow(1);
Cell cell = row.createCell(0);

cell.setCellType(cell.CELL_TYPE_STRING);
cell.setCellValue(GlobalVariable.gUserLastName);

FileOutputStream fos = new FileOutputStream(GlobalVariable.gTestIdPathWay);
workbook.write(fos);
fos.close();
fis.close();

and then to retrieve it:

FileInputStream fis = new FileInputStream (GlobalVariable.gTestIdPathWay);
XSSFWorkbook workbook = new XSSFWorkbook (fis);

XSSFSheet sheet = workbook.getSheet("Sheet1");
// cell A2
Row row = sheet.getRow(1);
Cell cell = row.getCell(0);
GlobalVariable.gUserLastName= cell.getStringCellValue();

fis.close()