Data Aware Grid Channels - BBj


For this topic's original documentation, see Data Aware Grid Channels.

As of BBj 4.0, data aware grids can manipulate OEM-formatted or Julian dates using INPUTD controls.

Attribute

Description

Example

DATE

Sets column style to INPUTD, and selects a particular OEM format. If DATE is specified without an OEM code, the date is assumed to be a numeric Julian date. For a list of OEM date codes, see OEM Date Formats. The example program below demonstrates several OEM date formats. OEM date columns should be defined as C(len), where (len) is the defined length of the OEM format. Julian date columns can be specified as any numeric type that is big enough for a 7-digit number.

"invoice_date:C(3):DATE=AON:"

"expiry_date:I(4):DATE:"

Y2KWINDOW

When using an OEM date format that is not inherently Y2K-compliant, a Y2KWINDOW must be specified. This shifts the two-digit years forward some number of years from the original implied range of 1900..1999. For example, Y2KWINDOW=30 indicates that the database now assumes a range of 1930..2029. If Y2KWINDOW is not specified, it is assumed to be 0, and valid dates remain in the range 1900..1999. The CITI, SSI, DISC(6) and DISC(8) MM/DD/YY formats must set a Y2KWINDOW that is consistent with the value defined by the application.

"order_date:C(6):DATE=DISC Y2KWINDOW=50:"

MASK

There are three different mask formats, controlled by the following trigger characters in the mask:

If the mask contains any '#' characters, numeric masking rules are used and the field is rendered with an INPUTN control.

If the mask contains any '%' characters, date masking is used (based on the rules of the DATE() function) and the field is rendered with an INPUTD control.

If the mask doesn't contain any '#' or '%' characters, string masking rules
are used and the field is rendered using an INPUTE control.

order_date:N(7*):MASK=%Mz/%Dz/%Yl:

invoice_total:B:MASK=$###,###.00:"

customer_code:C(6):MASK=000000:"

OMASK

The OMASK attribute is not currently supported with INPUTD fields.

 

Example

rem 'Data-aware grid for OEM date formats

rem 'Obtain the instance of the BBjAPI object
let myAPI!=BBjAPI()

rem 'Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI)"X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui!=myAPI!.getSysGui()

rem 'Set Locale (and default date mask) to German
Locale$=STBL("!LOCALE","de_DE")

rem 'Template for the sample record
TMPL$="KEY:C(1):MASK=A:,"
: +"AON3:C(3):DATE=AON:,"
: +"AON6:C(6):DATE=AON:,"
: +"AON8:C(8):DATE=AON:,"
: +"CITI:C(3):DATE=CITI Y2KWINDOW=30:,"
: +"CYYMMDD:C(7):DATE=CYYMMDD:,"
: +"DISC6:C(6):DATE=DISC Y2KWINDOW=50:,"
: +"DISC8a:C(8):DATE=DISC:,"
: +"DISC8b:C(8):DATE=DISC Y2KWINDOW=50:,"
: +"DISC10:C(10):DATE=DISC:,"
: +"MAI:C(3):DATE=MAI:,"
: +"SOA:C(6):DATE=SOA:,"
: +"SSI6:C(6):DATE=SSI Y2KWINDOW=40:,"
: +"SSI8:C(8):DATE=SSI:,"
: +"SSIJ:C(6):DATE=SSIJ:,"
: +"YMD8:C(8):DATE=YMD8:,"
: +"MonthDayYear6:C(6):DATE=MonthDayYear:,"
: +"MonthDayYear8:C(8):DATE=MonthDayYear:,"
: +"MonthDayYear10:C(10):DATE=MonthDayYear:,"
: +"DayMonthYear6:C(6):DATE=DayMonthYear:,"
: +"DayMonthYear8:C(8):DATE=DayMonthYear:,"
: +"DayMonthYear10:C(10):DATE=DayMonthYear:,"
: +"Julian:U(4):DATE=Julian:,"
: +"Date:U(4):DATE:"

rem 'Create the data file
GOSUB CreateDataFile

rem 'Create the main window, initially invisible
myWindow! = mySysGui!.addWindow(0,200,1500,120,"Data Aware Grid",$00000010$)

rem 'Open the data file
let DATACHAN=UNT
OPEN (DATACHAN) "BBjDAGrid.dat"

rem 'Create the grid
BBjGrid!=MyWindow!.addDataAwareGrid(500,10,10,1480,100,DATACHAN,TMPL$)

rem 'Setup the grid
GOSUB SetupGrid

rem 'Make the window visible
myWindow!.setVisible(mySysGui!.TRUE)

rem 'Register callback routines
CALLBACK(ON_CLOSE,EXIT_PROGRAM,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine that is called upon user exit
EXIT_PROGRAM:
release

rem 'Routine to create the data file
CreateDataFile:
    rem 'KEY,AON3,AON6,AON8,CITI,CYYMMDD,DISC6,DISC8a
    rem 'DISC8b,DISC10,MAI,SOA,SSI6,SSI8,SSIJ
    rem 'YMD8,MonthDayYear6,MonthDayYear8,MonthDayYear10,DayMonthYear6,DayMonthYear8,DayMonthYear10
    rem 'Julian,Julian
    rem ' July 10, 1964
    DATA "A",$60272a$,"640710","19640710",$640710$,"0640710","640710","19640710"
    DATA "07/10/64","07/10/1964",$60272a$,">L0710","640710","19640710","2535BB"
    DATA "19640710","071064","07101964","07/10/1964","100764","10071964","10/07/1964"
    DATA JUL(1964,7,10),JUL(1964,7,10)

    rem ' August 15, 2003
    DATA "B",$87282f$,"A30815","20030815",$030815$,"1030815","030815","20030815"
    DATA "08/15/03","08/15/2003",$87282f$,"?30815","030815","20030815","256D83"
    DATA "20030815","081503","08152003","08/15/2003","150803","15082003","15/08/2003"
    DATA JUL(2003,8,15),JUL(2003,8,15)

    rem ' February 29, 2008
    DATA "C",$8c223d$,"A80229","20080229",$080229$,"1080229","080229","20080229"
    DATA "02/29/08","02/29/2008",$8c223d$,"?80229","080229","20080229","2573F3"
    DATA "20080229","022908","02292008","02/29/2008","290208","29022008","29/02/2008"
    DATA JUL(2008,2,29),JUL(2008,2,29)

    rem 'Create the data file
    ERASE "BBjDAGrid.dat",ERR=CREATE_FILE

CREATE_FILE:
    DIM REC$:TMPL$
    MKEYED "BBjDAGrid.dat",[0:1:1],0,LEN(TMPL$)
    let DATACHAN=UNT
    OPEN (DATACHAN) "BBjDAGrid.dat"
    while 1
        DREAD REC.KEY$,ERR=*BREAK
        DREAD REC.AON3$,ERR=*BREAK
        DREAD REC.AON6$,ERR=*BREAK
        DREAD REC.AON8$,ERR=*BREAK
        DREAD REC.CITI$,ERR=*BREAK
        DREAD REC.CYYMMDD$,ERR=*BREAK
        DREAD REC.DISC6$,ERR=*BREAK
        DREAD REC.DISC8a$,ERR=*BREAK
        DREAD REC.DISC8b$,ERR=*BREAK
        DREAD REC.DISC10$,ERR=*BREAK
        DREAD REC.MAI$,ERR=*BREAK
        DREAD REC.SOA$,ERR=*BREAK
        DREAD REC.SSI6$,ERR=*BREAK
        DREAD REC.SSI8$,ERR=*BREAK
        DREAD REC.SSIJ$,ERR=*BREAK
        DREAD REC.YMD8$,ERR=*BREAK
        DREAD REC.MonthDayYear6$,ERR=*BREAK
        DREAD REC.MonthDayYear8$,ERR=*BREAK
        DREAD REC.MonthDayYear10$,ERR=*BREAK
        DREAD REC.DayMonthYear6$,ERR=*BREAK
        DREAD REC.DayMonthYear8$,ERR=*BREAK
        DREAD REC.DayMonthYear10$,ERR=*BREAK
        DREAD REC.Julian,ERR=*BREAK
        DREAD REC.Date,ERR=*BREAK
        WRITE RECORD (DATACHAN) REC$
    wend
    CLOSE (DATACHAN)
return

rem 'Routine to set up the grid
SetupGrid:
    rem 'Set the grid attributes
    BBjGrid!.setHorizontalScrollable(mySysGui!.TRUE)
    BBjGrid!.setVerticalScrollable(mySysGui!.TRUE)
    BBjGrid!.setDefaultColumnWidth(60)
    BBjGrid!.setScrollUpdate(mySysGui!.TRUE)
    BBjGrid!.setDefaultAlignment(mySysGui!.GRID_ALIGN_LEFT)
    BBjGrid!.setHasColumnHeader(mySysGui!.TRUE)
    BBjGrid!.setDefaultAlignment(mySysGui!.GRID_ALIGN_LEFT)
return

See Also

BBjInputD

BBjInputE

BBjInputN

OEM Date Formats

DATE Function - BBj