Conversion Codes


Conversion codes are applied to the raw data in a field to transform that data into a different format.  Dates are a good example of where a convesion code should be used.  Internally, all dates are stored as an integer representing the number of days relative to Day 0 (in UniVerse, Day 0 is December 31, 1967). When a date is retrieved from this field, it must be converted to a conventional form that is recognizable to the user. You may specify one or more conversion codes by seperating each conversion code by the pipe (|) character. If you use multiple conversion codes, the codes are applied from left to right, so that the leftmost code is applied to the original value, then the next conversion code to the right is applied to the result of the first conversion, and so on. Generally, conversion codes are identical to those used in the ICONV and OCONV functions of BASIC.

The following table describes some of the more useful standard conversion codes and any Kourier conversion code extensions.  For a complete list of conversion codes please consult your U2 documentation.

Conversion Description
Date The date conversion code is used to convert internal dates to external formats.  Assuming an internal date of 14201, the following conversion codes will produce the result shown.  
Conversion Result Comment
D2- 11-17-06
D4- 11-17-2006
D 17 NOV 2006
D0 17 NOV
DD 17
DM 11
DY 2006
DWA FRIDAY Day of the week
DJ 321 Julian date - the 321st day of the year
UYYMMDD 061117 Kourier Extenstion - 2-digit year, 2-digit month, 2-digit day
UYYYYMMDD 20061117 Kourier Extension - 4-digit year, 2-digit month, 2-digit day
Time The time conversion code is used to convert internal times to external formats.  Assuming an internal time of 50000, the following conversion codes will produce the result shown.  
Conversion Result Comment
MT 13:53 Hours and minutes in military format
MTS 13:53:20 Hours, minutes and seconds in military format
MTH 01:53pm Hours and minutes in standard format
UHHMMSS 135320 Kourier Extension - Hours, minutes and seconds in military format without colons
Group Extract The group extract conversion code is used to extract one or more values from a string separated by a given delimiter.  Assuming a string of 123*456*789:XY, the following conversion codes will produce the result shown.  
Conversion Result Comment
G0*1 123
G1*1 456
G1*2 456*789:XY
G0:1 123*456*789
D1:1 XY
Numbers The MR or MD conversion codes are used to convert internal numbers to external formats.  Assuming an internal number of 1420190, the following conversion codes will produce the result shown.  
Conversion Result Comment
MR2 14201.90 Number has two implied decimal places
MR4 142.0190 Number has four  implied decimal places
MR2,$ $14,201.90 Displays the number as currency with commas
MR(%10) 0001420190 Displays the number zero filled in ten characters
MR23, 1,420.19 Descales number by 10, two implied decimal places with commas
UEBCDIC 142019} Kourier Extension - Converts negative numbers to EBCDIC format
Characters The mask character conversion codes is used to select certain types of characters out of a string.  Assuming a character string of 492 Seacrest Dr., the following conversion codes will produce the result shown.  
Conversion Result Comment
MCU 492 SEACREST DR. Converts all characters to upper case
MCA SeacrestDr Extracts all alphabetic characters
MCN 492 Extracts all numeric characters
MX 0001420190 Displays the number zero filled
MR23, 1,420.19 Descales number by 10, two implied decimal places with commas
UCHANGE;str1;str2 492 SEacrEst Dr. Change str1 to str2. Change strings may contain one or more printable characters.  Non-printable characters may be entered using "0x" notation (e.g. UCHANGE;'0x0C0A';'' will change CRLF to an empty string).
UTRIM 492 Seacrest Dr. Kourier Extension - Trims leading, imbedded redundant, and trailing spaces
Substitution The substitution conversion code allows you to specify simple if/then processing on a data value.  The format of the substitution conversion code is S;op1;op2.

op1 -  is the value to use if the field is not null.  If op1 is numeric then the value is returned from the current record (if the value is greater than zero) or from the item-id of the current record (if the value is zero).  If op1 is a delimited text string, that value is returned.  If op1 is an asterisk, the original value is returned.

op2 -  is the value to use if the field is null.  If op2 is numeric then the value is returned from the current record (if the value is greater than zero) or from the item-id of the current record (if the value is zero).  If op2 is a delimited text string, that value is returned.  If op2 is an asterisk, the original value is returned.
Text Extract The text extract conversion code is used to extract a certain number of characters from a text string.  Assuming a character string of 492 Seacrest Dr., the following conversion codes will produce the result shown.  
Conversion Result Comment
T1,3 492 Extracts three characters beginning at position 1
T5,3 Sea Extracts three characters beginning at position 5
Translate The Tfile conversion code converts values from one file to another by translating through a file. It uses data values in the source file as IDs for records in a lookup file. The source file can then reference values in the lookup file. To access  the lookup file, its record IDs (field 0) must be referenced. If no reference is made to the record IDs of the lookup file, the file cannot be opened and the conversion cannot be performed. The format of the translate conversion code is Tfilename ; c [vmc]; [ivmc] ; [ovmc].

filename
- the name of the lookup file.  It can be preceeded by the keyword DICT to reference the files dictionary.
c - translate subcode.  When used in Kourier, you should only use the C (if conversion is impossible, return the orginal value) and X (if conversion is impossible, return an empty string).  The translate subcode may be followed by a number indicating which value to return from a multivalued field.
ivmc -  When used in Kourier, this field should always be omitted.
ovmc - Indicates the attribute number in the lookup file to return.  
Conversion Result Comment
TCUSTOMER;X;;1 Acme Inc. Assuming the current data value is the item-id to the Customer file, the value in attribute 1 is returned, presumably the Customer name.
UITRANS;lookup_key Integration translate replaces the current value with the value found in the lookup table referenced by the lookup_key.  The lookup_key is the item-id of the record in the KT_INTEGRATION_XREF file.  For example, UITRANS;DEMO*LOG_ERR_TYPE will use the lookup table named DEMO*LOG_ERR_TYPE when processing data values.
@ Codes Conversion codes that being with an @ character provide special capabilities.  The following table indicated the supported @ codes.  
Conversion Comment
@LASTCHGBY Returns the operating system name of the last user to change a record.  This conversion is only valid when an export has been net change enabled.
@MAXNV;n;n Returns the number of values in the source attributes referenced.  Attributes are delimited by the semi-colon (;) character.  This substitution is useful when a single attribute can not be identified as the controlling attribute in an association.
@MAXNS;n;n Returns the number of sub-values in the source attributes referenced.  Attributes are delimited by the semi-colon (;) character.  This substitution is useful when a single attribute can not be identified as the controlling attribute in an association.
@NV Returns the number of values in the source attribute/dictionary.
@NS Returns the number of sub-values in the source attribute/dictionary.
@RECORD<amc,vmc,svmc> Extracts data from the current record indicated by the value of amc (attribute), vmc (value) and svmc (sub-value).  if sepecified, all parameters must be numeric.  The vmc and svmc parameters are optional. 
@STRUCT;n In some applications, the structure of associated multi-valued attributes are not maintained in parallel (i.e. the same number of values/sub-values in each attribute).  This conversion code forces the source attribute to follow the structure of the attribute reference by 'n'.
@TEXT{;str} Converts all system delimiters (@AM, @VM, @SVM, and @TM) in the source attribute/dictionary to the space character.  Use the optional str expression to choose a character (or string of characters) other than the space character.  Non-printable characters may be entered using "0x" notation.
@TM2SPC{;str} Converts the @TM system delimiter in the source attribute/dictionary to the space character. Use the optional str expression to choose a character (or string of characters) other than the space character.  Non-printable characters may be entered using "0x" notation.
@SVM2SPC{;str} Converts the @SVM system delimiter in the source attribute/dictionary to the space character. Use the optional str expression to choose a character (or string of characters) other than the space character.  Non-printable characters may be entered using "0x" notation.
@VM2SPC{;str} Converts the @VM system delimiter in the source attribute/dictionary to the space character.  Use the optional str expression to choose a character (or string of characters) other than the space character.  Non-printable characters may be entered using "0x" notation.
Literal Strings To specify a literal string, enclose the data value in quotes or double quotes. 

For example, entering "{@YYYYMMDD}" (including the quotation marks) will return the current system date in YYYYMMDD format. Entering "KOURIER" (including the quotation marks) will return the string KOURIER.

The string can specify any number of valid substitution tags enclosed by curly braces ( {} ).


User Guide - Table of Contents