‎2016 Sep 26 3:26 PM
Hello all,
I came across a thought. Imagine example of object oriented design of a car garage. As we know, in garage, cars are parked.
Garage would be represented as object of class Garage. Cars as objects of class Car. In Garage I would have an internal table type table of ref to Car. So far, everything good.
But what if I need to retrieve a car with ID 45 I would need to loop through all objects in internal table and check ID until I find 45.
My question is: Is there any chance not to do that with loop but with read? Thanks
‎2016 Sep 26 3:39 PM
How about having a field called CAR ID in the internal table apart from the ref object? This way you can read the internal table with the field CAR ID and the second variable in the internal table would give you the instance of the car class?
Something like:
TYPES: BEGIN OF car,
car_id TYPE car_id,
car_instance TYPE REF TO class_name,
END OF car.
DATA: car_it TYPE TABLE OF car.
Thanks,
Vikram.M
‎2016 Sep 26 9:00 PM
I'm aware of that solution, I was thinking about more generic approach to read by any attribute, but that's something for functional programming
‎2016 Sep 26 4:18 PM
>>I came across a thought<<
Ouch. Did it hurt ??
I agree with Vikram.
And technically, a Garage is a Collection of Cars.....
Rich