Below is my code for the flow to check a flat file. and read every line.
Question is it skips one record i.e. tablenumber2 and want to add the records
for tablenumber2.
Following are the criteria to check and process.
1) check for the table number
2) on finding the table number
check
2.1) anywhere the word starting with PR1 and in that line to check
whether there is a word called ADD or LESS (if it is there store value)
(ADD or LESS can come any in the flat file)
2.2) if the criteria for the above 2.1 is met i.e. found PR1 and does not
have ADD or LESS and has a summary than do the process and store value.
all these are to be done in a loop for each table number and to check when the
table number changes.
e.g. for a flat file
------------------------
Date description qty
------------------------
TableNumber1
22-6-02 item1 3
PR1 ljflsdjf ADD 5
22-6-02 item3 0
PR1 Summary
Total Item 1 Added
Total Item 1 Deducted
------------------------------ (this line may be present at times)
TableNumber2
22-6-02 item4 2
22-6-02 item5 1
PR1 ljflsdjf ADD 4
PR1 Summary
Total Item 2 Added 5
Total Item 2 Deducted 6
PR1 ljflsdjf ADD 5
PR1 kjlfsadflkj LESS 4
-------------------------------------------------------------
TableNumber3
22-6-02 item4 2
22-6-02 item5 1
PR1 Summary
Total Item 2 Added 5
Total Item 2 Deducted 6
--------------------------------------
The code is as follows :
Do While Not EOF(varFileNumber)
Line Input #varFileNumber, varLineString
varTableNumber = Left(varLineString, 11)
If varTableNumber = "TableNumber" Then
pTerminalId = Right(varLineString, 1)
vCheckTerminalId = pTerminalId
Line Input #varFileNumber, varLineString
Do While varPR1 <> "PR1"
Line Input #varFileNumber, varLineString
varPR1 = Mid(varLineString, 2, 4)
Loop
If varPR1 = "PR1" Then
varADDLESS = Mid(varLineString, 45, 4)
If varADDLESS = "ADD" Or varADDLESS = "LESS" Then
Line Input #varFileNumber, varLineString
varPR1 = ""
End If
End If
varPR2 = varPR1
Do While varPR2 = "PR1"
'Processing to store records
Loop 'PR1
Loop
End If
Loop ' EOF of Raw File
Regards
Question is it skips one record i.e. tablenumber2 and want to add the records
for tablenumber2.
Following are the criteria to check and process.
1) check for the table number
2) on finding the table number
check
2.1) anywhere the word starting with PR1 and in that line to check
whether there is a word called ADD or LESS (if it is there store value)
(ADD or LESS can come any in the flat file)
2.2) if the criteria for the above 2.1 is met i.e. found PR1 and does not
have ADD or LESS and has a summary than do the process and store value.
all these are to be done in a loop for each table number and to check when the
table number changes.
e.g. for a flat file
------------------------
Date description qty
------------------------
TableNumber1
22-6-02 item1 3
PR1 ljflsdjf ADD 5
22-6-02 item3 0
PR1 Summary
Total Item 1 Added
Total Item 1 Deducted
------------------------------ (this line may be present at times)
TableNumber2
22-6-02 item4 2
22-6-02 item5 1
PR1 ljflsdjf ADD 4
PR1 Summary
Total Item 2 Added 5
Total Item 2 Deducted 6
PR1 ljflsdjf ADD 5
PR1 kjlfsadflkj LESS 4
-------------------------------------------------------------
TableNumber3
22-6-02 item4 2
22-6-02 item5 1
PR1 Summary
Total Item 2 Added 5
Total Item 2 Deducted 6
--------------------------------------
The code is as follows :
Do While Not EOF(varFileNumber)
Line Input #varFileNumber, varLineString
varTableNumber = Left(varLineString, 11)
If varTableNumber = "TableNumber" Then
pTerminalId = Right(varLineString, 1)
vCheckTerminalId = pTerminalId
Line Input #varFileNumber, varLineString
Do While varPR1 <> "PR1"
Line Input #varFileNumber, varLineString
varPR1 = Mid(varLineString, 2, 4)
Loop
If varPR1 = "PR1" Then
varADDLESS = Mid(varLineString, 45, 4)
If varADDLESS = "ADD" Or varADDLESS = "LESS" Then
Line Input #varFileNumber, varLineString
varPR1 = ""
End If
End If
varPR2 = varPR1
Do While varPR2 = "PR1"
'Processing to store records
Loop 'PR1
Loop
End If
Loop ' EOF of Raw File
Regards