Our application will not compile and run unless we provide code that declares our table, provides a COBOL record to receive the data, and provides a COBOL record for indicator variables. You can use OpenESQL Assistant to generate a copybook that contains all of this code and an INCLUDE statement to call the copybook. You can also use OpenESQL Assistant to embed the INCLUDE statement into the program.
You want to send the output from the application to the console in a readable format. This requires additional code we enter into the program manually.
OpenESQL Assistant generates the copybook and brings up the Generate Host Variable Declarations dialog box, giving you the opportunity to name it. The default name of the copybook is tablename.cpy. In this case, the name of the generated copybook is emp.cpy.
On the Auxiliary Code tab, you see that OpenESQL Assistant has also generated an INCLUDE statement to call the copybook from the program.
*> ------------------------------------------- *> COBOL HOST VARIABLES FOR TABLE EMP *> ------------------------------------------- 01 EMP-EMPNO STRING. 01 EMP-FIRSTNME STRING. 01 EMP-MIDINIT STRING. 01 EMP-LASTNAME STRING. 01 EMP-WORKDEPT STRING. 01 EMP-PHONENO STRING. 01 EMP-HIREDATE type System.DateTime. 01 EMP-JOB STRING. 01 EMP-EDLEVEL BINARY-SHORT. 01 EMP-SEX STRING. 01 EMP-BIRTHDATE type System.DateTime. 01 EMP-SALARY DECIMAL. 01 EMP-BONUS DECIMAL. 01 EMP-COMM DECIMAL. *> ------------------------------------------- *> COBOL INDICATOR VARIABLES FOR TABLE EMP *> ------------------------------------------- 01 EMP-WORKDEPT-NULL BINARY-SHORT. 01 EMP-PHONENO-NULL BINARY-SHORT. 01 EMP-HIREDATE-NULL BINARY-SHORT. 01 EMP-JOB-NULL BINARY-SHORT. 01 EMP-EDLEVEL-NULL BINARY-SHORT. 01 EMP-SEX-NULL BINARY-SHORT. 01 EMP-BIRTHDATE-NULL BINARY-SHORT. 01 EMP-SALARY-NULL BINARY-SHORT. 01 EMP-BONUS-NULL BINARY-SHORT. 01 EMP-COMM-NULL BINARY-SHORT.
01 EDIT-PAY PIC Z,ZZ99.99.
IF SQLCODE=0
MOVE EMP-SALARY TO EDIT-PAY
DISPLAY 'ROW FOUND'
DISPLAY 'NAME: ' EMP-LASTNAME ', ' EMP-FIRSTNME ' SALARY: ' EDIT-PAY UPON CONSOLE
This completes the tutorial. Next, please complete Tutorial: Run the Application.