Group name field display data horizontally.


I have a group name field (GenericMiscPrompt.GroupPrompt) in Crystal 9 that generates characteristics for trucks and displays as

Drivetrain     FT Axle     10,000
                   RR Axle     19,800
                   Brakes       Hyd

Is there a way to have this field display the data horizontally?
Such as:
Drivetrain     FT Axle     10,000     RR Axle     19,8000     Brakes     Hyd

I believe in access this was done with cross tabbing.
Any help would be greatly appreciated. Thanks.

Who is Participating?
1. But what if you want to do something like return the most recently updated Characteristic for the Batch from a list of possible Characteristic IDs. This feature is crucial since sometimes the information is recorded using different ID depending on the situation. The report needs to find the info no matter which ID is use and determine which result to show if more than one is found. (You could modify code below to concatenate all results found into a single varchar variable to return from Oracle to Crystal).
The TableofNumbers solves issue of being able to pass only 1 number as a parameter to function. The fnBatchChar() function adds more complex logic than the SQL Expression from the Crystal example i just posted.

2. And you want to reuse the code, since this is task is required frequently.

This solution and methodology came about as result of over 2 week of trying to come up with a reusable solution taking into account Crystal Reports limitations. I talked to a number of expert Oracle Developers but they were not use to thinking around the constraints generated by Crystal. I tried methods of using outerjoins and the (+)= oracle operator. But this required hardcoded views and i think it had problems if looking for more than 1 Char ID. I took some of the things i learned from them to develop this unique design.

I hope this works for you and that some other people might benefit from this. I should probably type up a simple explanation of the problem and design.

SQL Expression
Note: when you add a Crystal Report field to a SQL Expression it puts "" around the table and field like this "table"."field".

fnBatchChar("BATCH"."BATCHID", 44001)

This is more robust version of %Size from my last post.

fnBatchChar("BATCH"."BATCHID", '44008, 44354')

This is more robust version of %Volume from my last post.

Oracle Code
--Declare type TableofNumbers
create or replace type TableofNumbers as table of number;

--Convert a list of numbers receieved as a varchar array
--to a table of numbers. This is used by fnBatchChar below
--since you can't check for string of numbers using the IN clause
--without going through TableofNumbers function.
--Example: str2tbl('1,2,3')
--          Return
--               1
--               2
--               3
create or replace function str2tbl( p_str in varchar2 )
         return TableofNumbers
      l_str   long default p_str || ',';
      l_n        number;
      l_data    TableofNumbers := TableofNumbers();
                  l_n := instr( l_str, ',' );
                  exit when (nvl(l_n,0) = 0);
                  l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
                  l_str := substr( l_str, l_n+1 );
            end loop;
            return l_data;

--Find the Result of the most recently updated Batch Characteristic
--for a Batch from a list of Characteristic ID (number) to look for.
--Input list of Characteristic IDs as a string of numbers.
--Example: fnBatchChar(56845, 11) or fnBatchChar(56845, '11, 14, 54')
--The String of CharId is used because related information may go by
--different CharID depending on the type of Batch. This method will still
--allow for creating a single column for all batches included in the
--primary query.

CREATE OR REPLACE function fnBatchChar
      (fBatchID in number, fBatchCharIDs in varchar)
return varchar2
vCharValue varchar2 (60);

      --Use Max() to return the most recently updated Characteristic from the list
      --of Characteristics types that are being searched for.
      select max(characteristicvalue)
      into vCharValue
      from (select characteristicvalue from BatchcharacteristicDetail
            where batchid = fbatchid and batchcharacteristicid in
                  ( select * from THE ( select cast(str2tbl(fBatchCharIDs) as TableofNumbers )
                              from dual )  )
            order by changeddate desc
      where rownum <= 1;

      return vCharValue;
create public  SYNONYM fnBatchChar FOR fnBatchChar;
GRANT execute ON fnBatchChar  TO HPREAD, HPAPP;
Are the details separate records?

You may be able to do this with a multiple column report.
Open the report
Select the Detail section
Click the LAYOUT tab
Setup the columns.
Ensure you select ACROSS then DOWN

Crystal does have cross tab reports and a wizard.  You might also try that.

lburg55Author Commented:
Yes, the details are separate records.
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Are you wanting to report all Characteristics that are found for that Drivetrain, or specific ones that you know the characteristic type/id for (ftaxel, rtaxel, emptyweight, gross weight)?

If you want specific characteristics as columns, I've had best luck for performance and reusability by using SQL Expression. I created a oracle function that i pass the ID for the Truck and the Characteristic that i want to lookup, and i get back a single answer that can be dropped anywhere on the report, just like you are trying to do. You can do the same thing without the oracle function, by typing the sql in the SQL Expression.

If this will help you, i'll post the code samples .


lburg55Author Commented:
Yes, please post a sample of the code. That would be a great help.

I'm going to make 2 post. The first is a simple way doing the entire thing in Crystal Report. The second way is leveraging the power and reusability of oracle functions.

I have a Batch table which is a many table of Batches created by the business.


I have a Batch Characteristic setup table that defines 1000+ characteristics that can be used to record additional information about Batches


I have Batch Characteristic Detail which is records that actual Batch Characteristic results for a Batch



In Crystal Reports create 2 SQL Expression. One for each column that i want.

Select max(characteristicvalue)
from batchcharacteristicdetail
where batchid = "BATCH"."BATCHID" and
Batchcharacteristicid= 44001

The Max() is required because you will get error if more than 1 row is returned.

Select max(characteristicvalue)
from batchcharacteristicdetail
where batchid = "BATCH"."BATCHID" and
Batchcharacteristicid in (44004, 44354)

This one for Volume allows you to look up 1 or more Characteristic ID.
lburg55Author Commented:
Thanks! This has been a big help.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.