Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Combining Numbers Post Reply Post New Topic
Author Message
Lord Yorkshire
Newbie
Newbie
Avatar

Joined: 04 Jul 2010
Online Status: Offline
Posts: 28
Quote Lord Yorkshire Replybullet Topic: Combining Numbers
     Posted: 16 May 2014 at 2:17am
I am trying to write a report when we combine several job numbers. We raise a Purchase order for materials that cover several job number.

I need to strip out the obsolete number ( is there a specifc name for this process ? )


Jobs 64201 & 64209 then this would be 64201/9
jobs 64201 & 64216 then this would be 64201/16
Jobs 64201 & 64312 then this would be 64201/312

Has anyone tackled this issue before and has a solution they could share.


IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 16 May 2014 at 4:57am

so the raw data is a string like "64201 & 64209" and you want to display it as "64201/9" ?

Is it always in the same format (xxxxx & xxxxx) ?
can there be more than 2 in the original data field (xxxxx & xxxxx & xxxxx...)?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 May 2014 at 5:11am
local numbervar same;
local numbervar i;
for i:=1 to len({table.field1}) do(
if left({table.field1}, i) = left(table.field2, i) then
    same := i;
)

{table.field1} + "\" + mid({table.field2}, same +1)

this is assuming that the lengths are the same...otherwise, while the value will be correct, it will probably not accurately reflect the relationship between the values.

this logic can probably be expanded for more variables, but would have to be adjusted. There might be a more elegant way to do the same for n comparisons...

Either way, this would probably work (I always forget the syntax for the loops in CR as I almost never use them) (ie check Help)

HTH
IP IP Logged
Lord Yorkshire
Newbie
Newbie
Avatar

Joined: 04 Jul 2010
Online Status: Offline
Posts: 28
Quote Lord Yorkshire Replybullet Posted: 18 May 2014 at 2:52am
Yes, it is current in seperate strings and i want to combine it.

The format is always the same.

There can be more than 2, it could be up to a maximum of 5 seperate number

Lets say

64101
64106
64116
64187
64213

Answer needs to be 64101/6/16/87/213
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 19 May 2014 at 5:25am
my code should work, it would have to be a group footer...
I would probably modify it to something like this:
in the group header the reset:
shared stringvar orig:={table.field};
shared stringvar result := orig;
""//hide the result

in the detail section:
shared stringvar orig;
shared stringvar result;
shared stringvar cur := {table.field};
local numbervar i;
local numbervar same;
for i:=1 to len({table.field1}) do(
if left(orig, i) = left(cur, i) then
    same := i;
);

result:= result + "\" + mid(cur, same +1);
""

finally in the group footer
shared stringvar result


these are all formulas by the way

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