BCS Fast Reports Reusability

A regular recurring theme when developing software there exists scenarios where an application can have more than one entity using the facilities or database and reports.
The unique id number must exists for each entity then master detail relationships are employed to traverse the applications facilities.
The main difference in the reporting facilities are the headings used by each entity.
To promote reusability of the reports subsystem properties are established at the component level that allows for changing headings to reflect the appropriate entity.
When the component is used the following code is available to support the multi entity application.
[codesyntax lang=”delphi”]

  Procedure: btnTestCompClick
  @Author Mr. Arch Brooks, Software Engineer, Brooks Computing Systems LLC
  @Version 1.0
  Date:      09-May-2013
  @Param  Sender TObject Primary Object For Dialog
  Result:    None
  ----------------------------------------------------------------------------- }
procedure TBCSJeiSvccmpC.btnTestCompClick(Sender: TObject);
  BCSJeiSvcCmp1.RCaption := 'BCS Costs of Services';
  BCSJeiSvcCmp1.RCid := 1;
  BCSJeiSvcCmp1.RH1 := 'Brooks Computing Systems, LLC';
  BCSJeiSvcCmp1.RH2 := 'P. O. Box 7682';
  BCSJeiSvcCmp1.RH3 := 'Columbia, Missouri 65205-7682';
  BCSJeiSvcCmp1.RH4 := 'Costs of Services';

Notice the components properties are all preceded by a capital R the the property description.  This is a standard enforced to properly identify and group all component properties.
The definition of the frxMemoView class is found in frxClass.  To access it be sure to include it in a uses statement.
uses frxClass;
The following code snippet show how the component with implement the available properties.
[codesyntax lang=”delphi”]

 Procedure: Execute
 @Author Mr. Arch Brooks, Software Engineer, Brooks Computing Systems LLC
 @Version 1.0
 Date:      09-May-2013
 Arguments: None
 @return    Boolean T Sucessful Execution F Unsucessful Execution
function TBCSJeiSvcCmp.Execute: BooLean;
  MemView: TfrxMemoView;
  result := false;
  Application.CreateForm(TBCSJeiSvcdm, BCSJeiSvcdm);
  if RCid = 0 then
    RCid := 1;
  BCSJeiSvcdm.RCid := RCid;
  BCSJeiSvcdm.ataei_svcs.Active := false;
  BCSJeiSvcdm.ataei_svcs.Filter := 'cid = ' + IntToStr(RCid);
  BCSJeiSvcdm.ataei_svcs.Filtered := true;
  BCSJeiSvcdm.ataei_svcs.Active := true;
  Application.CreateForm(TBCSJeiSvcC, BCSJeiSvcC);
  MemView := BCSJeiSvcdm.frxReport1.FindObject('Memo2') as TfrxMemoView;
  MemView.Text := RH1;
  MemView := BCSJeiSvcdm.frxReport1.FindObject('Memo3') as TfrxMemoView;
  MemView.Text := RH2;
  MemView := BCSJeiSvcdm.frxReport1.FindObject('Memo4') as TfrxMemoView;
  MemView.Text := RH3;
  MemView := BCSJeiSvcdm.frxReport1.FindObject('Memo5') as TfrxMemoView;
  MemView.Text := RH4;
  if RCaption > '' then
    BCSJeiSvcC.Caption := RCaption;
  if BCSJeiSvcC.ShowModal = id_OK then
    result := true;

Notice the RCid (company / entity id) property is set to one if it is not initialized.  Also notice the RCid is used in the filter for the data table.  This ensures only the records for the desired entity are exposed.
Next the headings are set along with the dialog caption.  These features ensures our application is usable by multiple companies or entities without changing the core functionality of the application.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.

Leave a Reply

Your email address will not be published. Required fields are marked *