Thursday, 11 August 2022

Workflow validation before submit x++ D365 CoC

 [ExtensionOf(classStr(CustFreeInvoiceWorkflow))]

final class XX_CustFreeInvoiceWorkflow_Extension

{

    public static void main(Args _args)

    {

        CustFreeInvoiceWorkflow custFreeInvoiceWorkflow = CustFreeInvoiceWorkflow::construct();

        CustInvoiceTable        custInvoiceTable;

        FormDataSource          custInvoiceTableDataSource;


        if (_args)

        {

            custInvoiceTable = _args.record();

            custInvoiceTableDataSource = FormDataUtil::getFormDataSource(custInvoiceTable);


            if(custInvoiceTable)

            {

                CustInvoiceLine     custInvoiceLine;

                MainAccountNum      mainAccountNum;

                MainAccount         mainAccount;

                

                while select custInvoiceLine where custInvoiceLine.ParentRecId == custInvoiceTable.RecId

                {

                    if(MainAccount::findByMainAccountId(LedgerDimensionFacade::getDisplayValueForLedgerDimension(custInvoiceLine.LedgerDimension)).XX_IsMandatory == true)

                    {

                        boolean         validated, contractCat, customers, projects, division, site;


                        contractCat =   XX_CustInvoiceLineDimension::getValidated(custInvoiceLine.DefaultDimension, "ContractCategory");

                        customers   =   XX_CustInvoiceLineDimension::getValidated(custInvoiceLine.DefaultDimension, "Customers");

                        projects    =   XX_CustInvoiceLineDimension::getValidated(custInvoiceLine.DefaultDimension, "Projects");

                        division    =   XX_CustInvoiceLineDimension::getValidated(custInvoiceLine.DefaultDimension, "Division");

                        site        =   XX_CustInvoiceLineDimension::getValidated(custInvoiceLine.DefaultDimension, "Site");


                        if(contractCat || customers || projects || division || site)

                        {

                            throw error("[ContractCategory, Customers, Projects, Division, Site] dimensions are mandatory in line to submit");

                        }

                    }

                }

            }

        }

        next main(_args);

    }


}

Dimension value by name x++

 public static boolean getValidated(RecId defaultDimension, Name dimName)

    {

        DimensionAttributeValueSetStorage   dimStorage;

        boolean                             hasValue;

        dimStorage  =       DimensionAttributeValueSetStorage::find(defaultDimension);

        hasValue    =       dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName(dimName).RecId)? false : True;

        return hasValue;

    }

Thursday, 4 August 2022

Unpack dimension x++

 public str unpackDimension(DimensionDefault _transDimension)

    {

        DimensionAttributeValueSetStorage           dimStorage;

        str                                         segmentName, segmentDescription;

        str                                         segmentValue = "";

        str                                         retProj;//retDept;

        boolean                                     isNullforSales;

        int                                         hierarchyCount, hierarchyIndex;

        DefaultDimensionView                        defaultDimensionView;

        RecId                                       defaultDimension;

        int                                         i;

        container                                   conAttribute;

        container                                   conValues;

        DimensionDefault                            result;

 

        defaultDimension    = _transDimension;

        dimStorage          = DimensionAttributeValueSetStorage::find(defaultDimension);

        for (i= 1 ; i<= dimStorage.elements() ; i++)

        {

            segmentName         = DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name;

            segmentValue        = dimStorage.getDisplayValueByIndex(i);

            if(segmentName)

            {

                select defaultDimensionView

            where defaultDimensionView.DefaultDimension == defaultDimension

            && defaultDimensionView.Name == segmentName;

 

                segmentDescription = defaultDimensionView.dimensionDiscription();

            }

            if(segmentName != "Projects")

            {

                continue;

            }

            else

            {

                retProj =   segmentValue;

            }

        }

        return retProj;

    }

Sunday, 3 April 2022

Unpack ledger dimension x++ D365

 class FCC_TestDim

{

    /// <summary>

    /// Runs the class with the specified arguments.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>

    public static void main(Args _args)

    {

 

        // DimensionAttributeValueCombination stores the combinations of dimension values

// Any tables that uses dimension combinations for main account and dimensions

// Has a reference to this table’s recid

DimensionAttributeValueCombination dimAttrValueComb;

        //GeneralJournalAccountEntry is one such tables that refrences DimensionAttributeValueCombination

        GeneralJournalAccountEntry gjAccEntry;

        // Class Dimension storage is used to store and manipulate the values of combination

        DimensionStorage dimensionStorage;

        // Class DimensionStorageSegment will get specfic segments based on hierarchies

        DimensionStorageSegment segment;

        int segmentCount, segmentIndex;

        int hierarchyCount, hierarchyIndex;

        str segmentName, segmentDescription,segmentValue;

        LedgerJournalTrans ledgerJournalTrans;

        ;

        select ledgerJournalTrans where ledgerJournalTrans.JournalNum == "00457";

 

        dimAttrValueComb = DimensionAttributeValueCombination::find(ledgerJournalTrans.OffsetLedgerDimension);

 

        // Get dimension storage

        dimensionStorage = DimensionStorage::findById(ledgerJournalTrans.OffsetLedgerDimension);

        if (dimensionStorage == null)

        {

            throw error("@SYS83964");

        }

 

        // Get hierarchy count

        hierarchyCount = dimensionStorage.hierarchyCount();

        //Loop through hierarchies to get individual segments

        for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)

        {

 

            //Get segment count for hierarchy

            segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);

 

            //Loop through segments and display required values

            for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)

            {

                // Get segment

                segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);

 

                // Get the segment information

                if (segment.parmDimensionAttributeValueId() != 0)

                {

                    // Get segment name

                    segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;

                    //Get segment value (id of the dimension)

                    segmentValue = segment.parmDisplayValue();

                    segmentDescription = segment.getName();

                    if(segmentName =="BusinessUnit")            //Give the Dimension Name to that Dimension Value

                    {

                        info(strFmt("%1Value -- %2Name",segmentValue,segmentDescription));

                        //return segmentDescription;

                    }

                }

            }

        }

       // return "";

    }


}

Unpack ledger dimension x++ ax2012

 static void dimValues(Args _args)

{

    DimensionAttributeValueCombination  dimAttrValueCombination;

    DimensionStorage                    dimensionStorage;

    DimensionStorageSegment             segment;

    int                                 segmentCount, segmentIndex;

    int                                 hierarchyCount, hierarchyIndex;

    str                                 segmentName, segmentDescription;

    SysDim                              segmentValue;

    DimensionHierarchy                  dimensionHierarchy;

    LedgerDimensionAccount              ledgerDimension;

    ledgerJournalTrans                  ledgerJournalTrans;

    RefRecId                            _recid;


    //select ledgerJournalTrans where ledgerJournalTrans.JournalNum == "00457";//.LedgerDimension !=0;


    ledgerDimension = _recId;//ledgerJournalTrans.OffsetLedgerDimension;

    dimAttrValueCombination = DimensionAttributeValueCombination::find(ledgerDimension);


    dimensionStorage = DimensionStorage::findById(ledgerDimension,true);


    dimensionHierarchy = DimensionStorage::getAccountStructureFromLedgerDimension(ledgerDimension);

    hierarchyCount = dimensionStorage.hierarchyCount();

    for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)

    {

        if( dimensionHierarchy.RecId == DimensionHierarchy::find(dimensionStorage.getHierarchyId(hierarchyIndex)).RecId)

        {

            segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);

            for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)

            {

                segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);

                if (segment.parmDimensionAttributeValueId() != 0)

                {

                    segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;

                    segmentValue        = segment.parmDisplayValue();

                    segmentDescription  = segment.getName();

                    

                    if(segmentName == "BusinessUnit")

                    {

                        info(strFmt("%1--%2--%3", segmentName, segmentValue, segmentDescription));

                    }

                }

            }

        }

    }

}

Financial dimension unpack & create x++

 class TEST_DefaultDimensions

{

    public DimensionDefault createDimension(container _conAttr, container _conValue)

    {

        DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();

        DimensionDefault                    result;

        int                                 i;

        DimensionAttribute                  dimensionAttribute;

        DimensionAttributeValue             dimensionAttributeValue;

        container                           conAttr     = _conAttr;

        container                           conValue    = _conValue;

        str                                 dimValue;


        for (i = 1; i <= conLen(conAttr); i++)

        {

            dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

            if (dimensionAttribute.RecId == 0)

            {

                continue;

            }

            dimValue = conPeek(conValue,i);

            if (dimValue != "")

            {

                dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);

                valueSetStorage.addItem(dimensionAttributeValue);

            }

        }

        result = valueSetStorage.save();

        return result;

    }


    public DimensionDefault unpackDimension(CustAccount _custAccount)

    {

        DimensionAttributeValueSetStorage           dimStorage;

        str                                         segmentName, segmentValue, segmentDescription;

        boolean                                     isNullforSales;

        int                                         hierarchyCount, hierarchyIndex;

        DefaultDimensionView                        defaultDimensionView;

        RecId                                       defaultDimension;

        int                                         i;

        CustTable                                   custTable = CustTable::find(_custAccount);

        container                                   conAttribute;

        container                                   conValues;

        DimensionDefault                            result;

    

        defaultDimension    = custTable.DefaultDimension;

        dimStorage          = DimensionAttributeValueSetStorage::find(defaultDimension);

        for (i= 1 ; i<= dimStorage.elements() ; i++)

        {

            segmentName         = DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name;

            segmentValue        = dimStorage.getDisplayValueByIndex(i);

            isNullforSales      = DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).TEST_IsNULLForSales;

            if(segmentName)

            {

                select defaultDimensionView

                where defaultDimensionView.DefaultDimension == defaultDimension

                && defaultDimensionView.Name == segmentName;

    

                segmentDescription = defaultDimensionView.dimensionDiscription();

            }

    

            conAttribute = conIns(conAttribute,1, segmentName);

            if(isNullforSales == true)

            {

                segmentValue = "";

            }

            conValues    = conIns(conValues,1, segmentValue);

        }

        ttsbegin;

        result = this.createDimension(conAttribute, conValues);

        ttscommit;

        return result;

    }


}

Thursday, 24 March 2022

To get Name, Value, Description of Dimension in D365 F&O

 class TST_DimValues

{

    public static void main(Args _args)

    {       

DimensionAttributeValueCombination dimAttrValueComb;

        GeneralJournalAccountEntry gjAccEntry;

        DimensionStorage dimensionStorage;

        DimensionStorageSegment segment;

        int segmentCount, segmentIndex;

        int hierarchyCount, hierarchyIndex;

        str segmentName, segmentDescription,segmentValue;

        LedgerJournalTrans ledgerJournalTrans;

        

        select ledgerJournalTrans where ledgerJournalTrans.JournalNum == "00457";


        dimAttrValueComb = DimensionAttributeValueCombination::find(ledgerJournalTrans.OffsetLedgerDimension);

        dimensionStorage = DimensionStorage::findById(ledgerJournalTrans.OffsetLedgerDimension);

        if (dimensionStorage == null)

        {

            throw error("@SYS83964");

        }

        hierarchyCount = dimensionStorage.hierarchyCount();

        for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)

        {

            segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);

            for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)

            {

                segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);

                if (segment.parmDimensionAttributeValueId() != 0)

                {

                    segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;

                    segmentValue = segment.parmDisplayValue();

                    segmentDescription = segment.getName();

                    if(segmentName =="BusinessUnit")//Give the Dimension Name to that Dimension Value

                    {

                        info(strFmt("%1---%2",segmentValue,segmentDescription));

}

                }

            }

        }

    }


}

Tuesday, 1 February 2022

PO Partial packingslip, Invoice x++ D365

class TEST_POPackingSlip

{


    public static void main(Args _args)

    {

        PurchFormLetter             purchFormLetter, purchFormLetterInvoice;

        PurchFormletterParmData     purchFormLetterParmData;

        PurchParmUpdate             purchParmUpdate;

        PurchParmTable              purchParmTable;

        PurchParmLine               purchParmLine;

        TEST_POPartialLinesTmp      poPartialLinesTmp;

        PurchId                     purchId = 'purchaseOrderNum';

        PurchTable                  purchTable = PurchTable::find(purchId);

        PurchLine                   purchLine;

        Num                         packingSlipId = purchTable.PurchId;

        boolean                     isPackingslip = false;


        ttsBegin;

        if(purchTable.DocumentState != VersioningDocumentState::Confirmed)

        {

            purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);

            purchFormLetter.update(purchTable, strFmt("%1", purchTable.PurchId));

            Info(strFmt('Purchase order confirmed %1 ', purchTable.PurchId));

        }


        //partial quantity packingslip

        try

        {

            purchFormLetterParmData = PurchFormletterParmData::newData(DocumentStatus::PackingSlip,VersioningUpdateType::Initial);

            purchFormLetterParmData.parmOnlyCreateParmUpdate(true);

            purchFormLetterParmData.createData(false);

            purchParmUpdate = purchFormLetterParmData.parmParmUpdate();


            purchParmTable.clear();

            purchParmTable.TransDate                = SystemDateGet();

            purchParmTable.Ordering                 = DocumentStatus::PackingSlip;

            purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;

            purchParmTable.Num                      = packingSlipId;

            purchParmTable.PurchId                  = purchTable.PurchId;

            purchParmTable.PurchName                = purchTable.PurchName;

            purchParmTable.DeliveryName             = purchTable.DeliveryName;

            purchParmTable.DeliveryPostalAddress    = purchTable.DeliveryPostalAddress;

            purchParmTable.OrderAccount             = purchTable.OrderAccount;

            purchParmTable.CurrencyCode             = purchTable.CurrencyCode;

            purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;

            purchParmTable.ParmId                   = purchParmUpdate.ParmId;

            purchParmTable.insert();


            while select purchLine where purchLine.PurchId == purchId//purchTable.PurchId

            {

                select poPartialLinesTmp where poPartialLinesTmp.PurchId == purchLine.purchId && poPartialLinesTmp.ItemId == purchLine.ItemId;

                if(poPartialLinesTmp)

                {

                    purchParmLine.InitFromPurchLine(purchLine);


                    purchParmLine.ReceiveNow    = poPartialLinesTmp.Qty;

                    purchParmLine.ParmId        = purchParmTable.ParmId;

                    purchParmLine.TableRefId    = purchParmTable.TableRefId;

                    purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);

                    purchParmLine.setLineAmount();

                    purchParmLine.insert();

                    isPackingslip = true;

                }

                else

                {

                    continue;

                }

                

            }

            if(isPackingslip == true)

            {

                purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);

                purchFormLetter.transDate(systemDateGet());

                purchFormLetter.proforma(false);

                purchFormLetter.specQty(PurchUpdate::All);

                purchFormLetter.purchTable(purchTable);

    

                purchFormLetter.parmParmTableNum(purchParmTable.ParmId);

                purchFormLetter.parmId(purchParmTable.ParmId);

                purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());

                purchFormLetter.run();

                

                Info(strFmt('Packingslip crated for purchase order %1', purchTable.PurchId));


                //for Invoice

                TEST_PurchInvoice purchInvoice = new TEST_PurchInvoice();

                purchInvoice.poInvoice(purchTable.PurchId);

            }

            ttsCommit;

        }

        catch

        {

            info(infolog.text());

        }


    }


}


---For Invoice


class TEST_PurchInvoice

{

    public static void main(Args _args)

    {

        TEST_PurchInvoice purchInvoice = new TEST_PurchInvoice();

        purchInvoice.poInvoice("purchId");

    }


    public void poInvoice(PurchId _purchId)

    {

        PurchFormLetter             purchFormLetter;

        PurchTable                  purchTable = PurchTable::find(_purchId);

        PurchLine                   purchLine;

        VendPackingSlipJour         vendPackingSlipJour;

        VendPackingSlipTrans        vendPackingSlipTrans;

        VendInvoiceInfoTable        vendInvoiceInfoTable;

        VendInvoiceInfoLine         vendInvoiceInfoLine;

        VendInvoiceInfoSubTable     vendInvoiceInfoSubTable;

        VendInvoiceInfoSubLine      vendInvoiceInfoSubLine;

        InvoiceId                   invoiceId;

        TransDate                   invoiceDate;

        VendInvoiceJour             vendInvoiceJour;

        InventTrans                 inventTransQty;

        str errorLog;

        boolean isInvoiced;

        InvoiceId                   invoiceIdLocal;

        

        select vendPackingSlipJour where vendPackingSlipJour.PurchId == purchTable.PurchId;

        ttsBegin;

        if(vendPackingSlipJour.PackingSlipId)

        {

            invoiceId = strFmt("INV_%1", vendPackingSlipJour.PackingSlipId);

            invoiceDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());


            purchTable = vendPackingSlipJour.purchTable();

            vendInvoiceInfoTable.clear();

            vendInvoiceInfoTable.initValue();

            vendInvoiceInfoTable.initFromPurchTable(purchTable);


            vendInvoiceInfoTable.DocumentOrigin         = DocumentOrigin::Manual;

            vendInvoiceInfoTable.CurrencyCode           = purchTable.CurrencyCode;

            vendInvoiceInfoTable.DeliveryName           = purchTable.DeliveryName;

            vendInvoiceInfoTable.Num                    = invoiceId;

            vendInvoiceInfoTable.PurchName              = purchTable.PurchName;

            vendInvoiceInfoTable.VendInvoiceSaveStatus  = VendInvoiceSaveStatus::Pending;

            vendInvoiceInfoTable.TransDate              = invoiceDate;

            vendInvoiceInfoTable.DocumentDate           = invoiceDate;

            vendInvoiceInfoTable.LastMatchVariance      = LastMatchVarianceOptions::OK;

            vendInvoiceInfoTable.ParmJobStatus          = ParmJobStatus::Waiting;

            vendInvoiceInfoTable.DefaultDimension       = vendInvoiceInfoTable.copyDimension(purchTable.DefaultDimension);

            vendInvoiceInfoTable.defaultRow(purchTable);

            vendInvoiceInfoTable.insert();


            if(vendInvoiceInfoTable)

            {

                vendInvoiceInfoSubTable.clear();

                vendInvoiceInfoSubTable.initValue();

                vendInvoiceInfoSubTable.defaultRow();

                vendInvoiceInfoSubTable.ParmId      = vendInvoiceInfoTable.ParmId;

                vendInvoiceInfoSubTable.OrigPurchId = vendInvoiceInfoTable.PurchId;

                vendInvoiceInfoSubTable.PurchName   = vendInvoiceInfoTable.PurchName;

                vendInvoiceInfoSubTable.TableRefId  = vendInvoiceInfoTable.TableRefId;


                vendInvoiceInfoSubTable.insert();

            }


            while select vendPackingSlipTrans

                where vendPackingSlipTrans.PackingSlipId == vendPackingSlipJour.PackingSlipId

                && vendPackingSlipTrans.VendPackingSlipJour == vendPackingSlipJour.RecId

            {

                purchLine = vendPackingSlipTrans.purchLine();

                vendInvoiceInfoLine.clear();

                vendInvoiceInfoLine.initValue();

                vendInvoiceInfoLine.initFromPurchLine(purchLine);


                vendInvoiceInfoLine.DeliveryName    = vendInvoiceInfoTable.DeliveryName;

                vendInvoiceInfoLine.ParmId          = vendInvoiceInfoTable.ParmId;

                vendInvoiceInfoLine.TableRefId      = vendInvoiceInfoTable.TableRefId;

                vendInvoiceInfoLine.currencyCode    = vendInvoiceInfoTable.CurrencyCode;

                vendInvoiceInfoLine.LineNum         = any2int(purchLine.LineNumber);

                vendInvoiceInfoLine.InvoiceAccount  = vendInvoiceInfoTable.InvoiceAccount;

                vendInvoiceInfoLine.InventDimId     = vendPackingSlipTrans.InventDimId;

                vendInvoiceInfoLine.OrderAccount    = vendInvoiceInfoTable.OrderAccount;

                vendInvoiceInfoLine.ItemId          = vendPackingSlipTrans.ItemId;

                vendInvoiceInfoLine.InventTransId   = vendPackingSlipTrans.InventTransId;

                vendInvoiceInfoLine.PurchPrice      = purchLine.PurchPrice;

                vendInvoiceInfoLine.InventNow       = vendInvoiceInfoLine.ReceiveNow;

                vendInvoiceInfoLine.DocumentOrigin  = DocumentOrigin::Manual;

                vendInvoiceInfoLine.ReceiveNow      = vendPackingSlipTrans.Qty;

                vendInvoiceInfoLine.modifiedReceiveNow();

                if(purchLine.PurchQty != 0)

                {

                    vendInvoiceInfoLine.LineAmount = (purchLine.LineAmount / purchLine.PurchQty) * vendInvoiceInfoLine.ReceiveNow;

                }

                vendInvoiceInfoLine.DefaultDimension = purchLine.DefaultDimension;

                vendInvoiceInfoLine.insert();


                if(vendInvoiceInfoLine.RecId)

                {

                    vendInvoiceInfoSubLine.clear();

                    vendInvoiceInfoSubLine.initValue();

                    vendInvoiceInfoSubLine.defaultRow();

                    vendInvoiceInfoSubLine.ParmId               = vendInvoiceInfoTable.ParmId;

                    vendInvoiceInfoSubLine.LineRefRecId         = vendInvoiceInfoLine.RecId;

                    vendInvoiceInfoSubLine.ReceiveNow           = vendInvoiceInfoLine.ReceiveNow;

                    vendInvoiceInfoSubLine.InventNow            = vendInvoiceInfoLine.InventNow ;

                    vendInvoiceInfoSubLine.JournalRefRecId      = vendPackingSlipTrans.RecId;

                    vendInvoiceInfoSubLine.JournalRefTableId    = vendPackingSlipTrans.TableId;

                    vendInvoiceInfoSubLine.DocumentId           = vendPackingSlipTrans.PackingSlipId;

                    vendInvoiceInfoSubLine.insert();

                }

            }

            purchFormLetter = PurchFormLetter_Invoice::newFromSavedInvoice(vendInvoiceInfoTable);

            purchFormLetter.update(vendInvoiceInfoTable.purchTable(),vendInvoiceInfoTable.Num);

        }

        ttsCommit;

        PurchTable  purchTableLocal = PurchTable::find(purchTable.PurchId);

        PurchTable  purchTableUpdate;


        if (purchTableLocal.DocumentStatus == DocumentStatus::Invoice)

        {

            info(strFmt("Purchase order invoiced %1 ",purchTableLocal.PurchId));

            isInvoiced = true;

        }

        if(isInvoiced == true)

        {

            while select vendInvoiceJour where vendInvoiceJour.PurchId == purchTable.PurchId

            {

                invoiceIdLocal += vendInvoiceJour.InvoiceId+', ';

            }

            select forupdate purchTableUpdate where purchTableUpdate.PurchId == purchTableLocal.PurchId;

            if(purchTableUpdate)

            {

                ttsbegin;

                purchTableUpdate.Invoiced = invoiceIdLocal;

                purchTableUpdate.doUpdate();

                ttscommit;

            }

        }

    }


}