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. In Visual Studio, open the solution named LBLDURATION, which is located in the %PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\SQL\hcopg\LBLDURATION directory.
  2. From the Solution Explorer, open 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
  3. Close the code editor.

Analyze LBLDURATION project properties

  1. Open the project properties for the LBLDURATION project.
  2. Notice that the Output type on the Application tab is Console Application.
  3. Switch to the COBOL tab, and set the following:
    Configuration Active(Debug)
    Platform target x86
  4. Switch to the SQL tab. 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)1 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(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
    1 To run against PostgreSQL GDG, you would need to change this to TARGETDB=PGSQL.