BBjErrorMappingAction

Description

In BBj 8.0 and higher, BBjErrorMappingAction throws an !ERROR=82 (RECORD_SET_MAPPING) when asked to map a value.

Implemented Interfaces

BBjMappingAction

Creation

BBjAPI > BBjRecordSet > BBjErrorMappingAction

A BBjErrorMappingAction object is created through the following BBjRecordSet method:

Return Value

Method

BBjErrorMappingAction

createErrorMappingAction()

Methods of BBjErrorMappingAction

None.

Methods of BBjErrorMappingAction implemented for BBjMappingAction

Return Value

Method

int

getType()

Remarks

This object is useful for enumerated sets that have a known set of values, which should be covered by the primary value source mapping.

Constants

None.

Example

rem ' This sample introduces a RecordSetValue Source mapping

rem ' Mappings can be done with any type of recordset, they are done here
rem ' with MemoryRecordSets so the example stands on it's own.
rem ' Here we map Location, a number to be one of several regions.
rem '0= NORTH, 1= SOUTH, 2 = WEST, 3 = EAST
rem ' we specify an ErrorMappingAction because anything other than these 4 values is exceptional
rem ' see also the FormatMappingAction.
declare BBjRecordSet UserRS!
declare BBjRecordSet MapRS!
GOSUB SetupRecordSets
declare BBjMappingSource source!
declare BBjMappingAction action!

rem 'configure our source and fallback action
source! = UserRS!.createRecordSetMappingSource(MapRS!,"CODE","DESC")
action! = UserRS!.createErrorMappingAction()

rem 'Add the recordset
UserRS!.addMapping("LOCATION","MAPPED_LOC",source!,action!)
UserRS!.first()
while(1)
    gosub printRecord
    UserRS!.next(err=*end)
wend
end

printRecord:
    name$ = UserRS!.getCurrentRecordData().getFieldValue("NAME")
    location$ = UserRS!.getCurrentRecordData().getFieldValue("MAPPED_LOC")
    PRINT name$, " lives in the ", location$
return

SetupRecordSets:
    UserRS! = BBJAPI().createMemoryRecordSet("NAME:C(100* = 10),LOCATION:C(1)")
    Data! = UserRS!.getEmptyRecordData()
    Data!.setFieldValue("NAME", "John Doe")
    Data!.setFieldValue("LOCATION", "1")
    UserRS!.insert(Data!)
    Data! = UserRS!.getEmptyRecordData()
    Data!.setFieldValue("NAME", "Jane Smith")
    Data!.setFieldValue("LOCATION", "3")
    UserRS!.insert(Data!)
    Data! = UserRS!.getEmptyRecordData()
    Data!.setFieldValue("NAME", "Jane Doe")
    Data!.setFieldValue("LOCATION", "2")
    UserRS!.insert(Data!)
    Data! = UserRS!.getEmptyRecordData()
    Data!.setFieldValue("NAME", "Dr Droopy")
    Data!.setFieldValue("LOCATION", "0")
    UserRS!.insert(Data!)

    rem ' Create the recordset to use for mapping LOCATION to something more screenfriendly.
    MapRS! = BBjAPI().createMemoryRecordSet("CODE:C(1),DESC:C(20* = 10)")
    Data! = MapRS!.getEmptyRecordData()
    Data!.setFieldValue("CODE","0")
    Data!.setFieldValue("DESC","NORTH")
    MapRS!.insert(Data!)
    Data! = MapRS!.getEmptyRecordData()
    Data!.setFieldValue("CODE","1")
    Data!.setFieldValue("DESC","SOUTH")
    MapRS!.insert(Data!)
    Data! = MapRS!.getEmptyRecordData()
    Data!.setFieldValue("CODE","2")
    Data!.setFieldValue("DESC","EAST")
    MapRS!.insert(Data!)
    Data! = MapRS!.getEmptyRecordData()
    Data!.setFieldValue("CODE","3")
    Data!.setFieldValue("DESC","WEST")
    MapRS!.insert(Data!)
return

See Also

BBjAPI

BBjSysGui

BBjRecordSet

   BBjRecordSet::addMapping

BBjFormatMappingAction

BBjMappingAction

Working with RecordSet Mappings

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.