Home

Thursday, August 27, 2015

List Of PO with Line details Which are confirmed more then one Ax 2012

static void som_POHistoryGreaterThen1withPurchID(Args _args)
{
 PurchTable purchTable;
    PurchLine  purchLine;
    PurchId purchase;
    VendPurchOrderJour vendPurchOrderJour;
    /////
   PurchLineAllVersions purchLineAllVersions;
   PurchTableAllVersions purchTableAllVersions;
    PurchId         pid= 'LPO-000005361';
    int counter=0;
    RecId rec;
    while select purchTable where purchTable.DocumentState == enum2int(VersioningDocumentState::Confirmed)
    {
        purchase = pid;

            rec = (select count(RecId) from vendPurchOrderJour where vendPurchOrderJour.PurchId == purchase).RecId;
            if(rec > 1)
            {

                   while select * from vendPurchOrderJour where vendPurchOrderJour.PurchId == purchase
                    {                        counter++;
                        if(counter == 1)
                        {
                    info(strFmt("---------------->Purchase Order Number :- %1, Purchase Journal = %2, Date =  %3, Amount =  %4",vendPurchOrderJour.PurchId, vendPurchOrderJour.PurchOrderDocNum, vendPurchOrderJour.PurchOrderDate, vendPurchOrderJour.Amount));
                            while select purchLineAllVersions
                               where purchLineAllVersions.PurchId == vendPurchOrderJour.PurchId
                               && purchLineAllVersions.PurchTableVersionRecId == vendPurchOrderJour.PurchTableVersion
                            {
                              info(strFmt("purchid-%1,ItemID-%2,Item Name- %3,Qty-%4 , unit Price-%5",purchLineAllVersions.purchid,purchLineAllVersions.ItemId,purchLineAllVersions.itemName(),purchLineAllVersions.PurchQty,purchLineAllVersions.PurchPrice));
                            }
                        }
                        else
                        {
                           info(strFmt("----------------------------------------------------> Purchase Journal = %1, Date =  %2, Amount =  %3",vendPurchOrderJour.PurchOrderDocNum, vendPurchOrderJour.PurchOrderDate, vendPurchOrderJour.Amount));
                            while select purchLineAllVersions
                               where purchLineAllVersions.PurchId == vendPurchOrderJour.PurchId
                               && purchLineAllVersions.PurchTableVersionRecId == vendPurchOrderJour.PurchTableVersion
                            {
                               info(strFmt("purchid-%1,ItemID-%2,Item Name- %3,Qty-%4 , unit Price-%5",purchLineAllVersions.purchid,purchLineAllVersions.ItemId,purchLineAllVersions.itemName(),purchLineAllVersions.PurchQty,purchLineAllVersions.PurchPrice));
                            }
                        }

                    }
                counter = 0;
                info("----------------------------------------------------------------");
        info("----------------------------------------------------------------");
        }

        info("*********************************************************************************************************");
    }
}

No comments:

Post a Comment