* compile with D*B CRTSQLRPGI ANZJRN B*D D*B+ COMMIT(*NONE) B*D D*B+ OBJTYPE(*MODULE) B*D D*B+ DATFMT(*ISO) B*D D*B+ DBGVIEW(*SOURCE) B*D D*B CRTPGM ANZJRN B*D D*B+ BNDDIR(QC2LE) B*D D*B+ ACTGRP(ANZJRN) B*D /*--- import Prototypes /COPY QRPGLEH,SYSTEM /COPY QRPGLEH,QMHSNDPM /COPY QRPGLEH,ANZJRN /*--- local Prototypes D Work PR d init pr d dspJrn pr d crtDelFile pr d crtJoFile pr d copySchreck pr d error pr d message 80 value /*--- Constants D TRUE C *ON D FALSE C *OFF /*--- statefull Variables d errno s 10i 0 import('errno') d EXCP_MSGID s 7 import('_EXCP_MSGID') d initFlag s n INZ(FALSE) d vonDatum s 8a d bisDatum s 8a d vonZeit s 6a d bisZeit s 6a /*--- Main Interface D ANZJRN PI D fileName 10A CONST D library 10A CONST d joFile 10a const d joLib 10a const D vonTimestamp Z CONST d bisTimestamp Z CONST /*--- very unimportant procedure main ------------------------*/ /free monitor; Work(); on-error; error('unexpected error, call the hotline'); endmon; return; /end-free /*============================================================*/ P Work B /*------------------------------------------------------------*/ /free init(); dspJrn(); crtDelFile(); crtJoFile(); copySchreck(); return; /end-free P Work E /*============================================================*/ P crtDelFile B /*------------------------------------------------------------*/ d sqlString s 256 /free system('DLTF QTEMP/DELFILE'); sqlString = 'create table qtemp/delfile ' + 'as ( ' + 'select joseqn, joentt, jodate, ' + 'jotime, jojob, jouser, jonbr, jopgm, ' + 'joccid, joesd ' + 'from qtemp/dspjrn ' + 'where jocode = ''R'') ' + 'with data'; /end-free c/EXEC SQL c+ execute immediate :sqlString c/END-EXEC /free if SQLCOD < 0; error('SQLCOD ' + %char(SQLCOD) + ' extract DSPJRN Data'); endif; return; /end-free P crtDelFile E /*============================================================*/ P crtJoFile B /*------------------------------------------------------------*/ d sqlString s 256 /free system('DLTF ' + %trim(jolib) + '/' + %trim(joFile)); sqlString = 'create table ' + %trim(jolib) + '/' + %trim(joFile) + ' ' + 'as ( ' + 'select joseqn, joentt, jodate, ' + 'jotime, jojob, jouser, jonbr, jopgm, ' + 'joccid, d.* ' + 'from qtemp/dspjrn, ' + %trim(library) + '/' + %trim(fileName) + ' d) ' + 'with no data'; /end-free c/EXEC SQL c+ execute immediate :sqlString c/END-EXEC /free if SQLCOD < 0; error('SQLCOD ' + %char(SQLCOD) + ' occurred extract DSPJRN'); endif; return; /end-free P crtJoFile E /*============================================================*/ P copySchreck B /*------------------------------------------------------------*/ d rc s 10i 0 /free EXCP_MSGID = ' '; rc = system('CPYF QTEMP/DELFILE ' + %trim(joLib) + '/' + %trim(joFile) + ' ' + 'MBROPT(*REPLACE) ' + 'FMTOPT(*NOCHK)'); if rc <> 0; error(EXCP_MSGID + ' occurred CPYF'); endif; return; /end-free P copySchreck E /*============================================================*/ P error B d error pi d message 80 value /*------------------------------------------------------------*/ /free SendSysMsg( 'CPF9898' : 'QCPFMSG ' + '*LIBL ' : message : 80 : '*ESCAPE ' : '*PGMBDY ' : 1 : QMHSNDPM_MSGKEY : QMHSNDPM_MSGERR ); /end-free P error E /*============================================================*/ P dspJrn B /*------------------------------------------------------------*/ d rc s 10i 0 /free system('DLTF QTEMP/DSPJRN'); EXCP_MSGID = ' '; rc = system('DSPJRN JRN(' + %trim(library) + '/QSQJRN) ' + 'FILE((' + %trim(library) + '/' + %trim(FileName) + ')) ' + 'RCVRNG(*CURCHAIN) ' + 'FROMTIME(' + vonDatum + ' ' + vonZeit + ') ' + 'TOTIME(' + bisDatum + ' ' + bisZeit + ') ' + 'OUTPUT(*OUTFILE) ' + 'OUTFILE(QTEMP/DSPJRN) ' + 'ENTDTALEN(*CALC) ' + 'ENTTYP(*RCD)'); if rc <> 0; error( EXCP_MSGID + ' ocurred DSPJRN'); endif; return; /end-free P dspJrn E /*============================================================*/ P init B D init PI /*------------------------------------------------------------*/ d wDate s d DATFMT(*ISO) d wTime s t TIMFMT(*ISO) /free wDate = %date(vonTimeStamp); vonDatum = %subst(%char(wDate): 9: 2) + %subst(%char(wDate): 6: 2) + %subst(%char(wDate): 1: 4); wTime = %time(vonTimeStamp); vonZeit = %subst(%char(wTime): 1: 2) + %subst(%char(wTime): 4: 2) + %subst(%char(wTime): 7: 2); wDate = %date(bisTimeStamp); bisDatum = %subst(%char(wDate): 9: 2) + %subst(%char(wDate): 6: 2) + %subst(%char(wDate): 1: 4); wTime = %time(bisTimeStamp); bisZeit = %subst(%char(wTime): 1: 2) + %subst(%char(wTime): 4: 2) + %subst(%char(wTime): 7: 2); if not initFlag; endif; /end-free P init E