Skip to content

Working with the Getting Started application – Basic

First run the precompiler:

 citoesql sample.cbl
  • The -g parameter is required if you want to compile for debugging. You can omit it from release builds.
  • The -conf=citoesql.conf parameter sets compiler options required by CitOESQL including running CitOESQL’s preprocessor and linking its runtime library.
  • You can also run CitOESQL as a standalone preprocessor and then compile the generated output file.

Next compile the file generated by CitOESQL, which will have the same name but a .cbp extension.

  • Windows: cobc -g -l%COBOLITDIR%\lib\ citoesqlr_dll.lib sample.cbp
  • Linux: cobc -g -L\$COBOLITDIR/lib -lcitoesqlr sample.cbp

Note

The -I parameter links CitOESQL’s runtime library.

The application can now be executed using cobcrun. Enter the DSN, User-ID and Password when prompted. The console output should be as follows:

cobcrun sample
Create/insert/update/drop test

Enter data source (Eg odbcdemo) MyDSN
Enter username[('.'\|'/')password] (Eg admin/) myUserId.myPassword
Drop table
Error(anticipated) : cannot drop table
-00003701
Cannot drop the table 'mfesqltest', because it does not exist
Create table
Insert row
Commit
Update row
Verify data before rollback
Rollback
Verify data after rollback
Drop table
Disconnect
Create table after commit release
Cannot create table as expected
-00019702
Connection name not found.
Test completed without error

You can debug the application using cobcdb, as detailed in the Using the COBOL-IT Debugger section of the COBOL-IT Compiler Suite, Getting Started With Compiler Suite guide.

To build an executable program rather than the default dll or shared object add -x to the command line as shown in the example below:

 cobc -x -g -conf=citoesql.conf sample.cbl

Working with the Getting Started application in Developer Studio

Prerequisites

Set up a new workspace by following the steps documented in the Developer Studio Getting Started manual. In summary:

  1. Validate the COBOL-IT license using the menu sequence Window > Preferences > COBOL then click the Browse button to select the COBOL-IT license file.

  2. Using the menu sequence Window > Preferences > General > Editors > Text Editor, ensure Show line numbers has been checked.

  3. Using the menu sequence Window > Preferences > General > Workspace:

    1. De-select Build automatically
    2. Select Refresh using native hooks or polling
    3. Select Refresh on access
    4. Select Save automatically before build
  4. Using the menu sequence Window > Preferences > Run/Debug > Perspectives, select Always for the Open the associated perspective when launching.


Project creation and import of source code

Follow the steps listed to create a new project and import source code.

  1. Select File > New > COBOL Project… to open the COBOL Project Wizard.

  2. Enter a project name, for example samples, and click Finish.

  3. Right click on the newly created project and select New > Folder, enter the name object and click Finish.

  4. Right click on the project again and select Import followed by General and FileSystem then click Next.

  5. Click Browse and navigate to the COBOL-IT samples > sql directory, then click OK. Select sample.cbl and click Finish.

  6. Right click on the project again and select Properties followed by COBOL Properties then check the Enable source settings option.

  7. Select DevOps Tools > Debugging Tools. Check Enable source settings and Produce debugging metadata in compiled object.

  8. Select Dialects > Compiler Configuration Files. Enter citoesql.conf for Use <file> as configuration file.

  9. Select Link > Full Build and set Build type to Build executable program.

  10. Select Standard Options and check Save object file in source folder or in <directory> and enter object in the textbox.

  11. Click Apply and Close.


Build and Debugging

To build the project use the menu sequence Project > Clean, ensure the project is selected for cleaning and building and then click Clean.

You now need to set up a debug configuration as follows:

  1. Double click on sample.cbl to open the source file.

  2. Scroll down to the EXEC SQL CONNECT statement, right click the shaded area to the left of the line number of the EXEC SQL line and choose Toggle Breakpoint. A blue circle should appear next to the line number. You can also use double click to set and unset breakpoints as an alternative to right click.

  3. Right click on sample.cbl in the project file tree in the left-hand pane, select Debug As followed by Debug Configurations.

  4. Click on Cobol Program followed by the left most icon in the toolbar above (New launch configuration) and enter ‘sample’ as the configuration name at the top of the dialog box.

  5. Check that the Project Name is set to the correct project and that Program is set to sample.cbl.

  6. Click Debug.

  7. Respond to the prompts from the program with the ODBC Data Source Name, User-ID and Password.

  8. The application will stop on the breakpoint. You can now use other debugger features to inspect COBOL variables, manage other breakpoints, use single step code execution, etc. Please consult COBOL-IT Developer Studio, Getting Started: The Debugger Perspectiveguide for more information.

Back to top