/// <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));
        }