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

Formula Help

Status
Not open for further replies.

rb2005

Programmer
Mar 7, 2005
110
US
Can anyone tell me why I am not getting right value if I have sell_activity?


WhilePrintingRecords;
numberVar tempbuy := {a.BUY_ACTIVITY};
numberVar tempsell := {a.SELL_ACTIVITY};
numberVar tempnet = 0;
numberVar templong := {Morning_Adjustments_Element.yest_pcs_basis_actual_oi};
numberVar tempshort := {Morning_Adjustments_Element.SHORT_PCS_BASIS_QTY};
numberVar x := 0;
numberVar y := 0;

// Reduce the buy activity and the short position by the smaller of the two.
if tempbuy >= tempshort
then
x = tempshort
else
x = tempbuy;

tempbuy = tempbuy - x;
tempshort = tempshort - x;

// Reduce sell activity and the long position by the smaller of the two
if tempsell >= templong
then
y = templong
else
y = tempsell;

tempsell = tempsell - y;
templong = templong - y;

//if there are buys AND sells left, take the net and add it to the remaining longs
tempnet = tempbuy - tempsell;
templong = templong + tempnet;
if templong < 0
then
templong = 0;

// return result as the minimum long
templong
 
Please post the solution. This way if someone has a similar problem, they can see your solution.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
I have used Crystal Syntax, and over there assignment operator is ':=' not '='. If you change '=' to ':=' you will get right result, else your variable keep the old value.

Let me know if you have any further issue/query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top