Sample Bill Export Visual Basic Script with Commentary

Managing Bill Exports

Overview: Exporting Bills from EnergyCAP to an AP/GL System

About 50% of EnergyCAP Enterprise clients export billing data to their organization Accounts Payable or General Ledger system. The specific process and necessary software tools can be developed during software implementation. First, the information is entered or received into EnergyCAP. EnergyCAP audits the bills for billing errors, flags the issues and then passes the bills onto a supervisor for approval. When approved, the billing data is exported to the AP/GL system for payment. Once the AP/GL system pays the bills, information such as payment date, check number, etc can be imported back into EnergyCAP. The result is a complete bill record.

There are several advantages to doing business this way:

  • Bill entry efforts are simplified. Many organizations enter billing data twice – once in an energy information system and again in their AP/GL system, doubling their efforts. By using EnergyCAP’s bill export capability, the organization saves valuable manpower by avoiding duplication of efforts.
  • EnergyCAP becomes a “smart” front end to the AP/GL system. AP/GL systems are designed to facilitate the accounting process but not to analyze energy information. In most cases, as long as the vendor and date are correct, the system will issue payment. But if there are billing errors or if usage is irregularly high, the AP/GL system may not catch those types of savings opportunities.
  • EnergyCAP can catch billing errors before payment is made. Many organizations pay the bill and look for errors later. When a mistake is caught, the payment has already been made. The organization has to recover the cost, which can take months. But with busy schedules, some organizations don’t go after their credits. They throw their money away because they don’t have the time to recover it. Catching a billing error before payment can save time and money.
  • Consumption issues are spotted right away. With EnergyCAP’s audits and automatic benchmarks, you can spot problem facilities immediately. In one case, EnergyCAP benchmarks led a city energy manager to discover water pipes that were pouring directly into a drain. He quickly turned off the water. Although they eliminated future losses, they had already wasted thousands of dollars. AP/GL systems will not pick up many consumption issues but EnergyCAP will.

EnergyCAP can export to any AP/GL system. The company has extensive experience mapping data to and from a variety of different accounting systems. Typically, EnergyCAP exports to an intermediary file. A custom application reformats the EnergyCAP data to fit the AP/GL system and then imports to the system. When bringing data into EnergyCAP from the AP/GL system, the process is the same. This method ensures EnergyCAP’s compatibility with any system and at the same time protects the AP/GL system’s security and integrity.

NOTE: Bill Export and Import for AP/GL integration is a customized process for each organization. For pricing and implementation details, and/or a list of the applications interfaced with to date, contact EnergyCAP sales at sales@energycap.com.


Managing Bill Exports

Bill Export Detail and Process

See also—Exporting Bills from EnergyCAP to an AP/GL System.

Billing data can be exported from the EnergyCAP® database to a user-selected file type. The following file formats are supported:

  • .txt (text file—default format)
  • .dat (text file)
  • .csv (comma-separated value file in ASCII format)
  • .prn (contains a sequence of raw bytes that are understood by the printer hardware)

The bill export procedure involves defining and/or selecting an export Profile which specifies precisely what data will be exported and the format of the file. The bill export Profile includes a topmost Cost Center filter, as well as options for selecting which accounts and/or billing dates will be included in the export. The exported file can then be imported to the client A/P system, manipulated in a spreadsheet program for energy analysis, and/or used for reporting or other purposes. For most EnergyCAP clients, the export process is defined and all details finalized during software implementation.

There are two export streams in EnergyCAP; these export options offer additional flexibility for integration into an organization’s accounting structure:

  • A/P (often used for bill payment for accounts which receive bills)
  • G/L (often used for internal invoicing from accounts which calculate and issue bills based on submeter data)

There are also two ways to initiate bill export:

  • Using the Bill Export window/wizard
  • Running the bill export external task (EXPTSK.EXE) found in the EnergyCAP program directory

The advantage of the export task is that it can be run independently of the EnergyCAP program, even as a ‘scheduled task’ in Windows®, using a previously-defined export profile. For more information about this procedure, see the topic on External Tasks.

The advantage of using the Bill Export window/wizard is that the bill export profile can be defined and/or modified. Follow the procedure below to define an export profile and export billing data from the EnergyCAP program.

  1. Open EnergyCAP and navigate to the Account Manager or Work Flow Manager.
  2. Click File>Export.

    BillExportMenuOption.jpg
    The Export As: window will open.
  3. Click the Save in: drop-down arrow and browse to highlight/select the desired location for the export file on your hard drive or network.
  4. Click the File name: field and input the desired file name for the export file, including the desired three-letter file type extension (txt, dat, csv, prn). NOTE: If no file type is specified, the export will default to a .txt format file.
  5. Click Save. The Bill Export window will open.

    BillExportMenuOption2.jpg
  6. If the desired export profile has previously been defined, click the Use an existing profile radio button and select the profile from the drop-down list. Then proceed to step 8.
    NOTE: Defined profiles reside in the billexp.ini file. The default location for this file is C:\Documents and Settings\[User]\Local Settings\Application Data\EnergyCAP Enterprise\.
    (where [user] is the Windows® ID for the user)
  7. If it is necessary to create a new export profile, click the Create a new profile radio button. Then input the Profile Name in the field provided.
  8. Click Next. The Export Selection Filters window will open.

    ExportSelectionFilters1.jpg
  9. Click to select/highlight the desired Topmost Cost Center in your organization from which bill information will be exported. The Topmost Cost Center tree duplicates your Account Manager organizational hierarchy.
    • If necessary, expand the hierarchy by clicking the ‘plus’ icon to the left of the Cost Center.
      NOTE: Bill export options may be limited by individual User Permissions.
    • Click the radio button corresponding to the desired Bill Creation Method:
      • All Bills will export all unfiltered bills associated with the Cost Center.
      • Vendor Bills will export only bills from accounts that receive bills (see Account Properties/Billing tab).
      • Customer Bills will export only bills from accounts that create bills (see Account Properties/Billing tab).
  10. Click Next. The Bill Export-Delimiter and Output window will open.

    BillExport1.jpg
  11. Choose the desired delimiter (the character separating each piece of exported billing data from the next in each record in the exported bill file). Comma or tab-delimited files are most common.
  12. Click the radio button corresponding to the desired Output type:
    • a. Select Automatic output if the export parameters will be defined only by the presence or absence of export flags associated with the bill records.
    • Select Manual output to add additional export filters, including specific accounts and bill start/end dates.
  13. If using bill tracking options, click the Mark bill as “Exported” check box. When the bill is exported, this option sets an Exported flag (corresponding to export mode A/P or G/L) in the EnergyCAP database Bill table for the record associated with the bill, preventing the bill from being exported again in the future. This check box should ordinarily be checked.
    NOTE: Manual output includes an override option: Ignore “Exported” flag.
  14. If the Ignore restrictions checkbox is unchecked, Work Flow Wizard export restrictions will be honored in the bill export process. If checked, the exporter will ignore Work Flow restrictions, generally resulting in export of a larger number of bills. the default (unchecked) setting is recommended.
  15. Select the desired Export mode, A/P or G/L. Each bill record in EnergyCAP has an APExported flag and a GLExported flag. The Export mode determines which field will be flagged during the export process:
    • Select A/P if exporting to A/P.
    • Select G/L if exporting to G/L.
      NOTE: in Work Flow Manager are two Waiting for Export folders – one listing G/L bills and the other listing A/P bills. After each bill is created, approved, and the batch is closed, it appears in BOTH Waiting for GL Export and Waiting for AP Export since both the export flags are set to ‘0’. Then when an export is run, depending on the choice in the profile (A/P or G/L), the flag corresponding to the export mode is set to ‘1’ and the bill disappears from the corresponding folder.
  16. Manual ouput options should only be used in consultation with an EnergyCAP support technician. If using the Manual output options, set these additional filter options:
    • Accounts: To limit the export to a specific account or accounts, click the Plus button to add specific account filters to the export. The Advanced Search window will open, enabling input of account search options. Once accounts appear in the Results: pane, accounts to be exported can be selected/highlighted using the Ctrl-click and Shift-click keyboard-mouse combinations. Click the Select button to close the Search window and populate the Accounts pane with the selected accounts. Repeat the process as many times as necessary until all desired accounts have been included in the export.
    • Start/End date: To limit the export to a specific timeframe, click the Start date: and End date: drop downs and use the calendar interface to select each desired date.
  17. Click Next. The Bill Export-Line Selection window will open.

    BillExport2.jpg
  18. Click the checkboxes associated with the additional information desired for export. Then click Next. A series of windows corresponding to your previous selection(s) will open, one after the other.

    BillExport3.jpg
    In each window, the Available pane (left) displays available data for export. Click the arrow keys to move desired Available data to the Selected pane. The double-arrow button moves all data. The single-arrow button moves only the highlighted item. When desired data has been relocated to the Selected pane, click Next. Repeat this step until the Finished window appears.
  19. When the Finished window appears, click Finish to initiate the bill export. Bill data will be exported to the file and file location specified, and the Log window will open, displaying export information.
    NOTE: Depending on the number of bills and the amount of data required, and the selected export file format, the export process may take some time.
  20. Click Close to close the Log window.

The bill export process is complete.


Managing Bill Exports

Sample Bill Export Visual Basic Script with Commentary

This advanced topic provides guidance in constructing a visual basic script that can be automatically executed as a Windows Scheduled task. This script example runs the bill exporter (exports everything that's in the Waiting to A/P Export folder in Work Flow Manager) and locates it in a folder called D:\UtilBill\Out. The file is named AP_ECAP_EXPORT.csv. The export "map" (called the billexp.ini profile) is named BILLEXPORT.

The A/P import process must obtain the AP_ECAP_EXPORT.csv file from the AP_folder.

"ecap" is the datasource name (the name of the ODBC connection)
"apexport" is the user name and user password of a user set up just for exporting purposes. This user can have only one permission - Other Settings/Export.

________________________________

Option Explicit

Dim objFSO, myshell, export_folder, archive_folder, AP_folder, strFilename, strDate, strTime, strDateTime, EnergyCAP_APExport, strECEProgramDirectory

export_folder = "d:\utilbill\out\temp\" 'The folder for the file to be exported

AP_folder = "d:\utilbill\out\" 'The folder where A/P will grab the data

archive_folder = "d:\utilbill\out\archive\" 'The folder where the file is to be archived

strFilename = "AP_ECAP_Export" 'Name of the file to be created by EnergyCAP

strDate = Cstr(Year(date) & "-" & MonthName(month(date)) & "-" & Day(date)) 'Just the date in format YYYY-MON-DD

strTime = Cstr(FormatDateTime(Now(),vbLongTime)) 'Just the time in format HH:MM:SS AM/PM

strTime = Replace (strTime, ":",".",1,-1,vbTextCompare) 'Time is formatted to be HH.MM.SS AM/PM

strDateTime = strDate & "_" & strTime 'Date and time are strung together

EnergyCAP_APExport = "exptsk -d ""ecap"" -u apexport -p apexport -c STANDARD:BILL_TEXT -f """& export_folder & strFilename & ".csv"" -s ""BillExport""" 'This is the command line to execute the AP exporter - note the various parts of the command line and change where necessary

strECEProgramDirectory = "c:\program files\energycap enterprise\" 'Install location of EnergyCAP - the location of the exptsk.exe utility on the applications server

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set myshell = WScript.CreateObject("WScript.Shell")

if(objFSO.FileExists(export_folder & strFilename & ".csv")) then 'Looks in the dir to see if any files exist

objFSO.DeleteFile export_folder & strFilename & ".csv", "True"

end if

if(objFSO.FileExists(etl_folder & strFilename & ".csv")) then 'Looks in the dir to see if any files exist

objFSO.DeleteFile etl_folder & strFilename & ".csv", "True"

end if

myshell.CurrentDirectory = strECEProgramDirectory 'Sets the working directory to be the location where EnergyCAP is installed

myshell.Run EnergyCAP_APExport, 1, True 'Executes the AP Exporter

if(objFSO.FileExists(export_folder & strFilename & ".csv")) then 'Looks in the dir to see if any files exist

objFSO.CopyFile export_folder & strFilename & ".csv", archive_folder & strFilename & "_" & strDateTime & ".csv", "True" 'Archives the csv file created by EnergyCAP

objFSO.CopyFile export_folder & strFilename & ".csv", AP_folder & strFilename & ".csv", "True" 'readies the csv file created by EnergyCAP for AP

end if





if(objFSO.FileExists(export_folder & strFilename & ".csv")) then 'Cleans out any files left from the AP Export task

objFSO.DeleteFile export_folder & strFilename & ".csv", "True"

end if


Managing Bill Exports

Removing an Unwanted Export Profile

There is no way to remove an unwanted export profile using the EnergyCAP software. However, the profile can be deleted by externally editing the billexp.ini file by hand.

! CAUTION: Be sure to make a backup of the billexp.ini file before editing it because if you accidentally delete the profile you want to keep you won't be able to recover it!

In a default EnergyCAP installation, the file is located in the following directory:

C:\Documents and Settings\your_user_name\Local Settings\Application Data\EnergyCAP Enterprise

The text document is organized in multiple sections. There will be a section for each profile, headed by the profile name in brackets, and ending with the MergeSelections= statement. Just delete the unwanted section and save the edited file to the same name and location.


Managing Bill Exports

AP Export Fields - Dictionary and Best Practice Reference

Last Revised: EnergyCAP Release and Database Version: EnergyCAP Enterprise 6.2.64.130 [DB 64]

Purpose:

This document lists and describes all exportable AP fields and (if applicable) their field names in the EnergyCAP Enterprise database (assuming the database version mentioned above). This document will be helpful in developing specifications and processes for sharing EnergyCAP information with accounting (AP/GL) interfaces.

This topic does not provide details of the EnergyCAP bill export process. To learn more about exporting bill data, see Bill Export Detail and Process .

Line Selection

During the export setup, the user may select which lines of data to export. Best practices as of 4Q 2011 dictate that AT MINIMUM, the Bill summary, Account summary, Meter summary, G/L summary, and Bill Line summary should be selected for export. The individual fields within each of these lines may be chosen at the Project Manager’s discretion.

export1.png

A Note on String Literals

String Literals are used to clearly identify individual lines of the export file. Best practices dictate that for EVERY line type used for bill export, a string “literal” field should be added to the output fields to identify the line type for any AP interface. This is done during export profile definition using the EnergyCAP export interface:

export4.png

At minimum, the string literal must contain the letter “L” plus a number (0-6), depending upon the line type. Also, the string literal MUST be the FIRST field, in order, from top to bottom. The string literal should contain the [abbreviation] and full name of the line type. Custom also dictates that an “@” character is added to the END of the string literal. Customarily, each string literal will contain the name of the output line with which it is associated.

Below is an example demonstrating how to create and insert the string literal for the Bill Header line of the export profile during  profile definition:

export3.png

Bill Header

The Bill Header line appears ONCE at the top of a given export file. It contains highest-level summary information about the bills contained in the file.

export5.png

Field Name Database Field Field Description Sample Value
Current date N/A This is the date that the export file is generated. 01/10/2012
Current time N/A
This is the time that the export file is generated .
03:45:16
Number of bills N/A This is the number of bills written to the export file. 9
Total debits N/A This is the total cost of all debits in the export file. $0.00
Total credits N/A This is the total cost of all credits in the export file. $31152.79
Total amount N/A This is the sum of the Bill.TotalCost amounts for all the bills in the export file. $31152.79

 

Bill Summary

Bill Summary lines appear ONCE per bill. They contain high-level summary information about a particular bill.

export6.png

Field Name Database Field Field Description Sample Value
Bill ID Bill.billID This is the unique ID number assigned to each bill. 1024
Cost center CostCenter.costCenterInfo This is the display name of the Cost Center containing the Account associated with this bill. My Cost Center
Cost center code CostCenter.costCenterCode This is the unique code of the Cost Center containing the Account associated with this bill. MYCOSTCENTER
Parent cost center CostCenterParentChildView.costCenterInfo This is the display name of the Cost Center containing the Cost Center associated with the Account associated with this bill. Parent Cost Center
Parent cost center code CostCenterParentChildView.costCenterCode This is the unique code of the Cost Center containing the Cost Center associated with the Account associated with this bill.
PARENTCC
Account Account.accountCode This is the unique account code of the Account associated with this bill. 66661
Start date Bill.beginDate This is the begin date of the time period covered by the bill. 01/10/2012
End date Bill.endDate This is the end date of the time period covered by the bill. 02/09/2012
Exported Bill.exported This is the flag to show whether or not the bill has been exported. 0
Exported date Bill.exportDate This is the date upon which the bill has been exported. If the bill has never been exported, this field will contain the value “<none>”.
<none>
Total cost Bill.totalCost
This is the total cost of all charges on the bill $150.00
Vendor
Vendor.vendorCode This is the unique vendor code for the vendor assigned to the account with which this bill is assigned. VENDOR2
Billing period Bill.billingPeriod This is the billing period month to which this bill is assigned. Jan
Billing year Bill.billingPeriodYear This is the billing period year to which this bill is assigned. 2012
Batch number
Batch.batchCode This is the unique batch number to which this bill is assigned. This field will be blank if the bill is not assigned to a batch. 012012
Account period Bill.accountPeriod This is the account period month assigned to this bill. This field will be blank if the bill is not assigned to an account period.
March
Account year Bill.accountPeriodYear This is the account period year assigned to this bill. This field will be blank if the bill is not assigned to an account period.
2012
Control code Bill.controlCode This is the control code assigned to this bill. This field will be blank if there is no control code assigned to this bill. 0010102012
Due date Bill.dueDate This is the due date assigned to the bill. This field will contain the value “<none>” if no due date is assigned. <none>
Estimated Bill.estimated This flag indicates whether the bill is an estimated bill or an actual bill. 0
Invoice number Bill.invoiceNumber This is the invoice number assigned to the bill. 14243414241
Next reading Bill.NextReading The Date/Time Stamp of when we expect the next reading to be taken. 01/02/2012
Statement date Bill.StatementDate This is the statement date assigned to the bill. <none>
Observation method ID Bill.observationMethodID
This is the unique identifier for the type of bill. *
Account service Address Bill.addressid This is the service address assigned to the account to which this bill is assigned.**
Account active Account.active This flag indicates whether or not the account to which this bill is assigned is active. 1
Created Date Bill.createdDate
This is the date on which the bill was created and saved. 01/10/2012
Modified Date Bill.modifiedDate This is the date on which the bill was last modified. 01/10/2012

*Bills can be Automatic (1), Manual (2), Estimated (3), Simulated (4), Accrual (5), Adjustment (6) … from the ObservationMethod Table.  The Observation Method used depends on what method is used to create the bill.  For example, Manual is when bills are hand-keyed, Automated is for Bills that are imported, Estimated is when the Estimated flag is checked, Simulated is from processors like Bill Splits and Calculated Accounts.  Accrual bills are created by the accruals module/processor, and Adjustment bills are when the “monkey wrench” is used from the bill edit screen.

**Joined to Address table where addresstypeid = 3 (Note: Physical – 1, Billing – 2, Service – 3)

Account Summary

Account Summary lines appear ONCE per bill. They contain account-level summary information about a particular bill.

export7.png

Field Name Database Field Field Description Sample Value
Account ID Account.accountID This is the unique ID number assigned to the account. 1024
Start date Bill.beginDate This is the begin date of the time period covered by the bill. 01/10/2012
End date Bill.endDate This is the end date of the time period covered by the bill. 02/09/2012
Code
Account.accountCode This is the unique account code of the Account associated with this bill. 66661
Display
Account.accountInfo This is the display name of the Account associated with this bill. 66661
Vendor ID Account.vendorID This is the unique ID number of the vendor to which this account is assigned. Generated automatically by EnergyCAP during vendor creation.
1024
Vendor Vendor.vendorCode This is the unique code associated with the vendor to which this account is assigned.
VENDOR1
Rollup cost N/A This is the sum of all the dollar amounts belonging to the meters and account charges assigned to this account for this bill. $1548.23

 

Meter Summary

Meter Summary lines appear MULTIPLE times per Account Summary. They contain meter-level summary information about a particular bill.

export8.png

 

Field Name Database Field Field Description Sample Value
Place ID LogicalDevice.placeID This is the unique ID number assigned to the place to which this meter is assigned. Generated automatically by EnergyCAP during Place creation. 216
Place code Place.placeCode This is the unique place code of the Place to which this meter is assigned. MYPLACE
Place display Place.placeInfo This is the display name of the Place to which this meter is assigned. My Place
Place type PlaceType.placeTypeCode This is the unique place type code of the Place to which this meter is assigned. BUILDING
Meter ID Meter.meterID This is the unique ID number assigned to this meter. Generated automatically by EnergyCAP during Meter creation. 52
Meter code LogicalDevice.logicalDeviceCode This is the unique code assigned to this meter. MULTIMETERS-ELE01
Meter display LogicalDevice.logicalDeviceInfo This is the display name assigned to this meter. MULTIMETERS-ELE01
Cost N/A This is the sum of all the charges in this bill which are assigned to this meter.
$845.12
Use N/A This is the usage assigned to this meter in this bill. 457.0000
Demand N/A This is the demand assigned to this meter in this bill
1245.0000
Use unit
Unit.unitCode This is the unique unit code assigned to the use for this meter for this bill. KWH
Demand unit Unit.unitCode This is the unique unit code assigned to the demand for this meter for this bill. KW
Cost per Unit N/A This is the unit cost for the usage assigned to this meter for this bill (Cost / Use). 1.85

G/L Summary

G/L, GL, or General Ledger Summary lines appear ONCE per Meter Summary (if GL records are assigned to those meters), ONCE per Account Summary (for account-charges, if a GL record is assigned to the meter), or MULTIPLE times per Account Summary (for special charges, if the user inserts extra, non-template bodylines). They contain GL-level summary information about a particular bill.

export9.png

Field Name Database Field Field Description
Sample Value
Code GeneralLedger.generalLedgerCode This is the unique general ledger code of the General Ledger record assigned to this meter. ABC123
Subcode 1 GeneralLedger.subCode01 This is a unique information placeholder.
ABC124
Subcode 2-19 GeneralLedger.subCode02-19 This is a unique information placeholder. ABC125-143
Subcode 20 GeneralLedger.subCode20 This is a unique information placeholder. ABC144
Cost
N/A This is the rolled-up cost of all charge lines underneath this GL. $123.45

Bill Line Summary

Bodyline or Bill Line Summary lines appear MULTIPLE times per GL Summary (if GL records are assigned to Accounts or Meters) or MULTIPLE times per Account or Meter summary. They contain bill bodyline-level information about a particular bill and contain the most granular information of all the export line types.

export10.png

Field Name Database Field Field Description Sample Value
Commodity Commodity.commodityCode This is the unique commodity code for the commodity tracked by this bill bodyline. MONEY
Observation type ObservationType.observationTypeCode This is the unique observation type code for the observation type tracked by this bill bodyline. CHARGE
Unit Unit.unitCode This is the unique unit code for the unit of measure tracked by this bill bodyline.
KWH
Cost unit Unit.unitCode This unique unit code for the cost unit of measure tracked by this bill bodyline. USDOLLARS
Value BodyLine.value This is the numerical value for this bodyline. 1234.0000
Cost Bodyline.cost This is the cost for this bodyline. $123.45


Bill Footer

The Bill Footer line appears ONCE at the bottom of a given export file. It contains highest-level summary information about the bills contained in the file.

export11.png

Field Name
Database Field Field Description Sample Value
Current date N/A
This is the date that the export file is generated.
01/10/2012
Current time N/A
This is the time that the export file is generated.
03:45:16
Number of bills N/A
This is the number of bills written to the export file.
9
Total debits N/A
This is the total cost of all debits in the export file.
$0.00
Total credits N/A
This is the total cost of all credits in the export file.
$31152.79
Total amount N/A
This is the sum of the Bill.TotalCost amounts for all the bills in the export file. $31152.79