Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL
Message
From
13/11/2008 10:55:05
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01361585
Message ID:
01361684
Views:
15
>>>yes, thanks, Ed.
>>>
>>>If the result cursor has more employees in it than there are columns across the (landscape) page to fit on the report then I do the following:
>>>
>>>Say there are 10 columns of booked/charged data across the page. Then I go through the cursor and get each set of 10 records into a special cursor i keep just for the report.
>>> I report form this "batch" of 10 records then get the next 10 from the cursor.
>>>And so on till all the cursor recs have been printed.
>>>
>>>BTW, sorry but I need to leave work in 20 mins, so maybe carry this on tomorrow after that.
>>>
>>Sure, there still one issue left. If let's say Inv#1 has employees Bob and John, and next Inv.#2 has Derek and Paul; do you report them in 4 or 2 columns?
>
>4 columns
>
>>In other words, each employee has fixed position in the report or you always squeeze them and print employee name in each report line? I suspect that the latter is the case, but still will appreciate if you confirm it. Could you do it now? If yes, then I will give full report querying outline in the next message and you could look at it when you get home.
>
>Each employee against whose work an invoice has been raised will appear in a column of HIS data.
>Some employees may have hours in different invoices.
>Some invoices will have hours under more than one employee (eg several employees' work was invoiced for part of the job)
>the employee names will appear only at the top of the column dealing with all the work (invoices) charged against them.
>
>I hope this explains, but I really need to go now (dentist appt.) :-(
>
>Cheers Ed.

I see it, so you have fixed employee columns. Let's proceed with data processing now:
Firstly, you prepare report cursor invoice and batch columns
Create Cursor myreportcursor (invid I,invno C(10),batchno I)
Now you prepare employee columns
For nLoop=1 To 9
	cFieldname1='empcharge'+Transform(nLoop)
	cFieldname2='empbook'+Transform(nLoop)
	Alter Table myreportcursor Add Column &cFieldname1. N(4,1) Add Column &cFieldname2. N(4,1)
Endfor
Now you collect employees
Select Distinct EmpID,EmpName From InvoiceDataTable Join EmployeeTable On ... Where .... Order By 2 Into Cursor reportemployees
Now you can start collecting data for each employee filling it to the report cursor:
Select myreportcursor 
Index On Str(batchno)+str(InvId) Tag BatchInvoice
Set Order To Tag EmpId in InvoiceEmpData    && this is either full data or recordset collected by some invoice criteria
Select reportemployees
nCounter=0
Scan
  nCounter=nCounter+1
  nFieldnumber=mod(nCounter,9)   && use it to fill proper field in the reportcursor
  if nFieldnumber=0
    nFieldnumber=9
 endif
  nBatchno=ceiling(nCounter/9)   && first 9 employees go to 1st batch, next 9 to 2nd batch and so on
  nEmpId=reportemployees.empid   && use this id to collect hours from invoice/hours tables
  Select InvoiceEmpData
  Seek nEmpId
  Scan While InvoiceEmpData.EmpId=nEmpId
    nInvID=InvoiceEmpData.InvID
   *** check in hours tables to collect hours per InvId+EmpId, getting nCharge (charged hours) and nBooked (booked hours)
    If seek(Str(nBatchno)+Str(nInvID),'myreportcursor','BatchInvoice')=.F.   && add new record
      Insert into myreportcursor (invid,invno,batchno) values(nInvID,cInvno,nBatchno)
    endif
   cFieldname1='empcharge'+transform(nFieldnumber)
   cFieldname2='empbook'+transform(nFieldnumber)
   Replace &cFieldname1. With nCharge,&cFieldname2. With nBooked in myreportcursor 
  EndScan
EndScan
Please, note that I didn't test the code, so check for typos, and use actual table/field names. There are few auxiliary things that may transpire on the way, so do it methodically. Good luck.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform