Solved

Parsing multi-valued fields in Crystal Reports

Posted on 2008-10-14
5
570 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 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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 100

Accepted Solution

by:
mlmcc earned 250 total points
Comment Utility
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
Comment Utility
Thanks a lot.
0
 

Author Comment

by:cccpdavis
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now