Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OO Design Question and recursion question?
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00266441
Message ID:
00266785
Views:
22
>How would something like this handle all of the possible subassemblies? Would this be just a wrapper class?

Derek,

That depends on what you mean by "handle". Are you printing a BOM or displaying it onscreen, or both?

Here's a BOM function that will produce a cursor with the finished good as the frist record and each item after it with a link filed to an items immediate parent item;
* Calling stub
CREATE CURSOR BOM (ItemID I, ;
                   ParentItemID I )
LOCAL lnRecno()
PRIVATE lnRecurseLevel
lnRecurseLevel = 0
USE Inventory
* Find the fisnished good you want
SELECT 0
USE BOM ORDER ItemID
IF NOT ProduceBOM( ItemID )
   * Recursion failed because BOM is too complex
ENDIF
GOTO lnRecno()

* Produce BOM cursor
PROCEDURE ProduceBOM
LPARAMETERS liItem
LOCAL liNextItem, lcAlias, llRet
lnRecurseLevel = lnRecurseLevel + 1
IF lnRecurseLevel > 100
   RETURN .F.
ENDIF  
lcAlias = ALIAS()
SELECT BOM
SEEK litemID
SCAN WHILE iItemID = liItemID
   INSERT INTO BOM ( ItemID, ParentItemID ) VALUES ( iItemID, liItemID )
   llRet = ProduceBOM( ChildItemID )
ENDSCAN
RETURN llRet
This is just off the top of my head so it is not tested or debugged but it should show you that exploding a BOm is not a difficult process. The procedur could easily bet a mathod in an object and the object could have a property for hilding the top level item to be exploded.

The key conecpt here its to not think of the object as the BOM but rather as a thing that can produce a BOM.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform