cancel
Showing results for 
Search instead for 
Did you mean: 

transform java into CR code

Former Member
0 Kudos

Hi everybody,

has anybody an idea, how to realize this: "+new SimpleDateFormat("MMMM yyyy").format($P{MONTH_YEAR} -28)

in CR?

based on this java I think: new java.util.Date()

rgds

Eberhard

Accepted Solutions (1)

Accepted Solutions (1)

former_member205840
Active Contributor
0 Kudos

Hi Eberhard,

Below is the explanation for the code :

"+new SimpleDateFormat("MMMM yyyy").format($P{MONTH_YEAR} -28)

It is try to display the date in 'MMMM yyyy' format after manipulating MONTH_YEAR by reducing 28 days.

so, formula would be :

Totext((Month_Year)-28,"MMMM yyyy")

Thanks,

Sastry

Former Member
0 Kudos

Hi Sastry,

we are on the right way, but I get an error:     "one ) is missing".

rgds

Eberhard

Former Member
0 Kudos

Hi everybody,

this formula is working, but I am not certain, if it is correct?

If isNull({sub_bd_konkurierend.PAGER_NO}) then

     "?"

     Else {sub_bd_konkurierend.PAGER_NO}

The original is like this:

( $F{PAGER_NO} == null ? "?" : $F{PAGER_NO})

rgds

Eberhard

former_member205840
Active Contributor
0 Kudos

Hi Eberhard,

The formula which you have written is correct, I have searched IF condition in Jasper and see below example :

$F{column_value}.intValue() == 42 ? "Life, Universe, Everything" : "Naught"

Then the variable's value would be "Life, Universe, Everything" if, and only if, the integer value of $F{column_value} is equal to 42

This I got it from below URL :

jasper reports - doing comparison if else in JasperReports - Stack Overflow

Thanks,

Sastry

Answers (1)

Answers (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Eberhard,

I cannot say for certain what that piece of Java code does, however, it seems to me that it displays dates in a particular format - in this case MMMM yyyy.

The CR alternative for that would look like this:

ToText({Date field}, 'MMMM yyyy')

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

my problem in this case is which Date field to use?

The result should be always the month before the actual month (therefore the -28 in the formula), like we are in June, so it should be May 2016.

rgds

Eberhard

abhilash_kumar
Active Contributor
0 Kudos

Ah! Here's the formula:

ToText(Dateadd('m',-1,currentdate), 'MMMM yyyy');

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

I have a new syntax issue:

java code is like this: "new SimpleDateFormat("MM").format($F{DATE_ACTIONED})"

this formula will group the columns by month as follows in the crosstab, DATE_ACTIONED is a table field:

rgds

Eberhard

abhilash_kumar
Active Contributor
0 Kudos

Hi Eberhard,

Simply insert the Date_Actioned field as a Column in the Crosstab.

Next, highlight that date field > Group Options > Where it says 'The column will be printed', choose 'For Each Month' from the drop-down.

To display the month names, go to the Crosstab Expert again > highlight the Date field in the column > Group Options > Options tab > Check 'Customize Group Name field' > Click 'use a formula as group name' and click the formula button beside it > Add this code:

totext({Date Actioned}, 'MMMM')

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

tks, I think it´s not my day today, sufferung from yesterday´s dentist still

the whole report should look like this:

In jasper I have one main and 4 sub reps, which are not linked (no parameters), so I just insert 4 subs into 4 different details sections in the main report with the corresponding crosstabs in the header of the sub as I did now according to your instruction, right?

And then later I just add the chart.....This should be it?

rgds

Eberhard

abhilash_kumar
Active Contributor
0 Kudos

Yes, you're almost correct.

The Crosstab is set to display by month, however, the chart only seems to display a specific month.

If the chart is supposed to display only a specific month, you'd need another crosstab with just that month's data. You can then insert a chart off of this crosstab and suppress the section that holds this new crosstab.

-Abhilash