Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a better (faster) way
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00362228
Message ID:
00362249
Vues:
22
Why don't you just create another cursor with columns for all the months and append the cross-tab data into that cursor?

select 0
create cursor crsFinal (RowDesc C(x), C_01 N(x,x), C_02 N(x,x), C_03 N(x,x), C_04 N(x,x), C_05 N(x,x), C_06 N(x,x), C_07 N(x,x), C_08 N(x,x), C_09 N(x,x), C_10 N(x,x), C_11 N(x,x), C_12 N(x,x))
append from dbf('ytdtable_a')


>I've got a form that is used to generate a YTD report. It starts by letting the user select the starting month (combobox) and starting year(Combobox). Then it creates determines the starting date/and ending date for a 12 month period. From that I generate a SQL statement and load a table, I run the table through the cross-tab routine. This part is all really snappy and fast. But since the cross-tab only creates fields for months with data, I run the code listed below to populate a report table. I'm using a do case routine, and this part is really slow. The cross-tab routine with the sample data I'm using only has 29 records, yet it takes about 2 minutes on a PIII 600 256Megs of ram and win2000 pro to process. It works, it's just slow. Any help on how to speed this up would be greatly appreciated.
>
>***- Code Begins
>select ytdtable_a
>=afields(laFields)
>scan
>* Set the Description
>m.description=ytdtable_a.ROWDESC
>* Set Initial Values to 0
>store 0 to m.mon1,m.mon2,m.mon3,m.mon4,m.mon5,m.mon6,m.mon7
>store 0 to m.mon8,m.mon9,m.mon10,m.mon11,m.mon12,m.rowtotals
>* Loop Through the fields in the field array and store their value
>lnRowTotal=0
>for x=2 to alen(laFields,1)
>do case
>case allt(laFields[x,1])=[C_01] && January
> m.mon1=ytdtable_a.c_01
> lnRowTotal=lnRowTotal+ytdtable_a.c_01
>case allt(laFields[x,1])=[C_02]
> m.mon2=ytdtable_a.c_02
> lnRowTotal=lnRowTotal+ytdtable_a.c_02
>case allt(laFields[x,1])=[C_03]
> m.mon3=ytdtable_a.c_03
> lnRowTotal=lnRowTotal+ytdtable_a.c_03
>case allt(laFields[x,1])=[C_04]
> m.mon4=ytdtable_a.c_04
> lnRowTotal=lnRowTotal+ytdtable_a.c_04
>case allt(laFields[x,1])=[C_05]
> m.mon5=ytdtable_a.c_05
> lnRowTotal=lnRowTotal+ytdtable_a.c_05
>case allt(laFields[x,1])=[C_06]
> m.mon6=ytdtable_a.c_06
> lnRowTotal=lnRowTotal+ytdtable_a.c_06
>case allt(laFields[x,1])=[C_07]
> m.mon7=ytdtable_a.c_07
> lnRowTotal=lnRowTotal+ytdtable_a.c_07
>case allt(laFields[x,1])=[C_08]
> m.mon8=ytdtable_a.c_08
> lnRowTotal=lnRowTotal+ytdtable_a.c_08
>case allt(laFields[x,1])=[C_09]
> m.mon9=ytdtable_a.c_09
> lnRowTotal=lnRowTotal+ytdtable_a.c_09
>case allt(laFields[x,1])=[C_10]
> m.mon10=ytdtable_a.c_10
> lnRowTotal=lnRowTotal+ytdtable_a.c_10
>case allt(laFields[x,1])=[C_11]
> m.mon11=ytdtable_a.c_11
> lnRowTotal=lnRowTotal+ytdtable_a.c_11
>case allt(laFields[x,1])=[C_12]
> m.mon12=ytdtable_a.c_12
> lnRowTotal=lnRowTotal+ytdtable_a.c_12
>endcase
>endfor
>* Set the report ID, This is how we will requery on
>m.rowtotals=lnRowTotal
>m.reportid=lnReportID
>m.recordid=val(gnextid('MONTHST'))
>m.reportgroup=[DISCIPLINE]
>insert into monthst from memvar
>endscan
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform