30 Temmuz 2008 Çarşamba

Expand number of columns dynamically in report - Fetch example

// You should create tmp tables named TmpTotalTable and TmpTotalHeader and extended data type that has maximum number of elements. Then create a field in tmp tables type of extended data type.

public boolean fetch()
{
TmpTotalTable tmpsum,totalsum,totalsumym;
CustInvoiceJour custinvoicejour, custinvoicejourgr;
custGroup custgroup;
custTable custTable;

iNt i,j,offsetym,lastcol;
ReportStringControl headerfield;
ReportTextControl space;
ReportRealControl sumfield;
ReportRealControl percentfield;

Amount totalamountcur , totalamountYTL, totalamountEUR;

;



if (element.prompt())
{
sums.setTmpdata(tmpsum);
headers.clear();

while select currencycode from custinvoicejour
group by currencycode
where custinvoicejour.InvoiceDate >= datefrom
&& custinvoicejour.InvoiceDate <= dateto
{


i++;
headers.TotalName[i] = custinvoicejour.CurrencyCode;

headerfield = headersection.addStringControl(tablenum(TmpTotalHeader),fieldid2ext(fieldnum(TmpTotalHeader,TotalName),i));
headerfield.alignment(Alignment::Right);
headerfield.width(16,units::Char);
sumfield = sumsection.addRealControl(tablenum(TmpTotalTable),fieldid2ext(fieldnum(TmpTotalTable,Total),i));
sumfield.width(16,units::Char);
sumfield.sumAll(true);

}
colcount = i;
offsetym = i+1;

headers.insert();
this.send(headers);
headersection.executeSection();


while select custgroup from custinvoicejourgr
group by custgroup
where custinvoicejourgr.InvoiceDate >= datefrom
&& custinvoicejourgr.InvoiceDate <= dateto
{
sums.clear();
totalamountcur = 0;
totalamountytl = 0;
totalamounteur = 0;
sums.MaddeGrubu = custinvoicejourgr.CustGroup;
for (i=1; i<=colcount ; i++)
{
totalamountcur = 0;
select
sum(InvoiceAmount) , sum(InvoiceAmountMST), sum(SumTax), sum(SumTaxMST)
from custinvoicejour
where
custinvoicejour.CustGroup == custinvoicejourgr.CustGroup
&& custinvoicejour.CurrencyCode == headers.TotalName[i]
&& custinvoicejour.InvoiceDate >=datefrom
&& custinvoicejour.InvoiceDate <=dateto ;
{
totalamountcur += custinvoicejour.InvoiceAmount - custinvoicejour.SumTax;
total[i] +=totalamountcur;
}
sums.Total[i] = totalamountcur;

}
sums.insert();

}

sums.clear();
sums.totalname ="TOPLAM";
for (i=1; i<=colcount ; i++)
{
sums.Total[i] = total[i];
}
sums.insert();

while select sums
{
this.send(sums);
sumsection.executeSection();

}

}
return true;
}

Hiç yorum yok: