Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula Help Post Reply Post New Topic
Author Message
Phil713
Newbie
Newbie
Avatar

Joined: 21 Aug 2013
Online Status: Offline
Posts: 6
Quote Phil713 Replybullet Topic: Formula Help
     Posted: 22 Aug 2013 at 4:37am
Objective: to report sales order line as a letter
Rules:
1. If Sales Order has only one line then apply no letter
2. If Sales Order has more then one line then report line 1 = A, line 2 = B, line 3 = C etc
 
I have created following formula, I'm sure it's possible, but lack knowledge/experience to acheive both rules 1 & 2. Would appreciate advice
 
if {SO_Items.SO_Line_No} = 1 then "" else
if {SO_Items.SO_Line_No} = 2 then "B" else
if {SO_Items.SO_Line_No} = 3 then "C" else
if {SO_Items.SO_Line_No} = 4 then "D" else
if {SO_Items.SO_Line_No} = 5 then "E" else
if {SO_Items.SO_Line_No} = 6 then "F" else
if {SO_Items.SO_Line_No} = 7 then "G" else
if {SO_Items.SO_Line_No} = 8 then "H" else
if {SO_Items.SO_Line_No} = 9 then "I" else
if {SO_Items.SO_Line_No} = 10 then "J" else
if {SO_Items.SO_Line_No} = 11 then "K" else
if {SO_Items.SO_Line_No} = 12 then "L" else
if {SO_Items.SO_Line_No} = 13 then "M" else
if {SO_Items.SO_Line_No} = 14 then "N" else
if {SO_Items.SO_Line_No} = 15 then "O"
PND
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Aug 2013 at 4:51am
if next({table.SalesOrderNo})={table.SalesOrderNo} OR {table.SO_Line_No} > 1 then
Chrw({table.SO_Line_No} + 64);


Should work. If the sales orders are the same, then there is more than 1 line, or if the line number is > 1 then there is more one line (obviously)...then just print the ascii value of line number...65=A

HTH
IP IP Logged
Phil713
Newbie
Newbie
Avatar

Joined: 21 Aug 2013
Online Status: Offline
Posts: 6
Quote Phil713 Replybullet Posted: 22 Aug 2013 at 10:01am
Did you mean, I should add your formula on to mine?
Have tried just your formula on its own with success
Not sure I fully understand how formula should work
I've replaced table data from our data set
Any idea's were I'm going wrong?

if {SO_Items.SO_Line_No} = 1 then "" else
if {SO_Items.SO_Line_No} = 2 then "B" else
if {SO_Items.SO_Line_No} = 3 then "C" else
if {SO_Items.SO_Line_No} = 4 then "D" else
if {SO_Items.SO_Line_No} = 5 then "E" else
if {SO_Items.SO_Line_No} = 6 then "F" else
if {SO_Items.SO_Line_No} = 7 then "G" else
if {SO_Items.SO_Line_No} = 8 then "H" else
if {SO_Items.SO_Line_No} = 9 then "I" else
if {SO_Items.SO_Line_No} = 10 then "J" else
if {SO_Items.SO_Line_No} = 11 then "K" else
if {SO_Items.SO_Line_No} = 12 then "L" else
if {SO_Items.SO_Line_No} = 13 then "M" else
if {SO_Items.SO_Line_No} = 14 then "N" else
if {SO_Items.SO_Line_No} = 15 then "O"
if next ({SO_Header.SO_No}) = {SO_Header.SO_No} OR {SO_Items.SO_Line_No} > 1 then
Chrw ({SO_Items.SO_Line_No} + 64)
PND
IP IP Logged
Phil713
Newbie
Newbie
Avatar

Joined: 21 Aug 2013
Online Status: Offline
Posts: 6
Quote Phil713 Replybullet Posted: 22 Aug 2013 at 10:02am
Sorry second line should have read " without success"
PND
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Aug 2013 at 10:16am
he means to to replace your formula with his
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Aug 2013 at 10:17am
I was thinking that my snippet would replace yours...just because it's shorter.

so with the table names corrected, my snippet doesn't work?
what is it doing? any error message?

hmm...
IP IP Logged
Phil713
Newbie
Newbie
Avatar

Joined: 21 Aug 2013
Online Status: Offline
Posts: 6
Quote Phil713 Replybullet Posted: 23 Aug 2013 at 9:21am

Created formula using just your 'snippet', saved ok, no errors reported

Inserted formula into report, tried two print previews, 1st for 1 line sales order, 2nd for 2 line sales order, in both instances no data showing in formula field
PND
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Aug 2013 at 10:20am
well, the standard way to debug would be to break my snippet apart into smaller formulas and see what happens.

for example, put just the if statement into a formula like:
next({table.field}) = {table.field} //will return true or false

then maybe build a formula like:
chrw(65) should by 'A'

last {table.lineNumber}...should be a number, perhaps its a string...which won't work, but you could use val()

HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum