Hi Vitaly, this is existing code written by earlier team, linenumber+1 is there, the code first create globals and then from globals push the data to ECR. One question for reconciliation purpose I can create one table and push data to that table to i can store the flat files data into a table for example "SourceData" so I can do some validation on data prior to pushing to ECR like mandatory fields are not empty, code fields have allowed codes etc. 

I can do that 

Set  table.field1 = $PIECE(line"|", 1)

Set  table.field1 = $PIECE(line"|", 1)

set status = table.%save() 

OR

I can use your For logic above to go over the each value in the line but setting to table field can I use "i" variable like

For i=2:1:$LENGTH(line) {

set SourceTable.Field_i = $PIECE(line, "|", i)

Thanks, your code gave me the idea, Do you think below code will fix the issue and ".line" value will be changed? I will do testing but it will take time so review new code below pls and advice if anything wrong is there.

while ('tInput.AtEnd)   {
       #dim line as %String = tInput.ReadLine(, .status)
       quit:$$$ISERR(status)
       set tLineNumber = tLineNumber + 1
       //20112020: new code added
       Set remainder = $PIECE(line, "|", 9, $LENGTH(line))
       Set newline = $PIECE(line, "|", 2)_"^"_$PIECE(line, "|", 3)_"^"_$PIECE(line, "|", 4)_"^"_$PIECE(line, "|", 5)_"^"_$PIECE(line, "|", 6)_"^"_$PIECE(line, "|", 7)_"^"_$PIECE(line, "|", 8)_remainder
       Set line = newline
       //20112020: new code end
       if tLineNumber > 1       {
        If (tFileType="PatientContact")    {
        set status = ..SetPatientContact(.line, tFileType, tLineNumber)