Analyze the LBLDURATION Project

Guides you through the process of analyzing the LBLDURATION COBOL program and project to become familiar with its use of SQL and to learn how it is compiled for HCOPG.

Analyze EXEC SQL in LBLDURATION.cbl

  1. From the Eclipse IDE, click File > Import.
  2. Expand General, and select Existing Projects into Workspace; then click Next.
  3. Select Select root directory; then browse to the %PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\SQL\hcopg\LBLDURATION directory, and click Select Folder.
  4. On the Projects list, check LBLDURATION.
  5. Check Copy projects into workspace.
  6. Click Finish. Eclipse loads the project and builds it automatically.
  7. From the COBOL Explorer, expand LBLDURATION > COBOL Programs; then double-click the LBLDURATION.cbl file to view its contents. Pay particular attention to the following EXEC SQL statement:
               EXEC SQL 
                   DECLARE CSR69 CURSOR FOR SELECT 
                    A.PROJNO
                   ,A.PROJNAME
                   ,A.PRSTDATE
                   ,A.PRENDATE
                   ,(((DAYS(A.PRENDATE) - DAYS(A.PRSTDATE) ) / 7) + 1) * 40 
                   AS MANHOURS
                   FROM PROJ A
                   ORDER BY A.PROJNAME
               END-EXEC
    This contains your labeled duration calculation:
    ,(((DAYS(A.PRENDATE) - DAYS(A.PRSTDATE) ) / 7) + 1) * 40
    In this case, you are using the DAYS labeled duration in a calculation where you:
    • Start with the number of days between the start and end date for projects
    • Divide that number by 7 to get the number of weeks
    • Add 1 to account for truncation of a partial week
    • Multiply that result by 40 to get the number of hours needed to complete the project
  8. Close the code editor.

Analyze LBLDURATION project properties

  1. Open the project properties for the LBLDURATION project.
  2. Expand Micro Focus > Project Settings > COBOL; then select SQL Preprocessor. Several OpenESQL compiler directives have been set for you. The following table offers a brief description of each:
    SQL(DBMAN=ODBC) Uses an ODBC connection
    SQL(TARGETDB=POSTGRESQL) Target database is PostgreSQL
    SQL(DB=HCODemo) PostgreSQL connection name is HCODemo
    SQL(PASS=userid.password) Database login credentials
    SQL(DIALECT=MAINFRAME) HCOPG database syntax conversion is enabled
    SQL(DBRMLIB) EXEC-SQL commands are extracted and placed in database request module (DBRM)
    SQL(DATE=USA) Date output is in USA format
    SQL(INIT) Initiates the database connection
    SQL(QUALIFIER=TEST) Schema qualifier is TEST
    SQL(NOCHECK) No SQL compile-time checking performed
    SQL(BEHAVIOR=OPTIMIZED) Optimizes migration process