| dadlllogging |  |
| DLL Usage description Library: dadlllogging: This library contains the following groups of functions: Functions that operate on the logtables (daxch008 and daxch009). The logtable is used to keep track of the progress of the import and export program. During a full exchange or an exchange based on indicators the completion of each batchline should be logged. During an exchange based on audit each transaction should be logged. functions to retrieve info from the logtable also appear in this DLL, so all 'logic' about the logtable is concentrated in this library. Functions that operate on the log file. The logfile is used to record errors that occur during an import run. several types of errors can be logged: 1..Errors due to badly formatted strings, etc: exchange errors. 2. Errors due to database errors. 3. Record rejection due to conditions. 4. Stop.processing becomes true before the end of a run (due to a stop condition). 5. A batchline is not executed due to an execute condition. General remark: Whenever there is an optional parameter called company, it is possible to specify in which company should be searched for the answer, if the parameter is not provided during an actual call, the current company will be taken. DLL Prototypes
    function extern close.log.1s.transaction( )

    function extern close.log.file( )

    pre   : true

    post  : the logfile has been closed (if it was open)

    function extern flush.log.file( )

    pre   : true

    post  : the logfile has been flushed (if it was open)

    function extern long get.ascii.file.settings.of.exchange.run(
                    domain daxch.txch xch.type,
                    domain daxch.cxch xch.scheme,
                    domain daxch.cbat batch,
                    domain daxch.long run,
                    domain daxch.pint try,
                    ref domain daxch.yesno compressed.files,
                    ref domain daxch.yesno control,
                    ref domain daxch.sepa separator,
                    ref domain daxch.sepa enclosing.char )

    pre   : true

    post  : If return then compressed.files, control and separator, and enclosing.char are filled
            with the values read from the log table (batch level).

    return: Whether the log file contains an entry for the specified xch.type, xch.scheme,
            run and try.

    function extern long get.batch.lines.of.exchange.run(
                    domain daxch.txch xch.type,
                    domain daxch.cxch xch.scheme,
                    domain daxch.cbat batch,
                    domain daxch.long run,
                    domain daxch.pint try,
                    ref domain daxch.batl batl(),
                    ref domain daxch.path file() fixed )

    pre   : true

    post  : If n > 0 then for all n <= return value: batl(n) = export
            batch line of xch.scheme/batch read from the log table; file(n) = the
            name (including path name) of the file created when running batl(n) of
            xch.scheme/batch in run/try. Current record of daxch009 (log table, batch
            line level) may have been changed.

    return: The number of batch lines of the regular export run/try of the batch specified
            by xch.scheme/batch. (0 if no batch lines found.)

    function extern string get.highest.transno.completed(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    long run.num,
                    long try.num,
                    const domain daxch.cbat batch,
                    [ long company ] )

    pre   : true

    return: the highest transaction number completed found in the logtable for the run
            as specified with the parameters. If no log record can be found for these
            parameters 0 will be returned.

    function extern get.latest.batch.completed(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    long run.num,
                    long try.num,
                    ref domain daxch.pint seqn,
                    ref domain daxch.cbat batch,
                    [ long company ] )

    pre   : true

    post  : seqn and batch will contain the latest batch as has been completed
            for the given try. (these values are needed for a continuation). If not found:
            seqn = 0 and batch = ""

    desc  : A completed batch has an end date > 0

    function extern long get.latest.batl.completed(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    long run.num,
                    long try.num,
                    const domain daxch.cbat batch,
                    [ long company ] )

    pre   : true

    return: the batchline with the highest batchline sequence number found in the
            logtable for the run as specified with the parameters. If no log record can
            be found for these parameters 0 will be returned.

    function extern long get.next.run.num(
                    const domain daxch.cxch xch.scheme,
                    domain daxch.txch xch.type )

    return: (max. run number found for this exchange scheme and type) + 1, if combination does not
            exist in logtable: 1

    function extern long get.next.try.num(
                    const domain daxch.cxch xch.scheme,
                    domain daxch.txch xch.type,
                    long run.num )

    return: (maximum try number found for this run) + 1, if run number does not appear in
            logfile for this combination: 1

    function extern get.original.ttbl.and.casf(
                    ref string ttbl(),
                    ref string casf() )

    pre   : record of daxch009 is filled

    post  : ttbl and casf are filled with the TRITON Table and ASCII file belonging to this
            logged batchline.

    desc  : Due to the parent exchange scheme concept this is not trivial to find out.
            Moreover the link may have been removed making it unable to find the originally
            linked table and ascii file. If they cannot be found, will both arguments be
            emptied.

    state : record of daxch021 or daxch031 may be changed.

    function extern long get.previous.run.interval(
                    const domain daxch.cxch xch.scheme,
                    domain daxch.txch xch.type,
                    long run.num,
                    ref domain daxch.utc date.f,
                    ref domain daxch.utc date.t )

    pre   : true

    return: whether the given run has been logged as being 'based on audit'

    state : it is assumed that all records that satisfy the where condition contain
            the same audit interval: the export program assures this fields of daxch008 are changed

    post  : ret => the date and time variables contain the audit interval belonging to the
            given xch-scheme, -type and run.

    function extern long is.one.without.previous.run.interval(
                    const domain daxch.cxch xch.scheme.f,
                    const domain daxch.cxch xch.scheme.t,
                    domain daxch.txch xch.type )

    return: whether there exists an exchange scheme in the given range that is based on
            audit AND that in its previous run has not been exported based on audit.

    desc  : if no info can be found about the previous run 'true' will be returned. the
            field daxch008.cntl is used to determine whether there is interval information
            in the logdata

    function extern log.1s.transaction(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    const domain daxch.cbat batch,
                    long run.num,
                    long try.num,
                    long tran.id1,
                    long tran.id2,
                    long first )

    pre   : if first transaction within a second then first = true. open.log.1s.transaction
            has been called successfully (i.e. returning true).

    post  : the transaction id (consisting of two longs) has been written to the log file.

    desc  : purpose of this function is to write transactions that are within one second to a log
            file.

    function extern log.batchline(
                    domain daxch.batl batchline,
                    long no.read,
                    long no.prcd,
                    long no.erej,
                    long no.crej,
                    long no.skip,
                    domain daxch.path asciifile,
                    domain daxch.path sourcefile )

    pre   : log.start.batch has been called for the batch this batchline belongs to
            while log.end.batch has not been called yet.

    post  : finishing of batchline has been logged in the logtables. In daxch008 the
            'latest completed batchline' will be updated while in daxch009 the
            statistics will be inserted. On EDUPL in daxch009 the record will be ignored.

    state : No commit will be given and no new retry point will be set.

    desc  : It is expected (but not checked) that: no.read = no.prcd + no.erej + no.crej +
            no.skip

    function extern log.end.batch( )

    pre   : log.start.batch has been called before

    post  : the end of the batch logged via log.start.batch has been logged

    state : No new retry point will be set. A commit will be given.

    function extern log.error(
                    domain daxch.batl batl,
                    long error.type,
                    const string data.line(),
                    ... )

    pre   : * the logfile must have been opened by a prior call to open.log.file()
            * error.type in {e_cond, e_dberr, e_xcherr, e_stop}
            * 1 additional string argument (condition code) expected if error.type
              in {e_cond, e_stop}
            * 1 additional string argument (message code) expected if error.type =
              e_xcherr
            * 1 additional long argument (errno) expected if error.type = e_dberr
            * Note that casf does not have to be stripped

    post  : 1 line added to the logfile |#err.desc.o
            * consisting of: batl, error.type, error.code, data.line
            * consisting of: batl, error.type, error.code, |#err.desc.n error.message,
              data.line |#err.desc.n
            * in the same format as data.line (separator, encl.char, fixed length:
              should have been passed by a prior call to open.log.file()).
            * error.code is the additional argument (condition name, message code or
              error number).

    function extern log.multiline( long fp )

    pre   : * the logfile must have been opened by a prior call to open.log.file()
            * fp is a fileponter to a file open for reading (the ascii file)
            * the line just before the internal filepointer has just been logged to the logfile

    post  : The multiline texts following the line that has been logged are also appended to
            the logfile. No reprocess control data will be added to the multiline text
            lines written to the logfile.

    state : The internal filepointer for file fp now points to the first non-multiline text line.

    function extern log.set.sbus.batch( )

    pre   : log.start.batch has been called before

    post  : the field daxch008.sbus is updated with subscription.used setting state:
            No retry.point is set and no commit is given

    function extern log.start.batch(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    long run.num,
                    long try.num,
                    const domain daxch.cbat batch,
                    domain daxch.redo redo,
                    domain daxch.cntl cntl,
                    long processing.company,
                    long startup.company,
                    const string comb.sepa(),
                    domain daxch.sepa ench,
                    domain daxch.link link,
                    domain daxch.long srun,
                    domain daxch.pint stry,
                    domain daxch.yesno compressed,
                    [ domain daxch.date adat.f ],
                    [ domain daxch.time atim.f ],
                    [ domain daxch.date adat.t ],
                    [ domain daxch.time atim.t ] )

    pre   : if atim.f and atim.t are passed as parameter they should be in hhmmss
            format. If cntl = audit then the optional parameters are expected to be
            filled with the audit interval.

    post  : start of batch has been logged, ie the fixed data and the start date and time.
            Note that this fixed data is used in subsequent calls to:
            - log.transaction()
            - log.batchline()
            - log.end.batch()
            The logging will be done in company <startup.company>.

    state : No commit will be given and no new retry point will be set.

    function extern log.transaction( const string trans.num() )

    pre   : log.start.batch has been called before for the batch this transaction belongs
            to while log.end.batch has not been called yet.

    post  : the finishing of the transaction has been logged in the logtable (daxch008),
            for example the field 'highest completed transaction number' is updated.

    state : No commit will be given and no new retry point will be set.

    function extern long open.log.1s.transaction(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    const domain daxch.cbat batch,
                    long run.num,
                    long try.num )

    pre   : true.

    return: true if the log file could be created and opened.

    post  : if

    return: a file has been created; the name of this file is the same as of the
            log file, but with an extension ".tran". if the file could be created and
            opened

    note  : after calling this function and function log.1s.transaction(),
            function close.log.1s.transaction() must be called.

    function extern long open.log.file(
                    domain daxch.txch xch.type,
                    const domain daxch.cxch xch.scheme,
                    const domain daxch.cbat batch,
                    long run.num,
                    long try.num,
                    string separator(1),
                    string enclosing.char(1),
                    [ long company ] )

    pre   : xch.scheme should exist

    return: whether the logfile could be opened

    post  : the logfile where errors should be logged has been opened. If necessary the path,
            where the logfile is located, will be created.

    desc  : After opening the file errors can be logged using subsequent calls to log.error.
            The file should be closed by a call to close.log.file. The name of the logfile is
            as follows:
            * regular import: <daxch001.epth>/<xch.scheme>.<run.num>.i/log.<batch>.<run.num>.<try.num>
            * non-regular import: <daxch001.epth>/<xch.scheme>/log.<batch>.<run.num>.<try.num>
            * regular export: <daxch001.epth>/<xch.scheme>.<run.num>.e/exp.<batch>.<run.num>.<try.num>
            * non-regular export: <daxch001.epth>/<xch.scheme>/exp.<batch>.<run.num>.<try.num>
              Where table daxch001 of company <company> is taken, or if not present, the current company.

    function extern long try.to.get.previous.run.interval(
                    const domain daxch.cxch xch.scheme.f,
                    const domain daxch.cxch xch.scheme.t,
                    domain daxch.txch xch.type,
                    domain daxch.long run.num,
                    ref domain daxch.utc date.f,
                    ref domain daxch.utc date.t )

    return: Whether all xch-schemes had the same interval begin and end date and time
            for the given run number.

    post  : ret = true => interval will be filled with the found interval.
            ret = false => interval is undefined desc : Only exchange schemes that are based on audit and
            that also already were for run number run.num are taken into account.

    function extern long try.to.get.run.number(
                    const domain daxch.cxch xch.scheme.f,
                    const domain daxch.cxch xch.scheme.t,
                    domain daxch.txch xch.type,
                    ref long next.run.num )

    return: whether the highest used runnumber for the given xch-type is the same for
            all xch schemes.

    post  : ret = true => next.run.num = the found number + 1
            ret = false => next.run.num is undefined.
Related topics Libraries |