Solved

Parsing multi-valued fields in Crystal Reports

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

Accepted Solution

by:
mlmcc earned 250 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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