-
So, für alle, die es interessiert: ich habe jetzt die Qshell über Bord geworfen und die Lösung in RPG umgesetzt.
Dabei hat mir das Tutorial von Scott Klement sehr geholfen:
http://www.scottklement.com/rpg/ifs_ebook/
Wenn jemand Fragen dazu hat, kann ich sie gerne beantworten.
Danke nochmals, für dieses tolle Forum!
Gruß,
Frederik
Code:
h decedit('0,') datfmt(*iso) datedit(*dmy.)
h dftactgrp(*no) actgrp(*new) bnddir('QC2LE') bnddir('IFSTEXT')
//
d/copy tools/qrpgleh,ifsio_h
d/copy tools/qrpgleh,ifstext_h
d/copy tools/qrpgleh,errno_h
//
d finr s 2a
d dir s *
d dirname s 50a
d filename s 50a
d txtname s 50a inz('/tmp/hmg/kss/dateiliste.txt')
d modtime s z
d filetime s t
d filedate s d
d akttime s t
d aktdate s d
d fnwithdir s 100a
d mystat s like(statds)
d hours_utc s 10i 0
d mins_utc s 10i 0
d secs_utc s 8f
d epoch s z inz(z'1970-01-01-00.00.00.000000')
d utcoffset s 10i 0
d zeile s 80a
d anzahl s 10i 0
d groesse s 10i 0
d openflag s 5i 0
d fd s 10i 0
d line s 80a
d linelen s 10i 0
d err s 10i 0
//
d stm s 1000a
d len s 15p 5
//
d ceeutco pr
d hours_utc 10i 0
d mins_utc 10i 0
d secs_utc 8f
d feedback 12a options(*omit) UTC Offset
//
dqcmdexc pr extpgm('QCMDEXC') Systemaufruf
d stm 1000a options(*varsize) const
d len 15p 5 const
//
c *entry plist
c parm finr
//
/FREE
//-----------------------------------------------------------------------
// Hauptprogramm
//-----------------------------------------------------------------------
akttime = %time();
aktdate = %date();
dirname = '/var/lib/hmg/kss/transfer/2-' + finr + '/';
ceeutco(hours_utc: mins_utc: secs_utc: *omit); //UTC Offset holen
if %error;
utcoffset = 0;
else;
utcoffset = secs_utc + 3600; //Eine Stunde drauf, sonst falsch?!
endif;
dir = opendir(%trimr(dirname));
if dir = *NULL;
die('opendir(): '+%str(strerror(errno)));
endif;
anzahl = 0;
groesse = 0;
zeile = '';
filename = *blanks;
p_statds = %addr(mystat);
p_dirent = readdir(dir);
dow p_dirent <> *NULL;
filename = %subst(d_name:1:d_namelen);
fnwithdir = %trimr(dirname) + %trimr(filename);
if %subst(filename:1:1) <> '.'; //Verzeichnis?
if stat(%trimr(fnwithdir): %addr(mystat)) < 0;
die('stat(): '+%str(strerror(errno)));
endif;
modtime = epoch + %seconds(st_mtime) + %seconds(utcoffset);
filedate = %date(modtime);
filetime = %time(modtime);
if (filedate < aktdate) //Datum < Tagesdatum
or ((filedate = aktdate) //oder Datei von heute
and (%diff(akttime : filetime : *minutes) > 10)); //aber älter als 10 min
anzahl = anzahl + 1;
groesse = groesse + st_size;
if openflag = 0; //Datei noch nicht offen?
if unlink(%trimr(txtname)) < 0; //Datei erst mal löschen
err = errno;
if err <> ENOENT;
callp die('unlink(): ' + %str(strerror(err)));
endif;
endif;
fd = open(%trimr(txtname): //Anlegen mit richtiger Codepage
O_CREAT+O_WRONLY+O_CODEPAGE:
S_IWUSR+S_IRUSR+S_IRGRP+S_IROTH:
819);
if fd < 0;
callp die('open(): ' + %str(strerror(errno)));
endif;
callp close(fd);
fd = open(%trimr(txtname): //Öffnen als Text-Datei
O_WRONLY+O_TEXTDATA);
if fd < 0;
callp die('open(): ' + %str(strerror(errno)));
endif;
line = %trimr(dirname);
linelen = %len(%trimr(line));
callp writeline(fd: %addr(line): linelen); //Verzeichnisnamen schreiben
line = ' ';
linelen = %len(%trimr(line));
callp writeline(fd: %addr(line): linelen); //Leerzeile schreiben
openflag = 1;
endif;
line = filename + ' ' + %char(filedate) + ' ' +
%char(filetime) + ' ' + %char(st_size);
linelen = %len(%trimr(line));
callp writeline(fd: %addr(line): linelen); //Dateizeile schreiben
endif;
endif;
p_dirent = readdir(dir);
enddo;
closedir(dir);
if openflag = 1;
callp close(fd); //Textdatei schliessen
endif;
if (anzahl > 0);
exsr ticket;
endif;
*inlr = *on;
//-----------------------------------------------------------------------
// Ticket schreiben
//-----------------------------------------------------------------------
begsr ticket;
stm = 'SBMJOB CMD(' //Ticket Mail senden
+ 'IEFFECT/SNDEMAIL '
...
qcmdexc(stm: %size(stm));
endsr;
//-----------------------------------------------------------------------
// Programminit
//-----------------------------------------------------------------------
//
begsr *inzsr;
endsr;
//
/END-FREE
//
/DEFINE ERRNO_LOAD_PROCEDURE
/COPY TOOLS/QRPGLEH,ERRNO_H
Similar Threads
-
By VWBussi in forum IBM i Hauptforum
Antworten: 9
Letzter Beitrag: 24-08-12, 09:34
-
By heynem in forum IBM i Hauptforum
Antworten: 7
Letzter Beitrag: 05-12-02, 08:59
-
By Sascha in forum IBM i Hauptforum
Antworten: 7
Letzter Beitrag: 09-07-02, 09:08
-
By Burgy Zapp in forum NEWSboard Server & Hardware Markt
Antworten: 0
Letzter Beitrag: 22-03-02, 22:48
-
By Frank.Sobanek in forum IBM i Hauptforum
Antworten: 2
Letzter Beitrag: 29-08-01, 14:11
Tags for this Thread
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- You may not post attachments
- You may not edit your posts
-
Foren-Regeln
|
Erweiterte Foren Suche
Google Foren Suche
Forum & Artikel Update eMail
AS/400 / IBM i
Server Expert Gruppen
Unternehmens IT
|
Kategorien online Artikel
- Big Data, Analytics, BI, MIS
- Cloud, Social Media, Devices
- DMS, Archivierung, Druck
- ERP + Add-ons, Business Software
- Hochverfügbarkeit
- Human Resources, Personal
- IBM Announcements
- IT-Karikaturen
- Leitartikel
- Load`n`go
- Messen, Veranstaltungen
- NEWSolutions Dossiers
- Programmierung
- Security
- Software Development + Change Mgmt.
- Solutions & Provider
- Speicher – Storage
- Strategische Berichte
- Systemmanagement
- Tools, Hot-Tips
Auf dem Laufenden bleiben
|
Bookmarks