PANTHEON™ Help

 Toc
 Početna stranica
[Collapse]PANTHEON
 [Collapse]PANTHEON priručnici
  [Expand]Vodič kroz Datalab PANTHEON Farming
  [Expand]Vodič za mobilni POS
  [Expand]Vodič po DataLab PANTHEON™-u
  [Expand]Vodič po PANTHEON Vet
 [Collapse]PANTHEON korisnički priručnici
  [Expand]Korisnički priručnik za DataLab PANTHEON™
  [Expand]Korisnički priručnik za PANTHEON Vet
  [Expand]Korisnički priručnik za PANTHEON maloprodaju
[Collapse]PANTHEON Web
 [Collapse]Vodiči po PANTHEON Web
  [Expand]Vodič po PANTHEON Web Light-u
  [Expand]Vodič za PANTHEON Web Terminal
  [Expand]Arhiva starih proizvoda
  [Expand]Vodič po PANTHEON Web Legal
 [Collapse]Korisnički priručnici za PANTHEON Web
  [Expand]Početak rada s PANTHEON Web-om
  [Expand]Korisnički priručnik za PANTHEON Web Light
  [Expand]Korisnički priručnik za PANTHEON Web Terminal
  [Expand]Korisnički priručnik za PANTHEON Web Legal
  [Expand]Arhiva starih proizvoda
[Collapse]PANTHEON Granule
 [Collapse]Vodič po PANTHEON Granulama
  [Expand]Granule za Servis na terenu
  [Expand]Granula Kadrovi
  [Expand]Granula Putni nalozi
  [Expand]Granula Dokumenti i Zadaci
  [Expand]Granula Kontrolna tabla
  [Expand]Granula B2B narudžbe
  [Expand]Inventar Fiksne Imovine Granula
  [Expand]Inventar Skladišta Granula
 [Collapse]Korisnički priručnik za PANTHEON Granule
   Početak
   Korištenje PANTHEON Granula u imaginarnom poduzeću Tecta
  [Expand]PANTHEON Granule i aktivacija
  [Expand]Granula Kadrovi
  [Expand]Granula Putni nalozi
  [Expand]Granula Dokumenti i zadaci
  [Expand]Granula B2B narudžbe
  [Expand]Granula Nadzorna ploča
  [Expand]Granula Servis na terenu
   Česta pitanja i odgovori
  [Expand]Inventar dugotrajne imovine
  [Expand]Granula Inventura skladišta
   Arhiva

Load Time: 359,3853 ms
"
  6613 | 1 | |
Label


Datalab functions examples

 

An example of using a function dlGetSQLString


 
The most common example of using a function is to display the entire SELECT statement that is specified for the selected dataset when the report is opened. Most often, a SELECT statement appears, which belongs to a band called Detail:

begin
   ShowMessage(dlGetSQLString(Detail.Dataset));
end.

 

 An example of using a function dlStringReplace



On the 10A report (Goods | Invoices Issued Reports menu) add a band with the name Detail, serial numbers display that belong to the selected position and the selected invoice. The SQLExp function returns all records, each in its own row, but we want to display serial numbers in one row, separated by commas.
 
[dlStringReplace(SQLExp('SELECT acSerialNo, FROM tHE_MoveItemSerialNo WHERE acKey = ''' + <qReportIzpis."acKey"> + ''' AND acIdent = ''' + <qReportIzpis."acIdent"> + '''  GROUP BY acSerialNo UNION ALL SELECT acSerialNo FROM tHE_OrderItemSerialNo WHERE acKey = ''' + <qReportIzpis."acKey"> + ''' AND acIdent = ''' + <qReportIzpis."acIdent"> + ''' GROUP BY acSerialNo ORDER BY acSerialNo'), #13#10, ', ', 'rfReplaceAll', '')]
 


An example of using a function GetOurCompany


Name of our company: [GetOurCompany]
 


An example of using a function GetSubject



[GetSubject(<qSubjIzpis."acSubject">, <qSubjIzpis."acName">)]
[GetSubject(<qSubjIzpis."acSubject">, '']


 

An example of using a function

 

This chapter presents examples of using aggregate functions, an example of using GetForValue, SQLEXP, and IIF. Examples of using functions specifically written for PANTHEON and not included in the standard FastReport are explained separately in the Datalab Functions category.


 

An example of using the IIF function


The next example of using the IIF function is on the 22G report, which can be found in the program in the Goods | VAT menu only for Croatian legislation. The term first displays the name of the subject. If a VAT number is also entered, it will also print it in the new line. For the transition to the new line, the character sequence LF (No. 13) and CR (No. 10) was used.

[IIF(<qReportIzpis."acCode"> = '', <qReportIzpis."acSubject">,
<qReportIzpis."acSubject"> + Chr(13) + Chr(10)+ <qReportIzpis."acCode">)]


If nesting the IIF function, it quickly becomes opaque (non-transparent), so it's better to replace it with the if statement in the code. A code equivalent to the above expression is

procedure Memo19OnBeforePrint(Sender: TfrxComponent);
begin
if (<qReportIzpis."acCode"> = '' then
  Memo19.Text := <qReportIzpis."acSubject">
else
  Memo4.Text := <qReportIzpis."acSubject"> + Chr(13) + Chr(10)+ <qReportIzpis."acCode">;
end;

 

An example of using the GetFormValue function

 

In case of using the GetFormValue function, write down the term that returns the warehouse on the invoices issued thet is located in Goods | Invoices issued report | Invoices issued/Profit margin report. The name of the window is PrometObracunIzdRac, the name of the input field in which we select the warehouse is fSkladisce.

[GetFormValue('PrometObracunIzdRac.fSkladisce')]

The names of some document windows are composed of a base and a suffix representing the type of document. If we want to print the referent on the issue, we write down the term

[GetFormValue('PrometIzdDob3000.fReferentZap')]

It will only be printed for the document type 3000, but not for all others. In order to print for all document types, we have to write it down like this

[GetFormValue('PrometIzdDob'+<tbLookPoslDog."acDocType">+'.fReferentZap')]

Kjer dataseta tbLookPoslDog ni na voljo, lahko dobimo naziv okna iz številke dokumenta. Na naročilih kupcev zapišemo takole

Where tbLookPoslDog datase is not available, we can get the name of the window from the document number. On sale orders we write down:


[IIF(Copy(<qReportIzpisD."acKeyView">,Pos('-',
<qReportIzpisD."acKeyView">)+4,1) ='-',
GetFormValue('Naroc'+Copy(<qReportIzpisD."acKeyView">,Pos('-',
<qReportIzpisD."acKeyView">)+1,3)+'0.fReferentZap'),
GetFormValue('Naroc'+Copy(<qReportIzpisD."acKeyView">,Pos('-',
<qReportIzpisD."acKeyView">)+1,4)+'.fReferentZap'))]

 

An example of using the GetFormValue with Date function



The GetFormValue function returns the date in the yyyy/mm/dd format, but usually we want it in the dd.mm.yyyy or d.m.yyyy format.

The best example is when there are no data that you need in the dataset, there are notifications of outstanding commitments that are in the program in the Financials | Reports | Outstanding items.

The following expression returns the date of the state in the yyyy/mm/dd format:


[GetFormValue('GKOdprtePostavke.fDatumStanja')]

The term also has a disadvantage that if the date is not entered, it will print 1900/01/01.
We must check whether the date is entered before printing with the IIF function:

[IIF(GetFormValue('GKOdprtePostavke.fDatumStanja')= '1900/01/01','',
GetFormValue('GKOdprtePostavke.fDatumStanja'))]


If we want to print the date in the format dd.mm.yyyy, we need to change the order of the numbers in the report:

[IIF(GetFormValue('GKOdprtePostavke.fDatumStanja') ='1900/01/01','',
Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),9,2)+'.'+
Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),6,2)+'.'+
Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),1,4))]


The date of the situation in the d.m.yyyy format is obtained by turning the day of the month and month into a number and then back to the text:

[IIF(GetFormValue('GKOdprtePostavke.fDatumStanja') ='1900/01/01','',
IntToStr(StrToInt(Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),9,2)))
+'.'+IntToStr(StrToInt(Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),6,2)))
+'.'+Copy(GetFormValue('GKOdprtePostavke.fDatumStanja'),1,4))]
 

 

An example of using GetFormValue function - example of non-text object


Funkcijo GetFormValue lahko uporabimo tudi za objekte, ki ne predstavljajo besedila. V tem primeru nam vrne najpomembnejšo lastnost tega objekta. Vrnjena vrednost običajno ni primerna za neposreden izpis, lahko pa jo uporabljamo na samem izpisu. Lahko npr. izpišemo besedilo, ki je v oknu izpisano pri tej vrednosti.

Kot primer vzemimo skupino radijskih gumbov z imenom grpGroupBy na novi konto kartici. Naziv okna je GLAccountCard. Za to vrsto objekta funkcija vrne lastnost ItemIndex, ki določa, kateri gumb je izbran. V našem primeru ta lastnost določa, kako naj se združujejo podatki in skrivajo pasovi na izpisu. Vrednost, ki jo vrne funkcija, zapišemo v spremenljivko nGroupBy in potem glede na njeno vrednost skrivamo pasove na izpisu, kot npr. v proceduri SubjektFooterOnBeforePrint.


  var nGroupBy: Integer;
  ...
  procedure SubjektFooterOnBeforePrint(Sender: TfrxComponent);
  begin
    if nGroupBy <= 1 then
      SubjektFooter.Visible := False;
  end;
  ...
  nGroupBy := GetFormValue('GLAccountCard.grpGroupBy');




Nekaj bolj zapletenih primerov je na izpisu 04C, ki je v programu v meniju Blago | ECL/Intrastat | ECL – uvoz in na izpisu 3AR na izpisu personalne mape. V programu pridemo do njega tako, da v personalnih mapah, ki so v meniju Kadri | Personalne mape, kliknemo na gumb Izpisi.

 

Primer uporabe funkcije SQLExp - delo z datumskimi polji



Na kopijo izpisa 241, ki je v programu v meniju Blago | Izdaja | Dokument (npr. 3000 – Veleprodaja) dodamo saldo prejemnika računa na kontu 2200 na dan izstavitve računa. Pri tem je pomembno, da je datum formatiran v obliki yyyymmdd.

[SQLExp('SELECT SUM(anValDebit-anValCredit) from tHE_AcctTransItem where acAcct = 2200 and acSubject=''' + <qReportIzpisD."acReceiver"> + ''' and adDateDoc <= ''' + FormatDateTime('yyyymmdd',<qReportIzpisD."adDateInv">) + '''')]

 

Primer uporabe funkcije SQLExp - delo s števili

 


V tem primeru želimo na izpisu 156, ki je v programu v meniju Blago | Obračun materialnih prometov izpisati količino v alternativni merski enoti (EM2).

Ker nimamo na voljo faktorja za pretvorbo količine v primarni merski enoti (EM) v EM2, ga moramo dobiti iz šifranta merskih enot s pomočjo funkcije SQLExp.

To naredimo z naslednjim izrazom:

[SQLExp('SELECT anUMToUM2 from tHE_SetItem where acIdent = '''+ <qReportIzpis."acIdent">+'''')]

Zgornji izraz vrne število kot besedilo. Sedaj želimo izpisati količino, izpisano v EM2, zato moramo vrednost, ki smo jo dobili, s funkcijo dlStrToFloatDef pretvoriti v število. Potem še delimo količino v EM z dobljenim faktorjem, pri čemer zaradi preverjanja deljenja z nič, raje kot navadno deljenje, uporabimo funkcijo dlDiv. Na koncu dobimo:

[dlDiv(<qReportIzpis."anBegState">, dlStrToFloatDef(SQLExp('SELECT anUMToUM2 from tHE_SetItem where acIdent = '''+ <qReportIzpis."acIdent"> +''''), 1))]

 

Primer uporabe funkcije SQLExp - branje podatkov iz okna v programu


Naslednji primer lahko naredimo na kopijo izpisa 16B, ki je v programu v meniju Blago | Obračun izdanih računov | Obračun računov in razlike v ceni. Če je v oknu izbrano skladišče, izraz izpiše celotno zalogo identa, sicer izpiše zalogo samo v izbranem skladišču.

Okno v programu, iz katerega se zažene izpis, se imenuje PrometObracunIzdRac, vnosno polje, v katerem izberemo skladišče, pa ima naziv fSkladisce. Izraz, ki vrne besedilo v tem objektu, smo že spoznali:

[GetFormValue('PrometObracunIzdRac.fSkladisce')]

Najprej pogledamo, ali je izbrano kako skladišče. Če ni, se izvede prvi izraz SQLExp, ki vrne celotno zalogo izbranega identa v vseh skladiščih, sicer pa drugi, ki vrne zalogo identa samo v izbranem skladišču.

[IIF (GetFormValue('PrometObracunIzdRac.fSkladisce') = '',
SQLExp('select SUM (anStock) from tHE_Stock where acIdent = ''' +
<qReportIzpis."acIdent"> + ''''),
SQLExp('select anStock from tHE_Stock where acIdent = ''' +
<qReportIzpis."acIdent"> + ''' and acWarehouse = ''' +
GetFormValue('PrometObracunIzdRac.fSkladisce') + ''''))]


 

Primer uporabe funkcije SQLExp s kompleksnim stavkom select



Posebno obravnavo si zasluži izraz na izpisu 3AR, ki vrne ali je delavec invalid ali ne.

Ta podatek ni neposredno zapisan v bazi, ampak je v njej zapisana kategorija invalidnosti, in sicer v polju acDisabilityCode v tabeli tHR_PrsnHealth. Ker se kategorija invalidnosti posameznega delavca lahko spreminja, moramo dobiti tisto, ki je bila vpisana nazadnje. Datum spremembe invalidnosti je zapisan v polju adCreationDate v isti tabeli. Z naslednjim izrazom dobimo zadnji datum, ko se je spremenila kategorija invalidnosti za izbranega delavca.

[SQLExp('select max(adCreatonDate) from tHR_PrsnHealth where acWorker = ''' + <qryDelavec."acWorker"> + '''')]

Potem s spodnjim izrazom dobimo kategorijo invalidnosti delavca

[SQLExp('select acDisabilityCode from tHR_PrsnHealth where acWorker = ''' + <qryDelavec."acWorker"> + ''' and adCreatonDate = (select max(adCreatonDate) from tHR_PrsnHealth where acWorker = ''' + <qryDelavec."acWorker"> + ''')')]

Če v zgornjem izrazu polje acDisabilityCode zamenjamo z 'DA', izraz vrne 'DA', če je delavec invalid, sicer vrne prazen niz. Ker hočemo, da v primeru, ko delavec ni invalid, izraz vrne 'NE', damo izraz v pogojni stavek IIF in končno dobimo

[IIF(SQLExp('select ''DA'' from tHR_PrsnHealth where acWorker = ''' + <qryDelavec."acWorker"> + ''' and adCreatonDate = (select max(adCreatonDate) from tHR_PrsnHealth where acWorker = ''' + <qryDelavec."acWorker"> + ''' and acDisabilityCode > ''0'')') = 'DA','DA','NE')]

 

Primer uporabe funkcije SQLExp - grupiranje po polju, ki ga ni v datasetu


Zelo neobičajna in koristna je uporaba funkcije SQLExp za sortiranje in grupiranje po polju, ki je ni v datasetu.

Za osnovo bomo vzeli izpis 164, ki je v programu v meniju Blago | Obračun izdanih računov | Obračun računov in razlike v ceni. Najprej ustvarimo kopijo, na kateri bomo delali. Podatke bomo grupirali po izdajatelju računa in sortirali po izdajatelju in številki računa.

Lastnosti Condition GroupHeaderja priredimo vrednost

SQLExp('select G.acIssuer from tHE_Move G where G.acKey = ''' + <qReportIzpis."acKey"> + ''''),

zamenjamo napis, ki opisuje podatek, po katerem grupiramo, za sam podatek pa vnesemo isto kot zgoraj, le da damo vse skupaj še v oglate oklepaje (kot je prikazano na sliki). Za razvrščanje v šifrantu izpisov napišemo:

(select G.acIssuer from tHE_Move G where G.acKey = P.acKey), G.acKey



  
 

  

     


Rate this topic
Was this topic usefull?
Comments
Comment will also bo visible in forum!