[SOLVED] Build a string from a field in multiple records
I know I've seen this before but can't seem to get back to it.
I have a table with student_id and course_id like this:
quote:
PAGE 1
PERSON_UID CRS_ID 00021572 MAT 000 MAT 112 MAT 119 MAT 191
01038239 MAT 000 MAT 115
I need to print all the courses as a string field like this:
quote:
PERSON_UID ALL_MATH_COURSES 00021572 MAT 000 MAT 112 MAT 119 MAT 191 01038239 MAT 000 MAT 115
Thanks......SteveThis message has been edited. Last edited by: Kerry,
Dev Studio /7.6.11/7.7.02M MVS/USS AIX/SOLARIS Windows WF Client 7.6.8/7.6.11
September 01, 2011, 10:23 AM
Doug
Here's my first thought: COMPUTE (or DEFINE) a field which concatenates NewField/A132 = ThisField | LAST ThisField ; and so on...
September 01, 2011, 10:51 AM
jfr99
Hi Steve,
Here's an example using the CAR file. This creates a string (CAR_LIT) of all CARs per COUNTY.
-* TABLE FILE CAR PRINT CAR BY COUNTRY ON TABLE HOLD AS TMP_CAR END -* DEFINE FILE TMP_CAR CAR_LIT/A90 = IF COUNTRY EQ LAST COUNTRY THEN SUBSTR(90, CAR_LIT, 1, 72, 72, 'A72') || (', ' | CAR) ELSE CAR; END -* TABLE FILE TMP_CAR SUM CAR_LIT BY COUNTRY END
Maybe this will help.
Jim
WebFocus 8.201M, Windows, App Studio
September 01, 2011, 11:55 AM
SRC
Jim,
That worked perfectly!
I had started looking at string functions but figured by the time I went through all the iterations, someone would have the answer already.
Thanks a bunch............SteveThis message has been edited. Last edited by: SRC,
Dev Studio /7.6.11/7.7.02M MVS/USS AIX/SOLARIS Windows WF Client 7.6.8/7.6.11
September 01, 2011, 12:51 PM
jfr99
Hi Steve,
Glad it worked.
I save little examples like this so I can use them the next time I need it.