I am trying to merge 2 datarows and I am stuck with the following problem. I have 2 datarows like this Datarow 1:
PLAN VALUE
B 50
A 75
Datarow 2
PLAN AMT
C 1000
A 3400
B 1400
Now when I am merging the datarows, I check to see that the plan name is the same so that A has VALUE 75 and AMT 3400 and so on. Now it works fine for A but when it comes to B, the datarow 2 has already reached the end and so I am getting a null value. Is there any way to fix this problem?
This is what I want
PLAN VALUE AMT
A 75 3400
B 50 1400
I tried using the rewind method but it doesn't seem to work as I am getting a 'user error'. This is the code I have in the Fetch method of AcMultipleInputFilter:
Dim HdrDataRow as DataRow1
Dim CarrierDataRow as Datarow2
Dim MergedDatarow as Datarow3
set MergedDatarow = NewDataRow()
Dim adapter as AcDataAdapter
set adapter = InputAdapters.getAt(1)
set HdrDataRow = adapter.fetch()
if not HdrDatarow is nothing then
MergedDatarow.PLAN = HdrDataRow.PLAN
'----------------------------------------------------
' To get the appropriate value from datarow2
set myBuffer = InputAdapters.getAt(2)
set CarrierDataRow = myBuffer.Fetch()
Do while not CarrierDataRow is nothing
if MergedDataRow.PLAN = CarrierDataRow.PLAN then
MergedDataRow.AMT = CarrierDataRow.AMT
end if
set CarrierDataRow = adapter.Fetch() //this is going to
keep fetching records till it reaches the end
Loop
'----------------------------------------------------
MergedDataRow.VALUE = HdrDataRow.VALUE
else
MergedDatarow.PLAN = NULL
MergedDataRow.VALUE = NULL
end if
if HdrDataRow is nothing and CarrierDataRow is nothing then
Exit Function
end if
set Fetch = MergedDataRow
PLAN VALUE
B 50
A 75
Datarow 2
PLAN AMT
C 1000
A 3400
B 1400
Now when I am merging the datarows, I check to see that the plan name is the same so that A has VALUE 75 and AMT 3400 and so on. Now it works fine for A but when it comes to B, the datarow 2 has already reached the end and so I am getting a null value. Is there any way to fix this problem?
This is what I want
PLAN VALUE AMT
A 75 3400
B 50 1400
I tried using the rewind method but it doesn't seem to work as I am getting a 'user error'. This is the code I have in the Fetch method of AcMultipleInputFilter:
Dim HdrDataRow as DataRow1
Dim CarrierDataRow as Datarow2
Dim MergedDatarow as Datarow3
set MergedDatarow = NewDataRow()
Dim adapter as AcDataAdapter
set adapter = InputAdapters.getAt(1)
set HdrDataRow = adapter.fetch()
if not HdrDatarow is nothing then
MergedDatarow.PLAN = HdrDataRow.PLAN
'----------------------------------------------------
' To get the appropriate value from datarow2
set myBuffer = InputAdapters.getAt(2)
set CarrierDataRow = myBuffer.Fetch()
Do while not CarrierDataRow is nothing
if MergedDataRow.PLAN = CarrierDataRow.PLAN then
MergedDataRow.AMT = CarrierDataRow.AMT
end if
set CarrierDataRow = adapter.Fetch() //this is going to
keep fetching records till it reaches the end
Loop
'----------------------------------------------------
MergedDataRow.VALUE = HdrDataRow.VALUE
else
MergedDatarow.PLAN = NULL
MergedDataRow.VALUE = NULL
end if
if HdrDataRow is nothing and CarrierDataRow is nothing then
Exit Function
end if
set Fetch = MergedDataRow