Você está na página 1de 16

Title

Report Automation using Perl and Cognos macro


Author:
Sumit Kumar Mahato, Project Engineer (WT
Reviewed by:
Koushi! "anerjee, Project Manager (WT
W#$TE PAPER Report Automation using Perl and Cognos macro
Abstract
A %er& common re'uirement o( most o( the )ata
*arehousing projects is deli%ering the +nal Reports to the
intended "usiness ,sers- All the *arehouse process +nall&
culminates to good reporting- Whether *e ha%e conclusi%e
data, latest status o( Ke& process $ndicators or )ata mining
predictions all o( this matters onl& *hen the& are reported
on time to the right .usiness users- Manual reporting is
tedious and time consuming and it again in%ol%es dela&s
and spells less authorit&- So the ne/t o.%ious and sound
step is to automate the *hole reporting process, let the
.usiness user de+ne *hen and *hich report the& need,
thus .& automating the response *e achie%e a signi+cant
producti%it& impro%ement- We too had a similar o.jecti%e,
so here *e present as case stud& on a speci+c
implementation done on Automated Reporting in our
project 0ualit& Measures Re1Architecture-
Wipro Technologies Page 2 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
Table of Contents
1. BACKGROUN.....................................................!
". #NTROUCT#ON...................................................$
%. &N'#RON(&NT..................................................)
!. *ORK#NG O+ ,&R- CO&................................../
$. COGNO. (ACRO................................................11
). COGNO. T&(,-AT&..........................................1%
Wipro Technologies Page 3 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
1. Background
0ualit& Measures Re1Architecture Project
0ualit& Measures a glo.al application *hich consolidates
and .enchmar!s trade sampling results- The resulting
insights help to reduce the li!elihood and impact o( product
'ualit& incidents, and in(orm ho* 0ualit& Management
programs are directed-
This application earlier operated on se%eral technical
en%ironments including the Teradata data.ase- To get rid
o( signi+cant annual maintenance cost and to align
strategicall& *ith client2s "usiness $ntelligence architecture,
the *hole Teradata data.ase *as planned to .e replaced
along *ith all its applications- These actions contri.uted a
majorit& o( annual sa%ings to the client- These actions also
helped to reduce the Support Model comple/it& as the
support team no* has (e*er architecture components (or
maintenance-
A ne* data *arehouse in S03 Ser%er 4556 *as created and
all e/isting reporting and user inter(aces *ere redirected to
it- 7o impact to end1users *as e/pected (rom this project-
Automated Reporting using Cognos and Perl Scripts *as a
part o( the project- Some o( the Perl codes *ere changes
and all the templates *hich *ere interacting *ith the Were1
house *ere modi+ed- Major code changes *ere (or
retro+tting the e/isting Teradata %ersion o( code and
settings .& the ne* ones (or MS S03 Ser%er 4556-

Wipro Technologies Page 4 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
2. Introduction
We had to automate the reports *hose t&pe and (ormat
*ere prede+ned the +lter criteria (or customi8ing the report
data is pro%ided .& the end user *hen a particular report is
re'uested and then it is generated d&namicall&- The
templates (or such reports must .e created .e(orehand-
#ere *e are tr&ing to simulate a situation *here .usiness
user re'uests some +/ed 7 t&pes o( reports, he selects
their t&pe and their parameters (rom the (ront end-
All such re'uests are stored in a ta.le in data.ase, *hich
are later pic!ed .& our Report process to create the
reports- The t&pes o( reports are mapped to Cognos Report
templates and the parameters are mapped to the Cognos
Report prompts-
The Perl process coded in Pearl continuousl& scans a ta.le
and pic!s the re'uested report entries and in%o!es a
Cognos macro *hich calls the Cognos templates one .&
one, e/ecutes them and generates the report- The
generated reports are stored in the ser%er +le s&stem
(older, once the& are a%aila.le it *ould sho* in the (ront
end application, and the user could do*nload it (rom there-
Wipro Technologies Page 5 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
Bloc0 dia1ra2 describin1 full control 3ow
Wipro Technologies Page 6 of 16

Business User Front-end Application eports
Database Table storing
e!uest details report
t"pe and para#eters$
The Perl Process
is continuousl"
run %" a ser&ice$
Cognos
Perl Process
W#$TE PAPER Report Automation using Perl and Cognos macro
3. Environment
)W# MS S03 Ser%er 4556
STA9$79 :racle;i Enterprise
Edition
MART :racle;i Enterprise
Edition
Reporting C:97:S $mpromptu
<ersion =->-=4?-5
Coding 3anguage Perl
4. Working of Perl Codes
Wipro Technologies Page ' of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
"loc! diagram descri.ing control @o*-
The ,erl ,rocess
We ha%e (our major Perl scripts to achie%e the desired
(unctionalit&-
>- )irector& $n(ormation Perl Script
4- Starter Perl Script
A- Process Perl Script
?- Report Perl Script
"rie( implementation details o( the a.o%e Perl scripts-
Wipro Technologies Page ( of 16
)ontinuousl"
in&o*ed %" a
ser&ice$
+irector"
,nfor#ation
Perl -cript
-tarter Perl
-cript
Process Perl
-cript
eport Perl
-cript
)ognos
.acro
W#$TE PAPER Report Automation using Perl and Cognos macro
1. irectory #nfor2ation ,erl .cri4t: $t initiali8es all
the en%ironment %aria.les-
2. .tarter ,erl .cri4t: This Perl script starts all o( the
Bi/ed1Bormat Report real1time processes- The steps
(ollo*ed (or the same are:
a- Birst *e include standard su. routines )"$, WinA4,
WinA4::Process-
.- Calls director& in(ormation-pl/ *hich initiali8es all
en%ironment %aria.les-
c- $t connects to the data .ase and (etches (orm the
ta.le *hich stores the process codes, programs
their sleep time and the Ser%er name *here the&
should .e run- All these are sa%ed into arra&s li!e,
process arra&
program arra&
sleeptime arra&
d- Start a loop *hich *ill run till process arra& ma/-
Bor each process call the Process Perl script *ith
parameters Process $), Program 7ame and Sleep
time- Re(er (ollo*ing code snippet-
CcommandDlineE Fperl F - CP9MD"$7D)$R - F process-pl/ F -
Cprocess - F F - CsleepDtime - F F - CprogramDnameG
Cp E WinA4::Process::Create(CProg:.j,PER3-EHE,CcmdDline,5,
CWinA4::Process::)ETAC#E)DPR:CESS
I CWinA4::Process::CREATED7:DW$7):W,F-FG
3. ,rocess ,erl .cri4t
Wipro Technologies Page / of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
a- 9et Command13ine Parameters: Process $), Sleep
time and Program 7ame passed .& the starter perl
script, recei%e the arguments in %aria.les-
.- )e+ne command lines li!e:
CcmdDline E Fperl F - C PRD"$7D)$R - CpgmDnm - F F - CprcsDcdG
CmeDcmdDlineE Fperl F - C PRD"$7D)$R - F process-pl/ F -
CprcsDcd - F F - Csleeptime - F F - CpgmDnmG
c- 9et the process status (orm data data.ase
*hether it is acti%e or de1acti%e- ,pdate the status
to Acti%e i( it is not-
d- Bollo*ing code is used to spa*n the process,
i( (CcurrentDstatusDcd e' JAJ K
Ci E WinA4::Process::Create(CP:.j,
CPAT#DToDPER3DEHE,CcmdDline,5,
CWinA4::Process::)ETAC#E)DPR:CESS
I CWinA4::Process::CREATED7:DW$7):W,F-FG
i( (LCi K
M user de+ned (unction to !ill the process
,)BDdie(6,CpgmDnm - F F -
WinA4::BormatMessage( WinA4::9et3astError(G
N else K
Cpid E CP:.j1O9etProcess$)(G
CP:.j1OWait($7B$7$TEG
CP:.j1O9etE/itCode(CE/itCodeG
i( (CE/itCode LE 5 K
CprocessDmsgDdata E CprogramDnm - F rcE F - CE/itCode - F F -
WinA4::BormatMessage(CE/itCodeG
,)BD3ogger(CprcsDcd,A,CprcsDmsgDdataG
M Add Code to log message and issue commit to the )" handler-
N
N
N M End o( Spa*ning process-
e- Call the same code recursi%el& a(ter some sleep
time, using CmeDcmdDline as de+ned earlier in the
similar *a&-
Wipro Technologies Page 10 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
4. Re4ort ,erl .cri4t: This Push Report process in%o!es
Cognos to .uild report e/tensions- $t $nitiali8es
%aria.les .ased on Process Code- This single program
Controls all Cognos Report E/tension generation-
a- 9et the pending report e/tensions entered during
the Report re'uest and pass them to cognos-
.- ,pdate the report e/tension status and create a
@at +le o( (or the pending report e/tension to pass
to Cognos (or processing-
c- Start a loop (or multiple reports and get the Report
E/tension 9eneration )e+nition and .uild the
parameter string input to Cognos-
d- "uild the input to Cognos line
e- End the loop and Close the Blat Bile input (or
Cognos-
(- Kill the unmacA4-e/e and $mpAdmin-e/eJs and
spa*n the cognos .& calling the Cognos Macro
re(er to the (ollo*ing code:
CcmdDline E FrunmacA4-e/e F - C PRDC:97:SD)$R - FPPCognosDmacro-mc/FG
Ci E WinA4::Process::Create(CP:.j,
C0MRDC:97:SDEHE,CcmdDline,5,
CWinA4::Process::)ETAC#E)DPR:CESS
I CWinA4::Process::CREATED7:DW$7):W,F-FG
i( (LCi K
,)BDdie(6,CcmdDlineG
N
g- The Cognos Macro processes the re'uest and
generates the report +les-
h- 9et the Cognos return code and message created
.& the cognos script *e *ait (or > minute (or
cognos to complete each return code- This script
is (urther used to rename the report generated to
user (riendl& names-
i- 3og the report creation completion or (ailure
messages-
Wipro Technologies Page 11 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
5.Cognos Macro
Bunctional .loc! diagram
Wipro Technologies Page 12 of 16
)ognos
Te#plate 1
,nput
Pro#pts
)ognos
Te#plate 2
1ets data
fro# +W2
)ognos
Te#plate 3
1ets data
fro# hotfile
+W2
)ognos
.acro
eports
h
o
t
f
i
l
e
)atalog
W#$TE PAPER Report Automation using Perl and Cognos macro
The (ollo*ing are the major steps *e do in the Macro:
>- $n the Cognos Macro *e initiali8e %aria.les and speci(&
the log +le to .e used to log the steps o( Report
creation- There *e open a parameter +le, and read all
the cognos parameters li!e de.ug le%el, parameter
director&, log director&, report director& using a do
until loop-
4- 7e/t *e start the cognos process .& creating an :.ject
FCognos$mpromptu-ApplicationF- :pen the report
parameter +le and read the input report parameters to
+lter and customi8e the report according to the users2
re'uest- $nput report parameter +le is tilde(Q
separated parameter +le populated .& the Report Perl
script-
A- $t then opens the cognos catalog and re'uires the login
details (or the same-
?- Run a *hile loop to run the templates, the series o(
templates re'uired to .e process (or a report should .e
pro%ided in the input +le- The report parameter +le
also pro%ides the Cognos template names *hich ha%e
.een created earlier, the output +le (ormat-
6- Process the template .& opening the cognos report
using the cognos application o.ject pro%iding the
cognos director&, template .ase name and the output
+le t&pe etc at the cognos prompt-
Wipro Technologies Page 13 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
R- E/port the reportStemplate output *hether it is a
hot+le, e/cel +le or pd(, using To.ject-E/port#otBile2 or
To.ject-E/portE/cel*ithBormat2- Create another o.ject
to pu.lish the report (Pu.lishP)B- Also pass the report
director& as parameter to store the reports in the
re'uired (olders-
.Cognos !em"lates
Templates o( the reports are created .e(ore hand and
sa%ed in the Cognos director&-
>- +irst Te24late U Accepting the input prompts-
#ere in our implementation *e are using three t*o or
three templates- The +rst template is al*a&s used (or
the input prompts that are to accept the input the
parameters- $( the template is manuall& in%o!ed it
should prompt (or all those +elds-
When the template is in%o!ed %ia the Macro all these
parameters are ta!en (rom the input +le created .& the
Wipro Technologies Page 14 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
Report Perl Script details o( it ha%e .een mentioned
earlier-
4- .econd Te24late U 9etting the data (rom Warehouse-
$n the second template *e can either use a Tselect2
'uer& or call a procedure i( it is a comple/ 'uer& or
in%ol%es some other re'uirement- Bor doing additional
(ormatting o( data the output o( a second template is a
hot+le- We sa%e the data has a hot+le *hich could .e
used .& the +nal template-
&nsurin1 (ulti4le .essions and 4arallel
4rocessin15
$n this particular implementation *e *ere re'uired to
per(orm some )M3 operations in the 0ueries and
Stored Procedures the Cognos Templates *ere calling-
As the application *as earlier using Teradata as
.ac!end data .ase permanent ta.les *ere used- A
cop& o( the ta.le *as created (or each session and the
current data in the session *as reported to the
respecti%e user, so supporting multiple sessions *as
possi.le-
#o*e%er in MS S03 Ser%er 4556 this *as not possi.le
since each session ac'uired e/clusi%e *rite loc!s, *e
(aced pro.lems *hen multiple reports *ere re'uested
in the same session so could not use the same
(unctionalit&-
#ere, instead o( using permanent ta.les temporar&
ta.les (Single M *ere used- Those ta.les *ere
created in stored procedures and *ere dropped at the
end o( the stored procedure- The li(e o( these temp
Wipro Technologies Page 15 of 16
W#$TE PAPER Report Automation using Perl and Cognos macro
ta.les are not till the *hole session .ut onl& in the
stored procedure- #ence this contri.uted to greater
parallelism and also supported multiple sessions- $t
also enhanced the per(ormance compared to the
earlier Teradata implementation-
A- The 6nal te24late de+nes the re'uired (ormat o( the
report and the output +le t&peG it selects the data in
proper ro*s and columns as *ould .e re'uired (or the
report- At the end o( the e/ecution o( the last template
the +nal report is created in T-/ls2, or T-pd(2 (ormat in
the ser%er +le1s&stem, (rom *here it can .e
do*nloaded .& the user using the Bront1end
Application-
Wipro Technologies Page 16 of 16

Você também pode gostar