Pages

Banner 468 x 60px

 

Tuesday, November 21, 2017

create PR using x++

0 comments
create PR using x++ :

void clicked()
{
    PurchReqTable                   purchReqTable;
    PurchReqApprovalEventHandler    PurchReqApprovalEventHandler;
    PurchReqLine                    purchReqLine;

    // Get Procurement Category
    InventTable                     _inventTable;
    EcoResProduct                   _EcoResProduct;
    EcoResProductCategory           _EcoResProductCategory;

    // Get Clicked
    RUM_MasterProjectLines          GetClicked_RUM_MasterProjectLines;

    // Get UnitID
    EcoResProductName               _productName;
    EcoResProductTranslation        _EcoResProductTranslation;
    ;

    ttsBegin;
    purchReqTable.clear();
        purchReqTable.initValue();
        purchReqTable.PurchReqId        = NumberSeq::newGetNum(PurchReqTable::numRefPurchReqId()).num();
        purchReqTable.PurchReqName      = RUM_MasterProjectHeader.Description;
        PurchReqTable.ProjId            = RUM_MasterProjectHeader.Value;
        purchReqTable.ProjIdDataArea    = RUM_MasterProjectHeader.dataAreaId;
        PurchReqTable.RequisitionStatus = RUM_MasterProjectHeader.Status;
    purchReqTable.insert();
    ttsCommit;

     for(GetClicked_RUM_MasterProjectLines = getFirstSelection(RUM_MasterProjectLines_ds); GetClicked_RUM_MasterProjectLines; GetClicked_RUM_MasterProjectLines = RUM_MasterProjectLines_ds.getNext() )
    {
           ttsbegin;
           purchReqLine.clear();
                purchReqLine.initValue();
                purchReqLine.initFromPurchReqTable(purchReqTable);

                purchReqLine.InventDimId                      = GetClicked_RUM_MasterProjectLines.InventDimId;

                _inventTable = InventTable::find(GetClicked_RUM_MasterProjectLines.itemnumber);
                select _EcoResProduct where _EcoResProduct.RecId == _inventTable.Product;
                select _EcoResProductCategory where _EcoResProductCategory.Product == _EcoResProduct.RecId;
                select _EcoResProductTranslation where _EcoResProductTranslation.Product == _EcoResProduct.RecId;
                purchReqLine.ProcurementCategory              = _EcoResProductCategory.Category;

                purchReqLine.BuyingLegalEntity                = CompanyInfo::find().RecId;
                purchReqLine.ItemId                           = GetClicked_RUM_MasterProjectLines.ItemNumber;
                purchReqLine.InventDimIdDataArea              = curext();

                //  purchReqLine.ActivityNumber = salesLine.ActivityNumber;
                purchReqLine.DefaultDimension = RUM_MasterProjectHeader.DimensionDefault;

                purchReqLine.PurchQty                       = GetClicked_RUM_MasterProjectLines.QtyPlan;
                purchReqLine.PurchPrice                     = GetClicked_RUM_MasterProjectLines.PricePlan;
                purchReqLine.LineAmount                     = GetClicked_RUM_MasterProjectLines.QtyPlan * GetClicked_RUM_MasterProjectLines.PricePlan;
                purchReqLine.CurrencyCode                   = GetClicked_RUM_MasterProjectLines.CurrencyCode;
                PurchReqLine.RequisitionStatus              = GetClicked_RUM_MasterProjectLines.Status;
                purchReqLine.initFromInventTable(InventTable::find(GetClicked_RUM_MasterProjectLines.ItemNumber), true, false);

            purchReqLine.insert();
            ttsCommit;
    }
                if (purchReqLine.CurrencyCode != purchReqLine.orig().CurrencyCode && purchReqLine.orig().CurrencyCode)
                {
                    purchReqLine.write();
                }
                if (PurchReqWFStatusTransitionHelper::setPurchReqTable2InReview(purchReqTable.RecId))
                {
                    Workflow::activateFromWorkflowType("PurchReqReview", purchReqTable.RecId, "Auto-Submitted into workflow", false, curUserId() );
                }
                PurchReqWFStatusTransitionHelper::setPurchReqTable2Approved(purchReqTable.RecId,false);

    info(strFmt('Purchase Requisition has been created : %1', purchReqTable.PurchReqId));
}


0 comments:

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH