This is the API Call for a report. It differs only slightly from a transaction query in that the request is not an SQL type. Instead it looks like calling a url and passing the report request with options and authorization. The application I needed to create is for a vendor detail balance report. You might ask, why don't i just output an excel report. But in this case, I want to do a comparison of one company's vendor detail report and a second company's customer detail report. It is a question of determining the transactions between two QBO companies intercompany balance. I won't bore you with the last steps to do the comparison. I will leave the eventual processing to you. My blog will be about running the API on a report and parsing the result in JSON.
Lets get started. We will call our program getvdb.prg. (Get Vendor Detail Balance)
We will need to construct a resulting table and so I added some records to my fieldlist.dbf. For my proposes, I only need 5 fields.
Create table result (vendor c(40),docnumber c(20),amount n(12,2),balance n(12,2),txndate c(20)) I could do this in the code or i can
call the build table routine
**Do whatever you need with the result.dbf
FUNCTION createtable
PARAMETER lcentity,lcfilename,
USE fieldlist
SET FILTER TO entity=lcentity
mfieldcount=1
SCAN
DIME marray(mfieldcount,4)
marray(mfieldcount,1)=(colname)
DO CASE
CASE TYPE="String"
marray(mfieldcount,2)="C"
marray(mfieldcount,3)=VAL(MAXLEN)
marray(mfieldcount,4)=0
CASE TYPE="Number"
marray(mfieldcount,2)="N"
marray(mfieldcount,3)=12
marray(mfieldcount,4)=2
CASE TYPE="Boulean"
marray(mfieldcount,2)="L"
marray(mfieldcount,3)=1
marray(mfieldcount,4)=0
ENDCASE
mfieldcount=mfieldcount+1
ENDSCAN
CREATE TABLE (lcfilename) FROM ARRAY marray
RETURN
The next step is the makecallreport. This is almost identical to the makecallprg.
That is the MakeCallreport.prg. It should be universal for all of your API calls for reports.
See the JSON parsing for reports blog for that last chunk of code.
Craig Sobel