Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting a maximum amount per keycode

Status
Not open for further replies.

EBOUGHEY

Programmer
Aug 20, 2002
143
US
Need help on the below code. Trying to export 7222 records for each keycode, but the program is only exporting a portion of each. I have the file in dlrnmbr order but it still doesn't work. Anybody see something blaring or perhaps easier coding?

Thanks

Elena


CLOSE ALL
CLEAR
SET SAFETY OFF

lcprefix = "c:\working\"

*** [(job#-drop).DBF - ]
*** SEPARATES THE DATA BY key AND EXPORTS IT TO dbf files by dealer # (key)


CJobno = SPACE (10)
FILENAME = ''

clear
@ 5,5 say 'Enter Job Number: ' get CJobno
READ

LCNEWDIR = alltrim(lcprefix)+ALLTRIM(CJobno)+"\"
CD (lcNewDir)

USE 59107 EXCLUSIVE
INDEX ON dlrnmbr tag dlrnmbr
set order to dlrnmbr
lcOldJobNo = dlrnmbr
GO TOP
scan
lcNewFile = alltrim(lcnewdir+"\TEST\"+(CJobno))+"-"+ALLTRIM(dlrnmbr)+".DBF"
COPY next 7222 TO (lcNewFile) for lcOldJobNo = dlrnmbr
lcOldJobNo = dlrnmbr
ENDscan

SET SAFETY ON
 
No help available on this one? This has been frustrating. I've tried several different ways without success....
 
Hi Elena,

Looks to me like each time you copy 7222 records your record pointer is moved up by 7222. SCAN won't reset it back to 1, so you're running out of records.

Jim
 
Is there a different way that you know of that would produce the same results?

I can actually code a field within the file instead of exporting to different files by just using a replace command for the first 7222 records the program encounters for each dealer #.



 
This solution sticks with your original idea of copying to different files:

SELECT DISTINCT dlrnmbr FROM mytable INTO CURSOR mycursor
SELECT mycursor
SCAN
lcNewFile = ALLTRIM(lcnewdir+"\TEST\"+(CJobno))+ ;
"-"+ALLTRIM(mycursor.dlrnmbr)+".DBF"
dlrnmbrx = mycursor.dlrnmbr
SELECT TOP 7222 * FROM mytable WHERE ;
mytable.dlrnmbr = dlrnmbrx ORDER BY dlrnmbr ;
INTO TABLE (lcNewFile)
ENDSCAN

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top