Fast Report - Get Data Directly from DB: Difference between revisions

From eStream Software
Line 19: Line 19:
:01. Click the Red A Icon.
:01. Click the Red A Icon.
:02. Click on the place to be print/shown.
:02. Click on the place to be print/shown.
:03. Click on '''Events''' tab
:03. Right Click the Memo.
:04. Double Click '''OnBeforePrint'''
[[File:FR-DirectDB-04.jpg|center]]
:05. Enter below script
:04. Select '''Stretch'''
:05. Click on '''Events''' tab
:06. Double Click '''OnBeforePrint'''
:07. Enter below script
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="delphi">
procedure Memo18OnBeforePrint(Sender: TfrxComponent);
procedure Memo18OnBeforePrint(Sender: TfrxComponent);
Line 37: Line 40:


[[File:FR-DirectDB-02.jpg|center]]
[[File:FR-DirectDB-02.jpg|center]]
:06. Click '''Code''' Tab.
:08. Click '''Code''' Tab.
:07. Enter below script at the '''First''' line
:09. Enter below script at the '''First''' line
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="delphi">
var pST_Item : pointer;
var pST_Item : pointer;
Line 45: Line 48:


[[File:FR-DirectDB-03.jpg|800 px|center]]
[[File:FR-DirectDB-03.jpg|800 px|center]]
:08. Scroll till the end of the Code
:10. Scroll till the end of the Code
:09. Enter below script in between '''begin''' and '''end.'''
:11. Enter below script in between '''begin''' and '''end.'''
<syntaxhighlight lang="delphi">
<syntaxhighlight lang="delphi">
begin
begin
Line 52: Line 55:
end.
end.
</syntaxhighlight>
</syntaxhighlight>
:10. Save the report.
:12. Save the report.


===Example 2 - Get RefCost Field from Maintain Item===
===Example 2 - Get RefCost Field from Maintain Item===

Revision as of 07:22, 13 November 2015

Introduction

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.

There are 2 ways to Get the data directly from Database

  • Simple Query
  • Advance Query

Simple Query

Only available SQL Accounting Version 723 & above

Example 1 - Get Shelf Field from Maintain Item

Below is Example are doing following actions

  • At Sales Invoice to get Shelf field from Maintain Item

Last Script Update : 13 Nov 2015

Steps

FR-DirectDB-01.jpg
01. Click the Red A Icon.
02. Click on the place to be print/shown.
03. Right Click the Memo.
FR-DirectDB-04.jpg
04. Select Stretch
05. Click on Events tab
06. Double Click OnBeforePrint
07. Enter below script
procedure Memo18OnBeforePrint(Sender: TfrxComponent);
var V : Variant;                            
begin
  //Get Shelf From ST_Item
  V := CacheQuery_GetValue(pST_Item, [<Document_Detail."ItemCode">], 'Shelf');
    
  if not VarIsNull(V) then
    Memo18.Text := V else
    Memo18.Text := '';
end;


FR-DirectDB-02.jpg
08. Click Code Tab.
09. Enter below script at the First line
var pST_Item : pointer;


FR-DirectDB-03.jpg
10. Scroll till the end of the Code
11. Enter below script in between begin and end.
begin
  pST_Item := CacheQuery_New('SELECT Shelf FROM ST_ITEM WHERE Code=:Code');
end.
12. Save the report.

Example 2 - Get RefCost Field from Maintain Item

Below is Example are doing following actions

  • Sales Invoice to get RefCost field from Maintain Item
  • Use RefCost * Qty in Sales Invoice

Last Script Update : 13 Nov 2015

Steps

01. Click the Red A Icon.
02. Click on the place to be print/shown.
03. Click on Events tab
04. Double Click OnBeforePrint
05. Enter below script
procedure Memo18OnBeforePrint(Sender: TfrxComponent);
var V : Variant;                            
begin
  //Get RefCost*Qty
  V := CacheQuery_GetValue(pST_Item_UOM, [<Document_Detail."ItemCode">, <Document_Detail."UOM">], 'RefCost');        

  if not VarIsNull(V) then
    V := V * <Document_Detail."Qty"> else
    V := 0;
  Memo18.Text := FormatFloat(<Option."AccountingValueDisplayFormat">, V);
end;
06. Click Code Tab.
07. Enter below script at the First line
var pST_Item_UOM : pointer;
08. Scroll till the end of the Code
09. Enter below script in between begin and end.
begin
  pST_Item_UOM := CacheQuery_New('SELECT RefCost FROM ST_ITEM_UOM WHERE Code=:Code AND UOM=:UOM');
end.
10. Save the report.

Advance Query

  • Coming Soon....

See also