’ Clone the schema structure first
io_OutDT = in_TempDT.Clone()
’ Loop through each template line item and map it safely
For Each tempRow As DataRow In in_TempDT.Rows
Dim rowName As String = tempRow(0).ToString().Trim().ToUpper()
Dim cellValue As String = “”
If rowName.Contains("FROM DATE") Then
cellValue = in_CurrentRow("ACTUAL_DIS_DATE").ToString()
ElseIf rowName.Contains("TO DATE") Then
cellValue = in_CurrentRow("ACCT_OPN_DATE").ToString()
ElseIf rowName.Contains("ACC HOLDER") Then
cellValue = in_CurrentRow("ACCT_NAME").ToString()
ElseIf rowName.Contains("CIF ID") Then
cellValue = in_CurrentRow("CIF_ID").ToString()
ElseIf rowName.Contains("ACC ID") Then
cellValue = in_CurrentRow("ACCOUNT_ID").ToString()
ElseIf rowName.Contains("ACC SEASONAL LIM") Then
cellValue = in_CurrentRow("CUST_LIM_SANCTION_AMT").ToString()
ElseIf rowName.Contains("ACC REGULAR LIM") Then
cellValue = in_CurrentRow("ACCT_SANCTION_LIM").ToString()
ElseIf rowName.Contains("DIS AMT & DATE") Then
cellValue = in_CurrentRow("dis_amt").ToString() & " / " & in_CurrentRow("ACTUAL_DIS_DATE").ToString()
ElseIf rowName.Contains("ACTUAL DIS DATE") Then
cellValue = in_CurrentRow("ACTUAL_DIS_DATE").ToString()
ElseIf rowName.Contains("ACC LIM EXP DATE") Then
cellValue = in_CurrentRow("lim_exp_date").ToString()
ElseIf rowName.Contains("INT CHARGED") Then
cellValue = in_CurrentRow("InterestRate").ToString()
ElseIf rowName.Contains("PENAL CHARGES") Then
cellValue = in_CurrentRow("Penal_Amt").ToString()
End If
' Commit the resolved row into our output structure
io_OutDT.Rows.Add(rowName, cellValue)
Next