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

Crystal 8.5 - Comparing Shared Values/Variables

Status
Not open for further replies.

goopit

Technical User
May 9, 2003
43
US
Hello,

I have to make a report that will show orders where the order desk has manually entered the unit price.

Pricing for all our sales parts comes from one of two spots: the Agreement or the Price List. There are several values for each sales part in Agreement or Price List pricing. Reports have already been made, based upon sales part, which show all the possible prices for either the Agreement or Price List levels.

I made a report that looks for all open orders and shows each order line and the unit price for the sales part on each order line. I've included the Agreement and Price List reports in it as sub-reports. I'm having trouble, though, getting the main report to compare the sales unit price on the order line against the values returned by both the sub-reports.

Group Header 1 is the name of order desk operator
Group Header 2 is the Order Number
Group Header 3 is Order Line for the above Order Number

The sub-reports are placed in Group Header 3 and the report comes back valid. The sales part for each order line comes back with the unit price, as entered by the order desk, and it has that sales part's associated Agreement and Price List pricing. How do I get the main report to compare the sales unit price, on the order line, to the Agreement and Price List values for that particular sales part?

Thanks,

goopit
 
HI ,

You mentioned that the main reports displays the data from the subreport. Correct?

Then it should just be a matter of creating a formulae to do whatever it is you want to do. Diaplay a message, change the colour of the price etc.

The assumption is that you are using shared variables. Thats what you need to create your formulae in the main report.

In your sub, create a shared varibale.

e.g.
{@ShrVariableAgreementPrice}
whileprintingrecords; //Must be there
shared numbervar ShrVariableAgreementPrice :=0; //Init the variable every time you use it.
shrVariableExchangeRateMethod := {table.fieldname} //Use your Field name here.

Place your sharedvriable in your sub say at the detail section.
Turn off Perform Grouping on Server
Suppress every section

In your main report add a shared variable.
(I name it the same)
{@ShrVariableAgreementPrice}
whileprintingrecords;
shared numbervar ShrVariableAgreementPrice;

With the sub report, I place it in its own section on the main report then I format the section to have Underlay following sections, and size it so its as short as possible.

Then you can compare {@Order Price} to {@ShrVariableAgreementPrice} the normal way.
I think thats about it.


Fred
 
Fred,

I think I'm close to what you've prescribed.

In the Agreement sub-report, I have field named @agmnt sub form. The formula reads as:
//@agmnt sub form
//Stores the value of the
//{AGREEMENT_SALES_PART_DEAL.DEAL_PRICE} field
//in a currency variable called 'agreementprice'

WhilePrintingRecords;
Shared CurrencyVar agreementprice := {AGREEMENT_SALES_PART_DEAL.DEAL_PRICE}

In the Price List sub-report, I have field named @price list form. The formula reads as:
//@price list form
//Stores the value of the
//{SALES_PRICE_LIST_PART.SALES_PRICE} field
//in a currency variable called 'pricelistprice'

WhilePrintingRecords;
Shared CurrencyVar pricelistprice := {SALES_PRICE_LIST_PART.SALES_PRICE}

Now, in the main report I have a formula field called Agrmnt Field. It reads as:

//@AGRMNT FIELD
//Returns the value that was stored
//in the shared currency variable called
//agmnt sub form in the subreport

WhilePrintingRecords;
Shared CurrencyVar agreementprice;
agreementprice

Plus there is another formula field called Price List Field. It reads as:
//@PRICE LIST FIELD
//Returns the value that was stored
//in the shared currency variable called
//price list form in the subreport

WhilePrintingRecords;
Shared CurrencyVar pricelistprice;
pricelistprice

In the Group Header 3 section A of the main report, I have added a formula field called Unit Price Check. It reads as:
IF {CUSTOMER_ORDER_LINE.SALE_UNIT_PRICE}<>{@AGRMNT FIELD}
AND {CUSTOMER_ORDER_LINE.SALE_UNIT_PRICE}<>{@PRICE LIST FIELD}
THEN {CUSTOMER_ORDER_LINE.SALE_UNIT_PRICE}

I've put the sub-reports in Group Header 3 section B and used the Underlay Following Sections. However, the report is still showing orders where the unit price on the order line matches either the Agreement or Price List price. I want it to show me only those orders where the unit price on the order line does not match a value on the sub-reports.

Any idea where I've gone wrong?

Thanks Again,

goopit
 
You'll need to suppress the section using your condition you have just put together.
You cannot do it at the 'Selection Formulae' because of shared variables. Whileprintrecords occurs after the selection logic so you need to use a conditional suppression on the section.
Have a look at the Multi-pass reporting flow chart in the help to understand a little more when various process occurs.

The conditional suppression sounds wierd, but it does work okay.
Recently, i've started to use SQL expressions to achieve the same thing. ts a bit more involved but it can be faster.

Fred
 
I forgot to mention, when you use supression, your subotalling will include any records that were suppressed.
You'll have to code around that if you want subtotals.

Fred
 
First make sure you have placed the shared variables somewhere on each subreport canvas. You also have to place the subreports ABOVE the formula that uses the shared variables for calculations in the main report. The subreports should be GH#3a and {@UnitPricecheck} should be in GH#3b. If you don't want to show the subreport contents at all, within each subreport, suppress all sections and in the main report, resize the subreports to minimize them. Then use "Underlay following sections" on GH#2.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top