This discussion is archived
2 Replies Latest reply: May 14, 2012 10:15 PM by Sahar Hassan RSS

Arrange Numbers of Months into TermFrom and TermTo

Sahar Hassan Explorer
Currently Being Moderated
JDev 11.1.1.5.0 ADF BC

I have a Row array where user will input number of months like:

Number of Months
50
45
30

Now I want to store this to a table like:
TermFrom TermTo
---------- --------------
0 49
50 94
95 124

Requirement is: TermFrom will initially be 0 and TermTo will be months[0]-1. In the second iteration, TermFrom will have the value of months[0] and TermTo will have value of months[0]+months[1] and so on. I don't know how to write a Java code to meet this. Please help.
        BindingContainer bindings = getBindings();
        Integer term = 1;
        OperationBinding operationBinding = bindings.getOperationBinding("saveSummary");
        DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("summaryIterator");
        DCIteratorBinding crIter = (DCIteratorBinding) bindings.get("CreditAppraisal_EOVO1Iterator");
        Row crRow = crIter.getCurrentRow();
        BigDecimal srNo = new BigDecimal(crRow.getAttribute("SerialNo").toString());
        for(int i=0;i<dcib.getEstimatedRowCount()-1;i++){
            Row row = dcib.getRowAtRangeIndex(i);
            BigDecimal emi = new BigDecimal(row.getAttribute("EMI").toString());
            BigDecimal gmi = new BigDecimal(row.getAttribute("GMI").toString());
            BigDecimal iir = new BigDecimal(row.getAttribute("IIR").toString());
            operationBinding.getParamsMap().put("amEmi", emi);
            operationBinding.getParamsMap().put("amTermFrom", term);
            term = Integer.parseInt(row.getAttribute("termsMonths").toString());
            operationBinding.getParamsMap().put("amTermTo", term-1);
            operationBinding.getParamsMap().put("amGmi", gmi);
            operationBinding.getParamsMap().put("amIIR", iir);
            operationBinding.getParamsMap().put("serialNo", srNo);
            operationBinding.execute();
        }
Above code is what I tried.
But then that is resulted to achieve like:
TermFrom TermTo
---------- --------------
0 49
50 44
95 29

Edited by: Sahar Hassan on May 14, 2012 7:36 AM
  • 1. Re: Arrange Numbers of Months into TermFrom and TermTo
    Timo Hahn Oracle ACE
    Currently Being Moderated
    You need to add the start term to get the correct from term
    BindingContainer bindings = getBindings();
            Integer term = 1;
            OperationBinding operationBinding = bindings.getOperationBinding("saveSummary");
            DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("summaryIterator");
            DCIteratorBinding crIter = (DCIteratorBinding) bindings.get("CreditAppraisal_EOVO1Iterator");
            Row crRow = crIter.getCurrentRow();
            BigDecimal srNo = new BigDecimal(crRow.getAttribute("SerialNo").toString());
            for(int i=0;i<dcib.getEstimatedRowCount()-1;i++){
                Row row = dcib.getRowAtRangeIndex(i);
                BigDecimal emi = new BigDecimal(row.getAttribute("EMI").toString());
                BigDecimal gmi = new BigDecimal(row.getAttribute("GMI").toString());
                BigDecimal iir = new BigDecimal(row.getAttribute("IIR").toString());
                operationBinding.getParamsMap().put("amEmi", emi);
                operationBinding.getParamsMap().put("amTermFrom", term);
                Interger fromTerm = term;  // sate it to add it to get the end point
                term = Integer.parseInt(row.getAttribute("termsMonths").toString());
                operationBinding.getParamsMap().put("amTermTo", fromTerm + term-1);
                operationBinding.getParamsMap().put("amGmi", gmi);
                operationBinding.getParamsMap().put("amIIR", iir);
                operationBinding.getParamsMap().put("serialNo", srNo);
                operationBinding.execute();
            }
    Timo
  • 2. Re: Arrange Numbers of Months into TermFrom and TermTo
    Sahar Hassan Explorer
    Currently Being Moderated
    Thanks a lot Timo.

    However, there needed to be one more line to be added:
    ////////////////////////
                operationBinding.execute();
                term = fromTerm+term;
            }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points