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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a comma delimited field 1

Status
Not open for further replies.

slwilli

Programmer
Sep 24, 2002
5
US
I am new to Crystal Reports and am using version 8.0. I have a data field that can contain up to 30 characters of data. This data may consist of several part numbers separated by commas. Is there any way to extract these numbers individually for reporting?
 
Depending on what you mean by for reporting, you can certainly extract them.

If you just want to display them as separate entities vertically, you can just use something akin to the following:

Replace ({MyTable.MyParts}, ",", chr(13))

If you have to do some checking against them, you'll likely want an array, or to do leverage the sort of individual parsing the following array construction does:

whileprintingrecords;
Stringvar MyParts := {MyTable.MyParts};
Global Stringvar array MyPartsArray;

For x = 1 to 15 do // maximum number of commas
(
if InStr(MyParts, ",") > 0 then
MyPartsArray[X] := left({MyTable.MyParts},InStr(MyParts, ",") -1);
MyParts := mid({MyTable.MyParts},InStr(MyParts, ",")+1,30)
else
x = 16
);

(I didn't test the syntax and I'm tired, but this sample get you close).

-k kai@informeddatadecisions.com
 
Thanks for your help. This works for reporting. I do have another situation that may not be so easy to answer. I have two tables: one containing work orders and one containing purchase orders. The purchase order table has a text field that may contain a series of work order numbers (just like the parts number problem) that are separated by commas. Is there any way to extract those and join the work order table to the extracted information?
 
Not from within Crystal.

Though if the quantity is low enough, you might be able to manage this using arrays (1000 max per for CR 8.5 and below), but it's a long ways there...

This should be done on the database side, parse the data into meaningful fields.

Whoever designed these table structures should go back to skewl.

-k kai@informeddatadecisions.com
 
I agree! This is a user defined field and that is how they want to use it. I am not in a position to refuse (too new to the company). I am not sure how to handle this. Thanks for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top