| Author |
Message |
GrisCorp
Groupie
Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
|

Topic: Need to pull specific data from a string Posted: 15 Mar 2013 at 10:36am |
|
I am new to Crystal Reports. I am using Crystal Reports XI R2.
I am editing an existing report and need to add an alert if certain conditions are met.
The
report is a work order and some customers have given us specific
instructions regarding a particular part they order from us. If the
customer orders that part, I want an alert to print on the work order so
the shop sees it.
The issue I am running into is that the
database was designed oddly. If a customer has given us specific
instructions and we have logged those instructions, then the Part Number
and the Customer ID are both in ONE field.
The field is the 15-character alphanumeric Part Number, 15 spaces, the
7-character alphanumeric Customer ID, and finally 13 spaces.
I first tried adding a formula to the report and ended up with
4562 pages, instead of 2. I discovered I need to put the formula in a
sub-report. I did that and added subreport links. I still end up with
4562 pages and still do not have the alert printed out.
I need a formula in the sub-report that will look at this one field and see if both the Part Number and Customer ID are in it. And if both are in the field to add the alert to the main report.
Here is what I have that is not currently working: if {Standard_Notes.NOTTYP_46}="SV" and {Standard_Notes.TYPDAT_46} startswith {Part_Master_Ext.PRTNUM_01} and {Standard_Notes.TYPDAT_46} like {Customer_Master.CUSTID_23} then "*SEE CUSTOMER PART INSTRUCTIONS"
Any help I can get will be greatly appreciated.
|
IP Logged |
|
|
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 17 Mar 2013 at 8:35pm |
Hi
You can use the below formula to get the values :
if {Standard_Notes.NOTTYP_46}="SV" and
{Part_Master_Ext.PRTNUM_01} =left( trim({Standard_Notes.TYPDAT_46}),15)
and
{Customer_Master.CUSTID_23} = Right(Trim({Standard_Notes.TYPDAT_46} ),7)
then "*SEE CUSTOMER PART INSTRUCTIONS"
or you can check with length of the string and print your instructions..
like..
if trim({Standard_Notes.TYPDAT_46}) > 15 Then "*SEE CUSTOMER PART INSTRUCTIONS"
|
|
Thanks,
Sastry
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Mar 2013 at 4:36am |
Sastry is giving you a nice option for your formula but , just a guess, I think you are having a join issue more than a formula isue and your are trying to use the formula as a way to handle a join. The fact that you jump from 2 to 4500 pages is a good indicater that your join (I am guessing a cross join) was enforced when you added the formula. Consider using a formula in the main report as a concatenated string to link the main report to the sub report.
|
IP Logged |
|
GrisCorp
Groupie
Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
|

Posted: 19 Mar 2013 at 3:45am |
|
@Sastry, Thank you for the formulas. Unfortunately, it is still not
doing what I want it to do. It no longer generates 4500 pages, but
neither does it insert the alert text.
|
IP Logged |
|
GrisCorp
Groupie
Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
|

Posted: 19 Mar 2013 at 4:21am |
|
@DBlank, Thanks for the Join tip. While I am uncertain what a Join
is (I was more or less tossed into editing this report having never used
Crystal Reports before) I do have a Complete Reference I have been
using and will read up on Joins.
The report was pulling
information from an old database we are trying to eliminate. The
database is on an old Win2K server. The data has been replicated in our
new db, but when the new db was setup no one thought to create the
field names exactly as they were in the old db until it was too late to
change the field names. I have added the new db tables to the report
and created the proper links. I have also edited the existing
formulas. But everything I have accomplished on this report has been
through trial and error; seeing how the data was pulled from the old db
and changing/creating formulas to extract the data from the new db.
Unfortunately,
the existing formula for the alert cannot be changed to work because of
the way the customer instructions are stored. In the old db, the
instructions were stored in one field and the Part Number and Client ID
were each stored in their own field. In the new db each line of the
instructions is stored in its own field and the Part Number and Client
ID are combined into one field, replicated for each line of
instructions. So, if the customer instructions are 5 lines worth of
text, I have a table that looks like this:
NOTTYP_46 TYPDAT_46 NOTNUM_46 NOTE_46 SV WIDG571(15)ABCDE01(13) 0001 Each widget SV WIDG571(15)ABCDE01(13) 0002 must be placed SV WIDG571(15)ABCDE01(13) 0003 on its own skid SV WIDG571(15)ABCDE01(13) 0004 and shrink SV WIDG571(15)ABCDE01(13) 0005 wrapped.
For the sake of space above, I changed: the fifteen spaces following the part number to (15) the thirteen spaces following the client ID to (13)
Obviously, each line of instruction is much longer, but this demonstrates how the instructions are stored.
I
also need to extract the instructions themselves, but figured once I
got the formula to insert the alert, I would be able to use some of the
same formula/logic to print the instructions on the report.
I
know it's difficult to write a formula not knowing all the specifics of
the report and databases and how they're linked, but I figured it
wouldn't hurt to ask someone more knowledgeable than myself.
*Edited to correct the note numbers under NOTNUM_46.
Edited by GrisCorp - 19 Mar 2013 at 4:29am
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 19 Mar 2013 at 4:30am |
a join is a link.
however in Crystal making the a link does not enforce the join. You have to either force the join in the link set up or when you use any field from both tables (on either side of the link/join) it becomes enforced.
As you state there is no way to properly link between the new tables and the old. Hence my though that this is a cross join (no link).
What table is the special instructions from?
If you drag a field from that table onto your report what happens? Does it jump from 1 or 2 pages to 4500 pages? That is the report enforcing the cross join.
If this is happenening, get rid of that table from the main report.
in the main report make a formula field that creates the string that is in the special instructions table. I need to know the field types of the parts that make that up to write it.
once you have it you can use the result to link the main report to the sub report and return only the one data line you wanted. Edited by DBlank - 19 Mar 2013 at 4:32am
|
IP Logged |
|
GrisCorp
Groupie
Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
|

Posted: 19 Mar 2013 at 8:14am |
|
I have completely removed the old database table from the report. I
have also removed all formulas referencing the old db. The report needs
to pull all data from the new db tables only.
The instructions
are in the Standard_Notes table. I dragged a field from the table to a
Details section of the Main report. When I view it in my Report Viewer,
it resulted in over 4800 pages. I deleted the field then dragged it into
the page header. Same issue.
I have removed the Standard_Notes table from the
Database Expert selected tables. I am unsure of what you mean by making
a formula, in the main report, that creates the string in the special
instructions table. Without the table selected in Database Expert, I
cannot create any formulas referencing it.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 19 Mar 2013 at 9:34am |
it does not matter how or where you use field, it will force the join to happen when it is used at all. Not sure how I can explain it differently...
If i understand your set up, in them main report you have 2 distinct fields that are mashed together to make the unique string for your other tables 'special instructions' identifier, correct?
NOTTYP_46 TYPDAT_46 NOTNUM_46 NOTE_46 SV WIDG571(15)ABCDE01(13) 0001 Each widget
in the main report you have the part number and the client id which combine to make your string create a formula something like this:
left((table.partnumber + ' '),15) + left((table.clientid + ' '),13) now you have the match to your special instructions
insert the sub report into a header (group or report depending on your design) and use the link option
from teh main reprot select the fomrual field you just created, in the sub report select the typedat46. This is basically like a join.
|
IP Logged |
|
GrisCorp
Groupie
Joined: 08 Mar 2013
Online Status: Offline
Posts: 64
|

Posted: 25 Mar 2013 at 5:54am |
|
@DBlank,
Thanks so much for your assistance. I still was unable to get my report to work the way we wanted, so my supervisor authorized our contact at Exact Software to take a look at the report since it is going to be used in our Exact MAX program. He got the subreport to work perfectly. It was an issue with my subreport links. He found the data to which I needed to link in the subreport was in a different table altogether than the one I was trying to use.
Edited by GrisCorp - 25 Mar 2013 at 5:55am
|
IP Logged |
|
Nicker
Newbie
Joined: 23 Jan 2013
Online Status: Offline
Posts: 1
|

Posted: 22 Apr 2013 at 6:03pm |
This Crystal Reports font encoder UFL is capable of format data to a text string.
|
IP Logged |
|
|
|