Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OO Design Question and recursion question?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00266441
Message ID:
00266785
Vues:
21
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform