This section goes through the steps involved in creating a Built-In Function that will become part of the inline code of a LANSA function. The example is very simple but it will give you an understanding of how a Built-In Function fits into a LANSA system.
SCENARIO: This is a User Defined Built-In Function. The Built-In Function is used to flip dates from YYMMDD format to DDMMYY format.
The Built-in function will need some data structures (I SPECS) and some code (C SPECS) to drive the date manipulation.
The Built-In Function will be called UD_FLIP_DATE.
The next available identifier is 412.
BIF Definition (as per DC@F47 file)
|
Argument List (as per DC@F48 file)
|
Return Values (as per DC@F48 file)
|
Enter the data into the Built-In Function definition files: Create a member in QBIFSRC called BIF412ISPC and write the code for the data structures:
I* Code used by built-in function 412 - UD_FLIP_DATE
I*
IDATEIN DS
I 1 60NUMDI
I 1 20YRIN
I 3 40MNIN
I 5 60DYIN
I*
IDATEOU DS
I 1 60NUMDO
I 1 20DYOU
I 3 40MNOU
I 5 60YROU
Create a member in QBIFSRC called BIF412CSPC and write the code to manipulate the dates.
C*====================================================
C* IB@412 : UD_FLIP_DATE
C*====================================================
CSR IB@412 BEGSR
C*
C MOVEL'Y' DC@RET
C*
C Z-ADDB@412A NUMDI
C*
C MOVELDYIN DYOU
C MOVELMNIN MNOU
C MOVELYRIN YROU
C*
C Z-ADDNUMDO B@412B
C*
CSR ENDSR
These source members will be included in the inline code of a LANSA function that uses this Built-In Function by /COPY commands generated at compile time.