VB script - Read PO Detail bus - EoF error

I am writing a script on the purchase order header which looks at each line in the purchase order and looks up for the Item code in the purchase order detail bus to get information from previous order for that item.

I am using Set Browse Index EOF to loop through the transaction in the Purchase Order Detail bus, but, not sure why, my script is not going through EOF. Here is part of the code that.

Set oPurOrdDet = oSession.AsObject(oSession.GetObject("PO_PurchaseOrderDetail_bus"))
retVal = oPurOrdDet.SetBrowseIndex("KITEMWHSE", "")
retVal = oPurOrdDet.SetBrowseFilter(ItemCode & WarehouseCode & "" & "")
retVal = oPurOrdDet.MoveFirst()

Do until oPurOrdDet.EOF = 1
retVal = oPurOrdDet.GetValue("PurchaseOrderNo$", PONo)
retVal = oPurOrdDet.GetValue("ItemCode$", ItemCode1)

retVal = oPurOrdDet.MoveNext()

Loop

Any help is greatly appreciated.

Thanks,

Nishanth