UDR Functions

The following functions for UDR described here are:

udrAddError

Adds an error description message to the UDR, which will be visible from the Error Correction System Inspector window or the Data Veracity browser, Error Code column. A UDR can have several error descriptions.

void udrAddError ( drudr myUDR, string ecsErrorCode, string myString )
ParameterDescription

myUDR

The UDR to add error message to.

ecsErrorCode

An ECS Error Code as defined from the Error Correction System Inspector and Data Veracity browser.

myString

Any string to associate with the Error Code. This parameter comprises the Error Case found in the ECS or Data Veracity. Optional.

Returns

Nothing

Example - Using udrAddError

The following example appends error text to a UDR, which when displayed in ECS or Data Veracity will look like the following figure:

udrAddError( input, "CALL_ID_ERROR", 
 "The callId: " + 
 input.callId +
 " Calling number: " + 
 input.anum );



udrClearErrors

Removes all error descriptions, added to a UDR. This is useful when collecting UDRs from ECS or Data Veracity for a new validation which may send them back to ECS or Data Veracity. Adding a new error description, if one already exists, will make it impossible to auto-assign the UDR to a reprocessing group when it arrives to either Data Veracity or the ECS.

void udrClearErrors( drudr myUDR )
ParameterDescription

myUDR

The UDR to clear errors from

Returns

Nothing


udrClone

Clones a UDR. It is used when having multiple routes leaving the agent, where any of the routes changes the content of a UDR. For complex UDR structures, this can be a heavy operation, and must be used with care.

drudr udrClone( drudr  myUDR  )
ParameterDescription

myUDR

The UDR to clone

Returns

A clone of myUDR


udrContainsError

Returns true if an error description has been added to the UDR.

boolean udrContainsError( drudr  myUDR  )
ParameterDescription

myUDR

The UDR to evaluate for error descriptions

Returns

true or false


udrCreate

Creates a new UDR of the specified type. All fields are included, except for the optional.

drudr udrCreate( type  UDRType  )
ParameterDescription

UDRType

A defined UDR type

Returns:

A UDR of the specified type


udrDecode

Decodes a bytearray into a list of UDRs, and returns an error message if the operation fails. To route the UDRs to a subsequent agent, loop through the resulting list routing each element individually.

Note!

Built-in CSV and JSON formats are not supported by udrDecode.

string udrDecode
 ( string  decoderName , 
 list<drudr>  UDRlist , 
 bytearray  indata , 
 boolean  fullDecode  ) //Optional
ParameterDescription

decoderName

The name of a defined decoder

UDRlist

The list in which the resulting, decoded UDRs will be saved

indata

The input data to decode

fullDecode

States if Full Decode will be applied. By default, this parameter is set to true. For further information, see the /wiki/spaces/MD82/pages/3781411.

Returns

A string containing nothing (null) if the operation succeeded, and an error message if it failed

Example - Using udrDecode

A list must be created, not only declared, previously used by udrDecode:

list<drudr> myList = listCreate(drudr);

if (udrDecode("myFolder.myFormat.myDecoder", 
 myList, input) == null) {
 // Do something
} else {
 // Error handling
}

udrEncode

Encodes a UDR.

Note!

Built-in CSV and JSON formats are not supported by udrEncode.

bytearray udrEncode
 ( string  encoderName ,
 drudr  myUDR  )
ParameterDescription

encoderName

The name of a defined encoder

myUDR

The UDR to encode

Returns

A bytearray

udrForceDecode

By default, a Decoder only evaluates record sizes and field termination marks. It does not read the field values to evaluate for validity. This is done for each field when it is actually accessed, either from an agent utilizing APL code, or from an Encoder.

The udrForceDecode function will decode each field within a UDR. If a field is not valid, the agent will abort. This function is equal to the Full Decode option in the Decoder window. Note that the function has a negative impact on performance, and must be used mainly for testing purposes.

string udrForceDecode
 ( drudr  myUDR ,
 boolean  abortOnFail  ) //Optional
ParameterDescription

myUDR

The UDR to fully decode

abortOnFail

An optional argument. If not stated, true is assumed. If set to false, the workflow does not abort if decoding fails.

Returns

If decoding succeeds, null is returned. If not - and abortOnFail is set to false - an error message is returned.

udrGetErrorCodes

Returns a list of strings containing all error codes added to the UDR.

list <string> udrGetErrorCodes( drudr  myUDR  )
ParameterDescription

myUDR

The UDR

Returns

A list of strings with all error codes added to the UDR


udrGetErrorMessages

Returns a list of strings containing all error messages added to the UDR.

list <string> udrGetErrorMessages( drudr  myUDR  )
  
ParameterDescription

myUDR

The UDR

Returns

A list of strings with all error messages added to the UDR


udrGetErrorsAsString

Returns a string containing all error information that has been added to the UDR.

string udrGetErrorsAsString( drudr  myUDR  )
ParameterDescripton

myUDR

The UDR

Returns

A string with all error information added to the UDR

udrGetFields

Returns a list of the field names and field information in a UDR.

list<UDRFieldInfo> udrGetFields 
 ( drudr myUDR )
ParameterDescription

myUDR

The UDR.

Returns

list<UDRFieldInfo>

A list of the fields in the UDR and the field information. See the information below on UDRFieldInfo.

UDRFieldInfo is the UDR that is populated with the field information of the UDR that contains a list of fields.

The following fields are included in UDRFieldInfo:

FieldDescription
fieldName (string)The name of the field
fieldType (string)The field type, e g string, int, double etc.
isOptional (boolean)This indicates if the field is optional or not.
isReadOnly (boolean)This indicates if the field is read-only or not.


udrGetValue

Returns the value of fieldName in the myUDR.

any udrGetValue
 ( drudr  myUDR ,
 string  fieldname  )
ParameterDescription

myUDR

The UDR containing the field of interest

fieldname

A string, exactly matching the name of an existing field. If the field is OPTIONAL and is not present, the function returns null.

Constructed field names, that is subUDR.subField are allowed. If a field in the path is not present, null is returned in this case as well.

Returns

Any, depending on the field type


udrIsPresent

Returns true if the UDR field is present.

boolean udrIsPresent(identifier  field  )
ParameterDescription

field

The full field name including the UDR name. For instance, input.IN.moRecord.

Returns

true or false.

If a field is optional and not present, accessing the field will return the default null value that is null for object types, 0 for numeric types and false for boolean types.

Example - Using udrIsPresent

The function is recursive. If the optional field myField is to be accessed, and it is nested in three levels: fieldA.fieldB.myfield, and all levels are optional, only one if-statement is required:

if ( udrIsPresent( input.fieldA.fieldB.myField ) ) {
 // Some kind of operation.
}


udrMass Functions

The udrMass functions enable you to manage a decoder which purpose is to process large amounts of collected UDRs, while maintaining control over UDRs tailing bytes in between calls to consume .

The udrMass functions include:

  • udrMassCreateDecoder

  • udrMassClearBuffer
  • udrMassDecode

  • udrMassEOFCheck

  • udrMassGetDataTail
     

udrMassCreateDecoder

Creates a decoder object.

any udrMassCreateDecoder(string  decoderName )
ParameterDescription

decoderName

The name of the decoder object.

Returns:

A decoder object.

Example - Using udrMass* APL functions

any myDecoder;
initialize { 
 myDecoder = udrMassCreateDecoder("Default.ascii.asciiFile"); 
}
drain { 
 list<drudr> myList = listCreate(drudr); 
 string msg = udrMassEOFCheck(myDecoder, myList, false); 
 if (msg == null) {
 // Do something 
 } else { 
 // Error handling 
 } 
}
consume { 
 list<drudr> myList = listCreate(drudr); 
 string msg = udrMassDecode(myDecoder, myList, input, false); 
 if (msg == null) { 
 // Do something 
 } else { 
 // Error handling 
 } 
}

udrMassClearBuffer

The udrMassClearBuffer function clears the remaining buffer in the decoder.

void udrMassClearBuffer(any theDecoder)
ParameterDescription
theDecoder The decoder object that udrMassCreateDecoder generates
Returns:Nothing


udrMassDecode

The udrMassDecode function Decodes the bytearray input data by using the decoder, and generates it as a list.

Note!

See the example above, Using udrMass* APL Functions.

string udrMassDecode(
 any  theDecoder ,
 list<drudr> myList ,
 bytearray  inputData ,
 boolean  forceDecode )
ParameterDescription

theDecoder

The decoder object that udrMassCreateDecoder generates

myList

The product of the encoding process is saved as a list of UDRs.

inputData

The input data that is to be encoded into UDRs

forceDecode

Use true to force decoding (a full decode).

Returns:

If decoding fails, an error message is returned. Otherwise, returns null.

udrMassEOFCheck

The udrMassEOFCheck function attempts to decode any remaining bytes that are left behind and stored in the decoder. If the function executes and decoding is successful, the procedure sends endBatch to the decoder, the returned string is empty, and the myList parameter contains the UDRs. Otherwise, an error message is generated.

string udrMassEOFCheck(
 any theDecoder, 
 list<drudr> myList, 
 boolean forceDecode)
ParameterDescription

theDecoder

The decoder object that udrMassCreateDecoder generates

myList

The data that udrMassEOFCheck decodes

forceDecode

Use true to force decoding (a full decode).

Returns:

If decoding fails, an error message is returned. Otherwise, returns null.


udrMassGetDataTail

The  udrMassGetDataTail function makes the decoder generate the remaining bytes that it holds. The bytes are still stored in the decoder.

Note!

This function enables you to investigate the data that is stored in the decoder. Do not use it to reset the internal array of the remaining bytes.

bytearray udrMassGetDataTail(any  theDecoder )
ParameterDescription

theDecoder

The decoder object that udrMassCreateDecoder generates

Returns:

The raw bytearray data that the decoder in udrMassDecode uses as input. For further information see the section above, udrMassDecode.


udrRoute

The udrRoute function sends a UDR to a workflow route.

If no call to the route function is made, the agent will not have any outgoing routes in the Workflow Editor environment - it will not be possible to link to a subsequent agent.

The function routes a UDR to all the output routes, or a named output route. If the clone keyword is used, the UDR is cloned before output.

Note!

The udrRoute function cannot be used within global APL scripts, that is in code saved in the APL Code Editor.

void udrRoute
 ( drudr  myUDR ,
 string  routeName , //Optional
  clone  ) //Optional
ParameterDescription

myUDR

The UDR to send on

routeName

The route on which to send the UDR

clone

The UDR is cloned before routing on the output/outputs.

Returns

Nothing


udrSetValue

Sets the field named fieldName in the UDR myUDR to value .

void udrSetValue
 ( drudr  myUDR ,
 string  fieldName ,
 any  value  )
ParameterDescription

myUDR

The UDR, for which to set the field value

fieldName

A string, exactly matching an existing field. Constructed field names in the form of subUDR.subField are allowed. Trying to set a non-existing field will cause runtime error.

value

A value depending on the field type

Returns

Nothing


udrUnsetPresent

In the output files the Encoder maps by default, null fields as present but empty. This can be avoided by clearing a flag, Is Present, using the udrUnsetPresent function.

The field can be changed to Is Present again either via udrSetValue (see the section above, udrSetValue) or regular assignment of fields.

void udrUnsetPresent(identifier field )
ParameterDescription

field

The full name of the optional field including the UDR name. For instance, input.IN.moRecord.

Returns

Nothing