Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Probably an easy question
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00501861
Message ID:
00501868
Views:
19
>Hello,
>
>I am brand new to VFP, so this question is probably a very easy one. I am using VFP 6.0 with Stonefield and MMF.
>
>I have a large database containing many large tables. One of these tables contains several thousand customer orders, another contains a listing of all the possible products a customer can order, as well as all of the components needed to build each product. For example - Product A contains components 1, 3, 6, and 7; Product B contains componenents 1, 2, and 3.
>
>I need help writing a method that would pull all products containing a particular component and replace that component with a new one for all existing and future orders. For example - Using the data above, if component 2 was to be replaced with component 4, any future orders for product B would contain components 1, 3, and 4.
>
>I apologize if this seems real easy to you, but I am just starting out in VFP and could use any help you VFP Gurus could offer me!
>
>-Justin

Well, I would make a superseding table.
check my products for a supersession in it before adding them to the order.

create a table using stonefield containing two fields using the field repository definitions for your part number ( for ease of updates later)
one named newpart the other named oldpart
but for this example:

create table supersed (oldpart I ,newpart I)
index on newpart tag newpart
index on oldpart tag oldpart
put your supersesion info in it

then you could use code like the following

* Procedure superseded
*
* Author Alek Massey
* Date 5/1/2001
*
* this procedure doesn't care what type the superseded part is
* but will continue to look up a part until the end of the
* supersession chain is found and keeps track of the data environment only
* opening the supersesion table if required

PROCEDURE superseded
PARAMETER gCheckpart
LOCAL lreturnval, lnselect, llused

lnselect = sele(0)
lreturnval = gCheckpart
llused = used('supersed')
IF not llused
USE supersed in 0
ENDIF
SELE supersed
set order to oldpart

IF seek(gCheckpart)
lreturnval = superseded(newpart)
ENDIF

IF not llused
USE in supersed
ENDIF

SELE (lnselect)
RETURN lreturnval

ENDPROC

then call it like this

replace partnum with superseded(partnum)


There ya go
Alek
Alek Massey
- The only stupid question is one left unasked -
Previous
Reply
Map
View

Click here to load this message in the networking platform