How to Post Totals to Another Table

Question

I can get DataEase to generate report subtotals but I do not know how to transfer those totals to a separate summary table.

Solution

  1. Define a temporary variable of the same type as the field you are listing in groups.

  2. Use a for command to specify the Primary table for the report.

  3. Include a list records command. You only need to list the field that you are grouping. List the field in groups and terminate the list records command with a period.

  4. Use an if command to check the status of the temporary variable.

  5. Use the enter a record in command to enter a new record in the summary table each time the group changes.

  6. Reassign the temporary variable for the next pass of the for loop.

 

Example

 define temp "LASTGRP" Numeric String 5 .

for RESERVATIONS ;

list records

MEMBER ID in groups .

if MEMBER ID not = temp LASTGRP then

enter a record in RESERVATION SUMMARY

MEMBER_ID := RESERVATIONS MEMBER ID ;

TOTAL_SPENT := sum of RESERVATIONS with

( MEMBER ID = RESERVATION SUMMARY MEMBER_ID )

TOTAL DUE .

assign temp LASTGRP:= MEMBER_ID .

end -- if

end -- for

 

This example tells DataEase to: (1) define a temporary variable called last grp as a 5 digit numeric string, (2) open the reservations table and process every record, and (3) list the MEMBER ID in groups. The next part of the script tells DataEase to: (4) using an if command, compare the value in the MEMBER ID field (in the record being processed) with the value in the LAST GRP variable. If the two values are different, DataEase enters a new record in the summary table (RESERVATION SUMMARY). The information entered in the new record includes the MEMBER ID and the sum of the total cost of all the reservations for that member. The last part of the script tells DataEase to: (5) assign the temp LAST GRP variable the current MEMBER ID. The first end command terminates the if command and the second end terminates the for loop.