Guide
Load Report Template
-
Tools > Report Designer

-
Press on IMPORT

-
Follow the steps below :
-
Change the report type to SQL Report(rtm)
-
Select your Report
-
Press OPEN

-
Simple Calculation
- In Report Builder, you can also do some simple calculation using the Variable (The Calculator Icon)

-
Click on SubRptNorm: Document_Detail
-
Select the Variable button (the Calculator icon)
-
Click on the place to be print/shown.
-
Click on Calc Tab

-
Right click here & Select Event & find the component just now we had placed (eg Variable2)
-
Click OnCalc
-
Click here & enter the script below:
Script
procedure Variable2OnCalc(var value: Variant);beginVariable2.DisplayFormat := Option.GetFieldValue('StockPriceDisplayFormat'); // Set Display FormatValue := Document_Detail.GetFieldValue('Amount')/Document_Detail.GetFieldValue('Qty');end; -
Click File > Save As & enter New report Name after done
Get Data Directly from DB
- Sometime in the report you might wanted some extra information but you not able to select in the report design. So you had to self query to get the extra information.
Get Single Field
-
Example 1 - Get Shelf Field from Maintain Item
- Below is Example are doing following actions using Variable
- At Sales Invoice, get the Shelf field from Maintain Item

-
Click on SubRptNorm: Document_Detail
-
Select the Variable button (the Calculator icon)
-
Click on the place to be print/shown.
-
Click on Calc Tab

-
Right click here & Select Event & find the component just now we had placed (eg Variable2)
-
Click OnCalc
-
Click here & enter the script below:
Script
procedure Variable2OnCalc(var value: Variant);var s: string;begins := 'SELECT Shelf FROM ST_ITEM ' +'WHERE CODE=' + QuotedStr(Document_Detail.GetFieldValue('ItemCode'));Value := Trim(DBSQL_GetFieldValue(s));end; -
Click File > Save As & enter New report Name after done
Example 2 - Get Picture Field from Maintain Item
Below is Example are doing following actions using Image
At Sales Invoice, get the Picture field from Maintain Item
- Steps
-
Click on SubRptNorm: Document_Detail
-
Select the Image button (the Mountain & sun icon)
-
Click on the place to be print/shown.
-
Click on Calc Tab
-
Right click here & Select Event & find the component just now we had placed (eg Image1)
-
Click OnPrint
-
Click here & enter the below script
Script
procedure Image1OnPrint;var s: string;begins := 'SELECT Picture FROM ST_ITEM ' +'WHERE Code='+ QuotedStr(Document_Detail.GetFieldValue('ItemCode'));Image1.Visible := DBSQL_GetPicture(s, Image1.Picture);end; -
Click File > Save As & enter New report Name after done
Example 3 - Get Document Created UserName from Audit
Below is Example is to Get the who created the Document from Audit Table.
- Steps
-
Select the Variable button (the Calculator icon)
-
Click on the place to be print/shown.
-
Click on Calc Tab
-
Right click here & Select Event & find the component just now we had placed (eg Variable2)
-
Click OnCalc
-
Click here & enter the below script:
Script
procedure Variable2OnCalc(var value: Variant);var s: string;begins := 'SELECT UserName FROM AUDIT WHERE UPDATEKIND=''I'' ' +'AND REFERENCE LIKE ' +QuotedStr('%'+Main.GetFieldValue('DocNo')+'%Code: '+ //Delete this line for JV & CBMain.GetFieldValue('Code')+ //Delete this line for JV & CB',%');Value := Trim(DBSQL_GetFieldValue(s));end; -
Click File > Save As & enter New report Name after done
Example 4 - Get From Doc No. in Sales Invoice
Below is Example is to Get the From Document Number at Invoice Header.
- Steps
-
Select the Variable button (the Calculator icon)
-
Click on the place to be print/shown.
-
Click on Calc Tab
-
Right click here & Select Event & find the component just now we had placed (eg Variable2)
-
Click OnCalc
-
Click here & enter the below script
Script
procedure Variable2OnCalc(var value: Variant);var s, V : string;begins := 'SELECT First 1 FromDocType FROM SL_IVDTL '+'WHERE Dockey=' + Main.GetFieldValue('Dockey') +' AND FROMDOCTYPE IS NOT NULL';V := Trim(DBSQL_GetFieldValue(s));if Trim(V) \<> '' then begins := 'SELECT DocNo FROM SL_' + v +' WHERE DocKey=(SELECT First 1 FromDockey FROM SL_IVDTL '+'WHERE Dockey=' + Main.GetFieldValue('Dockey') +' AND FROMDOCTYPE IS NOT NULL)';Value := Trim(DBSQL_GetFieldValue(s));end elseValue := '';end; -
Click File > Save As & enter New report Name after done