package
cobolprogramclasses;
/************************************************************************
**This file automatically generated from Cobol
program CBLEX
**Generated at time 16:01:14.31 on Wednesday,
12/16/09
************************************************************************/
import
coboldataclasses.Rpt1;
import
coboldataclasses.Rpt2;
import
coboldataclasses.Sqlca;
import
coboldataclasses.Sqlda;
import
coboldataclasses.Rpt1Headers;
import
coboldataclasses.Rpt2Headers;
import coboldataclasses.Rpt1Data;
import
coboldataclasses.Rpt2Data;
import
com.res.java.lib.*;
import
java.math.BigDecimal;
public class
Cblex extends Program {
//****************************************************************
//* A sample program which updates the
salaries for those *
//* employees whose current commission
total is greater than or *
//* equal to the value of COMMISSION. The
salaries of those who *
//* qualify are increased by the value of
PERCENTAGE retroactive *
//* to RAISE-DATE. A report is generated
showing the projects *
//* which these employees have contributed
to ordered by the *
//* project number and employee ID. A
second report shows each *
//* project having an end date
occurring after RAISE-DATE *
//* (i.e. potentially affected by the
retroactive raises ) with *
//* its total salary expenses and a count
of employees who *
//* contributed to the project. *
//****************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",35,8)
//01
PRINT-RECORD PIC X(132).
public String getPrintRecord() {
return super.toString(0,132);
}
public
void setPrintRecord(String val) {
super.valueOf(0,132,val);
}
//@CobolSourceFile("EXEC-SQL1.cob",38,8)
//77
WORK-DAYS PIC S9(4) BINARY VALUE 253.
public int getWorkDays() {
return super.getBinaryInt(132,4);
}
public
void setWorkDays(int val) {
super.setBinaryInt(132,4,val,true);
}
//@CobolSourceFile("EXEC-SQL1.cob",39,8)
//77
RAISE-DATE PIC X(11) VALUE "1982-06-01".
public String getRaiseDate() {
return super.toString(134,11);
}
public
void setRaiseDate(String val) {
super.valueOf(134,11,val);
}
//@CobolSourceFile("EXEC-SQL1.cob",40,8)
//77
PERCENTAGE PIC S999V99 PACKED-DECIMAL.
public BigDecimal getPercentage() {
return
super.getPackedDecimalBigDecimal(145,6,2);
}
public
void setPercentage(BigDecimal val) {
super.setPackedDecimalBigDecimal(145,6,val,2,true);
}
//@CobolSourceFile("EXEC-SQL1.cob",41,8)
//77
COMMISSION PIC S99999V99 PACKED-DECIMAL VALUE 2000.00.
public BigDecimal getCommission() {
return
super.getPackedDecimalBigDecimal(148,8,2);
}
public
void setCommission(BigDecimal val) {
super.setPackedDecimalBigDecimal(148,8,val,2,true);
}
//***************************************************************
//*
Structure for report 1. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",47,8)
//01
RPT1.
private Rpt1 rpt1 = new Rpt1();
public byte[] getRpt1() {
return rpt1.getBytes();
}
public void setRpt1(byte[] val) {
rpt1.valueOf(val);
}
//***************************************************************
//*
Structure for report 2. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",58,8)
//01
RPT2.
private Rpt2 rpt2 = new Rpt2();
public byte[] getRpt2() {
return rpt2.getBytes();
}
public void setRpt2(byte[] val) {
rpt2.valueOf(val);
}
//*
EXEC SQL
//* INCLUDE SQLCA
//*
END-EXEC.
//@CobolSourceFile("EXEC-SQL1.cob",66,8)
//01 SQLCA.
private Sqlca sqlca = new Sqlca();
public byte[] getSqlca() {
return sqlca.getBytes();
}
public void setSqlca(byte[] val) {
sqlca.valueOf(val);
}
//@CobolSourceFile("EXEC-SQL1.cob",89,9)
//01 SQLDA.
private Sqlda sqlda = new Sqlda();
public byte[] getSqlda() {
return sqlda.getBytes();
}
public void setSqlda(byte[] val) {
sqlda.valueOf(val);
}
//@CobolSourceFile("EXEC-SQL1.cob",106,9)
//77
CODE-EDIT PIC ---99.
public int getCodeEdit() {
return super.getDisplayInt(152,4,false,false,false);
}
public
void setCodeEdit(int val) {
super.setDisplayInt(152,4,val,false,false,false);
}
//***************************************************************
//*
Headers for reports. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",112,8)
//01
RPT1-HEADERS.
private Rpt1Headers rpt1Headers = new
Rpt1Headers();
public byte[] getRpt1Headers() {
return rpt1Headers.getBytes();
}
public void setRpt1Headers(byte[] val) {
rpt1Headers.valueOf(val);
}
//@CobolSourceFile("EXEC-SQL1.cob",122,8)
//01
RPT2-HEADERS.
private Rpt2Headers rpt2Headers = new
Rpt2Headers();
public byte[] getRpt2Headers() {
return rpt2Headers.getBytes();
}
public void setRpt2Headers(byte[] val) {
rpt2Headers.valueOf(val);
}
//@CobolSourceFile("EXEC-SQL1.cob",137,8)
//01
RPT1-DATA.
private Rpt1Data rpt1Data = new
Rpt1Data();
public byte[] getRpt1Data() {
return rpt1Data.getBytes();
}
public void setRpt1Data(byte[] val) {
rpt1Data.valueOf(val);
}
//@CobolSourceFile("EXEC-SQL1.cob",146,8)
//01
RPT2-DATA.
private Rpt2Data rpt2Data = new
Rpt2Data();
public byte[] getRpt2Data() {
return rpt2Data.getBytes();
}
public void setRpt2Data(byte[] val) {
rpt2Data.valueOf(val);
}
public static void main(String[] args) {
Cblex instance_ = new Cblex();
instance_.initialize();
instance_.doCobolGotoStart();
System.exit(0);
}
Paragraph a000Main=new Paragraph(this) {
public CobolMethod run() {
//@CobolSourceFile("EXEC-SQL1.cob",159,12)
//MOVE 1.04 TO PERCENTAGE
setPercentage(new BigDecimal(1.04));
//@CobolSourceFile("EXEC-SQL1.cob",160,12)
//OPEN OUTPUT PRINTFILE
//***************************************************************
//* Update the selected employees by
the new percentage. If an *
//* error occurs during the update,
ROLLBACK the changes, *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",167,13)
//EXEC SQL
//
WHENEVER SQLERROR
if (false) {
//@CobolSourceFile("EXEC-SQL1.cob",168,35)
//GO TO E010-UPDATE-ERROR
return e010UpdateError;
}
//@CobolSourceFile("EXEC-SQL1.cob",170,13)
//EXEC SQL
//
UPDATE CORPDATA/EMPLOYEE
// SET SALARY = SALARY * :PERCENTAGE
// WHERE COMM >= :COMMISSION
dao.execSqlStatement1(getPercentage(),getCommission());
//***************************************************************
//*
Commit changes. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",180,13)
//EXEC SQL
// COMMIT
dao.execSqlStatement2();
//@CobolSourceFile("EXEC-SQL1.cob",184,12)
//EXEC SQL
// WHENEVER SQLERROR
if (false) {
//@CobolSourceFile("EXEC-SQL1.cob",185,35)
//GO TO E020-REPORT-ERROR
return e020ReportError;
}
//***************************************************************
//*
Report the updated statistics for each employee receiving *
//*
a raise and the projects that s/he participates in *
//***************************************************************
//***************************************************************
//*
Write out the header for Report 1. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",197,12)
//write print-record from
rpt1-header1
// before advancing 2 lines
//@CobolSourceFile("EXEC-SQL1.cob",199,12)
//write print-record from
rpt1-header2
// before advancing 1 line
//@CobolSourceFile("EXEC-SQL1.cob",201,13)
//exec sql
//
declare c1 cursor for
// SELECT DISTINCT projno, empprojact.empno,
// lastname||",
"||firstnme ,salary
// from corpdata/empprojact,
corpdata/employee
// where empprojact.empno =employee.empno
and
// comm >= :commission
// order by projno, empno
dao.execSqlStatement3(getCommission());
//@CobolSourceFile("EXEC-SQL1.cob",210,13)
//EXEC SQL
//
OPEN C1
dao.execSqlStatement4();
//@CobolSourceFile("EXEC-SQL1.cob",214,12)
//PERFORM B000-GENERATE-REPORT1 THRU
B010-GENERATE-REPORT1-EXIT
//
UNTIL SQLCODE NOT EQUAL TO ZERO
while(sqlca.getSqlcode() == 0) {
doCobolPerform(b000GenerateReport1,b010GenerateReport1Exit);
};
return doCobolExit();
}
};
Paragraph a100Done1=new Paragraph(this) {
public CobolMethod run() {
//@CobolSourceFile("EXEC-SQL1.cob",217,12)
//EXEC SQL
// CLOSE C1
//*************************************************************
//*
For all projects ending at a date later than the RAISE- *
//*
DATE ( i.e. those projects potentially affected by the *
//*
salary raises generate a report containing the project *
//*
project number, project name, the count of employees *
//*
participating in the project and the total salary cost *
//*
for the project *
//*************************************************************
//***************************************************************
//*
Write out the header for Report 2. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",235,12)
//MOVE SPACES TO PRINT-RECORD
setPrintRecord(" ");
//@CobolSourceFile("EXEC-SQL1.cob",236,12)
//WRITE PRINT-RECORD BEFORE
ADVANCING 2 LINES
//@CobolSourceFile("EXEC-SQL1.cob",237,12)
//WRITE PRINT-RECORD FROM
RPT2-HEADER1
// BEFORE ADVANCING 2 LINES
//@CobolSourceFile("EXEC-SQL1.cob",239,12)
//WRITE PRINT-RECORD FROM
RPT2-HEADER2
// BEFORE ADVANCING 1 LINE
//@CobolSourceFile("EXEC-SQL1.cob",241,12)
//WRITE PRINT-RECORD FROM
RPT2-HEADER3
// BEFORE ADVANCING 2 LINES
//@CobolSourceFile("EXEC-SQL1.cob",244,12)
//EXEC SQL
// DECLARE C2 CURSOR FOR
// SELECT EMPPROJACT.PROJNO, PROJNAME,
COUNT(*),
// SUM (
(DAYS(EMENDATE)-DAYS(EMSTDATE)) *
// EMPTIME * DECIMAL((SALARY /
:WORK-DAYS),8,2))
// FROM CORPDATA/EMPPROJACT,
CORPDATA/PROJECT,
// CORPDATA/EMPLOYEE
// WHERE EMPPROJACT.PROJNO=PROJECT.PROJNO
AND
// EMPPROJACT.EMPNO =EMPLOYEE.EMPNO
AND
// PRENDATE > :RAISE-DATE
// GROUP BY EMPPROJACT.PROJNO, PROJNAME
// ORDER BY 1
dao.execSqlStatement5(getWorkDays(),getRaiseDate());
//@CobolSourceFile("EXEC-SQL1.cob",257,12)
//EXEC SQL
// OPEN C2
dao.execSqlStatement6();
//@CobolSourceFile("EXEC-SQL1.cob",261,12)
//PERFORM C000-GENERATE-REPORT2 THRU
C010-GENERATE-REPORT2-EXIT
// UNTIL SQLCODE NOT EQUAL TO ZERO
while(sqlca.getSqlcode() == 0) {
doCobolPerform(c000GenerateReport2,c010GenerateReport2Exit);
};
return doCobolExit();
}
};
Paragraph a200Done2=new Paragraph(this) {
public CobolMethod run() {
//@CobolSourceFile("EXEC-SQL1.cob",265,12)
//EXEC SQL
// CLOSE C2
return doCobolExit();
}
};
Paragraph a900MainExit=new Paragraph(this)
{
public CobolMethod run() {
//***************************************************************
//*
All done.
*
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",274,12)
//CLOSE PRINTFILE
//@CobolSourceFile("EXEC-SQL1.cob",275,12)
//STOP RUN
System.exit(0);
return doCobolExit();
}
};
Paragraph b000GenerateReport1=new
Paragraph(this) {
public CobolMethod run() {
//***************************************************************
//*
Fetch and write the rows to PRINTFILE. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",281,13)
//EXEC SQL
//
WHENEVER NOT FOUND
if (false) {
//@CobolSourceFile("EXEC-SQL1.cob",282,36)
//GO TO A100-DONE1
return a100Done1;
}
//@CobolSourceFile("EXEC-SQL1.cob",284,13)
//EXEC SQL
//
FETCH C1 INTO :PROJECT.PROJNO, :RPT1.EMPNO,
// :RPT1.NAME, :RPT1.SALARY
try {
dao.execSqlStatement7();
if(dao.resultExists()) {
setProjno(dao.getResult().getInt(1));
rpt1.setEmpno(dao.getResult().getString(2));
rpt1.setName(dao.getResult().getString(3));
rpt1.setSalary(dao.getResult().getBigDecimal(4));
}
} catch(Exception e) {
e.printStackTrace();
}
//@CobolSourceFile("EXEC-SQL1.cob",288,12)
//MOVE CORRESPONDING RPT1 TO
RPT1-DATA
//* MOVE PROJNO OF RPT1 TO PROJNO OF RPT1-DATA.
//@CobolSourceFile("EXEC-SQL1.cob",290,12)
//WRITE PRINT-RECORD FROM RPT1-DATA
// BEFORE ADVANCING 1 LINE
return doCobolExit();
}
};
Paragraph b010GenerateReport1Exit=new
Paragraph(this) {
public CobolMethod run() {
return doCobolExit();
}
};
Paragraph c000GenerateReport2=new
Paragraph(this) {
public CobolMethod run() {
//***************************************************************
//*
Fetch and write the rows to PRINTFILE. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",301,12)
//EXEC SQL
// WHENEVER NOT FOUND
if (false) {
//@CobolSourceFile("EXEC-SQL1.cob",302,36)
//GO TO A200-DONE2
return a200Done2;
}
//@CobolSourceFile("EXEC-SQL1.cob",304,13)
//EXEC SQL
//
FETCH C2 INTO :RPT2
try {
dao.execSqlStatement8();
if(dao.resultExists()) {
setRpt2(dao.getResult().getBytes(1));
}
} catch(Exception e) {
e.printStackTrace();
}
//@CobolSourceFile("EXEC-SQL1.cob",307,12)
//MOVE CORRESPONDING RPT2 TO
RPT2-DATA
//@CobolSourceFile("EXEC-SQL1.cob",308,12)
//WRITE PRINT-RECORD FROM RPT2-DATA
// BEFORE ADVANCING 1 LINE
return doCobolExit();
}
};
Paragraph c010GenerateReport2Exit=new
Paragraph(this) {
public CobolMethod run() {
return doCobolExit();
}
};
Paragraph e010UpdateError=new
Paragraph(this) {
public CobolMethod run() {
//***************************************************************
//*
Error occured while updating table.
Inform user and *
//*
rollback changes. *
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",320,13)
//EXEC SQL
//
WHENEVER SQLERROR
if (false) {
//@CobolSourceFile("EXEC-SQL1.cob",321,35)
//CONTINUE
}
//@CobolSourceFile("EXEC-SQL1.cob",323,12)
//MOVE SQLCODE TO CODE-EDIT
setCodeEdit(sqlca.getSqlcode());
//@CobolSourceFile("EXEC-SQL1.cob",324,12)
//STRING "*** ERROR Occurred
while updating table. SQLCODE="
// CODE-EDIT DELIMITED BY SIZE INTO
PRINT-RECORD
//@CobolSourceFile("EXEC-SQL1.cob",326,12)
//WRITE PRINT-RECORD
//@CobolSourceFile("EXEC-SQL1.cob",327,13)
//EXEC SQL
//
ROLLBACK
//@CobolSourceFile("EXEC-SQL1.cob",330,12)
//STOP RUN
System.exit(0);
return doCobolExit();
}
};
Paragraph e020ReportError=new
Paragraph(this) {
public CobolMethod run() {
//***************************************************************
//*
Error occured while generating reports.
Inform user and *
//*
exit.
*
//***************************************************************
//@CobolSourceFile("EXEC-SQL1.cob",338,12)
//MOVE SQLCODE TO CODE-EDIT
setCodeEdit(sqlca.getSqlcode());
//@CobolSourceFile("EXEC-SQL1.cob",339,12)
//STRING "*** ERROR Occurred
while generating reports. SQLCODE="
CODE-EDIT DELIMITED BY SIZE INTO PRINT-RECORD
//@CobolSourceFile("EXEC-SQL1.cob",341,12)
//WRITE PRINT-RECORD
//@CobolSourceFile("EXEC-SQL1.cob",342,12)
//STOP RUN
System.exit(0);
return doCobolExit();
}
};
private Cblex() {
super(new CobolBytes(156));
}
private void initialize() {
setWorkDays(253);
setRaiseDate("1982-06-01");
setCommission(new
BigDecimal(2000.00));
rpt1.initialize();
rpt2.initialize();
sqlca.initialize();
sqlda.initialize();
rpt1Headers.initialize();
rpt2Headers.initialize();
rpt1Data.initialize();
rpt2Data.initialize();
}
private cobolprogramclasses.dao.CblexDao
dao = new cobolprogramclasses.dao.CblexDao();
}