Friday, March 21, 2014

Purchase order Packing Slip query by code and DP

// Purchase order Packing Slip query by code and DP process..

static void POtrans(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;
    ItemId      itemID;
    Query query;
    QueryRun    qr;
    QueryBuildDataSource qbdsTrans,qbdsJour,qbdsTransOrgin,qbdsinventTrans;


    ;

    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("000253");

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

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


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

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

}

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...