Hello;
I hope I can get a little help/direction.
I have one more step in this process to get my program working correctly. There is a field called AFFIL that is supposed to have affiliate codes automatically assigned as the files are uploaded in the temp directory. Examples of the codes are:
BMPR, HTTO etc. Is there a way(perhaps in a case statement, to have these codes automatically entered into the AFFIL field if they are part of the initial Excel file?
I am uncertain where and how to accomplish this in VFP.
I greatly appreciate any help.
*SET EXCLUSIVE OFF
* 1. Setup excel headers (Source doc)
* 2. Save excel as dbf (Table #1)
* 4. Export Exceed to excel
* 5. Convert Exceed excel to dbf (Table # 2)
* 6. Scan for dups
* 7. Export to excel (Table # 1)
* 8. Import into Exceed
CLOSE database
SET SAFETY OFF
SET DELETED on
clear
Set Default To c:\temp
cstr = Alltrim(Getfile('Excel:xls'))
*Alltrim..Removes all leading and trailing spaces or parsing characters from the specified character expression
Import From (cstr) Type Xls
*store ALIAS() TO cTableName
STORE JUSTFNAME(cstr) TO
STORE getwordnum(cFileName,1,".") TO cTableName
* Getwordnumreturns a specified word from a string
use
*IMPORT FROM c:\temp\+&cstr TYPE xls
SELECT 2
*this is the MERGE from Exceed
IMPORT FROM c:\temp\merge.xls TYPE XLS
SELECT 1
USE "c:\temp\"+(cTablename)+".dbf" exclusive
alter table (cTablename) rename column a to AIDNO
alter table (cTablename) rename column b to fNAME
alter table (cTablename) rename column c to lNAME
alter table (cTablename) rename column d to COMPANYDIV
alter table (cTablename) rename column e to ADDRES1
alter table (cTablename) rename column f to CITY
alter table (cTablename) rename column g to STATE
alter table (cTablename) rename column h to ZIP
alter table (cTablename) rename column i to PHONE
alter table (cTablename) rename column j to PHTYPE
alter table (cTablename) rename column k to PHNOTES
alter table (cTablename) rename column l to COUNTY
alter table (cTablename) rename column m to AFFIL
GOTO 1
DELETE
STORE 0 TO ncount
STORE 0 TO nduplicates
SCAN all
STORE ncount +1 TO ncount
STORE ALLTRIM(AIDNO) TO cAIDNO
STORE ALLTRIM(fname) TO cFname
STORE ALLTRIM(lname) TO cLname
STORE ALLTRIM(COMPANYDIV) TO cCOMPANYDIV
STORE ALLTRIM(addres1) TO cAddres1
STORE ALLTRIM(CITY) TO CCITY
STORE ALLTRIM(STATE) TO CSTATE
STORE ALLTRIM(ZIP) TO CZIP
STORE ALLTRIM(PHONE) TO CPHONE
STORE ALLTRIM(PHTYPE) TO CPHTYPE
STORE ALLTRIM(PHNOTES) TO CPHNOTES
STORE ALLTRIM(COUNTY) TO CCOUNTY
STORE ALLTRIM(AFFIL) TO CAFFIL
STORE "Source: "+cFname+" "+cLname+CHR(13)+cAddres1+", " +CCITY+", "+CSTATE+", "+CZIP TO cSource
SELECT 2
LOCATE FOR ALLTRIM(b) = cLname AND ALLTRIM(c) = cFname
IF FOUND()
store nduplicates+1 to nduplicates
STORE "Destination Record: "+ALLTRIM(c)+" "+ALLTRIM(b)+CHR(13)+ALLTRIM(i)+", " +ALLTRIM(k)+", "+ALLTRIM(l)+", "+ALLTRIM(m) TO cDestination
eMessageTitle = "Duplicate Checker"
eMessageText = "Duplicate found: "+csource+CHR(13)+CHR(13)+;
cDestination+CHR(13)+CHR(13)+ "Would you like to delete source record?"
nDialogType = 3 + 16 + 256
* 4 = Yes and No buttons
* 16 = Stop sign icon
* 256 = Second button is default
nAnswer = MESSAGEBOX(eMessageText, nDialogType, eMessageTitle)
DO CASE
CASE nAnswer = 2
cancel
CASE nAnswer = 6
SELECT 1
*this will delete record from data session
DELETE
CASE nAnswer = 7
SELECT 1
ENDCASE
ENDIF
*code if no dups
ENDSCAN
eMessageTitle = 'No Duplicates'
eMessageText = 'Completed Search. '+STR(ncount, 4)+' Records Searched'+Chr(13)+Chr(13)+STR(nduplicates, 4)+" Duplicates Found"
nDialogType = 0 + 16 + 256
* 4 = Yes and No buttons
* 16 = Stop sign icon
* 256 = Second button is default
nAnswer = MESSAGEBOX(eMessageText, nDialogType, eMessageTitle)
PACK
Select 1
COPY TO Exceed.CSV TYPE CSV
I hope I can get a little help/direction.
I have one more step in this process to get my program working correctly. There is a field called AFFIL that is supposed to have affiliate codes automatically assigned as the files are uploaded in the temp directory. Examples of the codes are:
BMPR, HTTO etc. Is there a way(perhaps in a case statement, to have these codes automatically entered into the AFFIL field if they are part of the initial Excel file?
I am uncertain where and how to accomplish this in VFP.
I greatly appreciate any help.
*SET EXCLUSIVE OFF
* 1. Setup excel headers (Source doc)
* 2. Save excel as dbf (Table #1)
* 4. Export Exceed to excel
* 5. Convert Exceed excel to dbf (Table # 2)
* 6. Scan for dups
* 7. Export to excel (Table # 1)
* 8. Import into Exceed
CLOSE database
SET SAFETY OFF
SET DELETED on
clear
Set Default To c:\temp
cstr = Alltrim(Getfile('Excel:xls'))
*Alltrim..Removes all leading and trailing spaces or parsing characters from the specified character expression
Import From (cstr) Type Xls
*store ALIAS() TO cTableName
STORE JUSTFNAME(cstr) TO
STORE getwordnum(cFileName,1,".") TO cTableName
* Getwordnumreturns a specified word from a string
use
*IMPORT FROM c:\temp\+&cstr TYPE xls
SELECT 2
*this is the MERGE from Exceed
IMPORT FROM c:\temp\merge.xls TYPE XLS
SELECT 1
USE "c:\temp\"+(cTablename)+".dbf" exclusive
alter table (cTablename) rename column a to AIDNO
alter table (cTablename) rename column b to fNAME
alter table (cTablename) rename column c to lNAME
alter table (cTablename) rename column d to COMPANYDIV
alter table (cTablename) rename column e to ADDRES1
alter table (cTablename) rename column f to CITY
alter table (cTablename) rename column g to STATE
alter table (cTablename) rename column h to ZIP
alter table (cTablename) rename column i to PHONE
alter table (cTablename) rename column j to PHTYPE
alter table (cTablename) rename column k to PHNOTES
alter table (cTablename) rename column l to COUNTY
alter table (cTablename) rename column m to AFFIL
GOTO 1
DELETE
STORE 0 TO ncount
STORE 0 TO nduplicates
SCAN all
STORE ncount +1 TO ncount
STORE ALLTRIM(AIDNO) TO cAIDNO
STORE ALLTRIM(fname) TO cFname
STORE ALLTRIM(lname) TO cLname
STORE ALLTRIM(COMPANYDIV) TO cCOMPANYDIV
STORE ALLTRIM(addres1) TO cAddres1
STORE ALLTRIM(CITY) TO CCITY
STORE ALLTRIM(STATE) TO CSTATE
STORE ALLTRIM(ZIP) TO CZIP
STORE ALLTRIM(PHONE) TO CPHONE
STORE ALLTRIM(PHTYPE) TO CPHTYPE
STORE ALLTRIM(PHNOTES) TO CPHNOTES
STORE ALLTRIM(COUNTY) TO CCOUNTY
STORE ALLTRIM(AFFIL) TO CAFFIL
STORE "Source: "+cFname+" "+cLname+CHR(13)+cAddres1+", " +CCITY+", "+CSTATE+", "+CZIP TO cSource
SELECT 2
LOCATE FOR ALLTRIM(b) = cLname AND ALLTRIM(c) = cFname
IF FOUND()
store nduplicates+1 to nduplicates
STORE "Destination Record: "+ALLTRIM(c)+" "+ALLTRIM(b)+CHR(13)+ALLTRIM(i)+", " +ALLTRIM(k)+", "+ALLTRIM(l)+", "+ALLTRIM(m) TO cDestination
eMessageTitle = "Duplicate Checker"
eMessageText = "Duplicate found: "+csource+CHR(13)+CHR(13)+;
cDestination+CHR(13)+CHR(13)+ "Would you like to delete source record?"
nDialogType = 3 + 16 + 256
* 4 = Yes and No buttons
* 16 = Stop sign icon
* 256 = Second button is default
nAnswer = MESSAGEBOX(eMessageText, nDialogType, eMessageTitle)
DO CASE
CASE nAnswer = 2
cancel
CASE nAnswer = 6
SELECT 1
*this will delete record from data session
DELETE
CASE nAnswer = 7
SELECT 1
ENDCASE
ENDIF
*code if no dups
ENDSCAN
eMessageTitle = 'No Duplicates'
eMessageText = 'Completed Search. '+STR(ncount, 4)+' Records Searched'+Chr(13)+Chr(13)+STR(nduplicates, 4)+" Duplicates Found"
nDialogType = 0 + 16 + 256
* 4 = Yes and No buttons
* 16 = Stop sign icon
* 256 = Second button is default
nAnswer = MESSAGEBOX(eMessageText, nDialogType, eMessageTitle)
PACK
Select 1
COPY TO Exceed.CSV TYPE CSV