DateTime Format Passing from C++ App to CR
Dear All,
I have found method to suppress the pop up of parameters by using the "Change Subreport Links", I link the parameter to "?@Parametername" ( the other option i see is @PM-Parametername ).
After I link the parameter I call the following code to pass the value to the main report ( Data type is date time ) :
I see that the date time being passed to those parameters indexes & the name of the parameter are correct, but the exported report ( text format ) does not have any records.
I use the cr designer for the same date time inputs & i see the result.
Can any one help me?
here's the codeL:
void CCrystalReport::setSPparam(int nth, const CString &in )
{
CRPEParameterFieldInfo info;
CRPEParameterFieldInfo *ptrInfo = &info;
if(! ::PEGetNthParameterField(m_printJob->GetJobHandle(),
(WORD)nth,
(struct PEParameterFieldInfo *) &info) ) {
throw new CCrystalException( m_printJob->GetErrorText() );
}
PEValueInfo valInfo;
valInfo.StructSize=PE_SIZEOF_VALUE_INFO;
valInfo.valueType = PE_VI_DATETIME;
CString tmpStr = in;
CString s;
char tBuf[10];
int liyear = atoi(tmpStr.Left (4));
valInfo.viDateTime[0] = liyear;
int limonth = atoi(tmpStr.Mid (5,2));
valInfo.viDateTime[1] = limonth;
int liday = atoi(tmpStr.Mid (8,2));
valInfo.viDateTime[2] = liday;
int liHr = atoi(tmpStr.Mid (11,2));
valInfo.viDateTime[3] = liHr ;
int liMin = atoi(tmpStr.Mid (14,2));
valInfo.viDateTime[4] = liMin;
int liSec = atoi(tmpStr.Mid (17,2));
valInfo.viDateTime[5] = liSec;
if (! ::PEConvertVInfoToPFInfo( &valInfo, &info.m_ValueType,
info.m_CurrentValue ) ) {
throw new CCrystalException( m_printJob->GetErrorText() );
}
info.m_DefaultValueSet=FALSE;
info.m_CurrentValueSet=TRUE;
if ( !m_printJob->SetNthParameterField( (short)nth, &info ) ) {
throw new CCrystalException( m_printJob->GetErrorText() );
}
}
void CCrystalReport::setSubReportSPparam(CRPEJob* p,int nth, const CString
&in )
{
CRPEParameterFieldInfo info;
int t = p->GetNParameterFields();
if(! ::PEGetNthParameterField(p->GetJobHandle(),
(WORD)nth,
(struct PEParameterFieldInfo *) &info) ) {
throw new CCrystalException( m_printJob->GetErrorText() );
}
PEValueInfo valInfo;
valInfo.StructSize=PE_SIZEOF_VALUE_INFO;
valInfo.valueType = info.m_ValueType ;
if (valInfo.valueType == 4 )
strcpy( valInfo.viString, in);
else if (valInfo.valueType == 5 )
{
// Handle the DateTime type
CString tmpStr = in;
CString s;
char tBuf[10];
int liyear = atoi(tmpStr.Left (4));
valInfo.viDateTime[0] = liyear;
valInfo.viDate[0] = liyear;
int limonth = atoi(tmpStr.Mid (5,2));
valInfo.viDateTime[1] = limonth;
valInfo.viDate[1] = limonth;
int liday = atoi(tmpStr.Mid (8,2));
valInfo.viDateTime[2] = liday;
valInfo.viDate[2] = liday;
int liHr = atoi(tmpStr.Mid (11,2));
valInfo.viDateTime[3] = liHr ;
valInfo.viTime[0] = liHr ;
int liMin = atoi(tmpStr.Mid (14,2));
valInfo.viDateTime[4] = liMin;
valInfo.viTime[1] = liMin;
int liSec = atoi(tmpStr.Mid (17,2));
valInfo.viDateTime[5] = liSec;
valInfo.viTime[2] = liSec;
}
if ( !p->SetNthParameterField( (short)nth, &info ) ) {
throw new CCrystalException( p->GetErrorText() );
}
}
Thanks & Regards
Sankar
|