Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can or would you help me with my programming???
Message
From
16/06/1999 14:56:34
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
 
 
To
16/06/1999 14:39:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00230556
Message ID:
00230581
Views:
19
>Post it here! Heck, just add it as a reply to my message....if people don't want to read it they don't have to.

Actually, I rather post it here, so if others spot something and shares some improvements, I may receive another pat on my back for it :)

So, here is the post, have a good day :)

***
CLEAR
SET MULTILOCKS ON
leavenow=.F.
SET ESCAPE OFF
ON ERROR DO getout
LOCAL laTables, lcTableName, lcKey
OPEN DATABASE po EXCLUSIVE
DIMENSION laTables[1]
ADBOBJECTS(laTables, "TABLE")
FOR EACH lcTableName IN laTables
USE (lcTableName) EXCLUSIVE IN 0
IF leavenow=.T.
EXIT
ENDIF
SELECT (lcTableName)
lcKey=TAG(1)
SET ORDER TO &lcKey
ENDFOR

IF leavenow=.T.
RETURN
ENDIF
SET ESCAPE ON
ON ERROR

*the remaining of the program starts right here...
SELECT poencr
APPEND FROM poencr.xls TYPE XLS
GO TOP
DELETE
PACK

SET SAFETY OFF
SELECT workpo
APPEND FROM poencr
REPLACE blanket WITH "BLKT" FOR blanket = "BLK"
REPLACE blanket WITH " " FOR blanket <> "BLKT"
GO TOP
SET DELETED ON
set step on
DO WHILE NOT EOF()
varpo = po
varclass = class
varfund = fund
varudds = udds
varamount = amount
varfy = fy
varactivity = activity
varaccount = account
SELECT * FROM workpo INTO CURSOR tempcur WHERE po = varpo
SELECT workpo
DELETE FOR po = varpo
SELECT tempcur
COUNT TO ct
IF ct = 1
SELECT histpo
COUNT FOR po = varpo
DO CASE
CASE _tally = 0 && (means HISTPO has no matching PO, just add new record into HISTPO)
SELECT tab1
APPEND FROM tempcur
CASE _tally = 1 && (means one matching record, need to see if any changes)
SEEK varpo
IF class = varclass AND ;
fund = varfund AND ;
udds = varudds AND ;
amount = varamount AND ;
fy = varfy AND ;
activity = varactivity AND ;
account = varaccount && (means all fields matches)
* SELECT workpo
* REPLACE which WITH "2"
SELECT tab2
APPEND FROM tempcur
ELSE && (means there is changes)
REPLACE class WITH varclass, ;
fund WITH varfund, ;
udds WITH varudds, ;
amount WITH varamount, ;
fy WITH varfy, ;
activity WITH varactivity, ;
account WITH varaccount
* SELECT workpo
* REPLACE which WITH "3"
SELECT tab3
APPEND FROM tempcur
ENDIF
OTHERWISE && (means HISTPO has duplicate POs, need to DELETE records in HISTPO, add new record into HISTPO)
SELECT tab3
APPEND FROM tempcur
ENDCASE
ELSE && (means tempcur has duplicates POs)
SELECT histpo
COUNT FOR po = varpo
DO CASE
CASE _tally = 0 && (means HISTPO has no matching PO, just add new records into HISTPO)
SELECT tab1
APPEND FROM tempcur


***
***THIS SECTION IS WHERE I NEED HELP!!!
***

CASE _tally = ct && (means both tables has same counts, so need to verfiy side-by-side)
SELECT histpo
SELECT * FROM histpo TO histtemp WHERE po = varpo
SELECT tempcur
SELECT * FROM tempcur TO temptemp
SCAN FOR po = varpo
IF class = varclass AND ;
fund = varfund AND ;
udds = varudds AND ;
amount = varamount AND ;
fy = varfy AND ;
activity = varactivity AND ;
account = varaccount
SELECT histtemp
DELETE
SELECT temptemp
DELETE
LOCATE
ELSE && (means tempcur has updated data, need to DELETE records in HISTPO, add new records into HISTPO)
SELECT tab3
APPEND FROM tempcur
EXIT
ENDIF
SELECT histtemp
IF BOF() && (see next 2nd line)
SELECT temptemp
IF BOF() && (means ALL matches)
SELECT tab2
APPEND FROM tempcur
ELSE
SELECT tab3
APPEND FROM tempcur
ENDIF
ELSE
SELECT tab3
APPEND FROM tempcur
ENDIF
ENDSCAN

***
*** ABOVE SECTION IS WHERE I NEED HELP!!!
***

OTHERWISE && (means both tables has different counts, so need to DELETE records in HISTPO, add new recs into HISTPO)
SELECT tab3
APPEND FROM tempcur
ENDCASE
ENDIF
SELECT tempcur
USE
SELECT workpo
GO TOP
ENDDO


SELECT workpo
ZAP
SELECT poencr
ZAP
CLOSE ALL
RETURN
Today is tomorrow's yesterday.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform