Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parsing multi-valued fields in Crystal Reports

Posted on 2008-10-14
5
Medium Priority
?
589 Views
Last Modified: 2012-06-21
I am pulling a multi-valued text string into Crystal Reports from a sql database.  The field is a comment field in which multiple values are entered into sql.  They are then stored in sql as a single text field, separated by: ý.
ie - teowtýCE.PHARM.TECH
I would like to take the text in this single Crystal Reports field and parse it out into two or more columns.
Column 1 = teowt
Column 2 = PHARM.TECH
Is there a way to do this in Crystal, or do I need to accomplish this via a SP on the SQL side?  I am not a promgrammer by any means, so dumb it down for me please !
Any help would be greatly appreciated.
0
Comment
Question by:cccpdavis
  • 3
  • 2
5 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 22712953
Yes, use the SPLIT function

Add a formula
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces := Split({YourField},'ý');
''

You can then use formulas to display each value
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces[1]

mlmcc
0
 

Author Comment

by:cccpdavis
ID: 22715347
First off, thanks for the response.
I attempted to run this process in Crystal and it throws errors relating to returning array values.  Right clicked on the field in the report and selected Format Field, then selected the formula icon next to the Display String details.  Not sure if I was executing that incorrectly or not.  
I then went into sql and executed the following:
Declare @SEC_COMMENTS    VARCHAR(100)
SET @SEC_COMMENTS = 'blahýblah'

SELECT SUBSTRING(@SEC_COMMENTS,1, NULLIF(CHARINDEX('ý', @SEC_COMMENTS) - 1, -1)) AS [COMMENT1],
         SUBSTRING(@SEC_COMMENTS, CHARINDEX('ý', @SEC_COMMENTS) +1, LEN(@SEC_COMMENTS)) AS [COMMENT2]

and it returns the text string that I specified in the correct format ('blahýblah'), but I cant figure out how to apply it to an actual data field to use in a query. Would I use this formula to create a stored procedure from which to generate a subset of data, or pass it directly in the query?  I am very new to all this (sql training coming in Feb) so now I am just trying to muddle through it on my own.  Thanks for any and all input.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 22715373
No.

In the Field Explorer
Right Click FORMULAS
Click NEW
Give it a NAME
Add the code
SAVE AND CLOSE

Use it like any other field from the database

mlmcc
0
 

Author Closing Comment

by:cccpdavis
ID: 31505942
Thanks a lot.
0
 

Author Comment

by:cccpdavis
ID: 22723986
Thanks a lot!  This worked great.  I figured out that the formula was one column, then I needed as many print columns as there were going to be delimiters.
Field 1 - WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces := Split({YourField},'ý');
''

Field 2, etc........ -
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces[1]
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question