>An example of my data:
>
>Part No Recseq
>854411-401 0000001
>854411-402 0000002
>854411-403 0000003
>854411-405 0000004
>854411-405 0000005
>854411-405 0000006
>854411-407 0000007
>
>My desired string:
>854411-401(000001),854411-402(000002),854411-403(0000003),854411-405(0000004,0000005,0000006),854411-407)
>
>This is the code I have came up with which almost works except it puts an ")" after the first -405 recseq number and no ")" after the last -405 recseq number(any multiple part numbers).
I'd rather do it like this:
CLEAR
SET EXACT On
partnoS = ""
SELECT testQuery
locate
do while !eof()
partnoS = ALLTRIM(partno)
lcCurrent=partno
lcComma="("
SCAN while partno=lcCurrent
partnoS=partnoS+lcComma+alltrim(recseq)
lcComma=","
endscan
partnoS=partnoS+")"
ENDdo
? partnoS