Text pasting in different line text box instead of intended line textbox

Your table starts at line 0 (zero), so the second line should be 1. Unfortunately, if you insert a row into the table, the “new” row does not become the “next” number, but some seemingly random number. As an example, below are the first two rows in the table after I inserted the new row. The new row went into the second row.

//row1 = _FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:**0**:it27::content
//row2 = _FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:**8**:it27::content

As you can see from the part that I highlighted in the above, there is only I digit that is different. Now, the table starts at 0 and the new row would be the ninth, so 8 is correct, however, you would need to count how many rows there are to get the new row index.

import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

def driver = DriverFactory.getWebDriver()
...
WebUI.click(findTestObject('Object Repository/Page_Manage Transactions - Billing - Oracle_c9685a/input_Number of Periods__FOpt1_FOr10_FOSrit_2e6301'))

WebUI.setText(findTestObject('Object Repository/Page_Manage Transactions - Billing - Oracle_c9685a/input_Assessable Value__FOpt1_FOr10_FOSrite_f82baf'), '2')

List<WebElement> list = driver.findElements(By.xpath('//input[contains(@id,"_FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:") and contains(@id, ":it27::content")]')
rowCount = list.size()  // this is the number we want less one because we start at zero

myItem = driver.findElement(By.xpath("id('_FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:${rowCount - 1}:it27::content')")
myItem.sendKeys("2nd line data")

I am using a substitution on the rowCount and you might have to play with the double quote and single quote placement. The substitution needs the double quotes, but the id should only need the single quote.

Edit: If I am on the wrong page and therefore the wrong table, my apologies, but I can only imagine what elements you are clicking on based on your naming convention / description that you are using, like: _FOpt1_FOr10_FOSritemNode_receiv_2e1a17. Perhaps, you can add some text of the element, like 'img_Reorder Columns_View_FOpt1_FOr10_FOSritemNo_901715`, or Edit or Action or AddRow… as I did not find any 901715 on the page.