#### 19.1.5 Example - Define a Built-In Function as a 3GL Subroutine

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)

 BIF Name: UD_FLIP_DATE Unique Identifier: 412 Description: Change date from YYMMDD to DDMMYY Call or Execute: E Program Name: IB@412 Terminates between calls: N Number of arguments: 1 Number of return values: 1

Argument List  (as per DC@F48 file)

 BIF Name: UD_FLIP_DATE Parameter Type ARG Parameter Sequence: 1 Parameter No: 1 Parameter Ident: A Description: Date in YYMMDD Required / Optional: R    (R or O) Parameter Type: N    (A, N or L) Minimum Length: 6 Maximum Length: 6 Minimum Decimal: Maximum Decimal: Pass Length: 6 Pass Decimal: Default:

Return Values (as per DC@F48 file)

 BIF Name: UD_FLIP_DATE Parameter Type RET Parameter Sequence: 1 Parameter Number: 2 Parameter Identifier: B Description: Date out (DDMMYY) Required / Optional: R    (R or O) Parameter Type: N    (A, N or L) Minimum Length: 6 Maximum Length: 6 Minimum Decimal: Maximum Decimal: Pass Length: 6 Pass Decimal:

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*

C                     MOVELDYIN      DYOU

C                     MOVELMNIN      MNOU

C                     MOVELYRIN      YROU

C*