INSTR in Crystal - crystal-reports

We are using this function to filter data by program codes entered, if nothing is entered return all?
Can any one please explain this Crystal function, and how Crystal works with it? Mainly the last statement.
Here is some information that might be useful.
{?Program} ==> Parameter to accept different programs codes in the following form
303&410&110
{Command.program_code} ==> Field were program code is stored
if ({?Program} = "")
then true
else
(INSTR("&" & {?Program} &"&", "&"& {Command.program_code} & "&")>0)
Thanks...

Related

Crystal Reports Formula: Help forming IIF Statement

I am working with Crystal Reports 11.5.10.1263 [CR Developer Type: Full].
I am familiar with Programming and SQL syntax in general and have worked with expressions in SSRS & MS Access but never in Crystal Reports.
Problem:
I modified the SQL in the Crystal report and it has had the desired effect - except in the last part of the report output - where the changes I made to the SQL do not have the desired effect.
The 'desired effect' is that when a field named 'FundNumber' has the values '2595', '2597' Then the field named 'Organization' should be assigned the value '41600'.
The Detail Record in the Report has the following three rows as part of its 'Formula':
+ IIf({Data.Payments} > 0, "+01W ", "-01W ")
+ Left({Data.FundNumber}+ SPACE(6),6)
+ Left({Data.Organization}+ SPACE(6),6)
I want to change the Data.Organization row to an IIF Statement that says [pseucode]:
IIf Data.FundNumber IN ["2595", "2597"] Then "41600" Else Data.Organization
I believe the Left() function is saying 'return the left 6 characters of [Data.Organization + 6 Spaces] ?? and that it has to do with the way the data is presented in the output.
I would appreciate help with creating the IIF statement for this.
I included the 'IIf({Data.Payments} ...' row in case that helps - as my google searches have turned up examples that use IF instead of IIF.
Thanks!
The syntax most of the time is the same as VB. Try
IIF({Data.FundNumber} = "2595" or {Data.FundNumber} = "2597", "41600", {Data.Organization})

my report run but does not display anything in oracle

I have designed report in 10g. When I call report through forms 10g than report executed but do not display anything. Kindly help me what I have to do to resolve this issue. I use .rep report and desformat is PDF. One thing more when in this desformat my report started downloading instead of giving a preview in internet explorer and downloaded pdf is empty (contain nothing).
Report displays the result of a query. So the most obvious question is: does the query, when you run it outside of the Forms/Reports application, work correctly and returns the result?
If it accepts certain parameters, verify that they are correctly passed. Mind the datatype, especially if DATE is involved as people usually have problems with different format masks, NLS settings and stuff.
Also, check whether those parameters are obligatory or not. If not, report's query should contain something like
where (some_value = :parameter_value or :parameter_value is null)
Furthermore, make sure that all those parameters are passed to the report. You can display their values in the report, just to see what's going on. Open Reports Paper Layout Editor, go to the margin and - using the ampersand notation - display those values, such as
Parameter one = &parameter_one
Parameter two = &parameter_two

Crystal Report XI If statement not working: not getting to else

I have a problem with an If statement in Crystal Reports XI.
This is my code:
IF {ANAGRAFICACF.CODLINGUA} = {DESCRARTICOLI.LINGUA}
THEN
{DESCRARTICOLI.DESCRIZIONEAGG}
ELSE
{RIGHEDOCUMENTI.DESCRIZIONEART};
The problem is that Crystal Reports retrieves only lines with the condition verified and completely ignores the else condition. So if in my documents there are 10 lines, it show me the only 2 that have the condition verified.
Can you explain why? I think this is OK. It's only a simple if statement.
There more details as you request:
I tryed also this code
IF NOT ISNULL({DESCRARTICOLI.DESCRIZIONEAGG}) AND {TESTEDOCUMENTI.CODLINGUA} <>0
THEN
{DESCRARTICOLI.DESCRIZIONEAGG}
ELSE
{RIGHEDOCUMENTI.DESCRIZIONEART}
For this last code I have this structure:
TESTEDOCUMENTI.CODLINGUA is numeric like in all other tables. So for English I've "1" for default I've "0"
DESCRARTICOLI.DESCRIZIONEAGG is the translation, so in DESCRARTICOLI
I've for example CODART CODLINGUA DESCRARTICOLI (Article code, Language Code, Article Translated Description)
RIGHEDOCUMENTI.DESCRIZIONEART is the standard italian description that I see in my ERP. So I've different columns including IDRIGA CODART DESCRIZIONEART (Line ID, Article Code, Italian Language Description)
Then I've TESTEDOCUMENTI table that contain the language CODLINGUA between columns. This table has the general setting of a single document.
So in my Cristal Report table setup I've linked the 3 tables RIGHEDOCUMENTI TESTEDOCUMENTI and DESCRARTICOLI and in particular TESTEDOCUMENTI.CODLINGUA with DESCRARTICOLI.CODLINGUA and RIGHEDOCUMENTI.CODART with DESCRARTICOLI.CODART.
When the translation is not stored in the article in the erp the DESCRARTICOLI.DESCRIZIONEAGG for this Article code doesn't exist. For example. If my CODART is "abg" in RIGHEDOCUMENTI I've CODART "abg" DESCRIZIONEART "ciao". Then in DESCRARTICOLI I've CODART "abg" CODLINGUA "1" DESCRIZIONEAGG "hI". If the translation is not stored the line in DESCRARTICOLI doesn't exist.
So my need is to verify if TESTEDOCUMENTI.CODLINGUA is different from "0" default language, but this is not enough because, most of my article hasn't the translation stored. So I need to show, the italian one, or a simple message telling me "no translation stored". I've tryed also to put this message instead of RIGHEDOCUMENTI.DESCRIZIONEART but it doesn't appear.
Another strange thing is that, in my document, on the same line I've also, in separate field in the report, the CODEART, MEASURES, PRICE. If I put directly RIGHEDOCUMENTI.DESCRIZIONEART without if statement, I see all those fields. Insted in I put the if statement I don't see neither thouse other fields..
It seems like that the first think it go to read the Translation Table DESCRARTICOLI, it doesn't come back to read the original one, so end the cicle through lines, without reading all parameters stored in the RIGHEDOCUMENTI tables, containing all data that don't appear in the report.
I hope to have been more clear now.
Thank you!

Crystal Reports - Command Line CRExport.exe Odd Formula Error

I built a report in crystal reports (version 11.5.12.1838 - yes it's old, but I have no ability to upgrade it, it comes with the software we use for cash reporting).
I have this formula:
if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
{rpcRGHL5DayBalanceView;1.1}
else
999999999999.99
The report runs and exports fine within crystal as well as the application we use. However, when using CrExport.exe (free command line tool) the report fails to generate and provides this error.
Error : A string is required here. Details: errorKind Error in File RGHL-5DayBalanceView {25B5C1DE-4C71-4A2D-816E-165F95A6B03B}.rpt:
Error in formula Balance1:
'if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then ' A string is required here. Details: errorKind
This seems to happen when the parameter I pass in via the command line differs from the stored value on the report. If I pass in the same value, the report generates, but the data is not updated. The data that was saved on the report is what I get.
I use this CrExport.exe with several other reports with no problem. Not sure if it's a bug in the command line tool or not.
Also, if I change the values from numeric to text via this code.
if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
ToText({rpcRGHL5DayBalanceView;1.1},0)
else
ToText(999999999999.99)
Then I get this error from the command line program.
Error : Too many arguments have been given to this function. Details: errorKind
Error in File RGHL-5DayBalanceView {98633D00-5B70-4B7D-839C-1D0CEB359AE9}.rpt:
Error in formula Balance1: 'if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date})) then
'Too many arguments have been given to this function.
Details: errorKind
Any help is much appreciated. Let me know if more information is needed and I will do what I can to provide it.
try like this:
if (DateTime(CStr({#Date1})) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
ToText(CStr({rpcRGHL5DayBalanceView;1.1}),0)
else
ToText(999999999999.99)

Crystal reports 11 : blank field bombs the report

I'm creating a invoice crystal report for sage mas 500 AR module. In it, I'm attempting to add the tarinvoice.balance field with the following formula:
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
I'm assuming that when the {tarPrintInvcHdrWrk.Posted} = 1 conditional statement holds FALSE, it doesn't attempt to pull the invoice field because when I remove the formula from the report, the form displays correctly without it.
When the conditional statement renders true in the report, the balance fields behaves correctly. However, with the formula renders FALSE in the CR form, the entire crystal report bombs and displays blank. Any ideas why or what I'm doing wrong?
Just tried setting everything to zero and the report still bombs. I'm starting to think its more of a query error in the report. I wish there was a way to exclude the field in the query when posted = 0.
With tarinvoice.balance removed when the posted = 0, the report works fine.
With tarinvoice.balance included and posted = 1, report works fine.
With tarinvoice.balance included and posted =0, report bombs.
I believe the conditional statement fails immediately if you encounter a NULL, so your formula needs to test IsNull({tarPrintInvcHdrWrk.Posted}) before it tests equality with "1".
You can change the way Crystal handles a null value for a value in a formula. At the top of the Formula Workshop there is a drop down box that usually says "Exceptions For Nulls".
Change this to the other option "Default Values For Nulls" and your formula should no longer bomb out. You used to be able to specify the what the default values applied were, but more recent versions of Crystal have these hard coded.
Search the help for "Null Treatment" for a table showing them.
I modified the formula to this:
if isnull({tarPrintInvcHdrWrk.Posted}) = FALSE then
if {tarPrintInvcHdrWrk.Posted} = 1 then
if isnull({tarInvoice.Balance}) = FALSE then
ToText({tarInvoice.Balance})
else
"0.00"
else
"0.0"
else
"0"
The crystal report still bombs.. Nevertheless, it does show "0" in the appropriate space.
I saw a suggestion on Exp.Exch to try putting the field into a variable before converting it to text.
e.g.
NumberVar InvoiceBalance;
If isnull({tarInvoice.Balance}) then
InvoiceBalance := 0
Else
InvoiceBalance := {tarInvoice.Balance};
If {tarPrintInvcHdrWrk.Posted} = 1 then
ToText(InvoiceBalance);
I also tried to recreate your problem, since I have see similar things before.
No luck though trying with CR 8.5 & XI R2. Perhpas it has to do with linked tables as well, since I only tried on a simple single table.
I have also seen similar behaviour when using a formula within a Running Total - they do not like nulls at all!
If you put {tarInvoice.Balance} directly on report (into details "debug" section - often needed, don't forget supress it in production :)), what values it displays or does report become empty?
Maybe you have Suppress If Blank section on your report. Try to put: Else " "
if isnull({tarPrintInvcHdrWrk.Posted}) or {tarPrintInvcHdrWrk.Posted}=0 then
" "
else
if {tarPrintInvcHdrWrk.Posted} = 1 then
ToText({tarInvoice.Balance})
else
" "
I have trouble with this kind of field when making reports to export to excel. A field with no data in will pull all columns to the right of it over to "fill the gap".