reports in a complex enviroment

22
Reports in a complex enviroment IGELU 2012 Zurich - 12 Zurich - 12 September 2012 September 2012 Zeno Tajoli – z.tajoli@ cineca.it Zeno Tajoli – z.tajoli@ cineca.it 12.Sep.2012

Upload: walter

Post on 03-Feb-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Reports in a complex enviroment. IGELU 2012. Zurich - 12 September 2012. Zeno Tajoli – z.tajoli @ cineca.it. Main points. More Modules ? To use cron Retrieve from BIB Retrieve from ADM Display with Excel Util e and GUI. More Modules ?. The language used: perl 5.8.x - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Reports in a complex enviroment

Reports in a complex enviroment

IGELU 2012IGELU 2012

Zurich - 12 Zurich - 12 September 2012 September 2012

Zeno Tajoli – z.tajoli@ cineca.itZeno Tajoli – z.tajoli@ cineca.it

12.Sep.2012

Page 2: Reports in a complex enviroment

Main points

• More Modules ?• To use cron• Retrieve from BIB• Retrieve from ADM• Display with Excel• Util e and GUI

12.Sep.2012

Page 3: Reports in a complex enviroment

More Modules ?

• The language used: perl 5.8.x• Two perl on Aleph500:– OS perl– Perl installed with Aleph500

• You can use both• Perl installed with Aleph500 has more

modules that SUN or RHEL perl

12.Sep.2012

Page 4: Reports in a complex enviroment

More Modules ?

• Useful extra modules:– Unicode::Lite– Convert::Translit

• Sun solution:– Install a third perl (like /usr/local/bin/perl)

• RHEL solution:– Add modules to OS perl with CPAN

12.Sep.2012

Page 5: Reports in a complex enviroment

To use cron

• Better to not repeat tasks• Cron is not the command line• Cron is a different enviroment• So you need to configure it to have the same

results• Our solution [ crontab –l ]

12.Sep.2012

Page 6: Reports in a complex enviroment

To use cron

#List serials34 10 31 12 * csh -c "/exlibris/aleph/list.csh" > /tmp/log18

-c [script] reads commands from the specified script file

12.Sep.2012

Page 7: Reports in a complex enviroment

#!/bin/cshsource /exlibris/aleph/.cshrcsource /exlibris/aleph/a20_1/alephm/.cshrcsource /exlibris/aleph/u20_1/alephe/aleph_startsource $aleph_proc/def_local_envset user = alephsetenv LOGNAME alephcd /exlibris/aleph/serials/exlibris/aleph/serials/list_serials.pl <params>

12.Sep.2012

Page 8: Reports in a complex enviroment

Retrieve from BIB

• Cataloguers have insert data in bib records instead of ADM records

• Elaborate a bibliography– Extract with p-ret-01 and p-print-03– Tuning tab expand– As format: “MARC with alphanumeric tags”– Do you need a fix routine ?– Or a character conversion ?

12.Sep.2012

Page 9: Reports in a complex enviroment

use MARC::Batch; #Work one record at time

my $batch = MARC::Batch->new( 'USMARC', $input_file );$batch->warnings_off(); $batch->strict_off();RECORD: while () { my $record; eval { $record = $batch->next() }; if ($@) { print ERRFILE "Bad MARC record " . $records_read . ": skipped.\n"; next; } last unless ($record); $records_read++; list_serials($record);}

12.Sep.2012

Page 10: Reports in a complex enviroment

sub list_serials{ my $record = shift; my $tipo =''; my $ldr = $record->leader(); my $id = $record->field('001')->data(); eval{$tipo = $record->field('200')->subfield("b")->data()}; if ($@) {$tipo = ''}; my @arr958 = $record->field('958');

12.Sep.2012

Page 11: Reports in a complex enviroment

if ((substr($ldr,5,3) eq 'nas') and (length($tipo)< 1)){ my $presenza_subs = 0; foreach my $campo (@arr958){ my $dato = $campo->subfield('a'); if (length($dato)>1){ $dato = substr($dato,0,3);

if (length($dato)>1){ $presenza_subs++; $dato =~ s/\://g; $dato =~ s/\s//g; my $i = $subs_presenti{$dato}; if ($i<1){ $subs_presenti{$dato} = 1; }else{ $i++; $subs_presenti{$dato}= $i; }; } } } if ($presenza_subs > 0){$contatore_serials_globale++}

12.Sep.2012

Page 12: Reports in a complex enviroment

sub send_avviso{ use MIME::Lite; my $val_subject = $_[0]; my $val_body=$_[1]; my $msg=MIME::Lite->new( From=>'[email protected]', To=>‘[email protected]', Subject=>$val_subject, Type=>'multipart/mixed');

$msg->attach(Type=>'TEXT',Data=>$val_body); $msg->attach(Type=>'text/plain', Path=>"/exlibris/aleph/lista.dat", Filename=>"lista.dat", Disposition=>'attachment'); MIME::Lite->send('smtp', 'localhost', Timeout=>60); $msg->send;};

12.Sep.2012

Page 13: Reports in a complex enviroment

Retrieve from ADM

• You retrieve data from Oracle• DBI, Unicode::Lite• Read the Oracle documentation from Doc

Portal• Explore data with Oracle SQL Developer• Setup the oracle environment in the scripts

12.Sep.2012

Page 14: Reports in a complex enviroment

Retrieve from ADM

• A selection:$ENV{ORACLE_OWNER} = "oracle";$ENV{ORACLE_VERSION} = "11";$ENV{ORACLE_SID} = "aleph20";$ENV{ORACLE_BASE} = "/exlibris/app/oracle";$ENV{ORACLE_HOME} =

"/exlibris/app/oracle/product/11";$ENV{ORACLE_CONF} = "/exlibris/aleph/ora_aleph";

• Use printenv to see

12.Sep.2012

Page 15: Reports in a complex enviroment

Retrieve from ADM

• Order and group data with ORDER BY and GROUP BY

$piano_sql = qq{ select z305_rec_key from xxx.z305};$sel_ids = $lda->prepare($piano_sql);$main::sel_ids->execute();my $ref_arr_ids = $sel_ids->fetchall_arrayref();foreach my $row(@$ref_arr_ids){ my ($idz305) = @$row;

12.Sep.2012

Page 16: Reports in a complex enviroment

select count(z35_rec_key), z35_sub_library from z35 where Z35_event_date like '2011%' and(z35_event_type = '71' OR z35_event_type = '71' OR z35_event_type = '72' OR z35_event_type = '73' ORz35_event_type = '74') group by z35_sub_library;

12.Sep.2012

Page 17: Reports in a complex enviroment

select z36h_sub_library, count(z36h_rec_key) from z36h wherez36h_item_status = '20' ANDZ36h_LOAN_DATE between '20120101' and '20121231'group by z36h_sub_library

select z36_status, count(z36_rec_key) from z36 wherez36_sub_library = 'BF ' ANDZ36_LOAN_DATE between '20120101' and '20121231'group by z36_status

12.Sep.2012

Page 18: Reports in a complex enviroment

• select z305_bor_status, count(z305_rec_key) from z305 where z305_rec_key like '%FIL ' group by z305_bor_status;

• In a for cicle with all sublibraries

• With a translation for bor status12.Sep.2012

Page 19: Reports in a complex enviroment

Display with Excel

• SYmbolic LinK (SYLK) format• http://en.wikipedia.org/wiki/SYmbolic_LinK_(SYLK)• http://wiki.tcl.tk/9800• http://netghost.narod.ru/gff/graphics/summary/

micsylk.htm

• It’s plain text• Quick and dirty

12.Sep.2012

Page 20: Reports in a complex enviroment

Display with Excel

• Column name with bold• Formatting values• Format dates• Excel and Calc (LibreOffice)• Selected ten years ago• Now better Open Document Format (XML)• http://standards.iso.org/ittf/

PubliclyAvailableStandards/c043485_ISO_IEC_26300_2006(E).zip

12.Sep.2012

Page 21: Reports in a complex enviroment

Util e and GUI• Util e 15 and 16 are like cron

– Setup time and parameters– Open when Aleph is open

# From p_custom_01 source $aleph_proc/def_local_env start_p_generic_proc /exlibris/aleph/repotes.pl echo "Fine lavori"exit: bl_end rm_f_symbol exit

12.Sep.2012

Page 22: Reports in a complex enviroment

Util e and GUI

• From Doc Portal: – How to make a home made custom service (19+)– How_to_add_additional_privileges_to_user_funct

ion_lng• You can use GUI to:– Send parameters– Send time– Use task Manager– Setup permission

12.Sep.2012