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

suppressing sections

Status
Not open for further replies.

unknownly

Programmer
Jul 7, 2003
181
US
Hi All,

Iam trying to do a report where I have 6 section units like sec1,sec2,sec3,sec4,sec5,sec6( different fields related by level). This unit will be prompt
but my user can enter any section unit(will be a dynamic).
I have grouped my report by each section unit and suppressing base on the prompt value entered. Question is I have really made it tough when my user is asking for the number of levels( which they can enter as a prompt and the report will show the sections by that num)for eg:

prompt1: sec2 (section unit)
prompt2: 3 ( number of levels)

Then my report should display as

Sec2, sec2 description
sec3, sec3 description
Sec4 num sec4 description code count(code)-- HDings
aaa aaaname n/a 36
aaa aaaname 100 125
aaa aaaname 150 103
bbb bbbname 150 95
.... so on.

I have messed my head thinking. Can anyone please advice on how to proceed.
I was doing good with prompt1 and I have fixed the number of levels to 3 always. But how can I make it work dynamic.

Any ideas greatly appericated..

Thanks,

Sweetie


 
I'd probably use a boolean variable for each section as to whether it's to be displayed, and use a single generic formula to set all of the variables, that way the logic is in one general area.

Since Crystal doesn't allow for dynamic variable creation, this will get large, the amount of If's and/or Swtich might be significant, but it shouldn't be too complicated.

-k
 
Can you please explain it to me or show an ex: in detail
My head is so mess now Iam unable to think. I appreciate and thank you for your time.

This is what I tried:

@inplevelunit:
--------------
Switch(sec1,1,sec2,2,sec3,3....sec6,6) and using this Formula in section format and suppressing and then I tried to implement for prompt2 by creating a formula
@numoflevel:
------------
tonumber{?prompt2}

@displaysection:
----------------

@inplevelunit + @numoflevel

and then using the @displaysection to suppress but it's all mess( because it will be a combination of 6x5 ways).

Thanks,
Sweetie

 
your use of the word "section" is a bit confusing since this word has a special meaning in Crystal that I don't think is the same as what you mean.

**************
prompt1: sec2 (section unit)
prompt2: 3 ( number of levels)

Then my report should display as

Sec2, sec2 description
sec3, sec3 description
Sec4 num sec4 description code count(code)-- HDings
aaa aaaname n/a 36
aaa aaaname 100 125
aaa aaaname 150 103
bbb bbbname 150 95
.... so on.

*******************

Soooo, I take it that "sec" is really a grouping...not a section per se...and there are a total of six of these groups.

The Prompt is really a parameter...ie. a user input

So {?Parm1} is the first group to be printed
{?Parm2} is how many groups are to be printed (in a row)

OK...this is pretty easy but requires a couple of questions.

1. The report only shows the groups defined by the above parameters...BUT is the report still grouped by the previous groups???

This is important...I will ASSUME that the earlier groupings are NOT part of the report. That is not only are they suppressed but they no longer are used.

2. What happens if the user enters bad data? For example say they enter 5 for {?Parm1} one and 4 for {?Parm2} since there are only 2 groups available (Group 5 and 6) how is this case to be handled???

OK...to solve the problem

Create the 6 Groupings based on formulas

//@Group1

//it is important that {Table.Sec1} be a string parameter
//if it is a number convert it to a string below using totext
if {?Parm1} = "1" then //I am assuming a string parameter
// possible values from 1 - 6
{Table.Sec1}
else
"Sec1 not used";

now it becomes a bit more complicated

//@Group2

if {?Parm1} = "2" or
({?Parm1} = "1" and {?Parm2} >= "2") then
{Table.Sec2}
else
"Sec2 not used";


//@Group3

if {?Parm1} = "3" or
({?Parm1} = "1" and {?Parm2} >= "3") or
({?Parm1} = "2" and {?Parm2} >= "2") or then
{Table.Sec3}
else
"Sec3 not used";

//@Group4

if {?Parm1} = "4" or
({?Parm1} = "1" and {?Parm2} >= "4") or
({?Parm1} = "2" and {?Parm2} >= "3") or
({?Parm1} = "3" and {?Parm2} >= "2") or then
{Table.Sec4}
else
"Sec4 not used";

//@Group5

if {?Parm1} = "5" or
({?Parm1} = "1" and {?Parm2} >= "5") or
({?Parm1} = "2" and {?Parm2} >= "4") or
({?Parm1} = "3" and {?Parm2} >= "3") or
({?Parm1} = "4" and {?Parm2} >= "2") or then
{Table.Sec5}
else
"Sec5 not used";

//@Group6

if {?Parm1} = "6" or
({?Parm1} = "1" and {?Parm2} >= "6") or
({?Parm1} = "2" and {?Parm2} >= "5") or
({?Parm1} = "3" and {?Parm2} >= "4") or
({?Parm1} = "4" and {?Parm2} >= "3") or
({?Parm1} = "5" and {?Parm2} >= "2") or then
{Table.Sec6}
else
"Sec6 not used";

Perhaps this
{?Parm2} >= "6" should be Tonumber({?Parm2}) >= "6"

This would make it a little more bullet ptoof to bad input. Using Text parameters eliminates annoying decimals.

So you see what I have done. If these formulas are out of the parameters ranges they are constant and thus are not a part of the grouping of the report....if this is what you want

To suppress the unwanted groupings use the same formulas in the conditional suppress in the respective group headers AND Footers but instead of making them values make the results boolean


For example for Group 1 header and footer conditional suppress

if {?Parm1} = "1" then
True
else
False;

For example for Group 2 header and footer conditional suppress

if {?Parm1} = "2" or
({?Parm1} = "1" and {?Parm2} >= "2") then
True
else
False;

That should do what you want....




Jim Broadbent
 
First I like to Thank you very much.. Jim.

Your are right that Sec1, sec2..sec6 is not the same Sections in CR.

I kind of getting to understand the way ur thinking.

ok may be I kind of misled u.

This is what I have to do:

{?Param1} is userinput and will be a string( ex: a user can enter any value like sec1, sec2...sec6 as a value for the field1, field2...field6. So I checking witha OR clause in SQL for
field1 = {?param1} or
field2 = {?param1} or
....field6 = {?param1}
{?Param2} value is stored as a string too so, I write a formula to convert it to number and {?Param2} is userinput to which is enterd as 1,2..( number of level ) to show the details in the report.

So, I have grouped all these field1...field6 I show the GH and placing the Details in GF. But thenI have Codes as details for all the groups and what happens is when I place the details in GF it give only the last code for that group.
So, I created this Formula:

@Inplevelunit:
--------------
Switch({?param1} = field1,1,
({?param1} = field2,2,..
({?param1} = field6,6)

Then Iam using this formaula and changed the grouping and each grouping has 2 section( a, b)
a has group name and b has the heading for the shown deatils

@group3:
--------
If @Inplevelunit = 1 then
Field3 + code
else
field3

and also using the @Inplevelunit in section conditional suppress to show the Sections in CR based on the value enter for {?param1}.

{?param1} value is not static for a field
{?param2} values tell to get down to number of levels of details to display.

Ex: user enters values for Param's
Param1 : sec2
Param2 : 2

Sec2, sec2 description( this will be level 1)
Sec3 num sec3 description code count(code)--HDings 2lvl
aaa aaaname n/a 36
aaa aaaname 100 125
aaa aaaname 150 103
bbb bbbname 150 95

---------------------------------------------------
2 ex:
Param1 : sec3
Param2 : 4
Sec3, sec3 description
sec4, sec4 description
Sec5 num sec5 description
Sec6num sec6 description code count(code)-- HDings
aaa aaaname n/a 36
aaa aaaname 100 125
aaa aaaname 150 103
bbb bbbname 150 95


I hope this helps u understand better than before.


Once again, I thank you.

Sweetie







 
your last example "sort of " made it clear.

Please take in Crystal technical terms though...

IE. Groupings, sections within groups/detail/footer

it makes it much clearer.

**************
a user can enter any value like sec1, sec2...sec6 as a value for the field1, field2...field6
**************

This statement is very confusing...I have the impression that sec1, sec2, sec3 are group levels...now groups can be based on a field value

I have accounted for this in my earlier post.

You cannot have GROUPS in Crystal that appear and disappear

The grouping structure must be cast in concrete for the report. However, having said that, I have show you how you can make groups esentially inactive by making them equal to a constant. You cannot group on a constant but when the the grouping field is a formula whose result could be a constant or field then Crystal is tricked into allowing this.

You are showing me that you have a variable number of groupings...Sec1 to Sec6 so far from your posts. Assuming that this is all the potential groupings then you will have create groups for all of them...whether or not they are used.

So your grouping and structure of your report must be

Group 1 - Sec1 (or a constant to deactivate this group)
Group 2 - Sec2 (or a constant to deactivate this group)
Group 3 - Sec3 (or a constant to deactivate this group)
Group 4 - Sec4 (or a constant to deactivate this group)
Group 5 - Sec5 (or a constant to deactivate this group)
Group 6 - Sec6 (or a constant to deactivate this group)
Details
Footer 6
Footer 5
Footer 4
Footer 3
Footer 2
Footer 1

The actual Groups involved are based on the formulas such as I derived earlier...it is then only a matter of suppressing the Groups/footers that have been rendered to constants.










Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top