Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Group by String Retrieved in Formula Post Reply Post New Topic
Author Message
cms7602
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Online Status: Offline
Posts: 3
Quote cms7602 Replybullet Topic: Group by String Retrieved in Formula
    Posted: 20 Oct 2011 at 8:42am
Hello all,
 
I'm definitely not a Crystal expert, so any help that can be provided would be greatly appreciated.
 
I need to sort a report based on the string data that I have extracted from a Description (string) field.
 
Example of the type of data stored in this string field {brptGLFinDet;1.DetailDesc}=
Invoice/20/920000/ZENITH TECH INC/ 8373003311/83733- /JB App
 
I am extracting the job# (83733-).
 
The job# will be located in a different place in the field depending on the type of transaction it is.  This is the reason for the IF statement for the Jrnl {brptGLFinDet;1.Jrnl}.  Ie, AP entries show the Job# between the 7th & 8th delimiter ("/"), AR trans show the Job# between the 5th & 6th delimiter.
 
I had success extracting the job# onto the report design using the formula:
 
local numbervar Start := instr({brptGLFinDet;1.DetailDesc},"/");
if
Start > 0 then

if {brptGLFinDet;1.Jrnl} = "AP" then split({brptGLFinDet;1.DetailDesc},"/")[7] else
if {brptGLFinDet;1.Jrnl} in[ "AR", "JB", "BL"] then split({brptGLFinDet;1.DetailDesc},"/")[6] else
if {brptGLFinDet;1.Jrnl} = "ER" then split({brptGLFinDet;1.DetailDesc},"/")[5]
else
 "Undefined job"

However, I can't use this formula as a sort. 
 
I'm not very good with variables, but I'm thinking that the use of variables may be the solution. (??)
 
Thanks in advance for any help!
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 9:42am
try:
if instr({brptGLFinDet;1.DetailDesc},"/")> 0 then
(if {brptGLFinDet;1.Jrnl} = "AP" then split({brptGLFinDet;1.DetailDesc},"/")[7] else
if {brptGLFinDet;1.Jrnl} in[ "AR", "JB", "BL"] then split({brptGLFinDet;1.DetailDesc},"/")[6] else
if {brptGLFinDet;1.Jrnl} = "ER" then split({brptGLFinDet;1.DetailDesc},"/")[5]
else "Undefined job") else  "Undefined job"
IP IP Logged
cms7602
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Online Status: Offline
Posts: 3
Quote cms7602 Replybullet Posted: 20 Oct 2011 at 10:05am
Thank you for the response.
 
I tried the formula below, as suggested, but I still get the message, "A subscript must be between 1 and the size fo the array" when I try to use that formula in a Group.
 
if instr({brptGLFinDet;1.DetailDesc},"/")> 0 then
(if {brptGLFinDet;1.Jrnl} = "AP" then split({brptGLFinDet;1.DetailDesc},"/")[7] else
if {brptGLFinDet;1.Jrnl} in[ "AR", "JB", "BL"] then split({brptGLFinDet;1.DetailDesc},"/")[6] else
if {brptGLFinDet;1.Jrnl} = "ER" then split({brptGLFinDet;1.DetailDesc},"/")[5]
else "Undefined job") else  "Undefined job"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 10:16am

one of your splits is trying to get a value from too large of a number...

(if {brptGLFinDet;1.Jrnl} = "AP" then split({brptGLFinDet;1.DetailDesc},"/")[7] else
if {brptGLFinDet;1.Jrnl} in[ "AR", "JB", "BL"] then split({brptGLFinDet;1.DetailDesc},"/")[6] else
if {brptGLFinDet;1.Jrnl} = "ER" then split({brptGLFinDet;1.DetailDesc},"/")[5]
 
IP IP Logged
cms7602
Newbie
Newbie
Avatar

Joined: 20 Oct 2011
Online Status: Offline
Posts: 3
Quote cms7602 Replybullet Posted: 20 Oct 2011 at 4:39pm
I hope this isn't a dumb question!  Why does it work when I use it in the body of the design then?  I only get that error message when I try to use this formula as my sort/group.
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Oct 2011 at 6:17pm
My guess is that you will get the error if you preview and go to the last page (and don't try to sort). If so, then the formula is choking on a particular row of data in your set.
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.