CAPITAL Office Business Software
CAPITAL Support Forum
FAQSearchMembersGroupsRegisterProfilePM'sLogin/Out
SCRIPT TEMPLATE: Parse Customer Transactions

 
Post new topic   Reply to topic    CAPITAL Office Business Software Forum Index -> Scripting & Customisation
View previous topic :: View next topic  
Author Message
COBS Tech Support



Joined: 09 Sep 2005
Posts: 617

PostPosted: Fri Sep 29, 2017 10:20 am    Post subject: SCRIPT TEMPLATE: Parse Customer Transactions Reply with quote

This script can be used as the basis for parsing the customer transaction file and saving the resulting data as a .CSV file.

Code:

* Sample framework script to parse the customer transaction /
* invoice file and export data as a CSV file.

Declare dDateFrom Type Date
Declare dDateTo   Type Date
Declare aTran     Type Array
aTran := {}

FormCreate()
FormAdd("Invoices From", Today())
FormAdd("Invoices To", Today())

If .Not. FormShow("Create a CSV File For Date Range")
   Return
Endif

dDateFrom := FormResult(1)
dDateTo   := FormResult(2)

OpenTable("INVOICE")
INVOICE->(Find(DTOS(dDateFrom), "DATE", TRUE))

:Loop
   If INVOICE->(EOF()) .OR. INVOICE->Date > dDateTo
      Goto WriteFile
   Endif

   * Export Tran No., date and transaction total
   AADD(aTran, { INVOICE->INVOICENO, INVOICE->DATE, INVOICE->INVTOT } )   

   INVOICE->(Skip())
   Goto Loop


:WriteFile
If Len(aTran) = 0
   Echo("Sorry, no transactions were found.")
Else
   If ExportASCII(aTran, PathProgram() + "NSWHealth.csv", "DEL")
      Echo("File created: " + PathProgram() + "NSWHealth.csv")
   Else
      Echo("Error creating: " + PathProgram() + "NSWHealth.csv " + NTRIM(FError()))
   Endif
Endif

CloseTable("INVOICE")
[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CAPITAL Office Business Software Forum Index -> Scripting & Customisation All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

phpBB Template by Vereor
Protected by Anti-Spam ACP