cobol_Tutorial1 - FairCom RTG includes a sample program to get you started. It is a simple COBOL application, so it can be run with most COBOL engines. This tutorial is provided only as background information for the curious programmer; it may be a useful way to verify the operation of the file system. It is NOT required for using FairCom RTG.
Sqlize Tutorial - You will also find a tutorial that demonstrates how to prepare your data for SQL access. This process is necessary only if you want to provide access to your data through relational interfaces such as SQL, ODBC, JDBC, etc.
cobol_Tutorial1
The cobol_tutorial1 sample program is a simple COBOL application which can be run with most COBOL engines. This tutorial will create a data table which is useful to verify if the file system is properly running.
Note: You do not need to use this tutorial to install or use FairCom RTG. It can be useful to verify the operation of the file system.
This tutorial is located in:
FairCom\Vx.x.x.RTG\win32\Driver\ctree.cobol\tutorials\Tutorial1\
(where FairCom\Vx.x.x.RTG is the installation directory and win32 is the platform directory)
COBOL Tutorial #1: Introductory Exercise - Simple Single Table
This program performs the following steps:
Initialize() - Connects to the FairCom RTG database engine.
Define() - Defines and creates a "customer master" (custmast.dat) table/file.
Manage() - Adds a few rows/records; reads the rows/records back from the database; displays the column/field content; and finally deletes the rows/records.
Done() - Disconnects from the FairCom RTG database engine.
Note: The sections on compiling and running the tutorial are specific to ACUCOBOL and isCOBOL. If you are using a different COBOL compiler, you will need to change the commands accordingly.
Compile cobol_Tutorial1 with ACUCOBOL
To compile the cobol_Tutorial1.cbl program, perform the following steps.
1. Copy the cobol_Tutorial1.cbl source into the directory that contains the ACUCOBOL-GT binaries, for example:
copy \FairCom\Vx.x.x.RTG\win32\Driver\ctree.cobol\tutorials\Tutorial1\cobol_Tutorial1.cbl C:\AcuGT\bin
2. Start the COBOL compiler as follows. The -f4 option instructs the ACUCOBOL COBOL compiler to generate an XFD file which defines the data used by the cobol_Tutorial1. This XFD file will be used later in this tutorial to demonstrate the SQL capabilities of the FairCom RTG solution.
cd C:\AcuGT\bin
ccbl32.exe -f4 cobol_Tutorial1.cblThis section is specific to ACUCOBOL. If you are using a different COBOL compiler, you will need to change the commands accordingly.
Compile cobol_Tutorial1 with isCOBOL
To compile the cobol_Tutorial1.cbl program, start the isCOBOL compiler as follows:
iscc.exe -efc cobol_Tutorial1.cblThe -efc option instructs the isCOBOL compiler to generate an XFD file which defines the data used by cobol_Tutorial1. This XFD file will be used in the tutorial below to demonstrate the SQL capabilities of the FairCom RTG COBOL Edition solution.
This section is specific to ACUCOBOL. If you are using a different COBOL compiler, you will need to change the commands accordingly.
Run cobol_Tutorial1 with ACUBOBOL
- Before running the tutorial, select the file system using one of the methods described above, such as setting the environment variable DEFAULT_HOST. For example: set DEFAULT_HOST=CTREE
- Move to the directory where cobol_Tutorial1 has been compiled and run it using the ACUCOBOL runtime
cd C:\AcuGT\bin
wrun32.exe cobol_Tutorial1.acuThis section is specific to ACUCOBOL. If you are using a different COBOL compiler, change the commands accordingly.
Run cobol_Tutorial1 with isCOBOL
Before running the tutorial, create a text file named test.properties in the working directory and put the following lines in it:
iscobol.file.index=ctree2
iscobol.sqlserver.iss=1
iscobol.isspath=.To run the cobol_Tutorial1 program, start the isCOBOL runtime as follows:
iscrun.exe –J-Discobol.conf=test.properties COBOL_TUTORIAL1iscobol.properties Setting: The tutorial will fail if you have the following setting in iscobol.properties:
iscobol.io_creates=1This section is specific to ACUCOBOL. If you are using a different COBOL compiler, change the commands accordingly.
If you run the tutorial with iscobol.io_creates=1 enabled, comment out that setting and delete the custmast.dat and custmast.idx files.
Open cobol_Tutorial1 data through SQL (optional)
If you are planning to provide SQL access to your COBOL data, this section provides a quick overview of the process. If not, it can be skipped.
To learn more about preparing for SQL access, the FairCom RTG COBOL Edition User Guide has a major section explaining the process and providing advanced tips for handling special considerations.
The cobol_Tutorial1 program creates a data file called CUSTMAST. The CUSTMAST file can be easily queried through FairCom DB SQL using the ISQL command-line utility or through the FairCom DB SQL Explorer GUI Tool.
To demonstrate this capability using ISQL, follow the instructions below:
1. Directly import the custmast.dat data file using the XFD file (ACUCOBOL) or ISS file (isCOBOL) generated when compiling cobol_Tutorial1.cbl. Using the ctutil -sqlize parameter will convert the XFD / ISS into an XDD file, insert it into the data file, and import the file into the specified FairCom DB SQL database.
\FairCom\V2.x.x.RTG\win32\tools\cmdline\ctutil.exe -sqlize custmast custmast.xfd ADMIN ctreeSQLFor isCOBOL:
\FairCom\V2.x.x.RTG\win32\tools\cmdline\ctutil.exe -sqlize custmast custmast.iss ADMIN ctreeSQL2. Start the ISQL interactive SQL utility:
\FairCom\V2.x.x.RTG\win32\tools\cmdline\isql.exe -u admin -a ADMIN ctreeSQL
3. From the interactive SQL prompt, list the records in the custmast table by using a SELECT SQL statement:
ISQL> SELECT * FROM CUSTMAST;Alternatively the XDD file can be generated from the XFD file and saved to disk using ctutil -xfd2xdd.
The generated XDD file can then be embedded inside the data file by using ctutil -sqlinfo.
The XDD file listed below, custmast.xdd, shows the cobol_Tutorial1 data that is obtained by executing:
\FairCom\V2.x.x.RTG\win32\tools\cmdline\ctutil.exe -xfd2xdd custmast.xfd
custmast.xdd:
<?xml version="1.0" encoding="US-ASCII"?>
<table name="CUSTMAST-FILE" maxRecLen="157" minRecLen="157">
<key segCount="1" duplicate="false">
<segment offset="0" size="4"/>
<part name="CM_CUSTNUMB" offset="0" size="4"/>
</key>
<schema name="CUSTMAST-FILE" size="157">
<field name="CM_CUSTNUMB" size="4" type="Alphanum" digits="4" scale="0"/>
<field name="CM_CUSTZIPC" size="9" type="Alphanum" digits="9" scale="0"/>
<field name="CM_CUSTSTAT" size="2" type="Alphanum" digits="2" scale="0"/>
<field name="CM_CUSTRTNG" size="1" type="Alphanum" digits="1" scale="0"/>
<field name="CM_CUSTNAME" size="47" type="Alphanum" digits="47" scale="0"/>
<field name="CM_CUSTADDR" size="47" type="Alphanum" digits="47" scale="0"/>
<field name="CM_CUSTCITY" size="47" type="Alphanum" digits="47" scale="0"/>
</schema>
</table>
cobol_Tutorial1 Source Code
IDENTIFICATION DIVISION.
PROGRAM-ID. cobol_Tutorial1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUSTMAST-FILE
ASSIGN TO "CUSTMAST"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS cm_custnumb
FILE STATUS IS st.
DATA DIVISION.
FILE SECTION.
FD CUSTMAST-FILE
RECORD CONTAINS 16 TO 1024 CHARACTERS.
01 CUSTMAST-RECORD.
03 cm_custnumb PIC X(4).
03 cm_custzipc PIC X(9).
03 cm_custstat PIC X(2).
03 cm_custrtng PIC X(1).
XFD VAR-LENGTH
03 cm_custname PIC X(47).
XFD VAR-LENGTH
03 cm_custaddr PIC X(47).
XFD VAR-LENGTH
03 cm_custcity PIC X(47).
WORKING-STORAGE SECTION.
77 st PIC X(2).
PROCEDURE DIVISION.
DECLARATIVES.
CUSTMAST-ERROR SECTION.
USE AFTER STANDARD ERROR PROCEDURE ON CUSTMAST-FILE.
CUSTMAST-ERR.
if file does not exist
if st = "35"
create table
perform Create_CustomerMaster_Table
open table
open i-o CUSTMAST-FILE
else
perform Handle_Error
end-if.
CUSTMAST-ERR-EXIT.
exit.
end declaratives.
main.
perform Init.
perform Define.
perform Manage.
perform Done.
display "Press <ENTER> key to exit . . .".
accept omitted end-accept.
stop run.
Init.
display "INIT".
no specific action is required to connect
Define.
display "DEFINE".
create table
perform Create_CustomerMaster_Table
open table
open i-o CUSTMAST-FILE.
Manage.
display "MANAGE".
populate the table with data
perform Add-Records.
display contents of table
perform Display_Records.
delete any existing records
perform Delete_Records.
Done.
display "DONE".
close CUSTMAST-FILE.
Create_CustomerMaster_Table.
display " Create table..."
create table
open output CUSTMAST-FILE
close CUSTMAST-FILE.
Delete_Records.
display " Delete records..."
move low-values to cm_custnumb
start CUSTMAST-FILE key not less cm_custnumb
perform until st not = "00"
read CUSTMAST-FILE next
at end
exit perform
not at end
delete CUSTMAST-FILE
end-read
end-perform.
Add_Records.
display " Add records..."
move "1000" to cm_custnumb.
move "92867" to cm_custzipc.
move "CA" to cm_custstat.
move "1" to cm_custrtng.
move "Bryan Williams" to cm_custname.
move "2999 Regency" to cm_custaddr.
move "Orange" to cm_custcity.
write CUSTMAST-RECORD.
move "1001" to cm_custnumb.
move "61434" to cm_custzipc.
move "CT" to cm_custstat.
move "1" to cm_custrtng.
move "Michael Jordan" to cm_custname.
move "13 Main" to cm_custaddr.
move "Harford" to cm_custcity.
write CUSTMAST-RECORD.
move "1002" to cm_custnumb.
move "73677" to cm_custzipc.
move "GA" to cm_custstat.
move "1" to cm_custrtng.
move "Joshua Brown" to cm_custname.
move "4356 Cambridge" to cm_custaddr.
move "Atlanta" to cm_custcity.
write CUSTMAST-RECORD.
move "1003" to cm_custnumb.
move "10034" to cm_custzipc.
move "MO" to cm_custstat.
move "1" to cm_custrtng.
move "Keyon Dooling" to cm_custname.
move "19771 Park Avenue" to cm_custaddr.
move "Columbia" to cm_custcity.
write CUSTMAST-RECORD.
Display_Records.
display " Display records..."
move low-values to cm_custnumb
start CUSTMAST-FILE key not less cm_custnumb
perform until st not = "00"
read CUSTMAST-FILE next
at end
exit perform
not at end
display " " with no advancing
display cm_custnumb " " with no advancing
display cm_custname
end-read
end-perform.
Handle_Error.
display "ERROR: [" st "]"
display "*** Execution aborted ***"
display "Press <ENTER> key to exit..."
accept omitted end-accept
stop run.
Sqlize Tutorial
A tutorial is provided to explain how to prepare your data for SQL access, a process called "sqlizing." This process is necessary only if you want to provide access to your data through relational interfaces such as SQL, ODBC, JDBC, etc.
This tutorial is located in:
FairCom\Vx.x.x.RTG\win32\Driver\ctree.cobol\tutorials\Sqlize\
(where FairCom\Vx.x.x.RTG is the installation directory and win32 is the platform directory.)
The Sqlize Tutorial COBOL source code is compatible with the Micro Focus ACUCOBOL compiler, Veryant isCOBOL, and Micro Focus starting with Visual COBOL 2010 release. Please check with FairCom regarding future support for other COBOL compilers.
For a thorough description of this tutorial, see the FairCom RTG COBOL Edition User's Guide.
SQLIZEEXAMPLE.CBL
IDENTIFICATION DIVISION.
PROGRAM-ID. SQLIZEEXAMPLE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
COPY "CARDFILE.SL".
DATA DIVISION.
FILE SECTION.
COPY "CARDFILE.FD".
WORKING-STORAGE SECTION.
01 WS_CARDFILE_STATUS_CODE PIC XX.
01 WS_CARDFILE_STATUS_CODE_85 PIC X(14).
01 WS_CRED_NUM_X PIC X(20).
01 WS_CRED_NUM_X_2 PIC X(10).
01 WS_VALID_CRED_NUM PIC S9(2) COMP.
01 WS_LEN_CRED_NUM PIC S9(2) COMP.
01 WS_COUNT PIC 9(4).
01 WS_TOTAL_RECORDS PIC 9(8) VALUE ZEROS.
01 WS_DATA_REMAINS_SWITCH PIC X(2) VALUE SPACES.
01 WS_VALID_CARDS PIC 9(4).
01 WS_DISP_X PIC X(47).
LINKAGE SECTION.
SCREEN SECTION.
PROCEDURE DIVISION.
DECLARATIVES.
CARDHERROR SECTION.
USE AFTER ERROR PROCEDURE ON CARDFILE.
ERROR-ROUTINE.
IF WS_CARDFILE_STATUS_CODE = "35"
OPEN OUTPUT CARDFILE
CLOSE CARDFILE
OPEN INPUT CARDFILE
ELSE
CALL "C$RERR" USING WS_CARDFILE_STATUS_CODE_85
DISPLAY 'ERROR ON FILE:'
DISPLAY WS_CARDFILE_STATUS_CODE_85
DISPLAY "Press enter to exit:"
ACCEPT WS_CRED_NUM_X
STOP RUN
END-IF.
END DECLARATIVES.
MAIN SECTION.
MAIN-PARA.
MOVE ZERO TO WS_VALID_CARDS.
MOVE ZERO TO WS_TOTAL_RECORDS.
MOVE ZERO TO WS_VALID_CRED_NUM.
DISPLAY ""
DISPLAY "|--------------------------------------------|"
DISPLAY "| Please visit us on |"
DISPLAY "| www.FairCom.com |"
DISPLAY "| FairCom Corporation |"
DISPLAY "| 6300 West Sugar Creek Drive |"
DISPLAY "| Columbia, MO 65203 |"
DISPLAY "|--------------------------------------------|"
DISPLAY "| This program lists and counts |"
DISPLAY "| all credit card holders within a file |".
DISPLAY "| whose credit card numbers are similar |".
DISPLAY "| to a sequence provided by the user. |".
DISPLAY "| Once it processed the whole file |".
DISPLAY "| it displays the total counting number. |".
DISPLAY "|--------------------------------------------|"
DISPLAY ""
PERFORM UNTIL WS_VALID_CRED_NUM = 1
DISPLAY "Please provide a number to search for:"
DISPLAY "XXXXXXXXXX (1-10 digits)"
MOVE 0 TO WS_CRED_NUM_X
ACCEPT WS_CRED_NUM_X
MOVE 0 TO WS_COUNT
MOVE 0 TO WS_LEN_CRED_NUM
INSPECT WS_CRED_NUM_X REPLACING
ALL LOW-VALUE BY SPACE
INSPECT WS_CRED_NUM_X
TALLYING WS_COUNT FOR TRAILING SPACE
COMPUTE WS_LEN_CRED_NUM =
LENGTH OF WS_CRED_NUM_X - WS_COUNT
IF WS_LEN_CRED_NUM <= 10 THEN
IF WS_LEN_CRED_NUM > 0 THEN
MOVE 1 TO WS_VALID_CRED_NUM
ELSE
DISPLAY ""
DISPLAY "ERROR: INVALID INPUT!"
DISPLAY "Insert at least 1 digit."
DISPLAY ""
END-IF
ELSE
DISPLAY ""
DISPLAY "ERROR: INVALID INPUT!"
DISPLAY "Greater than 10 digits."
DISPLAY ""
END-IF
END-PERFORM.
OPEN I-O CARDFILE.
READ CARDFILE NEXT
AT END MOVE 'NO' TO WS_DATA_REMAINS_SWITCH
END-READ.
PERFORM PROCESS-RECORDS
UNTIL WS_DATA_REMAINS_SWITCH = 'NO'.
PERFORM PRINT_SUMMARY.
CLOSE CARDFILE.
010-PROCESS.
GOBACK.
PROCESS-RECORDS.
MOVE CARD-RECORD-NUMBER TO WS_CRED_NUM_X_2.
MOVE WS_CRED_NUM_X_2(1:WS_LEN_CRED_NUM)
TO WS_CRED_NUM_X_2.
IF WS_CRED_NUM_X_2 = WS_CRED_NUM_X
ADD 1 TO WS_VALID_CARDS
IF WS_VALID_CARDS = 1 THEN
DISPLAY ""
DISPLAY "|--------------------------------------------|"
DISPLAY "|CARD NUMBER | NAME |"
END-IF
MOVE "| " TO WS_DISP_X
MOVE CARD-RECORD-NUMBER TO WS_DISP_X(3:10)
MOVE " | " TO WS_DISP_X(13:5)
MOVE CARD-CUSTOMER-NAME TO WS_DISP_X(18:28)
MOVE " |" TO WS_DISP_X(43:4)
DISPLAY WS_DISP_X
END-IF.
ADD 1 TO WS_TOTAL_RECORDS.
READ CARDFILE NEXT
AT END MOVE 'NO' TO WS_DATA_REMAINS_SWITCH
DISPLAY "|--------------------------------------------|"
DISPLAY ""
END-READ.
PRINT_SUMMARY.
DISPLAY "TOTAL NUMBER OF CARDS MATCHING:".
DISPLAY WS_VALID_CARDS.
DISPLAY "TOTAL NUMBER OF RECORDS READ:"
DISPLAY WS_TOTAL_RECORDS.
DISPLAY "Press enter to exit:"
ACCEPT WS_CRED_NUM_X
DISPLAY "|--------------------------------------------|"
DISPLAY "| Thank you for trying our SQLIZE Tutorial |"
DISPLAY "| Please visit us on |"
DISPLAY "| www.FairCom.com |"
DISPLAY "|--------------------------------------------|"
.
CARDFILE.FD
* This file is intended to be used as a tutorial
* for FairCom RTG COBOL Edition developers to learn
* about the multiple ways that a file descriptor
* is mapped into a SQL table within FairCom DB SQL.
* All copyrights belong to FairCom, Corp.
* **********************************************************
* The main file of this tutorial is CARDFILE, a file that
* contains records of a reward membership card for customers.
* **********************************************************
FD CARDFILE.
01 CARDRECORD-MASTER.
05 CARDRECORD-KEY.
10 CARD-RECORD-NUMBER PIC 9(10).
10 CARD REDEFINES CARD-RECORD-NUMBER.
15 CARD-1 PIC 9(6).
15 CARD-2 PIC 9(4).
* **********************************************************
* -----------------> TUTORIAL HINT <-----------------------
*
* By default xddgen expands the innermost fields.
* The "USE GROUP" directive is used here to force xddgen,
* when building the SQL table, to consider the entire
* CARD-TITLE-NUMBER group as one field instead of expanding
* its subfields. In this case we want to expose it and not
* its children.
*
* **********************************************************
*>>XDD USE GROUP
10 CARD-TITLE-NUMBER.
15 CARD-TITLE-NUMBER-1 PIC 9(4).
15 CARD-TITLE-NUMBER-2 PIC 9(6).
10 CARD-TITLE-NUMBER-X REDEFINES CARD-TITLE-NUMBER
PIC 9(10).
10 CUSTOMER-NUMBER PIC 9(4).
10 ELITE-MEMBER-TYPE PIC X.
88 CARD-GOLD VALUE "G".
88 CARD-PLATINUM VALUE "P".
88 CARD-SILVER VALUE "S".
***********************************************************
* CARD IDENTIFICATION DEFINITION
***********************************************************
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
*
* This is an example of the usage of multi-record with SQL.
* You can notice that CARD-TABLE is redefined later in this
* file by CARD-TABLE-PLATINUM which includes additional fields.
* This means that this table in COBOL has two different types
* of records, with different size. FairCom RTG can handle this
* properly, as long as you indicate what are the rules that
* the SQL server needs to use to decide which record belongs
* to which table. To do this, you use the following XDD directive:
* *>>XDD WHEN ... TABLENAME=...
* This will instruct FairCom RTG to create two separate SQL tables
* representing each separate set of records, depending on the
* condition that has been established for values within each
* record.
* Notice that physically there is still a single COBOL file
* which allows you to run your COBOL programs with no modification.
* FairCom RTG handles this dynamically, building SQL tables as
* if they were actually views, and updating the indexes in
* accordance to the file definition.
* In this example, we are forcing FairCom RTG to create two tables
* one for regular members ad one for Platinum members.
***********************************************************
*>>XDD WHEN ELITE-MEMBER-TYPE != "P" TABLENAME="REGULARMEMBERS"
05 CARD-TABLE.
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
*
* There are at maximum three copies of each membership card
* assigned to different family member, of which the first one
* is only assigned while the other two are optionally assigned.
* We needed to build an index on CARD-FAMILY-NUMBER of the
* first copy of the card. Therefore instead of coding a
* OCCURS 3, we explicitly add fields for the first card copy and
* coded a OCCURS 2 for the rest.
***********************************************************
*>>XDD USE GROUP
10 CARD-FAMILY-NUMBER-1.
15 CARD-LABEL-NUMBER-1 PIC 9(4).
15 CARD-MAIN-NUMBER-1 PIC 9(8).
15 CARD-NUMBER-CRC-1 PIC 9(2).
*>>XDD DATE = YYMMDD
10 EMISSION-DATE-1 PIC 9(6) COMP-6.
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
* The example below shows how to combine multiple XDD directives
* into a single line. In this example, we combined USE GROUP
* to force SQL to use the name of the group as the SQL field
* and a specific format to display this field as a date
* as YMD. There are multiple other formats available, please
* refer to the documentation for other options.
***********************************************************
*>>XDD USE GROUP
*>>XDD DATE=YYMMDD
10 VALID-UNTIL-DATE-1 PIC 9(6) COMP-6.
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
* Here is the OCCURS 2 we talked about earlier.
* OCCURS are handled automatically by FairCom RTG when converting
* this table into SQL. xddgen automatically expands every
* occurr into multiple fields, using numbered extensions such
* as "_1", "_2" and so on.
* Therefore the fields would be named as follows
* CARD_FAMILY_NUMBER_1
* EMISSION_DATE_1
* VALID_UNTIL_DATE_1
* CARD_FAMILY_NUMBER_2
* EMISSION_DATE_2
* VALID_UNTIL_DATE_2
* The first three fields cause a field name conflict, with the
* some fields previously defined in the structure (the three fields we
* specified outside the occurs at lines 57, 63, 76).
* This field name conflict does not allow the table to be "sqlized"
* since field names must be unique.
* The solution to this is to use the *>>XDD NAME directive to assign
* a different name for SQL to the conflicting fields.
* the result of the directive below is the following fields:
* EMISSION_DATE_1
* VALID_UNTIL_DATE_1
* CARD_FAMILY_NUMB_1
* EMISSION_1
* VALID_UNTIL_1
* CARD_FAMILY_NUMB_2
* EMISSION_2
* VALID_UNTIL_2
***********************************************************
10 GROUP-TITLE-INFO OCCURS 2 TIMES.
*>>XDD USE GROUP
*>>XDD NAME=CARD_FAMILY_NUMB
15 CARD-FAMILY-NUMBER.
20 CARD-LABEL-NUMBER PIC 9(4).
20 CARD-MAIN-NUMBER PIC 9(8).
20 CARD-NUMBER-CRC PIC 9(2).
*>>XDD USE GROUP
*>>XDD NAME=EMISSION
*>>XDD DATE = YYMMDD
15 EMISSION-DATE PIC 9(6) COMP-6.
*>>XDD USE GROUP
*>>XDD NAME=VALID_UNTIL
*>>XDD DATE=YYMMDD
15 VALID-UNTIL-DATE PIC 9(6) COMP-6.
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
* The example below shows the usage of HIDDEN as a directive
* that will instruct SQL to not display this field.
* With this directive, this field will simply not be displayed.
***********************************************************
*>>XDD HIDDEN
10 RESERVED PIC X(4).
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
* Fillers are hidden by default so there is no need to use
* directives here.
***********************************************************
10 FILLER PIC X(10).
***********************************************************
* -----------------> TUTORIAL HINT <-----------------------
*
* Here it comes the platinum member table we described above
***********************************************************
*>>XDD WHEN ELITE-MEMBER-TYPE="P" TABLENAME="PLATINUMMEMBERS"
05 CARD-TABLE-PLATINUM REDEFINES CARD-TABLE.
10 GROUP-TITLE-INFO-PLT OCCURS 3 TIMES.
15 CARD-FAMILY-NUMBER-PLT.
20 CARD-LABEL-NUMBER-PLT PIC 9(4).
20 CARD-MAIN-NUMBER-PLT PIC 9(8).
20 CARD-NUMBER-CRC-PLT PIC 9(2).
*>>XDD DATE=YYMMDD
15 EMISSION-DATE-PLT PIC 9(6) COMP-6.
*>>XDD DATE=YYMMDD
15 VALID-UNTIL-DATE-PLT PIC 9(6) COMP-6.
10 GROUP-REWARDS-POINTS.
15 TOTAL-POINTS PIC 9(8).
*>>XDD DATE=YYMMDD
15 EXPIRATION-DATE PIC 9(6) COMP-6.
*>>XDD DATE=YYMMDD
15 LAST-TRANS-DATE PIC 9(6) COMP-6.
05 CARD-GROUP-NUMBER PIC 9(4).
05 CARD-EMBOSS-FLAG PIC X(1).
*>>XDD USE GROUP
05 CARD-CUSTOMER-NAME.
10 CARD-CUSTOMER-LAST PIC X(30).
10 CARD-CUSTOMER-FIRST PIC X(20).
10 CARD-CUSTOMER-M PIC X(1).
05 CARD-ADDRESS.
10 CARD-STREET PIC X(40).
10 CARD-STREET-2 PIC X(40).
10 CARD-CITY PIC X(15).
10 CARD-STATE PIC X(2).
10 CARD-ZIP PIC 9(5) COMP-6.
05 CARD-CUSTOMER-SEX PIC X(1).
88 CARD-MEMBER-MAL VALUE "M".
88 CARD-MEMBER-FEM VALUE "F".
*>>XDD DATE=YYYYMMDD
05 CARD-CUSTOMER-BIRTH-DATE PIC 9(8) COMP-6.
CARDFILE.SL
* This file is intended to be used as a tutorial
* for c-treeRTG COBOL Edition developers to learn
* about the multiple ways that a file descriptor
* is mapped into a SQL table within FairCom DB SQL.
* All copyrights belong to FairCom, Corp.
SELECT CARDFILE
ASSIGN TO "CARDFILE"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS
CARDRECORD-KEY
ALTERNATE RECORD KEY IS
SPLIT-KEY-NAME-1 =
CARD-CUSTOMER-NAME,
CARD-GROUP-NUMBER
WITH DUPLICATES
ALTERNATE RECORD KEY IS
SPLIT-KEY-NAME-2 =
CARD-GROUP-NUMBER,
CARD-TITLE-NUMBER,
CARD-FAMILY-NUMBER-1
WITH DUPLICATES
ALTERNATE RECORD KEY IS
CARD-EMBOSS-FLAG
WITH DUPLICATES
FILE STATUS IS WS_CARDFILE_STATUS_CODE.
rules.xml
<XFDrules>
<rule sequence="100">
<when>
<field hidden="true"/>
</when>
<do>
<add>
<field bindefault="all-spaces"/>
</add>
</do>
</rule>
</XFDrules>
isCOBOL Samples
The FairCom RTG COBOL product contains a directory that includes sample programs described in this section. The samples directory is located in \Driver\ctree.cobol\samples\iscobol under the FairCom installation directory.
Accessing ESQL from isCOBOL
isCOBOL supports Embedded SQL (ESQL), which is an alternate way to access FairCom DB files. This is a product of isCobol and is not to be confused with the ESQL available from FairCom.
FairCom RTG COBOL contains a directory that includes the ESQL sample program described in this section. The samples directory is located in \Driver\ctree.cobol\samples\iscobol under the FairCom installation directory.
Compile cobol-esql with isCOBOL
To compile the cobol-esql.cbl program, start the isCOBOL compiler as follows.
iscc.exe –sp=C:\Program Files\Veryant\isCOBOL\sample\isdef cobol-esql.cblThe –sp option instructs the isCOBOL compiler where to find the SQLCA copybook.
Run cobol-esql with isCOBOL
Before running the tutorial, either copy ctreeJDBC.jar to the isCOBOL lib directory or add ctreeJDBC.jar to the CLASSPATH environment variable.
To run the cobol-esql program, start the isCOBOL runtime as follows:
iscrun.exe COBOL_ESQL