Friday, March 21, 2014

Test Query by X++ code

// Test Query by X++ code

static void QueryPacking(Args _args)
{
   date           _fromDate,_todate;
    #AviFiles
    SysOperationProgress progress = new SysOperationProgress();

    int i;
    boolean _unposted;
    InventTrans        inventTransactions,inventTrans;
    InventTransOrigin  inventTransOrigin;
    VendPackingSlipTrans    packingTrans;
    VendPackingSlipJour     packingJour;
    PurchTable              purchTable;
    EcoResDistinctProductVariant    ecoResDistinctProdVariant;

    //POView  poViewTable;
    InventDim inventdim;
    boolean UPDATE;

    Query query;
    QueryRun    qr;
    QueryBuildDataSource qbdsTrans,qbdsJour,qbdsTransOrgin,qbdsinventTrans;
    ItemId  itemID;
    ;

    //super();
    progress.setCaption("Purchase Report");
    progress.setAnimation(#AviUpdate);

   // delete_from poView;
   // ttsBegin;

    _fromDate = 11\10\2007;//fdate.dateValue();
    _todate   = 11\10\2007;//tDate.dateValue();
    ItemId = "9007";

    query = new Query();
    qbdsJour = query.addDataSource(tablenum(VendPackingSlipJour));
    qbdsJour.addRange(fieldnum(VendPackingSlipJour,PurchId)).value("000246");
   
    if(_fromDate && _todate)
    {
        qbdsJour.addRange(fieldnum(VendPackingSlipJour, Deliverydate)).value(SysQuery::range(_fromDate,_toDate));
    }
    qbdsTrans  = qbdsJour.addDataSource(tablenum(VendPackingSlipTrans));  
    qbdsTrans.joinMode(JoinMode::InnerJoin);
    qbdsTrans.relations(true);
    //qbdsTrans.addRange(fieldnum(VendPackingSlipTrans,OrigPurchId)).value("000246");
   
    qbdsTransOrgin = qbdsTrans.addDataSource(tablenum(inventTransOrigin));
    qbdsTransOrgin.joinMode(JoinMode::InnerJoin);
    qbdsTransOrgin.relations(true);
    qbdsTransOrgin.addLink(fieldnum(VendPackingSlipTrans, InventTransId), fieldnum(inventTransOrigin, InventTransId));

    qbdsinventTrans = qbdsTransOrgin.addDataSource(tablenum(inventTrans));
    qbdsinventTrans.joinMode(JoinMode::InnerJoin);
    qbdsinventTrans.relations(false);
    qbdsinventTrans.addLink(fieldnum(inventTrans, InventTransOrigin), fieldnum(inventTransOrigin, RecId));
   
    if(ItemId)
    {
        qbdsinventTrans.addRange(fieldnum(inventTrans, itemID)).value(ItemID);
    }

    //qbdsJour = qbdsTrans.addDataSource(tablenum(VendPackingSlipJour));
    //qbdsJour.joinMode(JoinMode::ExistsJoin);
    //qbdsJour.relations(true);
    ////qbdsJour.addLink(fieldnum(VendPackingSlipTrans, VendPackingSlipJour), fieldnum(VendPackingSlipJour, RecId));
    //qbdsJour.addRange(fieldnum(VendPackingSlipJour, PurchId)).value("000246");


    //if(_fromDate && _todate)
    //{
        //qbdsJour.addRange(fieldnum(VendPackingSlipJour, Deliverydate)).value(SysQuery::range(_fromDate,_toDate));
    //}

    //qbdsTransOrgin = qbdsTrans.addDataSource(tablenum(inventTransOrigin));
    //qbdsTransOrgin.joinMode(JoinMode::InnerJoin);
    //qbdsTransOrgin.relations(true);
    //qbdsTransOrgin.addLink(fieldnum(VendPackingSlipTrans, InventTransId), fieldnum(inventTransOrigin, InventTransId));

    //qbdsinventTrans = qbdsTransOrgin.addDataSource(tablenum(inventTrans));
    //qbdsinventTrans.joinMode(JoinMode::InnerJoin);
    //qbdsinventTrans.relations(false);
    //qbdsinventTrans.addLink(fieldnum(inventTrans, InventTransOrigin), fieldnum(inventTransOrigin, RecId));

    //if(Item.valueStr())
    //{
        //qbdsinventTrans.addRange(fieldnum(inventTrans, RetailVariantId)).value(Item.valueStr());
    //}

                    //while select * from packingTrans
                        //join packingJour where packingJour.RecId == packingTrans.VendPackingSlipJour
                        //&& packingJour.PurchId == "000246"
                        //join inventTransOrigin where inventTransOrigin.InventTransId == packingTrans.InventTransId
                    //{
                        //inventTrans = inventTrans::findByInventTransOrigin(inventTransOrigin.RecId);
                        //info(strFmt("%1,%2",packingJour.PurchId,packingTrans.ItemId));

    qr = new QueryRun(query);
    qr.prompt();

    while (qr.next())
    {
        packingTrans= qr.get(tableNum(VendPackingSlipTrans));
        packingJour =qr.get(tablenum(VendPackingSlipJour));
        inventTransOrigin= qr.get(tableNum(InventtransOrigin));
        inventTrans =qr.get(tablenum(Inventtrans));
        info(strFmt("%1,%2,%3,%4",packingJour.PurchId,packingJour.DeliveryDate,packingTrans.ItemId,inventTransOrigin.InventTransId));
    }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...