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!

Unique split and sort

Status
Not open for further replies.

rene316

Programmer
Jan 14, 2002
81
US
Hello,
I have a job that I am trying to stream line for one of our other departments, and need some help. The manager wants a program where he can just enter the name of the file and it gets the file ready for them. Basically, I need a program that will split the file on a card_num and sort it by customer_num and copy it to seperate files. So he will have however many groups as there are card numbers. If it helps you can think of the card number as a batch number. So the split will be batch number, then sorted on cust_id. I am stumped and running out of time, could someone please help me, I would be most appreciative.
-Thanks in advance
Rene
 
don't really know what your asking for, but maybe some SQL will help:

SELE * FROM MyFile ;
ORDER BY customer_num ;
WHERE card_num=MySelection ;
INTO CURSOR tmpCursor
 
Hi Rene

SELECT DISTINCT card_num FROM myTable INTO CURSOR temp

SCAN
myCard_Num = card_num
myFile = card_num
** assumed card_num = character field.
** if it is numeric.. then..
** myFile = "A"+ALLT(STR(card_num))
SELECT * FROM myTable ;
INTO DBF (myFile) WHERE card_num == myCard_num ;
ORDER BY customer_num
ENDSCAN

This will give you one table for each card_num with the name of card_num as your filename (or "A"+card_num)
and with all customer_num in order.

:)


____________________________________________
ramani - (Subramanian.G) :)
 
Thanks you two, I appreciate the help. Ramani, I used your code and it is working, the only thing that I am having a problem with is the fact that it wants to open the input table on every iteration of the scan. So say it splits card 1, when it is done it wants to open the table again and then split card 2 and so on and so forth. I have been messing with it for about an hour and can't seem to figure it out, what do you suggest?
-Rene
 
Nevermind figured it out, it was a rookie mistake, hahaha.
-Thanks for all your help
Rene
 
Where ramani's code says myTable, you should put the whole name of your table... then it won't have to ask what file!

if the table isn't in the current directory, you must specify the full path, or SET PATH TO the path it is contained in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top