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

combine data into string

Status
Not open for further replies.

atarrqis

IS-IT--Management
Nov 26, 2004
155
US
I have one or many classifications for each supplier. I just want to read each of the classifications and combine these into one text string.
I thought this is what join({Supplier_Class},",") would do but I get an error: String Array required.

Thanks.
 
The 'Join' function is used to create a string by joining all the substrings in an array. Are you trying to use the Join function directly on a database field?

Without really knowing anything about your report, essentially you will need a formula or formulas to build up a string containing the classifications for each supplier.

If you let me know what grouping you have on your report / any other detail I'll try and supply some detail for how you can do this.

Crystal and database version are also always useful.
 
You can do this using 3 formulas

Code:
//@Reset - Place this in the supplier group header suppressed
WhilePrintingRecords;
Shared Stringvar ClassCode :="";

Code:
//@Accumulate - Place this in the detail section suppressed
WhilePrintingRecords;
Shared Stringvar ClassCode;

If ClassCode = "" Then
   ClassCode := {Supplier_Class}
Else
   ClassCode := ClassCode & ", " & {Supplier_Class};

Code:
//@Display - place this in the supplier group footer section
WhilePrintingRecords;
Shared Stringvar ClassCode;

This should do the trick



Gary Parker
MIS Data Analyst
Manchester, England
 
That is very helpful, GJParker. It works great in my subreport and it appears very nicely in my main report.
However, now what I'd like to do is group in my main report on this field - Display or it's equivalent - Main_display. It does not appear to be possible but hope there is a workaround.

I'm using CR8.5 and Oracle.
 
If you need to group on this field you will need to build the field on the database using a stored procedure or view.

There is no workaround to allow you to group on this field using CR alone.



Gary Parker
MIS Data Analyst
Manchester, England
 
It sounds like you want to group by supplier, and just display the classifications. Not group by class.

If I don't misunderstand your requirements, perhaps you can group by Supplier, and create a subgroup by class. Suppress the class subgroup, and insert a formula like this one.
Code:
//YourFormula
StringVar Classification := Classification + " " +{Supplier_Class}

In the Supplier group footer, place {Supplier} & " " & {@YourFormula}.

If you need the heading before the details section, you can use a similar method as above using a shrunken subreport in a shrunken Supplier group header a, passing the values back in a shared variable to be displayed in Supplier group header b.

Naith
 
Thanks but GJParker is correct - I really wanted to group on the class code. I would create a view for this but cannot get my arms around the sqlplus code needed to do this - is there a forum here for sqlplus questions? Anyone know of others? Thanks.
 
If there aren't too many supplier and class codes, you could hard code this, like:

if {table.supplier code} in [1 to 19, 21,34] then
"Class A" else
if {table.supplier code} in [10,22 to 29, 35] then
"Class B" else
"Class C"

You can then insert a group on this formula.

-LB
 
SQLPLUS is a program used for constructing Oracle's PL/SQL.

I suggest that you try the Oracle forum for whatever version of Oracle you are using.

Not knowing what language you're using, nor posting anything technical such as software and version or the database doesn't bode well for you until you get some experience so I'd go with LBs solution.

I'd get you started but you need to read about software and databases more than trying to code right now.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top