Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

How to sort data in report data provider

$
0
0

i have a source code as this below :

public void processReport()
{

    QueryRun            qr;
    PurchReqTable       purchReqTable;
    PurchReqLine        purchReqLine;
    PurchLine           purchLine,lastPurchLine;
    InventTrans         inventTrans;
    InventTransOrigin   inventTransOrigin;
    
    /*SourceDocumentHeader                sourceDocumentHeader;
    WorkflowTrackingStatusTable         workflowTrackingStatusTable;
    WorkflowTrackingTable               workflowTrackingTable;
    UserInfo                            userInfo;
    WorkflowElementTable                workflowElementTable;
    WorkflowStepTable                   workflowStepTable;*/

    MK_PurchReqReportContract   contract = this.parmDataContract() as MK_PurchReqReportContract;
    utcDateTime         fromDate = DateTimeUtil::newDateTime(contract.parmFromDate(),0,DateTimeUtil::getCompanyTimeZone());
    utcDateTime         toDate = DateTimeUtil::newDateTime(contract.parmToDate(),DateTimeUtil::time(DateTimeUtil::maxValue()),DateTimeUtil::getCompanyTimeZone());

    qr = new QueryRun(this.parmQuery());
    qr.query().dataSourceTable(tableNum(PurchReqTable)).addRange(fieldNum(PurchReqTable,CreatedDateTime))
    .value(SysQuery::range(fromDate,toDate));

    while (qr.next())
    {
        purchReqTable = qr.get(tableNum(PurchReqTable));
        
        while select purchReqLine
               where purchReqLine.PurchReqTable == purchReqTable.RecId
        {
            purchLine = purchReqLine.purchLine();
            
            //tmpPurchReqReport.PurchReqDate              = DateTimeUtil::date(purchReqTable.cre);
            tmpPurchReqReport.PurchReqId                = purchReqTable.PurchReqId;
            tmpPurchReqReport.PurchReqName              = purchReqTable.PurchReqName;
            tmpPurchReqReport.PurchReqDate              = DateTimeUtil::date(purchReqTable.SubmittedDateTime);
            tmpPurchReqReport.Requester                 = purchReqLine.requisitionerName();
            tmpPurchReqReport.Preparer                  = purchReqTable.originatorName();
            tmpPurchReqReport.ItemDescription           = purchReqLine.MK_Description;
            tmpPurchReqReport.ItemId                    = purchReqLine.ItemId;
            tmpPurchReqReport.ItemName                  = purchReqLine.itemName();
            tmpPurchReqReport.PurchId                   = purchReqLine.PurchId;
            tmpPurchReqReport.PurchQty                  = purchReqLine.PurchQty;
            tmpPurchReqReport.PurchUnit                 = purchReqLine.unitOfMeasureSymbolById();
            tmpPurchReqReport.PurchPrice                = purchReqLine.PurchPrice;
            tmpPurchReqReport.CurrencyCode              = purchReqLine.CurrencyCode;
            tmpPurchReqReport.LineAmount                = purchReqLine.LineAmount;
            tmpPurchReqReport.VendAccount               = purchReqLine.VendAccount;
            tmpPurchReqReport.VendName                  = purchReqLine.vendName();
            tmpPurchReqReport.LeadTimeStd               = purchReqLine.inventTable().MK_LeadTime;

            tmpPurchReqReport.CostCenter                = MK_DimensionClass::getValueFromDefaultDimension(purchReqLine.DefaultDimension,"CostCenter");
            tmpPurchReqReport.Department                = MK_DimensionClass::getValueFromDefaultDimension(purchReqLine.DefaultDimension,"Department");
            tmpPurchReqReport.Purpose                   = MK_DimensionClass::getValueFromDefaultDimension(purchReqLine.DefaultDimension,"Purpose");
            tmpPurchReqReport.Spec                      = MK_DimensionClass::getValueFromDefaultDimension(purchReqLine.DefaultDimension,"Spec");
            tmpPurchReqReport.Spec1                     = MK_DimensionClass::getValueFromDefaultDimension(purchReqLine.DefaultDimension,"Spec1");

            this.setFieldManager(purchReqTable);
            this.setFieldSeniorManager(purchReqTable);
            this.setFieldRFQ(purchReqTable);
            this.setFieldDirector(purchReqTable);

            if(purchLine.RecId)
            {
                tmpPurchReqReport.PurchaseDate              = PurchTable::find(purchReqLine.PurchId).createDate();

                select firstOnly lastPurchLine order by RecId desc
                           where lastPurchLine.ItemId == purchLine.ItemId
                              && lastPurchLine.RecId <= purchLine.RecId
                              && lastPurchLine.PurchId != purchLine.PurchId;
                this.setFieldLastPurch(lastPurchLine);

                //first packing slip
                select firstOnly inventTrans order by RecId asc
                            join inventTransOrigin
                           where inventTransOrigin.InventTransId == purchLine.InventTransId
                              && inventTransOrigin.ReferenceId   == purchLine.PurchId
                              && inventTrans.InventTransOrigin   == inventTransOrigin.RecId
                              && inventTrans.VoucherPhysical     != "";
                this.setFieldFirstPackingSlip(inventTrans);

                tmpPurchReqReport.QtyRemain                 = purchLine.RemainPurchPhysical;
                tmpPurchReqReport.TotalQtyReceive           = purchLine.receivedInTotal();
                tmpPurchReqReport.CloseStatus               = (purchLine.RemainPurchPhysical > 0) ? "@SYS80095" : "@SYS14403";

                tmpPurchReqReport.ActualTimeProcessNeeded   = (tmpPurchReqReport.RFQAcceptDate && tmpPurchReqReport && tmpPurchReqReport.FirstReceiveDate && tmpPurchReqReport.PurchaseDate) ?
                                                               tmpPurchReqReport.RFQAcceptDate - tmpPurchReqReport.ApprovalManagerDate  + (tmpPurchReqReport.FirstReceiveDate - tmpPurchReqReport.PurchaseDate) :0;

           //    tmpPurchReqReport.ActualTimeProcessNeeded   = (tmpPurchReqReport.RFQAcceptDate && tmpPurchReqReport.ApprovalManagerDate) ?
          //                                                    tmpPurchReqReport.RFQAcceptDate - tmpPurchReqReport.ApprovalManagerDate :0;

                tmpPurchReqReport.LeadTime   = (tmpPurchReqReport.FirstReceiveDate && tmpPurchReqReport.PurchaseDate) ?  (tmpPurchReqReport.FirstReceiveDate - tmpPurchReqReport.PurchaseDate) :0;

         //       tmpPurchReqReport.LeadTimeStatus            = (tmpPurchReqReport.ActualTimeProcessNeeded <= 0) ? MK_NoneOK::None : (tmpPurchReqReport.ActualTimeProcessNeeded > tmpPurchReqReport.LeadTime) ? MK_NoneOK::NotOK : MK_NoneOK::OK;

                tmpPurchReqReport.LeadTimeStatus            = (tmpPurchReqReport.LeadTime <= 0) ? MK_NoneOK::OK : (tmpPurchReqReport.LeadTime > tmpPurchReqReport.LeadTimeStd) ? MK_NoneOK::NotOK : MK_NoneOK::OK;

                tmpPurchReqReport.PrepaymentDate            = (select firstOnly VendTrans
                                                                          where VendTrans.AccountNum  == purchLine.VendAccount
                                                                             && VendTrans.DocumentNum == purchLine.PurchId).TransDate;
                tmpPurchReqReport.PaymentDate               = PurchTable::find(purchLine.PurchId).paidDate();
            }
            else
            {
                select firstOnly lastPurchLine order by RecId desc
                           where lastPurchLine.ItemId == purchReqLine.ItemId;
                this.setFieldLastPurch(lastPurchLine);

                inventTrans.clear();
                this.setFieldFirstPackingSlip(inventTrans);

                tmpPurchReqReport.QtyRemain                 = purchReqLine.PurchQty;
                tmpPurchReqReport.TotalQtyReceive           = 0;
                tmpPurchReqReport.CloseStatus               = "@SYS80095";
                tmpPurchReqReport.LeadTimeStatus            = MK_NoneOK::OK;
                tmpPurchReqReport.PrepaymentDate            = dateNull();
                tmpPurchReqReport.PaymentDate               = dateNull();
            }
            
            
            //queryBuildDataSource.addSortField(fieldNum(custTable,AccountNum),SortOrder::Descending)
            tmpPurchReqReport.insert();
            


        }

    }


}

how to insert but order by tmpPurchReqReport.PurchReqId?

because in my program PurchReqId not list..


Viewing all articles
Browse latest Browse all 17532

Trending Articles