0
for (int l = 0; l < extractedData.size(); l++) {
                TSAMMGFSScfInvoiceData data = extractedData.get(l);
                if (DateUtil.formatDate(data.getMATDT()).equals(tomorrowDate)) {
                    BigDecimal S = null;
                    String obligatitionNumber = isNull(data.getOBLIGNUM());
                    String buyerName = isNull(data.getBUYERNAME());
                    String invoiceNumber = isNull(data.getINVNUMBER());
                    String sellerName = isNull(data.getSELLERNAME());
                    String importFileName = isNull(data.getIMPNAME());
                    String dataField_1 = isNull(data.getDATAFIELD1());
                    String dataField_2 = isNull(data.getDATAFIELD2());
                    String dataField_3 = isNull(data.getDATAFIELD3());
                    String dataField_4 = isNull(data.getDATAFIELD4());

                    reportData.append(TYPE_INVOICE).append(PIPE);
                    reportData.append(obligatitionNumber).append(PIPE);
                    reportData.append(buyerName).append(PIPE);
                    reportData.append(CURRENCY_USD).append(PIPE);

                    if (data.getINVAMT() == null) {

                        reportData.append("").append(PIPE);
                    } else {
                        reportData.append(data.getINVAMT().toString()).append(PIPE);
                    }

                    reportData.append(invoiceNumber).append(PIPE);
                    reportData.append(DateUtil.formatDate(data.getCM_MATDT(), DATE_FORMAT_MMDDYYYY_SHORT))
                            .append(PIPE);
                    reportData.append(sellerName).append(PIPE);
                    reportData.append(importFileName).append(PIPE);
                    reportData.append(dataField_1).append(PIPE);
                    reportData.append(dataField_2).append(PIPE);
                    reportData.append(dataField_3).append(PIPE);
                    reportData.append(dataField_4.replace("/", "")).append(PIPE);
                    reportData.append(presentDate).append(PIPE);
                    reportData.append(DateUtil.formatDate(currentDate, DATE_FORMAT_MMDDYYYYHHMM)).append(PIPE);
                    reportData
                            .append(DateUtil.formatDate(data.getLASTACTIVITYDTTM_CM(), DATE_FORMAT_MMDDYYYY_SHORT))
                            .append(invoiceNumber).append(PIPE);
                    reportData.append("\r\n");
                    b++;

                }
            }

I am extracting data from database. There is one column INVAMT(in the middle of the code) of BigDecimal type. I want to add all the values of INVAMT which I get once it is in if loop. How would I do that? Secondly is there a way to declare or get that value outside if loop or for loop?

Sam
  • 5
  • 4
  • Not pretty sure I understood what you're asking, but I think [this](http://stackoverflow.com/questions/1846900/addition-for-bigdecimal) might help you out! – Keews Jan 15 '16 at 15:10
  • @Keews How do I add all the values which I will get from database data.getINVAMT()? – Sam Jan 15 '16 at 15:16
  • you mean every single value in the column? – Keews Jan 15 '16 at 15:18
  • Database might have thousands of rows but I only want add to values which get excute. Like inside if loop in my case.... – Sam Jan 15 '16 at 15:21
  • @Keews Thanks...the link in your first comment gave me the solution. Appreciated – Sam Jan 15 '16 at 16:07
  • I'm glad it worked! Cheers :) – Keews Jan 18 '16 at 07:54

0 Answers0