Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SOS! Think you can help me?
Message
From
17/06/1999 13:42:00
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
SOS! Think you can help me?
Miscellaneous
Thread ID:
00230966
Message ID:
00230966
Views:
46
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
suspend
REPLACE blanket WITH "BLKT" FOR blanket = "BLK"
REPLACE blanket WITH " " FOR blanket <> "BLKT"
GO TOP
SET DELETED 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 DBF("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 tab2
APPEND FROM DBF("tempcur")
ELSE && (means there is changes)
SELECT tab3
APPEND FROM DBF("tempcur")
ENDIF
OTHERWISE && (means HISTPO has duplicate POs, need to DELETE recs in HISTPO, add new record into HISTPO)
SELECT tab3
APPEND FROM DBF("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 recs into HISTPO)
SELECT tab1
APPEND FROM DBF("tempcur")

!!!!!!!!!!
!!!!!!!!!! THIS IS SECTION I NEED HELP
!!!!!!!!!!

CASE _tally = ct && (means both tables has same counts, so need to verfiy side-by-side)
SELECT histpo
COPY TO histtemp FOR po = varpo && (to be able to DELETE recs in a table, not in a cursor)
USE histtemp IN 0
SELECT DBF("tempcur")
COPY TO temptemp && (to be able to DELETE recs in a tables, not in a cursor)
USE temptemp IN 0
SELECT temptemp
DO WHILE NOT EOF()
varpo = po
varclass = class
varfund = fund
varudds = udds
varamount = amount
varfy = fy
varactivity = activity
varaccount = account
SELECT histtemp
LOCATE
DO WHILE NOT EOF()
IF class = varclass AND ;
fund = varfund AND ;
udds = varudds AND ;
amount = varamount AND ;
fy = varfy AND ;
activity = varactivity AND ;
account = varaccount
DELETE
SELECT temptemp
DELETE
EXIT
ELSE
SKIP
IF EOF()
SELECT tab3
APPEND FROM DBF("tempcur")
ENDIF
ENDIF
ENDDO
ENDDO

!!!!!!!!!!
!!!!!!!!!! ABOVE IS SECTION I NEED HELP
!!!!!!!!!!

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

CLOSE ALL
RETURN

PROCEDURE getout
CLOSE ALL
WAIT WINDOW "The table(s) can not be open exclusively at this time, please try again later."
leavenow=.T.
RETURN
Today is tomorrow's yesterday.
Next
Reply
Map
View

Click here to load this message in the networking platform