Report Creating Module - RPTSUB

The purpose of this module is to provide all functions and procedures to simply create reports and statistics. This module is used in RPTBUT and RPTGEN.

The module provides the following routines:

Routine Argument(s) SQL Stream Description
Control of report
RptDefInit M M Initializes the controlling structures of a report definition
RptDefInitNext O O Initializes the controlling structures of a report definition starting a new report within the same output structure.
RptDefInitConversion in ArgCur text, in ArgTyp text, in ArgDat datetype O O Subroutine to initialize the currency conversion.
“ArgCur” holds the target currency of amounts which should be converted
“ArgTyp” holds the type of rate to be used in conversions, e.g. M = middle, S = selling, B = buying
“ArgDat” holds the value date of the exchange rates to be used
RptDefExecute (M) - Routine to create and store the requested report based on SQL. Left for compatibility and easy handling of simple SQL-based reports. Internally just to two routines “RptDefExecuteOneSql” and “RptDefEnd” are called.
RptDefExecuteOneSql M - Routine to create and store the requested report based on SQL.
RptDefExecuteOneStream in ArgStr stream - M Routine to create and store the requested report based on the passed stream.
RptDefEnd M M
Data sources
RptDefFromTableInstance in ArgTbl text, in ArgNam text, in ArgMod module M - Function to add a table instance to be used in the report
“ArgTbl” holds the table name to be accessed
“ArgNam” holds a optional symbolic instance name to identify the table in case of multiple instances of one table in on report.
If an empty argument is passed, the table name is used as default.
“ArgMod” optionally holds a module instance of a module of type “ArgTbl” as reference to check the table structure. In case no table structure is available the root instance (e.g. \) might be passed.
Corresponding functions: “RptDefLinkTableInstance”, “RptDefFromCBSInstance”, “RptDefLinkCBSInstance”
RptDefFromCBSInstance in ArgObj text, in ArgCbc text, in ArgNam text, in ArgDat datetype, in ArgMod module O - Register CBS-column instance to be selected in SQL (via Join)
“ArgObj” holds the instance the CBS column is associated to or a OBJTYP-Field in the form <instance>.<field> which holds the INR of the owning object. In the latter case, the necessary TYP field name is created by replacing the last three characters of the field name by the literal “TYP”.
“ArgCbc” CBS-Column name with optionally the “ExtId” (or comma separated list of external IDs) to be used in brackets
“ArgNam” holds a symbolic name to identify the CBB instance
“ArgDat” selected date
“ArgMod” holds a module as reference to check the fields
sample: “RptDefFromCBSInstance”( “GID”, “OPN(AMT1)”, “OPN1”, PERDAT, \CBSMOD\CBB )
“RptDefFromCBSInstance”( “PTS.OBJINR”, “MAXSUM(AMT1)”, “MAX1”, Today, \ )
“RptDefFromCBSInstance”( “BRD.PNTINR”, “OPN(AMT1)”, “PNTOPN1”, Today, \ )
“RptDefFromCBSInstance”( “PTE”, “”, “DPC”, GetRelevantDateForBalances, CBSGET\CBB )
Corresponding functions: “RptDefFromTableInstance”, “RptDefLinkTableInstance”, “RptDefLinkCBSInstance”
RptDefFromStream in ArgNam text - M Function to define a passed stream as main source for the generation of the report. The fields of each row might be accessed in the report definition by the passed instance name. The individual field names are numbered as numbers.
RptDefLinkTableInstance in ArgTbl text, in ArgNam text, in ArgMod module, in ArgOrd text O O Function to add a link instance to be used in the report. A link instance is accessed after the (primary) database selection has taken place. No selection or order is allowed for link instances. Within SQL this could be understood as a kind of an outer join.
“ArgTbl” holds the table name to be accessed
“ArgNam” holds a optional symbolic instance name to identify the table
in case of multiple instances of the same table in on report. If an empty argument is passed, the table name is used as default.
“ArgMod” optionally holds a module instance of a module of type “ArgTbl” as reference to check the table structure. In case no table structure is available the root instance (e.g. \) might be passed.
“ArgOrd” holds an optional order definition, which is used to identify the order in case multiple entries fit to the condition specified in the associated “RptDefLinkFieldWithField” call(s). Only the first entry will be taken.
The order definition consists of a comma separated list of column names of the table each followed by 'asc' or 'desc' for ascending or descending order. The reserved word order is automatically added by the RPTSUB routines, if required.
Corresponding functions: “RptDefFromTableInstance”, “RptDefFromCBSInstance”, “RptDefLinkCBSInstance”
RptDefLinkCBSInstance in ArgObj text, in ArgCbc text, in ArgNam text, in ArgDat datetype, in ArgMod module O O Register CBS column instance to be linked into the report.
ArgObj holds the instance the CBS column is associated to or a OBJTYP-Field in the form <instance>.<field> which holds the INR of the owning object. In the latter case the necessary TYP field name is created by replacing the last three characters of the field name by the literal “TYP”.
“ArgCbc” CBS column name with optionally the “ExtId” (or comma separated list of external IDs) to be used in brackets
“ArgNam” holds a symbolic name to identify the CBB instance
“ArgDat” selected date
“ArgMod” holds a module as reference to check the fields
sample: “RptDefLinkCBSInstance”( “GID”, “OPN(AMT1)”, “OPN1”, PERDAT, \CBSMOD\CBB )
“RptDefLinkCBSInstance”( “PTS.OBJINR”, “MAXSUM(AMT1)”, “MAX1”, Today, \ )
“RptDefLinkCBSInstance”( “BRD.PNTINR”, “OPN(AMT1)”, “PNTOPN1”, Today, \ )
“RptDefFromCBSInstance”( “PTE”, “”, “DPC”, GetRelevantDateForBalances, CBSGET\CBB )
Corresponding functions: “RptDefFromTableInstance”, “RptDefLinkTableInstance”, “RptDefFromCBSInstance”
Connection and conditions
RptDefConnectForInst in ArgIns1 text, in ArgFld1 text, in ArgCmp text, in ArgFld2 text O O Registers a link condition between two instances. The first instance might be a link or a join instance.
“ArgIns1” holds the name of the instance, for which this link or join is defined
“ArgFld1” holds the column name of the field of the table.
“ArgFld2” is a literal describing a qualified field instance to be used to link the instance.
The second field might be SQL fields of another instance (e.g. REC.EXTKEY)
or a numeric constant (e.g. 50)
or a field reference identified by a leading backslash (e.g. \GIDGRP\REC\EXTKEY)
or a string literal in double quotes. (e.g. “X”)
“ArgCmp” holds the compare sign. Usually a literal like `=`.
Corresponding functions: “RptDefWhereFieldWithField”, “RptDefConnectPerDate”
RptDefConnectPerDate in ArgIns1 text, in ArgFld2 text O O Registers a per date condition for an instance. The first instance might be a link or a join instance. This per date logic is used for date range access via RNGMOD.
“ArgIns1” holds the name of the instance, for which this per date defined
“ArgFld2” is a literal describing a qualified field instance to be used to access the date.
The second field might be SQL fields of another instance (e.g. REC.EXTKEY)
or a field reference identified by a leading backslash (e.g. \GIDGRP\REC\EXTKEY)
or a date literal in the format {yyyymmdd}
Corresponding functions: “RptDefConnectForInst”
RptDefWhereFieldWithField in ArgFld1 text, in ArgCmp text, in ArgFld2 text, in ArgHea text O - Registers a comparison between two fields
“ArgFld1” and ArgFld2 are literals describing the two fields to be compared.
The two fields might be SQL fields of an instance (e.g. REC.EXTKEY)
or a numeric constant (e.g. 50)
or a field reference identified by a leading backslash (e.g. \GIDGRP\REC\EXTKEY)
or a string literal in single or double quotes. (e.g. “X”)
or a date literal in the format {yyyymmdd} “ArgFld2” might hold a space separated list of multiple references enclosed in brackets.
In this case the compare sign has to be the IN operator.
“ArgCmp” holds the compare sign. Usually a literal like `<`, `=` or `like`.
“ArgCmp” might start with special literals.
Starting with “(”, this and the following condition will be put into brackets and will be connected by or.
Starting with “)”, this condition is the last condition connected by or
Starting with (or followed by) “not”, not will prefix this comparison.
RptDefWhereOnlyField in ArgFld text O - Registers field to be only used in comparison in SQL
“ArgFld” field name (field has to be build in the form <instance>.<column> )
RptDefWhereClause in ArgTxt text, in ArgHea text O - Additional unchecked where clause. The where clause could start with special characters to indicate the type connection to the other conditions. If the first character holds a `(` or a `)` this condition starts or ends a OR connected group.
Fields of report
RptDefSelectField in ArgFld text, in ArgHea text, in ArgAdd text M M Registers a field to be brought into the report. The field might reference any of the defined instances. Thus normal (joined) instances and linked in instances might be accessed.
“ArgFld” Field name (field has to be build in the form <instance>.<column>)
“ArgHea” Report header for the column
“ArgAdd” Additional formatting instructions, multiple instructions are passed as a space delimited list of instructions
RptDefAddConvertedAmount in ArgFld text, in ArgAmtFld text, in ArgHea text, in ArgAdd text O O Add a work column holding the converted amount of another column
“ArgFld” Field name which has to start with $ to define a column with a different data source
“ArgAmtFld” field holding the amount
“ArgHea” Report header for the column
“ArgAdd” Additional formatting instructions
RptDefAddField in ArgFld text, in ArgVal text, in ArgHea text, in ArgAdd text O O Adds a register field to be inserted in the resulting report.
“ArgFld” Field name which has to start with $ to define a column with a different data source
“ArgVal” Constant value or source field to be used in the report.
The value might be an SQL field of an instance (e.g. REC.EXTKEY)
or a numeric constant (e.g. 50)
or a field reference identified by a leading backslash (e.g. \GIDGRP\REC\EXTKEY)
or a string literal in double quotes (e.g. “X”)
or a date constant in the format {yyyymmdd}. (e.g. {20011231})
“ArgHea” Report header for the column
“ArgAdd” Additional formatting instructions
RptDefAddCalcField in ArgFld text, in ArgAmtFld1 text, in ArgCal text, in ArgAmtFld2 text, in ArgHea text, in ArgAdd text O O Adds a work column holding a calculated amount based on two other columns
“ArgFld” Field name which has to start with $ to define a column with a different data source
“ArgAmtFld1/2” field holding field names of the amount
ArgCal holds the calculation method. Possible are + - * / % “ArgHea” Report header for the column
“ArgAdd” Additional formatting instructions
Sort
RptDefOrderField in ArgFld text, in ArgSrt numeric, in ArgHea text O O Registers field to be part of the order in SQL
“ArgFld” Field name (field has to be build in the form <instance>.<column>)
“ArgSrt” numeric sortlevel. negative for descending sort.
“ArgHea” Description of the field for this order level. The default value is the field description used in the report heading
RptDefOrderSubField in ArgFld text, in ArgSrt numeric, in ArgBeg numeric, in ArgLen numeric, in ArgHea text O - Registers a part of a field to be part of the order in SQL
“ArgFld” Field name (field has to be build in the form instance . column )
“ArgSrt” numeric sortlevel. negative for descending sort.
“ArgBeg” numeric starting position of the sort part within the field (1 = first position)
“ArgLen” numeric number of characters of the sort part within the field
“ArgHea” Description of the field for this order level. The default value is the field description used in the report heading
Miscellaneous
RptDefAddPrefixLine in ArgHea text O O Registers an additional prefix line which will be part of the report prefix following the order definition and before the table holding the report data.
“ArgHea” Contents of the complete line.
RptDefGetFieldIdx in ArgFld text O O Function to return the internal index of a defined field.
“ArgFld” the Field name incl. Instance (e.g. PTA.NAM, $MAXAMT.AMT)
If not found, the index zero is returned.
Corresponding function: “RptOutGetFieldContent”
RptOutGetFieldContent in ArgIdx numeric O O Function to return the current value of a field within a report set. The index of the field might be determined once upfront by a call to the function “RptDefGetFieldIdx”.
The function is intended to be used in reports where Subroutines are used to handle certain parts of the logic.
Corresponding function: “RptDefGetFieldIdx”
RptDefGetSubordinatesOfPty in ArgInr text O O Function to return a textual description of a set of INRs which are directly or indirectly subordinate to the passed INR. The returned text might directly be passed to “RptDefWhereFieldWithField” with the compare connector “in”.
“ArgInr” holds the INR of the party