eboughey1008
Programmer
I'm trying to export each unique list in a table and have them export separately with the correct qty of records displayed in the filename.
I have a field called list_no to scan into a temp table for the count qty... It's not exporting properly though. One file looks okay and the other doesn't have anything but the hard coded characters and record count (---3 recs.csv) It's not displaying the fields from t3temp AND it's assigning the filename incorrectly. The only thing right in this debacle is the record qty.
The file should export like this: "AMGA-Client Name-03_04_2023-Print Vendor-4 recs.csv" / "AMGA-Client Name-03_05_2023-Print Vendor-3 recs.csv". Any assistance at all would be much appreciated. I've tried different ways to put the scan/endscan but still didn't work. I normally just use a Do while on this because I don't need unique record qty.
lcprefix = "D:\nvatomate\jobs\retarget\"
IF NOT Directory(lcprefix)
MD (lcprefix)
ENDIF
Select Count(*) as qty, list_no FROM t3temp ;
Where EMPTY(Status);
Group By list_no;
Into Cursor curCounts
Select curCounts
SCAN
SELECT t3temp
lcNewfile = ALLTRIM(lcprefix)+ALLTRIM(dlrcode)+"-"+ALLTRIM(dealer)+"-"+ALLTRIM(MATCHDATE)+"-Print Vendor-"+ALLTRIM(STR(curCounts.qty,10,0))+" recs.csv"
COPY TO (lcNewfile) CSV FOR list_no = curCounts.list_no
ENDSCAN
CLOSE ALL
CLEAR