View
214
Download
1
Category
Tags:
Preview:
Citation preview
Report ScriptsBaanERP 5.0c Tools
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Training objectivesTraining objectives
Insight in:• the structure and operation of reports, report
scripts and sessions• the main functions of BAAN-C• application possibilities of report scripts
Skills in:• construction and customization of report scripts
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Design EnvironmentDesign Environment
0101110110
T TT
OPER_001
tdB50O_c_cus1 tpB50O_c_cus1
DSGN_001
T TT
Ontwikkelaar
tdB50O_c_cus2 tpB50O_c_cus2
0101110110
0101110110
0101110110
0101110110
0101110110
0101110110
0101110110
0101110110
0101110110
tdB50_c tpB50_c
B50Sc
tdB50U_c_stnd tpB50U_c_stnd
Relation report/session (1)Relation report/session (1)
Printsession
form
0101110110
object report main table
Relation report/session (2)Relation report/session (2)
Printsession
form
0101110110
object report 1 main tablereport 2
Relation report layout/report scriptRelation report layout/report script
Applicatie Dictionary Runtime Dictionary
application
pakket dmversie a
forms
nedmodule oes
forms
engmodule oes
tools
1010100011
If … then ……else …...endif
Reportlayout
Report script(BAAN-C)
Report objectCompile
Application Dictionary Runtime Dictionary
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Usage of report scriptsUsage of report scripts
• Complex calculations• Complex field expressions
• Complex layout conditions• Complex field conditions• Complex aggregate expressions
• Reading of not related tables
Structure report scriptStructure report script
• Sections without subdivision• Sections with subsection(s)
Sections without subdivisionSections without subdivision
• Declaration• Before.program• After.program
• Functions
Declaration variables + tables
Initialization variables
Release allocated memory space
Define own functions
Sections with subsection(s)Sections with subsection(s)
• before.report.<seq.nr.>
• header.<seq.nr.>
• before.<field name>.<seq.nr.>
• detail.<seq.nr.>
• after.<field name>.<seq.nr.>
• footer.<seq.nr.>
• after.report.<seq. nr.>
• field.<text field name>
Subsection(s)
after.layout
Actions after printing
before.layout
Actions before printing
before.print
Examples - Examples - DeclarationDeclaration
declaration:string description(30) | Item descriptionlong tot.number | Total number of items per warehousedouble tot.amount | Total amount per warehouse
By means of data types
declaration:domain cudscr description | Item descriptiondomain cuquan tot.number | Total number of items per warehousedomain cupris tot.amount | Total amount per warehouse
By means of domains
Examples - Examples - Before.program, detail and Before.program, detail and after.fieldafter.field
before.program:tot.number = 0tot.amount = 0
detail.1:after.layout:
tot.number = tot.number + cuoes020.quantot.amount = tot.amount + (cuoes020.quan * cuoes001.spri)
after.cuoes020.cwar.1:after.layout:
tot.number = 0tot.amount = 0
BAAN-C syntaxBAAN-C syntax
• Program structures• Operators• Predefined variables and functions• Special report variables and functions
Program structuresProgram structures
if....then....else.....endif
on.....case..:...case...:..default:...endcase
while......endwhile
repeat....until.......
for....=....to.....step....endfor
break/continue
<condition> ? <expression-1> : <expression-2>
Program structures - Program structures - On caseOn case
on case cuoes001.igpc:
case “010”: newprice = 1.10 * cuoes001.spribreak
case “015”: newprice = 1.25 * cuoes001.spribreak
case “032”: newprice = 1.15 * cuoes001.spribreak
case “067”: newprice = 1.35 * cuoes001.spribreak
default: newprice = 1.05 * cuoes001.spribreak
endcase
OperatorsOperators
Mathematical operators
+ - * / \ &
Logical operators
AND OR NOT
Relational operators
= <> > < >= <=
EQ NE GT LT GE LE
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Predefined variablesPredefined variables
logname$ (BAAN user code)
user.type$ (User type: Normal or Super)
date$ (Current date, format DDMMYY)
time (Current time, format HHMM)
language$ (Current language code)
free$ (Free to use variable)
curr.pacc$ (Current Package Combination)
prog.name$ (Session name)
Predefined functionsPredefined functions
date.num(), num.to.date$(), date.to.num()shiftl$(), shiftr$(), shiftc$()strip$()edit$()get.compnr()get.company()tt.user()getenv$()sprintf$()toupper$(), tolower$()lval(), val(), str$()form.text$()
Special report variablesSpecial report variables
lattr.print
lattr.textexpand
lattr.lineno
lattr.break
lattr.enddata
lattr.prline
spool.pg.length
spool.pg.width
spool.device
Special report functionsSpecial report functions
page()
to.page()
skip()
skip.to()
layout.again()
reset.suppress()
need()
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Embedded SQLEmbedded SQL
Select <Fields>
From <Table(s)>
Where <Condition>
Selectdo
<Action(s) on each selected record>
Selecteos
<Action(s) after last selected record>
Selectempty
<Action(s) if no records are selected>
Selecterror
<Action(s) in case of an error>
Endselect
First and second degree reference First and second degree reference tablestables
Item groups
igpc dscrcuoes010
10 autos
Items
item igpccuoes001
1017 bmw
Stockmaintenance
itemcuoes020
171
Reading tables with embedded SQLReading tables with embedded SQL
declaration:table tcuoes010
detail.1:before.layout:
select cuoes010.dscrfrom cuoes010where cuoes010.igpc=:cuoes001.igpcselectdoendselect
Report script Stock Maintenance
where cuoes010._index1={:cuoes001.igpc}
Item groups
Items
Stockmaintenance
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Own functionsOwn functions
• Type• long, double, string, domain, void
• Prototype• declaration
• Definition• functions
• Call• before.program, detail, et cetera
Own functions - Own functions - type voidtype void
declaration:function fill.arrays()
detail.1:before.layout:
fill.arrays()
functions:function fill.arrays(){
tot.stock(ap1) = tot.stock(ap1) + cuoes001.stcktot.StockValue(ap1) = tot.StockValue(ap1) +(cuoes001.stck*cuoes001.spri)
}
Prototype
Call
Definition
(Not mandatory)
Own functions - Own functions - type doubletype double
declaration:function double incl_vat(double spri, double perc)
double price.incl.vat
detail.1:before.layout:
price.incl.vat = incl_vat(cuoes001.spri, cuoes012.perc)
functions:function double incl_vat(double spri, double perc){
double i | local variablei = spri + (spri * (perc / 100))return i
}
Call
Definition
Prototype
ArraysArrays
• Table/matrix• Maximal 4 dimensions• Data type: long, double, string• Usage: collect + print subtotals
Arrays - Arrays - Declaration (1)Declaration (1)
declaration:
long tot.stock(5)
double tot.StockValue(5)
string GroupDescription(30,5)
30
tot.stock(2)
tot.StockValue(2)
GroupDescription(1,2)
Arrays - Arrays - Declaration (2)Declaration (2)
declaration:
long tot.stock(5,3)
double tot.StockValue(5,3)
string GroupDescription(30,5,3)
30
tot.stock(4,2)
tot.StockValue(4,2)
GroupDescription(1,4,2)
Arrays - Arrays - FillFill
before.program:ap1 = 0
before.cuoes001.igpc.1:before.layout:
ap1 = ap1 + 1GroupDescription(1,ap1)=cuoes010.dscr
detail.1:after.layout:
tot.stock(ap1) = tot.stock(ap1) + cuoes001.stcktot.StockValue(ap1) = tot.StockValue(ap1) +(cuoes001.stck*cuoes001.spri)
30
Arrays - Arrays - PrintingPrinting
before.program:ap2 = 1
after.report.2:before.layout:
if ap2 <= ap1 thenlattr.print = true
elselattr.print = false
endif
after.layout:if ap2 < ap1 then
ap2 = ap2 + 1layout.again()
endif
30
Macro’sMacro’s
declaration:#define MAX 5
long tot.stock(MAX)
double tot.StockValue(MAX)
string GroupDescription(30,MAX)
30
AgendaAgenda
• Design Environment• Relation report/session• Relation report layout/report script• Usage of report scripts• Structure report script• BAAN-C syntax• Reading tables with embedded SQL• Own Functions• Arrays• Macros• Debugger
Debugger - Debugger - UseUse
• Track errors• Run program step by step• “Trace” variables
Debugger - Debugger - OptionsOptions
[s] Step
[b] “linenr” Break at “linenr.”
[t] “var” Trace “var”
[stop if] “expr” Stop in case “expr”
[stop in] “func” Stop in “function”
[g] “linenr” Go to “linenr”
[j] “func” Jump to “function”
[c] Continue
[q] Quit debugger
The EndThe End
Report ScriptsBaanERP 5.0c Tools
Recommended