主题思想,除了业务操作类以BO实现外,除非已有现成BO,查询/报表 不通过BO实现。
LIfeAsia文件的IO通过开发Java版本的IO来达到同样目的,LifeAsia的查询类程序通过PCML来调用,业务操作通过开发BO来实现。
(1)LifeAsia的Cobol版本的文件IO 以java版本来实现。最终调用代码类似。
Clnt clnt = new Clnt();
clnt.setClntpfx(Common.CLNTPFX);
clnt.setClntcoy(Common.CLNTCOY);
clnt.setClntnum(clntnum);
clnt.setIOF_(IOF.READR);
Clntio.io(clnt);
(2)PCML调用,通过IBM的PCML类调用LA的已有程序。比如HRTOTLON。
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-FUNCTION", loanCalCPY.getFunction());
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-STATUZ", Common.O_K);
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-CHDRCOY",loanCalCPY.getChdrcoy());
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-CHDRNUM",loanCalCPY.getChdrnum());
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-PRINCIPAL",new BigDecimal(0.0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-INTEREST",new BigDecimal(0.0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-LOAN-COUNT",new BigDecimal(0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-EFFECTIVE-DATE",loanCalCPY.getEffective_date());
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-BATCHKEY"," ");
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-TRANNO",new BigDecimal(0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-TRANID.TOTL-TRAN-TERM"," ");
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-TRANID.TOTL-TRAN-DATE",new BigDecimal(0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-TRANID.TOTL-TRAN-TIME",new BigDecimal(0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-TRANID.TOTL-TRAN-USER",new BigDecimal(0));
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-LANGUAGE","S");
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-POST-FLAG","N");
pcml.setValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-LOAN-NUMBER",loanCalCPY.getLoan_number());
// Request to call the API
rc = pcml.callProgram(pcmlfile);
// If return code is false, we received messages from the server
if(rc == false)
{
AS400Message[] msgs = pcml.getMessageList(pcmlfile);
// Iterate through messages and write them to standard output
for (int m = 0; m < msgs.length; m++)
{
msgId = msgs[m].getID();
msgText = msgs[m].getText();
System.out.println(" " + msgId + " - " + msgText);
}
System.out.println("** Call to PCMLTEST failed. See messages above **");
loanCalCPY.setStatuz(Common.BOMB);
loanCalCPY.setPrincipal(new BigDecimal(0.0));
loanCalCPY.setInterest (new BigDecimal(0.0));
loanCalCPY.setLoan_count(0);
}
else
{
loanCalCPY.setStatuz((String)pcml.getValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-STATUZ"));
loanCalCPY.setPrincipal((BigDecimal)pcml.getValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-PRINCIPAL"));
loanCalCPY.setInterest ((BigDecimal)pcml.getValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-INTEREST"));
loanCalCPY.setLoan_count(pcml.getIntValue("HRTOTLON.TOTL-TOTLOAN-REC.TOTL-LOAN-COUNT"));
}
(3)BO调用(没写好,待优化)
BORetPair boRetPair = new BORetPair(); String REQDATA = ""; String RESDATA = ""; ZSILCLTI icpy = new ZSILCLTI(); icpy = (ZSILCLTI)object; //Get BO Leader_Heade&SessionI String strBOHDR = BOrfmlUtil.getBOLDRHDRSESSIONIByClient(userId, BOrfmlUtil.VERB_ENQ, EnvParam.DEFAULTLANGUAGE ); //Get BO Message RecordFormatDocument rfmlin = RFMLFactory.getRFML(rfmlfilein); RecordFormatDocument rfmlout = RFMLFactory.getRFML(rfmlfileout); icpy.setRfmlFields(rfmlin); String strMSG = AS400CharConv.getInstance().byteArrayToString(rfmlin.toByteArray(BOrfmlUtil.MSGHDRREC)) + AS400CharConv.getInstance().byteArrayToString(rfmlin.toByteArray(BOrfmlUtil.MSGDTAREC)); REQDATA = strBOHDR + strMSG; // BO long a = System.currentTimeMillis(); BOHBOHCPY cpy = new BOHBOHCPY(REQDATA); if(!BOHBOHCL.programCall(cpy)){ return boRetPair; } RESDATA = cpy.getRspdta(); System.out.println(RESDATA.length()); System.out.println("BO Use time "+(System.currentTimeMillis()-a) + " ms"); a = System.currentTimeMillis(); RfmlBase.setValues(rfmlout,BOrfmlUtil.MSGDTAREC, AS400CharConv.getInstance().stringToByteArray(RESDATA.substring(130))); System.out.println("BO Use time "+(System.currentTimeMillis()-a) + " ms"); a = System.currentTimeMillis(); RfmlBase.setValues(rfmlout,BOrfmlUtil.MSGDTAREC, AS400CharConv.getInstance().stringToByteArray(RESDATA.substring(130,10000))); System.out.println("rfml analy Use time "+(System.currentTimeMillis()-a) + " ms"); CltUwrO cltUwrO = new CltUwrO(); cltUwrO.loadValueFromRfmlFields(rfmlout);