FUNCTION using_items
(item : founded_item_select, checked_items : SET [0:?] OF founded_item_select) : SET [0:?] OF founded_item_select;
LOCAL new_check_items : SET OF founded_item_select; result_items : SET OF founded_item_select; next_items : SET OF founded_item_select; END_LOCAL; result_items := []; new_check_items := checked_items + item; -- Find the SET OF representation_items OR founded_items -- IN which item is used directly. next_items := QUERY(z <* bag_to_set( USEDIN(item , '')) | ('REPRESENTATION_SCHEMA.REPRESENTATION_ITEM' IN TYPEOF(z)) OR ('REPRESENTATION_SCHEMA.FOUNDED_ITEM' IN TYPEOF(z))); -- IF the SET OF next_items is NOT empty; IF SIZEOF(next_items) > 0 THEN -- FOR each element IN the set, find the using_items recursively REPEAT i := 1 TO HIINDEX(next_items); -- Check FOR loop IN data model, i.e. one OF the next_items -- occurred earlier IN the SET OF check_items; IF NOT(next_items[i] IN new_check_items) THEN result_items := result_items + next_items[i] + using_items(next_items[i],new_check_items); END_IF; END_REPEAT; END_IF; -- RETURN the SET OF representation_items OR founded_items -- IN which the input item is used directly AND indirectly. RETURN (result_items); END_FUNCTION; -- using_items
|