Derivation expressions provide the ability to translate values or to retrieve information otherwise not accessible in an interface format in IDIF. Data from within the Wiki database may need to be translated to match the requirements from a receiving third party system. Also, data within a source file may need to be translated to match the Wiki specifications.

Derivation Expression Logic for Inbound Interfaces#

Inbound interfaces provide the ability to load a source file into ePersonality; this is done by running LMTD. The LMTD allows you to apply derivation expressions to variables within the record that is being loaded.

The LMTD respects most of the same derivation expressions that are used with SQL Loader. One exception that the LMTD does not respect is the BYPASS function. Instead you should define a qualifier record, this can be done using an existing column within the table or by defining a foreign field. The derivation expression in this situation would contain an IF statement or a Case When clause and the constant field would contain the result (i.e. True or False). For more information on this please review the chapter on loading with interfaces.

LMTD can handle multiple fields being referenced in a derivation expression, however, for LMTD purposes the syntax is slightly different. The multiple fields must be specified in brackets with a colon prefacing the field name, for example: (:PLPL.TIME_CODE).


Calling Functions in IDIF for Outbound Interfaces#

Define Interface Formats (IDIF) is the screen used within the system to define export interface definitions for processing by the various interface programs. Many of these interface programs support the use of derivation expressions, but not all. As at June 1, 2008, the following interface programs have this support:
  • UEEF - Employee / Assignment Interface
  • UPPHF - Pay History Interface
  • UBEF - Employee / Benefits Interface
  • UPGLF - General Ledger File Interface
  • UPDIF - Disbursement File Interface
  • UENH - New Hire Interface
  • UPVEND - AP (Vendors) Interface
  • UPDTB - Deposits to Bank Interface
  • UPROEF - Canadian Record of Employment file interface

Derivation Expressions Calling Database Functions#

For purposes of interfacing, writing scripts or end user reporting, there are a number of data base functions that can be used - both from Oracle and those created as part of the application. As well, customers could create their own custom data base function for this purpose.

The functions listed below are those found to be useful in the creation of interfaces, conversion, script writing or reporting. It is not an exhaustive list, and can certainly be extended by a customer adding their own functions.

Calling Functions in SQL Loader
Calling Functions in IDIF (Derivation Expression) – export interfaces

Personality supplied Functions#

P2K_SMGCDGiven an ID and Table_Alias return the CODE
P2K_SMGETUDFGiven a Table_Name and User Defined Field name return the value
P2K_SMGLXGiven a Lexicon_Name and Stored_Value return the Displayed_Value
P2K_SMGLXMNGiven a Lexicon_Name and Stored_Value return the Meaning value
P2K_SMAGEDetermine the age between two dates
P2K_STEEMObtain the ID for the employee's P2K_HR_EMPLOYMENTS record
P2K_PPAMTS.SPGETPELGiven an Element_Name return the ID
P2K_PPAMTS.SPGETPPCGiven a PC_CODE return the ID
P2K_PPAMTS.SPELPAYGet the value of an element from a Pay Header
P2K_PPAMTS.SPPCPAYGet the value of a pay component from a Pay Header
P2K_SPGETYTDGet the year to date value for a specific pay component for an employee
P2K_PPAMTS.SPPCTOTGet to To-Date value for a pay component for an employee
P2K_PPAMTS.SPPCTOT_FILTERGet to To-Date value for a pay component for an employee with additional filtering
P2K_PPAMTS.SPELTOTGet to To-Date value for an element for an employee
P2K_PPAMTS.SPELTOT_FILTERGet to To-Date value for an element for an employee with additional filtering
P2K_SPPERIODReturn a date in correct period format
P2K_PPAMTS.SPGETESTget an employees statistic value from IEST
P2K_PPGEN.SPINELEMDetermine if a pay component is in an element
P2K_SMZONEconvert a number into a zoned overpunch number
P2K_SPPGWAGEdetermine the wage rate for an employee
P2K_PMFORM.GET_ORG_LEVEL_CODEDetermine the ORG_LEVEL_CODE for a department
P2K_PUA complete utility package of numerous functions used for the creation of interfaces and reports
P2K_PMSEC.CHECKANDDECRYPTDecryption of encrypted Varchar2 or Number data
P2K_PMSEC.CHECKANDDECRYPTDATEDecryption of encrypted date columns

Oracle Built-in Functions#

ORACLE CASE WHEN FunctionalityComplex If-Then-Else logic

Conversion Functions#

TO_CHARConverting a numeric or date field to a character field (often with formatting)
TO_DATE(Oracle_Function)Converting a character field to a date (often with formatting)
TO_NUMBERConverting a character field to a number(often with formatting)
DATE FORMAT MODELS (Oracle) for TO_CHAR and TO_DATEFormat mask options
NUMBER FORMAT MODELS (Oracle) for TO_CHARFormat mask options

Text Functions#

CONCATConcatenation of two strings - usually easier to use two pipes (eg. ||)
SUBSTRExtracting a substring out of a larger text string
INITCAP , UPPER and LOWERReformatting a text string's capital letters
INSTRDetermining if one string is inside another
LENGTHDetermining the length of the string
LPAD and RPADLeft- and Right-padding character fields with another value
TRIMTrimming off characters (usually blanks)
LTRIM and RTRIMTrimming off characters (usually blanks) from teh left or right side of the string
REPLACEReplace one value in a string with another

Numeric Functions#

ABSAbsolute Value (removing the - on negative values)
CEILRounding a number up to the next integer
EXTRACTExtracts a year, month or day value from a date
FLOORRounding a number down to the previous integer
MOD and REMAINDERModulus division (determining the remainder) or just returning the remainder
ROUNDRounding a number up/down and to a specific number of decimal places
TRUNCTruncating the decimal part of a number
SIGNDetermining the +/- sign of a number

Date Functions#

SYSDATEGetting the current date/time
LAST_DAYDetermining the last day of a month
ADD_MONTHSAdding a number of months to a date
NEXT_DAYReturns the first weekday that is greater than a specified date
MONTHS_BETWEENDetermining the number of months between dates
TRUNC (Date usage)Round a date to a nearest unit (usually to midnight)

Miscellaneous Functions#

DECODETranslating a finite set of values from one set to another
GREATEST and LEASTDetermining the greatest (maximum) and least (minimum) value between sets of values
MAX and MINReturns the maximum and minimum values from an expression
NVLtesting for and resolving NULL values
NVL2testing for a resolving NULL and NOT NULL values
SUMReturns the summed value of an expression
COALESCEtesting for and resolving multiple NULL values
SQLCODEreturns Oracle error message number from the most recently raised exception
SQLERRMreturns Oracle error message text from the most recently raised exception
USERreturns the Oracle database username of your session
UIDreturns the Oracle Session UserID number for your session
SYS_CONTEXT-USERENVReturn various values related to your current database session


Notes #

Click to create a new notes page

Example Derivation Expressions#

The following are examples of what derivation expressions can be used for:

To translate Gender to M/F
DECODE(~, '01', 'M', '02', 'F')

To manipulate data prior to interfacing,e.g. to remove hyphens from Government ID
REPLACE(~, '-',)

To get data that is not otherwise available, e.g. to get the Department Code when you only have the ID available
P2K_SMGCD(~,'DDP')

To filter the data and "throw out" a record,e.g. if employee is not in department ABC, disregard otherwise put in "1234"
DECODE(~,'ABC','1234','BYPASS')

To populate an effective date
NVL(RTRIM(~),'01-JAN-0001')

To change the case of supplied data
upper(~) or initcap(~)

To extract a portion of the supplied data, e.g. the source data is a 30 character distribution code but we are only interested in loading some of it to our field)
substr(~,1,5)

To remove whitespace
trim(~)

To remove leading zeros off of a Person Code
LTRIM(~,'0')


To reformat a date value, e.g. date is coming in as YYYYMMDD and needs to be reformatted for the data base to accept it
TO_CHAR(TO_DATE(RTRIM(:HIRE_DATE),'YYYYMMDD'),'DD-Mon-YYYY')

To shorten a fiscal period of 200307 for just the period
Substr(~,5,2) would give you "07", begin in position 5 for 2 characters

To shorten a fiscal period of 200307 for just the year
Substr(~,1,4) would give you "2003", begin in position 1 for 4 characters

Distribution code (001-643-8824-0976), only see the last four positions of the distribution string
Substr(~,14,4) will display "0976", you must take the "-"'s into account when coding this string.


This is an example of populating a distribution segment using the value from another field defined in IDIF. In this example, the 6th segment will be populated based on the value in the time code field after it has been translated using a translation
lexicon.
'?-????-?????-???????-?-' || p2k_smglx('PL_LABOR_CD_KEYED', :PLPL.TIME_CODE) || '-?????'


Format a GL amount to display the leading zeros and display a decimal point for $2263.13
Substr(TO_CHAR(ABS(~),'0000000000009.99'),2,16) will display 0000000002263.13, will begin at the 2nd character ignoring the leading "-" or "+" sign.


To decode specific areas of the string
Decode(substr(~,117,2),'05',substr(~,55,5),'02',substr(~,51,3),' ')

To round information coming in from four to two decimal places
ROUND(~,2)


This is an example of providing a Start Date for a field. This example will use the Beginning of Time date if there is a null value provided
NVL2(~,(to_char(to_date(rtrim(~),'YYYYMMDD'),'DD-Mon-YYYY')),'01-Jan-0001')


To removing a colon from time field in an inbound interface (ie TTX.START_TIME)
concat(substr(~,1,2),substr(~,4,5))


Translate an incoming value to a defined Time Code in the system using a translation lexicon. The lexicon is defined in IMLN, the saved value is the value defined in the source file and the displayed value is the eP translation, in this example the time code.
P2K_SMGLX('GWRS_PC_TRANSLT',~)

Derivation Expression Examples for UPPHF AND UEEF#

IDIF - Derivation Expression - Multiple Field Processing#

On the IDIF derivation expression, you can specify multiple variable names processing by indicating the lexicon value of the X_INF_VARIABLE_NAME inside the bracket , e.g. [320001]. Lexicon values available from IMLN for X_INF_VARIABLE_NAME are: 32nnnn, 35nnnn.

A full list of INF variables interchangeable for UPPHF and UEEF are provided as long as the Database tables are being loaded according to the Interface Level parameter of the run.

Please see example below:

Example: Record # 50, Field # 20 Requirement for Employee Row id or Unit id:

  • If the Pay Header Group user-defined field (UDF) 'PROJECT HOURS BY PERSON' is 'Y', this means that the employee is an 'ADMIN' employee and if the journal entry is reporting for 'Hours', then use the Identity eid.id on the Interface File field.
Otherwise, use the Unit dun.id on the field for all other situations.
  • From above IDIF set up, you should specify the variable name using 'UDF (DGD)' and enter the name in the Constant Value field, then the value of UDF will be returned and represented as in the derivation expression.
  • In the derivation expression, enter: decode(~,'Y',decode([320803],'02',[320009],[350400]),[350400])
where:
[320803] Journal Type (DGA), 01 - Financial Journal, 02 - Statistical Journal
[320009] Identity eid_id
[350400] Unit dun_id (DUN)
  • This derivation expression means decode the value of from UDF. If the value is 'Y', then decode the value from [320803] Journal Type. If the journal type is '02' Statistical Journal, then return [320009] Identify eid.id. Otherwise, return [350400]
Unit dun_id.