Package org.openswing.swing.message.receive.java

Examples of org.openswing.swing.message.receive.java.Response


      bean.setConn(conn);

      // retrieve all out delivery note rows...
      GridParams pars = new GridParams();
      pars.getOtherGridParams().put(ApplicationConsts.DELIVERY_NOTE_PK,pk);
      Response res = bean.loadOutDeliveryNoteRows(variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,pars,serverLanguageId,username);
      if (res.isError())
        throw new Exception(res.getErrorMessage());

      ArrayList values = new ArrayList();
      String sql1 =
          "select QTY,OUT_QTY from DOC02_SELLING_ITEMS where "+
          "COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and "+
          "VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
          "VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
          "VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
          "VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
          "VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? ";

      String sql2 =
          "update DOC02_SELLING_ITEMS set OUT_QTY=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where "+
          "COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and OUT_QTY=? and "+
          "VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
          "VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
          "VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
          "VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
          "VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? ";

      String sql3 =
          "update DOC01_SELLING set DOC_STATE=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where "+
          "COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and "+
          " EXISTS(SELECT DOC_TYPE FROM DOC02_SELLING_ITEMS WHERE "+
          " COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? "+
          " GROUP BY COMPANY_CODE_SYS01,DOC_TYPE,DOC_YEAR,DOC_NUMBER "+
          " HAVING SUM(QTY-OUT_QTY)=0 )"; // used to close delivery note requests documents

      pstmt1 = conn.prepareStatement(sql1);
      pstmt2 = conn.prepareStatement(sql2);
      pstmt3 = conn.prepareStatement(sql3);

      // for each item row it will be updated the related sale document row and warehouse available quantities...
      GridOutDeliveryNoteRowVO vo = null;
      ResultSet rset1 = null;
      BigDecimal qtyDOC02 = null;
      BigDecimal outQtyDOC02 = null;
      BigDecimal qtyToAdd = null;
      Response innerResponse = null;
      DetailSaleDocVO saleDocVO = null;
      for(int i=0;i<((VOListResponse)res).getRows().size();i++) {
        vo = (GridOutDeliveryNoteRowVO)((VOListResponse)res).getRows().get(i);

        // update delivery request...
        pstmt1.setString(1,vo.getCompanyCodeSys01DOC10());
        pstmt1.setString(2,vo.getDocTypeDoc01DOC10());
        pstmt1.setBigDecimal(3,vo.getDocYearDoc01DOC10());
        pstmt1.setBigDecimal(4,vo.getDocNumberDoc01DOC10());
        pstmt1.setString(5,vo.getItemCodeItm01DOC10());

        pstmt1.setString(6,vo.getVariantTypeItm06DOC10());
        pstmt1.setString(7,vo.getVariantCodeItm11DOC10());
        pstmt1.setString(8,vo.getVariantTypeItm07DOC10());
        pstmt1.setString(9,vo.getVariantCodeItm12DOC10());
        pstmt1.setString(10,vo.getVariantTypeItm08DOC10());
        pstmt1.setString(11,vo.getVariantCodeItm13DOC10());
        pstmt1.setString(12,vo.getVariantTypeItm09DOC10());
        pstmt1.setString(13,vo.getVariantCodeItm14DOC10());
        pstmt1.setString(14,vo.getVariantTypeItm10DOC10());
        pstmt1.setString(15,vo.getVariantCodeItm15DOC10());

        rset1 = pstmt1.executeQuery();
        if(rset1.next()) {
          qtyDOC02 = rset1.getBigDecimal(1);
          outQtyDOC02 = rset1.getBigDecimal(2);
          rset1.close();

          // update out qty in the sale document row...
          if (vo.getQtyDOC10().doubleValue()<qtyDOC02.subtract(outQtyDOC02).doubleValue())
            qtyToAdd = vo.getQtyDOC10();
          else
            qtyToAdd = qtyDOC02.subtract(outQtyDOC02);
          pstmt2.setBigDecimal(1,outQtyDOC02.add(qtyToAdd).setScale(vo.getDecimalsREG02().intValue(),BigDecimal.ROUND_HALF_UP));
          pstmt2.setString(2,username);
          pstmt2.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
          pstmt2.setString(4,vo.getCompanyCodeSys01DOC10());
          pstmt2.setString(5,vo.getDocTypeDoc01DOC10());
          pstmt2.setBigDecimal(6,vo.getDocYearDoc01DOC10());
          pstmt2.setBigDecimal(7,vo.getDocNumberDoc01DOC10());
          pstmt2.setString(8,vo.getItemCodeItm01DOC10());
          pstmt2.setBigDecimal(9,outQtyDOC02);

          pstmt2.setString(10,vo.getVariantTypeItm06DOC10());
          pstmt2.setString(11,vo.getVariantCodeItm11DOC10());
          pstmt2.setString(12,vo.getVariantTypeItm07DOC10());
          pstmt2.setString(13,vo.getVariantCodeItm12DOC10());
          pstmt2.setString(14,vo.getVariantTypeItm08DOC10());
          pstmt2.setString(15,vo.getVariantCodeItm13DOC10());
          pstmt2.setString(16,vo.getVariantTypeItm09DOC10());
          pstmt2.setString(17,vo.getVariantCodeItm14DOC10());
          pstmt2.setString(18,vo.getVariantTypeItm10DOC10());
          pstmt2.setString(19,vo.getVariantCodeItm15DOC10());

          if (pstmt2.executeUpdate()==0)
            throw new Exception("Updating not performed: the record was previously updated.");
        }
        else
          rset1.close();

        // close delivery note requests document...
        pstmt3.setString(1,ApplicationConsts.CLOSED);
        pstmt3.setString(2,username);
        pstmt3.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
        pstmt3.setString(4,vo.getCompanyCodeSys01DOC10());
        pstmt3.setString(5,vo.getDocTypeDoc01DOC10());
        pstmt3.setBigDecimal(6,vo.getDocYearDoc01DOC10());
        pstmt3.setBigDecimal(7,vo.getDocNumberDoc01DOC10());
        pstmt3.setString(8,vo.getCompanyCodeSys01DOC10());
        pstmt3.setString(9,vo.getDocTypeDoc01DOC10());
        pstmt3.setBigDecimal(10,vo.getDocYearDoc01DOC10());
        pstmt3.setBigDecimal(11,vo.getDocNumberDoc01DOC10());
        int processedRows = pstmt3.executeUpdate();


        // update sale document...
        if (vo.getDocTypeDoc01DOC10().equals(ApplicationConsts.DELIVERY_REQUEST_DOC_TYPE)) {
           SaleDocPK saleDocPK = new SaleDocPK(vo.getCompanyCodeSys01DOC10(),vo.getDocTypeDoc01DOC10(),vo.getDocYearDoc01DOC10(),vo.getDocNumberDoc01DOC10());

           saleDocVO = loadSaleDocBean.loadSaleDoc(
          saleDocPK,
          serverLanguageId,
          username,
          new ArrayList()
          );

          pstmt1.setString(1,saleDocVO.getCompanyCodeSys01DOC01());
          pstmt1.setString(2,saleDocVO.getDocTypeDoc01DOC01());
          pstmt1.setBigDecimal(3,saleDocVO.getDocYearDoc01DOC01());
          pstmt1.setBigDecimal(4,saleDocVO.getDocNumberDoc01DOC01());
          pstmt1.setString(5,vo.getItemCodeItm01DOC10());

          pstmt1.setString(6,vo.getVariantTypeItm06DOC10());
          pstmt1.setString(7,vo.getVariantCodeItm11DOC10());
          pstmt1.setString(8,vo.getVariantTypeItm07DOC10());
          pstmt1.setString(9,vo.getVariantCodeItm12DOC10());
          pstmt1.setString(10,vo.getVariantTypeItm08DOC10());
          pstmt1.setString(11,vo.getVariantCodeItm13DOC10());
          pstmt1.setString(12,vo.getVariantTypeItm09DOC10());
          pstmt1.setString(13,vo.getVariantCodeItm14DOC10());
          pstmt1.setString(14,vo.getVariantTypeItm10DOC10());
          pstmt1.setString(15,vo.getVariantCodeItm15DOC10());

          rset1 = pstmt1.executeQuery();
          if(rset1.next()) {
            qtyDOC02 = rset1.getBigDecimal(1);
            outQtyDOC02 = rset1.getBigDecimal(2);
            rset1.close();

            // update out qty in the sale document row...
            if (vo.getQtyDOC10().doubleValue()<qtyDOC02.subtract(outQtyDOC02).doubleValue())
              qtyToAdd = vo.getQtyDOC10();
            else
              qtyToAdd = qtyDOC02.subtract(outQtyDOC02);
            pstmt2.setBigDecimal(1,outQtyDOC02.add(qtyToAdd).setScale(vo.getDecimalsREG02().intValue(),BigDecimal.ROUND_HALF_UP));
            pstmt2.setString(2,username);
            pstmt2.setTimestamp(3,new java.sql.Timestamp(System.currentTimeMillis()));
            pstmt2.setString(4,saleDocVO.getCompanyCodeSys01DOC01());
            pstmt2.setString(5,saleDocVO.getDocTypeDoc01DOC01());
            pstmt2.setBigDecimal(6,saleDocVO.getDocYearDoc01DOC01());
            pstmt2.setBigDecimal(7,saleDocVO.getDocNumberDoc01DOC01());
            pstmt2.setString(8,vo.getItemCodeItm01DOC10());
            pstmt2.setBigDecimal(9,outQtyDOC02);

            pstmt2.setString(10,vo.getVariantTypeItm06DOC10());
            pstmt2.setString(11,vo.getVariantCodeItm11DOC10());
            pstmt2.setString(12,vo.getVariantTypeItm07DOC10());
            pstmt2.setString(13,vo.getVariantCodeItm12DOC10());
            pstmt2.setString(14,vo.getVariantTypeItm08DOC10());
            pstmt2.setString(15,vo.getVariantCodeItm13DOC10());
            pstmt2.setString(16,vo.getVariantTypeItm09DOC10());
            pstmt2.setString(17,vo.getVariantCodeItm14DOC10());
            pstmt2.setString(18,vo.getVariantTypeItm10DOC10());
            pstmt2.setString(19,vo.getVariantCodeItm15DOC10());

            if (pstmt2.executeUpdate()==0)
              throw new Exception("Updating not performed: the record was previously updated.");
          }
          else
            rset1.close();

        } // end if on deliv.req.doc.



        String motive = null;
        if (vo.getDocTypeDoc01DOC10().equals(ApplicationConsts.SALE_ORDER_DOC_TYPE))
          motive = ApplicationConsts.WAREHOUSE_MOTIVE_UNLOAD_BY_ORDER;
        else if (vo.getDocTypeDoc01DOC10().equals(ApplicationConsts.SALE_CONTRACT_DOC_TYPE))
          motive = ApplicationConsts.WAREHOUSE_MOTIVE_UNLOAD_BY_CONTRACT;
        else if (vo.getDocTypeDoc01DOC10().equals(ApplicationConsts.DELIVERY_REQUEST_DOC_TYPE))
          motive = ApplicationConsts.WAREHOUSE_MOTIVE_UNLOAD_BY_DELIV_REQ;

        // update warehouse available qty..
        WarehouseMovementVO movVO = new WarehouseMovementVO(
            vo.getProgressiveHie01DOC10(),
            vo.getQtyDOC10(),
            vo.getCompanyCodeSys01DOC10(),
            vo.getWarehouseCodeWar01DOC08(),
            vo.getItemCodeItm01DOC10(),
            motive,
            ApplicationConsts.ITEM_GOOD,
            t1+" "+vo.getDocSequenceDoc01DOC10()+"/"+vo.getDocYearDoc01DOC10(),
            vo.getSerialNumbers(),
            vo.getVariantCodeItm11DOC10(),
            vo.getVariantCodeItm12DOC10(),
            vo.getVariantCodeItm13DOC10(),
            vo.getVariantCodeItm14DOC10(),
            vo.getVariantCodeItm15DOC10(),
            vo.getVariantTypeItm06DOC10(),
            vo.getVariantTypeItm07DOC10(),
            vo.getVariantTypeItm08DOC10(),
            vo.getVariantTypeItm09DOC10(),
            vo.getVariantTypeItm10DOC10()

        );
        innerResponse = movBean.addWarehouseMovement(movVO,t2,serverLanguageId,username);

        if (innerResponse.isError())
            throw new Exception(innerResponse.getErrorMessage());
      }


      return new VOResponse(Boolean.TRUE);
    }
View Full Code Here


  }


  void buttonExecNow_actionPerformed(ActionEvent e) {
    ETLProcessVO vo = (ETLProcessVO)getMainPanel().getVOModel().getValueObject();
    Response res = ClientUtils.getData("startETLProcess",vo);
    if (res.isError()) {
      OptionPane.showMessageDialog(MDIFrame.getInstance(),res.getErrorMessage(),"Error",JOptionPane.ERROR_MESSAGE);
    }
    else {
      String[] values = ((VOResponse)res).getVo().toString().split("\n");
      String msg =
          ClientSettings.getInstance().getResources().getResource("execution time")+": "+values[0]+"s\n"+
View Full Code Here

      ServerResourcesFactory factory = (ServerResourcesFactory)context.getAttribute(Controller.RESOURCES_FACTORY);
      String serverLanguageId = ((JAIOUserSessionParameters)userSessionPars).getServerLanguageId();
      String t1 = factory.getResources(serverLanguageId).getResource("there is already another people with the same first and last name.");

      Companies bean = (Companies)JAIOBeanFactory.getInstance().getBean(Companies.class);
      Response answer = bean.updateCompany(oldVO,newVO,t1,((JAIOUserSessionParameters)userSessionPars).getServerLanguageId(),userSessionPars.getUsername());

      return answer;
    }
    catch (Throwable ex) {
      Logger.error(userSessionPars.getUsername(),this.getClass().getName(),"executeCommand","Error while processing request",ex);
View Full Code Here

    Connection conn = null;
    try {
      //conn = ConnectionManager.getConnection(context);
      conn = ConnectionManager.getConnection(null);
      // retrieve supported languages...
      Response res = langsBean.loadLanguages(null,"");
      if (res.isError())
        return;
      java.util.List langsVO = ((VOListResponse)res).getRows();

      // read from SYS24 table...
      res = fieldsBean.loadETLProcessFields(processVO.getProgressiveSYS23(),null);
      if (res.isError())
        return;
      java.util.List fieldsVO = ((VOListResponse)res).getRows();

      Response answer = bean.importData(processVO,fieldsVO,langsVO,"",null);
      if (answer.isError()) {
        conn.rollback();
        return;
      }
      conn.commit();
    }
View Full Code Here

       PreparedStatement pstmt = null;
       Connection conn = null;
       try {
         if (this.conn == null) conn = getConn(); else conn = this.conn;

          Response res = null;
         java.util.List rows = null;
         ArrayList values = new ArrayList();
         boolean itemFound = false;

         GridOutDeliveryNoteRowVO vo = new GridOutDeliveryNoteRowVO();
         vo.setCompanyCodeSys01DOC10(pk.getCompanyCodeSys01DOC01());
         vo.setDocNumberDoc01DOC10(pk.getDocNumberDOC01());
         vo.setDocNumberDOC10(delivNoteDocNumber);
         vo.setDocTypeDoc01DOC10(pk.getDocTypeDOC01());
         vo.setDocTypeDOC10(ApplicationConsts.OUT_DELIVERY_NOTE_DOC_TYPE);
         vo.setDocYearDoc01DOC10(pk.getDocYearDOC01());
         vo.setDocYearDOC10(new BigDecimal(new java.util.Date().getYear() + 1900));
         vo.setQtyDOC10(new BigDecimal(1));
         vo.setInvoiceQtyDOC10(new BigDecimal(0));
         vo.setSerialNumbers(new ArrayList());
         vo.setWarehouseCodeWar01DOC08(warehouseCode);
         vo.setProgressiveHie01DOC10(progressiveHie01DOC10); // warehouse location
         vo.setDocSequenceDoc01DOC10(docSequenceDOC01);

         if ("B".equals(codeType)) {
           // validate variants barcode...
           String sql =
               "select "+
               "ITM22_VARIANT_BARCODES.COMPANY_CODE_SYS01,ITM22_VARIANT_BARCODES.ITEM_CODE_ITM01,SYS10_COMPANY_TRANSLATIONS.DESCRIPTION,"+
               "ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM06,ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM07,ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM08,ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM09,ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM10,"+
               "ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM11,ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM12,ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM13,ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM14,ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM15,"+
               "ITM22_VARIANT_BARCODES.BAR_CODE,ITM01_ITEMS.SERIAL_NUMBER_REQUIRED,ITM01_ITEMS.PROGRESSIVE_HIE02 "+
               "from ITM22_VARIANT_BARCODES,ITM01_ITEMS,SYS10_COMPANY_TRANSLATIONS,DOC02_SELLING_ITEMS "+
               "where "+
               "ITM22_VARIANT_BARCODES.COMPANY_CODE_SYS01=? AND "+
               "ITM22_VARIANT_BARCODES.BAR_CODE=? AND "+
               "ITM22_VARIANT_BARCODES.COMPANY_CODE_SYS01=ITM01_ITEMS.COMPANY_CODE_SYS01 AND "+
               "ITM22_VARIANT_BARCODES.ITEM_CODE_ITM01=ITM01_ITEMS.ITEM_CODE and ITM01_ITEMS.ENABLED='Y' AND "+
               "ITM01_ITEMS.COMPANY_CODE_SYS01=SYS10_COMPANY_TRANSLATIONS.COMPANY_CODE_SYS01 AND "+
               "ITM01_ITEMS.PROGRESSIVE_SYS10=SYS10_COMPANY_TRANSLATIONS.PROGRESSIVE AND "+
               "SYS10_COMPANY_TRANSLATIONS.LANGUAGE_CODE=? AND "+
               "DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01=ITM22_VARIANT_BARCODES.COMPANY_CODE_SYS01 AND "+
               "DOC02_SELLING_ITEMS.DOC_TYPE=? AND "+
               "DOC02_SELLING_ITEMS.DOC_YEAR=? AND "+
               "DOC02_SELLING_ITEMS.DOC_NUMBER=? AND "+
               "DOC02_SELLING_ITEMS.QTY-DOC02_SELLING_ITEMS.OUT_QTY>0 AND "+
               "DOC02_SELLING_ITEMS.ITEM_CODE_ITM01=ITM22_VARIANT_BARCODES.ITEM_CODE_ITM01 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06=ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM06 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07=ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM07 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08=ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM08 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09=ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM09 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10=ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM10 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11=ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM11 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12=ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM12 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13=ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM13 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14=ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM14 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15=ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM15  ";

           Map attribute2dbField = new HashMap();
           attribute2dbField.put("companyCodeSys01ITM22","ITM22_VARIANT_BARCODES.COMPANY_CODE_SYS01");
           attribute2dbField.put("itemCodeItm01ITM22","ITM22_VARIANT_BARCODES.ITEM_CODE_ITM01");
           attribute2dbField.put("descriptionSYS10","SYS10_COMPANY_TRANSLATIONS.DESCRIPTION");
           attribute2dbField.put("barCodeITM22","ITM22_VARIANT_BARCODES.BAR_CODE");
           attribute2dbField.put("serialNumberRequiredITM01","ITM01_ITEMS.SERIAL_NUMBER_REQUIRED");
           attribute2dbField.put("progressiveHie02ITM01","ITM01_ITEMS.PROGRESSIVE_HIE02");

           attribute2dbField.put("variantTypeItm06ITM22","ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM06");
           attribute2dbField.put("variantCodeItm11ITM22","ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM11");
           attribute2dbField.put("variantTypeItm07ITM22","ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM07");
           attribute2dbField.put("variantCodeItm12ITM22","ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM12");
           attribute2dbField.put("variantTypeItm08ITM22","ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM08");
           attribute2dbField.put("variantCodeItm13ITM22","ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM13");
           attribute2dbField.put("variantTypeItm09ITM22","ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM09");
           attribute2dbField.put("variantCodeItm14ITM22","ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM14");
           attribute2dbField.put("variantTypeItm10ITM22","ITM22_VARIANT_BARCODES.VARIANT_TYPE_ITM10");
           attribute2dbField.put("variantCodeItm15ITM22","ITM22_VARIANT_BARCODES.VARIANT_CODE_ITM15");

           values.clear();
           values.add(pk.getCompanyCodeSys01DOC01());
           values.add(code);
           values.add(serverLanguageId);
           values.add(pk.getDocTypeDOC01());
           values.add(pk.getDocYearDOC01());
           values.add(pk.getDocNumberDOC01());

           // read from ITM01 table...
           res = QueryUtil.getQuery(
               conn,
               new UserSessionParameters(username),
               sql,
               values,
               attribute2dbField,
               VariantBarcodeVO.class,
               "Y",
               "N",
               null,
               new GridParams(),
               true
           );
           if (res.isError())
             throw new Exception(res.getErrorMessage());

           rows = ((VOListResponse)res).getRows();
           if (rows.size() == 1) {
             // found variants barcode: pre-fill code and qty in variants matrix...
             VariantBarcodeVO barcodeVO = (VariantBarcodeVO)rows.get(0);

             //vo.setInQtyDOC02();
             //vo.setDecimalsREG02();
             vo.setItemCodeItm01DOC10(barcodeVO.getItemCodeItm01ITM22());
             vo.setDescriptionSYS10(barcodeVO.getDescriptionSYS10());
             vo.setSerialNumberRequiredITM01(new Boolean("Y".equals(barcodeVO.getSerialNumberRequiredITM01())));
             vo.setProgressiveHie02DOC10(barcodeVO.getProgressiveHie02ITM01()); // item's LOB

             //vo.setQtyDOC02();
             //vo.setSupplierItemCodePur02DOC10();
             //vo.setSupplierQtyDecimalsREG02();
             //vo.setUmCodeREG02();
             //vo.setUmCodeReg02PUR02();
             //vo.setValueREG05();
             vo.setVariantCodeItm11DOC10(barcodeVO.getVariantCodeItm11ITM22());
             vo.setVariantCodeItm12DOC10(barcodeVO.getVariantCodeItm12ITM22());
             vo.setVariantCodeItm13DOC10(barcodeVO.getVariantCodeItm13ITM22());
             vo.setVariantCodeItm14DOC10(barcodeVO.getVariantCodeItm14ITM22());
             vo.setVariantCodeItm15DOC10(barcodeVO.getVariantCodeItm15ITM22());
             vo.setVariantTypeItm06DOC10(barcodeVO.getVariantTypeItm06ITM22());
             vo.setVariantTypeItm07DOC10(barcodeVO.getVariantTypeItm07ITM22());
             vo.setVariantTypeItm08DOC10(barcodeVO.getVariantTypeItm08ITM22());
             vo.setVariantTypeItm09DOC10(barcodeVO.getVariantTypeItm09ITM22());
             vo.setVariantTypeItm10DOC10(barcodeVO.getVariantTypeItm10ITM22());

             itemFound = true;
           }

           if (!itemFound) {
             // no barcode found in ITM22 (barcode for item variants)
             // trying to find a barcode at item level...
             sql =
                 "select "+
                 "ITM01_ITEMS.COMPANY_CODE_SYS01,ITM01_ITEMS.ITEM_CODE,SYS10_COMPANY_TRANSLATIONS.DESCRIPTION,"+
                 "ITM01_ITEMS.SERIAL_NUMBER_REQUIRED,ITM01_ITEMS.PROGRESSIVE_HIE02 "+
                 "from ITM01_ITEMS,SYS10_COMPANY_TRANSLATIONS,DOC02_SELLING_ITEMS where "+
                 "ITM01_ITEMS.COMPANY_CODE_SYS01=? AND "+
                 "ITM01_ITEMS.BAR_CODE=? AND "+
                 "ITM01_ITEMS.ENABLED='Y' AND "+
                 "ITM01_ITEMS.COMPANY_CODE_SYS01=SYS10_COMPANY_TRANSLATIONS.COMPANY_CODE_SYS01 AND "+
                 "ITM01_ITEMS.PROGRESSIVE_SYS10=SYS10_COMPANY_TRANSLATIONS.PROGRESSIVE AND "+
                 "SYS10_COMPANY_TRANSLATIONS.LANGUAGE_CODE=? AND "+
                 "DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01=ITM01_ITEMS.COMPANY_CODE_SYS01 AND " +
                 "DOC02_SELLING_ITEMS.DOC_TYPE=? AND " +
                 "DOC02_SELLING_ITEMS.DOC_YEAR=? AND " +
                 "DOC02_SELLING_ITEMS.DOC_NUMBER=? AND " +
                 "DOC02_SELLING_ITEMS.QTY-DOC02_SELLING_ITEMS.OUT_QTY>0 AND "+
                 "DOC02_SELLING_ITEMS.ITEM_CODE_ITM01=ITM01_ITEMS.ITEM_CODE AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14='*' AND " +
                 "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15='*' ";

             attribute2dbField.clear();
             attribute2dbField.put("companyCodeSys01ITM01","ITM01_ITEMS.COMPANY_CODE_SYS01");
             attribute2dbField.put("itemCodeITM01","ITM01_ITEMS.ITEM_CODE");
             attribute2dbField.put("descriptionSYS10","SYS10_COMPANY_TRANSLATIONS.DESCRIPTION");
             attribute2dbField.put("barCodeITM01","ITM01_ITEMS.BAR_CODE");
             attribute2dbField.put("serialNumberRequiredITM01","ITM01_ITEMS.SERIAL_NUMBER_REQUIRED");
             attribute2dbField.put("progressiveHie02ITM01","ITM01_ITEMS.PROGRESSIVE_HIE02");

             values.clear();
             values.add(pk.getCompanyCodeSys01DOC01());
             values.add(code);
             values.add(serverLanguageId);
             values.add(pk.getDocTypeDOC01());
             values.add(pk.getDocYearDOC01());
             values.add(pk.getDocNumberDOC01());

             // read from ITM01 table...
             res = QueryUtil.getQuery(
                 conn,
                 new UserSessionParameters(username),
                 sql,
                 values,
                 attribute2dbField,
                 GridItemVO.class,
                 "Y",
                 "N",
                 null,
                 new GridParams(),
                 true
             );

             if (res.isError())
               throw new Exception(res.getErrorMessage());

             rows = ( (VOListResponse) res).getRows();
             if (rows.size() == 1) {
               // found variants barcode: pre-fill code and qty in variants matrix...
               GridItemVO itemVO = (GridItemVO)rows.get(0);

               //vo.setInQtyDOC02();
               //vo.setDecimalsREG02();
               vo.setItemCodeItm01DOC10(itemVO.getItemCodeITM01());
               vo.setDescriptionSYS10(itemVO.getDescriptionSYS10());
               vo.setSerialNumberRequiredITM01(new Boolean("Y".equals(itemVO.getSerialNumberRequiredITM01())));
               vo.setProgressiveHie02DOC10(itemVO.getProgressiveHie02ITM01()); // item's LOB

               //vo.setQtyDOC02();
               //vo.setSupplierItemCodePur02DOC10();
               //vo.setSupplierQtyDecimalsREG02();
               //vo.setUmCodeREG02();
               //vo.setUmCodeReg02PUR02();
               //vo.setValueREG05();
               vo.setVariantCodeItm11DOC10(ApplicationConsts.JOLLY);
               vo.setVariantCodeItm12DOC10(ApplicationConsts.JOLLY);
               vo.setVariantCodeItm13DOC10(ApplicationConsts.JOLLY);
               vo.setVariantCodeItm14DOC10(ApplicationConsts.JOLLY);
               vo.setVariantCodeItm15DOC10(ApplicationConsts.JOLLY);
               vo.setVariantTypeItm06DOC10(ApplicationConsts.JOLLY);
               vo.setVariantTypeItm07DOC10(ApplicationConsts.JOLLY);
               vo.setVariantTypeItm08DOC10(ApplicationConsts.JOLLY);
               vo.setVariantTypeItm09DOC10(ApplicationConsts.JOLLY);
               vo.setVariantTypeItm10DOC10(ApplicationConsts.JOLLY);

               itemFound = true;
             }
           }

           if (!itemFound) {
             // no barcode found!
             return null;
           }
         }
/*
         else if ("S".equals(codeType)) {
           // search for a serial number!
           String sql =
               "select WAR05_STORED_SERIAL_NUMBERS.COMPANY_CODE_SYS01,WAR05_STORED_SERIAL_NUMBERS.SERIAL_NUMBER,"+
               "WAR05_STORED_SERIAL_NUMBERS.ITEM_CODE_ITM01,WAR05_STORED_SERIAL_NUMBERS.PROGRESSIVE_HIE01,"+
               "SYS10_COMPANY_TRANSLATIONS.DESCRIPTION,ITM01_ITEMS.SERIAL_NUMBER_REQUIRED,ITM01_ITEMS.PROGRESSIVE_HIE02,"+
               "WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM06,WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM11,"+
               "WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM07,WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM12,"+
               "WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM08,WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM13,"+
               "WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM09,WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM14,"+
               "WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM10,WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM15 "+
               "from WAR05_STORED_SERIAL_NUMBERS,ITM01_ITEMS,SYS10_COMPANY_TRANSLATIONS,DOC02_SELLING_ITEMS "+
               "where "+
               "WAR05_STORED_SERIAL_NUMBERS.COMPANY_CODE_SYS01=? and "+
               "WAR05_STORED_SERIAL_NUMBERS.SERIAL_NUMBER=? and "+
               "ITM01_ITEMS.COMPANY_CODE_SYS01=? AND "+
               "ITM01_ITEMS.ITEM_CODE=WAR05_STORED_SERIAL_NUMBERS.ITEM_CODE_ITM01 AND "+
               "ITM01_ITEMS.ENABLED='Y' AND "+
               "ITM01_ITEMS.PROGRESSIVE_SYS10=SYS10_COMPANY_TRANSLATIONS.PROGRESSIVE AND "+
               "SYS10_COMPANY_TRANSLATIONS.LANGUAGE_CODE=? AND "+
               "DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01=ITM01_ITEMS.COMPANY_CODE_SYS01 AND " +
               "DOC02_SELLING_ITEMS.DOC_TYPE=? AND " +
               "DOC02_SELLING_ITEMS.DOC_YEAR=? AND " +
               "DOC02_SELLING_ITEMS.DOC_NUMBER=? AND " +
               "DOC02_SELLING_ITEMS.ITEM_CODE_ITM01=ITM01_ITEMS.ITEM_CODE AND " +
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06=WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM06 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07=WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM07 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08=WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM08 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09=WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM09 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10=WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM10 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11=WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM11 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12=WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM12 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13=WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM13 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14=WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM14 AND "+
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15=WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM15  ";

            values.clear();
            values.add(pk.getCompanyCodeSys01DOC01());
           values.add(code);
           values.add(pk.getCompanyCodeSys01DOC01());
           values.add(serverLanguageId);
           values.add(pk.getDocTypeDOC01());
           values.add(pk.getDocYearDOC01());
           values.add(pk.getDocNumberDOC01());

           Map attribute2dbField = new HashMap();
           attribute2dbField.put("companyCodeSys01WAR05","WAR05_STORED_SERIAL_NUMBERS.COMPANY_CODE_SYS01");
           attribute2dbField.put("serialNumberWAR05","WAR05_STORED_SERIAL_NUMBERS.SERIAL_NUMBER");
           attribute2dbField.put("itemCodeItm01WAR05","WAR05_STORED_SERIAL_NUMBERS.ITEM_CODE_ITM01");
           attribute2dbField.put("progressiveHie01WAR05","WAR05_STORED_SERIAL_NUMBERS.PROGRESSIVE_HIE01");
           attribute2dbField.put("descriptionSYS10","SYS10_COMPANY_TRANSLATIONS.DESCRIPTION");
           attribute2dbField.put("serialNumberRequiredITM01","ITM01_ITEMS.SERIAL_NUMBER_REQUIRED");
           attribute2dbField.put("progressiveHie02ITM01","ITM01_ITEMS.PROGRESSIVE_HIE02");

           attribute2dbField.put("variantTypeItm06WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM06");
           attribute2dbField.put("variantCodeItm11WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM11");
           attribute2dbField.put("variantTypeItm07WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM07");
           attribute2dbField.put("variantCodeItm12WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM12");
           attribute2dbField.put("variantTypeItm08WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM08");
           attribute2dbField.put("variantCodeItm13WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM13");
           attribute2dbField.put("variantTypeItm09WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM09");
           attribute2dbField.put("variantCodeItm14WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM14");
           attribute2dbField.put("variantTypeItm10WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_TYPE_ITM10");
           attribute2dbField.put("variantCodeItm15WAR05","WAR05_STORED_SERIAL_NUMBERS.VARIANT_CODE_ITM15");

           res = QueryUtil.getQuery(
               conn,
               new UserSessionParameters(username),
               sql,
               values,
               attribute2dbField,
               StoredSerialNumberVO.class,
               "Y",
               "N",
               null,
               new GridParams(),
               true
           );

           if (res.isError())
             throw new Exception(res.getErrorMessage());

           rows = ( (VOListResponse) res).getRows();
           if (rows.size() == 1) {
              StoredSerialNumberVO sVO = (StoredSerialNumberVO)rows.get(0);

              //vo.setInQtyDOC02();
              //vo.setDecimalsREG02();
              vo.setItemCodeItm01DOC10(sVO.getItemCodeItm01WAR05());
              vo.setDescriptionSYS10(sVO.getDescriptionSYS10());
              vo.setSerialNumberRequiredITM01(new Boolean(true));
              vo.setProgressiveHie02DOC10(sVO.getProgressiveHie02ITM01()); // item's LOB

              //vo.setQtyDOC02();
              //vo.setSupplierItemCodePur02DOC10();
              //vo.setSupplierQtyDecimalsREG02();
              //vo.setUmCodeREG02();
              //vo.setUmCodeReg02PUR02();
              //vo.setValueREG05();
              vo.setVariantCodeItm11DOC10(sVO.getVariantCodeItm11WAR05());
              vo.setVariantCodeItm12DOC10(sVO.getVariantCodeItm12WAR05());
              vo.setVariantCodeItm13DOC10(sVO.getVariantCodeItm13WAR05());
              vo.setVariantCodeItm14DOC10(sVO.getVariantCodeItm14WAR05());
              vo.setVariantCodeItm15DOC10(sVO.getVariantCodeItm15WAR05());
              vo.setVariantTypeItm06DOC10(sVO.getVariantTypeItm06WAR05());
              vo.setVariantTypeItm07DOC10(sVO.getVariantTypeItm07WAR05());
              vo.setVariantTypeItm08DOC10(sVO.getVariantTypeItm08WAR05());
              vo.setVariantTypeItm09DOC10(sVO.getVariantTypeItm09WAR05());
              vo.setVariantTypeItm10DOC10(sVO.getVariantTypeItm10WAR05());
              vo.setSerialNumberRequiredITM01(Boolean.TRUE);
              vo.getSerialNumbers().add(code);

              itemFound = true;
           }

           if (!itemFound) {
             // no serial number found!
             return null;
           }
         }
*/
         else {
           // check for item code WITHOUT VARIANTS in sale doc...
           String sql =
               "select DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01,DOC02_SELLING_ITEMS.ITEM_CODE_ITM01,"+
               "SYS10_COMPANY_TRANSLATIONS.DESCRIPTION,ITM01_ITEMS.SERIAL_NUMBER_REQUIRED,DOC02_SELLING_ITEMS.PROGRESSIVE_HIE02,"+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06,DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11,"+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07,DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12,"+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08,DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13,"+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09,DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14,"+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10,DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15, "+
               "ITM01_ITEMS.NO_WAREHOUSE_MOV "+
               "from DOC02_SELLING_ITEMS,ITM01_ITEMS,SYS10_COMPANY_TRANSLATIONS where "+
               "DOC02_SELLING_ITEMS.ITEM_CODE_ITM01=ITM01_ITEMS.ITEM_CODE and "+
               "DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01=ITM01_ITEMS.COMPANY_CODE_SYS01 and "+
               "ITM01_ITEMS.COMPANY_CODE_SYS01=SYS10_COMPANY_TRANSLATIONS.COMPANY_CODE_SYS01 and "+
               "ITM01_ITEMS.PROGRESSIVE_SYS10=SYS10_COMPANY_TRANSLATIONS.PROGRESSIVE and "+
               "SYS10_COMPANY_TRANSLATIONS.LANGUAGE_CODE=? and "+
               "DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01=? and "+
               "DOC02_SELLING_ITEMS.DOC_TYPE=? and "+
               "DOC02_SELLING_ITEMS.DOC_YEAR=? and "+
               "DOC02_SELLING_ITEMS.DOC_NUMBER=? and "+
               "DOC02_SELLING_ITEMS.QTY-DOC02_SELLING_ITEMS.OUT_QTY>0 AND "+
               "DOC02_SELLING_ITEMS.ITEM_CODE_ITM01=? AND "+
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14='*' AND " +
               "DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15='*' ";

           Map attribute2dbField = new HashMap();
           attribute2dbField.put("companyCodeSys01DOC02","DOC02_SELLING_ITEMS.COMPANY_CODE_SYS01");
           attribute2dbField.put("itemCodeItm01DOC02","DOC02_SELLING_ITEMS.ITEM_CODE_ITM01");
           attribute2dbField.put("descriptionSYS10","SYS10_COMPANY_TRANSLATIONS.DESCRIPTION");
           attribute2dbField.put("serialNumberRequiredITM01","ITM01_ITEMS.SERIAL_NUMBER_REQUIRED");
           attribute2dbField.put("progressiveHie02DOC02","DOC02_SELLING_ITEMS.PROGRESSIVE_HIE02");

           attribute2dbField.put("variantTypeItm06DOC02","DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM06");
           attribute2dbField.put("variantCodeItm11DOC02","DOC02_SELLING_ITEMS.VARIANT_CODE_ITM11");
           attribute2dbField.put("variantTypeItm07DOC02","DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM07");
           attribute2dbField.put("variantCodeItm12DOC02","DOC02_SELLING_ITEMS.VARIANT_CODE_ITM12");
           attribute2dbField.put("variantTypeItm08DOC02","DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM08");
           attribute2dbField.put("variantCodeItm13DOC02","DOC02_SELLING_ITEMS.VARIANT_CODE_ITM13");
           attribute2dbField.put("variantTypeItm09DOC02","DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM09");
           attribute2dbField.put("variantCodeItm14DOC02","DOC02_SELLING_ITEMS.VARIANT_CODE_ITM14");
           attribute2dbField.put("variantTypeItm10DOC02","DOC02_SELLING_ITEMS.VARIANT_TYPE_ITM10");
           attribute2dbField.put("variantCodeItm15DOC02","DOC02_SELLING_ITEMS.VARIANT_CODE_ITM15");

           attribute2dbField.put("noWarehouseMovITM01","ITM01_ITEMS.NO_WAREHOUSE_MOV");

           values.clear();
           values.add(serverLanguageId);
           values.add(pk.getCompanyCodeSys01DOC01());
           values.add(pk.getDocTypeDOC01());
           values.add(pk.getDocYearDOC01());
           values.add(pk.getDocNumberDOC01());
           values.add(code);

           // read from DOC02 table...
           res = QueryUtil.getQuery(
               conn,
               new UserSessionParameters(username),
               sql,
               values,
               attribute2dbField,
               GridSaleDocRowVO.class,
               "Y",
               "N",
               null,
               new GridParams(),
               true
           );

           if (res.isError())
             throw new Exception(res.getErrorMessage());

           rows = ( (VOListResponse) res).getRows();
           if (rows.size() == 1) {
              GridSaleDocRowVO itemVO = (GridSaleDocRowVO)rows.get(0);

View Full Code Here

  public final Response executeCommand(Object inputPar,UserSessionParameters userSessionPars,HttpServletRequest request, HttpServletResponse response,HttpSession userSession,ServletContext context) {
    GridParams gridParams = (GridParams)inputPar;
    try {

      Subjects bean = (Subjects)JAIOBeanFactory.getInstance().getBean(Subjects.class);
      Response answer = bean.loadReferences(gridParams,((JAIOUserSessionParameters)userSessionPars).getServerLanguageId(),userSessionPars.getUsername());

      return answer;
    }
    catch (Throwable ex) {
      Logger.error(userSessionPars.getUsername(),this.getClass().getName(),"executeCommand","Error while processing request",ex);
View Full Code Here

      ArrayList values = new ArrayList();
      values.add(ApplicationConsts.IN_DELIVERY_NOTE_DOC_TYPE);

      // read from DOC08 table...
      Response answer = QueryUtil.getQuery(
          conn,
          new UserSessionParameters(username),
          sql,
          values,
          attribute2dbField,
          GridDeliveryNoteVO.class,
          "Y",
          "N",
          null,
          pars,
          blockSize,
          true
      );



      if (answer.isError()) throw new Exception(answer.getErrorMessage()); else return (VOListResponse)answer;

    }
    catch (Throwable ex) {
      Logger.error(username,this.getClass().getName(),"executeCommand","Error while fetching in delivery notes list",ex);
      throw new Exception(ex.getMessage());
View Full Code Here

//      Resources resources = factory.getResources(userSessionPars.getLanguageId());

      // retrieve all in delivery note rows...
      GridParams pars = new GridParams();
      pars.getOtherGridParams().put(ApplicationConsts.DELIVERY_NOTE_PK,pk);
      Response res = bean.loadInDeliveryNoteRows(variant1Descriptions,variant2Descriptions,variant3Descriptions,variant4Descriptions,variant5Descriptions,pars,serverLanguageId,username);
      if (res.isError())
        throw new Exception(res.getErrorMessage());

      ArrayList values = new ArrayList();
      String sql1 =
          "select QTY,IN_QTY,ORDER_QTY from DOC07_PURCHASE_ITEMS where "+
          "COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and "+
          "VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
          "VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
          "VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
          "VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
          "VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? ";

        String sql2 =
          "update DOC07_PURCHASE_ITEMS set IN_QTY=?,ORDER_QTY=?,LAST_UPDATE_USER=?,LAST_UPDATE_DATE=?  where "+
          "COMPANY_CODE_SYS01=? and DOC_TYPE=? and DOC_YEAR=? and DOC_NUMBER=? and ITEM_CODE_ITM01=? and IN_QTY=? and "+
          "VARIANT_TYPE_ITM06=? and VARIANT_CODE_ITM11=? and "+
          "VARIANT_TYPE_ITM07=? and VARIANT_CODE_ITM12=? and "+
          "VARIANT_TYPE_ITM08=? and VARIANT_CODE_ITM13=? and "+
          "VARIANT_TYPE_ITM09=? and VARIANT_CODE_ITM14=? and "+
          "VARIANT_TYPE_ITM10=? and VARIANT_CODE_ITM15=? ";

      pstmt1 = conn.prepareStatement(sql1);
      pstmt2 = conn.prepareStatement(sql2);


      // for each item row it will be updated the related purchase order row and warehouse available quantities...
      GridInDeliveryNoteRowVO vo = null;
      ResultSet rset1 = null;
      BigDecimal qtyDOC07 = null;
      BigDecimal inQtyDOC07 = null;
      BigDecimal orderQtyDOC07 = null;
      BigDecimal qtyToAdd = null;
      Response innerResponse = null;
      for(int i=0;i<((VOListResponse)res).getRows().size();i++) {
        vo = (GridInDeliveryNoteRowVO)((VOListResponse)res).getRows().get(i);
        pstmt1.setString(1,vo.getCompanyCodeSys01DOC09());
        pstmt1.setString(2,vo.getDocTypeDoc06DOC09());
        pstmt1.setBigDecimal(3,vo.getDocYearDoc06DOC09());
        pstmt1.setBigDecimal(4,vo.getDocNumberDoc06DOC09());
        pstmt1.setString(5,vo.getItemCodeItm01DOC09());

        pstmt1.setString(6,vo.getVariantTypeItm06DOC09());
        pstmt1.setString(7,vo.getVariantCodeItm11DOC09());
        pstmt1.setString(8,vo.getVariantTypeItm07DOC09());
        pstmt1.setString(9,vo.getVariantCodeItm12DOC09());
        pstmt1.setString(10,vo.getVariantTypeItm08DOC09());
        pstmt1.setString(11,vo.getVariantCodeItm13DOC09());
        pstmt1.setString(12,vo.getVariantTypeItm09DOC09());
        pstmt1.setString(13,vo.getVariantCodeItm14DOC09());
        pstmt1.setString(14,vo.getVariantTypeItm10DOC09());
        pstmt1.setString(15,vo.getVariantCodeItm15DOC09());

        rset1 = pstmt1.executeQuery();
        if(rset1.next()) {
          qtyDOC07 = rset1.getBigDecimal(1);
          inQtyDOC07 = rset1.getBigDecimal(2);
          orderQtyDOC07 = rset1.getBigDecimal(3);
          rset1.close();

          // update in qty in the purchase order row...
          if (vo.getSupplierQtyDOC09().doubleValue()<qtyDOC07.subtract(inQtyDOC07).doubleValue())
            qtyToAdd = vo.getSupplierQtyDOC09();
          else
            qtyToAdd = qtyDOC07.subtract(inQtyDOC07);

          // update order qty in the purchase order row...
          orderQtyDOC07 = orderQtyDOC07.subtract(vo.getQtyDOC09()).setScale(vo.getDecimalsREG02().intValue(),BigDecimal.ROUND_HALF_UP);
          if (orderQtyDOC07.doubleValue()<0)
            orderQtyDOC07 = new BigDecimal(0);

          pstmt2.setBigDecimal(1,inQtyDOC07.add(qtyToAdd).setScale(vo.getSupplierQtyDecimalsREG02().intValue(),BigDecimal.ROUND_HALF_UP));
          pstmt2.setBigDecimal(2,orderQtyDOC07);
          pstmt2.setString(3,username);
          pstmt2.setTimestamp(4,new java.sql.Timestamp(System.currentTimeMillis()));
          pstmt2.setString(5,vo.getCompanyCodeSys01DOC09());
          pstmt2.setString(6,vo.getDocTypeDoc06DOC09());
          pstmt2.setBigDecimal(7,vo.getDocYearDoc06DOC09());
          pstmt2.setBigDecimal(8,vo.getDocNumberDoc06DOC09());
          pstmt2.setString(9,vo.getItemCodeItm01DOC09());
          pstmt2.setBigDecimal(10,inQtyDOC07);

          pstmt2.setString(11,vo.getVariantTypeItm06DOC09());
          pstmt2.setString(12,vo.getVariantCodeItm11DOC09());
          pstmt2.setString(13,vo.getVariantTypeItm07DOC09());
          pstmt2.setString(14,vo.getVariantCodeItm12DOC09());
          pstmt2.setString(15,vo.getVariantTypeItm08DOC09());
          pstmt2.setString(16,vo.getVariantCodeItm13DOC09());
          pstmt2.setString(17,vo.getVariantTypeItm09DOC09());
          pstmt2.setString(18,vo.getVariantCodeItm14DOC09());
          pstmt2.setString(19,vo.getVariantTypeItm10DOC09());
          pstmt2.setString(20,vo.getVariantCodeItm15DOC09());

          if (pstmt2.executeUpdate()==0)
             throw new Exception("Updating not performed: the record was previously updated.");
        }
        else
          rset1.close();

        // update warehouse available qty..
        WarehouseMovementVO movVO = new WarehouseMovementVO(
            vo.getProgressiveHie01DOC09(),
            vo.getQtyDOC09(),
            vo.getCompanyCodeSys01DOC09(),
            vo.getWarehouseCodeWar01DOC08(),
            vo.getItemCodeItm01DOC09(),
            ApplicationConsts.WAREHOUSE_MOTIVE_LOAD_BY_ORDER,
            ApplicationConsts.ITEM_GOOD,
            t1+" "+vo.getDocSequenceDoc06DOC09()+"/"+vo.getDocYearDoc06DOC09(),
            vo.getSerialNumbers(),

            vo.getVariantCodeItm11DOC09(),
            vo.getVariantCodeItm12DOC09(),
            vo.getVariantCodeItm13DOC09(),
            vo.getVariantCodeItm14DOC09(),
            vo.getVariantCodeItm15DOC09(),
            vo.getVariantTypeItm06DOC09(),
            vo.getVariantTypeItm07DOC09(),
            vo.getVariantTypeItm08DOC09(),
            vo.getVariantTypeItm09DOC09(),
            vo.getVariantTypeItm10DOC09()
        );
        innerResponse = movBean.addWarehouseMovement(movVO,t2,serverLanguageId,username);

        if (innerResponse.isError())
          throw new Exception(innerResponse.getErrorMessage());
      }


      return new VOResponse(Boolean.TRUE);
    }
View Full Code Here

      CustomizedWindows cust = ((JAIOUserSessionParameters)userSessionPars).getCustomizedWindows();
      ArrayList customizedFields = cust.getCustomizedFields( new BigDecimal(202));

      String defCompanyCodeSys01SYS03 = ((JAIOUserSessionParameters)userSessionPars).getDefCompanyCodeSys01SYS03();
      Carriers bean = (Carriers)JAIOBeanFactory.getInstance().getBean(Carriers.class);
      Response answer = bean.insertCarriers(list,((JAIOUserSessionParameters)userSessionPars).getServerLanguageId(),userSessionPars.getUsername(),defCompanyCodeSys01SYS03,customizedFields);

      return answer;
    }
    catch (Throwable ex) {
      Logger.error(userSessionPars.getUsername(),this.getClass().getName(),"executeCommand","Error while processing request",ex);
View Full Code Here

      pkAttributes.add("docTypeDOC08");
      pkAttributes.add("docYearDOC08");
      pkAttributes.add("docNumberDOC08");

      // update DOC08 table...
      Response res = org.jallinone.commons.server.QueryUtilExtension.updateTable(
          conn,
          new UserSessionParameters(username),
          pkAttributes,
          oldVO,
          newVO,
          "DOC08_DELIVERY_NOTES",
          attribute2dbField,
          "Y",
          "N",
          null,
          true
      );

      Response answer = res;

      if (answer.isError()) throw new Exception(answer.getErrorMessage()); else return (VOResponse)answer;
    }
    catch (Throwable ex) {
      Logger.error(username,this.getClass().getName(),"executeCommand","Error while updating an existing in delivery note",ex);
      try {
        if (this.conn==null && conn!=null)
View Full Code Here

TOP

Related Classes of org.openswing.swing.message.receive.java.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.