}       //	createPO

        /// <summary>
        /// Create Requisition
        /// </summary>
        private void CreateRequisition()
        {
            int    noReqs = 0;
            String info   = "";
            //
            MRequisition requisition = null;
            MWarehouse   wh          = null;

            X_T_Replenish[] replenishs = GetReplenish(_M_WareSource);
            for (int i = 0; i < replenishs.Length; i++)
            {
                X_T_Replenish replenish = replenishs[i];
                if (wh == null || wh.GetM_Warehouse_ID() != replenish.GetM_Warehouse_ID())
                {
                    wh = MWarehouse.Get(GetCtx(), replenish.GetM_Warehouse_ID());
                }
                //
                if (requisition == null ||
                    requisition.GetM_Warehouse_ID() != replenish.GetM_Warehouse_ID())
                {
                    requisition = new MRequisition(GetCtx(), 0, Get_TrxName());
                    requisition.SetAD_User_ID(GetAD_User_ID());
                    requisition.SetC_DocType_ID(_C_DocType_ID);
                    requisition.SetDescription(Msg.GetMsg(GetCtx(), "Replenishment"));
                    //	Set Org/WH
                    int _CountDTD001 = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_MODULEINFO_ID) FROM AD_MODULEINFO WHERE PREFIX='DTD001_'"));
                    if (_CountDTD001 > 0)
                    {
                        requisition.SetDTD001_MWarehouseSource_ID(wh.GetM_WarehouseSource_ID());
                    }
                    requisition.SetAD_Org_ID(wh.GetAD_Org_ID());
                    requisition.SetM_Warehouse_ID(wh.GetM_Warehouse_ID());

                    if (!requisition.Save())
                    {
                        return;
                    }
                    _DocNo = requisition.GetDocumentNo() + ","; //dtd
                    log.Fine(requisition.ToString());
                    noReqs++;
                    info += " - " + requisition.GetDocumentNo();
                }
                //
                MRequisitionLine line = new MRequisitionLine(requisition);
                line.SetM_Product_ID(replenish.GetM_Product_ID());
                line.SetC_BPartner_ID(replenish.GetC_BPartner_ID());
                line.SetQty(replenish.GetQtyToOrder());
                line.SetPrice();
                line.Save();
            }
            _DocNo = _DocNo.Substring(0, _DocNo.Length - 1);//dtd
            _info  = "#" + noReqs + info;
            log.Info(_info);
        }       //	createRequisition
        /// <summary>
        /// Load Document Details
        /// </summary>
        /// <returns>error message or null</returns>
        public override String LoadDocumentDetails()
        {
            SetC_Currency_ID(NO_CURRENCY);
            MRequisition req = (MRequisition)GetPO();

            SetDateDoc(req.GetDateDoc());
            SetDateAcct(req.GetDateDoc());
            // Amounts
            SetAmount(AMTTYPE_Gross, req.GetTotalLines());
            SetAmount(AMTTYPE_Net, req.GetTotalLines());
            // Contained Objects
            _lines = LoadLines(req);
            // log.fine( "Lines=" + _lines.length + ", Taxes=" + m_taxes.length);
            return(null);
        }
        /// <summary>
        /// Load Requisition Lines
        /// </summary>
        /// <param name="req">requisition</param>
        /// <returns>DocLine Array</returns>
        private DocLine[] LoadLines(MRequisition req)
        {
            List <DocLine> list = new List <DocLine>();

            MRequisitionLine[] lines = req.GetLines();
            for (int i = 0; i < lines.Length; i++)
            {
                MRequisitionLine line    = lines[i];
                DocLine          docLine = new DocLine(line, this);
                Decimal          Qty     = line.GetQty();
                docLine.SetQty(Qty, false);
                //	Decimal PriceActual =
                line.GetPriceActual();
                Decimal LineNetAmt = line.GetLineNetAmt();
                docLine.SetAmount(LineNetAmt);   // DR
                list.Add(docLine);
            }
            // Return Array
            DocLine[] dls = new DocLine[list.Count];
            dls = list.ToArray();
            return(dls);
        }
        /// <summary>
        ///     Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            //	Specific
            if (_M_Requisition_ID != 0)
            {
                log.Info("M_Requisition_ID=" + _M_Requisition_ID);
                MRequisition req = new MRequisition(GetCtx(), _M_Requisition_ID, Get_TrxName());
                if (!MRequisition.DOCSTATUS_Completed.Equals(req.GetDocStatus()))
                {
                    throw new Exception("@DocStatus@ = " + req.GetDocStatus());
                }
                MRequisitionLine[] lines = req.GetLines();
                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].GetC_OrderLine_ID() == 0)
                    {
                        Process(lines[i]);
                    }
                }
                CloseOrder();
                return(Msg.GetMsg(GetCtx(), "SuccessfullyCreatedPONo. " + createdPO));
            }   //	single Requisition

            //
            log.Info("AD_Org_ID=" + _AD_Org_ID
                     + ", M_Warehouse_ID=" + _M_Warehouse_ID
                     + ", DateDoc=" + _DateDoc_From + "/" + _DateDoc_To
                     + ", DateRequired=" + _DateRequired_From + "/" + _DateRequired_To
                     + ", PriorityRule=" + _PriorityRule
                     + ", AD_User_ID=" + _AD_User_ID
                     + ", M_Product_ID=" + _M_Product_ID
                     + ", ConsolidateDocument" + _ConsolidateDocument);

            StringBuilder sql = new StringBuilder("SELECT * FROM M_RequisitionLine rl ")
                                .Append("WHERE rl.C_OrderLine_ID IS NULL");

            if (_AD_Org_ID != 0)
            {
                sql.Append(" AND AD_Org_ID=" + _AD_Org_ID);
            }
            if (_M_Product_ID != 0)
            {
                sql.Append(" AND M_Product_ID=" + _M_Product_ID);
            }
            //	Requisition Header
            sql.Append(" AND EXISTS (SELECT * FROM M_Requisition r WHERE rl.M_Requisition_ID=r.M_Requisition_ID")
            .Append(" AND r.DocStatus='CO'");
            if (_M_Warehouse_ID != 0)
            {
                sql.Append(" AND r.M_Warehouse_ID=" + _M_Warehouse_ID);
            }
            //
            if (_DateDoc_From != null && _DateDoc_To != null)
            {
                sql.Append(" AND r.DateDoc BETWEEN " + _DateDoc_From + " AND " + _DateDoc_To);
            }
            else if (_DateDoc_From != null)
            {
                sql.Append(" AND r.DateDoc =>" + _DateDoc_From);
            }
            else if (_DateDoc_To != null)
            {
                sql.Append(" AND r.DateDoc <= " + _DateDoc_To);
            }
            //
            if (_DateRequired_From != null && _DateRequired_To != null)
            {
                sql.Append(" AND r.DateRequired BETWEEN " + _DateRequired_From + " AND " + _DateRequired_To);
            }
            else if (_DateRequired_From != null)
            {
                sql.Append(" AND r.DateRequired =>" + _DateRequired_From);
            }
            else if (_DateRequired_To != null)
            {
                sql.Append(" AND r.DateRequired <=" + _DateRequired_To);
            }
            //
            if (_PriorityRule != null)
            {
                sql.Append(" AND r.PriorityRule =>" + _PriorityRule);
            }
            if (_AD_User_ID != 0)
            {
                sql.Append(" AND r.AD_User_ID=" + _AD_User_ID);
            }
            //
            sql.Append(") ORDER BY ");


            if (!_ConsolidateDocument)
            {
                sql.Append("M_Requisition_ID, ");
            }
            sql.Append("M_Product_ID, C_Charge_ID, M_AttributeSetInstance_ID");

            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql.ToString(), null, Get_TrxName());
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    Process(new MRequisitionLine(GetCtx(), dr, Get_TrxName()));
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql.ToString(), e);
            }
            finally
            {
                dt = null;
                if (idr != null)
                {
                    idr.Close();
                }
            }

            CloseOrder();
            return(Msg.GetMsg(GetCtx(), "SuccessfullyCreatedPONo. " + createdPO));
        }