cancel
Showing results for 
Search instead for 
Did you mean: 

parameterfield with date ?

Former Member
0 Kudos

hello

how can i pass the variables date with parameterfield

thanks


     Fields fields = new Fields();    	

     ParameterField pfield2 = new ParameterField();

     Values vals2 = new Values();
   
     ParameterFieldDiscreteValue pfieldDV2 = new ParameterFieldDiscreteValue();

     pfield2.setName("Date_EA");
		
     pfieldDV2.setValue("2008-08-31");

     //pfieldDV2.setDescription("");

     vals2.add(pfieldDV2);

     pfield2.setCurrentValues(vals2);

     fields.add(pfield2);

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

And even if we put the date parameter in the way calendar(2008,10,01) in the java code ,the report data would be displayed in the way 01/10/2008.

Thanks

Soni

Former Member
0 Kudos

I have found with the class calendar

january = 0

decembre = 11

the mont begin at 0 for january

Thanks

Former Member
0 Kudos

hello

have you an example of code

for every types with a procedure ( string, date , boolean etc ..)

Regards

Michel

Former Member
0 Kudos

Hi Michel

The report always has a date parameter input of type yyyy-mm-dd .

However ,when the report is previewed (refreshed) ,the data (date value) will always be in the format 01/10/2008.

It works that way by design.

Thanks

Soni

Former Member
0 Kudos

Hi Moulery

Even though your report has the date format as 1/10/2008 ,you need to set it in this way through the code.

Calendar calendar = Calendar.getInstance();

calendar.set(2008,10,1);

Thanks

Soni

Former Member
0 Kudos

hello

No it's not that

I put calendar(2008,8,31) and in my report i have 01/10/2008

the date have changed and i don't no why ?

regards Michel,

Former Member
0 Kudos

Hi Moulery

Which SDK are you using?

If you are using JRC SDK ,you would need to import

<%@page import="java.util.*"%>

for the Calendra class.

Hope this helps.

Thanks

Soni

Former Member
0 Kudos

it's ok inport java.util.*

I have write the code in my jsp



 //DATE VALUE PARAMETER.
     Calendar calendar = Calendar.getInstance();
     calendar.set	(2008,8,31);
     Date dateParamVal = calendar.getTime();

     pfield2.setName("Date_E");
		
     pfieldDV2.setValue(dateParamVal);

     //pfieldDV2.setDescription("");

     vals2.add(pfieldDV2);

     pfield2.setCurrentValues(vals2);

     fields.add(pfield2);

but in my report i have 01/10/2008 ????

My report has a parameter input (date of type yyyy-mm-dd )

Thanks soni

Former Member
0 Kudos

Hi Moulery

Here is the snippet of code that will help you out.

try {

Object reportSource = session.getAttribute("reportSource");

if (reportSource == null)

{

ReportClientDocument oReportClientDocument = new ReportClientDocument();

oReportClientDocument.open("jrc_set_parameters_with_logon/jrc_set_parameters_with_logon.rpt", 0);

reportSource = oReportClientDocument.getReportSource();

session.setAttribute("reportSource", reportSource);

}

Fields oFields = new Fields();

//NUMBER VALUE PARAMETER.

Integer numberValue = new Integer("7");

//STRING VALUE PARAMETER.

String stringValue = "String parameter value.";

//BOOLEAN VALUE PARAMETER.

Boolean booleanValue = new Boolean("true");

//DATE VALUE PARAMETER.

Calendar calendar = Calendar.getInstance();

calendar.set(2004, 1, 17);

Date dateParamVal = calendar.getTime();

//DATE-TIME VALUE PARAMETER.

Calendar calendar2 = Calendar.getInstance();

calendar2.set(2002, 5, 12, 8, 23, 15);

Date dateTimeParamVal = calendar2.getTime();

//CURRENCY VALUE PARAMETER.

Double currParamVal = new Double(555.95);

//TIME VALUE PARAMETER.

Calendar calendar3 = Calendar.getInstance();

calendar3.set(2002, 5, 12, 13, 44, 59);

Date timeParamVal = calendar3.getTime();

//Set all of the parameter values using the utility function.

setDiscreteParameterValue(oFields, "NumberParam", "", numberValue);

setDiscreteParameterValue(oFields, "StringParam", "", stringValue);

setDiscreteParameterValue(oFields, "BooleanParam", "", booleanValue);

setDiscreteParameterValue(oFields, "DateParam", "", dateParamVal);

setDiscreteParameterValue(oFields, "DateTimeParam", "", dateTimeParamVal);

setDiscreteParameterValue(oFields, "CurrencyParam", "", currParamVal);

setDiscreteParameterValue(oFields, "TimeParam", "", timeParamVal);

//Push Fields collection into session so it can be retrieved by the viewer and set

//at view time.

session.setAttribute("parameterFields", oFields);

}

catch(ReportSDKException sdkEx) {

out.println(sdkEx);

}

Thanks

Soni

Former Member
0 Kudos

thanks soni

calendar --> what is the class ???

%><%@ page import="com.crystaldecisions.sdk.exception.SDKException,

com.crystaldecisions.sdk.framework.*,

com.crystaldecisions.sdk.occa.infostore.*"

?????

thanks